Skip to main content
Module

x/fun/mod.ts>array.sequence

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

Sequence over an array of type V, inverting the relationship between V and ReadonlyArray. This function also keeps the indexed types of in each V at covariant position 0. In other words sequence over [Option, Option] becomes Option<[number, string]>.

Examples

Example 1

import * as A from "./array.ts";
import * as O from "./option.ts";

const sequence = A.sequence(O.ApplicableOption);

const result1 = sequence(O.some(1), O.some("Hello")); // Some([1, "Hello"])
const result2 = sequence(O.none, O.some("Uh Oh")); // None

Type Parameters

V extends Kind

Parameters

A: Applicable<V>

Returns

<VS extends AnySub<V>[]>(...ua: VS) => Sequence<V, VS>