diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2016-04-27 21:25:57 +0200 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2016-05-27 15:01:47 +0200 |
commit | 6e9faf5157132ad575c98e5a9a0919ac38b7beb8 (patch) | |
tree | 1230333b98544c28b26e7c9e55d7581c62f323bd /test/files/presentation/t7678 | |
parent | f7b575de222befb2cd1dd2f676e177ece8a1d234 (diff) | |
download | scala-6e9faf5157132ad575c98e5a9a0919ac38b7beb8.tar.gz scala-6e9faf5157132ad575c98e5a9a0919ac38b7beb8.tar.bz2 scala-6e9faf5157132ad575c98e5a9a0919ac38b7beb8.zip |
Right-bias Either
- Add operations like map, flatMap which assume right-bias
- Deprecate {Left,Right}Projection
- Deprecate left and right in favor of swap
- Add contains, toOption, toTry, toSeq and filterOrElse
- toSeq returns collection.immutable.Seq instead of collection.Seq
- Don't add get
There are no incompatible changes.
The only possibility of breakage that exists is when people have added
extension methods named map, flatMap etc. to Either in the past doing
something different than the methods added to Either now.
One detail that moved the scales in favor of deprecating LeftProjection
and RightProjection was the desire to have toSeq return
scala.collection.immutable.Seq instead of scala.collection.Seq
like LeftProjection and RightProjection do.
Therefore keeping LeftProjection and RightProjection would introduce
inconsistency.
filter is called filterOrElse because filtering in a for-comprehension
doesn't work if the method needs an explicit argument.
contains was added as safer alternative to
if (either.isRight && either.right.get == $something) ...
While adding filter with an implicit zero value is possible, it's
dangerous as it would require that developers add a "naked" implicit
value of type A to their scope and it would close the door to a future
in which the Scala standard library ships with Monoid and filter could
exist with an implicit Monoid parameter.
Diffstat (limited to 'test/files/presentation/t7678')
-rw-r--r-- | test/files/presentation/t7678/Runner.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/test/files/presentation/t7678/Runner.scala b/test/files/presentation/t7678/Runner.scala index 14d6dc2a70..c6736a65b0 100644 --- a/test/files/presentation/t7678/Runner.scala +++ b/test/files/presentation/t7678/Runner.scala @@ -7,7 +7,7 @@ object Test extends InteractiveTest { override def runDefaultTests() { def resolveTypeTagHyperlink() { - val sym = compiler.askForResponse(() => compiler.currentRun.runDefinitions.TypeTagClass).get.left.get + val sym = compiler.askForResponse(() => compiler.currentRun.runDefinitions.TypeTagClass).get.swap.getOrElse(???) val r = new Response[Position] compiler.askLinkPos(sym, new BatchSourceFile("", source), r) r.get |