On the one hand, forall is superfluous here:
class MyClass c where getMyMap :: forall a. c -> MyMap a
Sample variables without explicit binding are universally evaluated at the most remote level, so this is exactly the same as c -> MyMap a .
In addition, the universally quantified type, of course, will not correspond to the existentially quantized type. The getMyMap type indicates that with a value of type c it MyMap a value of type MyMap a for any possible choice of type a . On the other hand, the accessor myMap says that with a value of type MyData it will MyMap a value of type MyMap a for a specific but unknown type a .
It is not possible to expand pop-up types of existential types (this requires a quantifier corresponding to forall ), so there is no way to rewrite the type getMyMap so that myMap a valid implementation.
All that you can do with something of an existential type completes its backup in another data type, which hides the existential quantifier, or passes it to a function that has an argument with a universal quantized type. For example, you can use length in list [a] with a existential type.
In your case, Map values ββare existential type without any other structure or restrictions, so they are practically useless and can also be () .
source share