Module

x/functional/mod.ts>alt

Common Functional Programming Algebraic data types for JavaScript that is compatible with most modern browsers and Deno.
Latest
variable alt
import { alt } from "https://deno.land/x/functional@v1.3.4/mod.ts";

alt

Alt a -> Alt b -> Alt a|b

This function takes a container of any type and, an Alternative functor. Then it returns either the container or the alternative functor. The function is in support of the Alt algebra.

import Either from "https://deno.land/x/functional@v1.3.2/library/Either.js";
import { alt } from "https://deno.land/x/functional@v1.3.2/library/utilities.js";

const container = alt(Either.Right(42), Either.Left("Not the meaning of life"));

assertEquals(container.extract(), 42);