Skip to content

Instantly share code, notes, and snippets.

@non
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save non/f262a7df9521b8db77d8 to your computer and use it in GitHub Desktop.
Save non/f262a7df9521b8db77d8 to your computer and use it in GitHub Desktop.
Typelevel Scala has an option to make for-comprehensions easier to reason about
erik@vx-2 ~/w/tlc (2.11.x) ⛭ ./build/quick/bin/scala -Zirrefutable-generator-patterns
Welcome to Scala version 2.11.3-20141005-222847-d37174644b (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_04).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val list: List[Any] = List((1,2), (3,4), 1, (4,5))
list: List[Any] = List((1,2), (3,4), 1, (4,5))
scala> for { (a, b) <- list } yield a
scala.MatchError: 1 (of class java.lang.Integer)
at $anonfun$1.apply(<console>:9)
at scala.collection.immutable.List.map(List.scala:276)
... 33 elided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment