r/ProgrammingLanguages • u/reflexive-polytope • Aug 10 '26
Design draft for a truly Affine OL
https://gist.github.com/eduardoleon/fba87a8b0b2ef04cd17f1ebf94c74b28Hello, everyone.
While recovering from an illness, in my state of delirium, I sketched the design of a type system inspired by Xi and Pfenning's Dependent ML, but which uses a key syntactic restriction that conjecturally restores ordinary ML's key metatheoretic properties: the existence of principal types and the decidability of type inference.
I very much welcome feedback that actually engages with the post's contents.
22
Upvotes
5
u/ianzen Aug 10 '26
You said that you want to enroll in a PhD program to research this right? Are you based in the US?
4
u/redchomper Sophie Language Aug 11 '26
OK, I read the gist and came to the conclusion that you should really look at APL. Oh, and Futhark.
There's a lot of interest in trying to define a type system that is more than HM but less than the fullness of dependent types with terms-as-types. Array bounds are a popular drum to beat, but it does seem like you could solve it by removing indices from the language (almost) altogether.
In the end, the interesting type systems are going to be the ones that seem impractical in theory but turn out to be quite practical in practice.
You spend a good bit of time worrying about the lack of principle types. I'm currently convinced that principle types are overrated. If you have a reasonably rich and inferential type system, then on the rare occasion that the compiler can't figure out what you mean simply enough, the programmer probably won't either or will at least appreciate an express hint. It might be possible to arrange for branching types to just try each branch until things get too hairy and then ask the programmer for a hint. I'll grant that this overall approach may not be ideologically pure, but it gets the job done.
Complicated types demand complicated terms to yield them up.
What, pray tell, is the type of a well-formed compressed LR-style parse table?
At some point, you have to be able to say "trust me, bro" or else accept that some interesting and useful programs will not be well-typed.
3
u/Athas Futhark Aug 11 '26
I think we discussed this on IRC (come join us on #proglangdesign on Libera, everyone! IRC is free of the enshittification that plagues all the other chat platforms!) Here are some more thoughts.
I still don't quite get how you intend to avoid problems with integer equalities. I know you say you don't want them, but many programs naturally require them. Even your
type graph[n] = adjac[n] vector[n]seems like it will require checking an equality at construction time. You then have the usual troubles with checking equalities of integer expressions.You mention this goal:
I suggest you study these projects, which don't do things the way you suggest, but also are about using type information to derive flat representations: Gibbon, Position-Dependent Arrays and Their Application for High Performance Code Generation.
How does
type dag[n] = adjac[k] vector[k < n]work? The namekseems unbound.I would also recommend you write down some functions in Affine OL and show what type constraints they produce. The overall shape of the type system is still somewhat murky to me.
Your proposed
fordefinition blocks are very similar to Dex'sforexpressions (which are also type-directed). Dex uses an effect system to handle reductions and multiple initialisations, however.