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

x/fun/mod.ts>combinable.first

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

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

Examples

Example 1

import { first, getCombineAll } from "./combinable.ts";
import { pipe } from "./fn.ts";

type Person = { name: string, age: number };
const FirstPerson = first<Person>();
const getFirstPerson = getCombineAll(FirstPerson);

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

const result = getFirstPerson(octavia, kimbra, brandon); // octavia