
This is meant to model errors. You want your computation to continue if
everything is going all-Right, but if there is an error, you want it to
stop there are report the error. This error is represented by Left
constructor.
On Tue, Apr 14, 2015 at 9:56 AM, Bob Ippolito
The Functor instance is defined for `Either a`, so Left is fixed. fmap only maps over Right. You'll find the same behavior for `(,) a`, e.g. `fmap (*2) (1,2) == (1,4)`.
On Tue, Apr 14, 2015 at 9:47 AM, Shishir Srivastava < shishir.srivastava@gmail.com> wrote:
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners