Skip to main content
Module

x/fun/mod.ts>pair.extend

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function pair.extend
import { pair } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { extend } = pair;

Creates a new pair by constructing a first value from the whole pair and keeping the second value from the original pair. Can be used somewhat like a superpowered Reader.

Examples

Example 1

import { extend, pair } from "./pair.ts";
import { pipe } from "./fn.ts";

const result = pipe(
  pair("Brandon", 37),
  extend(([name, age]) => `${name} is ${age}`)
); // ["Brandon is 37", 37];

Parameters

ftai: (ua: Pair<A, B>) => I

Returns

(ua: Pair<A, B>) => Pair<I, B>