
In order to move the function (\jmp -> jmp `runC` jmp) into callCC, the following law, that all instances of MonadCont seem to satisfy, is very helpful.
f =<< callCC g === callCC (\k -> f =<< g ((=<<) k . f)) This law is in fact only satisfied for some monads (QuickCheck suggests Cont r and ContT r m). A counterexample for the reader
Hi, Sorry, I have to do a small correction to an earlier post of mine. On 7/9/05, I wrote: transfomer: type M = ReaderT Bool (Cont Bool) f :: a -> M Bool f _ = ask g :: (Bool -> M a) -> M a g k = local not $ k True run :: M Bool -> Bool run (ReaderT m) = m True `runCont` id Now, run (f =<< callCC g) ==> True run (callCC (\k -> f =<< g ((=<<) k . f))) ==> False
In particular (regarding Functor as superclass of Monad), it follows
f `fmap` callCC g === callCC (\k -> f `fmap` g (k . f)) This law (the one I actually used) is satisfied (again, only according to QuickCheck) by every monad I checked.
Thomas