I agree with the general philosophy of RequiredInterfaces.jl that interfaces ought to be represented by abstract types, and more specific interfaces (with additional methods) are represented by subtypes. But, echoing @gdalle, it seems hard to put it into practice if we don’t have multiple inheritance.
Also, there are also some difficulties in 100% following that philosophy, even if we had multiple inheritance. Consider this function:
foo(x::Any) = convert(Int, x)
To 100% adhere to the RequiredInterfaces.jl philosophy, we would need to replace the argument annotation for x
with an abstract type ConvertibleToInt
. And we would also need ConvertibleToString
, ConvertibleToFloat64
, etc for other functions like foo
. Though I suppose it could be parametric, e.g. ConvertibleTo{Int}
.
Maybe I’m overinterpreting the philosophy in About Interfaces and you’re ok with not requiring argument annotations to be 100% correct all the time (in the ideal world where we have multiple inheritance).
(Do Haskell and Rust have type classes or traits for convertibility?)