Abstract Algebras and Where to Find Them Magmas, Monoids, and More!
summary
Defines magmas, semigroups, monoids and join-semilattices with concrete TypeScript implementations (no higher‑kinded types), shows foldMap abstraction and a fold that uses associativity for parallel reduction, cites 915 million combinations from a combinatorics example, recommends property‑based tests to verify algebraic laws, explains how commutative+idempotent structures underpin CRDT/eventual consistency, and describes a deployed ordering‑composition system used in production for a food‑service customer so the approach actually works.
AI-written summary · about
chapters (9)
- 0:00Start
- 0:12Abstract Algebras and Where to Find Them: Magmas, Monoids, & More!
- 3:57We want to be able to define ways of composing small, working pieces into larger, working pieces
- 6:26If a concept can only be approximated in your language, you'll likely only have an approximate understanding of it
- 12:31Closure keeps our code simple
- 22:44What if I have a non primitive type?
- 25:50foldMap allows us to use primitive monoids on complex types!
- 40:32Start with a domain and determine which properties the domain upholds. Code accordingly.
- 41:06There are many more properties and structures than we covered here. Explore them!








