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:
Flat which consists of base types or records of flat types. Thus if record flattening is implemented according to #1127 the Flat restriction characterizes the allowed return types for the flat and mixed/delat policies.
Nested which consists of base types, records of nested types, or collections (lists) of nested types. This would characterize the allowed return types of nested queries.
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.
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:
Flat
which consists of base types or records of flat types. Thus if record flattening is implemented according to #1127 theFlat
restriction characterizes the allowed return types for theflat
andmixed
/delat
policies.Nested
which consists of base types, records of nested types, or collections (lists) of nested types. This would characterize the allowed return types ofnested
queries.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 withMono
andBase
).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.