
#14203: GHC-inferred type signature doesn't actually typecheck -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Keywords: TypeInType, Resolution: | TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Here's a slightly simpler example that doesn't use `singletons`. This compiles: {{{#!hs {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} module Bug where import Data.Kind data TyFun :: * -> * -> * type a ~> b = TyFun a b -> * infixr 0 ~> type family Apply (f :: k1 ~> k2) (x :: k1) :: k2 data Foo (z :: Apply (p :: a ~> *) (x :: a)) data Bar where MkBar :: Foo z -> Bar }}} And if you ask GHCi for the type of `MkBar`, you get: {{{ λ> :type +v MkBar MkBar :: forall a (p :: TyFun a * -> *) (x :: a) (z :: Apply p x). Foo z -> Bar }}} But if you try using that: {{{#!hs {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} module Bug where import Data.Kind data TyFun :: * -> * -> * type a ~> b = TyFun a b -> * infixr 0 ~> type family Apply (f :: k1 ~> k2) (x :: k1) :: k2 data Foo (z :: Apply (p :: a ~> *) (x :: a)) data Bar where MkBar :: forall a (p :: TyFun a * -> *) (x :: a) (z :: Apply p x). Foo z -> Bar }}} It fails: {{{ GHCi, version 8.3.20170907: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hs:19:16: error: • Expected kind ‘Apply p0 x0’, but ‘z’ has kind ‘Apply p x’ • In the first argument of ‘Foo’, namely ‘z’ In the type ‘Foo z’ In the definition of data constructor ‘MkBar’ | 19 | Foo z -> Bar | ^ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14203#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler