When is the TemplateHaskell extension required in libraries providing TH deriving functions?

89 Views Asked by At

I was under the impression that using functions of type :: Name -> Q [Dec] had to be wrapped in a splice with the TemplateHaskell extension turned on, as e.g. documented in aeson:

$(deriveJSON defaultOptions ''(,,,))

But I just noticed the lens docs show using these TH functions without a splice (or TemplateHaskell), and I just tried it in a library I'm working on and it seems to work fine, even with something like this at the top level:

fmap concat $ forM [''X , ''Y , ''Z ] deriveFoo

Yet after making those modifications (removing from splice and removing pragma), I'm getting this error, unless I put a extensions: TemplateHaskell line in the test-suite block, which I don't really understand.

So is the splice thing a myth? And if so, then why do I need TemplateHaskell in an extensions list for the test-suite?

0

There are 0 best solutions below