Created
September 23, 2012 16:42
-
-
Save purefn/3772261 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Option
will need to be an abstract class for the inliner to work in 2.9. Not sure if that limitation will be lifted for 2.10.0 or for .1.