A
- The argument typeB
- The result type@FunctionalInterface public interface Fn1<A,B> extends MonadRec<B,Fn1<A,?>>, MonadReader<A,B,Fn1<A,?>>, MonadWriter<A,B,Fn1<A,?>>, Cartesian<A,B,Fn1<?,?>>, Cocartesian<A,B,Fn1<?,?>>
Modifier and Type | Method and Description |
---|---|
default <C,D> Fn2<A,C,D> |
andThen(Fn2<? super B,? super C,? extends D> after)
Left-to-right composition between different arity functions.
|
default B |
apply(A a)
Invoke this function explosively with the given argument.
|
default Fn1<A,Tuple2<A,B>> |
carry()
Pair the covariantly-positioned carrier type with the contravariantly-positioned carrier type.
|
default <C> Fn1<Tuple2<C,A>,Tuple2<C,B>> |
cartesian()
Pair a value with the input to this function, and preserve the paired value through to the output.
|
default Fn1<A,B> |
censor(Fn1<? super A,? extends A> fn)
Update the accumulated state.
|
B |
checkedApply(A a)
Invoke this function with the given argument, potentially throwing any
Throwable . |
default Fn1<A,Choice2<A,B>> |
choose()
Choose between a successful result
b or returning back the input, a . |
default <C> Fn1<Choice2<C,A>,Choice2<C,B>> |
cocartesian()
Choose between either applying this function or returning back a different result altogether.
|
default <Y,Z> Fn2<Y,Z,B> |
compose(Fn2<? super Y,? super Z,? extends A> before)
Right-to-left composition between different arity functions.
|
default <Z> Fn1<Z,B> |
contraMap(Fn1<? super Z,? extends A> fn)
Contravariantly map
A <- B . |
default <Z,C> Fn1<Z,C> |
diMap(Fn1<? super Z,? extends A> lFn,
Fn1<? super B,? extends C> rFn)
Exercise both
diMapL and diMapR over this function in the same invocation. |
default <Z> Fn1<Z,B> |
diMapL(Fn1<? super Z,? extends A> fn)
Contravariantly map over the argument to this function, producing a function that takes the new argument type,
and produces the same result.
|
default <C> Fn1<A,C> |
diMapR(Fn1<? super B,? extends C> fn)
Covariantly map over the return value of this function, producing a function that takes the same argument, and
produces the new result type.
|
default <C> Fn1<A,C> |
discardL(Applicative<C,Fn1<A,?>> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
default <C> Fn1<A,B> |
discardR(Applicative<C,Fn1<A,?>> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
default <C> Fn1<A,C> |
flatMap(Fn1<? super B,? extends Monad<C,Fn1<A,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
default <C> Fn1<A,C> |
fmap(Fn1<? super B,? extends C> f)
Also left-to-right composition (sadly).
|
static <A,B> Fn1<A,B> |
fn1(Fn1<? super A,? extends B> fn)
Static factory method for avoid explicit casting when using method references as
Fn1 s. |
static <A,B> Fn1<A,B> |
fromFunction(Function<? super A,? extends B> function)
|
default <C> Lazy<Fn1<A,C>> |
lazyZip(Lazy<? extends Applicative<Fn1<? super B,? extends C>,Fn1<A,?>>> 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. |
default <C> Fn1<A,Tuple2<B,C>> |
listens(Fn1<? super A,? extends C> fn)
Map the accumulation into a value and pair it with the current output.
|
default Fn1<A,B> |
local(Fn1<? super A,? extends A> fn)
Modify this
MonadReader's environment after reading it but before running the effect. |
default <C> Fn1<A,C> |
pure(C c)
Lift the value
b into this applicative functor. |
static <A> Pure<Fn1<A,?>> |
pureFn1()
|
default Fn0<B> |
thunk(A a)
|
default Function<A,B> |
toFunction()
|
default <C> Fn1<A,C> |
trampolineM(Fn1<? super B,? extends MonadRec<RecursiveResult<B,C>,Fn1<A,?>>> fn)
Given some operation yielding a
RecursiveResult inside this MonadRec , internally trampoline the
operation until it yields a termination instruction. |
default <Z> Fn2<Z,A,B> |
widen()
Widen this function's argument list by prepending an ignored argument of any type to the front.
|
default <C> Fn1<A,C> |
zip(Applicative<Fn1<? super B,? extends C>,Fn1<A,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using
whatever application semantics the current applicative supports.
|
default <C> Fn1<A,C> |
zip(Fn2<A,B,C> appFn) |
default B apply(A a)
a
- the argumentB checkedApply(A a) throws Throwable
Throwable
.a
- the argumentThrowable
- anything possibly thrown by the functiondefault Fn0<B> thunk(A a)
Fn1
to an Fn0
by supplying an argument to this function. Useful for fixing an
argument now, but deferring application until a later time.a
- the argumentFn0
default <Z> Fn2<Z,A,B> widen()
Z
- the new first argument typedefault Fn1<A,B> local(Fn1<? super A,? extends A> fn)
MonadReader's
environment after reading it but before running the effect.local
in interface MonadReader<A,B,Fn1<A,?>>
fn
- the modification functionMonadReader
with a modified environmentdefault <C> Fn1<A,Tuple2<B,C>> listens(Fn1<? super A,? extends C> fn)
listens
in interface MonadWriter<A,B,Fn1<A,?>>
C
- the mapped outputfn
- the mapping functionMonadWriter
default Fn1<A,B> censor(Fn1<? super A,? extends A> fn)
censor
in interface MonadWriter<A,B,Fn1<A,?>>
fn
- the update functionMonadWriter
default <C> Fn1<A,C> flatMap(Fn1<? super B,? extends Monad<C,Fn1<A,?>>> f)
flatMap
in interface Monad<B,Fn1<A,?>>
flatMap
in interface MonadReader<A,B,Fn1<A,?>>
flatMap
in interface MonadRec<B,Fn1<A,?>>
flatMap
in interface MonadWriter<A,B,Fn1<A,?>>
C
- the resulting monad parameter typef
- the dependent computation over Adefault <C> Fn1<A,C> fmap(Fn1<? super B,? extends C> f)
fmap
in interface Applicative<B,Fn1<A,?>>
fmap
in interface Functor<B,Fn1<A,?>>
fmap
in interface Monad<B,Fn1<A,?>>
fmap
in interface MonadReader<A,B,Fn1<A,?>>
fmap
in interface MonadRec<B,Fn1<A,?>>
fmap
in interface MonadWriter<A,B,Fn1<A,?>>
C
- the return type of the next function to invokef
- the function to invoke with this function's return valuedefault <C> Fn1<A,C> pure(C c)
b
into this applicative functor.pure
in interface Applicative<B,Fn1<A,?>>
pure
in interface Monad<B,Fn1<A,?>>
pure
in interface MonadReader<A,B,Fn1<A,?>>
pure
in interface MonadRec<B,Fn1<A,?>>
pure
in interface MonadWriter<A,B,Fn1<A,?>>
C
- the type of the returned applicative's parameterc
- the valuedefault <C> Fn1<A,C> zip(Applicative<Fn1<? super B,? extends C>,Fn1<A,?>> appFn)
zip
in interface Applicative<B,Fn1<A,?>>
zip
in interface Monad<B,Fn1<A,?>>
zip
in interface MonadReader<A,B,Fn1<A,?>>
zip
in interface MonadRec<B,Fn1<A,?>>
zip
in interface MonadWriter<A,B,Fn1<A,?>>
C
- the resulting applicative parameter typeappFn
- the other applicative instancedefault <C> Lazy<Fn1<A,C>> lazyZip(Lazy<? extends Applicative<Fn1<? super B,? extends C>,Fn1<A,?>>> 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<B,Fn1<A,?>>
lazyZip
in interface Monad<B,Fn1<A,?>>
lazyZip
in interface MonadReader<A,B,Fn1<A,?>>
lazyZip
in interface MonadRec<B,Fn1<A,?>>
lazyZip
in interface MonadWriter<A,B,Fn1<A,?>>
C
- the resulting applicative parameter typelazyAppFn
- the lazy other applicative instanceMaybe
,
Either
default <C> Fn1<A,C> trampolineM(Fn1<? super B,? extends MonadRec<RecursiveResult<B,C>,Fn1<A,?>>> 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,Fn1<A,?>>
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
default <C> Fn1<A,C> discardL(Applicative<C,Fn1<A,?>> 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,Fn1<A,?>>
discardL
in interface Monad<B,Fn1<A,?>>
discardL
in interface MonadReader<A,B,Fn1<A,?>>
discardL
in interface MonadRec<B,Fn1<A,?>>
discardL
in interface MonadWriter<A,B,Fn1<A,?>>
C
- the type of the returned Applicative's parameterappB
- the other Applicativedefault <C> Fn1<A,B> discardR(Applicative<C,Fn1<A,?>> 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<B,Fn1<A,?>>
discardR
in interface Monad<B,Fn1<A,?>>
discardR
in interface MonadReader<A,B,Fn1<A,?>>
discardR
in interface MonadRec<B,Fn1<A,?>>
discardR
in interface MonadWriter<A,B,Fn1<A,?>>
C
- the type of appB's parameterappB
- the other Applicativedefault <Z> Fn1<Z,B> diMapL(Fn1<? super Z,? extends A> fn)
diMapL
in interface Cartesian<A,B,Fn1<?,?>>
diMapL
in interface Cocartesian<A,B,Fn1<?,?>>
diMapL
in interface Profunctor<A,B,Fn1<?,?>>
Z
- the new argument typefn
- the contravariant argument mapping functionFn1
<Z, B>default <C> Fn1<A,C> diMapR(Fn1<? super B,? extends C> fn)
default <Z,C> Fn1<Z,C> diMap(Fn1<? super Z,? extends A> lFn, Fn1<? super B,? extends C> rFn)
diMapL
and diMapR
over this function in the same invocation.diMap
in interface Cartesian<A,B,Fn1<?,?>>
diMap
in interface Cocartesian<A,B,Fn1<?,?>>
diMap
in interface Profunctor<A,B,Fn1<?,?>>
Z
- the new argument typeC
- the new result typelFn
- the contravariant argument mapping functionrFn
- the covariant result mapping functionFn1
<Z, C>default <C> Fn1<Tuple2<C,A>,Tuple2<C,B>> cartesian()
default Fn1<A,Tuple2<A,B>> carry()
default <C> Fn1<Choice2<C,A>,Choice2<C,B>> cocartesian()
cocartesian
in interface Cocartesian<A,B,Fn1<?,?>>
C
- the potentially different resultFn1
default Fn1<A,Choice2<A,B>> choose()
b
or returning back the input, a
.default <Z> Fn1<Z,B> contraMap(Fn1<? super Z,? extends A> fn)
A <- B
.contraMap
in interface Cartesian<A,B,Fn1<?,?>>
contraMap
in interface Cocartesian<A,B,Fn1<?,?>>
contraMap
in interface Contravariant<A,Profunctor<?,B,Fn1<?,?>>>
contraMap
in interface Profunctor<A,B,Fn1<?,?>>
Z
- the new parameter typefn
- the mapping functiondefault <Y,Z> Fn2<Y,Z,B> compose(Fn2<? super Y,? super Z,? extends A> before)
Y
- the resulting function's first argument typeZ
- the resulting function's second argument typebefore
- the function to pass its return value to this function's inputFn2
<Y, Z, B>default <C,D> Fn2<A,C,D> andThen(Fn2<? super B,? super C,? extends D> after)
C
- the resulting function's second argument typeD
- the resulting function's return typeafter
- the function to invoke on this function's return valueFn2
<A, C, D>static <A,B> Fn1<A,B> fn1(Fn1<? super A,? extends B> fn)
Fn1
s.A
- the input typeB
- the output typefn
- the function to adaptFn1
static <A,B> Fn1<A,B> fromFunction(Function<? super A,? extends B> function)
A
- the input typeB
- the output typefunction
- the functionFn1