Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fun/comparable.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.12/comparable.ts";

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>>