[Haskell-cafe] Template Haskell and Types

Gracjan Polak gracjan at acchsh.com
Mon Sep 12 06:08:14 EDT 2005


Hi,

Probably very simple question about template haskell: How do I make a 
type for an argument to splice? Example:

data MyData = MyData1 | MyData2

mysplice mytype =
    [| litE $ stringL $ show mytype |]

main = do
    putStrLn $(mysplice MyData)


The above is not accepted, error:

Compiling Main             ( thtest.hs, thtest.o )

thtest.hs:51:34: Not in scope: data constructor `MyData'

So how do I provide type as an argument?

Besides: documentation that I found for th is very dated. Could somebody 
point me to something more up to date about th? Thanks!

-- 
Gracjan



More information about the Haskell-Cafe mailing list