[Haskell-beginners] Print values stored in an "Either" in the main method
Mathew Phillips
mathewrphillips at gmail.com
Fri Feb 21 01:16:27 UTC 2014
Actually your comment in parenthesis is what made it click. If i do "result
<- return $ runEval ..." it works too. The fact that the first error was
complaining that it expected something of type IO should have tipped me
off.
Thank you,
Matt P.
On Thu, Feb 20, 2014 at 7:10 PM, Brandon Allbery <allbery.b at gmail.com>wrote:
> On Thu, Feb 20, 2014 at 8:05 PM, Mathew Phillips <
> mathewrphillips at gmail.com> wrote:
>
>> Ok now I'm even more confused! That works, but I thought that "let" was
>> for when the value inside the do block was pure, and the <- notation when
>> it's inside another monad?
>>
>
> Are you referring to the fact that Either has a Monad instance? Because
> you're not *using* it monadically, but purely, so its Monad instance is not
> relevant. Likewise lists have a Monad instance, but most of the time you
> don't use it, you treat them as pure values.
>
> (You also can't mix monads; if you're using <- in a do block in IO, it
> must be working with a value in IO, not merely one in some monad. This is
> clearer when you learn how do blocks desugar into functions.)
>
> --
> brandon s allbery kf8nh sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> 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/20140220/56e59a81/attachment.html>
More information about the Beginners
mailing list