/** * A `Prism` is an optic used to select part of a sum type. * * Laws: * * 1. getOption(s).fold(s, reverseGet) = s * 2. getOption(reverseGet(a)) = Some(a) */ import type { Either } from "@effect-ts/core/Either"; import type { Predicate, Refinement } from "@effect-ts/core/Function"; import type { Newtype } from "@effect-ts/core/Newtype"; import * as O from "@effect-ts/core/Option"; import type { URI } from "@effect-ts/core/Prelude"; import * as P from "@effect-ts/core/Prelude"; import type { HashMap } from "@effect-ts/system/Collections/Immutable/HashMap"; import * as _ from "../Internal/index.js"; import { composePrism as compose, Prism } from "../Internal/index.js"; import type { Lens } from "../Lens/index.js"; import type { Optional } from "../Optional/index.js"; import type { Traversal } from "../Traversal/index.js"; import Option = O.Option; export { Prism }; export declare const id: () => _.Prism; export declare const fromPredicate: { (refinement: Refinement): Prism; (predicate: Predicate): Prism; }; /** * View a `Prism` as a `Optional` */ export declare const asOptional: (sa: Prism) => Optional; /** * View a `Prism` as a `Traversal` */ export declare const asTraversal: (sa: Prism) => Traversal; export { compose }; /** * Compose a `Prism` with a `Lens` */ export declare const composeLens: (ab: Lens) => (sa: Prism) => Optional; /** * Compose a `Prism` with an `Optional` */ export declare const composeOptional: (ab: _.Optional) => (sa: _.Prism) => _.Optional; export declare const set: (a: A) => (sa: Prism) => (s: S) => S; export declare const modifyOption: (f: (a: A) => A) => (sa: Prism) => (s: S) => Option; export declare const modify: (f: (a: A) => A) => (sa: Prism) => (s: S) => S; /** * Return a `Prism` from a `Prism` focused on a nullable value */ export declare const fromNullable: (sa: Prism) => Prism>; export declare function filter(refinement: Refinement): (sa: Prism) => Prism; export declare function filter(predicate: Predicate): (sa: Prism) => Prism; /** * Return a `Optional` from a `Prism` and a prop */ export declare const prop: (prop: P) => (sa: _.Prism) => _.Optional; /** * Return a `Optional` from a `Prism` and a list of props */ export declare const props: (props_0: P, props_1: P, ...props_2: P[]) => (sa: _.Prism) => _.Optional; /** * Return a `Optional` from a `Prism` and a component */ export declare const component: (prop: P) => (sa: _.Prism) => _.Optional; /** * Return a `Optional` from a `Prism` focused on a `ReadonlyArray` */ export declare const index: (i: number) => (sa: _.Prism) => _.Optional; /** * Return a `Optional` from a `Prism` focused on a `ReadonlyRecord` and a key */ export declare const keyInRecord: (key: string) => (sa: _.Prism>>) => _.Optional; /** * Return a `Optional` from a `Prism` focused on a `ReadonlyRecord` and a required key */ export declare const atKeyInRecord: (key: string) => (sa: _.Prism>>) => _.Optional>; /** * Return a `Optional` from a `Prism` focused on a `HashMap` and a key */ export declare const keyInHashMap: (key: K) => (sa: _.Prism>>) => _.Optional; /** * Return a `Optional` from a `Prism` focused on a `HashMap` and a required key */ export declare const atKeyInHashMap: (key: K) => (sa: _.Prism>>) => _.Optional>; /** * Return a `Prism` from a `Prism` focused on the `Some` of a `Option` type */ export declare const some: (soa: Prism>) => Prism; /** * Return a `Prism` from a `Prism` focused on the `Right` of a `Either` type */ export declare const right: (sea: Prism>) => Prism; /** * Return a `Prism` from a `Prism` focused on the `Left` of a `Either` type */ export declare const left: (sea: Prism>) => Prism; /** * Return a `Traversal` from a `Prism` focused on a `ForEach` */ export declare function forEach(T: P.ForEach): (sta: Prism>) => Traversal; export declare const find: (predicate: Predicate) => (sa: Prism>) => Optional; export declare const imap: (f: (a: A) => B, g: (b: B) => A) => (sa: Prism) => Prism; export declare const PrismURI = "monocle/Prism"; export declare type PrismURI = typeof PrismURI; declare module "@effect-ts/core/Prelude/HKT" { interface URItoKind { [PrismURI]: Prism; } } export declare const Category: P.Category<[URI<"monocle/Prism", {}>], P.Auto>; export declare const Invariant: P.Invariant<[URI<"monocle/Prism", {}>], P.Auto>; export declare function newtype>(getOption: (_: T["_A"]) => boolean): Prism; //# sourceMappingURL=index.d.ts.map