Hi Dan,

> > import Control.Monad.State
> 
> > test = do
> >     put $ x+1
> >     x <- return 1
> >     return undefined
> 
> > go = execState test undefined

I'd just like to point out that you can do something similar without
mdo.  For example, you can define a monad with newVar, readVar, and
writeVar such that running the following results in 2.

test = do x <- newVar
          y <- newVar

          valx <- readVar x

          writeVar y (valx+1)
          writeVar x 1

          valy <- readVar y
          return valy

(As you probably know, the previous two Monad.Reader issues include
two different examples -- assembler and circuit description -- of
circular programming in a monad.)

Matt.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to