3 ms·
> “Implementing” (with big scare quotes) algebraic structures by essentially implementing what appear to be “interfaces” (or traits or type classes or ...) migh
by rklaehn 7y ago
> “Implementing” (with big scare quotes) algebraic structures by essentially implementing what appear to be “interfaces” (or traits or type classes or ...) might give you a brief “aha!” about what an abstract algebraic structure is on the surface, but won’t give much insight or practical use beyond that.
I find something relatively simple like a monoid already tremendously useful for practical software engineering tasks like some aggregation.
> Critically, one of the many hugely lacking aspects in this approach to implementing these structures in a language like Rust (or Haskell or ...) is that one needs to prove that these interfaces satisfy the axiomatic laws of the structure.
Typically these libraries (alga for rust, spire for scala) come with laws that allow at least checking if the properties hold using property based testing. I find this very useful. See for example https://github.com/typelevel/spire/tree/master/laws/src/main/scala/spire/laws https://github.com/typelevel/spire/tree/master/laws/src/main...