
Hi, This is a "hey that's cool" post :-) I have seen both of those separately --- the generalized resumptions monad, and the IO (and others) monad written in continuation passing style, but never realized that the one was an instance of the other. It is neat how the basic operations are separated from the sequencing. Does anyone know how related (it seems somewhat related) is all that to the recent work by Plotkin and Power on deriving monad implementations from their operations? -Iavor
More generally:
data Resumptions f a = Val a | Resume (f (Resumptions f a))
instance Functor f => Monad (Resumptions f) where return = Val Leaf a >>= f = f a Resume t >>= f = Resume (fmap (>>= f) t)
An example is a model of the IO monad, with f instantiated to
data SysCall a = GetChar (Char -> a) | PutChar Char a | ...