Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

robcd
Copy link

@robcd robcd commented Jun 29, 2012

Dear Heather,

As threatened on the scala-debate thread by the same name, here's my suggestion for fixing scala.Either.

Best regards,

Rob

robcd added 16 commits June 12, 2012 21:28
…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.
…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.
@robcd
Copy link
Author

robcd commented Jul 6, 2012

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.

@SethTisue
Copy link
Member

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

@SethTisue SethTisue closed this Jul 13, 2015
@heathermiller
Copy link
Member

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)

@dickwall
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants