/** * The `Strong` class extends `Profunctor` with combinators for working with product types. * * `first` and `second` lift values in a `Profunctor` to act on the first and second components of a tuple, * respectively. * * Another way to think about Strong is to piggyback on the intuition of * inputs and outputs. Rewriting the type signature in this light then yields: * * ```purescript * first :: forall input output a. p input output -> p (Tuple input a) (Tuple output a) * second :: forall input output a. p input output -> p (Tuple a input) (Tuple a output) * ``` * * If we specialize the profunctor p to the function arrow, we get the following type * signatures, which may look a bit more familiar: * * ```purescript * first :: forall input output a. (input -> output) -> (Tuple input a) -> (Tuple output a) * second :: forall input output a. (input -> output) -> (Tuple a input) -> (Tuple a output) * ``` * * So, when the `profunctor` is `Function` application, `first` essentially applies your function * to the first element of a tuple, and `second` applies it to the second element (same as `map` would do). * * Adapted from https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Strong.purs * * @since 2.0.0 */ import { Category, Category2, Category3, Category4 } from './Category' import { HKT2, Kind2, Kind3, URIS2, URIS3, URIS4, Kind4 } from './HKT' import { Profunctor, Profunctor2, Profunctor3, Profunctor4 } from './Profunctor' /** * @category model * @since 2.0.0 */ export interface Strong extends Profunctor { readonly first: (pab: HKT2) => HKT2 readonly second: (pab: HKT2) => HKT2 } /** * @category model * @since 2.0.0 */ export interface Strong2 extends Profunctor2 { readonly first: (pab: Kind2) => Kind2 readonly second: (pab: Kind2) => Kind2 } /** * @category model * @since 2.0.0 */ export interface Strong3 extends Profunctor3 { readonly first: (pab: Kind3) => Kind3 readonly second: (pab: Kind3) => Kind3 } /** * @category model * @since 2.0.0 */ export interface Strong4 extends Profunctor4 { readonly first: (pab: Kind4) => Kind4 readonly second: (pab: Kind4) => Kind4 } /** * Compose a value acting on a tuple from two values, each acting on one of the components of the tuple. * * Specializing `split` to function application would look like this: * * ```purescript * split :: forall a b c d. (a -> b) -> (c -> d) -> (Tuple a c) -> (Tuple b d) * ``` * * We take two functions, `f` and `g`, and we transform them into a single function which takes a tuple and maps `f` * over the first element and `g` over the second. Just like `bi-map` would do for the `bi-functor` instance of tuple. * * @since 2.10.0 */ export declare function split( S: Strong4, C: Category4 ): (pab: Kind4, pcd: Kind4) => Kind4 export declare function split( S: Strong3, C: Category3 ): (pab: Kind3, pcd: Kind3) => Kind3 export declare function split( S: Strong2, C: Category2 ): (pab: Kind2, pcd: Kind2) => Kind2 export declare function split( S: Strong, C: Category ): (pab: HKT2, pcd: HKT2) => HKT2 /** * Compose a value which introduces a tuple from two values, each introducing one side of the tuple. * * This combinator is useful when assembling values from smaller components, because it provides a way to support two * different types of output. * * Specializing `fanOut` to function application would look like this: * * ```purescript * fanOut :: forall a b c. (a -> b) -> (a -> c) -> (a -> (Tuple b c)) * ``` * * We take two functions, `f` and `g`, with the same parameter type and we transform them into a single function which * takes one parameter and returns a tuple of the results of running `f` and `g` on the parameter, respectively. This * allows us to run two parallel computations on the same input and return both results in a tuple. * * @since 2.10.0 */ export declare function fanOut( S: Strong4, C: Category4 ): (pab: Kind4, pac: Kind4) => Kind4 export declare function fanOut( S: Strong3, C: Category3 ): (pab: Kind3, pac: Kind3) => Kind3 export declare function fanOut( S: Strong2, C: Category2 ): (pab: Kind2, pac: Kind2) => Kind2 export declare function fanOut( S: Strong, C: Category ): (pab: HKT2, pac: HKT2) => HKT2 /** * Use [`split`](#split) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare function splitStrong( F: Category4 & Strong4 ): (pab: Kind4, pcd: Kind4) => Kind4 /** @deprecated */ export declare function splitStrong( F: Category3 & Strong3 ): (pab: Kind3, pcd: Kind3) => Kind3 /** @deprecated */ export declare function splitStrong( F: Category2 & Strong2 ): (pab: Kind2, pcd: Kind2) => Kind2 /** @deprecated */ export declare function splitStrong( F: Category & Strong ): (pab: HKT2, pcd: HKT2) => HKT2 /** * Use [`fanOut`](#fanout) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare function fanout( F: Category4 & Strong4 ): (pab: Kind4, pac: Kind4) => Kind4 /** @deprecated */ export declare function fanout( F: Category3 & Strong3 ): (pab: Kind3, pac: Kind3) => Kind3 /** @deprecated */ export declare function fanout( F: Category2 & Strong2 ): (pab: Kind2, pac: Kind2) => Kind2 /** @deprecated */ export declare function fanout( F: Category & Strong ): (pab: HKT2, pac: HKT2) => HKT2