Pairing
The Pairing type represents a relationship between Functors F and G, where the sums in one can annihilate the products in the other.
The internals of this type embed a function of the following shape:
forall a b c. f a -> g b -> (a -> b -> c) -> c
Or equivalently:
forall a b. f (a -> b) -> g a -> b
Swift lacks universal quantifiers, so these types are replaced by Any
.
-
Safe downcast.
Declaration
Swift
public static func fix(_ value: PairingOf<F, G>) -> Pairing<F, G>
Parameters
value
Value in the higher-kind form.
Return Value
Value cast to Pairing.
-
Initializes a Pairing.
Declaration
Parameters
pairing
Relationship between the Functors, captured as a function of the form:
forall a b c. f a -> g b -> (a -> b -> c) -> c
-
Annilate the
F
andG
effects by extracting the values in their contexts and using the combination function.Declaration
Parameters
fa
An F-effectful value.
gb
A G-effectful value.
f
A function to combine the values in both contexts.
Return Value
Result of annihilating both effectful values and combining them with the provided function.
-
Annihilates the F and G effectful values with arguments flipped.
Declaration
Parameters
ga
A G-effectful value.
fb
An F-effectful value.
f
Combination function.
Return Value
Result of annihilating both effectful values and combining them with the provided function.
-
Lifts this Pairing to use it for a StateT-StoreT pairing.
Declaration
Swift
public func pairStateTStoreT<S>() -> Pairing<StateTPartial<F, S>, StoreTPartial<S, G>>
Return Value
A pairing for StateT-StoreT where their base Monad and Comonad are paired with this pairing.
-
Lifts this Pairing to use it for a WriterT-TracedT pairing.
Declaration
Swift
public func pairWriterTTracedT<W>() -> Pairing<WriterTPartial<F, W>, TracedTPartial<W, G>>
Return Value
A pairing for WriterT-TracedT where their base Monad and Comonad are paired with this pairing.
-
Lifts this Pairing to use it for a ReaderT-EnvT pairing.
Declaration
Swift
public func pairReaderTEnvT<R>() -> Pairing<ReaderTPartial<F, R>, EnvTPartial<R, G>>
Return Value
A pairing for ReaderT-EnvT where their base Monad and Comonad are paired with this pairing.
-
Provides a Pairing for StateT-StoreT.
Declaration
Swift
static func pairStateTStoreT<S, FF, GG>(_ pairing: Pairing<FF, GG>) -> Pairing<StateTPartial<FF, S>, StoreTPartial<S, GG>> where F == StateTPartial<FF, S>, G == StoreTPartial<S, GG>, FF : Functor, GG : Functor
Parameters
pairing
Pairing for the base Monad and Comonad in StateT-StoreT.
Return Value
A Pairing for StateT-StoreT using the provided Pairing to annihilate their internal base Monad and Comonad.
-
Provides a Pairing for State-Store.
Declaration
Swift
static func pairStateStore<S>() -> Pairing<StatePartial<S>, StorePartial<S>> where F == StatePartial<S>, G == StorePartial<S>
Return Value
A Pairing for State-Store.
-
Provides a Pairing for WriterT-TracedT.
Declaration
Swift
static func pairWriterTTracedT<W, FF, GG>(_ pairing: Pairing<FF, GG>) -> Pairing<WriterTPartial<FF, W>, TracedTPartial<W, GG>> where F == WriterTPartial<FF, W>, G == TracedTPartial<W, GG>, FF : Functor, GG : Functor
Parameters
pairing
Pairing for the base Monad and Comonad in WriterT-TracedT.
Return Value
A Pairing for WriterT-TracedT using the provided Pairing to annihilate their internal base Monad and Comonad.
-
Provides a Pairing for Writer-Traced.
Declaration
Swift
static func pairWriterTraced<W>() -> Pairing<WriterPartial<W>, TracedPartial<W>> where F == WriterPartial<W>, G == TracedPartial<W>
Return Value
A Pairing for Writer-Traced.
-
Provides a Pairing for ReaderT-EnvT.
Declaration
Swift
static func pairReaderTEnvT<R, FF, GG>(_ pairing: Pairing<FF, GG>) -> Pairing<ReaderTPartial<FF, R>, EnvTPartial<R, GG>> where F == ReaderTPartial<FF, R>, G == EnvTPartial<R, GG>, FF : Functor, GG : Functor
Parameters
pairing
Pairing for the base Monad and Comonad in ReaderT-EnvT.
Return Value
A Pairing for ReaderT-EnvT using the provided Pairing to annihilate their internal base Monad and Comonad.
-
Provides a Pairing for Reader-Env.
Declaration
Swift
static func pairReaderEnv<R>() -> Pairing<ReaderPartial<R>, EnvPartial<R>> where F == ReaderPartial<R>, G == EnvPartial<R>
Return Value
A Pairing for Reader-Env.
-
Provides a Pairing for Action-Moore.
Declaration
Swift
static func pairActionMoore<I>() -> Pairing<ActionPartial<I>, MoorePartial<I>> where F == ActionPartial<I>, G == MoorePartial<I>
Return Value
A Pairing for Action-Moore.
-
Provides a Pairing for CoSum-Sum.
Declaration
Swift
static func pairCoSumSum<FF, GG>() -> Pairing<CoSumPartial<FF, GG>, SumPartial<FF, GG>> where F == CoSumPartial<FF, GG>, G == SumPartial<FF, GG>, FF : Comonad, GG : Comonad
Return Value
A Pairing for CoSum-Sum.
-
Provides a Pairing for CoSumOpt-SumOpt.
Declaration
Swift
static func pairCoSumOptSumOpt<FF>() -> Pairing<CoSumOptPartial<FF>, SumOptPartial<FF>> where F == CoSumOptPartial<FF>, G == SumOptPartial<FF>, FF : Comonad
Return Value
A Pairing for CoSumOpt-SumOpt.