Lars Lundgren writes:
> [EMAIL PROTECTED] writes:
>
> > the problem of doing stateful things and IO at the same time. Eventually I
> > realised it is not possible to nest monads,
>
> But it is possible! You just need to use a monadtransformer:
>
> class MonadTrans t where
> lift :: Monad m => m a -> (t m) a
>
>
> A requirement for this to work is that one of the monadic types can carry
> the other monad inside, so to say. t m.
>
> This is no solution to the problem of mixing ST and IO though, because
> none of them can be instances of MonadTrans.
But it is a reasonable extension to expect. If we ever have a prelude
using monad transformers, an IO monad transformer should be provided.
This is discussed in my 1997 MSc thesis[1], where I implemented such a
beast in Gofer (Haskell did not have MPTCs at the time). These days an
implementation in Hugs or GHC should be straightforward.
It would be nice if generic state and environment monad transformers were provided in
the prelude also, to avoid users having roll their own every time.
Not sure if this should be a wish, though; it's a bit more blue-sky than that.
--KW 8-)
[1]
@MastersThesis{
Wansbrough97:Modular,
author="Keith Wansbrough",
title="A Modular Monadic Action Semantics",
school="Department of Computer Science, University of Auckland",
year="1997",
month=feb,
documentURL="http://www.cl.cam.ac.uk/users/kw217/research/msc/thesis/index.html",
}