Skip to main content
Module

x/fun/set.ts>ap

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 ap
import { ap } from "https://deno.land/x/fun@v.2.0.0-alpha.11/set.ts";

Given a ReadonlySet of functions A -> I and a ReadonlySet return a ReadonlySet by applying every function to every value A.

Examples

Example 1

import * as S from "./set.ts";
import { pipe } from "./fn.ts";

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

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

const result = pipe(
  S.of(person),
  S.ap(S.of("Brandon")),
  S.ap(S.of(37)),
); // ReadonlySet<Person>

Parameters

ua: ReadonlySet<A>

Returns

<I>(ufai: ReadonlySet<(a: A) => I>) => ReadonlySet<I>