Package fj
Class Function
java.lang.Object
fj.Function
Transformations on functions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionandThen()
Function composition flipped.static <A,
B, C> F <A, C> Function composition flipped.apply
(A a) Function application with the arguments flipped.static <A,
B, C> F <C, B> Performs function application within a higher-order function (applicative functor pattern).static <A,
B, C> F <C, B> Performs function application within a higher-order function (applicative functor pattern).static <A,
B, C> F <C, B> Binds the function in the second argument to the function in the first argument.static <A,
B, C, D>
F<D, C> Binds the given function f to the values of the given functions, with a final join.compose()
Function composition.static <A,
B, C> F <A, C> Function composition.Function composition.constant()
Returns a function that given an argument, returns a function that ignores its argument.static <A,
B> F <A, B> constant
(B b) Returns a function that ignores its argument to constantly produce the given value.Curry a function of arity-2.static <A,
B, C> F <B, C> Curry a function of arity-2.Curry a function of arity-3.Curry a function of arity-3.static <A,
B, C, D>
F<C, D> Curry a function of arity-3.Curry a function of arity-4.Curry a function of arity-4.Curry a function of arity-4.static <A,
B, C, D, E>
F<D, E> Curry a function of arity-4.Curry a function of arity-5.Curry a function of arity-5.Curry a function of arity-5.Curry a function of arity-5.static <A,
B, C, D, E, F$>
F<E, F$> Curry a function of arity-5.Curry a function of arity-6.Curry a function of arity-7.Curry a function of arity-7.Curry a function of arity-7.Curry a function of arity-7.Curry a function of arity-7.Curry a function of arity-7.static <A,
B, C, D, E, F$, G, H>
F<G, H> Curry a function of arity-7.Curry a function of arity-8.Curry a function of arity-8.Curry a function of arity-8.Curry a function of arity-8.Curry a function of arity-8.Curry a function of arity-8.Curry a function of arity-8.static <A,
B, C, D, E, F$, G, H, I>
F<H, I> Curry a function of arity-7.flip()
Function argument flipping.Function argument flipping.static <A,
B, C> F2 <B, A, C> Function argument flipping.flip2()
Function argument flipping.static <A> F
<A, A> identity()
The identity transformation.static <A,
B> F <B, A> Joins two arguments of a function of arity-2 into one argument, yielding a function of arity-1.Promotes a function of arity-2 to a higher-order function.Return a function that inspects the argument of the given function for anull
value and if so, does not apply the value, instead returning an empty optional value.Applies a given function over the arguments of another function of arity-2.static <A,
B, C> F <A, C> partialApply2
(F<A, F<B, C>> f, B b) Partial application of the second argument to the supplied function to get a function of typeA -> C
.partialApply3
(F<A, F<B, F<C, D>>> f, C c) Partial application of the third argument to the supplied function to get a function of typeA -> B -> D
.partialApply4
(F<A, F<B, F<C, F<D, E>>>> f, D d) Partial application of the fourth argument to the supplied function to get a function of typeA -> B -> C -> E
.Partial application of the fifth argument to the supplied function to get a function of typeA -> B -> C -> D -> F$
.Partial application of the sixth argument to the supplied function to get a function of typeA -> B -> C -> D -> E -> G
.Partial application of the seventh argument to the supplied function to get a function of typeA -> B -> C -> D -> E -> F$ -> H
.Partial application of the eigth argument to the supplied function to get a function of typeA -> B -> C -> D -> E -> F$ -> G -> I
.Uncurry a function of arity-2.static <A,
B, C> F2 <A, B, C> Uncurry a function of arity-2.Uncurry a function of arity-3.static <A,
B, C, D>
F3<A, B, C, D> Uncurry a function of arity-3.Uncurry a function of arity-4.static <A,
B, C, D, E>
F4<A, B, C, D, E> Uncurry a function of arity-4.Uncurry a function of arity-5.static <A,
B, C, D, E, F$>
F5<A, B, C, D, E, F$> Uncurry a function of arity-6.Uncurry a function of arity-6.static <A,
B, C, D, E, F$, G>
F6<A, B, C, D, E, F$, G> Uncurry a function of arity-6.Uncurry a function of arity-7.static <A,
B, C, D, E, F$, G, H>
F7<A, B, C, D, E, F$, G, H> Uncurry a function of arity-7.static <A,
B, C, D, E, F$, G, H, I>
F<F<A, F<B, F<C, F<D, F<E, F<F$, F<G, F<H, I>>>>>>>>, F8<A, B, C, D, E, F$, G, H, I>> Uncurry a function of arity-8.static <A,
B, C, D, E, F$, G, H, I>
F8<A, B, C, D, E, F$, G, H, I> Uncurry a function of arity-8.vary()
Simultaneously covaries and contravaries a function.static <A,
B> F <A, B> Simultaneously covaries and contravaries a function.
-
Constructor Details
-
Function
private Function()
-
-
Method Details
-
apply
Function application with the arguments flipped.- Parameters:
a
- The value to apply the function to.- Returns:
- A function that is partially-applied to the given value.
-
compose
Function composition.- Returns:
- A function that composes two functions to produce a new function.
-
compose
Function composition.- Parameters:
f
- A function to compose with another.g
- A function to compose with another.- Returns:
- A function that is the composition of the given arguments.
-
compose2
Function composition.- Parameters:
f
- A function to compose with another.g
- A function to compose with another.- Returns:
- A function that is the composition of the given arguments.
-
andThen
Function composition flipped.- Returns:
- A function that composes two functions to produce a new function.
-
andThen
Function composition flipped.- Parameters:
g
- A function to compose with another.f
- A function to compose with another.- Returns:
- A function that is the composition of the given arguments.
-
identity
The identity transformation.- Returns:
- The identity transformation.
-
constant
Returns a function that given an argument, returns a function that ignores its argument.- Returns:
- A function that given an argument, returns a function that ignores its argument.
-
constant
Returns a function that ignores its argument to constantly produce the given value.- Parameters:
b
- The value to return when the returned function is applied.- Returns:
- A function that ignores its argument to constantly produce the given value.
-
vary
Simultaneously covaries and contravaries a function.- Parameters:
f
- The function to vary.- Returns:
- A co- and contravariant function that invokes f on its argument.
-
vary
Simultaneously covaries and contravaries a function.- Returns:
- A function that varies and covaries a function.
-
flip
Function argument flipping.- Returns:
- A function that takes a function and flips its arguments.
-
flip
Function argument flipping.- Parameters:
f
- The function to flip.- Returns:
- The given function flipped.
-
flip
Function argument flipping.- Parameters:
f
- The function to flip.- Returns:
- The given function flipped.
-
flip2
Function argument flipping.- Returns:
- A function that flips the arguments of a given function.
-
nullable
Return a function that inspects the argument of the given function for anull
value and if so, does not apply the value, instead returning an empty optional value.- Parameters:
f
- The function to check for anull
argument.- Returns:
- A function that inspects the argument of the given function for a
null
value and if so, does not apply the value, instead returning an empty optional value.
-
curry
Curry a function of arity-2.- Parameters:
f
- The function to curry.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-2.- Parameters:
f
- The function to curry.a
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
uncurryF2
Uncurry a function of arity-2.- Returns:
- An uncurried function.
-
uncurryF2
Uncurry a function of arity-2.- Parameters:
f
- The function to uncurry.- Returns:
- An uncurried function.
-
curry
Curry a function of arity-3.- Parameters:
f
- The function to curry.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-3.- Parameters:
f
- The function to curry.a
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-3.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
uncurryF3
Uncurry a function of arity-3.- Returns:
- An uncurried function.
-
uncurryF3
Uncurry a function of arity-3.- Parameters:
f
- The function to uncurry.- Returns:
- An uncurried function.
-
curry
Curry a function of arity-4.- Parameters:
f
- The function to curry.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-4.- Parameters:
f
- The function to curry.a
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-4.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-4.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
uncurryF4
Uncurry a function of arity-4.- Returns:
- An uncurried function.
-
uncurryF4
Uncurry a function of arity-4.- Parameters:
f
- The function to uncurry.- Returns:
- An uncurried function.
-
curry
Curry a function of arity-5.- Parameters:
f
- The function to curry.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-5.- Parameters:
f
- The function to curry.a
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-5.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-5.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
Curry a function of arity-5.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.d
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
uncurryF5
Uncurry a function of arity-5.- Returns:
- An uncurried function.
-
uncurryF5
Uncurry a function of arity-6.- Parameters:
f
- The function to uncurry.- Returns:
- An uncurried function.
-
curry
Curry a function of arity-6.- Parameters:
f
- The function to curry.- Returns:
- A curried form of the given function.
-
uncurryF6
public static <A,B, F<F<A,C, D, E, F$, G> F<B, uncurryF6()F<C, F<D, F<E, F<F$, G>>>>>>, F6<A, B, C, D, E, F$, G>> Uncurry a function of arity-6.- Returns:
- An uncurried function.
-
uncurryF6
public static <A,B, F6<A,C, D, E, F$, G> B, uncurryF6C, D, E, F$, G> (F<A, F<B, F<C, F<D, F<E, F<F$, G>>>>>> f) Uncurry a function of arity-6.- Parameters:
f
- The function to uncurry.- Returns:
- An uncurried function.
-
curry
public static <A,B, F<A,C, D, E, F$, G, H> F<B, curryF<C, F<D, F<E, F<F$, F<G, H>>>>>>> (F7<A, B, C, D, E, F$, G, H> f) Curry a function of arity-7.- Parameters:
f
- The function to curry.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<B,C, D, E, F$, G, H> F<C, curryF<D, F<E, F<F$, F<G, H>>>>>> (F7<A, B, C, D, E, F$, G, H> f, A a) Curry a function of arity-7.- Parameters:
f
- The function to curry.a
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<C,C, D, E, F$, G, H> F<D, curryF<E, F<F$, F<G, H>>>>> (F7<A, B, C, D, E, F$, G, H> f, A a, B b) Curry a function of arity-7.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<D,C, D, E, F$, G, H> F<E, curryF<F$, F<G, H>>>> (F7<A, B, C, D, E, F$, G, H> f, A a, B b, C c) Curry a function of arity-7.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<E,C, D, E, F$, G, H> F<F$, curryF<G, H>>> (F7<A, B, C, D, E, F$, G, H> f, A a, B b, C c, D d) Curry a function of arity-7.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.d
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<F$,C, D, E, F$, G, H> F<G, curryH>> (F7<A, B, C, D, E, F$, G, H> f, A a, B b, C c, D d, E e) Curry a function of arity-7.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.d
- An argument to the curried function.e
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<G,C, D, E, F$, G, H> H> curry(F7<A, B, C, D, E, F$, G, H> f, A a, B b, C c, D d, E e, F$ f$) Curry a function of arity-7.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.d
- An argument to the curried function.e
- An argument to the curried function.f$
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
uncurryF7
public static <A,B, F<F<A,C, D, E, F$, G, H> F<B, uncurryF7()F<C, F<D, F<E, F<F$, F<G, H>>>>>>>, F7<A, B, C, D, E, F$, G, H>> Uncurry a function of arity-7.- Returns:
- An uncurried function.
-
uncurryF7
public static <A,B, F7<A,C, D, E, F$, G, H> B, uncurryF7C, D, E, F$, G, H> (F<A, F<B, F<C, F<D, F<E, F<F$, F<G, H>>>>>>> f) Uncurry a function of arity-7.- Parameters:
f
- The function to uncurry.- Returns:
- An uncurried function.
-
curry
public static <A,B, F<A,C, D, E, F$, G, H, I> F<B, curryF<C, F<D, F<E, F<F$, F<G, F<H, I>>>>>>>> (F8<A, B, C, D, E, F$, G, H, I> f) Curry a function of arity-8.- Parameters:
f
- The function to curry.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<B,C, D, E, F$, G, H, I> F<C, curryF<D, F<E, F<F$, F<G, F<H, I>>>>>>> (F8<A, B, C, D, E, F$, G, H, I> f, A a) Curry a function of arity-8.- Parameters:
f
- The function to curry.a
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<C,C, D, E, F$, G, H, I> F<D, curryF<E, F<F$, F<G, F<H, I>>>>>> (F8<A, B, C, D, E, F$, G, H, I> f, A a, B b) Curry a function of arity-8.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<D,C, D, E, F$, G, H, I> F<E, curryF<F$, F<G, F<H, I>>>>> (F8<A, B, C, D, E, F$, G, H, I> f, A a, B b, C c) Curry a function of arity-8.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<E,C, D, E, F$, G, H, I> F<F$, curryF<G, F<H, I>>>> (F8<A, B, C, D, E, F$, G, H, I> f, A a, B b, C c, D d) Curry a function of arity-8.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.d
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<F$,C, D, E, F$, G, H, I> F<G, curryF<H, I>>> (F8<A, B, C, D, E, F$, G, H, I> f, A a, B b, C c, D d, E e) Curry a function of arity-8.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.d
- An argument to the curried function.e
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<G,C, D, E, F$, G, H, I> F<H, curryI>> (F8<A, B, C, D, E, F$, G, H, I> f, A a, B b, C c, D d, E e, F$ f$) Curry a function of arity-8.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.d
- An argument to the curried function.e
- An argument to the curried function.f$
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
curry
public static <A,B, F<H,C, D, E, F$, G, H, I> I> curry(F8<A, B, C, D, E, F$, G, H, I> f, A a, B b, C c, D d, E e, F$ f$, G g) Curry a function of arity-7.- Parameters:
f
- The function to curry.a
- An argument to the curried function.b
- An argument to the curried function.c
- An argument to the curried function.d
- An argument to the curried function.e
- An argument to the curried function.f$
- An argument to the curried function.g
- An argument to the curried function.- Returns:
- A curried form of the given function.
-
uncurryF8
public static <A,B, F<F<A,C, D, E, F$, G, H, I> F<B, uncurryF8()F<C, F<D, F<E, F<F$, F<G, F<H, I>>>>>>>>, F8<A, B, C, D, E, F$, G, H, I>> Uncurry a function of arity-8.- Returns:
- An uncurried function.
-
uncurryF8
public static <A,B, F8<A,C, D, E, F$, G, H, I> B, uncurryF8C, D, E, F$, G, H, I> (F<A, F<B, F<C, F<D, F<E, F<F$, F<G, F<H, I>>>>>>>> f) Uncurry a function of arity-8.- Parameters:
f
- The function to uncurry.- Returns:
- An uncurried function.
-
bind
Binds the function in the second argument to the function in the first argument.- Parameters:
ma
- A function whose argument type is the same as the argument type of the return value.f
- A function whose argument type is the same as the return type of ma, and yields the return value.- Returns:
- A function that chains the given functions together such that the result of applying ma to the argument is given to f, yielding a function that is applied to the argument again.
-
apply
Performs function application within a higher-order function (applicative functor pattern).- Parameters:
cab
- The higher-order function to apply a function to.ca
- A function to apply within a higher-order function.- Returns:
- A new function after applying the given higher-order function to the given function.
-
apply
Performs function application within a higher-order function (applicative functor pattern).- Parameters:
cab
- The higher-order function to apply a function to.ca
- A function to apply within a higher-order function.- Returns:
- A new function after applying the given higher-order function to the given function.
-
bind
Binds the given function f to the values of the given functions, with a final join.- Parameters:
ca
- A function to bind f function to.cb
- A function to bind f function to.f
- The bound function to be composed with ca and then applied with cb- Returns:
- A new function after performing the composition, then application.
-
on
Applies a given function over the arguments of another function of arity-2.- Parameters:
a
- The function whose arguments to apply another function over.f
- The function to apply over the arguments of another function.- Returns:
- A function whose arguments are fed through function f, before being passed to function a.
-
lift
Promotes a function of arity-2 to a higher-order function.- Parameters:
f
- The function to promote.- Returns:
- A function of arity-2 promoted to compose with two functions.
-
join
Joins two arguments of a function of arity-2 into one argument, yielding a function of arity-1.- Parameters:
f
- A function whose arguments to join.- Returns:
- A function of arity-1 whose argument is substituted for both parameters of f.
-
partialApply2
Partial application of the second argument to the supplied function to get a function of typeA -> C
. Same asflip(f).f(b)
.- Parameters:
f
- The function to partially apply.b
- The value to apply to the function.- Returns:
- A new function based on
f
with its second argument applied.
-
partialApply3
Partial application of the third argument to the supplied function to get a function of typeA -> B -> D
.- Parameters:
f
- The function to partially apply.c
- The value to apply to the function.- Returns:
- A new function based on
f
with its third argument applied.
-
partialApply4
Partial application of the fourth argument to the supplied function to get a function of typeA -> B -> C -> E
.- Parameters:
f
- The function to partially apply.d
- The value to apply to the function.- Returns:
- A new function based on
f
with its fourth argument applied.
-
partialApply5
public static <A,B, F<A,C, D, E, F$> F<B, partialApply5F<C, F<D, F$>>>> (F<A, F<B, F<C, F<D, F<E, F$>>>>> f, E e) Partial application of the fifth argument to the supplied function to get a function of typeA -> B -> C -> D -> F$
.- Parameters:
f
- The function to partially apply.e
- The value to apply to the function.- Returns:
- A new function based on
f
with its fifth argument applied.
-
partialApply6
public static <A,B, F<A,C, D, E, F$, G> F<B, partialApply6F<C, F<D, F<E, G>>>>> (F<A, F<B, F<C, F<D, F<E, F<F$, G>>>>>> f, F$ f$) Partial application of the sixth argument to the supplied function to get a function of typeA -> B -> C -> D -> E -> G
.- Parameters:
f
- The function to partially apply.f$
- The value to apply to the function.- Returns:
- A new function based on
f
with its sixth argument applied.
-
partialApply7
public static <A,B, F<A,C, D, E, F$, G, H> F<B, partialApply7F<C, F<D, F<E, F<F$, H>>>>>> (F<A, F<B, F<C, F<D, F<E, F<F$, F<G, H>>>>>>> f, G g) Partial application of the seventh argument to the supplied function to get a function of typeA -> B -> C -> D -> E -> F$ -> H
.- Parameters:
f
- The function to partially apply.g
- The value to apply to the function.- Returns:
- A new function based on
f
with its seventh argument applied.
-
partialApply8
public static <A,B, F<A,C, D, E, F$, G, H, I> F<B, partialApply8F<C, F<D, F<E, F<F$, F<G, I>>>>>>> (F<A, F<B, F<C, F<D, F<E, F<F$, F<G, F<H, I>>>>>>>> f, H h) Partial application of the eigth argument to the supplied function to get a function of typeA -> B -> C -> D -> E -> F$ -> G -> I
.- Parameters:
f
- The function to partially apply.h
- The value to apply to the function.- Returns:
- A new function based on
f
with its eigth argument applied.
-