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

x/fun/mod.ts>combinable.last

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

Get an Combinable over A that always returns the last parameter supplied to combine (confusingly this is actually the first parameter since combine is in curried form).

Examples

Example 1

import { last } from "./combinable.ts";
import { pipe } from "./fn.ts";

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

const CombinablePerson = last<Person>();

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

const lastPerson = pipe(
  octavia,
  CombinablePerson.combine(kimbra),
  CombinablePerson.combine(brandon),
); // lastPerson === brandon