[Haskell-beginners] Maybe monad and computations

Emmanuel Touzery etouzery at gmail.com
Sat Sep 7 09:31:59 CEST 2013


Well I'm trying to combine two monads here, Maybe and either the Fay or the
IO monad. In the example code I just put return but otherwise in my real
code "operation" has side-effects and needs the Fay monad in the case of
the Fay program.

I understand how to use lift if "operation" is pure, without using monads,
but I have this trouble when it operates in another monad. I thought I
understood it, but looking at the difference in behaviour in the examples I
posted, maybe I don't.

Emmanuel


On Sat, Sep 7, 2013 at 9:11 AM, Daniel Trstenjak <daniel.trstenjak at gmail.com
> wrote:

> Hello Emmanuel,
>
> And I tried to apply it to the haskell fay compiler, but failed:
>
> http://stackoverflow.com/questions/18667530/dont-understand-this-liftm2-behaviour-in-fay
>
> Not sure whether it's a fay bug or something about the fay monad or liftM2
> which i don't understand.
>
> The point of lifting is, that you lift an operation into an other
> "context", so
> that the operation itself hasn't to operate in the same "context".
>
> I can't see how even your GHC version of 'operation' should work,
> because in both cases it should be something like:
>
> liftM2 (++) getValue1 getValue2
>
> or in applicative style
>
> (++) <$> getValue1 <*> getValue2
>
>
> Greetings,
> Daniel
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130907/a4588a4d/attachment.htm>


More information about the Beginners mailing list