Possible duplicate:
Local variables in Haskell template declarations
I am trying to build a simple Template Haskell function that, given a string like "Foo", will build a syntax tree for data Foo = Foo.
Now I'm trying to do something like this mkDecl name = [d|data $(conT name) = Foo|], but it gives me an error: "Malformed head type or class declaration: $ (conT name)". Any idea what is going on?
I could just write this using dataD, etc., but I prefer this way, since it would be much clearer what is going on.
source
share