Skip to main content
Module

x/fun/fn_either.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_either.ts";

Given a FnEither returning a function A => I and a FnEither returning a value A, combine them into a FnEither returning an I.

Examples

Example 1

import * as FE from "./fn_either.ts";
import { pipe } from "./fn.ts";

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

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

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

Returns

<L, I, J>(ufai: FnEither<L, J, (a: A) => I>) => FnEither<D & L, B | J, I>