Interface Fn0<A>
-
- Type Parameters:
A
- the result type
- All Superinterfaces:
Applicative<A,Fn1<Unit,?>>
,Cartesian<Unit,A,Fn1<?,?>>
,Cocartesian<Unit,A,Fn1<?,?>>
,Contravariant<Unit,Profunctor<?,A,Fn1<?,?>>>
,Fn1<Unit,A>
,Functor<A,Fn1<Unit,?>>
,Monad<A,Fn1<Unit,?>>
,MonadReader<Unit,A,Fn1<Unit,?>>
,MonadRec<A,Fn1<Unit,?>>
,MonadWriter<Unit,A,Fn1<Unit,?>>
,Profunctor<Unit,A,Fn1<?,?>>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Fn0<A> extends Fn1<Unit,A>
- See Also:
Fn1
,Callable
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default A
apply()
A
checkedApply()
default A
checkedApply(Unit unit)
Invoke this function with the given argument, potentially throwing anyThrowable
.default <B> Fn0<B>
diMapR(Fn1<? super A,? extends B> 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 <B> Fn0<B>
discardL(Applicative<B,Fn1<Unit,?>> appB)
Sequence both thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
.default <B> Fn0<A>
discardR(Applicative<B,Fn1<Unit,?>> appB)
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
.default <B> Fn0<B>
flatMap(Fn1<? super A,? extends Monad<B,Fn1<Unit,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.default <B> Fn0<B>
fmap(Fn1<? super A,? extends B> f)
Left-to-right composition.static <A> Fn0<A>
fn0(Fn0<A> fn)
Static factory method for coercing a lambda to anFn0
.static <A> Fn0<A>
fn0(Fn1<Unit,A> fn)
static <A> Fn0<A>
fromCallable(java.util.concurrent.Callable<A> callable)
Convenience method for converting aCallable
to anFn0
.static <A> Fn0<A>
fromSupplier(java.util.function.Supplier<A> supplier)
Convenience method for converting aSupplier
to anFn0
.default <B> Fn0<B>
pure(B b)
Lift the valueb
into this applicative functor.default java.util.concurrent.Callable<A>
toCallable()
Convert thisFn0
to a javaCallable
default java.util.function.Supplier<A>
toSupplier()
Convert thisFn0
to a javaSupplier
default <B> Fn0<B>
zip(Fn2<Unit,A,B> appFn)
default <B> Fn0<B>
zip(Applicative<Fn1<? super A,? extends B>,Fn1<Unit,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
-
-
-
Method Detail
-
checkedApply
A checkedApply() throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
apply
default A apply()
- Returns:
- the result
-
toSupplier
default java.util.function.Supplier<A> toSupplier()
Convert thisFn0
to a javaSupplier
- Returns:
- the
Supplier
-
toCallable
default java.util.concurrent.Callable<A> toCallable()
Convert thisFn0
to a javaCallable
- Returns:
- the
Callable
-
checkedApply
default A checkedApply(Unit unit) throws java.lang.Throwable
Invoke this function with the given argument, potentially throwing anyThrowable
.- Specified by:
checkedApply
in interfaceFn1<Unit,A>
- Parameters:
unit
- the argument- Returns:
- the result of the function application
- Throws:
java.lang.Throwable
- anything possibly thrown by the function
-
flatMap
default <B> Fn0<B> flatMap(Fn1<? super A,? extends Monad<B,Fn1<Unit,?>>> f)
Description copied from interface:Fn1
Chain dependent computations that may continue or short-circuit based on previous results.- Specified by:
flatMap
in interfaceFn1<Unit,A>
- Specified by:
flatMap
in interfaceMonad<A,Fn1<Unit,?>>
- Specified by:
flatMap
in interfaceMonadReader<Unit,A,Fn1<Unit,?>>
- Specified by:
flatMap
in interfaceMonadRec<A,Fn1<Unit,?>>
- Specified by:
flatMap
in interfaceMonadWriter<Unit,A,Fn1<Unit,?>>
- Type Parameters:
B
- the resulting monad parameter type- Parameters:
f
- the dependent computation over A- Returns:
- the new monad instance
-
fmap
default <B> Fn0<B> fmap(Fn1<? super A,? extends B> f)
Description copied from interface:Fn1
Left-to-right composition.- Specified by:
fmap
in interfaceApplicative<A,Fn1<Unit,?>>
- Specified by:
fmap
in interfaceFn1<Unit,A>
- Specified by:
fmap
in interfaceFunctor<A,Fn1<Unit,?>>
- Specified by:
fmap
in interfaceMonad<A,Fn1<Unit,?>>
- Specified by:
fmap
in interfaceMonadReader<Unit,A,Fn1<Unit,?>>
- Specified by:
fmap
in interfaceMonadRec<A,Fn1<Unit,?>>
- Specified by:
fmap
in interfaceMonadWriter<Unit,A,Fn1<Unit,?>>
- Type Parameters:
B
- the return type of the next function to invoke- Parameters:
f
- the function to invoke with this function's return value- Returns:
- a function representing the composition of this function and f
-
pure
default <B> Fn0<B> pure(B b)
Description copied from interface:Fn1
Lift the valueb
into this applicative functor.- Specified by:
pure
in interfaceApplicative<A,Fn1<Unit,?>>
- Specified by:
pure
in interfaceFn1<Unit,A>
- Specified by:
pure
in interfaceMonad<A,Fn1<Unit,?>>
- Specified by:
pure
in interfaceMonadReader<Unit,A,Fn1<Unit,?>>
- Specified by:
pure
in interfaceMonadRec<A,Fn1<Unit,?>>
- Specified by:
pure
in interfaceMonadWriter<Unit,A,Fn1<Unit,?>>
- Type Parameters:
B
- the type of the returned applicative's parameter- Parameters:
b
- the value- Returns:
- an instance of this applicative over b
-
zip
default <B> Fn0<B> zip(Applicative<Fn1<? super A,? extends B>,Fn1<Unit,?>> appFn)
Description copied from interface:Fn1
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.- Specified by:
zip
in interfaceApplicative<A,Fn1<Unit,?>>
- Specified by:
zip
in interfaceFn1<Unit,A>
- Specified by:
zip
in interfaceMonad<A,Fn1<Unit,?>>
- Specified by:
zip
in interfaceMonadReader<Unit,A,Fn1<Unit,?>>
- Specified by:
zip
in interfaceMonadRec<A,Fn1<Unit,?>>
- Specified by:
zip
in interfaceMonadWriter<Unit,A,Fn1<Unit,?>>
- Type Parameters:
B
- the resulting applicative parameter type- Parameters:
appFn
- the other applicative instance- Returns:
- the mapped applicative
-
discardL
default <B> Fn0<B> discardL(Applicative<B,Fn1<Unit,?>> appB)
Description copied from interface:Fn1
Sequence both thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
. This is generally useful for sequentially performing side-effects.- Specified by:
discardL
in interfaceApplicative<A,Fn1<Unit,?>>
- Specified by:
discardL
in interfaceFn1<Unit,A>
- Specified by:
discardL
in interfaceMonad<A,Fn1<Unit,?>>
- Specified by:
discardL
in interfaceMonadReader<Unit,A,Fn1<Unit,?>>
- Specified by:
discardL
in interfaceMonadRec<A,Fn1<Unit,?>>
- Specified by:
discardL
in interfaceMonadWriter<Unit,A,Fn1<Unit,?>>
- Type Parameters:
B
- the type of the returned Applicative's parameter- Parameters:
appB
- the other Applicative- Returns:
- appB
-
discardR
default <B> Fn0<A> discardR(Applicative<B,Fn1<Unit,?>> appB)
Description copied from interface:Fn1
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
. This is generally useful for sequentially performing side-effects.- Specified by:
discardR
in interfaceApplicative<A,Fn1<Unit,?>>
- Specified by:
discardR
in interfaceFn1<Unit,A>
- Specified by:
discardR
in interfaceMonad<A,Fn1<Unit,?>>
- Specified by:
discardR
in interfaceMonadReader<Unit,A,Fn1<Unit,?>>
- Specified by:
discardR
in interfaceMonadRec<A,Fn1<Unit,?>>
- Specified by:
discardR
in interfaceMonadWriter<Unit,A,Fn1<Unit,?>>
- Type Parameters:
B
- the type of appB's parameter- Parameters:
appB
- the other Applicative- Returns:
- this Applicative
-
diMapR
default <B> Fn0<B> diMapR(Fn1<? super A,? extends B> fn)
Description copied from interface:Fn1
Covariantly map over the return value of this function, producing a function that takes the same argument, and produces the new result type.- Specified by:
diMapR
in interfaceCartesian<Unit,A,Fn1<?,?>>
- Specified by:
diMapR
in interfaceCocartesian<Unit,A,Fn1<?,?>>
- Specified by:
diMapR
in interfaceFn1<Unit,A>
- Specified by:
diMapR
in interfaceProfunctor<Unit,A,Fn1<?,?>>
- Type Parameters:
B
- the new result type- Parameters:
fn
- the covariant result mapping function- Returns:
- an
Fn1
<A, C>
-
fromSupplier
static <A> Fn0<A> fromSupplier(java.util.function.Supplier<A> supplier)
Convenience method for converting aSupplier
to anFn0
.- Type Parameters:
A
- the output type- Parameters:
supplier
- the supplier- Returns:
- the
Fn0
-
fromCallable
static <A> Fn0<A> fromCallable(java.util.concurrent.Callable<A> callable)
Convenience method for converting aCallable
to anFn0
.- Type Parameters:
A
- the output type- Parameters:
callable
- the callable- Returns:
- the
Fn0
-
fn0
static <A> Fn0<A> fn0(Fn0<A> fn)
Static factory method for coercing a lambda to anFn0
.- Type Parameters:
A
- the output type- Parameters:
fn
- the lambda to coerce- Returns:
- the
Fn0
-
-