[Haskell-beginners] Print values stored in an "Either" in the main method

Brandon Allbery allbery.b at gmail.com
Fri Feb 21 01:10:18 UTC 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140220/4448b566/attachment.html>


More information about the Beginners mailing list