RE: template haskell printf doesn't compile...
Redirecting this to the Template Haskell mailing list Guys, can you help Alex? Simon | -----Original Message----- | From: S. Alexander Jacobson [mailto:alex@alexjacobson.com] | Sent: 03 December 2004 16:59 | To: Simon Peyton-Jones | Cc: GHC users | Subject: RE: template haskell printf doesn't compile... | | I was able to use the library documentation to get | printf to compile. But I still can't figure out | how to produce Declarations. Is there a directory | somewhere with more examples? | | Note this is being used to overhaul my relational | database code. | | -Alex- | | ______________________________________________________________ | S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com | | | | On Fri, 3 Dec 2004, Simon Peyton-Jones wrote: | | > Sorry Documentation out of date: consult the library documentation for | > up to date info. | > | > Change Expr to ExpQ | > change string to stringE | > | > | -----Original Message----- | > | From: glasgow-haskell-users-bounces@haskell.org | > [mailto:glasgow-haskell-users- | > | bounces@haskell.org] On Behalf Of S. Alexander Jacobson | > | Sent: 02 December 2004 20:21 | > | To: GHC users | > | Subject: template haskell printf doesn't compile... | > | | > | Tried to use the printf TH example described in | > | the GHC docs | > | | > | | > http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell | > .html | > | | > | Got this error: | > | | > | Chasing modules from: PrintMain.hs | > | Compiling Printf ( ./Printf.hs, ./Printf.o ) | > | | > | ./Printf.hs:23: Type constructor or class not in scope: `Expr' | > | | > | ./Printf.hs:26: Variable not in scope: `string' | > | ./Printf.hs:30: Type constructor or class not in scope: `Expr' | > | | > | Any clues? | > | | > | -Alex- | > | | > | ______________________________________________________________ | > | S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com | > | _______________________________________________ | > | Glasgow-haskell-users mailing list | > | Glasgow-haskell-users@haskell.org | > | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users | > _______________________________________________ | > Glasgow-haskell-users mailing list | > Glasgow-haskell-users@haskell.org | > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users | >
On Fri, Dec 03, 2004 at 05:03:58PM -0000, Simon Peyton-Jones wrote:
| I was able to use the library documentation to get | printf to compile. But I still can't figure out | how to produce Declarations. Is there a directory | somewhere with more examples?
There might be some in the testsuite: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/testsuite/tests/ghc-regres... and I might be able to dig up a couple of larger programs. However, I suspect your problems will be most easily solved by looking at decs reified with ghci, e.g.: $ ghci -fth [...] Prelude> :m + Language.Haskell.THSyntax Prelude Language.Haskell.THSyntax> do d <- runQ [d| f x = x |]; print d Loading package haskell98 ... linking ... done. Loading package haskell-src ... linking ... done. [FunD "f" [Clause [VarP "x'0"] (NormalB (VarE "x'0")) []]] Prelude Language.Haskell.THSyntax> Also, note that the current design doesn't allow splicing in as many places as you might like, e.g. you can't say [d| f $(my_pattern) = x |]
| Note this is being used to overhaul my relational | database code.
I'd be interested to have a look at it when it's done! Thanks Ian
participants (2)
-
Ian Lynagh -
Simon Peyton-Jones