Skip to main content
Module

x/fun/fn.ts>apply

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

Given L => A => I and D => A create a new Fn D & L => I. In order to preserve type widening for ap, it only handles unary functions.

Examples

Example 1

import * as F from "./fn.ts";

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

const person = (name: string) => (age: number): Person => ({ name, age });

const result = F.pipe(
  F.wrap(person),
  F.apply(F.wrap("Brandon")),
  F.apply(F.wrap(37)),
); // Fn<[], Person>

Returns

<I>(ufai: Fn<D, (a: A) => I>) => Fn<D, I>