Skip to main content
Module

x/fun/mod.ts>semigroup.constant

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 semigroup.constant
import { semigroup } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { constant } = semigroup;

Create a semigroup that always returns the given value, ignoring anything that it is concatenated with.

Examples

Example 1

import * as SG from "./semigroup.ts";
import { pipe } from "./fn.ts";

const { concat } = SG.constant("cake");

const whatDoWeWant = pipe(
  "apples",
  concat("oranges"),
  concat("bananas"),
  concat("pie"),
  concat("money"),
); // whatDoWeWant === "cake"