|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfj.P2<A,B>
public abstract class P2<A,B>
A product-2.
Constructor Summary | |
---|---|
P2()
|
Method Summary | ||
---|---|---|
static
|
__1()
Returns a function that returns the first element of a product. |
|
static
|
__2()
Returns a function that returns the second element of a product. |
|
P1<A> |
_1_()
Returns the 1-product projection over the first element. |
|
abstract A |
_1()
Access the first element of the product. |
|
P1<B> |
_2_()
Returns the 1-product projection over the second element. |
|
abstract B |
_2()
Access the second element of the product. |
|
|
cobind(F<P2<A,B>,C> k)
Duplicates this product on the first element, and maps the given function across the duplicate (Comonad pattern). |
|
P2<P2<A,B>,B> |
duplicate()
Duplicates this product into the first element (Comonad pattern). |
|
static
|
fanout(F<B,C> f,
F<B,D> g,
B b)
Sends the given input value to both argument functions and combines their output. |
|
|
inject(C c)
Replaces the first element of this product with the given value. |
|
static
|
map(F<A,B> f,
P2<A,A> p)
Maps the given function across both the elements of the given product. |
|
static
|
map1_(F<A,X> f)
Promotes a function so that it maps the first element of a product. |
|
|
map1(F<A,X> f)
Map the first element of the product. |
|
static
|
map2_(F<B,X> f)
Promotes a function so that it maps the second element of a product. |
|
|
map2(F<B,X> f)
Map the second element of the product. |
|
P2<A,B> |
memo()
Provides a memoising P2 that remembers its values. |
|
|
sequenceW(List<F<P2<A,B>,C>> fs)
Applies a list of comonadic functions to this product, returning a list of values. |
|
|
sequenceW(Stream<F<P2<A,B>,C>> fs)
Applies a stream of comonadic functions to this product, returning a stream of values. |
|
static
|
split_(F<A,C> f,
F<B,D> g)
A first-class version of the split function. |
|
|
split(F<A,C> f,
F<B,D> g)
Split this product between two argument functions and combine their output. |
|
static
|
swap_()
Returns a curried form of swap() . |
|
P2<B,A> |
swap()
Swaps the elements around in this product. |
|
static
|
tuple(F<A,F<B,C>> f)
Transforms a curried function of arity-2 to a function of a product-2 |
|
static
|
tuple(F2<A,B,C> f)
Transforms an uncurried function of arity-2 to a function of a product-2 |
|
static
|
untuple(F<P2<A,B>,C> f)
Transforms a function of a product-2 to an uncurried function or arity-2. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public P2()
Method Detail |
---|
public abstract A _1()
public abstract B _2()
public P2<B,A> swap()
public <X> P2<X,B> map1(F<A,X> f)
f
- The function to map with.
public <X> P2<A,X> map2(F<B,X> f)
f
- The function to map with.
public <C,D> P2<C,D> split(F<A,C> f, F<B,D> g)
f
- A function that will map the first element of this product.g
- A function that will map the second element of this product.
public <C> P2<C,B> cobind(F<P2<A,B>,C> k)
k
- A function to map over the duplicated product.
public P2<P2<A,B>,B> duplicate()
public <C> P2<C,B> inject(C c)
c
- The value with which to replace the first element of this product.
public <C> List<C> sequenceW(List<F<P2<A,B>,C>> fs)
fs
- A list of functions to apply to this product.
public <C> Stream<C> sequenceW(Stream<F<P2<A,B>,C>> fs)
fs
- A stream of functions to apply to this product.
public P1<A> _1_()
public P1<B> _2_()
public P2<A,B> memo()
public static <A,B,C,D> F<P2<A,B>,P2<C,D>> split_(F<A,C> f, F<B,D> g)
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.
public static <A,B,X> F<P2<A,B>,P2<X,B>> map1_(F<A,X> f)
f
- The function to promote.
public static <A,B,X> F<P2<A,B>,P2<A,X>> map2_(F<B,X> f)
f
- The function to promote.
public static <B,C,D> P2<C,D> fanout(F<B,C> f, F<B,D> g, B b)
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.
public static <A,B> P2<B,B> map(F<A,B> f, P2<A,A> p)
f
- A function to map over a product.p
- A product over which to map.
public static <A,B> F<P2<A,B>,P2<B,A>> swap_()
swap()
.
swap()
.public static <A,B> F<P2<A,B>,A> __1()
public static <A,B> F<P2<A,B>,B> __2()
public static <A,B,C> F<P2<A,B>,C> tuple(F<A,F<B,C>> f)
f
- a curried function of arity-2 to transform into a function of a product-2
public static <A,B,C> F<P2<A,B>,C> tuple(F2<A,B,C> f)
f
- an uncurried function of arity-2 to transform into a function of a product-2
public static <A,B,C> F2<A,B,C> untuple(F<P2<A,B>,C> f)
f
- A function of a product-2 to transform into an uncurried function.
|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |