scala.tools.nsc.typechecker.PatMatVirtualiser

MatchMonadInterface

trait MatchMonadInterface extends AnyRef

Interface with user-defined match monad? if there's a match in scope, we use this as the match strategy, assuming it conforms to MatchStrategy as defined below:

type Matcher[P[_], M[+_], A] = { def flatMap[B](f: P[A] => M[B]): M[B] def orElse[B >: A](alternative: => M[B]): M[B] }

abstract class MatchStrategy[P[_], M[+_]] { // runs the matcher on the given input def runOrElse[T, U](in: P[T])(matcher: P[T] => M[U]): P[U]

def zero: M[Nothing] def one[T](x: P[T]): M[T] def guard[T](cond: P[Boolean], then: => P[T]): M[T] def isSuccess[T, U](x: P[T])(f: P[T] => M[U]): P[Boolean] // used for isDefinedAt }

P and M are derived from one's signature (def one[T](x: P[T]): M[T])

if no match is found, we assume the following implementation (and generate optimized code accordingly)

object match extends MatchStrategy[({type Id[x] = x})#Id, Option] { def zero = None def one[T](x: T) = Some(x) // NOTE: guard's return type must be of the shape M[T], where M is the monad in which the pattern match should be interpreted def guard[T](cond: Boolean, then: => T): Option[T] = if(cond) Some(then) else None def runOrElse[T, U](x: T)(f: T => Option[U]): U = f(x) getOrElse (throw new MatchError(x)) def isSuccess[T, U](x: T)(f: T => Option[U]): Boolean = !f(x).isEmpty }

Source
PatMatVirtualiser.scala
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. MatchMonadInterface
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def inMatchMonad(tp: Type): Type

  2. abstract def matchMonadSym: Symbol

    Attributes
    protected
  3. abstract def pureType(tp: Type): Type

  4. abstract val typer: Typer

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  14. final def matchMonadResult(tp: Type): Type

  15. val matchOwner: Symbol

  16. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  20. def toString(): String

    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  22. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  23. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any