Upgrading Semigroup Data Types to Monoids

Thomas Greco
InstructorThomas Greco
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 4 years ago

In this lesson, we'll begin working with monoids by creating some of our own. Specifically, we will upgrade a previously defined semigroup (Product) so that it takes the form of a valid monoid. To ensure that we have a valid monoid, we will wrap up this video by testing Product so that it holds the laws of Right identity and Left` identity.

Fantasy Land Docs - Monoid

Tre' Codez
Tre' Codez
~ 4 years ago

Hey great series! I am curious as to why you chose empty for id

Thomas Greco
Thomas Grecoinstructor
~ 4 years ago

appreciated again tre... and once again, apologies for delay :)

good question though as empty is indeed the identity. the thing is, we want to leverage the identity of our different types whenever we encounter an "empty" value, hence why it's given that name.

you can see it in action with monoids here - https://egghead.io/lessons/javascript-how-to-create-a-monoidal-fold-function.

hopefully, my brief explanation made sense! feel free to reach out to me on twitter though if you have any questions you want to bounce off me or have any topics to discuss. always looking to help and more importantly grow my own abilities :)

thanks again for the support!

Markdown supported.
Become a member to join the discussionEnroll Today