Coding 2023-06-21

Tags:
By Max Woerner Chase

Okay, I'm kind of out of it right now, but I'd like to work through my ideas for other stuff to try with OCaml. One concept that ML-style modules seem well-suited to representing is that of an algebraic structure, which is something that Missable Mysteries would have/will end up covering.

:)

Kind of want to change the name...

I've tied myself in knots trying to fit an algebraic structure (admittedly a somewhat complicated one) into typed Python. I think doing it in Rust would require a bunch of newtypes in the general case, because Rust traits are all about "the implementation" of a concept, and some of the really interesting stuff happens when you're explicitly manipulating multiple groups derived from the same set.

Whereas in OCaml, a specific algebraic structure would be a module, a kind of algebraic structure would be a module signature, and a mapping between algebraic structures, such as "forgetting" parts of a structure, would be a functor.

This is slightly short of what I want, because I'm not sure if there's a good statically-analyzable way to handle the axioms of an algebraic structure. So, what I want to see if I can do is to express axioms in a form that a property-based testing library can handle. I searched around a bit, and found qcheck.

I think there are two basic concepts that need to be defined together to write the kind of tests I have in mind:

I guess all of this is going to take a bunch more modules and functors. Like, given an algebraic structure with some signature, that needs to combine with a generator, which... stuff happens, and eventually a module pops out with a list of tests.

Properties to test include:

I'm pretty tired, so I'm going to wrap this up now, and then sketch out exactly how I think this stuff should fit together.

Good night.