[Haskell] Template Haskell Question: Spliced expr. of type TypeQ

Simon Peyton-Jones simonpj at microsoft.com
Tue Jun 7 04:16:51 EDT 2005


[Redirecting to GHC users]

I'm afraid I never got around to implementing splices in types, I'm
afraid.  Interestingly, you are the first person who's asked for them.
I forget the details... it's not a massive job to implement them, but
not trivial either.  If this is important for other people too, feel
free to let me know.

Simon

| -----Original Message-----
| From: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org]
On Behalf Of Eike M.
| Scholz at gmx.de
| Sent: 06 June 2005 23:10
| To: haskell at haskell.org
| Subject: [Haskell] Template Haskell Question: Spliced expr. of type
TypeQ
| 
| Hi,
| 
| maybe someone can help me with this:
| 
| I was wandering if I could do something similar to Depended Types
| using Template-Haskell. The documentation of GHC (6.2.2 and
| 6.4) says that a splice may occur in place of a type, but I
| get a parse error when I try that.
| 
| So here is what I did:
| 
| made a Module Templates:
| 
|     module Templates where
| 
|     expr  = [| 1337*7331 |]
|     decl  = [d| hello = putStr "Hello\n"|]
|     ty    = [t| Int |]
| 
| 
| and made test file:
| 
|     import Templates
| 
|     $(decl)  -- works well (tested with ghci)
| 
|     e = $(expr) -- works also well
| 
|     i :: ($tyr) -- gives a parse error
|     i = 1
| 
| 
| I would be really happy if someone knows how to make the last example
| must be written, or if that works at all. (If not, maybe the
| Documentation should get updated)
| 
| and thanks you for reading this posting, anyway.
| 
| -- Eike
| 
| _______________________________________________
| Haskell mailing list
| Haskell at haskell.org
| http://www.haskell.org/mailman/listinfo/haskell


More information about the Glasgow-haskell-users mailing list