/** * **This module is experimental** * * Experimental features are published in order to get early feedback from the community. * * A feature tagged as _Experimental_ is in a high state of flux, you're at risk of it changing without notice. * * An `Iso` is an optic which converts elements of type `S` into elements of type `A` without loss. * * Laws: * * 1. `reverseGet(get(s)) = s` * 2. `get(reversetGet(a)) = a` * * @since 2.3.0 */ import { Category2 } from 'fp-ts/es6/Category' import { Either } from 'fp-ts/es6/Either' import { Predicate, Refinement } from 'fp-ts/es6/function' import { Functor, Functor1, Functor2, Functor3 } from 'fp-ts/es6/Functor' import { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from 'fp-ts/es6/HKT' import { Invariant2 } from 'fp-ts/es6/Invariant' import { Option } from 'fp-ts/es6/Option' import { ReadonlyNonEmptyArray } from 'fp-ts/es6/ReadonlyNonEmptyArray' import { ReadonlyRecord } from 'fp-ts/es6/ReadonlyRecord' import { Semigroupoid2 } from 'fp-ts/es6/Semigroupoid' import { Traversable1 } from 'fp-ts/es6/Traversable' import { Lens } from './Lens' import { Optional } from './Optional' import { Prism } from './Prism' import { Traversal } from './Traversal' /** * @category model * @since 2.3.0 */ export interface Iso { readonly get: (s: S) => A readonly reverseGet: (a: A) => S } /** * @category constructors * @since 2.3.8 */ export declare const iso: (get: Iso['get'], reverseGet: Iso['reverseGet']) => Iso /** * @category constructors * @since 2.3.0 */ export declare const id: () => Iso /** * View an `Iso` as a `Lens`. * * @category converters * @since 2.3.0 */ export declare const asLens: (sa: Iso) => Lens /** * View an `Iso` as a `Prism`. * * @category converters * @since 2.3.0 */ export declare const asPrism: (sa: Iso) => Prism /** * View an `Iso` as a `Optional`. * * @category converters * @since 2.3.0 */ export declare const asOptional: (sa: Iso) => Optional /** * View an `Iso` as a `Traversal`. * * @category converters * @since 2.3.0 */ export declare const asTraversal: (sa: Iso) => Traversal /** * Compose an `Iso` with an `Iso`. * * @category compositions * @since 2.3.0 */ export declare const compose: (ab: Iso) => (sa: Iso) => Iso /** * Alias of `compose`. * * @category compositions * @since 2.3.8 */ export declare const composeIso: (ab: Iso) => (sa: Iso) => Iso /** * Compose an `Iso` with a `Lens`. * * @category compositions * @since 2.3.8 */ export declare const composeLens: (ab: Lens) => (sa: Iso) => Lens /** * Compose an `Iso` with a `Prism`. * * @category compositions * @since 2.3.8 */ export declare const composePrism: (ab: Prism) => (sa: Iso) => Prism /** * Compose an `Iso` with a `Optional`. * * @category compositions * @since 2.3.8 */ export declare const composeOptional: (ab: Optional) => (sa: Iso) => Optional /** * Compose an `Iso` with a `Traversal`. * * @category compositions * @since 2.3.8 */ export declare const composeTraversal: (ab: Traversal) => (sa: Iso) => Traversal /** * @category constructors * @since 2.3.0 */ export declare const reverse: (sa: Iso) => Iso /** * @category combinators * @since 2.3.0 */ export declare const modify: (f: (a: A) => B) => (sa: Iso) => (s: S) => S /** * @category combinators * @since 2.3.5 */ export declare function modifyF( F: Functor3 ): (f: (a: A) => Kind3) => (sa: Iso) => (s: S) => Kind3 export declare function modifyF( F: Functor2 ): (f: (a: A) => Kind2) => (sa: Iso) => (s: S) => Kind2 export declare function modifyF( F: Functor1 ): (f: (a: A) => Kind) => (sa: Iso) => (s: S) => Kind export declare function modifyF( F: Functor ): (f: (a: A) => HKT) => (sa: Iso) => (s: S) => HKT /** * Return a `Prism` from a `Iso` focused on a nullable value. * * @category combinators * @since 2.3.8 */ export declare const fromNullable: (sa: Iso) => Prism> /** * @category combinators * @since 2.3.8 */ export declare function filter(refinement: Refinement): (sa: Iso) => Prism export declare function filter(predicate: Predicate): (sa: Iso) => Prism /** * Return a `Lens` from a `Iso` and a prop. * * @category combinators * @since 2.3.8 */ export declare const prop: (prop: P) => (sa: Iso) => Lens /** * Return a `Lens` from a `Iso` and a list of props. * * @category combinators * @since 2.3.8 */ export declare const props: ( props_0: P, props_1: P, ...props_2: P[] ) => (sa: Iso) => Lens /** * Return a `Lens` from a `Iso` focused on a component of a tuple. * * @category combinators * @since 2.3.8 */ export declare const component: ( prop: P ) => (sa: Iso) => Lens /** * Return a `Optional` from a `Iso` focused on an index of a `ReadonlyArray`. * * @category combinators * @since 2.3.8 */ export declare const index: (i: number) => (sa: Iso) => Optional /** * Return a `Optional` from a `Iso` focused on an index of a `ReadonlyNonEmptyArray`. * * @category combinators * @since 2.3.8 */ export declare const indexNonEmpty: (i: number) => (sa: Iso>) => Optional /** * Return a `Optional` from a `Iso` focused on a key of a `ReadonlyRecord`. * * @category combinators * @since 2.3.8 */ export declare const key: (key: string) => (sa: Iso>>) => Optional /** * Return a `Lens` from a `Iso` focused on a required key of a `ReadonlyRecord`. * * @category combinators * @since 2.3.8 */ export declare const atKey: (key: string) => (sa: Iso>>) => Lens> /** * Return a `Prism` from a `Iso` focused on the `Some` of a `Option` type. * * @category combinators * @since 2.3.8 */ export declare const some: (soa: Iso>) => Prism /** * Return a `Prism` from a `Iso` focused on the `Right` of a `Either` type. * * @category combinators * @since 2.3.8 */ export declare const right: (sea: Iso>) => Prism /** * Return a `Prism` from a `Iso` focused on the `Left` of a `Either` type. * * @category combinators * @since 2.3.8 */ export declare const left: (sea: Iso>) => Prism /** * Return a `Traversal` from a `Iso` focused on a `Traversable`. * * @category combinators * @since 2.3.8 */ export declare function traverse(T: Traversable1): (sta: Iso>) => Traversal /** * @category combinators * @since 2.3.8 */ export declare function findFirst( refinement: Refinement ): (sa: Iso>) => Optional export declare function findFirst(predicate: Predicate): (sa: Iso>) => Optional /** * @category combinators * @since 2.3.8 */ export declare function findFirstNonEmpty( refinement: Refinement ): (sa: Iso>) => Optional export declare function findFirstNonEmpty( predicate: Predicate ): (sa: Iso>) => Optional /** * @category Invariant * @since 2.3.0 */ export declare const imap: (f: (a: A) => B, g: (b: B) => A) => (sa: Iso) => Iso /** * @category instances * @since 2.3.0 */ export declare const URI = 'monocle-ts/Iso' /** * @category instances * @since 2.3.0 */ export declare type URI = typeof URI declare module 'fp-ts/es6/HKT' { interface URItoKind2 { readonly [URI]: Iso } } /** * @category instances * @since 2.3.0 */ export declare const Invariant: Invariant2 /** * @category instances * @since 2.3.8 */ export declare const Semigroupoid: Semigroupoid2 /** * @category instances * @since 2.3.0 */ export declare const Category: Category2