[Haskell] ANN: monadLib 2.0

Iavor Diatchki iavor.diatchki at gmail.com
Tue Mar 21 16:03:33 EST 2006


On 3/21/06, Andrew Pimlott <andrew at pimlott.net> wrote:
> I would like it if all mtl classes had a function that captures the
> general operation of the monad.  In this sense, asks is the essence of
> the Reader monad.  The essense of the State monad, which I have defined
> for myself many times, is
>     state :: MonadState s m => (s -> (a, s)) -> m a
> And so on for the others.  These could be part of the class (my
> preference, because the other ops can have default implementations in
> terms of it) or auxiliary functions.

'monadLib' already contains such functions.  Take a look at:
They are called inReader, inWriter, inState, inExcept.  There isn't
one for searching because we have 'msum' which does the same, and
there isn't one for continuations because I wasn't sure what should be
the type.

At the moment they are functions and not methods.  It is always tricky
to decide what to put in the classes, but my feeling is that functions
are more appropriate in this case.


More information about the Libraries mailing list