-
-
Notifications
You must be signed in to change notification settings - Fork 202
/
AppliedPPrism.scala
96 lines (71 loc) · 3.62 KB
/
AppliedPPrism.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package monocle.syntax
import monocle._
trait AppliedPPrism[S, T, A, B] extends AppliedPOptional[S, T, A, B] {
override def optic: PPrism[S, T, A, B]
override def some[A1, B1](implicit ev1: A =:= Option[A1], ev2: B =:= Option[B1]): AppliedPPrism[S, T, A1, B1] =
adapt[Option[A1], Option[B1]].andThen(std.option.pSome[A1, B1])
override private[monocle] def adapt[A1, B1](implicit evA: A =:= A1, evB: B =:= B1): AppliedPPrism[S, T, A1, B1] =
evB.substituteCo[AppliedPPrism[S, T, A1, *]](evA.substituteCo[AppliedPPrism[S, T, *, B]](this))
def andThen[C, D](other: PPrism[A, B, C, D]): AppliedPPrism[S, T, C, D] =
AppliedPPrism(value, optic.andThen(other))
}
object AppliedPPrism {
def apply[S, T, A, B](_value: S, _optic: PPrism[S, T, A, B]): AppliedPPrism[S, T, A, B] =
new AppliedPPrism[S, T, A, B] {
val value: S = _value
val optic: PPrism[S, T, A, B] = _optic
}
implicit def appliedPPrismSyntax[S, T, A, B](self: AppliedPPrism[S, T, A, B]): AppliedPPrismSyntax[S, T, A, B] =
new AppliedPPrismSyntax(self)
implicit def appliedPrismSyntax[S, A](self: AppliedPrism[S, A]): AppliedPrismSyntax[S, A] =
new AppliedPrismSyntax(self)
}
object AppliedPrism {
def apply[S, A](_value: S, _optic: Prism[S, A]): AppliedPrism[S, A] =
AppliedPPrism(_value, _optic)
}
final case class AppliedPPrismSyntax[S, T, A, B](private val self: AppliedPPrism[S, T, A, B]) extends AnyVal {
@deprecated("use andThen", since = "3.0.0-M1")
def composeFold[C](other: Fold[A, C]): AppliedFold[S, C] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def composeGetter[C](other: Getter[A, C]): AppliedFold[S, C] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def composeSetter[C, D](other: PSetter[A, B, C, D]): AppliedPSetter[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def composeTraversal[C, D](other: PTraversal[A, B, C, D]): AppliedPTraversal[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def composeOptional[C, D](other: POptional[A, B, C, D]): AppliedPOptional[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def composeLens[C, D](other: PLens[A, B, C, D]): AppliedPOptional[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def composePrism[C, D](other: PPrism[A, B, C, D]): AppliedPPrism[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def composeIso[C, D](other: PIso[A, B, C, D]): AppliedPPrism[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def ^|->>[C, D](other: PTraversal[A, B, C, D]): AppliedPTraversal[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def ^|-?[C, D](other: POptional[A, B, C, D]): AppliedPOptional[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def ^<-?[C, D](other: PPrism[A, B, C, D]): AppliedPPrism[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def ^|->[C, D](other: PLens[A, B, C, D]): AppliedPOptional[S, T, C, D] =
self.andThen(other)
@deprecated("use andThen", since = "3.0.0-M1")
def ^<->[C, D](other: PIso[A, B, C, D]): AppliedPPrism[S, T, C, D] =
self.andThen(other)
}
final case class AppliedPrismSyntax[S, A](private val self: AppliedPrism[S, A]) extends AnyVal {
def withDefault[A1](defaultValue: A1)(implicit evOpt: A =:= Option[A1]): AppliedPrism[S, A1] =
self.adapt[Option[A1], Option[A1]].andThen(std.option.withDefault(defaultValue))
}