GADT Type Inference with Higher-Kinded Types
问题 I've got some code that compiles: {-# LANGUAGE ScopedTypeVariables, KindSignatures, GADTs, FlexibleContexts #-} module Foo where data Foo :: (* -> *) where Foo :: c m zp' -> Foo (c m zp) f :: forall c m zp d . Foo (c m zp) -> d f y@(Foo (x :: c m a)) = g x y g :: c m a -> Foo (c m b) -> d g = error "" The key thing I need in my real code is to convince GHC that if y has the type Foo (c m zp) and x has the type c' m' zp' , then c' ~ c and m' ~ m . The above code achieves this because I am able