Class Tagged<S,B>
java.lang.Object
com.jnape.palatable.lambda.functor.builtin.Tagged<S,B>
- Type Parameters:
S- the phantom typeB- the value type
- All Implemented Interfaces:
Applicative<B, Tagged<S,?>>, Cocartesian<S, B, Tagged<?, ?>>, Contravariant<S, Profunctor<?, B, Tagged<?, ?>>>, Functor<B, Tagged<S, ?>>, Profunctor<S, B, Tagged<?, ?>>, Monad<B, Tagged<S, ?>>, MonadRec<B, Tagged<S, ?>>, Traversable<B, Tagged<S, ?>>
public final class Tagged<S,B>
extends Object
implements MonadRec<B, Tagged<S,?>>, Traversable<B, Tagged<S,?>>, Cocartesian<S, B, Tagged<?,?>>
Like
Const, but the phantom parameter is in the contravariant position, and the value is in covariant
position.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionChoose some typeCor this profunctor's carrier types.Contravariantly mapA <- B.<Z,C> Tagged <Z, C> Dually map contravariantly over the left parameter and covariantly over the right parameter.Contravariantly map over the left parameter.Covariantly map over the right parameter.discardL(Applicative<C, Tagged<S, ?>> appB) Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB.discardR(Applicative<C, Tagged<S, ?>> appB) Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative.booleanChain dependent computations that may continue or short-circuit based on previous results.Covariantly transmute this functor's parameter using the given mapping function.inthashCode()pure(C c) Lift the valuebinto this applicative functor.toString()trampolineM(Fn1<? super B, ? extends MonadRec<RecursiveResult<B, C>, Tagged<S, ?>>> fn) Given some operation yielding aRecursiveResultinside thisMonadRec, internally trampoline the operation until it yields aterminationinstruction.<C, App extends Applicative<?,App>, TravC extends Traversable<C, Tagged<S, ?>>, AppTrav extends Applicative<TravC, App>>
AppTravtraverse(Fn1<? super B, ? extends Applicative<C, App>> fn, Fn1<? super TravC, ? extends AppTrav> pure) Applyfnto each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.unTagged()Extract the contained value.Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.Methods inherited from interface Cocartesian
choose
-
Field Details
-
b
-
-
Constructor Details
-
Tagged
-
-
Method Details
-
unTagged
-
flatMap
Chain dependent computations that may continue or short-circuit based on previous results. -
trampolineM
public <C> Tagged<S,C> trampolineM(Fn1<? super B, ? extends MonadRec<RecursiveResult<B, C>, Tagged<S, ?>>> fn) Given some operation yielding aRecursiveResultinside thisMonadRec, internally trampoline the operation until it yields aterminationinstruction.Stack-safety depends on implementations guaranteeing that the growth of the call stack is a constant factor independent of the number of invocations of the operation. For various examples of how this can be achieved in stereotypical circumstances, see the referenced types.
- Specified by:
trampolineMin interfaceMonadRec<S,B> - Type Parameters:
C- the ultimate resulting carrier type- Parameters:
fn- the function to internally trampoline- Returns:
- the trampolined
MonadRec - See Also:
-
pure
Lift the valuebinto this applicative functor. -
fmap
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<S,B> - Specified by:
fmapin interfaceFunctor<S,B> - Specified by:
fmapin interfaceMonad<S,B> - Specified by:
fmapin interfaceMonadRec<S,B> - Specified by:
fmapin interfaceTraversable<S,B> - Type Parameters:
C- the new parameter type- Parameters:
fn- the mapping function- Returns:
- a functor over B (the new parameter type)
-
zip
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. -
discardL
Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB. This is generally useful for sequentially performing side-effects. -
discardR
Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative. This is generally useful for sequentially performing side-effects. -
traverse
public <C, App extends Applicative<?,App>, TravC extends Traversable<C, Tagged<S, AppTrav traverse?>>, AppTrav extends Applicative<TravC, App>> (Fn1<? super B, ? extends Applicative<C, App>> fn, Fn1<? super TravC, ? extends AppTrav> pure) Applyfnto each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.- Specified by:
traversein interfaceTraversable<S,B> - Type Parameters:
C- the resulting element typeApp- the result applicative typeTravC- this Traversable instance over BAppTrav- the full inferred resulting type from the traversal- Parameters:
fn- the function to applypure- the applicative pure function- Returns:
- the traversed Traversable, wrapped inside an applicative
-
cocartesian
Choose some typeCor this profunctor's carrier types.- Specified by:
cocartesianin interfaceCocartesian<S, B, Tagged<?,?>> - Type Parameters:
C- the choice type- Returns:
- the cocartesian-costrengthened profunctor
-
diMap
Dually map contravariantly over the left parameter and covariantly over the right parameter. This is isomorphic todiMapL(lFn).diMapR(rFn).- Specified by:
diMapin interfaceCocartesian<S, B, Tagged<?,?>> - Specified by:
diMapin interfaceProfunctor<S, B, Tagged<?,?>> - Type Parameters:
Z- the new left parameter typeC- the new right parameter type- Parameters:
lFn- the left parameter mapping functionrFn- the right parameter mapping function- Returns:
- a profunctor over Z (the new left parameter type) and C (the new right parameter type)
-
diMapL
Contravariantly map over the left parameter.- Specified by:
diMapLin interfaceCocartesian<S, B, Tagged<?,?>> - Specified by:
diMapLin interfaceProfunctor<S, B, Tagged<?,?>> - Type Parameters:
Z- the new left parameter type- Parameters:
fn- the mapping function- Returns:
- a profunctor over Z (the new left parameter type) and C (the same right parameter type)
-
diMapR
Covariantly map over the right parameter. For all profunctors that are also functors, it should hold thatdiMapR(f) == fmap(f).- Specified by:
diMapRin interfaceCocartesian<S, B, Tagged<?,?>> - Specified by:
diMapRin interfaceProfunctor<S, B, Tagged<?,?>> - Type Parameters:
C- the new right parameter type- Parameters:
fn- the mapping function- Returns:
- a profunctor over A (the same left parameter type) and C (the new right parameter type)
-
contraMap
Contravariantly mapA <- B.- Specified by:
contraMapin interfaceCocartesian<S, B, Tagged<?,?>> - Specified by:
contraMapin interfaceContravariant<S,B> - Specified by:
contraMapin interfaceProfunctor<S, B, Tagged<?,?>> - Type Parameters:
Z- the new parameter type- Parameters:
fn- the mapping function- Returns:
- the mapped Contravariant functor instance
-
equals
-
hashCode
-
toString
-
pureTagged
-