[Haskell-cafe] Most Important GHC extensions to learn/use?
wren ng thornton
wren at freegeek.org
Fri Jun 1 23:22:26 CEST 2012
On 6/1/12 12:45 AM, Jonathan Geddes wrote:
> Thanks, Wren, I really appreciate the detailed response! Though I am
> surprised that Template Haskell isn't on your list. From the little I know
> of TH it seems like all of the interesting generic/generative stuff is done
> with TH. Do the other extensions subsume the need for TH, or is it just not
> terribly interesting?
TH is plenty interesting, but it's a very different sort of direction to
head. The extensions I mentioned are the ones I think everyone assumes a
seasoned Haskeller will know. With the exception of TFs and GADTs, those
extensions have all been around since the days of GHC 6.6 and Hugs. Thus,
most people consider them normal parts of "Haskell" even if they're not in
in the Report. Consequently, understanding them is necessary to understand
most of the non-H98 code on Hackage.
TH, on the other hand, is very much GHC-only and that's unlikely to
change. Also, there's a lot of unnecessary(?) grunge there. The basic
theory of staged computation which led to TH was laid out in the
MetaML/MetaOCaml papers. The version in MetaML is a lot nicer in terms of
the theory, so I'd suggest people start there before diving into TH. One
of the nice things in MetaML is that there's no limit on the levels of
meta-ness. This was removed from TH because it would require having the
compiler present in every executable; a sensible limitation, though it
complicates the theory. Another major difference is that MetaML only did
staging at the term level, whereas TH also allows splices in type
signatures, splices which generate type class instances, etc. These
extensions make TH *much* more powerful than MetaML, but also make it
*much* harder to understand and reason about. IMO the formal theory of
these non-term splices hasn't been worked out very well, which is part of
the reason why TH is so grungy to work with.
I'm a big fan of staged computation, and I'd definitely suggest any
sophisticated functional programmer should read the MetaML papers (and the
TH papers if so inclined, and the Flask papers to get a different
perspective on the theme). But very few packages require understanding TH
in order to understand them, and even fewer require understanding TH in
order to use them.
More information about the Haskell-Cafe