Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fun/option.ts>getSemigroup

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

Create an instance of Semigroup<Option> given an instance of Semigroup.

Examples

Example 1

import * as O from "./option.ts";
import * as N from "./number.ts";
import { pipe } from "./fn.ts";

const { concat } = O.getSemigroup(N.SemigroupNumberSum);

const result1 = pipe(O.some(1), concat(O.some(1))); // Some(2)
const result2 = pipe(O.none, concat(O.some(1))); // Some(1)
const result3 = pipe(O.some(1), concat(O.none)); // Some(1)