Skip to main content
Module

x/fun/fn_either.ts>dimap

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

Map over the input of a FnEither contravariantly and the right result of a FnEither covariantly.

Examples

Example 1

import * as FE from "./fn_either.ts";
import { pipe } from "./fn.ts";

// This has type FnEither<[Date], never, string>
const computation = pipe(
  FE.id<number>(),
  FE.dimap(
    (d: Date) => d.valueOf(),
    String,
  ),
);

const result = computation(new Date(0)); // Right('0')

Parameters

fld: (l: L) => D
fai: (a: A) => I

Returns

<B>(ua: FnEither<D, B, A>) => FnEither<L, B, I>