Skip to main content
Module

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

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"