A
- the Iterable
element typepublic final class LambdaIterable<A> extends Object implements MonadRec<A,LambdaIterable<?>>, Traversable<A,LambdaIterable<?>>
LambdaMap
Modifier and Type | Method and Description |
---|---|
<B> LambdaIterable<B> |
discardL(Applicative<B,LambdaIterable<?>> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
<B> LambdaIterable<A> |
discardR(Applicative<B,LambdaIterable<?>> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
static <A> LambdaIterable<A> |
empty()
Construct an empty
LambdaIterable by wrapping Collections.emptyList() . |
boolean |
equals(Object other) |
<B> LambdaIterable<B> |
flatMap(Fn1<? super A,? extends Monad<B,LambdaIterable<?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
<B> LambdaIterable<B> |
fmap(Fn1<? super A,? extends B> fn)
Covariantly transmute this functor's parameter using the given mapping function.
|
int |
hashCode() |
<B> Lazy<LambdaIterable<B>> |
lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,LambdaIterable<?>>> 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> LambdaIterable<B> |
pure(B b)
Lift the value
b into this applicative functor. |
static Pure<LambdaIterable<?>> |
pureLambdaIterable()
The canonical
Pure instance for LambdaIterable . |
<B> LambdaIterable<B> |
trampolineM(Fn1<? super A,? extends MonadRec<RecursiveResult<A,B>,LambdaIterable<?>>> 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,LambdaIterable<?>>,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. |
Iterable<A> |
unwrap()
Unwrap the underlying
Iterable . |
static <A> LambdaIterable<A> |
wrap(Iterable<? extends A> as)
Wrap an
Iterable in a LambdaIterable . |
<B> LambdaIterable<B> |
zip(Applicative<Fn1<? super A,? extends B>,LambdaIterable<?>> 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 <B> LambdaIterable<B> fmap(Fn1<? super A,? extends B> fn)
fmap
in interface Applicative<A,LambdaIterable<?>>
fmap
in interface Functor<A,LambdaIterable<?>>
fmap
in interface Monad<A,LambdaIterable<?>>
fmap
in interface MonadRec<A,LambdaIterable<?>>
fmap
in interface Traversable<A,LambdaIterable<?>>
B
- the new parameter typefn
- the mapping functionpublic <B> LambdaIterable<B> pure(B b)
b
into this applicative functor.pure
in interface Applicative<A,LambdaIterable<?>>
pure
in interface Monad<A,LambdaIterable<?>>
pure
in interface MonadRec<A,LambdaIterable<?>>
B
- the type of the returned applicative's parameterb
- the valuepublic <B> LambdaIterable<B> zip(Applicative<Fn1<? super A,? extends B>,LambdaIterable<?>> appFn)
In this case, calculate the cartesian product of applications of all functions in appFn
to all
values wrapped by this LambdaIterable
.
zip
in interface Applicative<A,LambdaIterable<?>>
zip
in interface Monad<A,LambdaIterable<?>>
zip
in interface MonadRec<A,LambdaIterable<?>>
B
- the new parameter typeappFn
- the other applicative instancepublic <B> Lazy<LambdaIterable<B>> lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,LambdaIterable<?>>> 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,LambdaIterable<?>>
lazyZip
in interface Monad<A,LambdaIterable<?>>
lazyZip
in interface MonadRec<A,LambdaIterable<?>>
B
- the resulting applicative parameter typelazyAppFn
- the lazy other applicative instanceMaybe
,
Either
public <B> LambdaIterable<B> discardL(Applicative<B,LambdaIterable<?>> 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,LambdaIterable<?>>
discardL
in interface Monad<A,LambdaIterable<?>>
discardL
in interface MonadRec<A,LambdaIterable<?>>
B
- the type of the returned Applicative's parameterappB
- the other Applicativepublic <B> LambdaIterable<A> discardR(Applicative<B,LambdaIterable<?>> appB)
Applicative
and appB
, discarding appB's
result and
returning this Applicative
. This is generally useful for sequentially performing side-effects.discardR
in interface Applicative<A,LambdaIterable<?>>
discardR
in interface Monad<A,LambdaIterable<?>>
discardR
in interface MonadRec<A,LambdaIterable<?>>
B
- the type of appB's parameterappB
- the other Applicativepublic <B> LambdaIterable<B> flatMap(Fn1<? super A,? extends Monad<B,LambdaIterable<?>>> f)
flatMap
in interface Monad<A,LambdaIterable<?>>
flatMap
in interface MonadRec<A,LambdaIterable<?>>
B
- the resulting monad parameter typef
- the dependent computation over Apublic <B> LambdaIterable<B> trampolineM(Fn1<? super A,? extends MonadRec<RecursiveResult<A,B>,LambdaIterable<?>>> 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,LambdaIterable<?>>
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
public <B,App extends Applicative<?,App>,TravB extends Traversable<B,LambdaIterable<?>>,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,LambdaIterable<?>>
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 static <A> LambdaIterable<A> wrap(Iterable<? extends A> as)
Iterable
in a LambdaIterable
.A
- the Iterable element typeas
- the IterableLambdaIterable
public static <A> LambdaIterable<A> empty()
LambdaIterable
by wrapping Collections.emptyList()
.A
- the Iterable element typeLambdaIterable
public static Pure<LambdaIterable<?>> pureLambdaIterable()
Pure
instance for LambdaIterable
.Pure
instance