Coding 2021-11-19

By Max Woerner Chase

Well. Hm. I've started working on that stuff for MOTR, and I've hit a hurdle. I might be able to just figure it out by describing it.

So, I've got this Builder[T] class that can create instances of T, and I want to write helper functions that perform various simplifications to the interface. One of these is to have a way to create a Builder that produces Outputs, given a Builder[Input]. The one I'm trying to nail down right now is to create a Builder[T] in which T is not an Output, and it's not a Fragment or an Option that contains an Output.

Laying it out like that gives me an idea that I'm going to try.

Okay, let's see if this typechecks, but the basic idea is to create a validator using functools.singledispatch to put together a really quick recursive setup. This recurses over Fragments, Options, into CmdMeta, and bombs out on Outputs, and accepts all other inputs. This feels kind of hacky, but it looks like it should work. Anyway, the first decorator I wrote injects a call to the validator. Unfortunately, it can't do this any earlier than "when it's called to produce output", but this should at least prevent errors from going by unnoticed. Let's try using the decorator now...

Assuming this works (it just passed typechecking), my concern now is, my previous ideas about structuring imports are definitively super-obnoxious at this point, so I need to remember what, if anything, I was going to replace them with.

It's not great to switch focus in the middle of a big effort like this, but I just typed way too many full paths. When I have time (not now), I'm going to document any possible collisions, then address them, and cut some painfully long names out of this code.

Anyway, I shouldn't be up any longer.

Good night.