Skip to main content
Module

x/fun/mod.ts>fn.compose

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

Compose two functions by taking the output of one and passing it to another. This is equivalent to the map function.

Examples

Example 1

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

const length = (s: string) => s.length;
const dup = (n: number) => n + n;

const composed = pipe(
  length,
  compose(dup),
);

const result1 = composed("Hello"); // 10
const result2 = composed(""); // 0

Parameters

second: Fn<A, I>

Returns

<D>(first: Fn<D, A>) => Fn<D, I>