Interface Fn2<A,B,C>
-
- Type Parameters:
A- The first argument typeB- The second argument typeC- The return type
- All Superinterfaces:
Applicative<Fn1<B,C>,Fn1<A,?>>,Cartesian<A,Fn1<B,C>,Fn1<?,?>>,Cocartesian<A,Fn1<B,C>,Fn1<?,?>>,Contravariant<A,Profunctor<?,Fn1<B,C>,Fn1<?,?>>>,Fn1<A,Fn1<B,C>>,Functor<Fn1<B,C>,Fn1<A,?>>,Monad<Fn1<B,C>,Fn1<A,?>>,MonadReader<A,Fn1<B,C>,Fn1<A,?>>,MonadRec<Fn1<B,C>,Fn1<A,?>>,MonadWriter<A,Fn1<B,C>,Fn1<A,?>>,Profunctor<A,Fn1<B,C>,Fn1<?,?>>
- All Known Subinterfaces:
BiMonoidFactory<A,B,C>,BiPredicate<A,B>,BiSemigroupFactory<A,B,C>,Fn3<A,B,C,D>,Fn4<A,B,C,D,E>,Fn5<A,B,C,D,E,F>,Fn6<A,B,C,D,E,F,G>,Fn7<A,B,C,D,E,F,G,H>,Fn8<A,B,C,D,E,F,G,H,I>,Monoid<A>,MonoidFactory<A,B>,Semigroup<A>,SemigroupFactory<A,B>
- All Known Implementing Classes:
$,Absent,AddAll,All,Alter,And,Any,AutoBracket,Between,Both,Bracket,CartesianProduct,Clamp,CmpEq,CmpEqBy,CmpEqWith,Collapse,Collapse,Compare,Compose,Compose,Concat,Cons,Constantly,Difference,Drop,DropWhile,Endo,EndoK,Eq,Filter,Find,First,FoldLeft,FoldRight,GroupBy,GT,GTBy,GTE,GTEBy,GTEWith,GTWith,IfThenElse,InGroupsOf,Intersection,Intersperse,Into,Into1,Into3,Into4,Into5,Into6,Into7,Into8,Iterate,Join,Last,LazyRec,LeftAll,LeftAll,LeftAny,LeftAny,LiftA2,LiftA3,LiftA4,LiftA5,LiftA6,LiftA7,LT,LTBy,LTE,LTEBy,LTEWith,LTWith,MagnetizeBy,Map,Matching,Max,MaxBy,MaxWith,Merge,Merge,MergeHMaps,MergeMaps,Min,MinBy,MinWith,Not,Or,Over,Partition,Peek,Peek2,PrependAll,Present,PutAll,RateLimit,ReduceLeft,ReduceRight,Replicate,RightAll,RightAll,RightAny,RightAny,RunAll,RunAll,ScanLeft,Sequence,Set,Slide,Snoc,SortBy,SortWith,Span,Take,TakeWhile,Times,ToArray,ToCollection,ToMap,Trampoline,Trivial,Tupler2,Under,Unfoldr,Union,Until,View,Xor,Zip,ZipWith
- 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 Fn2<A,B,C> extends Fn1<A,Fn1<B,C>>
A function taking two arguments.Note that defining
Fn2in terms ofFn1provides a reasonable approximation of currying in the form of multipleapply(A, B)overloads that take different numbers of arguments.- See Also:
Fn1
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Fn1<B,C>apply(A a)Partially apply this function by passing its first argument.default Capply(A a, B b)Invoke this function with the given arguments.default Fn1<B,C>checkedApply(A a)Invoke this function with the given argument, potentially throwing anyThrowable.CcheckedApply(A a, B b)default <Y,Z>
Fn3<Y,Z,B,C>compose(Fn2<? super Y,? super Z,? extends A> before)Right-to-left composition between different arity functions.default <Z> Fn2<Z,B,C>contraMap(Fn1<? super Z,? extends A> fn)Contravariantly mapA <- B.static <A,B,C>
Fn2<A,B,C>curried(Fn1<A,Fn1<B,C>> curriedFn1)static <A,B,C>
Fn2<A,B,C>curry(Fn1<? super Tuple2<A,B>,? extends C> uncurriedFn1)default <Z> Fn2<Z,B,C>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 <D> Fn2<A,B,C>discardR(Applicative<D,Fn1<A,?>> appB)Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative.default Fn2<B,A,C>flip()Flip the order of the arguments.static <A,B,C>
Fn2<A,B,C>fn2(Fn2<A,B,C> fn2)Static method to aid inference.static <A,B,C>
Fn2<A,B,C>fromBiFunction(java.util.function.BiFunction<? super A,? super B,? extends C> biFunction)Static factory method for wrapping aBiFunctionin anFn2.default java.util.function.BiFunction<A,B,C>toBiFunction()View thisFn2as aBiFunction.default Fn1<? super Product2<? extends A,? extends B>,C>uncurry()default <Z> Fn3<Z,A,B,C>widen()Widen this function's argument list by prepending an ignored argument of any type to the front.
-
-
-
Method Detail
-
apply
default C apply(A a, B b)
Invoke this function with the given arguments.- Parameters:
a- the first argumentb- the second argument- Returns:
- the result of the function application
-
checkedApply
default Fn1<B,C> checkedApply(A a) throws java.lang.Throwable
Invoke this function with the given argument, potentially throwing anyThrowable.- Specified by:
checkedApplyin interfaceFn1<A,B>- Parameters:
a- the argument- Returns:
- the result of the function application
- Throws:
java.lang.Throwable- anything possibly thrown by the function
-
widen
default <Z> Fn3<Z,A,B,C> widen()
Widen this function's argument list by prepending an ignored argument of any type to the front.
-
toBiFunction
default java.util.function.BiFunction<A,B,C> toBiFunction()
View thisFn2as aBiFunction.- Returns:
- the same logic as a
BiFunction - See Also:
BiFunction
-
discardR
default <D> Fn2<A,B,C> discardR(Applicative<D,Fn1<A,?>> appB)
Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative. This is generally useful for sequentially performing side-effects.- Specified by:
discardRin interfaceApplicative<A,B>- Specified by:
discardRin interfaceFn1<A,B>- Specified by:
discardRin interfaceMonad<A,B>- Specified by:
discardRin interfaceMonadReader<A,B,C>- Specified by:
discardRin interfaceMonadRec<A,B>- Specified by:
discardRin interfaceMonadWriter<A,B,C>- Type Parameters:
D- the type of appB's parameter- Parameters:
appB- the other Applicative- Returns:
- this Applicative
-
diMapL
default <Z> Fn2<Z,B,C> 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.- Specified by:
diMapLin interfaceCartesian<A,B,C>- Specified by:
diMapLin interfaceCocartesian<A,B,C>- Specified by:
diMapLin interfaceFn1<A,B>- Specified by:
diMapLin interfaceProfunctor<A,B,C>- Type Parameters:
Z- the new argument type- Parameters:
fn- the contravariant argument mapping function- Returns:
- an
Fn1<Z, B>
-
contraMap
default <Z> Fn2<Z,B,C> contraMap(Fn1<? super Z,? extends A> fn)
Contravariantly mapA <- B.- Specified by:
contraMapin interfaceCartesian<A,B,C>- Specified by:
contraMapin interfaceCocartesian<A,B,C>- Specified by:
contraMapin interfaceContravariant<A,B>- Specified by:
contraMapin interfaceFn1<A,B>- Specified by:
contraMapin interfaceProfunctor<A,B,C>- Type Parameters:
Z- the new parameter type- Parameters:
fn- the mapping function- Returns:
- the mapped Contravariant functor instance
-
compose
default <Y,Z> Fn3<Y,Z,B,C> compose(Fn2<? super Y,? super Z,? extends A> before)
Right-to-left composition between different arity functions. Preserves highest arity in the return type.
-
fromBiFunction
static <A,B,C> Fn2<A,B,C> fromBiFunction(java.util.function.BiFunction<? super A,? super B,? extends C> biFunction)
Static factory method for wrapping aBiFunctionin anFn2.- Type Parameters:
A- the first input argument typeB- the second input argument typeC- the output type- Parameters:
biFunction- the biFunction to adapt- Returns:
- the
Fn2
-
curried
static <A,B,C> Fn2<A,B,C> curried(Fn1<A,Fn1<B,C>> curriedFn1)
- Type Parameters:
A- the first input argument typeB- the second input argument typeC- the output type- Parameters:
curriedFn1- the curried fn1 to adapt- Returns:
- the
Fn2
-
-