polymorphic type in state of state monad

Andrew J Bromage ajb@spamcop.net
Tue, 11 Mar 2003 10:05:27 +1100


G'day all.

On Tue, Mar 11, 2003 at 08:34:06AM +1300, Tom Pledger wrote:

> If, on the other hand, you want to vary the state type *during* a
> single monadic computation, it gets messy.  You could try one of the
> following.

Very often, you just want to vary the state type for some portion
of the computation then go back to the original.  In that case, a
simpler solution is to stack a new state monad transformer (such as
Control.Monad.State.StateT) on top of your existing state monad for
the part where you need it.

Cheers,
Andrew Bromage