Skip to main content
Module

x/fun/decoder.ts>nullable

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

A decoder combinator that modifies an existing decoder to accept null as an input value and a successful return value.

Examples

Example 1

import * as D from "./decoder.ts";

const orNull = D.nullable(D.string);

const result1 = orNull(null); // Right(null)
const result2 = orNull(2); // Left(DecodeError)
const result3 = orNull("Hello"); // Right("Hello")

Returns

Decoder<D | null, A | null>