S
- the phantom typeB
- the value typepublic final class Tagged<S,B> extends Object implements MonadRec<B,Tagged<S,?>>, Traversable<B,Tagged<S,?>>, Cocartesian<S,B,Tagged<?,?>>
Const
, but the phantom parameter is in the contravariant position, and the value is in covariant
position.Modifier and Type | Method and Description |
---|---|
<C> Tagged<Choice2<C,S>,Choice2<C,B>> |
cocartesian()
Choose some type
C or this profunctor's carrier types. |
<Z> Tagged<Z,B> |
contraMap(Fn1<? super Z,? extends S> fn)
Contravariantly map
A <- B . |
<Z,C> Tagged<Z,C> |
diMap(Fn1<? super Z,? extends S> lFn,
Fn1<? super B,? extends C> rFn)
Dually map contravariantly over the left parameter and covariantly over the right parameter.
|
<Z> Tagged<Z,B> |
diMapL(Fn1<? super Z,? extends S> fn)
Contravariantly map over the left parameter.
|
<C> Tagged<S,C> |
diMapR(Fn1<? super B,? extends C> fn)
Covariantly map over the right parameter.
|
<C> Tagged<S,C> |
discardL(Applicative<C,Tagged<S,?>> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
<C> Tagged<S,B> |
discardR(Applicative<C,Tagged<S,?>> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
boolean |
equals(Object other) |
<C> Tagged<S,C> |
flatMap(Fn1<? super B,? extends Monad<C,Tagged<S,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
<C> Tagged<S,C> |
fmap(Fn1<? super B,? extends C> fn)
Covariantly transmute this functor's parameter using the given mapping function.
|
int |
hashCode() |
<C> Tagged<S,C> |
pure(C c)
Lift the value
b into this applicative functor. |
static <S> Pure<Tagged<S,?>> |
pureTagged()
|
String |
toString() |
<C> Tagged<S,C> |
trampolineM(Fn1<? super B,? extends MonadRec<RecursiveResult<B,C>,Tagged<S,?>>> fn)
Given some operation yielding a
RecursiveResult inside this MonadRec , internally trampoline the
operation until it yields a termination instruction. |
<C,App extends Applicative<?,App>,TravC extends Traversable<C,Tagged<S,?>>,AppTrav extends Applicative<TravC,App>> |
traverse(Fn1<? super B,? extends Applicative<C,App>> fn,
Fn1<? super TravC,? extends AppTrav> pure)
Apply
fn to each element of this traversable from left to right, and collapse the results into
a single resulting applicative, potentially with the assistance of the applicative's pure function. |
B |
unTagged()
Extract the contained value.
|
<C> Tagged<S,C> |
zip(Applicative<Fn1<? super B,? extends C>,Tagged<S,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using
whatever application semantics the current applicative supports.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
choose
public Tagged(B b)
public B unTagged()
public <C> Tagged<S,C> flatMap(Fn1<? super B,? extends Monad<C,Tagged<S,?>>> f)
public <C> Tagged<S,C> trampolineM(Fn1<? super B,? extends MonadRec<RecursiveResult<B,C>,Tagged<S,?>>> fn)
RecursiveResult
inside this MonadRec
, internally trampoline the
operation until it yields a termination
instruction.
Stack-safety depends on implementations guaranteeing that the growth of the call stack is a constant factor independent of the number of invocations of the operation. For various examples of how this can be achieved in stereotypical circumstances, see the referenced types.
trampolineM
in interface MonadRec<B,Tagged<S,?>>
C
- the ultimate resulting carrier typefn
- the function to internally trampolineMonadRec
for a basic implementation
,
for a {@link CoProduct2 coproduct} implementation
,
for an implementation leveraging an already stack-safe {@link Monad#flatMap(Fn1)}
,
for a {@link MonadT monad transformer} implementation
public <C> Tagged<S,C> pure(C c)
b
into this applicative functor.pure
in interface Applicative<B,Tagged<S,?>>
pure
in interface Monad<B,Tagged<S,?>>
pure
in interface MonadRec<B,Tagged<S,?>>
C
- the type of the returned applicative's parameterc
- the valuepublic <C> Tagged<S,C> fmap(Fn1<? super B,? extends C> fn)
fmap
in interface Applicative<B,Tagged<S,?>>
fmap
in interface Functor<B,Tagged<S,?>>
fmap
in interface Monad<B,Tagged<S,?>>
fmap
in interface MonadRec<B,Tagged<S,?>>
fmap
in interface Traversable<B,Tagged<S,?>>
C
- the new parameter typefn
- the mapping functionpublic <C> Tagged<S,C> zip(Applicative<Fn1<? super B,? extends C>,Tagged<S,?>> appFn)
zip
in interface Applicative<B,Tagged<S,?>>
zip
in interface Monad<B,Tagged<S,?>>
zip
in interface MonadRec<B,Tagged<S,?>>
C
- the resulting applicative parameter typeappFn
- the other applicative instancepublic <C> Tagged<S,C> discardL(Applicative<C,Tagged<S,?>> appB)
Applicative
and appB
, discarding this Applicative's
result and returning appB
. This is generally useful for sequentially performing side-effects.discardL
in interface Applicative<B,Tagged<S,?>>
discardL
in interface Monad<B,Tagged<S,?>>
discardL
in interface MonadRec<B,Tagged<S,?>>
C
- the type of the returned Applicative's parameterappB
- the other Applicativepublic <C> Tagged<S,B> discardR(Applicative<C,Tagged<S,?>> appB)
Applicative
and appB
, discarding appB's
result and
returning this Applicative
. This is generally useful for sequentially performing side-effects.public <C,App extends Applicative<?,App>,TravC extends Traversable<C,Tagged<S,?>>,AppTrav extends Applicative<TravC,App>> AppTrav traverse(Fn1<? super B,? extends Applicative<C,App>> fn, Fn1<? super TravC,? extends AppTrav> pure)
fn
to each element of this traversable from left to right, and collapse the results into
a single resulting applicative, potentially with the assistance of the applicative's pure function.traverse
in interface Traversable<B,Tagged<S,?>>
C
- the resulting element typeApp
- the result applicative typeTravC
- this Traversable instance over BAppTrav
- the full inferred resulting type from the traversalfn
- the function to applypure
- the applicative pure functionpublic <C> Tagged<Choice2<C,S>,Choice2<C,B>> cocartesian()
C
or this profunctor's carrier types.cocartesian
in interface Cocartesian<S,B,Tagged<?,?>>
C
- the choice typepublic <Z,C> Tagged<Z,C> diMap(Fn1<? super Z,? extends S> lFn, Fn1<? super B,? extends C> rFn)
diMapL(lFn).diMapR(rFn)
.diMap
in interface Cocartesian<S,B,Tagged<?,?>>
diMap
in interface Profunctor<S,B,Tagged<?,?>>
Z
- the new left parameter typeC
- the new right parameter typelFn
- the left parameter mapping functionrFn
- the right parameter mapping functionpublic <Z> Tagged<Z,B> diMapL(Fn1<? super Z,? extends S> fn)
diMapL
in interface Cocartesian<S,B,Tagged<?,?>>
diMapL
in interface Profunctor<S,B,Tagged<?,?>>
Z
- the new left parameter typefn
- the mapping functionpublic <C> Tagged<S,C> diMapR(Fn1<? super B,? extends C> fn)
diMapR(f) == fmap(f)
.diMapR
in interface Cocartesian<S,B,Tagged<?,?>>
diMapR
in interface Profunctor<S,B,Tagged<?,?>>
C
- the new right parameter typefn
- the mapping functionpublic <Z> Tagged<Z,B> contraMap(Fn1<? super Z,? extends S> fn)
A <- B
.contraMap
in interface Cocartesian<S,B,Tagged<?,?>>
contraMap
in interface Contravariant<S,Profunctor<?,B,Tagged<?,?>>>
contraMap
in interface Profunctor<S,B,Tagged<?,?>>
Z
- the new parameter typefn
- the mapping function