When battle-testing with AbstractArray interface, it becomes clear that some interface contracts needs to be specified with duck typing e.g. setindex!(x, v, i::Int) where the type of v is not specified.
The interface check is based upon a subtype check. For example, if the interface specifies that a function accepts Any, then any implementation that only supports a subtype would not be compliant because it does not cover all other types that falls under Any. This is related to the contra-variances. So, when the interface calls for duck typing, it actually need to refer to the Base.Bottom data type, which is the bottom-most data type of the type hierarchy. Hence, any function definition taking any type will make it compliant with the contract.
For that reason, the Contract.args field must accept a type that includes any data type + Bottom. But Bottom <: DataType is not true. To keep it simple, I have relaxed the typing from NTuple{N,DataType} to just any Tuple.
When battle-testing with
AbstractArray
interface, it becomes clear that some interface contracts needs to be specified with duck typing e.g.setindex!(x, v, i::Int)
where the type ofv
is not specified.The interface check is based upon a subtype check. For example, if the interface specifies that a function accepts
Any
, then any implementation that only supports a subtype would not be compliant because it does not cover all other types that falls underAny
. This is related to the contra-variances. So, when the interface calls for duck typing, it actually need to refer to theBase.Bottom
data type, which is the bottom-most data type of the type hierarchy. Hence, any function definition taking any type will make it compliant with the contract.For that reason, the
Contract.args
field must accept a type that includes any data type + Bottom. ButBottom <: DataType
is not true. To keep it simple, I have relaxed the typing fromNTuple{N,DataType}
to just anyTuple
.