-
-
Notifications
You must be signed in to change notification settings - Fork 205
/
StateGetterSyntax.scala
35 lines (27 loc) · 1 KB
/
StateGetterSyntax.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
package monocle.state
import monocle.Getter
import cats.data.State
trait StateGetterSyntax {
@deprecated("no replacement", since = "3.0.0-M1")
implicit def toStateGetterOps[S, A](getter: Getter[S, A]): StateGetterOps[S, A] =
new StateGetterOps[S, A](getter)
}
@deprecated("no replacement", since = "3.0.0-M1")
final class StateGetterOps[S, A](private val getter: Getter[S, A]) extends AnyVal {
/** transforms a Getter into a State */
@deprecated("no replacement", since = "3.0.0-M1")
def toState: State[S, A] =
State(s => (s, getter.get(s)))
/** alias for toState */
@deprecated("no replacement", since = "3.0.0-M1")
def st: State[S, A] =
toState
/** extracts the value viewed through the getter */
@deprecated("no replacement", since = "3.0.0-M1")
def extract: State[S, A] =
toState
/** extracts the value viewed through the getter and applies `f` over it */
@deprecated("no replacement", since = "3.0.0-M1")
def extracts[B](f: A => B): State[S, B] =
extract.map(f)
}