Skip to main content
Module

x/fun/mod.ts>combinable.tuple

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

Get a Combinable from a tuple of combinables. The resulting combinable will operate over tuples applying the input combinables applying each based on its position,

Examples

Example 1

import * as SG from "./combinable.ts";
import { pipe } from "./fn.ts";

type Person = { name: string, age: number };

const first = SG.first<Person>();
const last = SG.last<Person>();
const { combine } = SG.tuple(first, last);

const octavia: Person = { name: "Octavia", age: 42 };
const kimbra: Person = { name: "Kimbra", age: 32 };
const brandon: Person = { name: "Brandon", age: 37 };

const tuplePeople = pipe(
  [octavia, octavia],
  combine([kimbra, kimbra]),
  combine([brandon, brandon]),
); // tuplePeople === [octavia, brandon]

Parameters

...combinables: T

Returns

Combinable<readonly [K in keyof T]: TypeOf<T[K]>>