Modifier and Type | Method and Description |
---|---|
static <V> Lens.Simple<V,Maybe<V>> |
asMaybe()
Convenience static factory method for creating a lens that focuses on a value as a
Maybe . |
static <S,T,A,B> Lens<S,T,Maybe<A>,B> |
liftA(Lens<S,T,A,B> lens)
Given a lens, lift
A into Maybe . |
static <S,T,A,B> Lens<S,T,A,Maybe<B>> |
liftB(Lens<S,T,A,B> lens,
B defaultB)
|
static <S,T,A,B> Lens<Maybe<S>,T,A,B> |
liftS(Lens<S,T,A,B> lens,
S defaultS)
|
static <S,T,A,B> Lens<S,Maybe<T>,A,B> |
liftT(Lens<S,T,A,B> lens)
Given a lens, lift
T into Maybe . |
static <S,T,A,B> Lens<S,T,A,B> |
unLiftA(Lens<S,T,Maybe<A>,B> lens,
A defaultA)
|
static <S,T,A,B> Lens<S,T,A,B> |
unLiftB(Lens<S,T,A,Maybe<B>> lens)
|
static <S,T,A,B> Lens<S,T,A,B> |
unLiftS(Lens<Maybe<S>,T,A,B> lens)
|
static <S,T,A,B> Lens<S,T,A,B> |
unLiftT(Lens<S,Maybe<T>,A,B> lens,
T defaultT)
|
public static <S,T,A,B> Lens<Maybe<S>,T,A,B> liftS(Lens<S,T,A,B> lens, S defaultS)
S
, lift S
into Maybe
.
Note that this lens is NOT lawful, since "putting back what you got changes nothing" fails for any value
B
where S
is Maybe.nothing()
.
S
- the type of the "larger" value for readingT
- the type of the "larger" value for puttingA
- the type of the "smaller" value that is readB
- the type of the "smaller" update valuelens
- the lensdefaultS
- the S to use if Maybe.nothing()
is givenpublic static <S,T,A,B> Lens<S,Maybe<T>,A,B> liftT(Lens<S,T,A,B> lens)
T
into Maybe
.S
- the type of the "larger" value for readingT
- the type of the "larger" value for puttingA
- the type of the "smaller" value that is readB
- the type of the "smaller" update valuelens
- the lenspublic static <S,T,A,B> Lens<S,T,Maybe<A>,B> liftA(Lens<S,T,A,B> lens)
A
into Maybe
.S
- the type of the "larger" value for readingT
- the type of the "larger" value for puttingA
- the type of the "smaller" value that is readB
- the type of the "smaller" update valuelens
- the lenspublic static <S,T,A,B> Lens<S,T,A,Maybe<B>> liftB(Lens<S,T,A,B> lens, B defaultB)
B
, lift B
into Maybe
.
Note that this lens is NOT lawful, since "putting back what you got changes nothing" fails for any value
B
where S
is Maybe.nothing()
.
S
- the type of the "larger" value for readingT
- the type of the "larger" value for puttingA
- the type of the "smaller" value that is readB
- the type of the "smaller" update valuelens
- the lensdefaultB
- the B to use if Maybe.nothing()
is givenpublic static <S,T,A,B> Lens<S,T,A,B> unLiftS(Lens<Maybe<S>,T,A,B> lens)
S
- the type of the "larger" value for readingT
- the type of the "larger" value for puttingA
- the type of the "smaller" value that is readB
- the type of the "smaller" update valuelens
- the lenspublic static <S,T,A,B> Lens<S,T,A,B> unLiftT(Lens<S,Maybe<T>,A,B> lens, T defaultT)
T
lifted into Maybe
and a default T
, flatten T
back down.
Note that while this lens is not *necessarily* unlawful, it probably is, since the only case where "you get back
what you put in" would not be violated is if T
could never be Maybe.nothing()
.
S
- the type of the "larger" value for readingT
- the type of the "larger" value for puttingA
- the type of the "smaller" value that is readB
- the type of the "smaller" update valuelens
- the lensdefaultT
- the T to use if lens produces Maybe.nothing()
public static <S,T,A,B> Lens<S,T,A,B> unLiftA(Lens<S,T,Maybe<A>,B> lens, A defaultA)
A
lifted into Maybe
and a default A
, flatten A
back down.
Note that while this lens is not *necessarily* unlawful, it probably is, since the only case where "putting back
what you got changes nothing" would not be violated is if A
could never be Maybe.nothing()
.
S
- the type of the "larger" value for readingT
- the type of the "larger" value for puttingA
- the type of the "smaller" value that is readB
- the type of the "smaller" update valuelens
- the lensdefaultA
- the A to use if lens produces Maybe.nothing()
public static <S,T,A,B> Lens<S,T,A,B> unLiftB(Lens<S,T,A,Maybe<B>> lens)
S
- the type of the "larger" value for readingT
- the type of the "larger" value for puttingA
- the type of the "smaller" value that is readB
- the type of the "smaller" update valuelens
- the lenspublic static <V> Lens.Simple<V,Maybe<V>> asMaybe()
Maybe
.V
- the value typeMaybe