Skip to main content
Module

x/fun/ord.ts>contramap

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 contramap
import { contramap } from "https://deno.land/x/fun@v2.0.0-alpha.10/ord.ts";

Derives an instance of Ord by take an existing Ord over D and a function that turns an L into D and returns an Ord over L.

Examples

Example 1

import { contramap } from "./ord.ts";
import { OrdNumber } from "./number.ts";
import { pipe } from "./fn.ts";

// Use number ordering, turn date into number and contramap
const date = pipe(
  OrdNumber,
  contramap((d: Date) => d.valueOf()),
);

Parameters

fld: (l: L) => D

Returns

(ord: Ord<D>) => Ord<L>