[Template-haskell] Big TH commit
Simon Peyton-Jones
simonpj at microsoft.com
Thu Nov 6 17:19:08 EST 2003
OK, I've committed the new TH stuff. There is still more to do, but
lots of stuff works that didn't before (summarised below).
One thing that's a bit "off" at the moment is that I'm using the type
checker's own monad to generate uniques for TH. As a result, if you
print out the TH-generated code, you get stuff like
data TH_reifyDecl1.R a_1627393116 = TH_reifyDecl1.C a_1627393116
Now there's nothing wrong with this, but it might make sense for the
pretty-printer (now in THLib) to clean it up.
I'm hoping that Ian or someone will do that task -- it's quite clearly
separated.
Meanwhile, please do beat on this new stuff. It's really a big step
forward I think.
Simon
-----Original Message-----
From: cvs-all-bounces at haskell.org [mailto:cvs-all-bounces at haskell.org]
On Behalf Of Simon Peyton Jones
Sent: 06 November 2003 17:10
To: cvs-ghc at haskell.org; cvs-fptools at haskell.org;
cvs-libraries at haskell.org
Subject: cvs commit: fptools/ghc/compiler/basicTypes Name.lhs
OccName.lhs RdrName.lhs UniqSupply.lhs Unique.lhs Var.lhs
fptools/ghc/compiler/deSugar DsExpr.lhs DsForeign.lhs DsMeta.hs
DsMonad.lhs fptools/ghc/compiler/hsSyn Convert.lhs HsExpr.lhs ...
simonpj 2003/11/06 09:10:01 PST
Modified files:
ghc/compiler/basicTypes Name.lhs OccName.lhs RdrName.lhs
UniqSupply.lhs Unique.lhs Var.lhs
ghc/compiler/deSugar DsExpr.lhs DsForeign.lhs DsMeta.hs
DsMonad.lhs
ghc/compiler/hsSyn Convert.lhs HsExpr.lhs
ghc/compiler/iface LoadIface.lhs
ghc/compiler/main ErrUtils.lhs
ghc/compiler/parser Lexer.x Parser.y
ghc/compiler/prelude PrelNames.lhs
ghc/compiler/rename RnEnv.lhs RnExpr.lhs RnSource.lhs
ghc/compiler/typecheck TcClassDcl.lhs TcExpr.lhs TcHsSyn.lhs
TcHsType.lhs TcRnDriver.lhs
TcRnMonad.lhs TcSplice.lhs TcUnify.lhs
ghc/compiler/utils UniqFM.lhs
testsuite/tests/ghc-regress/th TH_bracket3.hs TH_reifyDecl1.hs
TH_reifyType1.hs
TH_reifyType2.hs TH_repE1.hs
TH_repE2.hs TH_repE3.hs
TH_repPrim.hs TH_repPrim.stderr
TH_repPrimOutput.hs
TH_spliceDecl1.hs
TH_spliceDecl2.hs
TH_spliceDecl3.hs
TH_spliceDecl3_Lib.hs
TH_spliceE3.hs
TH_spliceExpr1.hs all.T
libraries/haskell-src Makefile
Added files:
testsuite/tests/ghc-regress/th TH_reifyDecl1.stderr
TH_spliceE1.hs
TH_spliceE1.stdout
libraries/haskell-src/Language/Haskell TH.hs
libraries/haskell-src/Language/Haskell/TH THLib.hs THSyntax.hs
Removed files:
testsuite/tests/ghc-regress/th TH_reifyDecl2.hs
TH_reifyDecl3.hs
TH_reifyDecl4.hs
libraries/haskell-src/Language/Haskell THSyntax.hs
Log:
------------------------------------
Major increment for Template Haskell
------------------------------------
1. New abstract data type "Name" which appears where String used to
be.
E.g. data Exp = VarE Name | ...
2. New syntax 'x and ''T, for quoting Names. It's rather like [| x
|]
and [t| T |] respectively, except that
a) it's non-monadic: 'x :: Name
b) you get a Name not an Exp or Type
3. reify is an ordinary function
reify :: Name -> Q Info
New data type Info which tells what TH knows about Name
4. Local variables work properly. So this works now (crashed
before):
f x = $( [| x |] )
5. THSyntax is split up into three modules:
Language.Haskell.TH TH "clients" import this
Language.Haskell.TH.THSyntax data type declarations and
internal stuff
Language.Haskell.TH.THLib Support library code (all re-exported
by TH), including smart constructors and
pretty printer
6. Error reporting and recovery are in (not yet well tested)
report :: Bool {- True <=> fatal -} -> String -> Q ()
recover :: Q a -> Q a -> Q a
7. Can find current module
currentModule :: Q String
Much other cleaning up, needless to say.
Revision Changes Path
1.107 +1 -1 fptools/ghc/compiler/basicTypes/Name.lhs
1.56 +10 -4 fptools/ghc/compiler/basicTypes/OccName.lhs
1.26 +3 -3 fptools/ghc/compiler/basicTypes/RdrName.lhs
1.32 +2 -2 fptools/ghc/compiler/basicTypes/UniqSupply.lhs
1.69 +11 -8 fptools/ghc/compiler/basicTypes/Unique.lhs
1.33 +8 -8 fptools/ghc/compiler/basicTypes/Var.lhs
1.103 +1 -2 fptools/ghc/compiler/deSugar/DsExpr.lhs
1.81 +2 -2 fptools/ghc/compiler/deSugar/DsForeign.lhs
1.48 +318 -296 fptools/ghc/compiler/deSugar/DsMeta.hs
1.51 +4 -2 fptools/ghc/compiler/deSugar/DsMonad.lhs
1.41 +79 -74 fptools/ghc/compiler/hsSyn/Convert.lhs
1.88 +0 -19 fptools/ghc/compiler/hsSyn/HsExpr.lhs
1.5 +1 -1 fptools/ghc/compiler/iface/LoadIface.lhs
1.42 +2 -10 fptools/ghc/compiler/main/ErrUtils.lhs
1.15 +61 -31 fptools/ghc/compiler/parser/Lexer.x
1.129 +9 -13 fptools/ghc/compiler/parser/Parser.y
1.83 +0 -3 fptools/ghc/compiler/prelude/PrelNames.lhs
1.171 +18 -22 fptools/ghc/compiler/rename/RnEnv.lhs
1.125 +2 -6 fptools/ghc/compiler/rename/RnExpr.lhs
1.162 +3 -0 fptools/ghc/compiler/rename/RnSource.lhs
1.137 +1 -1 fptools/ghc/compiler/typecheck/TcClassDcl.lhs
1.161 +0 -12 fptools/ghc/compiler/typecheck/TcExpr.lhs
1.94 +0 -2 fptools/ghc/compiler/typecheck/TcHsSyn.lhs
1.7 +1 -3 fptools/ghc/compiler/typecheck/TcHsType.lhs
1.53 +1 -0 fptools/ghc/compiler/typecheck/TcRnDriver.lhs
1.28 +5 -2 fptools/ghc/compiler/typecheck/TcRnMonad.lhs
1.28 +232 -120 fptools/ghc/compiler/typecheck/TcSplice.lhs
1.52 +1 -1 fptools/ghc/compiler/typecheck/TcUnify.lhs
1.37 +16 -16 fptools/ghc/compiler/utils/UniqFM.lhs
1.2 +1 -0
fptools/testsuite/tests/ghc-regress/th/TH_bracket3.hs
1.4 +30 -14
fptools/testsuite/tests/ghc-regress/th/TH_reifyDecl1.hs
1.4 +3 -3
fptools/testsuite/tests/ghc-regress/th/TH_reifyType1.hs
1.4 +3 -3
fptools/testsuite/tests/ghc-regress/th/TH_reifyType2.hs
1.3 +1 -1
fptools/testsuite/tests/ghc-regress/th/TH_repE1.hs
1.2 +1 -1
fptools/testsuite/tests/ghc-regress/th/TH_repE2.hs
1.2 +1 -1
fptools/testsuite/tests/ghc-regress/th/TH_repE3.hs
1.4 +11 -12
fptools/testsuite/tests/ghc-regress/th/TH_repPrim.hs
1.4 +6 -6
fptools/testsuite/tests/ghc-regress/th/TH_repPrim.stderr
1.5 +2 -10
fptools/testsuite/tests/ghc-regress/th/TH_repPrimOutput.hs
1.5 +2 -2
fptools/testsuite/tests/ghc-regress/th/TH_spliceDecl1.hs
1.3 +1 -2
fptools/testsuite/tests/ghc-regress/th/TH_spliceDecl2.hs
1.3 +2 -2
fptools/testsuite/tests/ghc-regress/th/TH_spliceDecl3.hs
1.5 +4 -4
fptools/testsuite/tests/ghc-regress/th/TH_spliceDecl3_Lib.hs
1.2 +1 -1
fptools/testsuite/tests/ghc-regress/th/TH_spliceE3.hs
1.3 +1 -1
fptools/testsuite/tests/ghc-regress/th/TH_spliceExpr1.hs
1.15 +3 -4 fptools/testsuite/tests/ghc-regress/th/all.T
1.9 +2 -2 fptools/libraries/haskell-src/Makefile
_______________________________________________
Cvs-libraries mailing list
Cvs-libraries at haskell.org
http://www.haskell.org/mailman/listinfo/cvs-libraries
More information about the template-haskell
mailing list