Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>combinable.dual

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

Get the "Dual" of an existing Combinable. This effectively reverses the order of the input combinable's application. For example, the dual of the "first" combinable is the "last" combinable. The dual of (boolean, ||) is itself.

Examples

Example 1

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

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

const last = SG.last<Person>();
const dual = SG.dual(last);

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

const dualPerson = pipe(
  octavia,
  dual.combine(kimbra),
  dual.combine(brandon),
); // dualPerson === octavia