Reputation: 3953
Say I have this:
f x = x + 1
tt2 name o = sequence [valD (varP (mkName name)) (normalB [| f $(varE o) |]) []]
I'd like to convert tt2
to tt
:
tt name o = [d| ??? = f $(varE o) |]
I cannot figure out what ???
should be. This is probably because I don't understand how TH works yet. Can someone help?
Upvotes: 4
Views: 385
Reputation: 139830
You're trying to splice a name or a pattern. Unfortunately, this is not possible. Template Haskell only allows splicing expressions, types and declarations, so you're stuck with doing it manually as in your original code.
See GHC #1476 for some of the reasons why pattern splices are not allowed.
Upvotes: 2