External Publication
Visit Post

Sneak Peek: Bolt Math

Haskell Community [Unofficial] March 16, 2026
Source

Adjoints, anyone? Last time I was building something using units, I needed the arithmetic equivalent to symmetric set difference. Take the monoid operation • to be addition in a lattice of non-negative quantities (e.g. energy). This makes this Semiringresiduated.

Try to take amount y from amount x where both are non-negative. Conceptually, x-y is the unique number such that y+(x-y) = x, or, in the language of residuals, subtraction is right adjoint to addition in the lattice of numbers. If all quantities are non-negative (e.g. energy), the proper difference y-x must remain a pair and uniqueness is lost. We can, however, choose a canonical representative:

  • If y > x, then the result is the pair (0, y-x) signifying that there was more to take away than what was there.
  • If x > y then the result is the pair (x-y, 0) signifying what is left over after taking away some.

I have the impression that primary school kids use a related concept when doing arithmetic involving numbers larger than 10. The fundamental operation being to split a quantity (number) using a smaller one.

Discussion in the ATmosphere

Loading comments...