Package fj
Class P1<A>
java.lang.Object
fj.P1<A>
- Direct Known Subclasses:
$
,P1.Memo
,P1.ReferenceMemo
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
(package private) static class
(package private) static final class
(package private) static final class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription__1()
Returns a function that returns the first element of a product.abstract A
_1()
Access the first element of the product.final <B> P1
<B> Performs function application within a P1 (applicative functor pattern).final <B> P1
<B> Binds the given function to the value in a product-1 with a final join.final <B,
C> P1 <C> Binds the given function to the values in the given P1s with a final join.final <B,
C> P1 <C> Binds the given function to the values in the given P1s with a final join.constant()
Returns a constant function that always uses this value.Promotes the given function so that it returns its value in a P1.final boolean
final A
f()
hardMemo()
Returns a P1 that remembers its value.final int
hashCode()
static <A> P1
<A> Joins a P1 of a P1 with a bind operation.Promotes a function of arity-2 to a function on P1s.final <B,
C> P1 <C> final <B> P1
<B> Map the element of the product.Promote any function to a transformation between P1s.memo()
Wrap the memoized value into aWeakReference
.Turns an array of P1s into a single P1 of an array.Turns a List of P1s into a single P1 of a List.Turns an optional P1 into a lazy option.Turns a stream of P1s into a single P1 of a stream.A first-class version of the sequence method for lists of P1s.softMemo()
Likememo
, but the memoized value is wrapped into aSoftReference
final String
toString()
traverseEither
(F<A, Either<X, B>> f) Traversable instance of P1 for EithertraverseList
(F<A, List<B>> f) Traversable instance of P1 for ListtraverseOption
(F<A, Option<B>> f) Traversable instance of P1 for OptiontraverseStream
(F<A, Stream<B>> f) Traversable instance of P1 for Streamfinal <B,
E> Validation <E, P1<B>> traverseValidation
(F<A, Validation<E, B>> f) Traversable instance of P1 for ValidationweakMemo()
Likememo
, but the memoized value is wrapped into aWeakReference
-
Constructor Details
-
P1
public P1()
-
-
Method Details
-
f
-
_1
Access the first element of the product.- Returns:
- The first element of the product.
-
__1
Returns a function that returns the first element of a product.- Returns:
- A function that returns the first element of a product.
-
map_
Promote any function to a transformation between P1s.- Parameters:
f
- A function to promote to a transformation between P1s.- Returns:
- A function promoted to operate on P1s.
-
bind
Binds the given function to the value in a product-1 with a final join.- Parameters:
f
- A function to apply to the value in a product-1.- Returns:
- The result of applying the given function to the value of given product-1.
-
curry
Promotes the given function so that it returns its value in a P1.- Parameters:
f
- A function to have its result wrapped in a P1.- Returns:
- A function whose result is wrapped in a P1.
-
apply
Performs function application within a P1 (applicative functor pattern).- Parameters:
cf
- The P1 function to apply.- Returns:
- A new P1 after applying the given P1 function to the first argument.
-
bind
Binds the given function to the values in the given P1s with a final join.- Parameters:
cb
- A given P1 to bind the given function with.f
- The function to apply to the values in the given P1s.- Returns:
- A new P1 after performing the map, then final join.
-
bind
Binds the given function to the values in the given P1s with a final join. -
join
Joins a P1 of a P1 with a bind operation.- Parameters:
a
- The P1 of a P1 to join.- Returns:
- A new P1 that is the join of the given P1.
-
liftM2
Promotes a function of arity-2 to a function on P1s.- Parameters:
f
- The function to promote.- Returns:
- A function of arity-2 promoted to map over P1s.
-
liftM2
-
sequence
Turns a List of P1s into a single P1 of a List.- Parameters:
as
- The list of P1s to transform.- Returns:
- A single P1 for the given List.
-
sequenceList
A first-class version of the sequence method for lists of P1s.- Returns:
- A function from a List of P1s to a single P1 of a List.
-
sequence
Turns a stream of P1s into a single P1 of a stream.- Parameters:
as
- The stream of P1s to transform.- Returns:
- A single P1 for the given stream.
-
sequence
Turns an optional P1 into a lazy option. -
sequence
Turns an array of P1s into a single P1 of an array.- Parameters:
as
- The array of P1s to transform.- Returns:
- A single P1 for the given array.
-
traverseList
Traversable instance of P1 for List- Parameters:
f
- The function that takes A and produces a List (non-deterministic result)- Returns:
- A List of P1
-
traverseEither
Traversable instance of P1 for Either- Parameters:
f
- The function produces Either- Returns:
- An Either of P1
-
traverseOption
Traversable instance of P1 for Option- Parameters:
f
- The function that produces Option- Returns:
- An Option of P1
-
traverseValidation
Traversable instance of P1 for Validation- Parameters:
f
- The function might produces Validation- Returns:
- An Validation of P1
-
traverseStream
Traversable instance of P1 for Stream- Parameters:
f
- The function that produces Stream- Returns:
- An Stream of P1
-
map
Map the element of the product.- Parameters:
f
- The function to map with.- Returns:
- A product with the given function applied.
-
memo
Wrap the memoized value into aWeakReference
. -
hardMemo
Returns a P1 that remembers its value.- Returns:
- A P1 that calls this P1 once and remembers the value for subsequent calls.
-
weakMemo
Likememo
, but the memoized value is wrapped into aWeakReference
-
softMemo
Likememo
, but the memoized value is wrapped into aSoftReference
-
constant
Returns a constant function that always uses this value.- Returns:
- A constant function that always uses this value.
-
toString
-
equals
-
hashCode
public final int hashCode()
-