import { semigroup } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { tuple } = semigroup;
Get a Semigroup from a tuple of semigroups. The resulting semigroup will operate over tuples applying the input semigroups applying each based on its position,
Examples
Example 1
Example 1
import * as SG from "./semigroup.ts";
import { pipe } from "./fn.ts";
type Person = { name: string, age: number };
const first = SG.first<Person>();
const last = SG.last<Person>();
const { concat } = 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],
concat([kimbra, kimbra]),
concat([brandon, brandon]),
); // tuplePeople === [octavia, brandon]
Type Parameters
T extends AnySemigroup[]
Parameters
...semigroups: T