By my reckoning, your substantive new suggestions are
- pullbacks and pushouts
- (limited) W-types
- stating things in compositional rather than applicative form
Pullbacks are just subsets of products. Their elements would be pairs w/ an equation. In other words, they are special cases of a subset type; a subset of an existing type with a predicate that each element must satisfy. In other words, it’s what we already have w/ products plus a semantic side-condition that the type checker knows about. Do we want this? It’s not relevant to the serializer, but it could be used by a type checker.
Pushouts are a separate story. Their point is to have syntactically distinct things which are considered equivalent by fiat. Syntactically, it’s elements are the same as that of coproduct, but some inl(x)
s are considered the same as some inr(y)
s. What is the serializer supposed to do with that? I think the answer is “nothing”, and it’s just the type checker that sees them as the same. This disconnect begs the question of what the exact relation between the serializer and the type checker is supposed to be. That’s a question for @cwgoes , I suppose. Then again, I could be totally wrong. If you have something else in mind for how pushouts are supposed to work, it would help get a better understanding of your suggestion. Same goes with all my interpretations.
I think there’s two discussions going on here. The GOAL goal is to define a canonical set of serializable types supported by VMs and, separately, there’s a goal of defining a type theory for reasoning about interfacing between these VMs that’s some happy medium between minimal and practical. It does not seem like arbitrary nestings of function types should be serializable, but the meta-type checker should be able to reason about them. It’s not clear from your suggestion what, exactly, the serializable data is supposed to be. I think you started with FinSet since everything in it (and emerging from it with the W-type construction) will have serializable elements. At the same time, what is the serializer supposed to do with predicate/quotient information? The type checker can use that, but does it need to be limited to what you described? I don’t think so, but I’m also shaky on what the complete goal is with that.
As for W-types, that’s worth considering. It may cut the knot on the question of if lists etc. should be a fundamental supported type. It’s really not obvious to me that your specific restriction is the correct one. In general, so long as, for any serializable X, F(X) is also serializable, then the initial algebra of F will be serializable since all elements will just be finite many F layers. Equivalently, if F(ℕ) ≃ ℕ then Fix F ≃ ℕ (where the later isomorphism can usually be defined as the ana+cata over the (co)algebras in the F(ℕ) ≃ ℕ isomorphism). Interface wise, I think we can assume F-catamorphisms (folds) AND F-anamorphisms (unfolds) since I don’t believe there’s a termination requirement. (As an aside, if termination isn’t required, should the type theory have a bottom element? Should it have intersection or union types? Do we want our type theory to be more extensional rather than intentional?) I think this would be larger than your restricted W-types. As an example, the initial algebra of List will have serializable elements. Correct me if I’m wrong, but I don’t think that type can be defined under your restriction.
As for things being in compositional rather than applicative form, this would mean all our data are morphisms and, for example, the stuff being serialized will be (some of?) the morphisms out of the terminal object. That’s going to look very alien to most people, and I’d suggest working out an example. For example, what would constructing a finite field look like? What would a user actually type to get that done? And would this be better than the applicative style (e.g. something like Agda records)? To me, that seems more like a UI question. As someone whose not too enamored with point-free programming, I’m not going to advocate it over an applicative style, but it’s something worth considering. But you’ll have to put a clearer image in people’s heads for a proper determination to be made.