/** * An `Optional` is an optic used to zoom inside a product. Unlike the `Lens`, the element that the `Optional` focuses * on may not exist. * * `Optional`s have two type parameters generally called `S` and `A`: `Optional` where `S` represents the product * and `A` an optional element inside of `S`. * * Laws: * * 1. getOption(s).fold(() => s, a => set(a)(s)) = s * 2. getOption(set(a)(s)) = getOption(s).map(_ => a) * 3. set(a)(set(a)(s)) = set(a)(s) */ import type { Either } from "@effect-ts/core/Either"; import type { Predicate, Refinement } from "@effect-ts/core/Function"; 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 { Optional } from "../Internal/index.js"; import type { Traversal } from "../Traversal/index.js"; import Option = O.Option; export { Optional }; export declare const id: () => _.Optional; /** * View a `Optional` as a `Traversal` */ export declare const asTraversal: (sa: Optional) => Traversal; /** * Compose a `Optional` with a `Optional` */ export declare const compose: (ab: Optional) => (sa: Optional) => Optional; export declare const modifyOption: (f: (a: A) => A) => (optional: Optional) => (s: S) => Option; export declare const modify: (f: (a: A) => A) => (optional: Optional) => (s: S) => S; /** * Return an `Optional` from a `Optional` focused on a nullable value */ export declare const fromNullable: (sa: Optional) => Optional>; export declare function filter(refinement: Refinement): (sa: Optional) => Optional; export declare function filter(predicate: Predicate): (sa: Optional) => Optional; /** * Return a `Optional` from a `Optional` and a prop */ export declare const prop: (prop: P) => (sa: _.Optional) => _.Optional; /** * Return a `Optional` from a `Optional` and a list of props */ export declare const props: (props_0: P, props_1: P, ...props_2: P[]) => (sa: _.Optional) => _.Optional; /** * Return a `Optional` from a `Optional` and a component */ export declare const component: (prop: P) => (sa: _.Optional) => _.Optional; /** * Return a `Optional` from a `Optional` focused on a `ReadonlyArray` */ export declare const index: (i: number) => (sa: _.Optional) => _.Optional; /** * Return a `Optional` from a `Optional` focused on a `ReadonlyRecord` and a key */ export declare const keyInRecord: (key: string) => (sa: _.Optional>>) => _.Optional; /** * Return a `Optional` from a `Optional` focused on a `ReadonlyRecord` and a required key */ export declare const atKeyInRecord: (key: string) => (sa: _.Optional>>) => _.Optional>; /** * Return a `Optional` from a `Optional` focused on a `HashMap` and a key */ export declare const keyInHashMap: (key: K) => (sa: _.Optional>>) => _.Optional; /** * Return a `Optional` from a `Optional` focused on a `HashMap` and a required key */ export declare const atKeyInHashMap: (key: K) => (sa: _.Optional>>) => _.Optional>; /** * Return a `Optional` from a `Optional` focused on the `Some` of a `Option` type */ export declare const some: (soa: Optional>) => Optional; /** * Return a `Optional` from a `Optional` focused on the `Right` of a `Either` type */ export declare const right: (sea: Optional>) => Optional; /** * Return a `Optional` from a `Optional` focused on the `Left` of a `Either` type */ export declare const left: (sea: Optional>) => Optional; /** * Return a `Traversal` from a `Optional` focused on a `ForEach` */ export declare function forEach(T: P.ForEach): (sta: Optional>) => Traversal; export declare const find: (predicate: Predicate) => (sa: Optional>) => Optional; export declare const imap: (f: (a: A) => B, g: (b: B) => A) => (fa: Optional) => Optional; export declare const OptionalURI = "monocle/Optional"; export declare type OptionalURI = typeof OptionalURI; declare module "@effect-ts/core/Prelude/HKT" { interface URItoKind { [OptionalURI]: Optional; } } export declare const Category: P.Category<[URI<"monocle/Optional", {}>], P.Auto>; export declare const Invariant: P.Invariant<[URI<"monocle/Optional", {}>], P.Auto>; //# sourceMappingURL=index.d.ts.map