template-haskell

What's so bad about Template Haskell?

无人久伴 提交于 2019-11-27 08:58:13
问题 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

Preferred method for viewing code generated by Template Haskell

折月煮酒 提交于 2019-11-27 01:13:35
问题 As you know, Template Haskell is used to generate various kinds of AST splices programmatically at compile-time. However, a splice can often be very opaque, and it is often difficult to discern what a splice actually generates. If you run the Q monad for a splice, and the splice is well-typed, you get a show able representation of the generated piece of AST, but this representation can be very difficult to understand, because of its unstructured layout. What is the preferred method for