A
- the value typepublic final class Identity<A> extends Object implements MonadRec<A,Identity<?>>, Traversable<A,Identity<?>>
A
that can be mapped over and retrieved later.Modifier and Type | Method and Description |
---|---|
<B> Identity<B> |
discardL(Applicative<B,Identity<?>> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
<B> Identity<A> |
discardR(Applicative<B,Identity<?>> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
boolean |
equals(Object other) |
<B> Identity<B> |
flatMap(Fn1<? super A,? extends Monad<B,Identity<?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
<B> Identity<B> |
fmap(Fn1<? super A,? extends B> fn)
Covariantly transmute this functor's parameter using the given mapping function.
|
int |
hashCode() |
<B> Lazy<Identity<B>> |
lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,Identity<?>>> lazyAppFn)
Given a
lazy instance of this applicative over a mapping function, "zip" the two instances together
using whatever application semantics the current applicative supports. |
<B> Identity<B> |
pure(B b)
Lift the value
b into this applicative functor. |
static Pure<Identity<?>> |
pureIdentity()
|
A |
runIdentity()
Retrieve the value.
|
String |
toString() |
<B> Identity<B> |
trampolineM(Fn1<? super A,? extends MonadRec<RecursiveResult<A,B>,Identity<?>>> fn)
Given some operation yielding a
RecursiveResult inside this MonadRec , internally trampoline the
operation until it yields a termination instruction. |
<B,App extends Applicative<?,App>,TravB extends Traversable<B,Identity<?>>,AppTrav extends Applicative<TravB,App>> |
traverse(Fn1<? super A,? extends Applicative<B,App>> fn,
Fn1<? super TravB,? 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> Identity<B> |
zip(Applicative<Fn1<? super A,? extends B>,Identity<?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using
whatever application semantics the current applicative supports.
|
public Identity(A a)
public A runIdentity()
public <B> Identity<B> flatMap(Fn1<? super A,? extends Monad<B,Identity<?>>> f)
public <B> Identity<B> fmap(Fn1<? super A,? extends B> fn)
fmap
in interface Applicative<A,Identity<?>>
fmap
in interface Functor<A,Identity<?>>
fmap
in interface Monad<A,Identity<?>>
fmap
in interface MonadRec<A,Identity<?>>
fmap
in interface Traversable<A,Identity<?>>
B
- the new parameter typefn
- the mapping functionpublic <B> Identity<B> pure(B b)
b
into this applicative functor.pure
in interface Applicative<A,Identity<?>>
pure
in interface Monad<A,Identity<?>>
pure
in interface MonadRec<A,Identity<?>>
B
- the type of the returned applicative's parameterb
- the valuepublic <B> Identity<B> zip(Applicative<Fn1<? super A,? extends B>,Identity<?>> appFn)
zip
in interface Applicative<A,Identity<?>>
zip
in interface Monad<A,Identity<?>>
zip
in interface MonadRec<A,Identity<?>>
B
- the resulting applicative parameter typeappFn
- the other applicative instancepublic <B> Lazy<Identity<B>> lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,Identity<?>>> lazyAppFn)
lazy
instance of this applicative over a mapping function, "zip" the two instances together
using whatever application semantics the current applicative supports. This is useful for applicatives that
support lazy evaluation and early termination.lazyZip
in interface Applicative<A,Identity<?>>
lazyZip
in interface Monad<A,Identity<?>>
lazyZip
in interface MonadRec<A,Identity<?>>
B
- the resulting applicative parameter typelazyAppFn
- the lazy other applicative instanceMaybe
,
Either
public <B> Identity<B> discardL(Applicative<B,Identity<?>> 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<A,Identity<?>>
discardL
in interface Monad<A,Identity<?>>
discardL
in interface MonadRec<A,Identity<?>>
B
- the type of the returned Applicative's parameterappB
- the other Applicativepublic <B> Identity<A> discardR(Applicative<B,Identity<?>> appB)
Applicative
and appB
, discarding appB's
result and
returning this Applicative
. This is generally useful for sequentially performing side-effects.public <B,App extends Applicative<?,App>,TravB extends Traversable<B,Identity<?>>,AppTrav extends Applicative<TravB,App>> AppTrav traverse(Fn1<? super A,? extends Applicative<B,App>> fn, Fn1<? super TravB,? 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<A,Identity<?>>
B
- the resulting element typeApp
- the result applicative typeTravB
- this Traversable instance over BAppTrav
- the full inferred resulting type from the traversalfn
- the function to applypure
- the applicative pure functionpublic <B> Identity<B> trampolineM(Fn1<? super A,? extends MonadRec<RecursiveResult<A,B>,Identity<?>>> 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<A,Identity<?>>
B
- 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