{-# LANGUAGE RankNTypes, TypeOperators #-}
f1 :: ∀ a b . a → b → b
f1 x y = y
f2 :: ∀ b a . a → b → b
f2 x y = y
h :: (∀ a b . a → b → b) → c → d → d
h f x y = f x y
a = h f1
b = h f2Think about what this means for implementing a type-checker: to match one ∀-type against another, you have to find the right permutation of bound type variables. (A naive approach requires searching through all n! permutations!) Presumably the actual implementation incrementally unifies the type variables as it recurs into the bodies of the ∀-types.Does anyone know of a paper that describes this aspect of implementing higher-rank polymorphism?

