links-lang / links

Links: Linking Theory to Practice for the Web
http://www.links-lang.org
Other
332 stars 42 forks source link

"flat" and "nested" kinds for query results #1140

Open jamescheney opened 2 years ago

jamescheney commented 2 years ago

This is a proposal to address #761 (which calls for typechecking nested query results to ensure that they are sensible nested types) and (the typechecking part of) #1127 (which calls for providing record flattening for all kinds of queries).

The proposal is to add two kind restrictions:

We would also have subkinding relationships Base <: Flat <: Nested <: Mono. I believe checking the above restrictions would be straightforward: whenever we unify a flexible type variable with one of the above restrictions applied to it with something else, we check whether the newly unified structure makes use of any disallowed type constructors and constrain any type variables encountered along the way by min-ing with the subkind (similar to what already happens with Mono and Base).

I'd still rather have this happen as an instance of a general-purpose programmable mechanism like type classes, but that doesn't seem likely to happen in the near future.