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 twoApplicative
functors; 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 thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
.<B> Compose<F,G,A>
discardR(Applicative<B,Compose<F,G,?>> appB)
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
.boolean
equals(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()
int
hashCode()
<B> Lazy<Compose<F,G,B>>
lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,Compose<F,G,?>>> lazyAppFn)
Given alazy
instance 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 valueb
into 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.String
toString()
<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:
fmap
in interfaceApplicative<F extends Applicative<?,F>,G extends Applicative<?,G>>
- Specified by:
fmap
in 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 valueb
into this applicative functor.- Specified by:
pure
in 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:
zip
in 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 alazy
instance 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:
lazyZip
in 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 thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
. This is generally useful for sequentially performing side-effects.- Specified by:
discardL
in 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 thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
. This is generally useful for sequentially performing side-effects.- Specified by:
discardR
in 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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 outerApplicative
typeG
- the innerApplicative
type- Parameters:
pureF
- thePure
constructor for the outerApplicative
pureG
- thePure
constructor for the innerApplicative
- Returns:
- the
Pure
instance
-
-