Continuation monad "interface"
Posted
by sdcvvc
on Stack Overflow
See other posts from Stack Overflow
or by sdcvvc
Published on 2010-04-17T19:09:01Z
Indexed on
2010/04/17
19:13 UTC
Read the original article
Hit count: 384
haskell
|continuations
The state monad "interface"
class MonadState s m where
get :: m s
put :: s -> m ()
(+ return and bind) allows to construct any possible computation with State monad without using State
constructor. For example, State $ \s -> (s+1, s-1)
can be written as
do s <- get
put (s-1)
return (s+1)
Similarily, I never have to use Reader
constructor, because I can create that computation using ask
, return
and (>>=)
. Precisely: Reader f == ask >>= return . f
.
Is it the same true for continuations - is it possible to write all instances of Cont r a
using callCC
(the only function in MonadCont
), return and bind, and never type something like Cont (\c -> ...)
?
© Stack Overflow or respective owner