Skip to main content
Module

x/fun/eq.ts>readonly

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

Create a Eq that casts the inner type of another Eq to Readonly.

Examples

Example 1

import { readonly, fromEquals } from "./eq.ts";

// This has type Eq<Array<string>>
const EqMutableArray = fromEquals<Array<string>>(
  (first, second) => first.length === second.length
  && first.every((value, index) => value === second[index])
);

// This has type Eq<Readonly<Array<string>>>
const EqReadonlyArray = readonly(EqMutableArray);

Returns

Eq<Readonly<A>>