DEV Community

Dmitrii Kovanikov
Dmitrii Kovanikov

Posted on • Edited on

Pragmatic Category Theory | Part 2: Composing Semigroups

This article was permanently moved to my personal website:

Top comments (4)

Collapse
 
bathtub profile image
gank york •

Great job!

Just wondering if there are any common utils for Semigroups?

e.g. For Comparable typeclass/trait, I would expect a sort function. Do we have anything like this for Semigroups?

Collapse
 
chshersh profile image
Dmitrii Kovanikov •

Great question!

I feel like these sorts of abstractions are not that common in the OCaml world. For example, the sort function for a list just takes a comparator explicitly instead of working with an abstract module:

val sort : ('a -> 'a -> int) -> 'a list -> 'a list
Enter fullscreen mode Exit fullscreen mode

With abstractions like Semigroups they're even less common in the OCaml standard library. I don't think they're popular outside as well (I rarely see them being used). But I'm trying to change this with my series and explain the value of these abstraction 😌

Collapse
 
nunocf profile image
Nuno Ferreira •

This is an absolute gem!
I've been working with functional programming for years (Haskell and Elm, and Elixir before) but always struggled with explaining the concept of a semigroup with real, useful examples. I particularly liked your line of explaining that ideas > implementation!
This is incredibly well done and I've already shared this series with a bunch of people.
Really looking forward to read more of these articles :)

Collapse
 
chshersh profile image
Dmitrii Kovanikov •

Thanks a lot for your comment! I'm really glad you enjoyed the post!