Re: RE: template haskell printf doesn't compile...

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.template
Message-ID <[email protected]>
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-regress/th/
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.