[GHC] #14203: GHC-inferred type signature doesn't actually typecheck
GHC
ghc-devs at haskell.org
Fri Nov 3 14:55:45 UTC 2017
#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):
OK, I found out how to do this. The trick is to make the kind of `a` in
`F` visible:
{{{#!hs
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module Bug where
type family F a
data Foo a (z :: F a)
bar :: forall a (z :: F a). Foo a z -> Int
bar _ = 42
}}}
A similar trick works for the program in comment:1:
{{{#!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 p x (z :: Apply (p :: a ~> *) (x :: a))
data Bar where
MkBar :: forall a (p :: TyFun a * -> *) (x :: a) (z :: Apply p x).
Foo p x z -> Bar
}}}
Alas, this trick doesn't scale very well to the original program, since
you'd need to give `p` as a visible argument to `Sing px` somehow. (It's
not clear to me if even visible kind application would fix this problem.)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14203#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list