Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/optic.ts>optic

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

Construct an Optic<U, S, A> & Reviewer<S, A> from a tag as well as view, modify, and reivew functions.

Type Parameters

U extends Tag
S
A

Parameters

tag: U
view: (s: S) => $<ToKind<U>, [A, never, never]>
modify: (modifyFn: (a: A) => A) => (s: S) => S
review: (a: A) => S

Construct an Optic<U, S, A> from a tag as well as view and modify functions.

Type Parameters

U extends Tag
S
A

Parameters

tag: U
view: (s: S) => $<ToKind<U>, [A, never, never]>
modify: (modifyFn: (a: A) => A) => (s: S) => S