Skip to main content
Module

x/eitherway/mod.ts>Empty

Yet Another Option and Result Implementation - providing safe abstractions for fallible flows inspired by F# and Rust
Latest
type alias Empty
import { type Empty } from "https://deno.land/x/eitherway@0.10.0/mod.ts";

An artificial bottom type en lieu of unknown and nullish types

This is used as a combatibility safe-guard for conversions between Result<T, E> and Option<T>, where a value of type Ok<void> would evaluate to None when converted with .ok().

Examples

Example 1

import { assert } from "./assert.ts";
import { Empty, Ok, Option, Result, Some } from "./mod.ts";

const voidResult: Result<void, never> = Ok(undefined);
const emptyResult: Result<Empty, never> = Ok.empty();

assert(voidResult.ok().isNone() === true);
assert(emptyResult.ok().isNone() === false);
definition: Readonly<{ }>