Skip to main content
Module

x/fun/decoder.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/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.wrap(person),
  D.apply(D.wrap("Brandon")),
  D.apply(D.wrap(37)),
); // Decoder<unknown, Person>

Type Parameters

A
optional
D = unknown

Returns

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