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
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"