Class Callables
java.lang.Object
fj.control.parallel.Callables
Monadic functions and conversion methods for java.util.concurrent.Callable.
- Version:
- %build.number%
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <A,B> Callable <B> Performs function application within a callable (applicative functor pattern).arrow()Provides a transformation from a function to a Callable-valued function that is equivalent to it.static <A,B> Callable <B> Binds the given function to the value in a Callable with a final join.static <A,B, C> Callable <C> Binds the given function to the values in the given callables with a final join.callable()Provides a transformation from a value to a Callable that completely preserves that value.static <A> Callable<A> callable(A a) Returns a callable that completely preserves the argument.Wraps a given function's return value in a Callable.static <A> Callable<A> Returns a callable that throws the given exception.either()Returns a transformation from a Callable to an Either.Turns the given Callable into either an exception or the value in the Callable.Lifts any function to a function on Callables.Returns a transformation from an Either to a Callable.static <A> Callable<A> fromEither(F0<Either<Exception, A>> e) Turns a given Either value into the equivalent Callable.Returns a transformation from an optional value to a Callablestatic <A> Callable<A> fromOption(F0<Option<A>> o) Turns an optional value into a Callable.static <A> Callable<A> Joins a Callable of a Callable with a bind operation.Promotes a function of arity-2 to a function on callables.A first-class version of the normalise function.static <A> Callable<A> Normalises the given Callable by calling it and wrapping the result in a new Callable.option()Returns a transformation from a Callable to an optional value.Turns the given Callable into an optional value.Turns a List of Callables into a single Callable of a List.A first-class version of the sequence method.
-
Constructor Details
-
Callables
private Callables()
-
-
Method Details
-
callable
Returns a callable that completely preserves the argument. The unit function for Callables.- Parameters:
a- A value to preserve in a Callable- Returns:
- A Callable that yields the argument when called.
-
callable
-
callable
-
callable
-
arrow
-
bind
Binds the given function to the value in a Callable with a final join.- Parameters:
a- A value in a Callable to which to apply a function.f- A function to apply to the value in a Callable.- Returns:
- The result of applying the function in the second argument to the value of the Callable in the first.
-
fmap
-
apply
Performs function application within a callable (applicative functor pattern).- Parameters:
ca- The callable to which to apply a function.cf- The callable function to apply.- Returns:
- A new callable after applying the given callable function to the first argument.
-
bind
Binds the given function to the values in the given callables with a final join.- Parameters:
ca- A given callable to bind the given function with.cb- A given callable to bind the given function with.f- The function to apply to the values in the given callables.- Returns:
- A new callable after performing the map, then final join.
-
join
-
liftM2
-
sequence
-
sequence_
-
option
-
option
-
either
Turns the given Callable into either an exception or the value in the Callable.- Parameters:
a- The callable to convert to an Either value.- Returns:
- Either the value in the given Callable, or the Exception with which the Callable fails.
-
either
-
fromEither
-
fromEither
-
fromOption
-
fromOption
-
normalise
Normalises the given Callable by calling it and wrapping the result in a new Callable. If the given Callable throws an Exception, the resulting Callable will throw that same Exception.- Parameters:
a- The callable to evaluate.- Returns:
- A normalised callable that just returns the result of calling the given callable.
-
normalise
-