Class Compose<F extends Applicative<?,F>,G extends Applicative<?,G>,A>
- java.lang.Object
-
- com.jnape.palatable.lambda.functor.builtin.Compose<F,G,A>
-
- Type Parameters:
F- The outer applicativeG- The inner applicativeA- The carrier type
- All Implemented Interfaces:
Applicative<A,Compose<F,G,?>>,Functor<A,Compose<F,G,?>>
public final class Compose<F extends Applicative<?,F>,G extends Applicative<?,G>,A> extends java.lang.Object implements Applicative<A,Compose<F,G,?>>
A functor representing the type-level composition of twoApplicativefunctors; useful for preserving nested type-level transformations during traversal of aTraversable.
-
-
Field Summary
Fields Modifier and Type Field Description private Applicative<? extends Applicative<A,G>,F>fga
-
Constructor Summary
Constructors Constructor Description Compose(Applicative<? extends Applicative<A,G>,F> fga)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <B> Compose<F,G,B>discardL(Applicative<B,Compose<F,G,?>> appB)Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB.<B> Compose<F,G,A>discardR(Applicative<B,Compose<F,G,?>> appB)Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative.booleanequals(java.lang.Object other)<B> Compose<F,G,B>fmap(Fn1<? super A,? extends B> fn)Covariantly transmute this functor's parameter using the given mapping function.<GA extends Applicative<A,G>,FGA extends Applicative<GA,F>>
FGAgetCompose()inthashCode()<B> Lazy<Compose<F,G,B>>lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,Compose<F,G,?>>> lazyAppFn)Given alazyinstance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.<B> Compose<F,G,B>pure(B b)Lift the valuebinto this applicative functor.static <F extends Applicative<?,F>,G extends Applicative<?,G>>
Pure<Compose<F,G,?>>pureCompose(Pure<F> pureF, Pure<G> pureG)java.lang.StringtoString()<B> Compose<F,G,B>zip(Applicative<Fn1<? super A,? extends B>,Compose<F,G,?>> appFn)Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
-
-
-
Field Detail
-
fga
private final Applicative<? extends Applicative<A,G extends Applicative<?,G>>,F extends Applicative<?,F>> fga
-
-
Constructor Detail
-
Compose
public Compose(Applicative<? extends Applicative<A,G>,F> fga)
-
-
Method Detail
-
getCompose
public <GA extends Applicative<A,G>,FGA extends Applicative<GA,F>> FGA getCompose()
-
fmap
public <B> Compose<F,G,B> fmap(Fn1<? super A,? extends B> fn)
Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.- Specified by:
fmapin interfaceApplicative<F extends Applicative<?,F>,G extends Applicative<?,G>>- Specified by:
fmapin interfaceFunctor<F extends Applicative<?,F>,G extends Applicative<?,G>>- Type Parameters:
B- the new parameter type- Parameters:
fn- the mapping function- Returns:
- a functor over B (the new parameter type)
-
pure
public <B> Compose<F,G,B> pure(B b)
Lift the valuebinto this applicative functor.- Specified by:
purein interfaceApplicative<F extends Applicative<?,F>,G extends Applicative<?,G>>- Type Parameters:
B- the type of the returned applicative's parameter- Parameters:
b- the value- Returns:
- an instance of this applicative over b
-
zip
public <B> Compose<F,G,B> zip(Applicative<Fn1<? super A,? extends B>,Compose<F,G,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.- Specified by:
zipin interfaceApplicative<F extends Applicative<?,F>,G extends Applicative<?,G>>- Type Parameters:
B- the resulting applicative parameter type- Parameters:
appFn- the other applicative instance- Returns:
- the mapped applicative
-
lazyZip
public <B> Lazy<Compose<F,G,B>> lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,Compose<F,G,?>>> lazyAppFn)
Given alazyinstance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. This is useful for applicatives that support lazy evaluation and early termination.- Specified by:
lazyZipin interfaceApplicative<F extends Applicative<?,F>,G extends Applicative<?,G>>- Type Parameters:
B- the resulting applicative parameter type- Parameters:
lazyAppFn- the lazy other applicative instance- Returns:
- the mapped applicative
- See Also:
Maybe,Either
-
discardL
public <B> Compose<F,G,B> discardL(Applicative<B,Compose<F,G,?>> appB)
Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB. This is generally useful for sequentially performing side-effects.- Specified by:
discardLin interfaceApplicative<F extends Applicative<?,F>,G extends Applicative<?,G>>- Type Parameters:
B- the type of the returned Applicative's parameter- Parameters:
appB- the other Applicative- Returns:
- appB
-
discardR
public <B> Compose<F,G,A> discardR(Applicative<B,Compose<F,G,?>> appB)
Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative. This is generally useful for sequentially performing side-effects.- Specified by:
discardRin interfaceApplicative<F extends Applicative<?,F>,G extends Applicative<?,G>>- Type Parameters:
B- the type of appB's parameter- Parameters:
appB- the other Applicative- Returns:
- this Applicative
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
pureCompose
public static <F extends Applicative<?,F>,G extends Applicative<?,G>> Pure<Compose<F,G,?>> pureCompose(Pure<F> pureF, Pure<G> pureG)
- Type Parameters:
F- the outerApplicativetypeG- the innerApplicativetype- Parameters:
pureF- thePureconstructor for the outerApplicativepureG- thePureconstructor for the innerApplicative- Returns:
- the
Pureinstance
-
-