
Hello,
On 3/21/06, Andrew Pimlott
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: http://www.csee.ogi.edu/~diatchki/monadLib/current/doc/html/Monad-Prelude.ht... 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. -Iavor