MarioAriasC / funKTionale

Functional constructs for Kotlin
914 stars 71 forks source link

The Either type is unbiased #11

Closed denisftw closed 8 years ago

denisftw commented 8 years ago

Hi!

I just wanted to clarify whether it was a design decision to make Either unbiased. As far as I remember, the only unbiased version of Either in the Scala world is ancient scala.util.Either and it's criticized by everyone left and right for exactly its unbiased nature.

Pretty much all alternatives including scala.util.Try, scalaz.\/ or cats.data.Xor are right-biased. In your wiki you are also pointing out that

Traditionally the Left represent an error and Right a correct return

So, why not make it right-biased by design and provide map and flatMap? It would make it even more useful.

Thank you for a great library!

MarioAriasC commented 8 years ago

Either will remain unbiased but is under consideration to include a biased version, so both will coexists.

Thank you for your comments, you're welcome

denisftw commented 8 years ago

Cool, thanks!

In this case I'll just write a couple of extension methods for my code. RightProjection already allows to to implement them literally in one line of code, so this is not a problem :)

MarioAriasC commented 8 years ago

A Disjunction (Right biased Either) type was included on 0.9 release