On Friday, 7 September 2018 at 23:37:05 UTC, Josphe Brigmo wrote:
On Friday, 7 September 2018 at 18:18:50 UTC, Neia Neutuladh
Algebraic!SomeInterface should allow anything that inherits
from that interface (possibly with an explicit cast).
It doesn't.
I *did* say "possibly with an explicit cast", and adding an
explicit cast does work.
One of the problems with the above is that it doesn't allow
different 'Wrapped' to equate to the same type:
Wrapper!(I, A) != Wrapper!(I, B)
Although, by construction, they implement I
That's the whole point. You can use this to wrap a struct or
object, and then you can use it with anything that takes an `I`.
I guess one needs to return a WrappedBase!I type that is common
to all and does some magic to trick the compiler.
You can have variables and fields whose type is an interface, so
just use the interface.
If you must, it's pretty trivial to write an abstract base class
for the Wrapper class I wrote above.
Although, maybe
Wrapped!(I, Object) a;
will allow this to work?
That would only work if class Object conforms to that interface.