Skip to content

Instantly share code, notes, and snippets.

@ms-tg
Created August 6, 2013 17:07
Show Gist options
  • Select an option

  • Save ms-tg/6166436 to your computer and use it in GitHub Desktop.

Select an option

Save ms-tg/6166436 to your computer and use it in GitHub Desktop.

Revisions

  1. ms-tg created this gist Aug 6, 2013.
    39 changes: 39 additions & 0 deletions for-comp-either-right.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    ////
    // Output of running:
    // $ scala -Xprint:parser -e "val e: Either[String, Int] = Right(1); for {i <- e.right; j = i + 1} yield j"
    ////
    //
    // Picked up _JAVA_OPTIONS: -Xss3m -XX:MaxPermSize=256M
    // /tmp/scalacmd2064075741948415763.scala:1: error: value map is not a member
    // of Product with Either[String,(Int, Int)] with Serializable
    // val e: Either[String, Int] = Right(1); for {i <- e.right; j = i + 1} yield j
    // ^
    // one error found
    // [[syntax trees at end of parser]]// Scala source: scalacmd2064075741948415763.scala
    package <empty> {
    object Main extends scala.ScalaObject {
    def <init>() = {
    super.<init>();
    ()
    };
    def main(argv: Array[String]): scala.Unit = {
    val args = argv;
    {
    final class $anon extends scala.AnyRef {
    def <init>() = {
    super.<init>();
    ()
    };
    val e: Either[String, Int] = Right(1);
    e.right.map(((i) => {
    val j = i.$plus(1);
    scala.Tuple2(i, j)
    })).map(((x$1) => x$1: @scala.unchecked match {
    case scala.Tuple2((i @ _), (j @ _)) => j
    }))
    };
    new $anon()
    }
    }
    }
    }