Skip to main content
Module

x/fun/monoid.ts>dual

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 dual
import { dual } from "https://deno.land/x/fun@v.2.0.0-alpha.11/monoid.ts";

Create a dual Monoid from an existing monoid. This effectively switches the order of application of the original Monoid.

Examples

Example 1

import { dual, concatAll, intercalcate } from "./monoid.ts";
import { MonoidString } from "./string.ts";
import { pipe } from "./fn.ts";

const reverse = dual(MonoidString);
const reverseAll = pipe(
  reverse,
  intercalcate(" "),
  concatAll,
);

const result = reverseAll(["Hello", "World"]); // "World Hello"