[Haskell-cafe] Very simple parser

Alexis Hazell dry.green.tea at gmail.com
Wed Jul 4 10:58:06 EDT 2007

On Tuesday 03 July 2007 09:51, Arie Peterson wrote:

> No, there is a 'State s' monad provided (for arbitrary state type 's'),
> which implements the 'get' and 'put' methods. In other words, 'State s' is
> an instance of the 'MonadState s' class. This terminology can be really
> confusing at first.
> For now, you may forget about the MonadState class. Simply use 'get' &
> friends and everything will work fine.

This may be a stupid question, but i don't understand how (indeed, if) one can 
maintain multiple states using the State monad, since 'get' etc. don't seem 
to require that one specify which particular copy of a State monad one wishes 
to 'get' from, 'put' to etc.? Does one have to use (say) a tuple or a list to 
contain all the states, and when one wishes to change only one of those 
states, pass that entire tuple or list to 'put' with one element changed and 
the rest unchanged?


More information about the Haskell-Cafe mailing list