[Haskell-cafe] generic preprocessor for haskell

Graham Klyne GK at ninebynine.org
Mon May 17 10:43:10 EDT 2004

I guess that extensible syntax is great for language experiments, but I'd 
be concerned about it becoming a common feature of production 
programming.  I have found that even the simple facility of user-defined 
operators (not including the `name` form) leads to code that is far harder 
to pick up and understand.

I hypothesize (based on my own experience) that when picking up some new 
code, a programmer relies to a considerable extent on the mnemonic 
significance of the names used in the code.  Non-mnemonic elements of the 
code must be learned and committed to memory before they can be read with 
any facility.  This suggests that user-defined syntax (and operators) run 
the risk of making the task of understanding a new program more akin to 
learning a new programing language.


At 17:49 15/05/04 +0200, Per Larsson wrote:
>I have recently made a small detour into ocaml programming and I'm rather
>impressed with the generic preprocessor 'camlp4' for ocaml. Camlp4 allows the
>programmer to (i) interact with the ocaml parser and lexer to extend the
>concrete grammar with new syntax and (ii) to directly define the translation
>of such new syntax forms in terms of ocaml abstract syntax. Haskell
>programmers (at least in GHC) can also manipulate abstract syntax with the
>Template Haskell extension and the Language.Haskell.THSyntax library, but to
>my knowing there is no haskell compiler which supports the inclusion of new
>syntax forms. Wouldn't such a tool be cool? In the haskell community there
>are a number of handmade preprocesserors (DrIFT, Generic Haskell, HaRP, ...)
>which  are both cumbersome to write, because the authors must write a
>(partial) haskell parser for every small extension, but also cumbersome to
>use because of increasing complexity to your makefiles and different
>standards for error reporting. Also, experimental extensions could quickly be
>written and evaluated by the haskell users, decreasing the dependency on the
>compiler maintainers.
>Per Larsson
>Haskell-Cafe mailing list
>Haskell-Cafe at haskell.org

Graham Klyne
For email:

More information about the Haskell-Cafe mailing list