Upgrading Semigroup Data Types to Monoids

InstructorThomas Greco

Share this video with your friends

Send Tweet

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
~ 4 years ago

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

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!