Skip to main content
Module

x/fun/mod.ts>comparable.readonly

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

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

Examples

Example 1

import { readonly, fromCompare } from "./comparable.ts";

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

// This has type Comparable<Readonly<Array<string>>>
const ComparableReadonlyArray = readonly(ComparableMutableArray);

Parameters

comparable: Comparable<A>

Returns

Comparable<Readonly<A>>