At 10:40 -0800 1998/11/13, Jeffrey R. Lewis wrote:
>  Say you've got some code that wasn't originally
>monadic, and you now need to re-express your code in monadic form.  You
>apply the monad translation. Using the `kleisli' functions makes this
>process simpler.  Consider:
>
>    map f (... xs ...)
>
>If we do the monad translation on the argument of `map f', we'll get (...
>return xs ...).  The monad translation on `f' is `return . f'.  Now we need
>the monad translation on `map'.  Oh hey - someone's already done it for us -
>it's called mapM.  So now our original term with the monad translation
>applied to it is:
>
>    mapM (return . f) (... return xs ...)

It is a fact that every such monadic modification also have such a monadic
lifting. Could you not implement this fact in such a way that people need
not bother writing out the details for every specific case? That is,
Haskell recognizes that
    map (return . f) (... return xs ...)
should mean
    mapM (return . f) (... return xs ...)

  Hans Aberg
                  * Email: Hans Aberg <mailto:[EMAIL PROTECTED]>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>



Reply via email to