Class P2<A,B>
java.lang.Object
fj.P2<A,B>
A product-2.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription__1()Returns a function that returns the first element of a product.__2()Returns a function that returns the second element of a product.abstract A_1()Access the first element of the product._1_()Returns the 1-product projection over the first element.abstract B_2()Access the second element of the product._2_()Returns the 1-product projection over the second element.append(C el) Duplicates this product on the first element, and maps the given function across the duplicate (Comonad pattern).Duplicates this product into the first element (Comonad pattern).final booleanstatic <B,C, D> P2 <C, D> Sends the given input value to both argument functions and combines their output.final inthashCode()inject(C c) Replaces the first element of this product with the given value.static <A,B> P2 <B, B> Maps the given function across both the elements of the given product.Map the first element of the product.Promotes a function so that it maps the first element of a product.Map the second element of the product.Promotes a function so that it maps the second element of a product.memo()Provides a memoising P2 that remembers its values.final <C> List<C> Applies a list of comonadic functions to this product, returning a list of values.final <C> Stream<C> Applies a stream of comonadic functions to this product, returning a stream of values.final <C,D> P2 <C, D> Split this product between two argument functions and combine their output.A first-class version of the split function.swap()Swaps the elements around in this product.swap_()Returns a curried form ofswap().final StringtoString()traverseEither(F<B, Either<X, C>> f) traverseIO(F<B, IO<C>> f) traverseList(F<B, List<C>> f) traverseOption(F<B, Option<C>> f) traverseStream(F<B, Stream<C>> f) Transforms a curried function of arity-2 to a function of a product-2Transforms an uncurried function of arity-2 to a function of a product-2static <A,B, C> F2 <A, B, C> Transforms a function of a product-2 to an uncurried function or arity-2.
-
Constructor Details
-
P2
public P2()
-
-
Method Details
-
_1
Access the first element of the product.- Returns:
- The first element of the product.
-
_2
Access the second element of the product.- Returns:
- The second element of the product.
-
equals
-
hashCode
-
swap
-
map1
-
map2
-
split
Split this product between two argument functions and combine their output.- Parameters:
f- A function that will map the first element of this product.g- A function that will map the second element of this product.- Returns:
- A new product with the first function applied to the second element and the second function applied to the second element.
-
cobind
Duplicates this product on the first element, and maps the given function across the duplicate (Comonad pattern).- Parameters:
k- A function to map over the duplicated product.- Returns:
- A new product with the result of the given function applied to this product as the first element, and with the second element intact.
-
duplicate
-
inject
-
sequenceW
-
traverseList
-
traverseStream
-
traverseIO
-
traverseOption
-
traverseEither
-
sequenceW
Applies a stream of comonadic functions to this product, returning a stream of values.- Parameters:
fs- A stream of functions to apply to this product.- Returns:
- A stream of the results of applying the given stream of functions to this product.
-
_1_
-
_2_
-
append
-
append
-
append
-
append
-
append
-
append
-
memo
-
split_
A first-class version of the split function.- Parameters:
f- A function that will map the first element of the given product.g- A function that will map the second element of the given product.- Returns:
- A function that splits a given product between the two given functions and combines their output.
-
map1_
-
map2_
-
fanout
Sends the given input value to both argument functions and combines their output.- Parameters:
f- A function to receive an input value.g- A function to receive an input value.b- An input value to send to both functions.- Returns:
- The product of the two functions applied to the input value.
-
map
-
swap_
-
__1
-
__2
-
tuple
-
tuple
-
untuple
-
toString
-