Skip to content

Instantly share code, notes, and snippets.

@fommil
Created January 21, 2018 18:11
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 fommil/eb0c8b83bb4e5b63f7decb9cd68132fb to your computer and use it in GitHub Desktop.
Save fommil/eb0c8b83bb4e5b63f7decb9cd68132fb to your computer and use it in GitHub Desktop.
anonymous coproducts
import scalaz._
def foo(x: String \/ Int) = {
x match {
case -\/(s) => println("I'm a String")
case \/-(i) => println("I'm an Int")
case _ => println("I cannot be anything else 'cuz compiler guarantees it!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment