Skip to main content
Module

x/fun/pair.ts>getRightMonad

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

Creates a Monad instance for Pair where the second parameter is concatenated according to the Monoid instance passed in.

Examples

Example 1

import { MonoidNumberSum } from "./number.ts";
import { getRightMonad, pair } from "./pair.ts";
import { pipe } from "./fn.ts";

const Monad = getRightMonad(MonoidNumberSum);

const ageOneYear = (name: string) => pair(name, 1);

const result = pipe(
  pair("Brandon", 36), // Pair(Name, Age)
  Monad.chain(ageOneYear),
  Monad.chain(ageOneYear)
); // ["Brandon", 38]