/** * `Compactable` represents data structures which can be _compacted_/_filtered_. This is a generalization of * `catOptions` as a new function `compact`. `compact` has relations with `Functor`, `Applicative`, * `Monad`, `Alternative`, and `Traversable` in that we can use these classes to provide the ability to * operate on a data type by eliminating intermediate `None`s. This is useful for representing the filtering out of * values, or failure. * * Adapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Compactable.purs * * @since 2.0.0 */ import { Either } from './Either' import { Functor, Functor1, Functor2, Functor2C, Functor3C, FunctorComposition, FunctorComposition11, FunctorComposition12, FunctorComposition12C, FunctorComposition21, FunctorComposition22, FunctorComposition22C, FunctorComposition23, FunctorComposition23C, FunctorComposition2C1 } from './Functor' import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT' import { Option } from './Option' import * as S from './Separated' /** * @category model * @since 2.0.0 */ export interface Compactable { readonly URI: F /** * Compacts a data structure unwrapping inner Option */ readonly compact: (fa: HKT>) => HKT /** * Separates a data structure moving inner Left to the left side and inner Right to the right side of Separated */ readonly separate: (fa: HKT>) => S.Separated, HKT> } /** * @category model * @since 2.0.0 */ export interface Compactable1 { readonly URI: F readonly compact: (fa: Kind>) => Kind readonly separate: (fa: Kind>) => S.Separated, Kind> } /** * @category model * @since 2.0.0 */ export interface Compactable2 { readonly URI: F readonly compact: (fa: Kind2>) => Kind2 readonly separate: (fa: Kind2>) => S.Separated, Kind2> } /** * @category model * @since 2.0.0 */ export interface Compactable2C { readonly URI: F readonly _E: E readonly compact: (fa: Kind2>) => Kind2 readonly separate: (fa: Kind2>) => S.Separated, Kind2> } /** * @category model * @since 2.0.0 */ export interface Compactable3 { readonly URI: F readonly compact: (fa: Kind3>) => Kind3 readonly separate: (fa: Kind3>) => S.Separated, Kind3> } /** * @category model * @since 2.2.0 */ export interface Compactable3C { readonly URI: F readonly _E: E readonly compact: (fa: Kind3>) => Kind3 readonly separate: (fa: Kind3>) => S.Separated, Kind3> } /** * @category model * @since 2.0.0 */ export interface Compactable4 { readonly URI: F readonly compact: (fa: Kind4>) => Kind4 readonly separate: ( fa: Kind4> ) => S.Separated, Kind4> } /** * `compact` composition. * * @since 2.10.0 */ export declare function compact( F: Functor2, G: Compactable2C ): (fa: Kind2>>) => Kind2> export declare function compact( F: Functor1, G: Compactable2C ): (fa: Kind>>) => Kind> export declare function compact( F: Functor1, G: Compactable1 ): (fa: Kind>>) => Kind> export declare function compact( F: Functor, G: Compactable ): (fa: HKT>>) => HKT> /** * `separate` composition. * * @since 2.10.0 */ export declare function separate( F: Functor2, C: Compactable2C, G: Functor2 ): ( fge: Kind2>> ) => S.Separated>, Kind2>> export declare function separate( F: Functor1, C: Compactable2C, G: Functor2 ): (fge: Kind>>) => S.Separated>, Kind>> export declare function separate( F: Functor1, C: Compactable1, G: Functor1 ): (fge: Kind>>) => S.Separated>, Kind>> export declare function separate( F: Functor, C: Compactable, G: Functor ): (fge: HKT>>) => S.Separated>, HKT>> /** * @category zone of death * @since 2.0.0 * @deprecated */ export interface CompactableComposition extends FunctorComposition { readonly compact: (fga: HKT>>) => HKT> readonly separate: (fge: HKT>>) => Separated>, HKT>> } /** * @category zone of death * @since 2.0.0 * @deprecated */ export interface CompactableComposition11 extends FunctorComposition11 { readonly compact: (fga: Kind>>) => Kind> readonly separate: (fge: Kind>>) => Separated>, Kind>> } /** * @category zone of death * @since 2.0.0 * @deprecated */ export interface CompactableComposition12 extends FunctorComposition12 { readonly compact: (fga: Kind>>) => Kind> readonly separate: ( fge: Kind>> ) => Separated>, Kind>> } /** * @category zone of death * @since 2.0.0 * @deprecated */ export interface CompactableComposition12C extends FunctorComposition12C { readonly compact: (fga: Kind>>) => Kind> readonly separate: ( fge: Kind>> ) => Separated>, Kind>> } /** * @category zone of death * @since 2.0.0 * @deprecated */ export interface CompactableComposition21 extends FunctorComposition21 { readonly compact: (fga: Kind2>>) => Kind2> readonly separate: ( fge: Kind2>> ) => Separated>, Kind2>> } /** * @category zone of death * @since 2.0.0 * @deprecated */ export interface CompactableComposition2C1 extends FunctorComposition2C1 { readonly compact: (fga: Kind2>>) => Kind2> readonly separate: ( fge: Kind2>> ) => Separated>, Kind2>> } /** * @category zone of death * @since 2.0.0 * @deprecated */ export interface CompactableComposition22 extends FunctorComposition22 { readonly compact: (fga: Kind2>>) => Kind2> readonly separate: ( fge: Kind2>> ) => Separated>, Kind2>> } /** * @category zone of death * @since 2.0.0 * @deprecated */ export interface CompactableComposition22C extends FunctorComposition22C { readonly compact: (fga: Kind2>>) => Kind2> readonly separate: ( fge: Kind2>> ) => Separated>, Kind2>> } /** * @category zone of death * @since 2.2.0 * @deprecated */ export interface CompactableComposition23 extends FunctorComposition23 { readonly compact: (fga: Kind2>>) => Kind2> readonly separate: ( fge: Kind2>> ) => Separated>, Kind2>> } /** * @category zone of death * @since 2.2.0 * @deprecated */ export interface CompactableComposition23C extends FunctorComposition23C { readonly compact: (fga: Kind2>>) => Kind2> readonly separate: ( fge: Kind2>> ) => Separated>, Kind2>> } /** * Use [`compact`](#compact) and [`separate`](#separate) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare function getCompactableComposition( F: Functor2, G: Compactable3C & Functor3C ): CompactableComposition23C /** @deprecated */ export declare function getCompactableComposition( F: Functor2, G: Compactable2C & Functor2C ): CompactableComposition22C /** @deprecated */ export declare function getCompactableComposition( F: Functor2, G: Compactable2 & Functor2 ): CompactableComposition22 /** @deprecated */ export declare function getCompactableComposition( F: Functor2C, G: Compactable1 & Functor1 ): CompactableComposition2C1 /** @deprecated */ export declare function getCompactableComposition( F: Functor2, G: Compactable1 & Functor1 ): CompactableComposition21 /** @deprecated */ export declare function getCompactableComposition( F: Functor1, G: Compactable2C & Functor2C ): CompactableComposition12 /** @deprecated */ export declare function getCompactableComposition( F: Functor1, G: Compactable2 & Functor2 ): CompactableComposition12 /** @deprecated */ export declare function getCompactableComposition( F: Functor1, G: Compactable1 & Functor1 ): CompactableComposition11 /** @deprecated */ export declare function getCompactableComposition( F: Functor, G: Compactable & Functor ): CompactableComposition /** * Use [`Separated`](./Separated.ts.html#separated) instead. * * @since 2.0.0 * @deprecated */ export interface Separated { readonly left: A readonly right: B }