import { fn } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { ap } = fn;
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
Example 1
import * as F from "./fn.ts";
import { ap, pipe } from "./fn.ts";
type Person = { name: string, age: number };
const person = (name: string) => (age: number): Person => ({ name, age });
const result = pipe(
F.of(person),
F.ap(F.of("Brandon")),
F.ap(F.of(37)),
); // Fn<[], Person>