Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Maybe monad and computations (Daniel Trstenjak) 2. Re: Maybe monad and computations (Emmanuel Touzery) 3. Re: Maybe monad and computations (Daniel Trstenjak) 4. Re: Maybe monad and computations (Emmanuel Touzery) 5. Re: Maybe monad and computations (Emmanuel Touzery) ---------------------------------------------------------------------- Message: 1 Date: Sat, 7 Sep 2013 09:11:24 +0200 From: Daniel Trstenjak <daniel.trsten...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarilybeginner-level topics related to Haskell <beginners@haskell.org> Cc: The Haskell-Beginners Mailing List - Discussion of primarilybeginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Maybe monad and computations Message-ID: <570b07cc-69e6-4be1-ba67-dd2d8b118...@gmail.com> Content-Type: text/plain; charset="us-ascii" 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130907/5f6a9aae/attachment-0001.html> ------------------------------ Message: 2 Date: Sat, 7 Sep 2013 09:31:59 +0200 From: Emmanuel Touzery <etouz...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Maybe monad and computations Message-ID: <CAC42Re=mz3qb0defdrusd9b3aetgzwsqpeh7mdjtqwxwmm4...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" 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.trsten...@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@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-0001.html> ------------------------------ Message: 3 Date: Sat, 7 Sep 2013 09:38:09 +0200 From: Daniel Trstenjak <daniel.trsten...@gmail.com> To: Daniel Trstenjak <daniel.trsten...@gmail.com> Cc: The Haskell-Beginners Mailing List - Discussion of primarilybeginner-leveltopics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Maybe monad and computations Message-ID: <1bcd020c-324c-4e2d-9bad-dbf95351b...@gmail.com> Content-Type: text/plain; charset=us-ascii > I can't see how even your GHC version of 'operation' should work ... Ok, the GHC version puts the IO action into the Maybe and returns it then from 'process'. There's really no need for this extra wrapping of the string into the IO monad. I know nothing about Fay, so I don't know why this extra wrapping shouldn't work for Fay. Fay has an instance for Monad, right? Greetings, Daniel ------------------------------ Message: 4 Date: Sat, 7 Sep 2013 09:43:39 +0200 From: Emmanuel Touzery <etouz...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Maybe monad and computations Message-ID: <cac42rencd+fo3rbogvnfztbiv1zslo8ccfokmme-xpunmg7...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Yes, I agree there is no need in the GHC version to wrap it with return, you can imagine that "operation" instead asks the user through the command line which operation to do, (++) or just pick the first or the second string for instance. In that case it would really need the IO monad and that is my situation. I didn't take the time to code it for the purpose of the example but that is my problem. In that case liftM2 offers me a solution, I can use it also to call functions operating in another monad than the one the parameters are in. In Fay I have that problem with Fay monad, and I don't know why. It's more a Fay question, but Fay normally uses GHC for typecheck so I thought it's maybe something with the Fay monad that is obvious for someone more knowledgeable than me. emmanuel On Sat, Sep 7, 2013 at 9:38 AM, Daniel Trstenjak <daniel.trsten...@gmail.com > wrote: > > > I can't see how even your GHC version of 'operation' should work ... > > Ok, the GHC version puts the IO action into the Maybe and returns it then > from 'process'. There's really no need for this extra wrapping of the > string > into the IO monad. > > I know nothing about Fay, so I don't know why this extra wrapping shouldn't > work for Fay. Fay has an instance for Monad, right? > > > Greetings, > Daniel > > _______________________________________________ > Beginners mailing list > Beginners@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/434f5270/attachment-0001.html> ------------------------------ Message: 5 Date: Sat, 7 Sep 2013 09:47:46 +0200 From: Emmanuel Touzery <etouz...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Maybe monad and computations Message-ID: <cac42rekwxklwwhzrkxvfxejlfjun7x2dv76n5mslweapr9p...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" > I know nothing about Fay, so I don't know why this extra wrapping shouldn't > work for Fay. Fay has an instance for Monad, right? > well when you write haskell code that you'll compile with Fay you can't use typeclasses. So AFAIK no, the "Fay" that I use in the Fay code doesn't implement the Monad typeclass. OK, so it seems my Haskell code is OK, and probably my stackoverflow question is legitimate about whether this valid Haskell code can work on Fay. Btw I used stackoverflow because the Fay website states that they use it as a preferred channel for support. Thank you for the insights! Emmanuel -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130907/99760918/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 63, Issue 11 *****************************************