summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-02 15:19:46 -0800
committerPaul Phillips <paulp@improving.org>2012-02-02 15:19:46 -0800
commitb0e33f583955485fbdfa01aa741e440961fb6e2c (patch)
treedb2ec32f8ceed02ed7454d3a6634384d69ab9f31 /src/library
parentd76af28209eb1759b4e1cc335abd44eafb61eb22 (diff)
parentc58b240177bf6b1017b5fdb6cbfb7be49b4ee3f1 (diff)
downloadscala-b0e33f583955485fbdfa01aa741e440961fb6e2c.tar.gz
scala-b0e33f583955485fbdfa01aa741e440961fb6e2c.tar.bz2
scala-b0e33f583955485fbdfa01aa741e440961fb6e2c.zip
Merge commit 'c58b240' into develop
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/MatchingStrategy.scala27
1 files changed, 0 insertions, 27 deletions
diff --git a/src/library/scala/MatchingStrategy.scala b/src/library/scala/MatchingStrategy.scala
deleted file mode 100644
index d11598bad6..0000000000
--- a/src/library/scala/MatchingStrategy.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-package scala
-
-abstract class MatchingStrategy[M[+x]] {
- // runs the matcher on the given input
- def runOrElse[T, U](in: T)(matcher: T => M[U]): U
-
- def zero: M[Nothing]
- def one[T](x: T): M[T]
- def guard[T](cond: Boolean, then: => T): M[T]
- def isSuccess[T, U](x: T)(f: T => M[U]): Boolean // used for isDefinedAt
-
- def caseResult[T](x: T): M[T] = one(x) // used as a marker to distinguish the RHS of a case (case pat => RHS) and intermediate successes
- // when deriving a partial function from a pattern match,
- // we need to distinguish the RHS of a case, which should not be evaluated when computing isDefinedAt,
- // from an intermediate result (which must be computed)
-}
-
-object MatchingStrategy {
- implicit object OptionMatchingStrategy extends MatchingStrategy[Option] {
- type M[+x] = Option[x]
- @inline def runOrElse[T, U](x: T)(f: T => M[U]): U = f(x) getOrElse (throw new MatchError(x))
- @inline def zero: M[Nothing] = None
- @inline def one[T](x: T): M[T] = Some(x)
- @inline def guard[T](cond: Boolean, then: => T): M[T] = if(cond) Some(then) else None
- @inline def isSuccess[T, U](x: T)(f: T => M[U]): Boolean = !f(x).isEmpty
- }
-} \ No newline at end of file