@@ -20,16 +20,17 @@ private[thoughtworks] sealed trait LowPriorityExtractor extends LowLowPriorityEx
2020 sealed trait SeqExtractor [- A , + B ] {
2121 def unapplySeq (a : A ): Option [Seq [B ]]
2222 }
23-
24- implicit final class OptionFunctionToSeqExtractor [- A , + B ] private [LowPriorityExtractor ](underlying : A => Option [Seq [B ]]) {
23+
24+ implicit final class OptionFunctionToSeqExtractor [- A , + B ] private [LowPriorityExtractor ] (
25+ underlying : A => Option [Seq [B ]]) {
2526 def seq = new SeqExtractor [A , B ] {
2627 def unapplySeq (a : A ) = underlying(a)
2728 }
2829 @ deprecated(" Use f.extract.seq instead" , " 1.1.0" )
2930 def extractSeq = seq
3031 }
3132
32- implicit final class OptionFunctionToExtractor [- A , + B ] private [LowPriorityExtractor ](underlying : A => Option [B ]) {
33+ implicit final class OptionFunctionToExtractor [- A , + B ] private [LowPriorityExtractor ] (underlying : A => Option [B ]) {
3334 def extract = new Extractor [A , B ] {
3435 def unapply (a : A ) = underlying(a)
3536 }
@@ -51,12 +52,12 @@ sealed trait Extractor[-A, +B] extends (A => Option[B]) {
5152 * @example
5253 {{{
5354 import com.thoughtworks.Extractor._
54-
55+
5556 // Define a PartialFunction
5657 val pf: PartialFunction[Int, String] = {
5758 case 1 => "matched by PartialFunction"
5859 }
59-
60+
6061 // Define an optional function
6162 val f: Int => Option[String] = { i =>
6263 if (i == 2) {
@@ -65,10 +66,10 @@ sealed trait Extractor[-A, +B] extends (A => Option[B]) {
6566 None
6667 }
6768 }
68-
69+
6970 // Convert an optional function to a PartialFunction
7071 val pf2: PartialFunction[Int, String] = f.unlift
71-
72+
7273 util.Random.nextInt(4) match {
7374 case pf.extract(m) => // Convert a PartialFunction to a pattern
7475 println(m)
@@ -92,13 +93,13 @@ object Extractor extends LowPriorityExtractor {
9293 }
9394 }
9495
95- implicit final class PartialFunctionToExtractor [- A , + B ] private [Extractor ](underlying : PartialFunction [A , B ]) {
96+ implicit final class PartialFunctionToExtractor [- A , + B ] private [Extractor ] (underlying : PartialFunction [A , B ]) {
9697 def extract = new Extractor [A , B ] {
9798 def unapply (a : A ) = underlying.lift(a)
9899 }
99100 }
100101
101- implicit final class OptionFunctionToPartialFunction [- A , + B ] private [Extractor ](underlying : A => Option [B ]) {
102+ implicit final class OptionFunctionToPartialFunction [- A , + B ] private [Extractor ] (underlying : A => Option [B ]) {
102103 def unlift : PartialFunction [A , B ] = {
103104 case underlying.extract(b) => b
104105 }
0 commit comments