Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is a monoid #8

Open
dullbananas opened this issue Apr 12, 2020 · 5 comments
Open

what is a monoid #8

dullbananas opened this issue Apr 12, 2020 · 5 comments

Comments

@dullbananas
Copy link

the documentation needs to explain what a monoid/semigroup is

@nikita-volkov
Copy link
Owner

Agreed. Care to PR?

@dullbananas
Copy link
Author

no. i dont understand the concept of monoids and semigroups

@nikita-volkov
Copy link
Owner

@dullbananas
Copy link
Author

is it basically something that has andThen?

@nikita-volkov
Copy link
Owner

That would be Monad :)

Monoid is a binary operation (function on two arguments) equipped with identity value (a neutral value in regards to the binary operation). Here's a few examples of practical monoids:

  • string concatenation for binary operation and empty string for identity value
  • numeric sum for binary operation and 0 for identity value
  • numeric product for binary operation and 1 for identity value
  • list concatenation and empty list
  • command batching and empty command.

This is an extremely universal abstraction and it allows you to apply the same patterns in composition of seemingly completely unrelated things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants