Coding 2023-09-21

Tags:
By Max Woerner Chase

I tried to come up with a nice way to deal with some of the OCaml standard library code that I was having trouble translating to Impliciula, and I think I just made more problems for myself.

Here's the deal: various standard library types have a fold function defined which, in the cases I've looked at, takes named arguments that are named after the different constructors for the type, and those arguments are functions that convert the relevant variants to a return value. I was looking at this like "I do not want to figure out what kind of noun phrase would accommodate those parameters". "... But what if, all of those named arguments were packed into a record type?" At that point, the record type is *checks the giant pile of open web browser tabs* ... isomorphic to the evaluation function in an F-algebra? I think?

Now, the normal way to define an F-algebra is to put together an endofunctor that, I think, represents the partially applied computation. The equivalent with a record type for the evaluation function is to represent the partial evaluations as parameters of each function in the record. So each function in the record would be receiving a destructured variant and the intermediate calculation, and those can be cut down based on the variant...

I'm going to need to try sketching implementations both ways, because I can't figure out whether I prefer to be closer to how the OCaml functions sort of look, or to the theoretical description. Like, is it better for all implementors to put together a when-is-be block, or to construct it in one place per type using raw materials from everywhere? The former is more flexible, but the latter was clearly (at least to me) good enough for OCaml.

Yeah, this is definitely something that I need to take a good, clear look at, which is not happening right now. I should go to bed as soon as I can.

Good night.