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

x/fun/mod.ts>optic.id

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

Construct an Iso<A, A> from a type level argument. This is the entrypoint to almost all optics as it allows one to start with a type and compose other optics from there.

Examples

Example 1

import * as O from "./optic.ts";

const number = O.id<number>();

const result1 = number.view(1); // 1
const result2 = number.review(1); // 1
const result4 = number.modify(n => n + 1)(1); // 2