Skip to main content
Module

x/fun/refinement.ts>literal

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

Creates an instance of Refinement<unknown, P> where P is a union of literal values.

Examples

Example 1

import * as R from "./refinement.ts";

const places = R.literal(1, 2, 3);

const result1 = places(null); // false
const result2 = places(1); // true, variable now typed as 1 | 2 | 3
const result3 = places(2); // true, variable now typed as 1 | 2 | 3
const result4 = places(10); // false

Parameters

...literals: A

Returns

Refinement<unknown, A[number]>