### asOptional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Converts an Iso to an Optional. This leverages the `get` and `reverseGet` properties of Iso to satisfy the Optional interface. ```APIDOC ## asOptional ### Description View an `Iso` as an `Optional`. This function enables the use of Iso's properties within contexts that expect an Optional, providing a way to access and modify parts of a structure. ### Signature ```ts export declare const asOptional: (sa: Iso) => Optional ``` ``` -------------------------------- ### Iso Constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `iso` to construct an Iso from `get` and `reverseGet` functions. This function is available since v2.3.8. ```typescript export declare const iso: (get: (s: S) => A, reverseGet: (a: A) => S) => Iso ``` -------------------------------- ### Optional Interface Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Optional.ts.md Defines the core Optional interface with methods for getting an Option of a value and setting a value. ```APIDOC ## Optional (interface) ### Description Represents an optional value within a larger structure. ### Signature ```ts export interface Optional { readonly getOption: (s: S) => Option readonly set: (a: A) => (s: S) => S } ``` ``` -------------------------------- ### prism Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Create a Prism from a getter and a setter. This constructor allows defining a Prism by providing functions to get an optional value and to set a value. ```APIDOC ## prism ### Description Create a `Prism` from a getter and a setter. ### Method Not applicable (function signature) ### Endpoint Not applicable (function signature) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### Prism constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Constructs a new Prism instance. A Prism is defined by a function to get an Option of the target value from the source and a function to reverse-get the source from the target value. ```APIDOC ## Prism (class) ### Constructor **Signature** ```ts constructor(readonly getOption: (s: S) => Option, readonly reverseGet: (a: A) => S) ``` ``` -------------------------------- ### optional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Optional.ts.md Constructs an Optional from a getter function that returns an Option and a setter function. This allows creating an Optional for any data structure where you can define how to get and set values. ```APIDOC ## optional ### Description Constructs an Optional from a getter function that returns an Option and a setter function. ### Signature ```ts export declare const optional: (getOption: (s: S) => O.Option, set: (a: A) => (s: S) => S) => Optional ``` ``` -------------------------------- ### Iso Class Constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Defines the constructor for the Iso class, requiring functions for getting a target value and reversing the operation. ```typescript export declare class Iso { constructor(readonly get: (s: S) => A, readonly reverseGet: (a: A) => S) } ``` -------------------------------- ### _right Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Either.ts.md Creates a Prism that focuses on the right (success) side of an Either. This allows for getting or setting the success value within an Either. ```APIDOC ## _right ### Description Creates a Prism that focuses on the right (success) side of an Either. This allows for getting or setting the success value within an Either. ### Signature ```ts export declare const _right: () => Prism, A> ``` ``` -------------------------------- ### Prism Interface Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Defines the structure of a Prism, which consists of a function to get an Option of the focused value and a function to construct the whole structure from a focused value. ```APIDOC ## Prism Interface ### Description Defines the structure of a Prism, which consists of a function to get an Option of the focused value and a function to construct the whole structure from a focused value. ### Interface ```ts export interface Prism { readonly getOption: (s: S) => Option readonly reverseGet: (a: A) => S } ``` ``` -------------------------------- ### Fold.getAll Property Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md A property that returns a function to get all targets of a Fold as an array. ```typescript readonly getAll: (s: S) => Array ``` -------------------------------- ### iso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Creates an Iso from a getter and a reverse getter. This is the primary constructor for creating Iso instances. ```APIDOC ## iso ### Description Creates an Iso from a getter and a reverse getter. This is the primary constructor for creating Iso instances. ### Signature ```ts export declare const iso: (get: (s: S) => A, reverseGet: (a: A) => S) => Iso ``` ``` -------------------------------- ### Iso.unwrap Property Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md A property that provides the function to get the target value from the source value. ```typescript readonly unwrap: (s: S) => A ``` -------------------------------- ### At.fromIso Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Creates an At instance by lifting it with an Iso. Useful for adapting At to different types. ```typescript fromIso(iso: Iso): At ``` -------------------------------- ### atReadonlyRecord Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/At/ReadonlyRecord.ts.md Creates an accessor for a ReadonlyRecord that allows getting an optional value at a specific key. ```APIDOC ## atReadonlyRecord ### Description Creates an accessor for a ReadonlyRecord that allows getting an optional value at a specific key. ### Method Signature ```ts export declare const atReadonlyRecord: () => At>, string, Option> ``` ### Parameters This function does not take any direct parameters. It returns an accessor. ### Returns An accessor of type `At>, string, Option>` which can be used to interact with a `Readonly>`. ### Example ```ts import { atReadonlyRecord } from '@fp-ts/monocle-ts/ReadonlyRecord' import { some, none } from '@fp-ts/data/Option' const record = { a: 1, b: 2 } as const const accessor = atReadonlyRecord() // Getting a value console.log(accessor.get(record, 'a')) // Output: { _tag: 'Some', value: 1 } console.log(accessor.get(record, 'c')) // Output: { _tag: 'None' } // Setting a value (Note: ReadonlyRecord is immutable, this would typically be used with lenses/prisms) // For demonstration, if it were mutable: // accessor.set(record, 'c', 3) // console.log(record) // Would conceptually become { a: 1, b: 2, c: 3 } // Modifying a value (Note: ReadonlyRecord is immutable) // accessor.modify(record, 'a', (n) => n * 2) // console.log(record) // Would conceptually become { a: 2, b: 2 } ``` ``` -------------------------------- ### TypeScript Interfaces Source: https://github.com/gcanti/monocle-ts/blob/master/docs/index.md Defines the interfaces for Employee, Company, Address, and Street objects used in the examples. ```typescript interface Street { num: number name: string } interface Address { city: string street: Street } interface Company { name: string address: Address } interface Employee { name: string company: Company } ``` -------------------------------- ### At.fromIso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md The fromIso method allows lifting an instance of At using an Iso, creating a new At instance with a potentially different type context. ```APIDOC ## fromIso(iso: Iso) : At ### Description Lifts an instance of `At` using an `Iso`. ### Parameters * **iso** (Iso) - Required - An Iso instance used to transform the type context. ``` -------------------------------- ### Prism.some Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Creates a Prism that focuses on the value inside an Option, if it exists. ```APIDOC ### some (static method) **Signature** ```ts static some(): Prism, A> ``` ``` -------------------------------- ### Iso.to Property Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md An alias for the `unwrap` property, providing the function to get the target value from the source value. ```typescript readonly to: (s: S) => A ``` -------------------------------- ### fromIso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/At.ts.md Lifts an existing At instance using an Iso. This allows you to adapt an At instance from one type to another compatible type defined by the Iso. ```APIDOC ## fromIso ### Description Lift an instance of `At` using an `Iso`. ### Signature ```ts export declare const fromIso: (iso: Iso) => (sia: At) => At ``` ``` -------------------------------- ### at Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/At.ts.md Constructs an At instance from a function that returns a Lens. This allows for creating an At instance for a specific structure based on a provided lens. ```APIDOC ## at ### Description Constructs an At instance from a function that returns a Lens. This allows for creating an At instance for a specific structure based on a provided lens. ### Signature ```ts export declare const at: (at: (i: I) => Lens) => At ``` ``` -------------------------------- ### Iso Interface Definition Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Defines the structure of an Iso, requiring `get` and `reverseGet` methods. Added in v2.3.0. ```typescript export interface Iso { readonly get: (s: S) => A readonly reverseGet: (a: A) => S } ``` -------------------------------- ### Iso.asPrism Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Converts the Iso into a Prism, allowing it to be used in contexts expecting a Prism. ```typescript asPrism(): Prism ``` -------------------------------- ### Iso.asLens Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Converts the Iso into a Lens, allowing it to be used in contexts expecting a Lens. ```typescript asLens(): Lens ``` -------------------------------- ### fromAt Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Ix.ts.md Constructs an Index from an At instance. This allows for indexed access to a structure based on the capabilities defined by the At type. ```APIDOC ## fromAt ### Description Constructs an Index from an At instance. This allows for indexed access to a structure based on the capabilities defined by the At type. ### Signature ```ts export declare const fromAt: (at: At>) => Index ``` ``` -------------------------------- ### Lens Class Signature Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Defines the structure of a Lens, which consists of a get function to retrieve a value and a set function to update it. ```typescript export declare class Lens { constructor(readonly get: (s: S) => A, readonly set: (a: A) => (s: S) => S) } ``` -------------------------------- ### Index.fromIso Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Lifts an Iso instance into an Index, allowing an Iso to be used for indexing operations. ```typescript fromIso(iso: Iso): Index ``` -------------------------------- ### asLens Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Converts an Iso to a Lens. This allows viewing the bidirectional mapping of an Iso through the lens interface. ```APIDOC ## asLens ### Description View an `Iso` as a `Lens`. This function allows you to treat an Iso, which provides a bidirectional mapping between two types, as a Lens, which is a unidirectional focusing type. ### Signature ```ts export declare const asLens: (sa: Iso) => Lens ``` ``` -------------------------------- ### Lens Interface Definition Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Lens.ts.md Defines the core structure of a Lens, which includes methods for getting and setting values within a structure. ```typescript export interface Lens { readonly get: (s: S) => A readonly set: (a: A) => (s: S) => S } ``` -------------------------------- ### some Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Returns a Prism from a Prism focused on the Some of a Option type. ```APIDOC ## some ### Description Returns a Prism from a Prism focused on the Some of a Option type. ### Signature ```ts export declare const some: (soa: Prism>) => Prism ``` ``` -------------------------------- ### Optional Interface Definition Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Optional.ts.md Defines the core Optional interface, including methods for getting an optional value and setting a value. ```typescript export interface Optional { readonly getOption: (s: S) => Option readonly set: (a: A) => (s: S) => S } ``` -------------------------------- ### Category Instance Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Defines the Category instance for Iso, enabling algebraic composition of Isos. ```APIDOC ## Category ### Description Provides the `Category` instance for the `Iso` type. This allows for the composition of `Iso` instances, forming a category where `Iso`s are morphisms. ### Signature ```ts export declare const Category: Category2<'monocle-ts/Iso'> ``` ``` -------------------------------- ### Filter Traversal Example Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Demonstrates filtering elements within a list using a Traversal and then modifying a property of the filtered elements. ```typescript import { fromTraversable, Lens } from 'monocle-ts' import { Traversable } from 'fp-ts/Array' interface Person { name: string cool: boolean } const peopleTraversal = fromTraversable(Traversable)() const coolLens = Lens.fromProp()('cool') const people = [ { name: 'bill', cool: false }, { name: 'jill', cool: true }, ] const actual = peopleTraversal .filter((p) => p.name === 'bill') .composeLens(coolLens) .set(true)(people) assert.deepStrictEqual(actual, [ { name: 'bill', cool: true }, { name: 'jill', cool: true }, ]) ``` -------------------------------- ### Prism Class Signature Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Defines the Prism class with its constructor, which takes a function to get an Option of a value and a function to reverse the operation. ```typescript export declare class Prism { constructor(readonly getOption: (s: S) => Option, readonly reverseGet: (a: A) => S) } ``` -------------------------------- ### Iso.composePrism Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Iso with a Prism, resulting in a Prism. ```typescript composePrism(ab: Prism): Prism ``` -------------------------------- ### _left Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Either.ts.md Creates a Prism that focuses on the left (error) side of an Either. This allows for getting or setting the error value within an Either. ```APIDOC ## _left ### Description Creates a Prism that focuses on the left (error) side of an Either. This allows for getting or setting the error value within an Either. ### Signature ```ts export declare const _left: () => Prism, E> ``` ``` -------------------------------- ### Fold.headOption Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md The headOption method retrieves the first target of a Fold, returning it as an Option. ```APIDOC ## headOption(s: S) : Option ### Description Gets the first target of a `Fold`. ### Parameters * **s** (S) - Required - The structure to extract the target from. ``` -------------------------------- ### fromIso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Ix.ts.md Lifts an existing Index instance using an Iso. This allows an Index to operate on a different but isomorphic data structure. ```APIDOC ## fromIso ### Description Lifts an existing Index instance using an Iso. This allows an Index to operate on a different but isomorphic data structure. ### Signature ```ts export declare const fromIso: (iso: Iso) => (sia: Index) => Index ``` ``` -------------------------------- ### fromTraversable Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Create a Traversal from a Traversable structure. This function is overloaded to support different arities of Traversable types and includes an example of its usage. ```APIDOC ## fromTraversable ### Description Create a `Traversal` from a `Traversable`. ### Signature ```ts export declare function fromTraversable( T: Traversable3 ): () => Traversal, A> export declare function fromTraversable(T: Traversable2): () => Traversal, A> export declare function fromTraversable(T: Traversable1): () => Traversal, A> export declare function fromTraversable(T: Traversable): () => Traversal, A> ``` ### Example ```ts import { Lens, fromTraversable } from 'monocle-ts' import { Traversable } from 'fp-ts/Array' interface Tweet { text: string } interface Tweets { tweets: Tweet[] } const tweetsLens = Lens.fromProp()('tweets') const tweetTextLens = Lens.fromProp()('text') const tweetTraversal = fromTraversable(Traversable)() const composedTraversal = tweetsLens.composeTraversal(tweetTraversal).composeLens(tweetTextLens) const tweet1: Tweet = { text: 'hello world' } const tweet2: Tweet = { text: 'foobar' } const model: Tweets = { tweets: [tweet1, tweet2] } const actual = composedTraversal.modify((text) => text.split('').reverse().join(''))(model) assert.deepStrictEqual(actual, { tweets: [{ text: 'dlrow olleh' }, { text: 'raboof' }] }) ``` ``` -------------------------------- ### Identity Lens Constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Lens.ts.md Create an identity Lens that focuses on the entire structure itself. Useful as a starting point or for functions expecting a Lens. ```typescript export declare const id: () => Lens ``` -------------------------------- ### Convert Iso to Prism Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `asPrism` to view an Iso as a Prism. This function is available from v2.3.0. ```typescript export declare const asPrism: (sa: Iso) => Prism ``` -------------------------------- ### lens Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Lens.ts.md Constructs a Lens from getter and setter functions. This function allows the creation of a new lens by providing functions to get and set values. ```APIDOC ## lens ### Description Constructs a `Lens` from getter and setter functions. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response Returns a `Lens`. ### Response Example None ``` -------------------------------- ### props Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Returns an Optional from a Prism and a list of props. ```APIDOC ## props ### Description Returns an Optional from a Prism and a list of props. ### Signature ```ts export declare const props: (props_0: P, props_1: P, ...props_2: P[]) => (sa: Prism) => Optional ``` ``` -------------------------------- ### Prism.asOptional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Views the Prism as an Optional. ```APIDOC ### asOptional (method) view a `Prism` as a `Optional` **Signature** ```ts asOptional(): Optional ``` ``` -------------------------------- ### Iso.asOptional Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Converts the Iso into an Optional, allowing it to be used in contexts expecting an Optional. ```typescript asOptional(): Optional ``` -------------------------------- ### Iso.composeLens Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Iso with a Lens, resulting in a Lens. ```typescript composeLens(ab: Lens): Lens ``` -------------------------------- ### Semigroupoid Instance Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Defines the Semigroupoid instance for Iso, supporting the composition of Isos. ```APIDOC ## Semigroupoid ### Description Provides the `Semigroupoid` instance for the `Iso` type. This allows for the sequential composition of `Iso` instances, forming a semigroupoid structure. ### Signature ```ts export declare const Semigroupoid: Semigroupoid2<'monocle-ts/Iso'> ``` ``` -------------------------------- ### Modify Tweet Text using fromTraversable Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Demonstrates how to use fromTraversable with an Array Traversable to modify text within a nested structure of tweets. Ensure 'monocle-ts' and 'fp-ts' are installed. ```typescript import { Lens, fromTraversable } from 'monocle-ts' import { Traversable } from 'fp-ts/Array' interface Tweet { text: string } interface Tweets { tweets: Tweet[] } const tweetsLens = Lens.fromProp()('tweets') const tweetTextLens = Lens.fromProp()('text') const tweetTraversal = fromTraversable(Traversable)() const composedTraversal = tweetsLens.composeTraversal(tweetTraversal).composeLens(tweetTextLens) const tweet1: Tweet = { text: 'hello world' } const tweet2: Tweet = { text: 'foobar' } const model: Tweets = { tweets: [tweet1, tweet2] } const actual = composedTraversal.modify((text) => text.split('').reverse().join(''))(model) assert.deepStrictEqual(actual, { tweets: [{ text: 'dlrow olleh' }, { text: 'raboof' }] }) ``` -------------------------------- ### Construct Index from At Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Ix.ts.md Creates an Index from an At instance. Use this when you have a way to access elements by a key and want to treat it as an Index. ```typescript export declare const fromAt: (at: At>) => Index ``` -------------------------------- ### FromIso Constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/At.ts.md Lifts an At instance using an Iso. Allows applying At operations to a structure transformed by an Iso. ```typescript export declare const fromIso: (iso: Iso) => (sia: At) => At ``` -------------------------------- ### composeOptional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Compose an Iso with an Optional. This function composes an Iso with an Optional, yielding an Optional. ```APIDOC ## composeOptional ### Description Compose an `Iso` with an `Optional`. This function composes an Iso with an Optional, yielding an Optional. ### Signature ```ts export declare const composeOptional: (ab: Optional) => (sa: Iso) => Optional ``` ``` -------------------------------- ### Index.fromAt Static Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Creates an Index from an At instance, useful for indexing into structures that support the At typeclass. ```typescript static fromAt(at: At>): Index ``` -------------------------------- ### Construct Index from Iso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Ix.ts.md Lifts an existing Index instance using an Iso. This is useful for transforming the structure of the data before applying the index. ```typescript export declare const fromIso: (iso: Iso) => (sia: Index) => Index ``` -------------------------------- ### At Constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md The At class constructor is used to create an instance of At, which holds a function to derive a Lens from an input. ```APIDOC ## constructor At ### Description Initializes a new instance of the At class. ### Parameters * **at** (function) - Required - A function that takes an input `I` and returns a `Lens`. ``` -------------------------------- ### Iso.reverse Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Returns a new Iso with the source and target types swapped, effectively reversing the direction of the isomorphism. ```typescript reverse(): Iso ``` -------------------------------- ### composeIso Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Getter with an Iso. This operation results in a Getter. ```APIDOC ## composeIso Method ### Description Composes a `Getter` with an `Iso`. ### Signature ```ts composeIso(ab: Iso): Getter ``` #### Parameters * **ab** (Iso) - Required - The Iso to compose with. ``` -------------------------------- ### some Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Returns a Prism from an Iso focused on the Some variant of an Option type. This Prism allows for accessing or modifying the value within the Some. ```APIDOC ## some ### Description Returns a Prism from an Iso focused on the Some variant of an Option type. This Prism allows for accessing or modifying the value within the Some. ### Signature ```ts export declare const some: (soa: Iso>) => Prism ``` ``` -------------------------------- ### props Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Returns a Lens from an Iso and a list of props. This enables focused access to multiple properties of an object, returning them as a new object. ```APIDOC ## props ### Description Returns a Lens from an Iso and a list of props. This enables focused access to multiple properties of an object, returning them as a new object. ### Signature ```ts export declare const props: (props_0: P, props_1: P, ...props_2: P[]) => (sa: Iso) => Lens ``` ``` -------------------------------- ### composePrism Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Compose an Iso with a Prism. This function composes an Iso with a Prism, resulting in a Prism. ```APIDOC ## composePrism ### Description Compose an `Iso` with a `Prism`. This function composes an Iso with a Prism, resulting in a Prism. ### Signature ```ts export declare const composePrism: (ab: Prism) => (sa: Iso) => Prism ``` ``` -------------------------------- ### Convert Iso to Lens Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `asLens` to view an Iso as a Lens. This function is available from v2.3.0. ```typescript export declare const asLens: (sa: Iso) => Lens ``` -------------------------------- ### Prism.composeIso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Prism with an Iso. ```APIDOC ### composeIso (method) compose a `Prism` with a `Iso` **Signature** ```ts composeIso(ab: Iso): Prism ``` ``` -------------------------------- ### fromPredicate Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Create a Prism from a predicate or a refinement. This constructor allows building a Prism based on a condition. ```APIDOC ## fromPredicate ### Description Create a `Prism` from a `Predicate` or `Refinement`. ### Method Not applicable (function signature) ### Endpoint Not applicable (function signature) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### composeLens Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Traversal.ts.md Compose a `Traversal` with a `Lens`. This enables leveraging the focused access of a Lens within a Traversal's broader applicability. ```APIDOC ## composeLens ### Description Compose a `Traversal` with a `Lens`. ### Signature ```ts export declare const composeLens: (ab: Lens) => (sa: Traversal) => Traversal ``` ``` -------------------------------- ### Getter Class Constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Initializes a new Getter instance. It takes a function that extracts a part of a structure. ```APIDOC ## Getter Class ### Description Represents a way to get a part of a structure. ### Constructor ```ts new Getter(get: (s: S) => A) ``` #### Parameters * **get** (function) - Required - A function that takes the source structure `S` and returns a part `A`. ``` -------------------------------- ### composeLens Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Compose an Iso with a Lens. This function allows composing an Iso with a Lens, resulting in a Lens. ```APIDOC ## composeLens ### Description Compose an `Iso` with a `Lens`. This function allows composing an Iso with a Lens, resulting in a Lens. ### Signature ```ts export declare const composeLens: (ab: Lens) => (sa: Iso) => Lens ``` ``` -------------------------------- ### Convert Iso to Optional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `asOptional` to view an Iso as an Optional. This function is available from v2.3.0. ```typescript export declare const asOptional: (sa: Iso) => Optional ``` -------------------------------- ### asOptional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Converts a Prism into an Optional. This allows viewing the Prism's structure through the lens of an Optional, enabling operations defined for Optionals. ```APIDOC ## asOptional ### Description Converts a Prism into an Optional. This allows viewing the Prism's structure through the lens of an Optional, enabling operations defined for Optionals. ### Signature ```ts export declare const asOptional: (sa: Prism) => Optional ``` ``` -------------------------------- ### Semigroupoid Instance Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Provides the Semigroupoid typeclass instance for Prism, supporting composition of Prisms. ```APIDOC ## Semigroupoid Instance ### Description Provides the Semigroupoid typeclass instance for Prism, supporting composition of Prisms. ### Signature ```ts export declare const Semigroupoid: Semigroupoid2<'monocle-ts/Prism'> ``` ``` -------------------------------- ### prop Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Returns an Optional from a Prism and a prop. ```APIDOC ## prop ### Description Returns an Optional from a Prism and a prop. ### Signature ```ts export declare const prop: (prop: P) => (sa: Prism) => Optional ``` ``` -------------------------------- ### prop Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Returns a Lens from an Iso and a prop. This allows for focused access to a property of an object. ```APIDOC ## prop ### Description Returns a Lens from an Iso and a prop. This allows for focused access to a property of an object. ### Signature ```ts export declare const prop: (prop: P) => (sa: Iso) => Lens ``` ``` -------------------------------- ### component Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Returns an Optional from a Prism focused on a component of a tuple. ```APIDOC ## component ### Description Returns an Optional from a Prism focused on a component of a tuple. ### Signature ```ts export declare const component: (prop: P) => (sa: Prism) => Optional ``` ``` -------------------------------- ### Prism.composeIso Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Prism with an Iso. This results in a new Prism that targets the structure accessible through both the Prism and the Iso. ```typescript composeIso(ab: Iso): Prism ``` -------------------------------- ### Compose Iso with Optional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `composeOptional` to combine an Iso with an Optional. This function is available since v2.3.8. ```typescript export declare const composeOptional: (ab: Optional) => (sa: Iso) => Optional ``` -------------------------------- ### At (interface) Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/At.ts.md The At interface defines the core structure for At instances, providing a method to access elements within a structure using a key. ```APIDOC ## At (interface) ### Description The At interface defines the core structure for At instances, providing a method to access elements within a structure using a key. ### Signature ```ts export interface At { readonly at: (i: I) => Lens } ``` ``` -------------------------------- ### Iso.composeSetter Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Iso with a Setter, resulting in a Setter. ```typescript composeSetter(ab: Setter): Setter ``` -------------------------------- ### Compose Iso with Prism Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `composePrism` to combine an Iso with a Prism. This function is available since v2.3.8. ```typescript export declare const composePrism: (ab: Prism) => (sa: Iso) => Prism ``` -------------------------------- ### asPrism Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Converts an Iso to a Prism. This function enables the use of Iso's bidirectional mapping capabilities within a Prism's structure. ```APIDOC ## asPrism ### Description View an `Iso` as a `Prism`. This conversion allows you to utilize the bidirectional nature of an Iso in scenarios where a Prism is expected, facilitating pattern matching and modification. ### Signature ```ts export declare const asPrism: (sa: Iso) => Prism ``` ``` -------------------------------- ### atKey Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Returns an Optional from a Prism focused on a required key of a ReadonlyRecord. ```APIDOC ## atKey ### Description Returns an Optional from a Prism focused on a required key of a ReadonlyRecord. ### Signature ```ts export declare const atKey: (key: string) => (sa: Prism>>) => Optional> ``` ``` -------------------------------- ### asOptional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Lens.ts.md View a Lens as an Optional. This function converts a lens into an optional, allowing it to be used in contexts expecting an optional. ```APIDOC ## asOptional ### Description View a `Lens` as a `Optional`. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response Returns an `Optional`. ### Response Example None ``` -------------------------------- ### some Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Traversal.ts.md Creates a Traversal focused on the `Some` variant of an `Option` type. This allows for operations specifically on the present value within an Option. ```APIDOC ## some ### Description Return a `Traversal` from a `Traversal` focused on the `Some` of a `Option` type. ### Signature ```ts export declare const some: (soa: Traversal>) => Traversal ``` ``` -------------------------------- ### composeIso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Traversal.ts.md Compose a `Traversal` with an `Iso`. This is useful for combining traversal capabilities with isomorphism to navigate and modify data. ```APIDOC ## composeIso ### Description Compose a `Traversal` with a `Iso`. ### Signature ```ts export declare const composeIso: (ab: Iso) => (sa: Traversal) => Traversal ``` ``` -------------------------------- ### Iso.asGetter Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Converts the Iso into a Getter, allowing it to be used in contexts expecting a Getter. ```typescript asGetter(): Getter ``` -------------------------------- ### composeLens Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Getter with a Lens. This operation results in a Getter. ```APIDOC ## composeLens Method ### Description Composes a `Getter` with a `Lens`. ### Signature ```ts composeLens(ab: Lens): Getter ``` #### Parameters * **ab** (Lens) - Required - The Lens to compose with. ``` -------------------------------- ### Compose Lens with Prism Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md The `composePrism` method combines a Lens with a Prism. This creates a new Optional that operates on the target of the Lens, using the Prism for potential matching and setting. ```typescript composePrism(ab: Prism): Optional ``` -------------------------------- ### Invariant Instance Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Defines the Invariant instance for Iso, allowing transformations that preserve the structure of the Iso. ```APIDOC ## Invariant ### Description Provides the `Invariant` instance for the `Iso` type. This enables mapping over the structure of an `Iso` without changing its fundamental shape or type. ### Signature ```ts export declare const Invariant: Invariant2<'monocle-ts/Iso'> ``` ``` -------------------------------- ### Iso.asSetter Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Converts the Iso into a Setter, allowing it to be used in contexts expecting a Setter. ```typescript asSetter(): Setter ``` -------------------------------- ### composeOptional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Traversal.ts.md Compose a `Traversal` with an `Optional`. This allows for safe navigation and modification of potentially absent data. ```APIDOC ## composeOptional ### Description Compose a `Traversal` with a `Optional`. ### Signature ```ts export declare const composeOptional: (ab: Optional) => (sa: Traversal) => Traversal ``` ``` -------------------------------- ### Iso.composeOptional Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Iso with an Optional, resulting in an Optional. ```typescript composeOptional(ab: Optional): Optional ``` -------------------------------- ### atKey Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Lens.ts.md Returns a Lens focused on a required key of a ReadonlyRecord. If the key does not exist, it returns an Option.None. ```APIDOC ## atKey ### Description Returns a Lens focused on a required key of a ReadonlyRecord. If the key does not exist, it returns an Option.None. ### Signature ```ts export declare const atKey: (key: string) => (sa: Lens>>) => Lens> ``` ``` -------------------------------- ### At Constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/At.ts.md Creates an At instance from a function that returns a Lens. Useful for custom data structures. ```typescript export declare const at: (at: (i: I) => Lens) => At ``` -------------------------------- ### Optional.fromPath Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Creates an Optional instance from a path within a nested structure. It handles cases where intermediate properties might be null or undefined. ```APIDOC ## Optional.fromPath ### Description Returns an `Optional` from a nullable (`A | null | undefined`) prop. ### Signature ```ts static fromPath(): OptionalFromPath ``` ### Example ```ts import { Optional } from 'monocle-ts' interface Phone { number: string } interface Employment { phone?: Phone } interface Info { employment?: Employment } interface Response { info?: Info } const numberFromResponse = Optional.fromPath()(['info', 'employment', 'phone', 'number']) const response1: Response = { info: { employment: { phone: { number: '555-1234', }, }, }, } const response2: Response = { info: { employment: {}, }, } numberFromResponse.getOption(response1) // some('555-1234') numberFromResponse.getOption(response2) // none ``` ``` -------------------------------- ### composeOptional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Compose a Prism with an Optional. This function creates a new Optional by composing a Prism with an existing Optional. ```APIDOC ## composeOptional ### Description Compose a `Prism` with an `Optional`. ### Method Not applicable (function signature) ### Endpoint Not applicable (function signature) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### Prism.some Static Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Creates a Prism that targets the value inside an Option. This is useful for working with optional values within a larger structure. ```typescript static some(): Prism, A> ``` -------------------------------- ### Compose Iso with Iso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `compose` to combine two Isos. This function is available since v2.3.0. ```typescript export declare const compose: (ab: Iso) => (sa: Iso) => Iso ``` -------------------------------- ### Semigroupoid Instance for Iso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md The Semigroupoid instance for Iso is exported as `Semigroupoid`. Added in v2.3.8. ```typescript export declare const Semigroupoid: Semigroupoid2<'monocle-ts/Iso'> ``` -------------------------------- ### filter Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Creates a Prism from an Iso. It can either use a refinement function to filter for a specific subtype or a predicate function to filter values. ```APIDOC ## filter ### Description Creates a Prism from an Iso. It can either use a refinement function to filter for a specific subtype or a predicate function to filter values. ### Signature ```ts export declare function filter(refinement: Refinement): (sa: Iso) => Prism export declare function filter(predicate: Predicate): (sa: Iso) => Prism ``` ``` -------------------------------- ### Fold.headOption Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Retrieves the first target of a Fold as an Option. Returns None if the Fold has no targets. ```typescript headOption(s: S): Option ``` -------------------------------- ### some Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Lens.ts.md Returns an Optional focused on the Some value of an Option type. If the Option is None, this Optional will be None. ```APIDOC ## some ### Description Returns an Optional focused on the Some value of an Option type. If the Option is None, this Optional will be None. ### Signature ```ts export declare const some: (soa: Lens>) => Optional ``` ``` -------------------------------- ### Category Instance for Iso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md The Category instance for Iso is exported as `Category`. Added in v2.3.0. ```typescript export declare const Category: Category2<'monocle-ts/Iso'> ``` -------------------------------- ### setOption Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Optional.ts.md Sets a new value within an Optional, returning a new Optional. ```APIDOC ## setOption ### Description Sets a new value within an Optional, returning a new Optional. ### Signature ```ts export declare const setOption: (a: A) => (optional: Optional) => (s: S) => O.Option ``` ``` -------------------------------- ### Category Instance Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Provides the Category typeclass instance for Prism, enabling category-theoretic operations on Prisms. ```APIDOC ## Category Instance ### Description Provides the Category typeclass instance for Prism, enabling category-theoretic operations on Prisms. ### Signature ```ts export declare const Category: Category2<'monocle-ts/Prism'> ``` ``` -------------------------------- ### Prism.composeOptional Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Prism with an Optional. ```APIDOC ### composeOptional (method) compose a `Prism` with a `Optional` **Signature** ```ts composeOptional(ab: Optional): Optional ``` ``` -------------------------------- ### index Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Ix.ts.md Creates an Index by providing a function that maps an index key to an Optional value within a structure. ```APIDOC ## index ### Description Creates an Index by providing a function that maps an index key to an Optional value within a structure. ### Signature ```ts export declare const index: (index: (i: I) => Optional) => Index ``` ``` -------------------------------- ### Iso.from Property Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md An alias for the `wrap` property, providing the function to create a source value from a target value. ```typescript readonly from: (a: A) => S ``` -------------------------------- ### Optional.composeIso Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Optional with an Iso. ```typescript composeIso(ab: Iso): Optional ``` -------------------------------- ### Identity Iso Constructor Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `id` to create an Iso that represents the identity function for any type. This function is available since v2.3.0. ```typescript export declare const id: () => Iso ``` -------------------------------- ### composeIso Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Compose a Prism with an Iso. This function allows combining a Prism with an Iso to create a new Prism. ```APIDOC ## composeIso ### Description Compose a `Prism` with an `Iso`. ### Method Not applicable (function signature) ### Endpoint Not applicable (function signature) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### Prism.asSetter Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Views the Prism as a Setter. ```APIDOC ### asSetter (method) view a `Prism` as a `Setter` **Signature** ```ts asSetter(): Setter ``` ``` -------------------------------- ### Iso.compose Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Iso with another Iso, creating a new Iso that represents the combined transformation. ```typescript compose(ab: Iso): Iso ``` -------------------------------- ### Compose Iso with Lens Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Iso.ts.md Use `composeLens` to combine an Iso with a Lens. This function is available since v2.3.8. ```typescript export declare const composeLens: (ab: Lens) => (sa: Iso) => Lens ``` -------------------------------- ### Prism.fromPredicate Static Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Creates a Prism from a predicate or a refinement function. Use this to create prisms that target a subset of a structure based on a condition. ```typescript static fromPredicate(refinement: Refinement): Prism static fromPredicate(predicate: Predicate): Prism ``` -------------------------------- ### composeIso Method Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/index.ts.md Composes the current Getter with an Iso to create a new Getter. ```typescript composeIso(ab: Iso): Getter ``` -------------------------------- ### key Source: https://github.com/gcanti/monocle-ts/blob/master/docs/modules/Prism.ts.md Returns an Optional from a Prism focused on a key of a ReadonlyRecord. ```APIDOC ## key ### Description Returns an Optional from a Prism focused on a key of a ReadonlyRecord. ### Signature ```ts export declare const key: (key: string) => (sa: Prism>>) => Optional ``` ```