Visible forall in class methods
Summary
currently it isn't possible to change the visibility of a quantified type in a class method
a class method with forall tv -> will introduce a new tv visibly quantified type variable named tv even if the class definition contains a tv type variable shadowing the existing one and making the method be ambigously typed
Steps to reproduce
class Bits b where
bitSize :: forall b -> Int
Expected behavior
actually it is somewhat unclear, a forall tv. also introduces a new variable shadowing the one from the class head but in a constructor the types from the data declaration aren't in scope so you could use forall tv -> if it weren't explicitly disallowed. Basically there should be a way to define a method which works the same as
class Bits b where
bitSize :: forall a -> a ~ b => Int
without introducing a new variable, also in the future assuming foreach tv. and foreach tv -> are introduced we probably should be able to control how a class variable is quantified in each method
Environment
- GHC version used: The Glorious Glasgow Haskell Compilation System, version 9.10.1
Optional:
- Operating System: Linux
- System Architecture: x86_64