import { intercalcate } from "https://deno.land/x/fun@v.2.0.0-alpha.11/monoid.ts";
Create a monoid that works like Array.join, inserting middle between every two values that are concatenated. This can have some interesting results.
Examples
Example 1
Example 1
import * as M from "./monoid.ts";
import * as S from "./string.ts";
import { pipe } from "./fn.ts";
const { concat: toList } = pipe(
S.MonoidString,
M.intercalcate(", "),
);
const list = pipe(
"apples",
toList("oranges"),
toList("and bananas"),
); // list === "apples, oranges, and bananas"
Parameters
middle: A