Skip to main content
Module

x/fun/decoder.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@v2.0.0-alpha.10/decoder.ts";

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

Examples

Example 1

import * as D from "./decoder.ts";
import { pipe } from "./fn.ts";

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

const result = pipe(
  D.of(person),
  D.ap(D.of("Brandon")),
  D.ap(D.of(37)),
); // Decoder<unknown, Person>

Type Parameters

A
optional
D = unknown

Returns

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