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

x/fun/newtype.ts>iso

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

If the Newtype and its underlying value are referentially transparent (meaning they can always be swapped) then you can create an instance of Iso for the Newtype for mapping back and forth.

Examples

Example 1

import * as N from "./newtype.ts";

type Real = N.Newtype<"Real", number>;

const isoReal = N.iso<Real>();

const result1: Real = isoReal.view(1); // Turn number into Real
const result2: number = isoReal.review(result1); // Turn Real into number