# Pairing

``public class Pairing<F, G> : PairingOf<F, G> where F : Functor, G : Functor``

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`.

• ``` fix(_:) ```

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.

• ``` init(_:) ```

Initializes a Pairing.

#### Declaration

Swift

``public init(_ zap: @escaping (Kind<F, (/*A*/Any) -> /*B*/Any>, Kind<G, /*A*/Any>) -> /*B*/Any)``

#### Parameters

 ``` zap ``` Relationship between the Functors, captured as a function of the form: `forall a b. f (a -> b) -> g a -> b`
• ``` init(_:) ```

Initializes a Pairing.

#### Declaration

Swift

``public init(_ pairing: @escaping (Kind<F, /*A*/Any>, Kind<G, /*B*/Any>, @escaping (/*A*/Any, /*B*/Any) -> /*C*/Any) -> /*C*/Any)``

#### 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`
• ``` zap(_:_:) ```

Annihilate the `F` and `G` effects by calling the wrapped function in `F` with the wrapped value

#### Declaration

Swift

``public func zap<A, B>(_ fab: Kind<F, (A) -> B>, _ ga: Kind<G, A>) -> B``

#### Parameters

 ``` fab ``` An `F`-effectful `A -> B` ``` ga ``` A `G`-effectful `A`

#### Return Value

A pure `B`

• ``` pair(_:_:_:) ```

Annilate the `F` and `G` effects by extracting the values in their contexts and using the combination function.

#### Declaration

Swift

``public func pair<A, B, C>(_ fa: Kind<F, A>, _ gb: Kind<G, B>, _ f: @escaping (A, B) -> C) -> C``

#### 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.

• ``` select(_:_:) ```

Explores the space given by one Functor, using the other as an explorer.

#### Declaration

Swift

``public func select<A, B>(_ fa: Kind<F, A>, _ ggb: Kind<G, Kind<G, B>>) -> Kind<G, B>``

#### Parameters

 ``` fa ``` Explorer Functorial value. ``` ggb ``` Spact Functorial value.

#### Return Value

Result of the exploration.

• ``` pairFlipped(_:_:_:) ```

Annihilates the F and G effectful values with arguments flipped.

#### Declaration

Swift

``public func pairFlipped<A, B, C>(_ ga: Kind<G, A>, _ fb: Kind<F, B>, _ f: @escaping (A, B) -> C) -> C``

#### 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.

• ``` pairStateTStoreT() ```

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.

• ``` pairWriterTTracedT() ```

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.

• ``` pairReaderTEnvT() ```

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

• ``` pairId() ```

Provides a Pairing for Id-Id.

#### Declaration

Swift

``static func pairId() -> Pairing<ForId, ForId>``

#### Return Value

A Pairing for Id-Id.

• ``` pairStateTStoreT(_:) ```

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.

• ``` pairStateStore() ```

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.

• ``` pairWriterTTracedT(_:) ```

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.

• ``` pairWriterTraced() ```

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.

• ``` pairReaderTEnvT(_:) ```

#### 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

• ``` pairReaderEnv() ```

#### Declaration

Swift

``static func pairReaderEnv<R>() -> Pairing<ReaderPartial<R>, EnvPartial<R>> where F == ReaderPartial<R>, G == EnvPartial<R>``

#### Return Value

• ``` pairActionMoore() ```

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.

• ``` pairCoSumSum() ```

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.

• ``` pairCoSumOptSumOpt() ```

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.

• ``` pairPullerZipper() ```

Provides a Pairing for Puller-Zipper.

#### Declaration

Swift

``static func pairPullerZipper() -> Pairing<ForPuller, ForZipper>``

#### Return Value

A Pairing for Puller-Zipper.