Skip to content

Instantly share code, notes, and snippets.

@evaporei
Created September 13, 2019 19:48
Show Gist options
  • Select an option

  • Save evaporei/a17ed6deabb781285caad35b0a5257ca to your computer and use it in GitHub Desktop.

Select an option

Save evaporei/a17ed6deabb781285caad35b0a5257ca to your computer and use it in GitHub Desktop.
Category Theory - Monoid Integer Sum
Number.prototype.mappend = function (x: Number): Number {
return this + x
}
Number.prototype.mempty = function (): Number {
return 0
}
console.log('mappend:', Number(5).mappend(4)) // 9
console.log('mempty:', Number().mempty()) // 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment