[Haskell-cafe] OT: Monad co-tutorial: the Compilation Monad

Gregg Reynolds dev at mobileink.com
Fri Dec 17 01:59:19 CET 2010


This is a little off-topic, since it isn't specifically about Haskell, but
since Haskell is the home of the monad tutorial it isn't completely
irrelevant.  The monad tutorial genre is well-known; it's often written
somebody who has just learned the concept trying to explain it, often in
highly imaginative terms (e.g. "a monad is just like a giant squid, with
special tentacles").  I propose "monad co-tutorial" for attempts, often by
an amateur (e.g. me) to work out how a monad appears in an unexpected place.


In particular, I recently suffered through a few days of learning to deal
with Ant and Maven2, which got me thinking about build systems in general,
which got me thinking about the (meta-)language used in such systems, which
got me thinking about What It's Really All About.

Lo and behold - a monad!  I think, anyway.  The basic idea is that program
texts (source or object code) are to programs as sentences are to
propositions.  Compilation transforms one representation into another.  This
can be viewed in terms of the unit natural transformation of a monad of
transformations over program representations.  The multiplication component
captures the fact that program text transformations can be chained, as in
macro expansion, phased optimization, etc.

I'm not sure if this works, but it fits my somewhat limited idea of monads,
so I wrote an article <http://blog.mobileink.com/> about it and I'd
appreciate any corrections.  I expect if it does work somebody has already
done something like it, so I would appreciate any pointers to more info.  My
real goal is to think about better language for software build systems,
since what we have now is pretty weak, in my view.  One thing that follows
from thinking in terms of monads is that we can discard the notion of
dependency of object code of source code in favor of a notion of equivalence
(i.e. unit transform).  My hunch is that thinking along such lines might
lead to an improved metalanguage for build DSLs.

Thanks,

Gregg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20101216/ac9866d7/attachment.htm>


More information about the Haskell-Cafe mailing list