Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active April 4, 2019 07:52
Show Gist options
  • Select an option

  • Save dewey92/f7593bcf123eca1457288e5750dceece to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/f7593bcf123eca1457288e5750dceece to your computer and use it in GitHub Desktop.
Boolean Monoid
// OR
const boolOr = createMonoid({
indentity: false,
semigroup: (a, b) => a || b,
});
log(boolOr.id) // => false
log(boolOr.append(true, boolOr.id)) // => true
log(boolOr.append(false, boolOr.id)) // => false
// AND
const boolAnd = createMonoid({
indentity: true,
semigroup: (a, b) => a && b,
});
log(boolAnd.id) // => true
log(boolAnd.append(true, boolAnd.id)) // => true
log(boolAnd.append(false, boolAnd.id)) // => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment