1c25fab6474c42a9dee6f2d79b4036821283b1b6
—
Sam A. Horvath-Hunt
3 years ago
9cdb27e

Fix type in monoid-semigroup

1 files changed,1insertions(+),1deletions(-) M published/20200830-monoid-semigroup.md

M published/20200830-monoid-semigroup.md => published/20200830-monoid-semigroup.md +1 -1

@@ 68,7 68,7 @@ const robroy: Cocktail = { name: 'Rob Roy', ingredients: ['scotch', 'bitters'] }const combined = semigroupCocktail.concat(mojito, robroy); ``` And just llike that we can combine our types together! Of course, we could just define a function for concatenating these two particular types together without the semigroup formalism, but that’d be both less obvious at a glance to developers familiar with this mathematical terminology, and less likely to be reusable in common abstractions; you’d have to rely upon duck typing and couldn’t rely upon adherence to any laws. Speaking of which, utilising the semigroup type class implies adhering to the law of [associativity](https://en.wikipedia.org/wiki/Associative_property), something common in mathematical and functional abstractions that allows the consumer to make useful assumptions. And just like that we can combine our types together! Of course, we could just define a function for concatenating these two particular types together without the semigroup formalism, but that’d be both less obvious at a glance to developers familiar with this mathematical terminology, and less likely to be reusable in common abstractions; you’d have to rely upon duck typing and couldn’t rely upon adherence to any laws. Speaking of which, utilising the semigroup type class implies adhering to the law of [associativity](https://en.wikipedia.org/wiki/Associative_property), something common in mathematical and functional abstractions that allows the consumer to make useful assumptions. _Fun fact_: If your (attempted) semigroup instance isn’t associative, then it is in actual fact a [magma](https://en.wikipedia.org/wiki/Magma_(algebra))! Although it does exist in the type class hierarchy, it’s exceptionally rare to define a magma that’s not associative thus not also a semigroup.