Skip to main content
Module

x/fun/refinement.ts>tuple

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

Create a Refinement from an array of refinements, where each index of a type much match the originated refinement type.

Examples

Example 1

import * as R from "./refinement.ts";

const tuple = R.tuple(R.number, R.string);

const result1 = tuple(null); // false
const result2 = tuple([]); // false
const result3 = tuple(["Hello", 1]); // false
const result4 = tuple([1, "Hello"]);
// true, variable has type [number, string]
const result5 = tuple([1, "Hello", "Goodbye"]); // false

Type Parameters

A extends any[]

Parameters

...items: [K in keyof A]: Refinement<unknown, A[K]>

Returns

Refinement<unknown, [K in keyof A]: A[K]>