Skip to main content
Module

x/fun/fn.ts>premap

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

Map over the input of a function, turning D => A and L => D into L => A.

Examples

Example 1

import { premap, pipe } from "./fn.ts";

const equalsZero = (n: number): boolean => n === 0;
const strLength = (s: string): number => s.length;

const isEmpty = pipe(
  equalsZero,
  premap(strLength),
);

const result1 = isEmpty(""); // true
const result2 = isEmpty("Hello"); // false

Parameters

fld: (l: L) => D

Returns

<A>(ta: Fn<D, A>) => Fn<L, A>