This note reminisces on a paper by Dan Friedman (with Haynes and Kohlbecker, 1984):
"Programming with Continuations". That paper used call/cc and mutable state (via
"set!") to describe an "exercise", which they called "devils and angels". This "exercise"
has little practical point, per se: it is really the illustration of the combination
of state and first-class continuations which was important...
This note shows an alternative implementation: in terms of monads: a state monad
lifted into a continuation monad...
What this note does is to show an implementation, not in terms of the standard
implementation of monads, but rather one based on Andrzej Filinski's paper
"Representing Monads". That paper shows how a "monadic" program may be written
in direct style--i.e. how to add "effects" to an Scheme/ML program without completely
transforming that program into the normal monadic style. Shift and reset--delimited
continuations-- are used to achieve this.
Reflection and monad transformers play an important role in this tour de force.
Posted to functional by Ehud Lamm on 5/11/03; 8:44:22 AM