[Haskell-cafe] Why Either = Left | Right instead of something like Result = Success | Failure

Thomas Schilling nominolo at googlemail.com
Thu May 27 11:04:54 EDT 2010


It's indeed arbitrary.  Other common names are Inl and Inr (presumably
standing for "inject left/right").  Some Haskell project do indeed use
a more specific name.  The advantage of using the generic Left/Right
is reusability of library code.  The particular name of the datatype
and its constructors are competely arbitrary.  The use of "Right" for
"Success" is a handy pun -- the program returned "the right answer".

HTH,

/ Thomas

On 27 May 2010 15:25, Ionut G. Stan <ionut.g.stan at gmail.com> wrote:
> Hi,
>
> I was just wondering if there's any particular reason for which the two
> constructors of the Either data type are named Left and Right. I'm thinking
> that something like Success | Failure or Right | Wrong would have been a
> little better.
>
> I've recently seen that Scala uses a similar convention for some error
> notifications so I'm starting to believe there's more background behind it
> than just an unfortunate naming.
>
> Thanks,
> --
> Ionuț G. Stan  |  http://igstan.ro
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Push the envelope.  Watch it bend.


More information about the Haskell-Cafe mailing list