[Haskell-cafe] Template Haskell and Types

Tomasz Zielonka tomasz.zielonka at gmail.com
Tue Sep 13 03:03:17 EDT 2005


On Mon, Sep 12, 2005 at 12:08:14PM +0200, Gracjan Polak wrote:
> 
> 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)

Cale explained how you can quote types in general. In the special case
when you simply want the Name of a type-constructor, you can use the ''
quoting syntax:

    putStrLn $(mysplice ''MyData)

Best regards
Tomasz


More information about the Haskell-Cafe mailing list