I'm trying to learn the concept of monad
, I'm watching this excellent video Brian Beckend trying to explain what is monad.
When he talks about monoid
, it's a collection of types, it has a rule of composition, and this composition has to obey 2 rules:
- associative:
x @ (y @ z ) = (x @ y) @ z
- a special member in the collection:
x @ id = x and id @ x = x
I'm using @
symbol representing composition. id
means the special member.
The second point is what I'm trying to understand. why does this matter ? what if there's no such special member ?
When I learn new concept, I always try to relate these abstract concept to some other concrete things, so that I can fully understand and learn them by heart.
So what I'm trying to relate monad
and monoid
to is lego
. So all the building blocks in a lego set forms a collection. and the composition rule is composite them into new shape of building blocks. and it's obvious the composition obey the first rule: associative. But there's no special building block which can composite with other building block and get the same back. So it fails to obey the second rule.
But lego is still highly composable. What has been missing or lack when lego fails to obey the second rule ? What is the consequence ?
Or put it this way, comparing to other monoid
which obey all those rules. What feature does other monoid
has but lego doesn't ?
The empty Lego could be considered as
id
but then you will have to accept that empty space is Lego. But yes if you don't want id like @sclv wrote, it would be asemigroup
.