/
Unapply.scala
47 lines (41 loc) · 1.02 KB
/
Unapply.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package name.rayrobdod.stringContextParserCombinator
/**
* An object that can be a pattern match pattern
*/
sealed trait Unapply[-A] {
}
/**
* The types of pattern match objects
*/
object Unapply {
/**
* An extractor that extracts zero items
*/
trait Zero[-A] extends Unapply[A] {
def unapply(scrutinee:A):Boolean
}
/**
* An extractor that extracts a set number of items
*/
trait Fixed[-A, Z] extends Unapply[A] {
def unapply(scrutinee:A):Option[Z]
}
/**
* An extractor that extracts a set number of items and always succeeds
*/
trait FixedIrrefutable[-A, Z] extends Unapply[A] {
def unapply(scrutinee:A):Some[Z]
}
/**
* An extractor that extracts a variable number of items
*/
trait Seq[-A, Z] extends Unapply[A] {
def unapplySeq(scrutinee:A):Option[scala.collection.immutable.Seq[Z]]
}
/**
* An extractor that extracts a variable number of items and always succeeds
*/
trait SeqIrrefutable[-A, Z] extends Unapply[A] {
def unapplySeq(scrutinee:A):Some[scala.collection.immutable.Seq[Z]]
}
}