Skip to main content
Module

x/fun/pair.ts>getRightFlatmappable

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function getRightFlatmappable
import { getRightFlatmappable } from "https://deno.land/x/fun@v2.0.0/pair.ts";

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

Examples

Example 1

import { InitializableNumberSum } from "./number.ts";
import { getRightFlatmappable, pair } from "./pair.ts";
import { pipe } from "./fn.ts";

const Flatmappable = getRightFlatmappable(InitializableNumberSum);

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

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