Skip to content

Instantly share code, notes, and snippets.

@purefn
Created September 23, 2012 16:42
Show Gist options
  • Save purefn/3772261 to your computer and use it in GitHub Desktop.
Save purefn/3772261 to your computer and use it in GitHub Desktop.
trait Option[+A] {
@inline final def cata[Z](some: A => Z, none: => Z) = this match {
case Some(a) => some(a)
case None => none
}
}
object Option {
private[Option] case class Some[+A](a: A) extends Option[A]
private[Option] case object None extends Option[Nothing]
def some[A](a: A): Option[A] = Some(a)
def none: Option[Nothing] = None
}
@retronym
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment