News for hackers. Stuff that matters.
Re:Nixpkgs Overlays Are Monoids by whateveracct on Wednesday January 26, 2022 @04:51PM (#30092455)
Monoid is just a binary associative "mappend" function + an identity "mempty" to that function such that "mappend whatever mempty = whatever"

It's a very common structure across programming domains.

The identity overlay is "self: super: {}"

Overlay combination is associative. If you have N overlays, it doesn't matter the order to apply them left-to-right.

In fact, I believe overlays are also commutative. Which makes sense - it would be silly if you wrote an overlay in isolation and how it worked depended on where it landed in your overlays list.

Re:Nixpkgs Overlays Are Monoids by Gabriel439 on Wednesday January 26, 2022 @05:22PM (#30092923)
The order in which you combine overlays can sometimes matter. In other words, overlays are monoids, but not commutative monoids. That said, most of the time overlay order does not matter
Re:Nixpkgs Overlays Are Monoids by whateveracct on Wednesday January 26, 2022 @07:47PM (#30094457)
Ah that's true thinking about it. If I have two overlays that both set some value to X..one's gotta win!
Re:Nixpkgs Overlays Are Monoids by cmm on Wednesday January 26, 2022 @05:27PM (#30092998)
> In fact, I believe overlays are also commutative.

No. But "nice" overlays probably should have this property, since commutativity means orthogonality.