[Haskell-cafe] Wow Monads!

Richard A. O'Keefe ok at cs.otago.ac.nz
Wed Apr 19 10:20:57 UTC 2017

> On 19/04/2017, at 7:08 PM, Joachim Durchholz <jo at durchholz.org> wrote:
>> Too powerful for whom?
> Too powerful for teams that include sub-average programmers (by definition, you always have a sub-average one on the team).
> The issue is that you don't have enough brilliant developers to staff all the projects in the world, so you need technology that gives consistent results, much more than technology that boosts productivity but is inconsistent.

To keep this relevant to Haskell, Template Haskell is roughly
analogous to Lisp macros.  It works on syntactically well-formed
fragments.  It is normally hygienic, like Scheme, but permits
quite complex transformations, like Lisp.  And macros in Lisp
and Scheme have traditionally been used to develop embedded DSLs,
which is something Haskell programmers sometimes do.  Template
Haskell can of course do amazing things that Lisp and Scheme cannot.

There are at least two claims here.
- using (not developing, just using) macros requires "brilliant developers"
- using (not developing, just using) macros "gives inconsistent results".

I am willing to concede that *writing* Lisp macros requires particularly
good programmers (because the 'implementation language' of Lisp macros
has the full power of Lisp) and that *writing* Scheme macros requires
particularly good programmers (because the 'implementation language'
of Scheme macros *isn't* Scheme but tree-to-tree rewrite rules).  In
particular, I am not yet competent to write any Scheme macro whose
implementation requires recursion, so since I'm a brilliant programmer,
people who can do that must be geniuses, eh?

It does not follow that *using* macros is any harder than using any
special form pre-defined by the language, and as a matter of fact,
it isn't.  In Scheme, logical conjunction (AND) and disjunction (OR)
are in principle defined as macros.  That doesn't make them hard to
use, error-prone to use, or in any way inconsistent.

(And yes, I *have* struggled with macros in UCI Lisp and InterLisp.
Modern Lisp is not your grandfather's Lisp any more than
modern Scheme is your grandfather's Scheme or
modern Fortran your grandfather's Fortran.  And yep, there's a
Fortran preprocessor, fpp, modelled on cpp but adapted to Fortran.
Not standard, but freely available.  And it hasn't caused the
death of Fortran yet, any more than CPP has killed Haskell.)


More information about the Haskell-Cafe mailing list