5

Possible Duplicate:
Local variables in Template Haskell declarations

I'm trying to construct a simple Template Haskell function that, given a string like "Foo", will construct the syntax tree for data Foo = Foo.

Right now, I'm trying to do something like mkDecl name = [d|data $(conT name) = Foo|], but that's giving me the error: "Malformed head of type or class declaration: $(conT name)". Any idea what's going on?

I could just write it out using dataD and such, but I prefer this way since it'd be much clearer what's going on.

Community
  • 1
  • 1
Venge
  • 2,417
  • 16
  • 21
  • I don't understand your syntax. You can't use `data` inside a function. Also you can't put a pattern/function inside a list like that. – Wes Jul 08 '12 at 05:37
  • I'm using Template Haskell, which lets you write Haskell code that outputs Haskell code. – Venge Jul 08 '12 at 05:38
  • Ah, okay. So you're using Template Haskell. Might want to mention that in your question :P – Wes Jul 08 '12 at 05:38

0 Answers0