DEV Community

Dmitrii Kovanikov
Dmitrii Kovanikov

Posted on • Edited on

25

Pragmatic Category Theory | Part 2: Composing Semigroups

This article was permanently moved to my personal website:

Top comments (4)

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!

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 😌

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay