RankNTypes
通常では定義できないが、RankNTypes を使えば定義できる例。特に、forall だけでなく context も対象となる点に注意。
context の例
code: (hs)
ghci>:set -XRankNTypes
ghci> f = undefined :: (Eq a => a) -> b -- context
forall の例
code: (hs)
ghci>:set -XRankNTypes
ghci> g = undefined :: (forall a . a) -> b -- forall
• Cannot instantiate unification variable ‘a0’
with a type involving foralls: (forall a. a) -> b1
GHC doesn't yet support impredicative polymorphism
• In the expression: undefined :: (forall a. a) -> b
In an equation for ‘g’: g = undefined :: (forall a. a) -> b