C minus minus? No, C monad monad.

Simon Peyton-Jones simonpj at microsoft.com
Mon Oct 31 12:37:31 EST 2005


Interesting message.

But I'm not completely convinced.  

Firstly, C-- *continuations* are quasi-first class values: you can pass
them as arguments to functions, and store them in data structures.  In
contrast, your continuations are more akin to C-- *labels*.  These are
definitely not first class.  They just give a textual way of describing
a control flow graph.  That's much closer to what you mean to do (with
join points etc).  

Of course, labels allow you to build a cyclic graph. Your hack for
building cycles feels to me like using the monadic story for something
it wasn't really meant for.  Somehow, a set of labelled blocks seems
more more direct.

I'm also not convinced that you are getting anything much from your
monadic presentation that you would not also get, sometimes more
directly, from a C-- representation.  What, do you think you gain?

There is a long and distinguished history to regarding lambda code as an
intermediate language that can go all the way to machine code (e.g. the
lambda-the-ultimate papers; the T compiler; Appel's book etc).  Using a
monadic, rather than CPS, framework may be better -- though it's a
tricky case to make.  But in fact, few compilers do take this idea right
through.  It's hard to say why, except that it can be a bit clumsy to
make one hammer that is truly comfortable on many different nails.

At the moment, I'd still incline to translating Grin into C-- (or
something like it), and optimising there.  But maybe you have good
reasons not to do that.


More information about the Glasgow-haskell-users mailing list