Skip to main content
Module

x/fun/option.ts>none

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
variable none
import { none } from "https://deno.land/x/fun@v2.0.0-alpha.10/option.ts";

The cannonical implementation of the None type. Since all None values are equivalent there is no reason to construct more than one object instance.

Examples

Example 1

import type { Option } from "./option.ts";
import * as O from "./option.ts";

function fromNilable<A>(a: A | null | undefined): Option<A> {
  return a === null || a === undefined ? O.none : O.some(a);
}

const result1 = fromNilable(null); // None
const result2 = fromNilable(1); // Some<number>

type

Option<never>