Skip to main content
Module

x/fun/mod.ts>fn_either.apply

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

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>