Skip to main content
Module

x/fun/decoder.ts>map

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

Map over the output of a Decoder.

Examples

Example 1

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

const stringLength = pipe(
  D.string,
  D.map(s => s.length),
);

const result1 = stringLength(null); // Left(DecodeError)
const result2 = stringLength(""); // Right(0)
const result3 = stringLength("Hello"); // Right(5)

Parameters

fai: (a: A) => I

Returns

<D = unknown>(ua: Decoder<D, A>) => Decoder<D, I>