[Haskell-cafe] looking for origin of quote on preprocessors and
jmillikin at gmail.com
Wed Jan 13 17:43:04 EST 2010
Haskell doesn't *need* preprocessors, but they sure make a lot of
things easier. There are three I use regularly (c2hs, cpphs, noweb),
and each serves a purpose which isn't directly supported by plain
c2hs -- Supports generating foreign function imports and wrappers
based on C header files. This is simpler and less prone to
cross-platform type errors than writing the declarations in Haskell,
which generally requires a cpp-style #if..#else..#endif preprocessor
cpphs -- The C preprocessor, adapted to Haskell syntax. I'd like to
replace my uses of it with Template Haskell, but TH's limitation that
its splices can't be defined in the same file make it (for my
purposes) essentially useless. cpphs is text-based, which means you
can glue together pretty much anything and let the compiler verify
that it type-checks.
noweb -- True literate programming (as opposed to .lhs verbose
commenting), which allows sections of the source code to be
re-arranged arbitrarily. I suppose it's possible in theory for a
language to support this without a preprocessing step, but (to my
knowledge) not even LISP derivatives do/can.
On Thu, Jan 7, 2010 at 04:32, Johannes Waldmann
<waldmann at imn.htwk-leipzig.de> wrote:
> Dear all,
> It's not exactly Haskell-specific, but ...
> I am trying to track down the origin of the proverb
> "the existence (or: need for) a preprocessor
> shows omissions in (the design of) a language."
> I like to think that in Haskell, we don't need
> preprocessors since we can manipulate programs
> programmatically, because they are data.
> In other words, a preprocessor realizes higher order
> functions, and you only need this if your base language
> is first-order.
> Yes, that's vastly simplified, and it does not cover
> all cases, what about generic programming
> (but this can be done via Data.Data)
> and alex/happy (but we have parsec) etc etc.
> Best regards, J.W.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe