[Haskell-beginners] Left vs Right

Kostiantyn Rybnikov k-bx at k-bx.com
Wed Apr 15 12:50:01 UTC 2015


Adding to others,

For fmapping left value I suggest using fmapLeft from errors package, for
fmapping both you can use

either (Left . replicate 3) (Right . replicate 3)
14 квіт. 2015 19:48 "Shishir Srivastava" <shishir.srivastava at gmail.com>
пише:

> Hi,
>
> Can someone please explain the difference in outputs of the following two
> expressions -
>
> --------------
>
> ghci> fmap (replicate 3) (Right "blah")
> Right ["blah","blah","blah"]
>
> ghci> fmap (replicate 3) (Left "foo")
> Left "foo"
>
> ---------------
>
> Why does 'Right' return a list of Strings whereas 'Left' returns just a
> String.
>
> Thanks,
> Shishir
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150415/ebfc14eb/attachment.html>


More information about the Beginners mailing list