
Sven Panne
2017-04-06 9:33 GMT+02:00 Jon Fairbairn
: Sven Panne
writes: [...] Although something like Error/OK would have been better than Left/Right, a slight majority preferred to give a bias to Either. The reasoning was that using "Right" for a "wrong" outcome (i.e. failure) would be a bit obscure, and there was already quite some code using it in the way we still do today. The bias is even explicitly documented in the Haddock docs for Data.Either for ages, so it would not be very wise to change the meaning here after roughly 2 decades.
I guess this means that Haskell has failed to sufficiently avoid success. If a mistake in library design is bad enough (not necessarily the case for Either, but arguably so), it should be corrected even after 20 years.
Just to clarify my POV: I didn't want to criticize anything here, I just wanted to point to some previous discussion. In my POV, Either *is* intended as a biased sum type (there are tons of more or less standard libraries which use it that way), while pairs/tuples are intended as unbiased product types.
I agree with that, although somewhat reluctantly about Either. The original intention (as I remember it, but how reliable is my memory of meetings nearly thirty years ago?) was to pick a name for an unbiased sum type and its constructors. We chose Either and Left and Right (the latter two being names that had been used in prior languages). It was then noticed that Either provided what was needed for results that could either be a success or an error, and Right was the obvious choice for the success. (,) never had that: it was unbiased, apart from the inevitable syntactic and evaluation order biases. I would like to be able to say that (excluding questions of evaluation order) if one systematically replaced (a,b) with (b,a) throughout the source of a programme, it would still be the same programme. I would also like to think that instances provided in base were “the only sensible instance” (for some value of sensible). This is the case for Foldable Maybe, maybe for Either (but not for an unbiased sum) and definitely not for (,). -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk