Re:Codata in action, or how to connect FP and OOP
by codr7 on Monday August 10, 2020 @10:01AM
(#24109310)
It must have enough methods to get the behavior you want, that doesn't always mean all subtypes.
Assuming you're running a version of Java that supports default implementations, which may often be used to avoid breaking the interface.
Sum types are a different story, as you would have to dive into existing code.
Sure there is. If I have a function that takes a Foo and a Bar, and it calls a generic method on them, the generic method must have methods that cover the real subtypes of Foo and Bar. If someone had created subtypes of Foo and Bar and defined methods on all the generic methods that they knew about, and now you create a new generic method, you have absolutely broken the interface just as much as adding a new method to Iterable in Java.