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

Eike M. Scholz at gmx.de eikescholz at gmx.de
Mon Jun 6 18:10:28 EDT 2005


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

More information about the Haskell mailing list