What’s so bad about Template Haskell?

It seems that Template Haskell is often viewed by the Haskell community as an unfortunate convenience. It’s hard to put into words exactly what I have observed in this regard, but consider these few examples

  • Template Haskell listed under “The Ugly (but necessary)” in response to the question Which Haskell (GHC) extensions should users use/avoid?
  • Template Haskell considered a temporary/inferior solution in Unboxed Vectors of newtype’d values thread (libraries mailing list)
  • Yesod is often criticized for relying too much on Template Haskell (see the blog post in response to this sentiment)

I’ve seen various blog posts where people do pretty neat stuff with Template Haskell, enabling prettier syntax that simply wouldn’t be possible in regular Haskell, as well as tremendous boilerplate reduction. So why is it that Template Haskell is looked down upon in this way? What makes it undesirable? Under what circumstances should Template Haskell be avoided, and why?

6 Answers
6

Leave a Comment