Applying my TypeInterface to not-controlled-by-me types

I am defining a type interface for which there is a meaningful implementation for the tensor type, and I would like to provide that implementation. Do we have a way to do that?

If we don’t, I think it would be cool to add that. Rust’s trait system has a concept called “coherence” which manifests as the so-called “orphan rule”, which translated to this context would mean “to implement a type interface, either the type interface must be defined by you or the type must be defined by you”. This formulation has some nice properties regarding guaranteeing uniqueness of implementations.
More info: Coherence

I think that Rust also has some good designs here where you can say (again, translated to MLIR’s type interfaces) “if a type implements type interface Foo, then it also implements type interface Bar, and here is how to implement Bar in terms of Foo”. Their “trait” system is effectively our “interface” system.

@River707 @mehdi_amini

We have this for dialect interfaces. I wonder if a combination of the interface fallback @mehdi_amini implemented and a dialect interface attached to the dialect you don’t define would work here.

Anyway, this sounds like a useful feature to have for composability.