Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save dewey92/020323ca2b30835387d4c293db1633cf to your computer and use it in GitHub Desktop.
Endomorphism Monoid
const endoFunc = createMonoid({
indentity: x => x,
semigroup: compose,
});
const incr = x => x + 1;
const square = x => x * x;
log(endoFunc.id) // x => x
log(endoFunc.append(square, incr)(9)) // => 100
log(endoFunc.append(incr, square)(9)) // => 82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment