Skip to main content
Module

x/fun/mod.ts>optic.modify

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function optic.modify
import { optic } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { modify } = optic;

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 "./optic.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>