I am building a type system and have a variant type which can support all the other types. Here is a simple example where an int32, float, and str are allowed:
`variant_scalar`
"hello"
NULL
2
2.7
Additionally, a typed array of variant length is supported, such as:
`int32_arrar`
[1,2]
[1,2,3]
[1]
Now I have a question about the following two variant columns, one which contains only variant-array items and the other which contains types of both scalar and array nature:
`variant_array`
[1,2,"hello"]
["new", [1,2]]
NULL
-------------------------------------
`variant_anything`
1
"hello"
NULL
[1,2,"hello"]
What would be the proper way to handle this in a type system (for example, for a database)? Should there just be one Variant type which supports everything, or should there also be a VariantArray type that supports an array of anything...but it must be an array?
I suppose one reference which might be useful is the Type System used by the M Language: https://docs.microsoft.com/en-us/powerquery-m/m-spec-types.