import { optic } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { replace } = optic;
A pipeable replace function, that uses the modify function of an Optic to replace an existing value over the structure S.
Examples
Example 1
Example 1
import * as O from "./optic.ts";
import { pipe } from "./fn.ts";
type Person = { name: string };
const name = pipe(O.id<Person>(), O.prop("name"));
const toBrandon = pipe(name, O.replace("Brandon"));
const tina: Person = { name: "Tina" }
const result = toBrandon(tina); // { name: "Brandon" }
Parameters
a: A