Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TemplateHaskell example

22 views
Skip to first unread message

Jeff M.

unread,
Sep 17, 2011, 11:44:07 AM9/17/11
to
I'm trying to do something specific w/ TemplateHaskell and am unsure how. Hoping someone here can just give me a simple example. I want to pass a type constructor to a template to be used in a pattern match.

$(templateFunc Foo)

templateFunc type =
do x <- newName "x"
[| case something of
($type x) -> ...
|]

I'll readily admit I don't know how to properly unquote "type" here as I'm just learning TH, but hopefully this little example gets the idea across.

Thanks for any help,

Jeff M.
0 new messages