Quantified constraints
This wiki page summarises the state of play on the idea of allowing quantification in class constraints. For example
data Rose f a = Branch a (f (Rose f a))
instance (Eq a, forall b. (Eq b) => Eq (f b))
=> Eq (Rose f a)
where ...
The new bit is the forall
in the context of the instance declaration. This is allowed in GHC 8.6 and later using the QuantifiedConstraints
extension.
Here are some resources
-
Derivable type classes, Section 7, where the idea was first proposed (I think).
-
#2893 (closed), a ticket about the idea
-
Quantified class constraints, a Haskell 2017 paper that works out the idea in some detail, and a Reddit thread about it.
Status
See the QuantifiedConstraints label for tickets.