-
Notifications
You must be signed in to change notification settings - Fork 1k
new SIP added: Fixing Either #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…with some example code, and has yet to be checked using jekyll
…y to submit -sips/pending/_posts/2012-06-13-fixing-eithers-left-rightprojection.md
-This third solution has been [demonstrated][project] to work well, and is the one +This third solution has been [shown][project] to work well, and is the one
-A trial verson of `Either` incorporating the proposed enhancements, +A trial verson of `Either` incorporating the proposed fixes,
…on 'Regarding the second example of odd behaviour' corrected Regarding the second example of odd behaviour, involving `if`, this was traced to the fact that the `filter` method (of `LeftProjection` and `RightProjection`) returns an `Option` instead of the - respective projection. + an `Either`, thus allowing `None` to be returned when the predicate is `false`. A +`Left` (`Right`) could not be returned in the case of a +`RightProjection` (`LeftProjection`) since no value is available to go +into it.
…egy ## as suggested by Daniel Sobral
…t => BB' explanation added; reference to Tony's filter objection added
…around withFilter, now that Convert retains the type of its field
…on now mentions the possibility of using polymorphic implicit conversions -so that `res.e` would be `Left("(1,2)")` if `b > 0` were false. +so that `res.e` would be `Left("(1,2)")` if `b > 0` were false. Note +that `g` may be given a type parameter, in case multiple conversions +would otherwise be needed, and a single, common, implementation would suffice.
Sorry about all the recent changes. I think this is now stable, with no responses on the scala-debate thread since the latest changes were described, on Wed 4th. |
this has actually been the subject of fresh discussion recently, but regardless, I'm closing to close the PR, so it doesn't show up in our queue. there's still strong interest in doing something about Either for 2.13, so @robcd, if you're still around, consider reviving this |
Pinging @dickwall just to keep him in the loop about this (this PR was discussed in the most recent SIP/SLIP meeting btw, so we would like to do something about providing a right-biased variant of Either somehow) |
I think left vs right bias is one of the first things to address in fact. For an infix type like Or (e.g. Person Or Error) it would make more sense to be left biased, right bias is the convention through Scala for either at present though because of the Right holding the "right" answer (and of course the conventions in languages like Haskell). I suspect this might be a long journey. |
Dear Heather,
As threatened on the scala-debate thread by the same name, here's my suggestion for fixing scala.Either.
Best regards,
Rob