[Haskell-cafe] ANN: Wheb -- A WAI framework

Kyle Hanson hanooter at gmail.com
Sat Feb 8 03:43:45 UTC 2014


Hi Luke!

I can tell you why I didn't want to include TH.

You are correct that TH does have many benefits and does indeed make a lot
of things easier in Haskell. However, easier does not always mean more
understandable.

Haskell has a pretty steep learning curve. Just learning the core Haskell98
is pretty difficult to grasp for a beginner. Adding TH haskell on top of
that is bad news. There is an inherit disconnect between a template haskell
function and the code it generates, because you can't see it. Type
signatures in Haskell provide much more than hints to the compiler about
types, they are also a good source of documentation. That is why I hate TH
functions. Take for example Yesod's mkYesod type signature:

*mkYesod :: String -> [Resource String] -> Q [Dec]*

That doesn't give me any information about what to expect as a result.
About the only way to know how to use this function is to find examples of
it or start digging into the code. It would probably help some if it were
standard practice for package maintainers to put the expected
type-signatures along with the TH functions.

Another problem that I see is that TH is not that discoverable. I would
wager that most Haskell users know how to use Template Haskell functions
but not how to implement them. TH is a sort of black box if you are
beginner where you can't look at the source code for a TH function because
once you look under the hood, it a bunch of VarTs, ConsTs, Decs.

--
Kyle Hanson


On Fri, Feb 7, 2014 at 5:13 PM, Luke Clifton <ltclifton at gmail.com> wrote:

>
> > I was rather frustrated with the use of Template Haskell as the main
> entry point for the big framework projects (Yesod, Snap, etc.)
>
> Perhaps slightly off topic, but can someone outline why Template Haskell
> has so much negativity?
>
> I've used Yesod a bit, and from my limited experience, the TH does a good
> job at removing a lot of boilerplate code, while still keeping things
> readable and type safe.
>
> The main negatives I see are somewhat complicated error messages if you
> make a mistake, but the issue is usually pretty easy to spot because the TH
> is pretty simple.
>
> Is portability an issue? How do the other Haskell compilers go with it?
>
> Not to detract from your work, I think it's great to have options! I'm
> just curious.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140207/f6a87a0c/attachment.html>


More information about the Haskell-Cafe mailing list