A question just came up about java generics. The example code is:
public interface A < T extends A < T> > {
}
A linked question asks about
Class Enum<E extends Enum<E>> ...
When I try to read the java documentation about these kinds of generic expressions, my eyes glaze over and it’s Greek to me.
I’m hoping that I can understand them in terms of the Haskell equivalent!
What is the equivalent (or similar) in Haskell of one or both of these examples?
This trick is used to allow the interface to refer to the concrete implementation type, for example to enforce that the type of the argument and the type of the result are the same type as the implementing class in something like this:
This is similar to what you get for free with type classes in Haskell: