I'm a little confused by Postgres arrays. From the documentation:
However, the current implementation ignores any supplied array size limits, i.e., the behavior is the same as for arrays of unspecified length.
The current implementation does not enforce the declared number of dimensions either. Arrays of a particular element type are all considered to be of the same type, regardless of size or number of dimensions. So, declaring the array size or number of dimensions in CREATE TABLE is simply documentation; it does not affect run-time behavior.
But also,
Multidimensional arrays must have matching extents for each dimension. A mismatch causes an error.
What I've been thinking is that Squeal should not support nested arrays, but rather, single-dimensional variable length arrays and multidimensional static length arrays, over nullity types, something like
data PGType
= ..
| PGvararray NullityType
| PGfixarray [Nat] NullityType
Then the actual type expressions should restrict users from expressing nested arrays (i.e. no vararray (vararray int)s) or 0-dimensional arrays (i.e. no fixarray @'[] ints). Does this make sense? Is there a better way to do arrays?
I'm a little confused by Postgres arrays. From the documentation:
But also,
What I've been thinking is that Squeal should not support nested arrays, but rather, single-dimensional variable length arrays and multidimensional static length arrays, over nullity types, something like
Then the actual type expressions should restrict users from expressing nested arrays (i.e. no
vararray (vararray int)s) or 0-dimensional arrays (i.e. nofixarray @'[] ints). Does this make sense? Is there a better way to do arrays?