Skip to main content
Module

x/fun/optics.ts>modify

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function modify
import { modify } from "https://deno.land/x/fun@v.2.0.0-alpha.11/optics.ts";

A pipeable modify function that applies a modification function to a Modifier<S, A> modify function. It will return a function S -> S that applies the modify function according to the type of optic. Note: All Optics are Modifiers.

Examples

Example 1

import * as O from "./optics.ts";
import { pipe } from "./fn.ts";

type Person = { readonly name: string };

const name = pipe(O.id<Person>(), O.prop("name"));

const upper = pipe(name, O.modify(s => s.toUpperCase()));

const result1 = upper({ name: "brandon" }); // { name: "BRANDON" }

Parameters

faa: (a: A) => A

Returns

<S>(modifier: Modifier<S, A>) => ReturnType<modifier.modify>