Skip to main content
Module

x/fun/mod.ts>refinement.nullable

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

Turn a Refinement<A, B> into Refinement<null | A, null | B>.

Examples

Example 1

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

const nullOrNum = R.nullable(R.number);

const result1 = nullOrNum(null); // true, variable is now null | number
const result2 = nullOrNum(1); // true, variable is now null | number
const result3 = nullOrNum("hello"); // false

Type Parameters

A
B extends A

Returns

Refinement<A | null, B | null>