Skip to content

Instantly share code, notes, and snippets.

@UserGalileo
Last active April 14, 2020 18:24
Show Gist options
  • Save UserGalileo/5c9fe2a8e84d017aa6cf56cddd03233a to your computer and use it in GitHub Desktop.
Save UserGalileo/5c9fe2a8e84d017aa6cf56cddd03233a to your computer and use it in GitHub Desktop.
Monad Identity Monoid
// Here's our unit function
const id = x => Identity(x);
// Left & Right Identity...
const identity1 = op(f, id);
const identity2 = op(id, f);
// ...are the same!
inspect(identity1('i')); // Identity(i1)
inspect(identity2('i')); // Identity(i1)
/**
* We can say that:
*
* op(f,id) EQUALS op(id, f)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment