Monad composition

John Hughes rjmh@cs.chalmers.se
Thu, 24 Jan 2002 10:29:34 +0100 (MET)


The easiest way to combine State and IO is using a monad transformer. There
are some lecture notes which you might find useful at

	http://www.md.chalmers.se/~rjmh/Combinators/Monads/index.htm

which refer to a library module

	http://www.md.chalmers.se/~rjmh/Combinators/MonadTransformers.hs

Using this library you just build the type

	type StateIO s a = State s IO a

which is a monad with operations readState, writeState, and

	lift :: IO a -> StateIO s a

John