links
links copied to clipboard
"flat" and "nested" kinds for query results
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:
Flatwhich consists of base types or records of flat types. Thus if record flattening is implemented according to #1127 theFlatrestriction characterizes the allowed return types for theflatandmixed/delatpolicies.Nestedwhich consists of base types, records of nested types, or collections (lists) of nested types. This would characterize the allowed return types ofnestedqueries.
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.