GHC issueshttps://gitlab.haskell.org/ghc/ghc//issues20190707T18:15:13Zhttps://gitlab.haskell.org/ghc/ghc//issues/14880GHC panic: updateRole20190707T18:15:13ZRyan ScottGHC panic: updateRoleThe following program panics on GHC 8.0.2, 8.2.2, 8.4.1, and HEAD:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality ((:~:))
type SameKind (a :: k) (b :: k) = (() :: Constraint)
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data WhyCongSym1 (x :: Type) :: forall (a :: x)
(y :: Type)
(z :: x).
Type ~> (x ~> y) ~> x ~> x ~> (a :~: z) ~> Type
data WhyCongSym0 :: forall (x :: Type)
(a :: x)
(y :: Type)
(z :: x).
Type ~> Type ~> (x ~> y) ~> x ~> x ~> (a :~: z) ~> Type
where
WhyCongSym0KindInference :: forall x arg.
SameKind (Apply WhyCongSym0 arg) (WhyCongSym1 arg) =>
WhyCongSym0 x
```
```
$ /opt/ghc/8.2.2/bin/ghci Bug.hs
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
ghc: panic! (the 'impossible' happened)
(GHC version 8.2.2 for x86_64unknownlinux):
updateRole
WhyCongSym0
arg_a1A6[sk:1]
[a1A5 :> 4, a2Cy :> 0, a2Cz :> 1, a2CA :> 2, a2CB :> 3]
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcTyDecls.hs:656:23 in ghc:TcTyDecls
```The following program panics on GHC 8.0.2, 8.2.2, 8.4.1, and HEAD:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality ((:~:))
type SameKind (a :: k) (b :: k) = (() :: Constraint)
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data WhyCongSym1 (x :: Type) :: forall (a :: x)
(y :: Type)
(z :: x).
Type ~> (x ~> y) ~> x ~> x ~> (a :~: z) ~> Type
data WhyCongSym0 :: forall (x :: Type)
(a :: x)
(y :: Type)
(z :: x).
Type ~> Type ~> (x ~> y) ~> x ~> x ~> (a :~: z) ~> Type
where
WhyCongSym0KindInference :: forall x arg.
SameKind (Apply WhyCongSym0 arg) (WhyCongSym1 arg) =>
WhyCongSym0 x
```
```
$ /opt/ghc/8.2.2/bin/ghci Bug.hs
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
ghc: panic! (the 'impossible' happened)
(GHC version 8.2.2 for x86_64unknownlinux):
updateRole
WhyCongSym0
arg_a1A6[sk:1]
[a1A5 :> 4, a2Cy :> 0, a2Cz :> 1, a2CA :> 2, a2CB :> 3]
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcTyDecls.hs:656:23 in ghc:TcTyDecls
```8.6.2Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc//issues/14883QuantifiedConstraints don't kick in when used in TypeApplications20200310T22:34:23ZRyan ScottQuantifiedConstraints don't kick in when used in TypeApplicationsConsider the following program:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE ImpredicativeTypes #}
{# LANGUAGE InstanceSigs #}
{# LANGUAGE KindSignatures #}
{# LANGUAGE GeneralizedNewtypeDeriving #}
{# LANGUAGE QuantifiedConstraints #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
module Bug where
import Data.Coerce
import Data.Kind
type Representational1 m = (forall a b. Coercible a b => Coercible (m a) (m b) :: Constraint)
class Representational1 f => Functor' f where
fmap' :: (a > b) > f a > f b
class Functor' f => Applicative' f where
pure' :: a > f a
(<*>@) :: f (a > b) > f a > f b
class Functor' t => Traversable' t where
traverse' :: Applicative' f => (a > f b) > t a > f (t b)
 Typechecks
newtype T1 m a = MkT1 (m a) deriving Functor'
instance Traversable' m => Traversable' (T1 m) where
traverse' :: forall f a b. (Applicative' f) => (a > f b) > T1 m a > f (T1 m b)
traverse' = coerce @((a > f b) > m a > f (m b))
@((a > f b) > T1 m a > f (T1 m b))
traverse'
 Doesn't typecheck
newtype T2 m a = MkT2 (m a) deriving Functor'
instance Traversable' m => Traversable' (T2 m) where
traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
@(forall f a b. Applicative' f => (a > f b) > T2 m a > f (T2 m b))
traverse'
```
This defines a variant of `Functor` that has `forall a b. Coercible a b. Coercible (m a) (m b)` as a superclass, and also defines versions of `Applicative` and `Traversable` that use this `Functor` variant. This is towards the ultimate goal of defining `Traversable'` à la `GeneralizedNewtypeDeriving`.
This attempt (using `InstanceSigs`) typechecks:
```hs
newtype T1 m a = MkT1 (m a) deriving Functor'
instance Traversable' m => Traversable' (T1 m) where
traverse' :: forall f a b. (Applicative' f) => (a > f b) > T1 m a > f (T1 m b)
traverse' = coerce @((a > f b) > m a > f (m b))
@((a > f b) > T1 m a > f (T1 m b))
traverse'
```
However, this version (which is closer to what `GeneralizedNewtypeDeriving` would actually create) does //not// typecheck:
```hs
newtype T2 m a = MkT2 (m a) deriving Functor'
instance Traversable' m => Traversable' (T2 m) where
traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
@(forall f a b. Applicative' f => (a > f b) > T2 m a > f (T2 m b))
traverse'
```
```
$ ghccq/inplace/bin/ghcstage2 interactive Bug.hs
GHCi, version 8.5.20180128: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:38:15: error:
• Couldn't match representation of type ‘f1 (m b1)’
with that of ‘f1 (T2 m b1)’
arising from a use of ‘coerce’
NB: We cannot know what roles the parameters to ‘f1’ have;
we must assume that the role is nominal
• In the expression:
coerce
@(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
@(forall f a b.
Applicative' f => (a > f b) > T2 m a > f (T2 m b))
traverse'
In an equation for ‘traverse'’:
traverse'
= coerce
@(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
@(forall f a b.
Applicative' f => (a > f b) > T2 m a > f (T2 m b))
traverse'
In the instance declaration for ‘Traversable' (T2 m)’
• Relevant bindings include
traverse' :: (a > f b) > T2 m a > f (T2 m b)
(bound at Bug.hs:38:3)

38  traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
```
Shouldn't it, though? These instance declarations out to be equivalent (morally, at least).
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"QuantifiedConstraints don't kick in when used in TypeApplications","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["QuantifiedConstraints,","wipT2893"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE ImpredicativeTypes #}\r\n{# LANGUAGE InstanceSigs #}\r\n{# LANGUAGE KindSignatures #}\r\n{# LANGUAGE GeneralizedNewtypeDeriving #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\nmodule Bug where\r\n\r\nimport Data.Coerce\r\nimport Data.Kind\r\n\r\ntype Representational1 m = (forall a b. Coercible a b => Coercible (m a) (m b) :: Constraint)\r\n\r\nclass Representational1 f => Functor' f where\r\n fmap' :: (a > b) > f a > f b\r\n\r\nclass Functor' f => Applicative' f where\r\n pure' :: a > f a\r\n (<*>@) :: f (a > b) > f a > f b\r\n\r\nclass Functor' t => Traversable' t where\r\n traverse' :: Applicative' f => (a > f b) > t a > f (t b)\r\n\r\n Typechecks\r\nnewtype T1 m a = MkT1 (m a) deriving Functor'\r\ninstance Traversable' m => Traversable' (T1 m) where\r\n traverse' :: forall f a b. (Applicative' f) => (a > f b) > T1 m a > f (T1 m b)\r\n traverse' = coerce @((a > f b) > m a > f (m b))\r\n @((a > f b) > T1 m a > f (T1 m b))\r\n traverse'\r\n\r\n Doesn't typecheck\r\nnewtype T2 m a = MkT2 (m a) deriving Functor'\r\ninstance Traversable' m => Traversable' (T2 m) where\r\n traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n @(forall f a b. Applicative' f => (a > f b) > T2 m a > f (T2 m b))\r\n traverse'\r\n}}}\r\n\r\nThis defines a variant of `Functor` that has `forall a b. Coercible a b. Coercible (m a) (m b)` as a superclass, and also defines versions of `Applicative` and `Traversable` that use this `Functor` variant. This is towards the ultimate goal of defining `Traversable'` à la `GeneralizedNewtypeDeriving`.\r\n\r\nThis attempt (using `InstanceSigs`) typechecks:\r\n\r\n{{{#!hs\r\nnewtype T1 m a = MkT1 (m a) deriving Functor'\r\ninstance Traversable' m => Traversable' (T1 m) where\r\n traverse' :: forall f a b. (Applicative' f) => (a > f b) > T1 m a > f (T1 m b)\r\n traverse' = coerce @((a > f b) > m a > f (m b))\r\n @((a > f b) > T1 m a > f (T1 m b))\r\n traverse'\r\n}}}\r\n\r\nHowever, this version (which is closer to what `GeneralizedNewtypeDeriving` would actually create) does //not// typecheck:\r\n\r\n{{{#!hs\r\nnewtype T2 m a = MkT2 (m a) deriving Functor'\r\ninstance Traversable' m => Traversable' (T2 m) where\r\n traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n @(forall f a b. Applicative' f => (a > f b) > T2 m a > f (T2 m b))\r\n traverse'\r\n}}}\r\n{{{\r\n$ ghccq/inplace/bin/ghcstage2 interactive Bug.hs\r\nGHCi, version 8.5.20180128: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:38:15: error:\r\n • Couldn't match representation of type ‘f1 (m b1)’\r\n with that of ‘f1 (T2 m b1)’\r\n arising from a use of ‘coerce’\r\n NB: We cannot know what roles the parameters to ‘f1’ have;\r\n we must assume that the role is nominal\r\n • In the expression:\r\n coerce\r\n @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n @(forall f a b.\r\n Applicative' f => (a > f b) > T2 m a > f (T2 m b))\r\n traverse'\r\n In an equation for ‘traverse'’:\r\n traverse'\r\n = coerce\r\n @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n @(forall f a b.\r\n Applicative' f => (a > f b) > T2 m a > f (T2 m b))\r\n traverse'\r\n In the instance declaration for ‘Traversable' (T2 m)’\r\n • Relevant bindings include\r\n traverse' :: (a > f b) > T2 m a > f (T2 m b)\r\n (bound at Bug.hs:38:3)\r\n \r\n38  traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n}}}\r\n\r\nShouldn't it, though? These instance declarations out to be equivalent (morally, at least).","type_of_failure":"OtherFailure","blocking":[]} >Consider the following program:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE ImpredicativeTypes #}
{# LANGUAGE InstanceSigs #}
{# LANGUAGE KindSignatures #}
{# LANGUAGE GeneralizedNewtypeDeriving #}
{# LANGUAGE QuantifiedConstraints #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
module Bug where
import Data.Coerce
import Data.Kind
type Representational1 m = (forall a b. Coercible a b => Coercible (m a) (m b) :: Constraint)
class Representational1 f => Functor' f where
fmap' :: (a > b) > f a > f b
class Functor' f => Applicative' f where
pure' :: a > f a
(<*>@) :: f (a > b) > f a > f b
class Functor' t => Traversable' t where
traverse' :: Applicative' f => (a > f b) > t a > f (t b)
 Typechecks
newtype T1 m a = MkT1 (m a) deriving Functor'
instance Traversable' m => Traversable' (T1 m) where
traverse' :: forall f a b. (Applicative' f) => (a > f b) > T1 m a > f (T1 m b)
traverse' = coerce @((a > f b) > m a > f (m b))
@((a > f b) > T1 m a > f (T1 m b))
traverse'
 Doesn't typecheck
newtype T2 m a = MkT2 (m a) deriving Functor'
instance Traversable' m => Traversable' (T2 m) where
traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
@(forall f a b. Applicative' f => (a > f b) > T2 m a > f (T2 m b))
traverse'
```
This defines a variant of `Functor` that has `forall a b. Coercible a b. Coercible (m a) (m b)` as a superclass, and also defines versions of `Applicative` and `Traversable` that use this `Functor` variant. This is towards the ultimate goal of defining `Traversable'` à la `GeneralizedNewtypeDeriving`.
This attempt (using `InstanceSigs`) typechecks:
```hs
newtype T1 m a = MkT1 (m a) deriving Functor'
instance Traversable' m => Traversable' (T1 m) where
traverse' :: forall f a b. (Applicative' f) => (a > f b) > T1 m a > f (T1 m b)
traverse' = coerce @((a > f b) > m a > f (m b))
@((a > f b) > T1 m a > f (T1 m b))
traverse'
```
However, this version (which is closer to what `GeneralizedNewtypeDeriving` would actually create) does //not// typecheck:
```hs
newtype T2 m a = MkT2 (m a) deriving Functor'
instance Traversable' m => Traversable' (T2 m) where
traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
@(forall f a b. Applicative' f => (a > f b) > T2 m a > f (T2 m b))
traverse'
```
```
$ ghccq/inplace/bin/ghcstage2 interactive Bug.hs
GHCi, version 8.5.20180128: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:38:15: error:
• Couldn't match representation of type ‘f1 (m b1)’
with that of ‘f1 (T2 m b1)’
arising from a use of ‘coerce’
NB: We cannot know what roles the parameters to ‘f1’ have;
we must assume that the role is nominal
• In the expression:
coerce
@(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
@(forall f a b.
Applicative' f => (a > f b) > T2 m a > f (T2 m b))
traverse'
In an equation for ‘traverse'’:
traverse'
= coerce
@(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
@(forall f a b.
Applicative' f => (a > f b) > T2 m a > f (T2 m b))
traverse'
In the instance declaration for ‘Traversable' (T2 m)’
• Relevant bindings include
traverse' :: (a > f b) > T2 m a > f (T2 m b)
(bound at Bug.hs:38:3)

38  traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
```
Shouldn't it, though? These instance declarations out to be equivalent (morally, at least).
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"QuantifiedConstraints don't kick in when used in TypeApplications","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["QuantifiedConstraints,","wipT2893"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE ImpredicativeTypes #}\r\n{# LANGUAGE InstanceSigs #}\r\n{# LANGUAGE KindSignatures #}\r\n{# LANGUAGE GeneralizedNewtypeDeriving #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\nmodule Bug where\r\n\r\nimport Data.Coerce\r\nimport Data.Kind\r\n\r\ntype Representational1 m = (forall a b. Coercible a b => Coercible (m a) (m b) :: Constraint)\r\n\r\nclass Representational1 f => Functor' f where\r\n fmap' :: (a > b) > f a > f b\r\n\r\nclass Functor' f => Applicative' f where\r\n pure' :: a > f a\r\n (<*>@) :: f (a > b) > f a > f b\r\n\r\nclass Functor' t => Traversable' t where\r\n traverse' :: Applicative' f => (a > f b) > t a > f (t b)\r\n\r\n Typechecks\r\nnewtype T1 m a = MkT1 (m a) deriving Functor'\r\ninstance Traversable' m => Traversable' (T1 m) where\r\n traverse' :: forall f a b. (Applicative' f) => (a > f b) > T1 m a > f (T1 m b)\r\n traverse' = coerce @((a > f b) > m a > f (m b))\r\n @((a > f b) > T1 m a > f (T1 m b))\r\n traverse'\r\n\r\n Doesn't typecheck\r\nnewtype T2 m a = MkT2 (m a) deriving Functor'\r\ninstance Traversable' m => Traversable' (T2 m) where\r\n traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n @(forall f a b. Applicative' f => (a > f b) > T2 m a > f (T2 m b))\r\n traverse'\r\n}}}\r\n\r\nThis defines a variant of `Functor` that has `forall a b. Coercible a b. Coercible (m a) (m b)` as a superclass, and also defines versions of `Applicative` and `Traversable` that use this `Functor` variant. This is towards the ultimate goal of defining `Traversable'` à la `GeneralizedNewtypeDeriving`.\r\n\r\nThis attempt (using `InstanceSigs`) typechecks:\r\n\r\n{{{#!hs\r\nnewtype T1 m a = MkT1 (m a) deriving Functor'\r\ninstance Traversable' m => Traversable' (T1 m) where\r\n traverse' :: forall f a b. (Applicative' f) => (a > f b) > T1 m a > f (T1 m b)\r\n traverse' = coerce @((a > f b) > m a > f (m b))\r\n @((a > f b) > T1 m a > f (T1 m b))\r\n traverse'\r\n}}}\r\n\r\nHowever, this version (which is closer to what `GeneralizedNewtypeDeriving` would actually create) does //not// typecheck:\r\n\r\n{{{#!hs\r\nnewtype T2 m a = MkT2 (m a) deriving Functor'\r\ninstance Traversable' m => Traversable' (T2 m) where\r\n traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n @(forall f a b. Applicative' f => (a > f b) > T2 m a > f (T2 m b))\r\n traverse'\r\n}}}\r\n{{{\r\n$ ghccq/inplace/bin/ghcstage2 interactive Bug.hs\r\nGHCi, version 8.5.20180128: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:38:15: error:\r\n • Couldn't match representation of type ‘f1 (m b1)’\r\n with that of ‘f1 (T2 m b1)’\r\n arising from a use of ‘coerce’\r\n NB: We cannot know what roles the parameters to ‘f1’ have;\r\n we must assume that the role is nominal\r\n • In the expression:\r\n coerce\r\n @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n @(forall f a b.\r\n Applicative' f => (a > f b) > T2 m a > f (T2 m b))\r\n traverse'\r\n In an equation for ‘traverse'’:\r\n traverse'\r\n = coerce\r\n @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n @(forall f a b.\r\n Applicative' f => (a > f b) > T2 m a > f (T2 m b))\r\n traverse'\r\n In the instance declaration for ‘Traversable' (T2 m)’\r\n • Relevant bindings include\r\n traverse' :: (a > f b) > T2 m a > f (T2 m b)\r\n (bound at Bug.hs:38:3)\r\n \r\n38  traverse' = coerce @(forall f a b. Applicative' f => (a > f b) > m a > f (m b))\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n}}}\r\n\r\nShouldn't it, though? These instance declarations out to be equivalent (morally, at least).","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/14884Type holes cause assertion failure in ghcstage2 compiler during type checking20190707T18:15:11ZTao Hesighingnow@gmail.comType holes cause assertion failure in ghcstage2 compiler during type checkingghcstage2 panic! due to assertion failure when compiling the following code with `ghcstage2 Bug.hs`
```hs
module Bug where
x :: IO ()
x = _ print "abc"
```
Callstack:
```
λ inplace\bin\ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180225 for x86_64unknownmingw32):
ASSERT failed!
t_a4ec[tau:2]
2
1
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\utils\Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler\utils\Outputable.hs:1206:5 in ghc:Outputable
assertPprPanic, called at compiler\\typecheck\\TcType.hs:1187:83 in ghc:TcType
CallStack (from prof):
TcInteract.solve_loop (compiler\typecheck\TcInteract.hs:(247,9)(254,44))
TcInteract.solveSimples (compiler\typecheck\TcInteract.hs:(241,5)(243,21))
TcRnDriver.simplifyTop (compiler\typecheck\TcRnDriver.hs:408:2539)
TcRnDriver.tcRnSrcDecls (compiler\typecheck\TcRnDriver.hs:254:2565)
```
The failed assertion is `checkTcLevelInvariant ctxt_tclvl tv_tclvl` in `isTouchableMetaTyVar`:
```hs
isTouchableMetaTyVar :: TcLevel > TcTyVar > Bool
isTouchableMetaTyVar ctxt_tclvl tv
 isTyVar tv  See Note [Coercion variables in free variable lists]
= ASSERT2( tcIsTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
MetaTv { mtv_tclvl = tv_tclvl }
> ASSERT2( checkTcLevelInvariant ctxt_tclvl tv_tclvl,
ppr tv $$ ppr tv_tclvl $$ ppr ctxt_tclvl )
tv_tclvl `sameDepthAs` ctxt_tclvl
_ > False
 otherwise = False
```
Notice that the ghcstage1 compiler doesn't panic and report the type hole correctly. This seems a regression and I have checked that ghc8.2.2 also works well.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Type holes cause assertion failure in ghcstage2 compiler during type checking","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"ghcstage2 panic! due to assertion failure when compiling the following code with `ghcstage2 Bug.hs`\r\n\r\n{{{#!hs\r\nmodule Bug where\r\n\r\nx :: IO ()\r\nx = _ print \"abc\"\r\n}}}\r\n\r\nCallstack:\r\n\r\n{{{\r\nλ inplace\\bin\\ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180225 for x86_64unknownmingw32):\r\n ASSERT failed!\r\n t_a4ec[tau:2]\r\n 2\r\n 1\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler\\utils\\Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler\\utils\\Outputable.hs:1206:5 in ghc:Outputable\r\n assertPprPanic, called at compiler\\\\typecheck\\\\TcType.hs:1187:83 in ghc:TcType\r\nCallStack (from prof):\r\n TcInteract.solve_loop (compiler\\typecheck\\TcInteract.hs:(247,9)(254,44))\r\n TcInteract.solveSimples (compiler\\typecheck\\TcInteract.hs:(241,5)(243,21))\r\n TcRnDriver.simplifyTop (compiler\\typecheck\\TcRnDriver.hs:408:2539)\r\n TcRnDriver.tcRnSrcDecls (compiler\\typecheck\\TcRnDriver.hs:254:2565)\r\n}}}\r\n\r\nThe failed assertion is `checkTcLevelInvariant ctxt_tclvl tv_tclvl` in `isTouchableMetaTyVar`:\r\n\r\n{{{#!hs\r\nisTouchableMetaTyVar :: TcLevel > TcTyVar > Bool\r\nisTouchableMetaTyVar ctxt_tclvl tv\r\n  isTyVar tv  See Note [Coercion variables in free variable lists]\r\n = ASSERT2( tcIsTcTyVar tv, ppr tv )\r\n case tcTyVarDetails tv of\r\n MetaTv { mtv_tclvl = tv_tclvl }\r\n > ASSERT2( checkTcLevelInvariant ctxt_tclvl tv_tclvl,\r\n ppr tv $$ ppr tv_tclvl $$ ppr ctxt_tclvl )\r\n tv_tclvl `sameDepthAs` ctxt_tclvl\r\n _ > False\r\n  otherwise = False\r\n}}}\r\n\r\nNotice that the ghcstage1 compiler doesn't panic and report the type hole correctly. This seems a regression and I have checked that ghc8.2.2 also works well.","type_of_failure":"OtherFailure","blocking":[]} >ghcstage2 panic! due to assertion failure when compiling the following code with `ghcstage2 Bug.hs`
```hs
module Bug where
x :: IO ()
x = _ print "abc"
```
Callstack:
```
λ inplace\bin\ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180225 for x86_64unknownmingw32):
ASSERT failed!
t_a4ec[tau:2]
2
1
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\utils\Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler\utils\Outputable.hs:1206:5 in ghc:Outputable
assertPprPanic, called at compiler\\typecheck\\TcType.hs:1187:83 in ghc:TcType
CallStack (from prof):
TcInteract.solve_loop (compiler\typecheck\TcInteract.hs:(247,9)(254,44))
TcInteract.solveSimples (compiler\typecheck\TcInteract.hs:(241,5)(243,21))
TcRnDriver.simplifyTop (compiler\typecheck\TcRnDriver.hs:408:2539)
TcRnDriver.tcRnSrcDecls (compiler\typecheck\TcRnDriver.hs:254:2565)
```
The failed assertion is `checkTcLevelInvariant ctxt_tclvl tv_tclvl` in `isTouchableMetaTyVar`:
```hs
isTouchableMetaTyVar :: TcLevel > TcTyVar > Bool
isTouchableMetaTyVar ctxt_tclvl tv
 isTyVar tv  See Note [Coercion variables in free variable lists]
= ASSERT2( tcIsTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
MetaTv { mtv_tclvl = tv_tclvl }
> ASSERT2( checkTcLevelInvariant ctxt_tclvl tv_tclvl,
ppr tv $$ ppr tv_tclvl $$ ppr ctxt_tclvl )
tv_tclvl `sameDepthAs` ctxt_tclvl
_ > False
 otherwise = False
```
Notice that the ghcstage1 compiler doesn't panic and report the type hole correctly. This seems a regression and I have checked that ghc8.2.2 also works well.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Type holes cause assertion failure in ghcstage2 compiler during type checking","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"ghcstage2 panic! due to assertion failure when compiling the following code with `ghcstage2 Bug.hs`\r\n\r\n{{{#!hs\r\nmodule Bug where\r\n\r\nx :: IO ()\r\nx = _ print \"abc\"\r\n}}}\r\n\r\nCallstack:\r\n\r\n{{{\r\nλ inplace\\bin\\ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180225 for x86_64unknownmingw32):\r\n ASSERT failed!\r\n t_a4ec[tau:2]\r\n 2\r\n 1\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler\\utils\\Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler\\utils\\Outputable.hs:1206:5 in ghc:Outputable\r\n assertPprPanic, called at compiler\\\\typecheck\\\\TcType.hs:1187:83 in ghc:TcType\r\nCallStack (from prof):\r\n TcInteract.solve_loop (compiler\\typecheck\\TcInteract.hs:(247,9)(254,44))\r\n TcInteract.solveSimples (compiler\\typecheck\\TcInteract.hs:(241,5)(243,21))\r\n TcRnDriver.simplifyTop (compiler\\typecheck\\TcRnDriver.hs:408:2539)\r\n TcRnDriver.tcRnSrcDecls (compiler\\typecheck\\TcRnDriver.hs:254:2565)\r\n}}}\r\n\r\nThe failed assertion is `checkTcLevelInvariant ctxt_tclvl tv_tclvl` in `isTouchableMetaTyVar`:\r\n\r\n{{{#!hs\r\nisTouchableMetaTyVar :: TcLevel > TcTyVar > Bool\r\nisTouchableMetaTyVar ctxt_tclvl tv\r\n  isTyVar tv  See Note [Coercion variables in free variable lists]\r\n = ASSERT2( tcIsTcTyVar tv, ppr tv )\r\n case tcTyVarDetails tv of\r\n MetaTv { mtv_tclvl = tv_tclvl }\r\n > ASSERT2( checkTcLevelInvariant ctxt_tclvl tv_tclvl,\r\n ppr tv $$ ppr tv_tclvl $$ ppr ctxt_tclvl )\r\n tv_tclvl `sameDepthAs` ctxt_tclvl\r\n _ > False\r\n  otherwise = False\r\n}}}\r\n\r\nNotice that the ghcstage1 compiler doesn't panic and report the type hole correctly. This seems a regression and I have checked that ghc8.2.2 also works well.","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/14887Explicitly quantifying a kind variable causes a telescope to fail to kindcheck20190707T18:15:11ZRyan ScottExplicitly quantifying a kind variable causes a telescope to fail to kindcheckConsider the following program:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
{# OPTIONS_GHC fprintexplicitkinds #}
module Bug where
import Data.Kind
import Data.Type.Equality
type family Foo1 (e :: (a :: k) :~: (a :: k)) :: Type where
Foo1 (e :: a :~: a) = a :~: a
type family Foo2 (k :: Type) (e :: (a :: k) :~: (a :: k)) :: Type where
Foo2 k (e :: a :~: a) = a :~: a
```
`Foo2` is wholly equivalent to `Foo1`, except that in `Foo2`, the `k` kind variable is explicitly quantified. However, `Foo1` typechecks, but `Foo2` does not!
```
$ /opt/ghc/8.2.2/bin/ghci Bug.hs fprintexplicitkinds
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/ryanglscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:13:10: error:
• Couldn't match kind ‘k’ with ‘k1’
When matching the kind of ‘a’
Expected kind ‘(:~:) k a a’, but ‘e’ has kind ‘(:~:) k a a’
• In the second argument of ‘Foo2’, namely ‘(e :: a :~: a)’
In the type family declaration for ‘Foo2’

13  Foo2 k (e :: a :~: a) = a :~: a
 ^^^^^^^^^^^^^^
```
(Moreover, there seems to be a tidying bug, since GHC claims that `(:~:) k a a` is not the same kind as `(:~:) k a a`.)
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Explicitly quantifying a kind variable causes a type family to fail to typecheck","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\n{# OPTIONS_GHC fprintexplicitkinds #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\ntype family Foo1 (e :: (a :: k) :~: (a :: k)) :: Type where\r\n Foo1 (e :: a :~: a) = a :~: a\r\n\r\ntype family Foo2 (k :: Type) (e :: (a :: k) :~: (a :: k)) :: Type where\r\n Foo2 k (e :: a :~: a) = a :~: a\r\n}}}\r\n\r\n`Foo2` is wholly equivalent to `Foo1`, except that in `Foo2`, the `k` kind variable is explicitly quantified. However, `Foo1` typechecks, but `Foo2` does not!\r\n\r\n{{{\r\n$ /opt/ghc/8.2.2/bin/ghci Bug.hs fprintexplicitkinds\r\nGHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/ryanglscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:13:10: error:\r\n • Couldn't match kind ‘k’ with ‘k1’\r\n When matching the kind of ‘a’\r\n Expected kind ‘(:~:) k a a’, but ‘e’ has kind ‘(:~:) k a a’\r\n • In the second argument of ‘Foo2’, namely ‘(e :: a :~: a)’\r\n In the type family declaration for ‘Foo2’\r\n \r\n13  Foo2 k (e :: a :~: a) = a :~: a\r\n  ^^^^^^^^^^^^^^\r\n}}}\r\n\r\n(Moreover, there seems to be a tidying bug, since GHC claims that `(:~:) k a a` is not the same kind as `(:~:) k a a`.)","type_of_failure":"OtherFailure","blocking":[]} >Consider the following program:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
{# OPTIONS_GHC fprintexplicitkinds #}
module Bug where
import Data.Kind
import Data.Type.Equality
type family Foo1 (e :: (a :: k) :~: (a :: k)) :: Type where
Foo1 (e :: a :~: a) = a :~: a
type family Foo2 (k :: Type) (e :: (a :: k) :~: (a :: k)) :: Type where
Foo2 k (e :: a :~: a) = a :~: a
```
`Foo2` is wholly equivalent to `Foo1`, except that in `Foo2`, the `k` kind variable is explicitly quantified. However, `Foo1` typechecks, but `Foo2` does not!
```
$ /opt/ghc/8.2.2/bin/ghci Bug.hs fprintexplicitkinds
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/ryanglscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:13:10: error:
• Couldn't match kind ‘k’ with ‘k1’
When matching the kind of ‘a’
Expected kind ‘(:~:) k a a’, but ‘e’ has kind ‘(:~:) k a a’
• In the second argument of ‘Foo2’, namely ‘(e :: a :~: a)’
In the type family declaration for ‘Foo2’

13  Foo2 k (e :: a :~: a) = a :~: a
 ^^^^^^^^^^^^^^
```
(Moreover, there seems to be a tidying bug, since GHC claims that `(:~:) k a a` is not the same kind as `(:~:) k a a`.)
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Explicitly quantifying a kind variable causes a type family to fail to typecheck","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\n{# OPTIONS_GHC fprintexplicitkinds #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\ntype family Foo1 (e :: (a :: k) :~: (a :: k)) :: Type where\r\n Foo1 (e :: a :~: a) = a :~: a\r\n\r\ntype family Foo2 (k :: Type) (e :: (a :: k) :~: (a :: k)) :: Type where\r\n Foo2 k (e :: a :~: a) = a :~: a\r\n}}}\r\n\r\n`Foo2` is wholly equivalent to `Foo1`, except that in `Foo2`, the `k` kind variable is explicitly quantified. However, `Foo1` typechecks, but `Foo2` does not!\r\n\r\n{{{\r\n$ /opt/ghc/8.2.2/bin/ghci Bug.hs fprintexplicitkinds\r\nGHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/ryanglscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:13:10: error:\r\n • Couldn't match kind ‘k’ with ‘k1’\r\n When matching the kind of ‘a’\r\n Expected kind ‘(:~:) k a a’, but ‘e’ has kind ‘(:~:) k a a’\r\n • In the second argument of ‘Foo2’, namely ‘(e :: a :~: a)’\r\n In the type family declaration for ‘Foo2’\r\n \r\n13  Foo2 k (e :: a :~: a) = a :~: a\r\n  ^^^^^^^^^^^^^^\r\n}}}\r\n\r\n(Moreover, there seems to be a tidying bug, since GHC claims that `(:~:) k a a` is not the same kind as `(:~:) k a a`.)","type_of_failure":"OtherFailure","blocking":[]} >8.8.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc//issues/14904Compiler panic (piResultTy)20190707T18:15:06ZCsongor KissCompiler panic (piResultTy)Typechecking the following type family
```hs
type family F (f :: forall a. g a) :: Type where
F (f :: forall a. g a) = Int
```
panics with the message:
```txt
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.0.20180118 for x86_64appledarwin):
piResultTy
k_aVM[tau:1]
a_aVF[sk:1]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:950:35 in ghc:Type
```
The panic happens with HEAD, 8.4 and 8.2. 8.0 rejects the program with an error message, but even it panics on the following version:
```hs
type family F f :: Type where
F ((f :: forall a. g a) :: forall a. g a) = Int
```
#14873 seemed somewhat related, so I tried with the patch implemented in 3d252037234ce48f9bdada7d5c9b1d8eba470829, but that fails with the same panic too.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  #14873 
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Compiler panic (piResultTy)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[14873],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Typechecking the following type family\r\n\r\n{{{#!hs\r\ntype family F (f :: forall a. g a) :: Type where\r\n F (f :: forall a. g a) = Int\r\n}}}\r\n\r\npanics with the message:\r\n\r\n{{{#!txt\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.0.20180118 for x86_64appledarwin):\r\n piResultTy\r\n k_aVM[tau:1]\r\n a_aVF[sk:1]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:950:35 in ghc:Type\r\n\r\n}}}\r\n\r\nThe panic happens with HEAD, 8.4 and 8.2. 8.0 rejects the program with an error message, but even it panics on the following version:\r\n\r\n{{{#!hs\r\ntype family F f :: Type where\r\n F ((f :: forall a. g a) :: forall a. g a) = Int\r\n}}}\r\n\r\n#14873 seemed somewhat related, so I tried with the patch implemented in 3d252037234ce48f9bdada7d5c9b1d8eba470829, but that fails with the same panic too.","type_of_failure":"OtherFailure","blocking":[]} >Typechecking the following type family
```hs
type family F (f :: forall a. g a) :: Type where
F (f :: forall a. g a) = Int
```
panics with the message:
```txt
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.0.20180118 for x86_64appledarwin):
piResultTy
k_aVM[tau:1]
a_aVF[sk:1]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:950:35 in ghc:Type
```
The panic happens with HEAD, 8.4 and 8.2. 8.0 rejects the program with an error message, but even it panics on the following version:
```hs
type family F f :: Type where
F ((f :: forall a. g a) :: forall a. g a) = Int
```
#14873 seemed somewhat related, so I tried with the patch implemented in 3d252037234ce48f9bdada7d5c9b1d8eba470829, but that fails with the same panic too.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  #14873 
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Compiler panic (piResultTy)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[14873],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Typechecking the following type family\r\n\r\n{{{#!hs\r\ntype family F (f :: forall a. g a) :: Type where\r\n F (f :: forall a. g a) = Int\r\n}}}\r\n\r\npanics with the message:\r\n\r\n{{{#!txt\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.0.20180118 for x86_64appledarwin):\r\n piResultTy\r\n k_aVM[tau:1]\r\n a_aVF[sk:1]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:950:35 in ghc:Type\r\n\r\n}}}\r\n\r\nThe panic happens with HEAD, 8.4 and 8.2. 8.0 rejects the program with an error message, but even it panics on the following version:\r\n\r\n{{{#!hs\r\ntype family F f :: Type where\r\n F ((f :: forall a. g a) :: forall a. g a) = Int\r\n}}}\r\n\r\n#14873 seemed somewhat related, so I tried with the patch implemented in 3d252037234ce48f9bdada7d5c9b1d8eba470829, but that fails with the same panic too.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/14916Missing checks when deriving special classes20190707T18:15:03ZAndres LöhMissing checks when deriving special classesFor the following program
```hs
{# LANGUAGE DeriveAnyClass #}
module T where
import Data.Coerce
import Data.Typeable
data A = MkA deriving ((~) A)
data B = MkB deriving (Coercible B)
```
the deriving clause for `A` is accepted without complaints, and the
deriving clause for `B` fails with the following error:
```
T.hs:8:24: error:
Toplevel bindings for unlifted types aren't allowed:

8  data B = MkB deriving (Coercible B)
 ^^^^^^^^^^^
```
Corresponding standalone deriving instances trigger errors
saying "Manual instances of this class are not permitted".
Probably similar error messages should be triggered here.For the following program
```hs
{# LANGUAGE DeriveAnyClass #}
module T where
import Data.Coerce
import Data.Typeable
data A = MkA deriving ((~) A)
data B = MkB deriving (Coercible B)
```
the deriving clause for `A` is accepted without complaints, and the
deriving clause for `B` fails with the following error:
```
T.hs:8:24: error:
Toplevel bindings for unlifted types aren't allowed:

8  data B = MkB deriving (Coercible B)
 ^^^^^^^^^^^
```
Corresponding standalone deriving instances trigger errors
saying "Manual instances of this class are not permitted".
Probably similar error messages should be triggered here.8.4.2https://gitlab.haskell.org/ghc/ghc//issues/14932DeriveAnyClass produces unjustifiably untouchable unification variables20190707T18:14:59ZRyan ScottDeriveAnyClass produces unjustifiably untouchable unification variablesThe following code (courtesy of kosmikus) should typecheck, but does not:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE DeriveAnyClass #}
{# LANGUAGE DefaultSignatures #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
module Zero where
import GHC.Exts
class Zero a where
zero :: a
default zero :: (Code a ~ '[xs], All Zero xs) => a
zero = undefined
type family All c xs :: Constraint where
All c '[] = ()
All c (x : xs) = (c x, All c xs)
type family Code (a :: *) :: [[*]]
type instance Code B1 = '[ '[ ] ]
data B1 = B1
deriving Zero
```
This produces the following error:
```
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /nfs/nfs7/home/rgscott/.ghci
[1 of 1] Compiling Zero ( Bug.hs, interpreted )
Bug.hs:23:11: error:
• Couldn't match type ‘xs0’ with ‘'[]’
arising from the 'deriving' clause of a data type declaration
‘xs0’ is untouchable
inside the constraints: All Zero xs0
bound by the deriving clause for ‘Zero B1’
at Bug.hs:23:1114
• When deriving the instance for (Zero B1)

23  deriving Zero
 ^^^^
```
This error is baffling, however, because `xs0` should be a unification variable that readily unifies with `'[]`! As evidence, this typechecks:
```
instance Zero B1
```
But the equivalent `deriving` clause does not.
I know what is going on here after some sleuthing: `DeriveAnyClass` (specifically, `inferConstraintsDAC`) is producing unification variables whose TcLevel is always bumped to three. However, in the program above, we will not form an implication constraints around those unification variables, since `zero` has no locally quantified type variables or given constraints. Thus, `simplifyDeriv` will try to simplify unification variables with TcLevel 3 at the top level, which results in them being untouchable. Blegh.
This was partially noticed in #13272, when we were failing to bump unification variables that //did// appear inside implication constraints. However, we overlooked this one corner case, which kosmikus happened to stumble upon in a `genericssop` [example](https://stackoverflow.com/a/49335338/1482749).
Patch incoming.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  #13272 
 Blocking  
 CC  kosmikus 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"DeriveAnyClass produces unjustifiably untouchable unification variables","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[13272],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":["deriving"],"differentials":[],"test_case":"","architecture":"","cc":["kosmikus"],"type":"Bug","description":"The following code (courtesy of kosmikus) should typecheck, but does not:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE DeriveAnyClass #}\r\n{# LANGUAGE DefaultSignatures #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Zero where\r\n\r\nimport GHC.Exts\r\n\r\nclass Zero a where\r\n zero :: a\r\n default zero :: (Code a ~ '[xs], All Zero xs) => a\r\n zero = undefined\r\n\r\ntype family All c xs :: Constraint where\r\n All c '[] = ()\r\n All c (x : xs) = (c x, All c xs)\r\n\r\ntype family Code (a :: *) :: [[*]]\r\ntype instance Code B1 = '[ '[ ] ]\r\n\r\ndata B1 = B1\r\n deriving Zero\r\n}}}\r\n\r\nThis produces the following error:\r\n\r\n{{{\r\nGHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /nfs/nfs7/home/rgscott/.ghci\r\n[1 of 1] Compiling Zero ( Bug.hs, interpreted )\r\n\r\nBug.hs:23:11: error:\r\n • Couldn't match type ‘xs0’ with ‘'[]’\r\n arising from the 'deriving' clause of a data type declaration\r\n ‘xs0’ is untouchable\r\n inside the constraints: All Zero xs0\r\n bound by the deriving clause for ‘Zero B1’\r\n at Bug.hs:23:1114\r\n • When deriving the instance for (Zero B1)\r\n \r\n23  deriving Zero\r\n  ^^^^\r\n}}}\r\n\r\nThis error is baffling, however, because `xs0` should be a unification variable that readily unifies with `'[]`! As evidence, this typechecks:\r\n\r\n{{{\r\ninstance Zero B1\r\n}}}\r\n\r\nBut the equivalent `deriving` clause does not.\r\n\r\nI know what is going on here after some sleuthing: `DeriveAnyClass` (specifically, `inferConstraintsDAC`) is producing unification variables whose TcLevel is always bumped to three. However, in the program above, we will not form an implication constraints around those unification variables, since `zero` has no locally quantified type variables or given constraints. Thus, `simplifyDeriv` will try to simplify unification variables with TcLevel 3 at the top level, which results in them being untouchable. Blegh.\r\n\r\nThis was partially noticed in #13272, when we were failing to bump unification variables that //did// appear inside implication constraints. However, we overlooked this one corner case, which kosmikus happened to stumble upon in a `genericssop` [https://stackoverflow.com/a/49335338/1482749 example].\r\n\r\nPatch incoming.","type_of_failure":"OtherFailure","blocking":[]} >The following code (courtesy of kosmikus) should typecheck, but does not:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE DeriveAnyClass #}
{# LANGUAGE DefaultSignatures #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
module Zero where
import GHC.Exts
class Zero a where
zero :: a
default zero :: (Code a ~ '[xs], All Zero xs) => a
zero = undefined
type family All c xs :: Constraint where
All c '[] = ()
All c (x : xs) = (c x, All c xs)
type family Code (a :: *) :: [[*]]
type instance Code B1 = '[ '[ ] ]
data B1 = B1
deriving Zero
```
This produces the following error:
```
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /nfs/nfs7/home/rgscott/.ghci
[1 of 1] Compiling Zero ( Bug.hs, interpreted )
Bug.hs:23:11: error:
• Couldn't match type ‘xs0’ with ‘'[]’
arising from the 'deriving' clause of a data type declaration
‘xs0’ is untouchable
inside the constraints: All Zero xs0
bound by the deriving clause for ‘Zero B1’
at Bug.hs:23:1114
• When deriving the instance for (Zero B1)

23  deriving Zero
 ^^^^
```
This error is baffling, however, because `xs0` should be a unification variable that readily unifies with `'[]`! As evidence, this typechecks:
```
instance Zero B1
```
But the equivalent `deriving` clause does not.
I know what is going on here after some sleuthing: `DeriveAnyClass` (specifically, `inferConstraintsDAC`) is producing unification variables whose TcLevel is always bumped to three. However, in the program above, we will not form an implication constraints around those unification variables, since `zero` has no locally quantified type variables or given constraints. Thus, `simplifyDeriv` will try to simplify unification variables with TcLevel 3 at the top level, which results in them being untouchable. Blegh.
This was partially noticed in #13272, when we were failing to bump unification variables that //did// appear inside implication constraints. However, we overlooked this one corner case, which kosmikus happened to stumble upon in a `genericssop` [example](https://stackoverflow.com/a/49335338/1482749).
Patch incoming.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  #13272 
 Blocking  
 CC  kosmikus 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"DeriveAnyClass produces unjustifiably untouchable unification variables","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[13272],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":["deriving"],"differentials":[],"test_case":"","architecture":"","cc":["kosmikus"],"type":"Bug","description":"The following code (courtesy of kosmikus) should typecheck, but does not:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE DeriveAnyClass #}\r\n{# LANGUAGE DefaultSignatures #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Zero where\r\n\r\nimport GHC.Exts\r\n\r\nclass Zero a where\r\n zero :: a\r\n default zero :: (Code a ~ '[xs], All Zero xs) => a\r\n zero = undefined\r\n\r\ntype family All c xs :: Constraint where\r\n All c '[] = ()\r\n All c (x : xs) = (c x, All c xs)\r\n\r\ntype family Code (a :: *) :: [[*]]\r\ntype instance Code B1 = '[ '[ ] ]\r\n\r\ndata B1 = B1\r\n deriving Zero\r\n}}}\r\n\r\nThis produces the following error:\r\n\r\n{{{\r\nGHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /nfs/nfs7/home/rgscott/.ghci\r\n[1 of 1] Compiling Zero ( Bug.hs, interpreted )\r\n\r\nBug.hs:23:11: error:\r\n • Couldn't match type ‘xs0’ with ‘'[]’\r\n arising from the 'deriving' clause of a data type declaration\r\n ‘xs0’ is untouchable\r\n inside the constraints: All Zero xs0\r\n bound by the deriving clause for ‘Zero B1’\r\n at Bug.hs:23:1114\r\n • When deriving the instance for (Zero B1)\r\n \r\n23  deriving Zero\r\n  ^^^^\r\n}}}\r\n\r\nThis error is baffling, however, because `xs0` should be a unification variable that readily unifies with `'[]`! As evidence, this typechecks:\r\n\r\n{{{\r\ninstance Zero B1\r\n}}}\r\n\r\nBut the equivalent `deriving` clause does not.\r\n\r\nI know what is going on here after some sleuthing: `DeriveAnyClass` (specifically, `inferConstraintsDAC`) is producing unification variables whose TcLevel is always bumped to three. However, in the program above, we will not form an implication constraints around those unification variables, since `zero` has no locally quantified type variables or given constraints. Thus, `simplifyDeriv` will try to simplify unification variables with TcLevel 3 at the top level, which results in them being untouchable. Blegh.\r\n\r\nThis was partially noticed in #13272, when we were failing to bump unification variables that //did// appear inside implication constraints. However, we overlooked this one corner case, which kosmikus happened to stumble upon in a `genericssop` [https://stackoverflow.com/a/49335338/1482749 example].\r\n\r\nPatch incoming.","type_of_failure":"OtherFailure","blocking":[]} >8.4.2https://gitlab.haskell.org/ghc/ghc//issues/14933DeriveAnyClass can cause "No skolem info" GHC panic20190707T18:14:59ZRyan ScottDeriveAnyClass can cause "No skolem info" GHC panicThis program panics:
```hs
{# LANGUAGE DefaultSignatures #}
{# LANGUAGE DeriveAnyClass #}
{# LANGUAGE DeriveGeneric #}
{# LANGUAGE DerivingStrategies #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE GeneralizedNewtypeDeriving #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
module Bug where
import Control.Concurrent (ThreadId)
import Control.Monad.Reader
class Wrapped s where
type Unwrapped s :: *
_Wrapped' :: Iso' s (Unwrapped s)
type Iso' s a = forall f. Functor f => (a > f a) > s > f s
class Fork m where
fork :: x > m () > m ThreadId
default fork :: ( Wrapped (m ())
, Unwrapped (m ()) ~ t ()
, Fork t
, Wrapped (m ThreadId)
, Unwrapped (m ThreadId) ~ t ThreadId
) => x > m () > m ThreadId
fork = undefined  view _Unwrapped' . fork . view _Wrapped'
instance Fork m => Fork (ReaderT e m) where
fork x action = ReaderT $ \env > fork x (runReaderT action env)
data Env
newtype MyThing m a = MyThing { unMyThing :: ReaderT Env m a }
deriving newtype (Functor, Applicative, Monad)
deriving anyclass (Fork)
instance Wrapped (MyThing m a) where
type Unwrapped (MyThing m a) = ReaderT Env m a
_Wrapped' = undefined  iso unMyThing MyThing
```
```
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:39:24: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.2.2 for x86_64unknownlinux):
No skolem info:
m_a1Hs[sk:2]
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors
```
(Program adapted from [here](https://github.com/ekmett/lens/issues/793#issuecomment369597846).)
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"DeriveAnyClass can cause \"No skolem info\" GHC panic","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["deriving"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This program panics:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DefaultSignatures #}\r\n{# LANGUAGE DeriveAnyClass #}\r\n{# LANGUAGE DeriveGeneric #}\r\n{# LANGUAGE DerivingStrategies #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE GeneralizedNewtypeDeriving #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\nimport Control.Concurrent (ThreadId)\r\nimport Control.Monad.Reader\r\n\r\nclass Wrapped s where\r\n type Unwrapped s :: *\r\n _Wrapped' :: Iso' s (Unwrapped s)\r\n\r\ntype Iso' s a = forall f. Functor f => (a > f a) > s > f s\r\n\r\nclass Fork m where\r\n fork :: x > m () > m ThreadId\r\n\r\n default fork :: ( Wrapped (m ())\r\n , Unwrapped (m ()) ~ t ()\r\n , Fork t\r\n , Wrapped (m ThreadId)\r\n , Unwrapped (m ThreadId) ~ t ThreadId\r\n ) => x > m () > m ThreadId\r\n fork = undefined  view _Unwrapped' . fork . view _Wrapped'\r\n\r\ninstance Fork m => Fork (ReaderT e m) where\r\n fork x action = ReaderT $ \\env > fork x (runReaderT action env)\r\n\r\ndata Env\r\n\r\nnewtype MyThing m a = MyThing { unMyThing :: ReaderT Env m a }\r\n deriving newtype (Functor, Applicative, Monad)\r\n deriving anyclass (Fork)\r\n\r\ninstance Wrapped (MyThing m a) where\r\n type Unwrapped (MyThing m a) = ReaderT Env m a\r\n _Wrapped' = undefined  iso unMyThing MyThing\r\n}}}\r\n\r\n{{{\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:39:24: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.2.2 for x86_64unknownlinux):\r\n No skolem info:\r\n m_a1Hs[sk:2]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable\r\n callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors\r\n}}}\r\n\r\n(Program adapted from [https://github.com/ekmett/lens/issues/793#issuecomment369597846 here].)","type_of_failure":"OtherFailure","blocking":[]} >This program panics:
```hs
{# LANGUAGE DefaultSignatures #}
{# LANGUAGE DeriveAnyClass #}
{# LANGUAGE DeriveGeneric #}
{# LANGUAGE DerivingStrategies #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE GeneralizedNewtypeDeriving #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
module Bug where
import Control.Concurrent (ThreadId)
import Control.Monad.Reader
class Wrapped s where
type Unwrapped s :: *
_Wrapped' :: Iso' s (Unwrapped s)
type Iso' s a = forall f. Functor f => (a > f a) > s > f s
class Fork m where
fork :: x > m () > m ThreadId
default fork :: ( Wrapped (m ())
, Unwrapped (m ()) ~ t ()
, Fork t
, Wrapped (m ThreadId)
, Unwrapped (m ThreadId) ~ t ThreadId
) => x > m () > m ThreadId
fork = undefined  view _Unwrapped' . fork . view _Wrapped'
instance Fork m => Fork (ReaderT e m) where
fork x action = ReaderT $ \env > fork x (runReaderT action env)
data Env
newtype MyThing m a = MyThing { unMyThing :: ReaderT Env m a }
deriving newtype (Functor, Applicative, Monad)
deriving anyclass (Fork)
instance Wrapped (MyThing m a) where
type Unwrapped (MyThing m a) = ReaderT Env m a
_Wrapped' = undefined  iso unMyThing MyThing
```
```
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:39:24: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.2.2 for x86_64unknownlinux):
No skolem info:
m_a1Hs[sk:2]
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors
```
(Program adapted from [here](https://github.com/ekmett/lens/issues/793#issuecomment369597846).)
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"DeriveAnyClass can cause \"No skolem info\" GHC panic","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["deriving"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This program panics:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DefaultSignatures #}\r\n{# LANGUAGE DeriveAnyClass #}\r\n{# LANGUAGE DeriveGeneric #}\r\n{# LANGUAGE DerivingStrategies #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE GeneralizedNewtypeDeriving #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\nimport Control.Concurrent (ThreadId)\r\nimport Control.Monad.Reader\r\n\r\nclass Wrapped s where\r\n type Unwrapped s :: *\r\n _Wrapped' :: Iso' s (Unwrapped s)\r\n\r\ntype Iso' s a = forall f. Functor f => (a > f a) > s > f s\r\n\r\nclass Fork m where\r\n fork :: x > m () > m ThreadId\r\n\r\n default fork :: ( Wrapped (m ())\r\n , Unwrapped (m ()) ~ t ()\r\n , Fork t\r\n , Wrapped (m ThreadId)\r\n , Unwrapped (m ThreadId) ~ t ThreadId\r\n ) => x > m () > m ThreadId\r\n fork = undefined  view _Unwrapped' . fork . view _Wrapped'\r\n\r\ninstance Fork m => Fork (ReaderT e m) where\r\n fork x action = ReaderT $ \\env > fork x (runReaderT action env)\r\n\r\ndata Env\r\n\r\nnewtype MyThing m a = MyThing { unMyThing :: ReaderT Env m a }\r\n deriving newtype (Functor, Applicative, Monad)\r\n deriving anyclass (Fork)\r\n\r\ninstance Wrapped (MyThing m a) where\r\n type Unwrapped (MyThing m a) = ReaderT Env m a\r\n _Wrapped' = undefined  iso unMyThing MyThing\r\n}}}\r\n\r\n{{{\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:39:24: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.2.2 for x86_64unknownlinux):\r\n No skolem info:\r\n m_a1Hs[sk:2]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable\r\n callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors\r\n}}}\r\n\r\n(Program adapted from [https://github.com/ekmett/lens/issues/793#issuecomment369597846 here].)","type_of_failure":"OtherFailure","blocking":[]} >8.4.2https://gitlab.haskell.org/ghc/ghc//issues/14938Pattern matching on GADT does not refine type family parameters20190707T18:14:57ZCsongor KissPattern matching on GADT does not refine type family parametersCompiling the following code
```hs
type family R (x :: k) (y :: k) (prf :: x :~: y) :: x :~: y where
R x y Refl = Refl
```
fails with the error
```txt
Temp.hs:49:9: error:
• Expected kind ‘x :~: y’, but ‘Refl’ has kind ‘x :~: x’
• In the third argument of ‘R’, namely ‘Refl’
In the type family declaration for ‘R’

49  R x y Refl = Refl
 ^^^^
```
where `Refl` is defined as
```hs
data a :~: b where
Refl :: a :~: a
```
I would expect patternmatching on `Refl` to bring the equality `x ~ y` into scope. It seems like it not only doesn't do that, but the pattern match itself is rejected.
(both 8.2.2 and HEAD)
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Pattern matching on GADT does not refine type family parameters","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["GADTs,","TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Compiling the following code\r\n\r\n{{{#!hs\r\ntype family R (x :: k) (y :: k) (prf :: x :~: y) :: x :~: y where\r\n R x y Refl = Refl\r\n}}}\r\n\r\nfails with the error\r\n\r\n\r\n{{{#!txt\r\nTemp.hs:49:9: error:\r\n • Expected kind ‘x :~: y’, but ‘Refl’ has kind ‘x :~: x’\r\n • In the third argument of ‘R’, namely ‘Refl’\r\n In the type family declaration for ‘R’\r\n \r\n49  R x y Refl = Refl\r\n  ^^^^\r\n}}}\r\n\r\nwhere `Refl` is defined as\r\n{{{#!hs\r\ndata a :~: b where\r\n Refl :: a :~: a\r\n}}}\r\n\r\nI would expect patternmatching on `Refl` to bring the equality `x ~ y` into scope. It seems like it not only doesn't do that, but the pattern match itself is rejected.\r\n\r\n(both 8.2.2 and HEAD)\r\n","type_of_failure":"OtherFailure","blocking":[]} >Compiling the following code
```hs
type family R (x :: k) (y :: k) (prf :: x :~: y) :: x :~: y where
R x y Refl = Refl
```
fails with the error
```txt
Temp.hs:49:9: error:
• Expected kind ‘x :~: y’, but ‘Refl’ has kind ‘x :~: x’
• In the third argument of ‘R’, namely ‘Refl’
In the type family declaration for ‘R’

49  R x y Refl = Refl
 ^^^^
```
where `Refl` is defined as
```hs
data a :~: b where
Refl :: a :~: a
```
I would expect patternmatching on `Refl` to bring the equality `x ~ y` into scope. It seems like it not only doesn't do that, but the pattern match itself is rejected.
(both 8.2.2 and HEAD)
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Pattern matching on GADT does not refine type family parameters","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["GADTs,","TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Compiling the following code\r\n\r\n{{{#!hs\r\ntype family R (x :: k) (y :: k) (prf :: x :~: y) :: x :~: y where\r\n R x y Refl = Refl\r\n}}}\r\n\r\nfails with the error\r\n\r\n\r\n{{{#!txt\r\nTemp.hs:49:9: error:\r\n • Expected kind ‘x :~: y’, but ‘Refl’ has kind ‘x :~: x’\r\n • In the third argument of ‘R’, namely ‘Refl’\r\n In the type family declaration for ‘R’\r\n \r\n49  R x y Refl = Refl\r\n  ^^^^\r\n}}}\r\n\r\nwhere `Refl` is defined as\r\n{{{#!hs\r\ndata a :~: b where\r\n Refl :: a :~: a\r\n}}}\r\n\r\nI would expect patternmatching on `Refl` to bring the equality `x ~ y` into scope. It seems like it not only doesn't do that, but the pattern match itself is rejected.\r\n\r\n(both 8.2.2 and HEAD)\r\n","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/14968QuantifiedConstraints: Can't be RHS of type family instances20190707T18:14:51ZjosefQuantifiedConstraints: Can't be RHS of type family instancesHere's a type family that I tried to write using QuantifiedConstraints.
```hs
{# LANGUAGE TypeOperators #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE KindSignatures #}
{# LANGUAGE DataKinds #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE QuantifiedConstraints #}
module QCTypeInstance where
import GHC.Exts (Constraint)
type family Functors (fs :: [(* > *) > * > *]) :: Constraint
type instance Functors '[] = (() :: Constraint)
type instance Functors (t ': ts) = (forall f. Functor f => Functor (t f), Functors ts)
```
Unfortunately, GHC complains that it's illegal to have polymorphism on the right hand side of a type instance definition.
```
$ ../ghcwip/T2893/inplace/bin/ghcstage2 interactive QCTypeInstance.hs
GHCi, version 8.5.20180322: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling QCTypeInstance ( QCTypeInstance.hs, interpreted )
QCTypeInstance.hs:13:15: error:
• Illegal polymorphic type:
forall (f :: * > *). Functor f => Functor (t f)
• In the type instance declaration for ‘Functors’

13  type instance Functors (t ': ts) = (forall f. Functor f => Functor (t f), Functors ts)
 ^^^^^^^^
```
Would it be possible to lift this restriction and allow quantified constraints as right hand sides of type family instances? Or are there fundamental difficulties with what I'm trying to do?
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"QuantifiedConstraints: Can't be RHS of type family instances","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["QuantifiedConstraints"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here's a type family that I tried to write using QuantifiedConstraints.\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE KindSignatures #}\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\nmodule QCTypeInstance where\r\n\r\nimport GHC.Exts (Constraint)\r\n\r\ntype family Functors (fs :: [(* > *) > * > *]) :: Constraint\r\ntype instance Functors '[] = (() :: Constraint)\r\ntype instance Functors (t ': ts) = (forall f. Functor f => Functor (t f), Functors ts)\r\n}}}\r\n\r\nUnfortunately, GHC complains that it's illegal to have polymorphism on the right hand side of a type instance definition.\r\n\r\n{{{\r\n$ ../ghcwip/T2893/inplace/bin/ghcstage2 interactive QCTypeInstance.hs \r\nGHCi, version 8.5.20180322: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling QCTypeInstance ( QCTypeInstance.hs, interpreted )\r\n\r\nQCTypeInstance.hs:13:15: error:\r\n • Illegal polymorphic type:\r\n forall (f :: * > *). Functor f => Functor (t f)\r\n • In the type instance declaration for ‘Functors’\r\n \r\n13  type instance Functors (t ': ts) = (forall f. Functor f => Functor (t f), Functors ts)\r\n  ^^^^^^^^\r\n}}}\r\n\r\nWould it be possible to lift this restriction and allow quantified constraints as right hand sides of type family instances? Or are there fundamental difficulties with what I'm trying to do?","type_of_failure":"OtherFailure","blocking":[]} >Here's a type family that I tried to write using QuantifiedConstraints.
```hs
{# LANGUAGE TypeOperators #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE KindSignatures #}
{# LANGUAGE DataKinds #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE QuantifiedConstraints #}
module QCTypeInstance where
import GHC.Exts (Constraint)
type family Functors (fs :: [(* > *) > * > *]) :: Constraint
type instance Functors '[] = (() :: Constraint)
type instance Functors (t ': ts) = (forall f. Functor f => Functor (t f), Functors ts)
```
Unfortunately, GHC complains that it's illegal to have polymorphism on the right hand side of a type instance definition.
```
$ ../ghcwip/T2893/inplace/bin/ghcstage2 interactive QCTypeInstance.hs
GHCi, version 8.5.20180322: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling QCTypeInstance ( QCTypeInstance.hs, interpreted )
QCTypeInstance.hs:13:15: error:
• Illegal polymorphic type:
forall (f :: * > *). Functor f => Functor (t f)
• In the type instance declaration for ‘Functors’

13  type instance Functors (t ': ts) = (forall f. Functor f => Functor (t f), Functors ts)
 ^^^^^^^^
```
Would it be possible to lift this restriction and allow quantified constraints as right hand sides of type family instances? Or are there fundamental difficulties with what I'm trying to do?
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"QuantifiedConstraints: Can't be RHS of type family instances","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["QuantifiedConstraints"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here's a type family that I tried to write using QuantifiedConstraints.\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE KindSignatures #}\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\nmodule QCTypeInstance where\r\n\r\nimport GHC.Exts (Constraint)\r\n\r\ntype family Functors (fs :: [(* > *) > * > *]) :: Constraint\r\ntype instance Functors '[] = (() :: Constraint)\r\ntype instance Functors (t ': ts) = (forall f. Functor f => Functor (t f), Functors ts)\r\n}}}\r\n\r\nUnfortunately, GHC complains that it's illegal to have polymorphism on the right hand side of a type instance definition.\r\n\r\n{{{\r\n$ ../ghcwip/T2893/inplace/bin/ghcstage2 interactive QCTypeInstance.hs \r\nGHCi, version 8.5.20180322: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling QCTypeInstance ( QCTypeInstance.hs, interpreted )\r\n\r\nQCTypeInstance.hs:13:15: error:\r\n • Illegal polymorphic type:\r\n forall (f :: * > *). Functor f => Functor (t f)\r\n • In the type instance declaration for ‘Functors’\r\n \r\n13  type instance Functors (t ': ts) = (forall f. Functor f => Functor (t f), Functors ts)\r\n  ^^^^^^^^\r\n}}}\r\n\r\nWould it be possible to lift this restriction and allow quantified constraints as right hand sides of type family instances? Or are there fundamental difficulties with what I'm trying to do?","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/14984Regression: 8.4.1 says "Could not deduce" when before 8.4 it could20190707T18:14:47ZerikdRegression: 8.4.1 says "Could not deduce" when before 8.4 it couldHave some code:
```hs
import Test.QuickCheck
import Test.QuickCheck.Monadic
testPropertyIO :: Testable a => PropertyM IO a > Property
testPropertyIO = monadicIO . (=<<) stop
```
That compiles fine with ghc 7.10 through 8.2, but with 8.4.1 fails with:
```
test/Test/Mafia/IO.hs:18:18: error:
? Could not deduce (Testable a0) arising from a use of ?monadicIO?
from the context: Testable a
bound by the type signature for:
testPropertyIO :: forall a.
Testable a =>
PropertyM IO a > Property
at test/Test/Mafia/IO.hs:17:158
The type variable ?a0? is ambiguous
These potential instances exist:
instance [safe] Testable prop => Testable (Gen prop)
 Defined in ?Test.QuickCheck.Property?
instance [safe] Testable Discard
 Defined in ?Test.QuickCheck.Property?
instance [safe] Testable Property
 Defined in ?Test.QuickCheck.Property?
...plus three others
...plus two instances involving outofscope types
(use fprintpotentialinstances to see them all)
? In the first argument of ?(.)?, namely ?monadicIO?
In the expression: monadicIO . (=<<) stop
In an equation for ?testPropertyIO?:
testPropertyIO = monadicIO . (=<<) stop
```
Either the compiler has been incorrectly accepting this as valid for a number of releases or this is a regression.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Rgression: 8.4.1 says \"Could not deduce\" when before 8.4 it could","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Have some code:\r\n\r\n{{{#!hs\r\nimport Test.QuickCheck\r\nimport Test.QuickCheck.Monadic\r\n\r\ntestPropertyIO :: Testable a => PropertyM IO a > Property\r\ntestPropertyIO = monadicIO . (=<<) stop\r\n}}}\r\n\r\nThat compiles fine with ghc 7.10 through 8.2, but with 8.4.1 fails with:\r\n{{{\r\ntest/Test/Mafia/IO.hs:18:18: error:\r\n ? Could not deduce (Testable a0) arising from a use of ?monadicIO?\r\n from the context: Testable a\r\n bound by the type signature for:\r\n testPropertyIO :: forall a.\r\n Testable a =>\r\n PropertyM IO a > Property\r\n at test/Test/Mafia/IO.hs:17:158\r\n The type variable ?a0? is ambiguous\r\n These potential instances exist:\r\n instance [safe] Testable prop => Testable (Gen prop)\r\n  Defined in ?Test.QuickCheck.Property?\r\n instance [safe] Testable Discard\r\n  Defined in ?Test.QuickCheck.Property?\r\n instance [safe] Testable Property\r\n  Defined in ?Test.QuickCheck.Property?\r\n ...plus three others\r\n ...plus two instances involving outofscope types\r\n (use fprintpotentialinstances to see them all)\r\n ? In the first argument of ?(.)?, namely ?monadicIO?\r\n In the expression: monadicIO . (=<<) stop\r\n In an equation for ?testPropertyIO?:\r\n testPropertyIO = monadicIO . (=<<) stop\r\n}}}\r\n\r\nEither the compiler has been incorrectly accepting this as valid for a number of releases or this is a regression.","type_of_failure":"OtherFailure","blocking":[]} >Have some code:
```hs
import Test.QuickCheck
import Test.QuickCheck.Monadic
testPropertyIO :: Testable a => PropertyM IO a > Property
testPropertyIO = monadicIO . (=<<) stop
```
That compiles fine with ghc 7.10 through 8.2, but with 8.4.1 fails with:
```
test/Test/Mafia/IO.hs:18:18: error:
? Could not deduce (Testable a0) arising from a use of ?monadicIO?
from the context: Testable a
bound by the type signature for:
testPropertyIO :: forall a.
Testable a =>
PropertyM IO a > Property
at test/Test/Mafia/IO.hs:17:158
The type variable ?a0? is ambiguous
These potential instances exist:
instance [safe] Testable prop => Testable (Gen prop)
 Defined in ?Test.QuickCheck.Property?
instance [safe] Testable Discard
 Defined in ?Test.QuickCheck.Property?
instance [safe] Testable Property
 Defined in ?Test.QuickCheck.Property?
...plus three others
...plus two instances involving outofscope types
(use fprintpotentialinstances to see them all)
? In the first argument of ?(.)?, namely ?monadicIO?
In the expression: monadicIO . (=<<) stop
In an equation for ?testPropertyIO?:
testPropertyIO = monadicIO . (=<<) stop
```
Either the compiler has been incorrectly accepting this as valid for a number of releases or this is a regression.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Rgression: 8.4.1 says \"Could not deduce\" when before 8.4 it could","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Have some code:\r\n\r\n{{{#!hs\r\nimport Test.QuickCheck\r\nimport Test.QuickCheck.Monadic\r\n\r\ntestPropertyIO :: Testable a => PropertyM IO a > Property\r\ntestPropertyIO = monadicIO . (=<<) stop\r\n}}}\r\n\r\nThat compiles fine with ghc 7.10 through 8.2, but with 8.4.1 fails with:\r\n{{{\r\ntest/Test/Mafia/IO.hs:18:18: error:\r\n ? Could not deduce (Testable a0) arising from a use of ?monadicIO?\r\n from the context: Testable a\r\n bound by the type signature for:\r\n testPropertyIO :: forall a.\r\n Testable a =>\r\n PropertyM IO a > Property\r\n at test/Test/Mafia/IO.hs:17:158\r\n The type variable ?a0? is ambiguous\r\n These potential instances exist:\r\n instance [safe] Testable prop => Testable (Gen prop)\r\n  Defined in ?Test.QuickCheck.Property?\r\n instance [safe] Testable Discard\r\n  Defined in ?Test.QuickCheck.Property?\r\n instance [safe] Testable Property\r\n  Defined in ?Test.QuickCheck.Property?\r\n ...plus three others\r\n ...plus two instances involving outofscope types\r\n (use fprintpotentialinstances to see them all)\r\n ? In the first argument of ?(.)?, namely ?monadicIO?\r\n In the expression: monadicIO . (=<<) stop\r\n In an equation for ?testPropertyIO?:\r\n testPropertyIO = monadicIO . (=<<) stop\r\n}}}\r\n\r\nEither the compiler has been incorrectly accepting this as valid for a number of releases or this is a regression.","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/14991GHC HEAD regression involving TYPEs in type families20190707T18:14:46ZRyan ScottGHC HEAD regression involving TYPEs in type familiesThis program typechecks on GHC 8.2.2 and 8.4.1:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind
type family Promote (k :: Type) :: Type
type family PromoteX (a :: k) :: Promote k
type family Demote (k :: Type) :: Type
type family DemoteX (a :: k) :: Demote k

 Type

type instance Demote Type = Type
type instance Promote Type = Type
type instance DemoteX (a :: Type) = Demote a
type instance PromoteX (a :: Type) = Promote a

 Arrows

data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type instance Demote (a ~> b) = DemoteX a > DemoteX b
type instance Promote (a > b) = PromoteX a ~> PromoteX b
```
However, it fails to typecheck on GHC HEAD:
```
$ ~/Software/ghc/inplace/bin/ghcstage2 interactive Bug.hs
GHCi, version 8.5.20180401: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:34:34: error:
• Expected a type, but ‘PromoteX a’ has kind ‘Promote (TYPE t0)’
• In the first argument of ‘(~>)’, namely ‘PromoteX a’
In the type ‘PromoteX a ~> PromoteX b’
In the type instance declaration for ‘Promote’

34  type instance Promote (a > b) = PromoteX a ~> PromoteX b
 ^^^^^^^^^^
Bug.hs:34:48: error:
• Expected a type, but ‘PromoteX b’ has kind ‘Promote (TYPE t1)’
• In the second argument of ‘(~>)’, namely ‘PromoteX b’
In the type ‘PromoteX a ~> PromoteX b’
In the type instance declaration for ‘Promote’

34  type instance Promote (a > b) = PromoteX a ~> PromoteX b
 ^^^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD regression involving TYPEs in type families","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeFamilies","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This program typechecks on GHC 8.2.2 and 8.4.1:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype family Promote (k :: Type) :: Type\r\ntype family PromoteX (a :: k) :: Promote k\r\n\r\ntype family Demote (k :: Type) :: Type\r\ntype family DemoteX (a :: k) :: Demote k\r\n\r\n\r\n Type\r\n\r\n\r\ntype instance Demote Type = Type\r\ntype instance Promote Type = Type\r\n\r\ntype instance DemoteX (a :: Type) = Demote a\r\ntype instance PromoteX (a :: Type) = Promote a\r\n\r\n\r\n Arrows\r\n\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\n\r\ntype instance Demote (a ~> b) = DemoteX a > DemoteX b\r\ntype instance Promote (a > b) = PromoteX a ~> PromoteX b\r\n}}}\r\n\r\nHowever, it fails to typecheck on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 interactive Bug.hs\r\nGHCi, version 8.5.20180401: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:34:34: error:\r\n • Expected a type, but ‘PromoteX a’ has kind ‘Promote (TYPE t0)’\r\n • In the first argument of ‘(~>)’, namely ‘PromoteX a’\r\n In the type ‘PromoteX a ~> PromoteX b’\r\n In the type instance declaration for ‘Promote’\r\n \r\n34  type instance Promote (a > b) = PromoteX a ~> PromoteX b\r\n  ^^^^^^^^^^\r\n\r\nBug.hs:34:48: error:\r\n • Expected a type, but ‘PromoteX b’ has kind ‘Promote (TYPE t1)’\r\n • In the second argument of ‘(~>)’, namely ‘PromoteX b’\r\n In the type ‘PromoteX a ~> PromoteX b’\r\n In the type instance declaration for ‘Promote’\r\n \r\n34  type instance Promote (a > b) = PromoteX a ~> PromoteX b\r\n  ^^^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >This program typechecks on GHC 8.2.2 and 8.4.1:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind
type family Promote (k :: Type) :: Type
type family PromoteX (a :: k) :: Promote k
type family Demote (k :: Type) :: Type
type family DemoteX (a :: k) :: Demote k

 Type

type instance Demote Type = Type
type instance Promote Type = Type
type instance DemoteX (a :: Type) = Demote a
type instance PromoteX (a :: Type) = Promote a

 Arrows

data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type instance Demote (a ~> b) = DemoteX a > DemoteX b
type instance Promote (a > b) = PromoteX a ~> PromoteX b
```
However, it fails to typecheck on GHC HEAD:
```
$ ~/Software/ghc/inplace/bin/ghcstage2 interactive Bug.hs
GHCi, version 8.5.20180401: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:34:34: error:
• Expected a type, but ‘PromoteX a’ has kind ‘Promote (TYPE t0)’
• In the first argument of ‘(~>)’, namely ‘PromoteX a’
In the type ‘PromoteX a ~> PromoteX b’
In the type instance declaration for ‘Promote’

34  type instance Promote (a > b) = PromoteX a ~> PromoteX b
 ^^^^^^^^^^
Bug.hs:34:48: error:
• Expected a type, but ‘PromoteX b’ has kind ‘Promote (TYPE t1)’
• In the second argument of ‘(~>)’, namely ‘PromoteX b’
In the type ‘PromoteX a ~> PromoteX b’
In the type instance declaration for ‘Promote’

34  type instance Promote (a > b) = PromoteX a ~> PromoteX b
 ^^^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD regression involving TYPEs in type families","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeFamilies","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This program typechecks on GHC 8.2.2 and 8.4.1:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype family Promote (k :: Type) :: Type\r\ntype family PromoteX (a :: k) :: Promote k\r\n\r\ntype family Demote (k :: Type) :: Type\r\ntype family DemoteX (a :: k) :: Demote k\r\n\r\n\r\n Type\r\n\r\n\r\ntype instance Demote Type = Type\r\ntype instance Promote Type = Type\r\n\r\ntype instance DemoteX (a :: Type) = Demote a\r\ntype instance PromoteX (a :: Type) = Promote a\r\n\r\n\r\n Arrows\r\n\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\n\r\ntype instance Demote (a ~> b) = DemoteX a > DemoteX b\r\ntype instance Promote (a > b) = PromoteX a ~> PromoteX b\r\n}}}\r\n\r\nHowever, it fails to typecheck on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 interactive Bug.hs\r\nGHCi, version 8.5.20180401: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:34:34: error:\r\n • Expected a type, but ‘PromoteX a’ has kind ‘Promote (TYPE t0)’\r\n • In the first argument of ‘(~>)’, namely ‘PromoteX a’\r\n In the type ‘PromoteX a ~> PromoteX b’\r\n In the type instance declaration for ‘Promote’\r\n \r\n34  type instance Promote (a > b) = PromoteX a ~> PromoteX b\r\n  ^^^^^^^^^^\r\n\r\nBug.hs:34:48: error:\r\n • Expected a type, but ‘PromoteX b’ has kind ‘Promote (TYPE t1)’\r\n • In the second argument of ‘(~>)’, namely ‘PromoteX b’\r\n In the type ‘PromoteX a ~> PromoteX b’\r\n In the type instance declaration for ‘Promote’\r\n \r\n34  type instance Promote (a > b) = PromoteX a ~> PromoteX b\r\n  ^^^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc//issues/15014Exhaustivity check should suggest when COMPLETE could be helpful20190707T18:14:41ZEdward Z. YangExhaustivity check should suggest when COMPLETE could be helpful```
MacBookPro97:ghc ezyang$ cat A.hs
{# LANGUAGE PatternSynonyms #}
module A where
pattern F :: a > b > (a, b)
pattern F x y = (x, y)
g :: (a, b) > (a, b)
g (F x y) = (x, y)
MacBookPro97:ghc ezyang$ inplace/bin/ghcstage2 c A.hs Wall fforcerecomp
A.hs:8:1: warning: [Wincompletepatterns]
Pattern match(es) are nonexhaustive
In an equation for ‘g’: Patterns not matched: _

8  g (F x y) = (x, y)
 ^^^^^^^^^^^^^^^^^^
MacBookPro97:ghc ezyang$ inplace/bin/ghcstage2 version
The Glorious Glasgow Haskell Compilation System, version 8.5.20180304
```
Any time the exhaustiveness checker throws up its hands and says that `_` is not matched, we ought to give a hint that this may have occurred due to pattern synonyms, and that the author of the pattern synonyms can help out by specifying a COMPLETE pragma.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Exhaustivity check should suggest when COMPLETE could be helpful","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.4.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["PatternMatchWarnings","PatternSynonyms,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\nMacBookPro97:ghc ezyang$ cat A.hs\r\n{# LANGUAGE PatternSynonyms #}\r\nmodule A where\r\n\r\npattern F :: a > b > (a, b)\r\npattern F x y = (x, y)\r\n\r\ng :: (a, b) > (a, b)\r\ng (F x y) = (x, y)\r\nMacBookPro97:ghc ezyang$ inplace/bin/ghcstage2 c A.hs Wall fforcerecomp\r\n\r\nA.hs:8:1: warning: [Wincompletepatterns]\r\n Pattern match(es) are nonexhaustive\r\n In an equation for ‘g’: Patterns not matched: _\r\n \r\n8  g (F x y) = (x, y)\r\n  ^^^^^^^^^^^^^^^^^^\r\nMacBookPro97:ghc ezyang$ inplace/bin/ghcstage2 version\r\nThe Glorious Glasgow Haskell Compilation System, version 8.5.20180304\r\n}}}\r\n\r\nAny time the exhaustiveness checker throws up its hands and says that `_` is not matched, we ought to give a hint that this may have occurred due to pattern synonyms, and that the author of the pattern synonyms can help out by specifying a COMPLETE pragma.","type_of_failure":"OtherFailure","blocking":[]} >```
MacBookPro97:ghc ezyang$ cat A.hs
{# LANGUAGE PatternSynonyms #}
module A where
pattern F :: a > b > (a, b)
pattern F x y = (x, y)
g :: (a, b) > (a, b)
g (F x y) = (x, y)
MacBookPro97:ghc ezyang$ inplace/bin/ghcstage2 c A.hs Wall fforcerecomp
A.hs:8:1: warning: [Wincompletepatterns]
Pattern match(es) are nonexhaustive
In an equation for ‘g’: Patterns not matched: _

8  g (F x y) = (x, y)
 ^^^^^^^^^^^^^^^^^^
MacBookPro97:ghc ezyang$ inplace/bin/ghcstage2 version
The Glorious Glasgow Haskell Compilation System, version 8.5.20180304
```
Any time the exhaustiveness checker throws up its hands and says that `_` is not matched, we ought to give a hint that this may have occurred due to pattern synonyms, and that the author of the pattern synonyms can help out by specifying a COMPLETE pragma.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Exhaustivity check should suggest when COMPLETE could be helpful","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.4.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["PatternMatchWarnings","PatternSynonyms,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\nMacBookPro97:ghc ezyang$ cat A.hs\r\n{# LANGUAGE PatternSynonyms #}\r\nmodule A where\r\n\r\npattern F :: a > b > (a, b)\r\npattern F x y = (x, y)\r\n\r\ng :: (a, b) > (a, b)\r\ng (F x y) = (x, y)\r\nMacBookPro97:ghc ezyang$ inplace/bin/ghcstage2 c A.hs Wall fforcerecomp\r\n\r\nA.hs:8:1: warning: [Wincompletepatterns]\r\n Pattern match(es) are nonexhaustive\r\n In an equation for ‘g’: Patterns not matched: _\r\n \r\n8  g (F x y) = (x, y)\r\n  ^^^^^^^^^^^^^^^^^^\r\nMacBookPro97:ghc ezyang$ inplace/bin/ghcstage2 version\r\nThe Glorious Glasgow Haskell Compilation System, version 8.5.20180304\r\n}}}\r\n\r\nAny time the exhaustiveness checker throws up its hands and says that `_` is not matched, we ought to give a hint that this may have occurred due to pattern synonyms, and that the author of the pattern synonyms can help out by specifying a COMPLETE pragma.","type_of_failure":"OtherFailure","blocking":[]} >8.4.3https://gitlab.haskell.org/ghc/ghc//issues/15039Bizarre prettyprinting of inferred Coercible constraint in partial type sign...20190707T18:14:36ZRyan ScottBizarre prettyprinting of inferred Coercible constraint in partial type signatureConsider the following GHCi session:
```
$ ghci
GHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> import Data.Type.Coercion
λ> foo :: _ => Coercion a b; foo = Coercion
<interactive>:2:8: error:
• Found type wildcard ‘_’
standing for ‘Coercible a b :: TYPE ('GHC.Types.TupleRep '[])’
Where: ‘a’, ‘b’ are rigid type variables bound by
the inferred type of foo :: Coercible a b => Coercion a b
at <interactive>:2:2740
To use the inferred type, enable PartialTypeSignatures
• In the type signature: foo :: _ => Coercion a b
λ> :set fprintexplicitkinds
λ> foo :: _ => Coercion a b; foo = Coercion
<interactive>:4:8: error:
• Found type wildcard ‘_’
standing for ‘(a :: *) ~~ (b :: *) :: TYPE
('GHC.Types.TupleRep ('[] GHC.Types.RuntimeRep))’
Where: ‘a’, ‘b’ are rigid type variables bound by
the inferred type of
foo :: ((a :: *) ~~ (b :: *)) => Coercion * a b
at <interactive>:4:2740
To use the inferred type, enable PartialTypeSignatures
• In the type signature: foo :: _ => Coercion a b
```
There are two things quite strange about this:
1. In both error messages, GHC claims that `Coercible a b`/`a ~~ b` has kind `TYPE (TupleRep '[])`. This is wrong, and should be `Coercible`.
1. For some reason, enabling `fprintexplicitkinds` causes the inferred constraint to be `(~~)` instead of `Coercible`, which is just plain wrong.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Bizarre prettyprinting of inferred Coercible constraint in partial type signature","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":["PartialTypeSignatures"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following GHCi session:\r\n\r\n{{{\r\n$ ghci\r\nGHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\nλ> import Data.Type.Coercion\r\nλ> foo :: _ => Coercion a b; foo = Coercion\r\n\r\n<interactive>:2:8: error:\r\n • Found type wildcard ‘_’\r\n standing for ‘Coercible a b :: TYPE ('GHC.Types.TupleRep '[])’\r\n Where: ‘a’, ‘b’ are rigid type variables bound by\r\n the inferred type of foo :: Coercible a b => Coercion a b\r\n at <interactive>:2:2740\r\n To use the inferred type, enable PartialTypeSignatures\r\n • In the type signature: foo :: _ => Coercion a b\r\nλ> :set fprintexplicitkinds \r\nλ> foo :: _ => Coercion a b; foo = Coercion\r\n\r\n<interactive>:4:8: error:\r\n • Found type wildcard ‘_’\r\n standing for ‘(a :: *) ~~ (b :: *) :: TYPE\r\n ('GHC.Types.TupleRep ('[] GHC.Types.RuntimeRep))’\r\n Where: ‘a’, ‘b’ are rigid type variables bound by\r\n the inferred type of\r\n foo :: ((a :: *) ~~ (b :: *)) => Coercion * a b\r\n at <interactive>:4:2740\r\n To use the inferred type, enable PartialTypeSignatures\r\n • In the type signature: foo :: _ => Coercion a b\r\n}}}\r\n\r\nThere are two things quite strange about this:\r\n\r\n1. In both error messages, GHC claims that `Coercible a b`/`a ~~ b` has kind `TYPE (TupleRep '[])`. This is wrong, and should be `Coercible`.\r\n2. For some reason, enabling `fprintexplicitkinds` causes the inferred constraint to be `(~~)` instead of `Coercible`, which is just plain wrong.","type_of_failure":"OtherFailure","blocking":[]} >Consider the following GHCi session:
```
$ ghci
GHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> import Data.Type.Coercion
λ> foo :: _ => Coercion a b; foo = Coercion
<interactive>:2:8: error:
• Found type wildcard ‘_’
standing for ‘Coercible a b :: TYPE ('GHC.Types.TupleRep '[])’
Where: ‘a’, ‘b’ are rigid type variables bound by
the inferred type of foo :: Coercible a b => Coercion a b
at <interactive>:2:2740
To use the inferred type, enable PartialTypeSignatures
• In the type signature: foo :: _ => Coercion a b
λ> :set fprintexplicitkinds
λ> foo :: _ => Coercion a b; foo = Coercion
<interactive>:4:8: error:
• Found type wildcard ‘_’
standing for ‘(a :: *) ~~ (b :: *) :: TYPE
('GHC.Types.TupleRep ('[] GHC.Types.RuntimeRep))’
Where: ‘a’, ‘b’ are rigid type variables bound by
the inferred type of
foo :: ((a :: *) ~~ (b :: *)) => Coercion * a b
at <interactive>:4:2740
To use the inferred type, enable PartialTypeSignatures
• In the type signature: foo :: _ => Coercion a b
```
There are two things quite strange about this:
1. In both error messages, GHC claims that `Coercible a b`/`a ~~ b` has kind `TYPE (TupleRep '[])`. This is wrong, and should be `Coercible`.
1. For some reason, enabling `fprintexplicitkinds` causes the inferred constraint to be `(~~)` instead of `Coercible`, which is just plain wrong.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Bizarre prettyprinting of inferred Coercible constraint in partial type signature","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":["PartialTypeSignatures"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following GHCi session:\r\n\r\n{{{\r\n$ ghci\r\nGHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\nλ> import Data.Type.Coercion\r\nλ> foo :: _ => Coercion a b; foo = Coercion\r\n\r\n<interactive>:2:8: error:\r\n • Found type wildcard ‘_’\r\n standing for ‘Coercible a b :: TYPE ('GHC.Types.TupleRep '[])’\r\n Where: ‘a’, ‘b’ are rigid type variables bound by\r\n the inferred type of foo :: Coercible a b => Coercion a b\r\n at <interactive>:2:2740\r\n To use the inferred type, enable PartialTypeSignatures\r\n • In the type signature: foo :: _ => Coercion a b\r\nλ> :set fprintexplicitkinds \r\nλ> foo :: _ => Coercion a b; foo = Coercion\r\n\r\n<interactive>:4:8: error:\r\n • Found type wildcard ‘_’\r\n standing for ‘(a :: *) ~~ (b :: *) :: TYPE\r\n ('GHC.Types.TupleRep ('[] GHC.Types.RuntimeRep))’\r\n Where: ‘a’, ‘b’ are rigid type variables bound by\r\n the inferred type of\r\n foo :: ((a :: *) ~~ (b :: *)) => Coercion * a b\r\n at <interactive>:4:2740\r\n To use the inferred type, enable PartialTypeSignatures\r\n • In the type signature: foo :: _ => Coercion a b\r\n}}}\r\n\r\nThere are two things quite strange about this:\r\n\r\n1. In both error messages, GHC claims that `Coercible a b`/`a ~~ b` has kind `TYPE (TupleRep '[])`. This is wrong, and should be `Coercible`.\r\n2. For some reason, enabling `fprintexplicitkinds` causes the inferred constraint to be `(~~)` instead of `Coercible`, which is just plain wrong.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15043A more aggressive version of fprintexpandedsynonyms that prints all type s...20200123T19:20:59ZDomen KožarA more aggressive version of fprintexpandedsynonyms that prints all type synonymsUsing GHC 8.2.2 and `stack build ghcoptions=fprintexpandedsynonyms` I have the following type synonym for servant:
```hs
type Get302 (cts :: [*]) (hs :: [*]) = Verb 'GET 302 cts
(Headers (Header "Location" String ': hs) NoContent)
```
and get the following error message when `String` is mismatched for `Text`:
```
• Couldn't match type ‘Text’ with ‘[Char]’
Expected type: AsServerT App
: ("login"
:> ("callback"
:> (QueryParam "code" Text
:> (QueryParam "state" Text
:> MyApp.Types.Servant.Get302
'[PlainText]
'[Header "SetCookie" SetCookie,
Header "SetCookie" SetCookie]))))
Actual type: Maybe Code
> Maybe Text
> App
(Headers
'[Header "Location" Text, Header "SetCookie" SetCookie,
Header "SetCookie" SetCookie]
NoContent)
```
The error is confusing as type synonym is not expanded and offending `Header` is missing from the output in the expected type.Using GHC 8.2.2 and `stack build ghcoptions=fprintexpandedsynonyms` I have the following type synonym for servant:
```hs
type Get302 (cts :: [*]) (hs :: [*]) = Verb 'GET 302 cts
(Headers (Header "Location" String ': hs) NoContent)
```
and get the following error message when `String` is mismatched for `Text`:
```
• Couldn't match type ‘Text’ with ‘[Char]’
Expected type: AsServerT App
: ("login"
:> ("callback"
:> (QueryParam "code" Text
:> (QueryParam "state" Text
:> MyApp.Types.Servant.Get302
'[PlainText]
'[Header "SetCookie" SetCookie,
Header "SetCookie" SetCookie]))))
Actual type: Maybe Code
> Maybe Text
> App
(Headers
'[Header "Location" Text, Header "SetCookie" SetCookie,
Header "SetCookie" SetCookie]
NoContent)
```
The error is confusing as type synonym is not expanded and offending `Header` is missing from the output in the expected type.https://gitlab.haskell.org/ghc/ghc//issues/15047Outdated comments in RnSource.hs20190707T18:14:33ZArtem PelenitsynOutdated comments in RnSource.hsWhile reading sources of the Renamer I noticed some comments which seem to be irrelevant now.
The body of `rnSrcDecls` (`RnSource.hs`) is broken up in several “parts” (A, B, etc.). \#b1884b0e6 removed what is used to be called part (C) — the use of `extendRecordFieldEnv`, with the following comment in [D761](https://phabricator.haskell.org/D761):
> Get rid of `extendRecordFieldEnv`, do it in `getLocalNonValBinders` instead
(Note: `getLocalNonValBinders` belongs to part (B)). At the same time, the references to this part (C) remained in comments to other "parts" (B and D2). Removing these references will save inexperienced reader from confusion.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Outdated comments in RnSource.hs","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"While reading sources of the Renamer I noticed some comments which seem to be irrelevant now. \r\n\r\nThe body of `rnSrcDecls` (`RnSource.hs`) is broken up in several “parts” (A, B, etc.). #b1884b0e6 removed what is used to be called part (C) — the use of `extendRecordFieldEnv`, with the following comment in Phab:D761:\r\n\r\n> Get rid of `extendRecordFieldEnv`, do it in `getLocalNonValBinders` instead\r\n\r\n(Note: `getLocalNonValBinders` belongs to part (B)). At the same time, the references to this part (C) remained in comments to other \"parts\" (B and D2). Removing these references will save inexperienced reader from confusion.","type_of_failure":"OtherFailure","blocking":[]} >While reading sources of the Renamer I noticed some comments which seem to be irrelevant now.
The body of `rnSrcDecls` (`RnSource.hs`) is broken up in several “parts” (A, B, etc.). \#b1884b0e6 removed what is used to be called part (C) — the use of `extendRecordFieldEnv`, with the following comment in [D761](https://phabricator.haskell.org/D761):
> Get rid of `extendRecordFieldEnv`, do it in `getLocalNonValBinders` instead
(Note: `getLocalNonValBinders` belongs to part (B)). At the same time, the references to this part (C) remained in comments to other "parts" (B and D2). Removing these references will save inexperienced reader from confusion.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Outdated comments in RnSource.hs","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"While reading sources of the Renamer I noticed some comments which seem to be irrelevant now. \r\n\r\nThe body of `rnSrcDecls` (`RnSource.hs`) is broken up in several “parts” (A, B, etc.). #b1884b0e6 removed what is used to be called part (C) — the use of `extendRecordFieldEnv`, with the following comment in Phab:D761:\r\n\r\n> Get rid of `extendRecordFieldEnv`, do it in `getLocalNonValBinders` instead\r\n\r\n(Note: `getLocalNonValBinders` belongs to part (B)). At the same time, the references to this part (C) remained in comments to other \"parts\" (B and D2). Removing these references will save inexperienced reader from confusion.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15076Typed hole with higherrank kind causes GHC to panic (No skolem info)20190707T18:14:23ZRyan ScottTyped hole with higherrank kind causes GHC to panic (No skolem info)Spun out from #14040\#[ticket:15076\#comment:152359](https://gitlab.haskell.org//ghc/ghc/issues/15076#note_152359), which was different enough from the original program in #14040 to warrant its own ticket. The following program panics on every version of GHC from 8.0.2 onward:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
import Data.Proxy
foo :: forall (a :: Type)
(f :: forall (x :: a). Proxy x > Type).
Proxy f > ()
foo (_ :: _) = ()
```
```
$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:12:11: error:ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180420 for x86_64unknownlinux):
No skolem info:
[a_aZo[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:3224:5 in ghc:TcErrors
```Spun out from #14040\#[ticket:15076\#comment:152359](https://gitlab.haskell.org//ghc/ghc/issues/15076#note_152359), which was different enough from the original program in #14040 to warrant its own ticket. The following program panics on every version of GHC from 8.0.2 onward:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
import Data.Proxy
foo :: forall (a :: Type)
(f :: forall (x :: a). Proxy x > Type).
Proxy f > ()
foo (_ :: _) = ()
```
```
$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:12:11: error:ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180420 for x86_64unknownlinux):
No skolem info:
[a_aZo[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:3224:5 in ghc:TcErrors
```8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15079GHC HEAD regression: cannot instantiate higherrank kind20201031T11:08:22ZRyan ScottGHC HEAD regression: cannot instantiate higherrank kindThe following program typechecks on GHC 8.2.2 and 8.4.2:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Void
infixl 4 :==
  Heterogeneous Leibnizian equality.
newtype (a :: j) :== (b :: k)
= HRefl { hsubst :: forall (c :: forall (i :: Type). i > Type). c a > c b }
newtype Coerce a = Coerce { uncoerce :: Starify a }
type family Starify (a :: k) :: Type where
Starify (a :: Type) = a
Starify _ = Void
coerce :: a :== b > a > b
coerce f = uncoerce . hsubst f . Coerce
```
But GHC HEAD rejects it:
```
$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:21:34: error:
• Kind mismatch: cannot unify (c0 :: forall i. i > *) with:
Coerce :: forall k. k > *
Their kinds differ.
Expected type: a > c0 * a
Actual type: Starify a > Coerce a
• In the second argument of ‘(.)’, namely ‘Coerce’
In the second argument of ‘(.)’, namely ‘hsubst f . Coerce’
In the expression: uncoerce . hsubst f . Coerce

21  coerce f = uncoerce . hsubst f . Coerce
 ^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD regression: cannot instantiate higherrank kind","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.2.2 and 8.4.2:\r\n\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Void\r\n\r\ninfixl 4 :==\r\n  Heterogeneous Leibnizian equality.\r\nnewtype (a :: j) :== (b :: k)\r\n = HRefl { hsubst :: forall (c :: forall (i :: Type). i > Type). c a > c b }\r\n\r\nnewtype Coerce a = Coerce { uncoerce :: Starify a }\r\ntype family Starify (a :: k) :: Type where\r\n Starify (a :: Type) = a\r\n Starify _ = Void\r\n\r\ncoerce :: a :== b > a > b\r\ncoerce f = uncoerce . hsubst f . Coerce\r\n}}}\r\n\r\nBut GHC HEAD rejects it:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:21:34: error:\r\n • Kind mismatch: cannot unify (c0 :: forall i. i > *) with:\r\n Coerce :: forall k. k > *\r\n Their kinds differ.\r\n Expected type: a > c0 * a\r\n Actual type: Starify a > Coerce a\r\n • In the second argument of ‘(.)’, namely ‘Coerce’\r\n In the second argument of ‘(.)’, namely ‘hsubst f . Coerce’\r\n In the expression: uncoerce . hsubst f . Coerce\r\n \r\n21  coerce f = uncoerce . hsubst f . Coerce\r\n  ^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program typechecks on GHC 8.2.2 and 8.4.2:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Void
infixl 4 :==
  Heterogeneous Leibnizian equality.
newtype (a :: j) :== (b :: k)
= HRefl { hsubst :: forall (c :: forall (i :: Type). i > Type). c a > c b }
newtype Coerce a = Coerce { uncoerce :: Starify a }
type family Starify (a :: k) :: Type where
Starify (a :: Type) = a
Starify _ = Void
coerce :: a :== b > a > b
coerce f = uncoerce . hsubst f . Coerce
```
But GHC HEAD rejects it:
```
$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:21:34: error:
• Kind mismatch: cannot unify (c0 :: forall i. i > *) with:
Coerce :: forall k. k > *
Their kinds differ.
Expected type: a > c0 * a
Actual type: Starify a > Coerce a
• In the second argument of ‘(.)’, namely ‘Coerce’
In the second argument of ‘(.)’, namely ‘hsubst f . Coerce’
In the expression: uncoerce . hsubst f . Coerce

21  coerce f = uncoerce . hsubst f . Coerce
 ^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD regression: cannot instantiate higherrank kind","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.2.2 and 8.4.2:\r\n\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Void\r\n\r\ninfixl 4 :==\r\n  Heterogeneous Leibnizian equality.\r\nnewtype (a :: j) :== (b :: k)\r\n = HRefl { hsubst :: forall (c :: forall (i :: Type). i > Type). c a > c b }\r\n\r\nnewtype Coerce a = Coerce { uncoerce :: Starify a }\r\ntype family Starify (a :: k) :: Type where\r\n Starify (a :: Type) = a\r\n Starify _ = Void\r\n\r\ncoerce :: a :== b > a > b\r\ncoerce f = uncoerce . hsubst f . Coerce\r\n}}}\r\n\r\nBut GHC HEAD rejects it:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:21:34: error:\r\n • Kind mismatch: cannot unify (c0 :: forall i. i > *) with:\r\n Coerce :: forall k. k > *\r\n Their kinds differ.\r\n Expected type: a > c0 * a\r\n Actual type: Starify a > Coerce a\r\n • In the second argument of ‘(.)’, namely ‘Coerce’\r\n In the second argument of ‘(.)’, namely ‘hsubst f . Coerce’\r\n In the expression: uncoerce . hsubst f . Coerce\r\n \r\n21  coerce f = uncoerce . hsubst f . Coerce\r\n  ^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15116GHC internal error when GADT return type mentions its own constructor name20190707T18:14:11ZRyan ScottGHC internal error when GADT return type mentions its own constructor nameTake the following program:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE TypeInType #}
module Bug where
data A (a :: k) where
MkA :: A MkA
```
On GHC 8.4.2, this is rejected with a sensible error message:
```
$ /opt/ghc/8.4.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:6:12: error:
• Data constructor ‘MkA’ cannot be used here
(it is defined and used in the same recursive group)
• In the first argument of ‘A’, namely ‘MkA’
In the type ‘A MkA’
In the definition of data constructor ‘MkA’

6  MkA :: A MkA
 ^^^
```
On GHC HEAD, however, this causes a GHC internal error:
```
$ ghc2/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:6:12: error:
• GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: [asv :> Type variable ‘k’ = k :: *,
asw :> Type variable ‘a’ = a :: k,
rqs :> ATcTyCon A :: forall k. k > *]
• In the first argument of ‘A’, namely ‘MkA’
In the type ‘A MkA’
In the definition of data constructor ‘MkA’

6  MkA :: A MkA
 ^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC internal error when GADT return type mentions its own constructor name","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["GADTs,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Take the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\ndata A (a :: k) where\r\n MkA :: A MkA\r\n}}}\r\n\r\nOn GHC 8.4.2, this is rejected with a sensible error message:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:6:12: error:\r\n • Data constructor ‘MkA’ cannot be used here\r\n (it is defined and used in the same recursive group)\r\n • In the first argument of ‘A’, namely ‘MkA’\r\n In the type ‘A MkA’\r\n In the definition of data constructor ‘MkA’\r\n \r\n6  MkA :: A MkA\r\n  ^^^\r\n}}}\r\n\r\nOn GHC HEAD, however, this causes a GHC internal error:\r\n\r\n{{{\r\n$ ghc2/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:6:12: error:\r\n • GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer\r\n tcl_env of environment: [asv :> Type variable ‘k’ = k :: *,\r\n asw :> Type variable ‘a’ = a :: k,\r\n rqs :> ATcTyCon A :: forall k. k > *]\r\n • In the first argument of ‘A’, namely ‘MkA’\r\n In the type ‘A MkA’\r\n In the definition of data constructor ‘MkA’\r\n \r\n6  MkA :: A MkA\r\n  ^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >Take the following program:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE TypeInType #}
module Bug where
data A (a :: k) where
MkA :: A MkA
```
On GHC 8.4.2, this is rejected with a sensible error message:
```
$ /opt/ghc/8.4.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:6:12: error:
• Data constructor ‘MkA’ cannot be used here
(it is defined and used in the same recursive group)
• In the first argument of ‘A’, namely ‘MkA’
In the type ‘A MkA’
In the definition of data constructor ‘MkA’

6  MkA :: A MkA
 ^^^
```
On GHC HEAD, however, this causes a GHC internal error:
```
$ ghc2/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:6:12: error:
• GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: [asv :> Type variable ‘k’ = k :: *,
asw :> Type variable ‘a’ = a :: k,
rqs :> ATcTyCon A :: forall k. k > *]
• In the first argument of ‘A’, namely ‘MkA’
In the type ‘A MkA’
In the definition of data constructor ‘MkA’

6  MkA :: A MkA
 ^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC internal error when GADT return type mentions its own constructor name","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["GADTs,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Take the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\ndata A (a :: k) where\r\n MkA :: A MkA\r\n}}}\r\n\r\nOn GHC 8.4.2, this is rejected with a sensible error message:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:6:12: error:\r\n • Data constructor ‘MkA’ cannot be used here\r\n (it is defined and used in the same recursive group)\r\n • In the first argument of ‘A’, namely ‘MkA’\r\n In the type ‘A MkA’\r\n In the definition of data constructor ‘MkA’\r\n \r\n6  MkA :: A MkA\r\n  ^^^\r\n}}}\r\n\r\nOn GHC HEAD, however, this causes a GHC internal error:\r\n\r\n{{{\r\n$ ghc2/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:6:12: error:\r\n • GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer\r\n tcl_env of environment: [asv :> Type variable ‘k’ = k :: *,\r\n asw :> Type variable ‘a’ = a :: k,\r\n rqs :> ATcTyCon A :: forall k. k > *]\r\n • In the first argument of ‘A’, namely ‘MkA’\r\n In the type ‘A MkA’\r\n In the definition of data constructor ‘MkA’\r\n \r\n6  MkA :: A MkA\r\n  ^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15119Program involving existentials and type class constraint gets rejected20190707T18:14:11ZSebastian GrafProgram involving existentials and type class constraint gets rejectedThe following example from https://stackoverflow.com/a/50160423/388010 demonstrates some code involving type classes and existentials that I'd love for it to pass the type checker:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeApplications #}
module Foo where
class C a where
getInt :: Int
instance C Char where
getInt = 42
f :: (forall a. C a => Int) > Bool
f x = even (x @ Char)
g :: (forall a. C a => Int) > Bool
g = f  fails
 g h = f h  fails
 g h = f getInt  fails
 g _ = f 42  OK
```
This complains with the following error:
```
test.hs:17:5: error:
• Could not deduce (C a0)
from the context: C a
bound by a type expected by the context:
forall a. C a => Int
at test.hs:17:5
The type variable ‘a0’ is ambiguous
These potential instance exist:
instance C Char  Defined at test.hs:10:10
• In the expression: f
In an equation for ‘g’: g = f

17  g = f  fails
 ^
```
Is this expected behavior or a bug? I understand why the program leads to that particular error, but isn't there a way for the compiler to accept this?
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Program involving existentials and type class constraint gets rejected","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following example from https://stackoverflow.com/a/50160423/388010 demonstrates some code involving type classes and existentials that I'd love for it to pass the type checker:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeApplications #}\r\n\r\nmodule Foo where\r\n\r\nclass C a where\r\n getInt :: Int\r\n\r\ninstance C Char where\r\n getInt = 42\r\n\r\nf :: (forall a. C a => Int) > Bool\r\nf x = even (x @ Char)\r\n\r\ng :: (forall a. C a => Int) > Bool\r\ng = f  fails\r\n g h = f h  fails\r\n g h = f getInt  fails\r\n g _ = f 42  OK\r\n}}}\r\n\r\nThis complains with the following error:\r\n\r\n{{{\r\ntest.hs:17:5: error:\r\n • Could not deduce (C a0)\r\n from the context: C a\r\n bound by a type expected by the context:\r\n forall a. C a => Int\r\n at test.hs:17:5\r\n The type variable ‘a0’ is ambiguous\r\n These potential instance exist:\r\n instance C Char  Defined at test.hs:10:10\r\n • In the expression: f\r\n In an equation for ‘g’: g = f\r\n \r\n17  g = f  fails\r\n  ^\r\n}}}\r\n\r\nIs this expected behavior or a bug? I understand why the program leads to that particular error, but isn't there a way for the compiler to accept this?","type_of_failure":"OtherFailure","blocking":[]} >The following example from https://stackoverflow.com/a/50160423/388010 demonstrates some code involving type classes and existentials that I'd love for it to pass the type checker:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeApplications #}
module Foo where
class C a where
getInt :: Int
instance C Char where
getInt = 42
f :: (forall a. C a => Int) > Bool
f x = even (x @ Char)
g :: (forall a. C a => Int) > Bool
g = f  fails
 g h = f h  fails
 g h = f getInt  fails
 g _ = f 42  OK
```
This complains with the following error:
```
test.hs:17:5: error:
• Could not deduce (C a0)
from the context: C a
bound by a type expected by the context:
forall a. C a => Int
at test.hs:17:5
The type variable ‘a0’ is ambiguous
These potential instance exist:
instance C Char  Defined at test.hs:10:10
• In the expression: f
In an equation for ‘g’: g = f

17  g = f  fails
 ^
```
Is this expected behavior or a bug? I understand why the program leads to that particular error, but isn't there a way for the compiler to accept this?
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Program involving existentials and type class constraint gets rejected","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following example from https://stackoverflow.com/a/50160423/388010 demonstrates some code involving type classes and existentials that I'd love for it to pass the type checker:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeApplications #}\r\n\r\nmodule Foo where\r\n\r\nclass C a where\r\n getInt :: Int\r\n\r\ninstance C Char where\r\n getInt = 42\r\n\r\nf :: (forall a. C a => Int) > Bool\r\nf x = even (x @ Char)\r\n\r\ng :: (forall a. C a => Int) > Bool\r\ng = f  fails\r\n g h = f h  fails\r\n g h = f getInt  fails\r\n g _ = f 42  OK\r\n}}}\r\n\r\nThis complains with the following error:\r\n\r\n{{{\r\ntest.hs:17:5: error:\r\n • Could not deduce (C a0)\r\n from the context: C a\r\n bound by a type expected by the context:\r\n forall a. C a => Int\r\n at test.hs:17:5\r\n The type variable ‘a0’ is ambiguous\r\n These potential instance exist:\r\n instance C Char  Defined at test.hs:10:10\r\n • In the expression: f\r\n In an equation for ‘g’: g = f\r\n \r\n17  g = f  fails\r\n  ^\r\n}}}\r\n\r\nIs this expected behavior or a bug? I understand why the program leads to that particular error, but isn't there a way for the compiler to accept this?","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15122GHC HEAD typechecker regression20190707T18:14:10ZfmixingGHC HEAD typechecker regressionThis code, distilled from the `typelevelsets` library:
```hs
{# LANGUAGE FlexibleInstances #}
{# LANGUAGE GADTs #}
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
data Proxy (p :: k) = Proxy
data Set (n :: [k]) where
Empty :: Set '[]
Ext :: e > Set s > Set (e ': s)
type family (m :: [k]) :\ (x :: k) :: [k] where
'[] :\ x = '[]
(x ': xs) :\ x = xs
(y ': xs) :\ x = y ': (xs :\ x)
class Remove s t where
remove :: Set s > Proxy t > Set (s :\ t)
instance Remove '[] t where
remove Empty Proxy = Empty
instance {# OVERLAPS #} Remove (x ': xs) x where
remove (Ext _ xs) Proxy = xs
instance {# OVERLAPPABLE #} (((y : xs) :\ x) ~ (y : (xs :\ x)), Remove xs x)
=> Remove (y ': xs) x where
remove (Ext y xs) (x@Proxy) = Ext y (remove xs x)
```
Typechecks in GHC 8.4.2, but not in GHC HEAD:
```
$ /opt/ghc/head/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:31:33: error:
• Could not deduce: ((e : s) :\ x) ~ (e : (s :\ x))
from the context: (((y : xs) :\ x) ~ (y : (xs :\ x)), Remove xs x)
bound by the instance declaration at Bug.hs:(29,31)(30,27)
or from: (k ~ *, (y : xs :: [k]) ~~ (e : s :: [*]))
bound by a pattern with constructor:
Ext :: forall e (s :: [*]). e > Set s > Set (e : s),
in an equation for ‘remove’
at Bug.hs:31:1118
Expected type: Set ((y : xs) :\ x)
Actual type: Set (e : (s :\ x))
• In the expression: Ext y (remove xs x)
In an equation for ‘remove’:
remove (Ext y xs) (x@Proxy) = Ext y (remove xs x)
In the instance declaration for ‘Remove (y : xs) x’
• Relevant bindings include
x :: Proxy x (bound at Bug.hs:31:22)
xs :: Set s (bound at Bug.hs:31:17)
y :: e (bound at Bug.hs:31:15)
remove :: Set (y : xs) > Proxy x > Set ((y : xs) :\ x)
(bound at Bug.hs:31:3)

31  remove (Ext y xs) (x@Proxy) = Ext y (remove xs x)
 ^^^^^^^^^^^^^^^^^^^
```
This regression was introduced in commit e3dbb44f53b2f9403d20d84e27f187062755a089 (Fix #12919 by making the flattener homegeneous.).This code, distilled from the `typelevelsets` library:
```hs
{# LANGUAGE FlexibleInstances #}
{# LANGUAGE GADTs #}
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
data Proxy (p :: k) = Proxy
data Set (n :: [k]) where
Empty :: Set '[]
Ext :: e > Set s > Set (e ': s)
type family (m :: [k]) :\ (x :: k) :: [k] where
'[] :\ x = '[]
(x ': xs) :\ x = xs
(y ': xs) :\ x = y ': (xs :\ x)
class Remove s t where
remove :: Set s > Proxy t > Set (s :\ t)
instance Remove '[] t where
remove Empty Proxy = Empty
instance {# OVERLAPS #} Remove (x ': xs) x where
remove (Ext _ xs) Proxy = xs
instance {# OVERLAPPABLE #} (((y : xs) :\ x) ~ (y : (xs :\ x)), Remove xs x)
=> Remove (y ': xs) x where
remove (Ext y xs) (x@Proxy) = Ext y (remove xs x)
```
Typechecks in GHC 8.4.2, but not in GHC HEAD:
```
$ /opt/ghc/head/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:31:33: error:
• Could not deduce: ((e : s) :\ x) ~ (e : (s :\ x))
from the context: (((y : xs) :\ x) ~ (y : (xs :\ x)), Remove xs x)
bound by the instance declaration at Bug.hs:(29,31)(30,27)
or from: (k ~ *, (y : xs :: [k]) ~~ (e : s :: [*]))
bound by a pattern with constructor:
Ext :: forall e (s :: [*]). e > Set s > Set (e : s),
in an equation for ‘remove’
at Bug.hs:31:1118
Expected type: Set ((y : xs) :\ x)
Actual type: Set (e : (s :\ x))
• In the expression: Ext y (remove xs x)
In an equation for ‘remove’:
remove (Ext y xs) (x@Proxy) = Ext y (remove xs x)
In the instance declaration for ‘Remove (y : xs) x’
• Relevant bindings include
x :: Proxy x (bound at Bug.hs:31:22)
xs :: Set s (bound at Bug.hs:31:17)
y :: e (bound at Bug.hs:31:15)
remove :: Set (y : xs) > Proxy x > Set ((y : xs) :\ x)
(bound at Bug.hs:31:3)

31  remove (Ext y xs) (x@Proxy) = Ext y (remove xs x)
 ^^^^^^^^^^^^^^^^^^^
```
This regression was introduced in commit e3dbb44f53b2f9403d20d84e27f187062755a089 (Fix #12919 by making the flattener homegeneous.).8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15142GHC HEAD regression: tcTyVarDetails20190707T18:14:05ZRyan ScottGHC HEAD regression: tcTyVarDetailsThis regression prevents the `genericlens` library from building. Here is a minimized test case:
```hs
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
class ListTuple (tuple :: Type) (as :: [(k, Type)]) where
type ListToTuple as :: Type
```
On GHC 8.4.2, this compiles, but on GHC HEAD, it panics:
```
$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180511 for x86_64unknownlinux):
tcTyVarDetails
co_aWx :: (k_aWt[tau:2] :: *) ~# (* :: *)
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD regression: tcTyVarDetails","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeFamilies","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This regression prevents the `genericlens` library from building. Here is a minimized test case:\r\n\r\n{{{#!hs\r\n{# LANGUAGE MultiParamTypeClasses #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\nclass ListTuple (tuple :: Type) (as :: [(k, Type)]) where\r\n type ListToTuple as :: Type\r\n}}}\r\n\r\nOn GHC 8.4.2, this compiles, but on GHC HEAD, it panics:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180511 for x86_64unknownlinux):\r\n tcTyVarDetails\r\n co_aWx :: (k_aWt[tau:2] :: *) ~# (* :: *)\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable\r\n pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >This regression prevents the `genericlens` library from building. Here is a minimized test case:
```hs
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
class ListTuple (tuple :: Type) (as :: [(k, Type)]) where
type ListToTuple as :: Type
```
On GHC 8.4.2, this compiles, but on GHC HEAD, it panics:
```
$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180511 for x86_64unknownlinux):
tcTyVarDetails
co_aWx :: (k_aWt[tau:2] :: *) ~# (* :: *)
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD regression: tcTyVarDetails","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeFamilies","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This regression prevents the `genericlens` library from building. Here is a minimized test case:\r\n\r\n{{{#!hs\r\n{# LANGUAGE MultiParamTypeClasses #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\nclass ListTuple (tuple :: Type) (as :: [(k, Type)]) where\r\n type ListToTuple as :: Type\r\n}}}\r\n\r\nOn GHC 8.4.2, this compiles, but on GHC HEAD, it panics:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180511 for x86_64unknownlinux):\r\n tcTyVarDetails\r\n co_aWx :: (k_aWt[tau:2] :: *) ~# (* :: *)\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable\r\n pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc//issues/15144Type inference regression between GHC 8.0.2 and 8.2.220190707T18:14:05ZRyan ScottType inference regression between GHC 8.0.2 and 8.2.2I observed this when debugging a test case from the `HList` library that works in GHC 8.0.2, but not in GHC 8.2.2 or later. Consider the following minimized example:
```hs
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE FunctionalDependencies #}
{# LANGUAGE TypeFamilies #}
module Bug where
import Data.Coerce
import Data.Proxy
type family TagR a
class TypeIndexed r tr  r > tr, tr > r where
typeIndexed ::
(Coercible (TagR a) s, Functor f) =>
Proxy a
> (tr (TagR a) > f (tr (TagR a))) > r s > f (r s)
typeIndexed' pa x = typeIndexed pa x
```
In GHC 8.0.2, the type of `typeIndexed'` is correctly inferred as:
```
$ /opt/ghc/8.0.2/bin/ghci Bug.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Ok, modules loaded: Bug.
λ> :t typeIndexed'
typeIndexed'
:: (Coercible s (TagR a), TypeIndexed r tr, Functor f) =>
Proxy a > (tr (TagR a) > f (tr (TagR a))) > r s > f (r s)
```
In GHC 8.2.2 and later, however, the inferred type is less general:
```
$ /opt/ghc/8.4.2/bin/ghci Bug.hs
GHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Ok, one module loaded.
λ> :t typeIndexed'
typeIndexed'
:: (TypeIndexed r tr, Functor f) =>
Proxy a
> (tr (TagR a) > f (tr (TagR a))) > r (TagR a) > f (r (TagR a))
```
Notice how the `Coercible s (TagR a)` constraint is no longer inferred. Instead, it seems that GHC is inferring the less general constraint `s ~ TagR a`, since `s` has been substituted for `TagR a` in the type `r (TagR a) > f (r (TagR a))` (whereas in 8.0.2, it was `r s > f (r s)`).
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Type inference regression between GHC 8.0.2 and 8.2.2","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I observed this when debugging a test case from the `HList` library that works in GHC 8.0.2, but not in GHC 8.2.2 or later. Consider the following minimized example:\r\n\r\n{{{#!hs\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE FunctionalDependencies #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\nimport Data.Coerce\r\nimport Data.Proxy\r\n\r\ntype family TagR a\r\n\r\nclass TypeIndexed r tr  r > tr, tr > r where\r\n typeIndexed ::\r\n (Coercible (TagR a) s, Functor f) =>\r\n Proxy a\r\n > (tr (TagR a) > f (tr (TagR a))) > r s > f (r s)\r\n\r\ntypeIndexed' pa x = typeIndexed pa x\r\n}}}\r\n\r\nIn GHC 8.0.2, the type of `typeIndexed'` is correctly inferred as:\r\n\r\n{{{\r\n$ /opt/ghc/8.0.2/bin/ghci Bug.hs\r\nGHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\nOk, modules loaded: Bug.\r\nλ> :t typeIndexed'\r\ntypeIndexed'\r\n :: (Coercible s (TagR a), TypeIndexed r tr, Functor f) =>\r\n Proxy a > (tr (TagR a) > f (tr (TagR a))) > r s > f (r s)\r\n}}}\r\n\r\nIn GHC 8.2.2 and later, however, the inferred type is less general:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.2/bin/ghci Bug.hs\r\nGHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\nOk, one module loaded.\r\nλ> :t typeIndexed'\r\ntypeIndexed'\r\n :: (TypeIndexed r tr, Functor f) =>\r\n Proxy a\r\n > (tr (TagR a) > f (tr (TagR a))) > r (TagR a) > f (r (TagR a))\r\n}}}\r\n\r\nNotice how the `Coercible s (TagR a)` constraint is no longer inferred. Instead, it seems that GHC is inferring the less general constraint `s ~ TagR a`, since `s` has been substituted for `TagR a` in the type `r (TagR a) > f (r (TagR a))` (whereas in 8.0.2, it was `r s > f (r s)`).","type_of_failure":"OtherFailure","blocking":[]} >I observed this when debugging a test case from the `HList` library that works in GHC 8.0.2, but not in GHC 8.2.2 or later. Consider the following minimized example:
```hs
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE FunctionalDependencies #}
{# LANGUAGE TypeFamilies #}
module Bug where
import Data.Coerce
import Data.Proxy
type family TagR a
class TypeIndexed r tr  r > tr, tr > r where
typeIndexed ::
(Coercible (TagR a) s, Functor f) =>
Proxy a
> (tr (TagR a) > f (tr (TagR a))) > r s > f (r s)
typeIndexed' pa x = typeIndexed pa x
```
In GHC 8.0.2, the type of `typeIndexed'` is correctly inferred as:
```
$ /opt/ghc/8.0.2/bin/ghci Bug.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Ok, modules loaded: Bug.
λ> :t typeIndexed'
typeIndexed'
:: (Coercible s (TagR a), TypeIndexed r tr, Functor f) =>
Proxy a > (tr (TagR a) > f (tr (TagR a))) > r s > f (r s)
```
In GHC 8.2.2 and later, however, the inferred type is less general:
```
$ /opt/ghc/8.4.2/bin/ghci Bug.hs
GHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Ok, one module loaded.
λ> :t typeIndexed'
typeIndexed'
:: (TypeIndexed r tr, Functor f) =>
Proxy a
> (tr (TagR a) > f (tr (TagR a))) > r (TagR a) > f (r (TagR a))
```
Notice how the `Coercible s (TagR a)` constraint is no longer inferred. Instead, it seems that GHC is inferring the less general constraint `s ~ TagR a`, since `s` has been substituted for `TagR a` in the type `r (TagR a) > f (r (TagR a))` (whereas in 8.0.2, it was `r s > f (r s)`).
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.2.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Type inference regression between GHC 8.0.2 and 8.2.2","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I observed this when debugging a test case from the `HList` library that works in GHC 8.0.2, but not in GHC 8.2.2 or later. Consider the following minimized example:\r\n\r\n{{{#!hs\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE FunctionalDependencies #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\nimport Data.Coerce\r\nimport Data.Proxy\r\n\r\ntype family TagR a\r\n\r\nclass TypeIndexed r tr  r > tr, tr > r where\r\n typeIndexed ::\r\n (Coercible (TagR a) s, Functor f) =>\r\n Proxy a\r\n > (tr (TagR a) > f (tr (TagR a))) > r s > f (r s)\r\n\r\ntypeIndexed' pa x = typeIndexed pa x\r\n}}}\r\n\r\nIn GHC 8.0.2, the type of `typeIndexed'` is correctly inferred as:\r\n\r\n{{{\r\n$ /opt/ghc/8.0.2/bin/ghci Bug.hs\r\nGHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\nOk, modules loaded: Bug.\r\nλ> :t typeIndexed'\r\ntypeIndexed'\r\n :: (Coercible s (TagR a), TypeIndexed r tr, Functor f) =>\r\n Proxy a > (tr (TagR a) > f (tr (TagR a))) > r s > f (r s)\r\n}}}\r\n\r\nIn GHC 8.2.2 and later, however, the inferred type is less general:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.2/bin/ghci Bug.hs\r\nGHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\nOk, one module loaded.\r\nλ> :t typeIndexed'\r\ntypeIndexed'\r\n :: (TypeIndexed r tr, Functor f) =>\r\n Proxy a\r\n > (tr (TagR a) > f (tr (TagR a))) > r (TagR a) > f (r (TagR a))\r\n}}}\r\n\r\nNotice how the `Coercible s (TagR a)` constraint is no longer inferred. Instead, it seems that GHC is inferring the less general constraint `s ~ TagR a`, since `s` has been substituted for `TagR a` in the type `r (TagR a) > f (r (TagR a))` (whereas in 8.0.2, it was `r s > f (r s)`).","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15163non coercion variable in coVarKindsTypesRole20190707T18:13:58ZAlp Mestanogullarinon coercion variable in coVarKindsTypesRoleIt is triggered by T14732... in the `profasm` way, and only that one.
```sh
$ make fulltest TEST="T14732" THREADS=4
=====> T14732(profasm) 1 of 1 [0, 0, 0]
cd "./typecheck/should_compile/T14732.run" && "/home/alp/WT/ghcslowvalidate/inplace/test spaces/ghcstage2" c T14732.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput fnowarnincompletepatterns O prof static fprofauto
Compile failed (exit code 1) errors were:
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180511 for x86_64unknownlinux):
coVarKindsTypesRole, non coercion variable
as_atY
Vector a_a2sO
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:376:16 in ghc:Coercion
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for T14732(profasm)
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"non coercion variable in coVarKindsTypesRole","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"It is triggered by T14732... in the `profasm` way, and only that one.\r\n\r\n{{{#!sh\r\n$ make fulltest TEST=\"T14732\" THREADS=4\r\n=====> T14732(profasm) 1 of 1 [0, 0, 0]\r\ncd \"./typecheck/should_compile/T14732.run\" && \"/home/alp/WT/ghcslowvalidate/inplace/test spaces/ghcstage2\" c T14732.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput fnowarnincompletepatterns O prof static fprofauto \r\nCompile failed (exit code 1) errors were:\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180511 for x86_64unknownlinux):\r\n\tcoVarKindsTypesRole, non coercion variable\r\n as_atY\r\n Vector a_a2sO\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:376:16 in ghc:Coercion\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n\r\n*** unexpected failure for T14732(profasm)\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >It is triggered by T14732... in the `profasm` way, and only that one.
```sh
$ make fulltest TEST="T14732" THREADS=4
=====> T14732(profasm) 1 of 1 [0, 0, 0]
cd "./typecheck/should_compile/T14732.run" && "/home/alp/WT/ghcslowvalidate/inplace/test spaces/ghcstage2" c T14732.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput fnowarnincompletepatterns O prof static fprofauto
Compile failed (exit code 1) errors were:
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.5.20180511 for x86_64unknownlinux):
coVarKindsTypesRole, non coercion variable
as_atY
Vector a_a2sO
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:376:16 in ghc:Coercion
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for T14732(profasm)
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"non coercion variable in coVarKindsTypesRole","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"It is triggered by T14732... in the `profasm` way, and only that one.\r\n\r\n{{{#!sh\r\n$ make fulltest TEST=\"T14732\" THREADS=4\r\n=====> T14732(profasm) 1 of 1 [0, 0, 0]\r\ncd \"./typecheck/should_compile/T14732.run\" && \"/home/alp/WT/ghcslowvalidate/inplace/test spaces/ghcstage2\" c T14732.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput fnowarnincompletepatterns O prof static fprofauto \r\nCompile failed (exit code 1) errors were:\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180511 for x86_64unknownlinux):\r\n\tcoVarKindsTypesRole, non coercion variable\r\n as_atY\r\n Vector a_a2sO\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:376:16 in ghc:Coercion\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n\r\n*** unexpected failure for T14732(profasm)\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.4.4https://gitlab.haskell.org/ghc/ghc//issues/15170GHC HEAD panic (dischargeFmv)20190707T18:13:56ZRyan ScottGHC HEAD panic (dischargeFmv)The following program panics on GHC HEAD:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE FlexibleInstances #}
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilyDependencies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Proxy
data family Sing (a :: k)
data SomeSing :: Type > Type where
SomeSing :: Sing (a :: k) > SomeSing k
class SingKind k where
type Demote k = (r :: Type)  r > k
fromSing :: Sing (a :: k) > Demote k
toSing :: Demote k > SomeSing k
withSomeSing :: forall k r
. SingKind k
=> Demote k
> (forall (a :: k). Sing a > r)
> r
withSomeSing x f =
case toSing x of
SomeSing x' > f x'
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (f @@ t) }
instance (SingKind k1, SingKind k2) => SingKind (k1 ~> k2) where
type Demote (k1 ~> k2) = Demote k1 > Demote k2
fromSing sFun x = withSomeSing x (fromSing . applySing sFun)
toSing = undefined
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
type f @@ x = Apply f x
infixl 9 @@
dcomp :: forall (a :: Type)
(b :: a ~> Type)
(c :: forall (x :: a). Proxy x ~> b @@ x ~> Type)
(f :: forall (x :: a) (y :: b @@ x). Proxy x ~> Proxy y ~> c @@ ('Proxy :: Proxy x) @@ y)
(g :: forall (x :: a). Proxy x ~> b @@ x)
(x :: a).
SingKind (c @@ ('Proxy :: Proxy x) @@ (g @@ ('Proxy :: Proxy x)))
=> (forall (xx :: a) (yy :: b @@ xx). Sing (f @@ ('Proxy :: Proxy xx) @@ ('Proxy :: Proxy yy)))
> Sing g
> Sing a
> Demote (c @@ ('Proxy :: Proxy x) @@ (g @@ ('Proxy :: Proxy x)))
dcomp _sf _ _ = undefined
```
```
$ /opt/ghc/head/bin/ghc Bug2.hs
[1 of 1] Compiling Bug ( Bug2.hs, Bug2.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.5.20180501 for x86_64unknownlinux):
dischargeFmv
[D] _ {0}:: (Apply
(f_a1ih[sk:2] xx_a1iA[tau:3] yy_a1iB[tau:3] > Sym ((TyFun
<Proxy xx_a1iA[tau:3]>_N
((TyFun
(Proxy
(Sym {co_a1jm})
(Coh <yy_a1iB[tau:3]>_N
{co_a1jm}))_N
(Sym {co_a1jB} ; (Apply
(Sym {co_a1jm})
<*>_N
(Coh ((Coh <s_a1jn[fmv:0]>_N
((TyFun
(Sym {co_a1jm})
<*>_N)_N
>_N <*>_N) ; Sym {co_a1jA}) ; (Apply
<Proxy
xx_a1iA[tau:3]>_N
((TyFun
(Sym {co_a1jm})
<*>_N)_N
>_N <*>_N)
(Coh <c_a1ig[sk:2] xx_a1iA[tau:3]>_N
(Sym ((TyFun
<Proxy
xx_a1iA[tau:3]>_N
((TyFun
(Sym {co_a1jm})
<*>_N)_N
>_N <*>_N))_N
>_N <*>_N)))
<'Proxy>_N)_N)
(Sym ((TyFun
(Sym {co_a1jm})
<*>_N)_N
>_N <*>_N)))
(Coh <yy_a1iB[tau:3]>_N
{co_a1jm}))_N))_N
>_N <*>_N))_N
>_N <*>_N))
'Proxy :: (Proxy (yy_a1iB[tau:3] > {co_a1jm}) ~> s_a1jp[fmv:0]))
~# (s_a1jQ[fmv:0] :: (Proxy (yy_a1iB[tau:3] > {co_a1jm})
~> s_a1jp[fmv:0]))
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcSMonad.hs:3047:25 in ghc:TcSMonad
```
On GHC 8.4.2, it simply throws an error:
```
$ /opt/ghc/8.4.2/bin/ghci Bug2.hs
GHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug2.hs, interpreted )
Bug2.hs:53:71: error:
• Expected kind ‘Apply b xx’, but ‘y’ has kind ‘b @@ x’
• In the first argument of ‘Proxy’, namely ‘y’
In the first argument of ‘(~>)’, namely ‘Proxy y’
In the second argument of ‘(~>)’, namely
‘Proxy y ~> c @@ ( 'Proxy :: Proxy x) @@ y’

53  (f :: forall (x :: a) (y :: b @@ x). Proxy x ~> Proxy y ~> c @@ ('Proxy :: Proxy x) @@ y)
 ^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD panic (dischargeFmv)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics on GHC HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE FlexibleInstances #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilyDependencies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Proxy\r\n\r\ndata family Sing (a :: k)\r\ndata SomeSing :: Type > Type where\r\n SomeSing :: Sing (a :: k) > SomeSing k\r\n\r\nclass SingKind k where\r\n type Demote k = (r :: Type)  r > k\r\n fromSing :: Sing (a :: k) > Demote k\r\n toSing :: Demote k > SomeSing k\r\n\r\nwithSomeSing :: forall k r\r\n . SingKind k\r\n => Demote k\r\n > (forall (a :: k). Sing a > r)\r\n > r\r\nwithSomeSing x f =\r\n case toSing x of\r\n SomeSing x' > f x'\r\n\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (f @@ t) }\r\n\r\ninstance (SingKind k1, SingKind k2) => SingKind (k1 ~> k2) where\r\n type Demote (k1 ~> k2) = Demote k1 > Demote k2\r\n fromSing sFun x = withSomeSing x (fromSing . applySing sFun)\r\n toSing = undefined\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\n\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\ntype f @@ x = Apply f x\r\ninfixl 9 @@\r\n\r\ndcomp :: forall (a :: Type)\r\n (b :: a ~> Type)\r\n (c :: forall (x :: a). Proxy x ~> b @@ x ~> Type)\r\n (f :: forall (x :: a) (y :: b @@ x). Proxy x ~> Proxy y ~> c @@ ('Proxy :: Proxy x) @@ y)\r\n (g :: forall (x :: a). Proxy x ~> b @@ x)\r\n (x :: a).\r\n SingKind (c @@ ('Proxy :: Proxy x) @@ (g @@ ('Proxy :: Proxy x)))\r\n => (forall (xx :: a) (yy :: b @@ xx). Sing (f @@ ('Proxy :: Proxy xx) @@ ('Proxy :: Proxy yy)))\r\n > Sing g\r\n > Sing a\r\n > Demote (c @@ ('Proxy :: Proxy x) @@ (g @@ ('Proxy :: Proxy x)))\r\ndcomp _sf _ _ = undefined\r\n}}}\r\n{{{\r\n$ /opt/ghc/head/bin/ghc Bug2.hs\r\n[1 of 1] Compiling Bug ( Bug2.hs, Bug2.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180501 for x86_64unknownlinux):\r\n dischargeFmv\r\n [D] _ {0}:: (Apply\r\n (f_a1ih[sk:2] xx_a1iA[tau:3] yy_a1iB[tau:3] > Sym ((TyFun\r\n <Proxy xx_a1iA[tau:3]>_N\r\n ((TyFun\r\n (Proxy\r\n (Sym {co_a1jm})\r\n (Coh <yy_a1iB[tau:3]>_N\r\n {co_a1jm}))_N\r\n (Sym {co_a1jB} ; (Apply\r\n (Sym {co_a1jm})\r\n <*>_N\r\n (Coh ((Coh <s_a1jn[fmv:0]>_N\r\n ((TyFun\r\n (Sym {co_a1jm})\r\n <*>_N)_N\r\n >_N <*>_N) ; Sym {co_a1jA}) ; (Apply\r\n <Proxy\r\n xx_a1iA[tau:3]>_N\r\n ((TyFun\r\n (Sym {co_a1jm})\r\n <*>_N)_N\r\n >_N <*>_N)\r\n (Coh <c_a1ig[sk:2] xx_a1iA[tau:3]>_N\r\n (Sym ((TyFun\r\n <Proxy\r\n xx_a1iA[tau:3]>_N\r\n ((TyFun\r\n (Sym {co_a1jm})\r\n <*>_N)_N\r\n >_N <*>_N))_N\r\n >_N <*>_N)))\r\n <'Proxy>_N)_N)\r\n (Sym ((TyFun\r\n (Sym {co_a1jm})\r\n <*>_N)_N\r\n >_N <*>_N)))\r\n (Coh <yy_a1iB[tau:3]>_N\r\n {co_a1jm}))_N))_N\r\n >_N <*>_N))_N\r\n >_N <*>_N))\r\n 'Proxy :: (Proxy (yy_a1iB[tau:3] > {co_a1jm}) ~> s_a1jp[fmv:0]))\r\n ~# (s_a1jQ[fmv:0] :: (Proxy (yy_a1iB[tau:3] > {co_a1jm})\r\n ~> s_a1jp[fmv:0]))\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcSMonad.hs:3047:25 in ghc:TcSMonad\r\n}}}\r\n\r\nOn GHC 8.4.2, it simply throws an error:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.2/bin/ghci Bug2.hs\r\nGHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug2.hs, interpreted )\r\n\r\nBug2.hs:53:71: error:\r\n • Expected kind ‘Apply b xx’, but ‘y’ has kind ‘b @@ x’\r\n • In the first argument of ‘Proxy’, namely ‘y’\r\n In the first argument of ‘(~>)’, namely ‘Proxy y’\r\n In the second argument of ‘(~>)’, namely\r\n ‘Proxy y ~> c @@ ( 'Proxy :: Proxy x) @@ y’\r\n \r\n53  (f :: forall (x :: a) (y :: b @@ x). Proxy x ~> Proxy y ~> c @@ ('Proxy :: Proxy x) @@ y)\r\n  ^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program panics on GHC HEAD:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE FlexibleInstances #}
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilyDependencies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Proxy
data family Sing (a :: k)
data SomeSing :: Type > Type where
SomeSing :: Sing (a :: k) > SomeSing k
class SingKind k where
type Demote k = (r :: Type)  r > k
fromSing :: Sing (a :: k) > Demote k
toSing :: Demote k > SomeSing k
withSomeSing :: forall k r
. SingKind k
=> Demote k
> (forall (a :: k). Sing a > r)
> r
withSomeSing x f =
case toSing x of
SomeSing x' > f x'
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (f @@ t) }
instance (SingKind k1, SingKind k2) => SingKind (k1 ~> k2) where
type Demote (k1 ~> k2) = Demote k1 > Demote k2
fromSing sFun x = withSomeSing x (fromSing . applySing sFun)
toSing = undefined
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
type f @@ x = Apply f x
infixl 9 @@
dcomp :: forall (a :: Type)
(b :: a ~> Type)
(c :: forall (x :: a). Proxy x ~> b @@ x ~> Type)
(f :: forall (x :: a) (y :: b @@ x). Proxy x ~> Proxy y ~> c @@ ('Proxy :: Proxy x) @@ y)
(g :: forall (x :: a). Proxy x ~> b @@ x)
(x :: a).
SingKind (c @@ ('Proxy :: Proxy x) @@ (g @@ ('Proxy :: Proxy x)))
=> (forall (xx :: a) (yy :: b @@ xx). Sing (f @@ ('Proxy :: Proxy xx) @@ ('Proxy :: Proxy yy)))
> Sing g
> Sing a
> Demote (c @@ ('Proxy :: Proxy x) @@ (g @@ ('Proxy :: Proxy x)))
dcomp _sf _ _ = undefined
```
```
$ /opt/ghc/head/bin/ghc Bug2.hs
[1 of 1] Compiling Bug ( Bug2.hs, Bug2.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.5.20180501 for x86_64unknownlinux):
dischargeFmv
[D] _ {0}:: (Apply
(f_a1ih[sk:2] xx_a1iA[tau:3] yy_a1iB[tau:3] > Sym ((TyFun
<Proxy xx_a1iA[tau:3]>_N
((TyFun
(Proxy
(Sym {co_a1jm})
(Coh <yy_a1iB[tau:3]>_N
{co_a1jm}))_N
(Sym {co_a1jB} ; (Apply
(Sym {co_a1jm})
<*>_N
(Coh ((Coh <s_a1jn[fmv:0]>_N
((TyFun
(Sym {co_a1jm})
<*>_N)_N
>_N <*>_N) ; Sym {co_a1jA}) ; (Apply
<Proxy
xx_a1iA[tau:3]>_N
((TyFun
(Sym {co_a1jm})
<*>_N)_N
>_N <*>_N)
(Coh <c_a1ig[sk:2] xx_a1iA[tau:3]>_N
(Sym ((TyFun
<Proxy
xx_a1iA[tau:3]>_N
((TyFun
(Sym {co_a1jm})
<*>_N)_N
>_N <*>_N))_N
>_N <*>_N)))
<'Proxy>_N)_N)
(Sym ((TyFun
(Sym {co_a1jm})
<*>_N)_N
>_N <*>_N)))
(Coh <yy_a1iB[tau:3]>_N
{co_a1jm}))_N))_N
>_N <*>_N))_N
>_N <*>_N))
'Proxy :: (Proxy (yy_a1iB[tau:3] > {co_a1jm}) ~> s_a1jp[fmv:0]))
~# (s_a1jQ[fmv:0] :: (Proxy (yy_a1iB[tau:3] > {co_a1jm})
~> s_a1jp[fmv:0]))
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcSMonad.hs:3047:25 in ghc:TcSMonad
```
On GHC 8.4.2, it simply throws an error:
```
$ /opt/ghc/8.4.2/bin/ghci Bug2.hs
GHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug2.hs, interpreted )
Bug2.hs:53:71: error:
• Expected kind ‘Apply b xx’, but ‘y’ has kind ‘b @@ x’
• In the first argument of ‘Proxy’, namely ‘y’
In the first argument of ‘(~>)’, namely ‘Proxy y’
In the second argument of ‘(~>)’, namely
‘Proxy y ~> c @@ ( 'Proxy :: Proxy x) @@ y’

53  (f :: forall (x :: a) (y :: b @@ x). Proxy x ~> Proxy y ~> c @@ ('Proxy :: Proxy x) @@ y)
 ^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD panic (dischargeFmv)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics on GHC HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE FlexibleInstances #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilyDependencies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Proxy\r\n\r\ndata family Sing (a :: k)\r\ndata SomeSing :: Type > Type where\r\n SomeSing :: Sing (a :: k) > SomeSing k\r\n\r\nclass SingKind k where\r\n type Demote k = (r :: Type)  r > k\r\n fromSing :: Sing (a :: k) > Demote k\r\n toSing :: Demote k > SomeSing k\r\n\r\nwithSomeSing :: forall k r\r\n . SingKind k\r\n => Demote k\r\n > (forall (a :: k). Sing a > r)\r\n > r\r\nwithSomeSing x f =\r\n case toSing x of\r\n SomeSing x' > f x'\r\n\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (f @@ t) }\r\n\r\ninstance (SingKind k1, SingKind k2) => SingKind (k1 ~> k2) where\r\n type Demote (k1 ~> k2) = Demote k1 > Demote k2\r\n fromSing sFun x = withSomeSing x (fromSing . applySing sFun)\r\n toSing = undefined\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\n\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\ntype f @@ x = Apply f x\r\ninfixl 9 @@\r\n\r\ndcomp :: forall (a :: Type)\r\n (b :: a ~> Type)\r\n (c :: forall (x :: a). Proxy x ~> b @@ x ~> Type)\r\n (f :: forall (x :: a) (y :: b @@ x). Proxy x ~> Proxy y ~> c @@ ('Proxy :: Proxy x) @@ y)\r\n (g :: forall (x :: a). Proxy x ~> b @@ x)\r\n (x :: a).\r\n SingKind (c @@ ('Proxy :: Proxy x) @@ (g @@ ('Proxy :: Proxy x)))\r\n => (forall (xx :: a) (yy :: b @@ xx). Sing (f @@ ('Proxy :: Proxy xx) @@ ('Proxy :: Proxy yy)))\r\n > Sing g\r\n > Sing a\r\n > Demote (c @@ ('Proxy :: Proxy x) @@ (g @@ ('Proxy :: Proxy x)))\r\ndcomp _sf _ _ = undefined\r\n}}}\r\n{{{\r\n$ /opt/ghc/head/bin/ghc Bug2.hs\r\n[1 of 1] Compiling Bug ( Bug2.hs, Bug2.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180501 for x86_64unknownlinux):\r\n dischargeFmv\r\n [D] _ {0}:: (Apply\r\n (f_a1ih[sk:2] xx_a1iA[tau:3] yy_a1iB[tau:3] > Sym ((TyFun\r\n <Proxy xx_a1iA[tau:3]>_N\r\n ((TyFun\r\n (Proxy\r\n (Sym {co_a1jm})\r\n (Coh <yy_a1iB[tau:3]>_N\r\n {co_a1jm}))_N\r\n (Sym {co_a1jB} ; (Apply\r\n (Sym {co_a1jm})\r\n <*>_N\r\n (Coh ((Coh <s_a1jn[fmv:0]>_N\r\n ((TyFun\r\n (Sym {co_a1jm})\r\n <*>_N)_N\r\n >_N <*>_N) ; Sym {co_a1jA}) ; (Apply\r\n <Proxy\r\n xx_a1iA[tau:3]>_N\r\n ((TyFun\r\n (Sym {co_a1jm})\r\n <*>_N)_N\r\n >_N <*>_N)\r\n (Coh <c_a1ig[sk:2] xx_a1iA[tau:3]>_N\r\n (Sym ((TyFun\r\n <Proxy\r\n xx_a1iA[tau:3]>_N\r\n ((TyFun\r\n (Sym {co_a1jm})\r\n <*>_N)_N\r\n >_N <*>_N))_N\r\n >_N <*>_N)))\r\n <'Proxy>_N)_N)\r\n (Sym ((TyFun\r\n (Sym {co_a1jm})\r\n <*>_N)_N\r\n >_N <*>_N)))\r\n (Coh <yy_a1iB[tau:3]>_N\r\n {co_a1jm}))_N))_N\r\n >_N <*>_N))_N\r\n >_N <*>_N))\r\n 'Proxy :: (Proxy (yy_a1iB[tau:3] > {co_a1jm}) ~> s_a1jp[fmv:0]))\r\n ~# (s_a1jQ[fmv:0] :: (Proxy (yy_a1iB[tau:3] > {co_a1jm})\r\n ~> s_a1jp[fmv:0]))\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcSMonad.hs:3047:25 in ghc:TcSMonad\r\n}}}\r\n\r\nOn GHC 8.4.2, it simply throws an error:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.2/bin/ghci Bug2.hs\r\nGHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug2.hs, interpreted )\r\n\r\nBug2.hs:53:71: error:\r\n • Expected kind ‘Apply b xx’, but ‘y’ has kind ‘b @@ x’\r\n • In the first argument of ‘Proxy’, namely ‘y’\r\n In the first argument of ‘(~>)’, namely ‘Proxy y’\r\n In the second argument of ‘(~>)’, namely\r\n ‘Proxy y ~> c @@ ( 'Proxy :: Proxy x) @@ y’\r\n \r\n53  (f :: forall (x :: a) (y :: b @@ x). Proxy x ~> Proxy y ~> c @@ ('Proxy :: Proxy x) @@ y)\r\n  ^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15202Internal error showing typed hole in GHCi20190707T18:13:49ZDavid FeuerInternal error showing typed hole in GHCiRun `ghc interactive`, and at the prompt type
```hs
default ()
fish :: Eq a => a; fish = undefined
foo :: String; foo = show _
```
The following error appears:
```
<interactive>:1:1: error:
GHC internal error: ‘Ghci1.$trModule’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: [r2CZ :> Identifier[foo::String, TopLevelLet]]
```
I have not yet been able to reproduce this loading a module; it seems to need to be on the command line.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Internal error showing typed hole in GHCi","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypedHoles"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Run `ghc interactive`, and at the prompt type\r\n\r\n{{{#!hs\r\ndefault ()\r\nfish :: Eq a => a; fish = undefined\r\nfoo :: String; foo = show _\r\n}}}\r\n\r\nThe following error appears:\r\n\r\n{{{\r\n<interactive>:1:1: error:\r\n GHC internal error: ‘Ghci1.$trModule’ is not in scope during type checking, but it passed the renamer\r\n tcl_env of environment: [r2CZ :> Identifier[foo::String, TopLevelLet]]\r\n}}}\r\n\r\nI have not yet been able to reproduce this loading a module; it seems to need to be on the command line.","type_of_failure":"OtherFailure","blocking":[]} >Run `ghc interactive`, and at the prompt type
```hs
default ()
fish :: Eq a => a; fish = undefined
foo :: String; foo = show _
```
The following error appears:
```
<interactive>:1:1: error:
GHC internal error: ‘Ghci1.$trModule’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: [r2CZ :> Identifier[foo::String, TopLevelLet]]
```
I have not yet been able to reproduce this loading a module; it seems to need to be on the command line.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Internal error showing typed hole in GHCi","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypedHoles"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Run `ghc interactive`, and at the prompt type\r\n\r\n{{{#!hs\r\ndefault ()\r\nfish :: Eq a => a; fish = undefined\r\nfoo :: String; foo = show _\r\n}}}\r\n\r\nThe following error appears:\r\n\r\n{{{\r\n<interactive>:1:1: error:\r\n GHC internal error: ‘Ghci1.$trModule’ is not in scope during type checking, but it passed the renamer\r\n tcl_env of environment: [r2CZ :> Identifier[foo::String, TopLevelLet]]\r\n}}}\r\n\r\nI have not yet been able to reproduce this loading a module; it seems to need to be on the command line.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15215GHC HEAD internal error when FlexibleContexts isn't enabled20190707T18:13:45ZRyan ScottGHC HEAD internal error when FlexibleContexts isn't enabledThe following code produces a GHC internal error on GHC HEAD:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
data A :: Type > Type where
MkA :: Show (Maybe a) => A a
data SA :: forall a. A a > Type where
SMkA :: SA MkA
```
```
$ ~/Software/ghc5/inplace/bin/ghcstage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:9:3: error:
• Non typevariable argument in the constraint: Show (Maybe a)
(Use FlexibleContexts to permit this)
• In the definition of data constructor ‘MkA’
In the data type declaration for ‘A’

9  MkA :: Show (Maybe a) => A a
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:12:14: error:
• GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: [rqU :> ATcTyCon SA :: forall a. A a > *,
rsV :> APromotionErr RecDataConPE]
• In the first argument of ‘SA’, namely ‘MkA’
In the type ‘SA MkA’
In the definition of data constructor ‘SMkA’

12  SMkA :: SA MkA
 ^^^
```
Enabling `FlexibleContexts` causes the internal error to go away.
This is a regression from GHC 8.4, which does not give an internal error.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD internal error when FlexibleContexts isn't enabled","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code produces a GHC internal error on GHC HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata A :: Type > Type where\r\n MkA :: Show (Maybe a) => A a\r\n\r\ndata SA :: forall a. A a > Type where\r\n SMkA :: SA MkA\r\n}}}\r\n{{{\r\n$ ~/Software/ghc5/inplace/bin/ghcstage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:9:3: error:\r\n • Non typevariable argument in the constraint: Show (Maybe a)\r\n (Use FlexibleContexts to permit this)\r\n • In the definition of data constructor ‘MkA’\r\n In the data type declaration for ‘A’\r\n \r\n9  MkA :: Show (Maybe a) => A a\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:12:14: error:\r\n • GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer\r\n tcl_env of environment: [rqU :> ATcTyCon SA :: forall a. A a > *,\r\n rsV :> APromotionErr RecDataConPE]\r\n • In the first argument of ‘SA’, namely ‘MkA’\r\n In the type ‘SA MkA’\r\n In the definition of data constructor ‘SMkA’\r\n \r\n12  SMkA :: SA MkA\r\n  ^^^\r\n}}}\r\n\r\nEnabling `FlexibleContexts` causes the internal error to go away.\r\n\r\nThis is a regression from GHC 8.4, which does not give an internal error.","type_of_failure":"OtherFailure","blocking":[]} >The following code produces a GHC internal error on GHC HEAD:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
data A :: Type > Type where
MkA :: Show (Maybe a) => A a
data SA :: forall a. A a > Type where
SMkA :: SA MkA
```
```
$ ~/Software/ghc5/inplace/bin/ghcstage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:9:3: error:
• Non typevariable argument in the constraint: Show (Maybe a)
(Use FlexibleContexts to permit this)
• In the definition of data constructor ‘MkA’
In the data type declaration for ‘A’

9  MkA :: Show (Maybe a) => A a
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:12:14: error:
• GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: [rqU :> ATcTyCon SA :: forall a. A a > *,
rsV :> APromotionErr RecDataConPE]
• In the first argument of ‘SA’, namely ‘MkA’
In the type ‘SA MkA’
In the definition of data constructor ‘SMkA’

12  SMkA :: SA MkA
 ^^^
```
Enabling `FlexibleContexts` causes the internal error to go away.
This is a regression from GHC 8.4, which does not give an internal error.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD internal error when FlexibleContexts isn't enabled","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code produces a GHC internal error on GHC HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata A :: Type > Type where\r\n MkA :: Show (Maybe a) => A a\r\n\r\ndata SA :: forall a. A a > Type where\r\n SMkA :: SA MkA\r\n}}}\r\n{{{\r\n$ ~/Software/ghc5/inplace/bin/ghcstage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:9:3: error:\r\n • Non typevariable argument in the constraint: Show (Maybe a)\r\n (Use FlexibleContexts to permit this)\r\n • In the definition of data constructor ‘MkA’\r\n In the data type declaration for ‘A’\r\n \r\n9  MkA :: Show (Maybe a) => A a\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:12:14: error:\r\n • GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer\r\n tcl_env of environment: [rqU :> ATcTyCon SA :: forall a. A a > *,\r\n rsV :> APromotionErr RecDataConPE]\r\n • In the first argument of ‘SA’, namely ‘MkA’\r\n In the type ‘SA MkA’\r\n In the definition of data constructor ‘SMkA’\r\n \r\n12  SMkA :: SA MkA\r\n  ^^^\r\n}}}\r\n\r\nEnabling `FlexibleContexts` causes the internal error to go away.\r\n\r\nThis is a regression from GHC 8.4, which does not give an internal error.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15231UndecidableInstances validity checking is wrong in the presence of Quantified...20190707T18:13:42ZRyan ScottUndecidableInstances validity checking is wrong in the presence of QuantifiedConstraintsConsider this program:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE GADTs #}
{# LANGUAGE KindSignatures #}
{# LANGUAGE QuantifiedConstraints #}
module Bug where
import Data.Kind
data ECC :: Constraint > Type > Type
class Y a
class Z a
instance c => Y (ECC c a)
instance (c => Z a) => Z (ECC c a)
```
I would expect both of these instances to work. But while GHC accepts the `Y` instance, it rejects the `Z` instance:
```
$ ~/Software/ghc5/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:10: error:
• Variable ‘c’ occurs more often
in the constraint ‘c’ than in the instance head
(Use UndecidableInstances to permit this)
• In the instance declaration for ‘Z (ECC c a)’

15  instance (c => Z a) => Z (ECC c a)
 ^^^^^^^^^^^^^^^^^^^^^^^^^
```
That error message seems completely bogus to me, since `c` appears once in both the context and instance head in both instances.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"UndecidableInstances validity checking is wrong in the presence of QuantifiedConstraints","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["QuantifiedConstraints"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE KindSignatures #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata ECC :: Constraint > Type > Type\r\n\r\nclass Y a\r\nclass Z a\r\n\r\ninstance c => Y (ECC c a)\r\ninstance (c => Z a) => Z (ECC c a)\r\n}}}\r\n\r\nI would expect both of these instances to work. But while GHC accepts the `Y` instance, it rejects the `Z` instance:\r\n\r\n{{{\r\n$ ~/Software/ghc5/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:10: error:\r\n • Variable ‘c’ occurs more often\r\n in the constraint ‘c’ than in the instance head\r\n (Use UndecidableInstances to permit this)\r\n • In the instance declaration for ‘Z (ECC c a)’\r\n \r\n15  instance (c => Z a) => Z (ECC c a)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nThat error message seems completely bogus to me, since `c` appears once in both the context and instance head in both instances.","type_of_failure":"OtherFailure","blocking":[]} >Consider this program:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE GADTs #}
{# LANGUAGE KindSignatures #}
{# LANGUAGE QuantifiedConstraints #}
module Bug where
import Data.Kind
data ECC :: Constraint > Type > Type
class Y a
class Z a
instance c => Y (ECC c a)
instance (c => Z a) => Z (ECC c a)
```
I would expect both of these instances to work. But while GHC accepts the `Y` instance, it rejects the `Z` instance:
```
$ ~/Software/ghc5/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:10: error:
• Variable ‘c’ occurs more often
in the constraint ‘c’ than in the instance head
(Use UndecidableInstances to permit this)
• In the instance declaration for ‘Z (ECC c a)’

15  instance (c => Z a) => Z (ECC c a)
 ^^^^^^^^^^^^^^^^^^^^^^^^^
```
That error message seems completely bogus to me, since `c` appears once in both the context and instance head in both instances.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"UndecidableInstances validity checking is wrong in the presence of QuantifiedConstraints","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["QuantifiedConstraints"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE KindSignatures #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata ECC :: Constraint > Type > Type\r\n\r\nclass Y a\r\nclass Z a\r\n\r\ninstance c => Y (ECC c a)\r\ninstance (c => Z a) => Z (ECC c a)\r\n}}}\r\n\r\nI would expect both of these instances to work. But while GHC accepts the `Y` instance, it rejects the `Z` instance:\r\n\r\n{{{\r\n$ ~/Software/ghc5/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:10: error:\r\n • Variable ‘c’ occurs more often\r\n in the constraint ‘c’ than in the instance head\r\n (Use UndecidableInstances to permit this)\r\n • In the instance declaration for ‘Z (ECC c a)’\r\n \r\n15  instance (c => Z a) => Z (ECC c a)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nThat error message seems completely bogus to me, since `c` appears once in both the context and instance head in both instances.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15242Typechecker sometimes doesn't preserve HsPar in original source.20190707T18:13:38ZZubinTypechecker sometimes doesn't preserve HsPar in original source.The typechecker doesn't preserve parenthesis that occur at the head of applications.
This results in some weird SrcSpans in the TypecheckedSource
For example, given code
```hs
foo a b c = (bar a) b c
```
The typechecker will emit an HsApp with head spanning over `bar a) b` and tail spanning over `c`.
Notice that the opening parenthesis is not included.
On the other hand, the renamer will generate the expected SrcSpans that always include both parenthesis, or neither. This becomes an issue when you want to associate RenamedSource with its corresponding TypecheckedSource, as the SrcSpans no longer match and overlap partially.
This occurs due to this line in TcExpr.hs
```hs
tcApp m_herald (L _ (HsPar _ fun)) args res_ty
= tcApp m_herald fun args res_ty
```
I have a work in progress fix here: https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  alanz, bgamari, gbaz 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Typechecker sometimes doesn't preserve HsPar in original source.","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["alanz","bgamari","gbaz"],"type":"Bug","description":"The typechecker doesn't preserve parenthesis that occur at the head of applications.\r\n\r\nThis results in some weird SrcSpans in the TypecheckedSource\r\n\r\nFor example, given code\r\n\r\n{{{#!hs\r\nfoo a b c = (bar a) b c\r\n}}}\r\n\r\nThe typechecker will emit an HsApp with head spanning over `bar a) b` and tail spanning over `c`.\r\nNotice that the opening parenthesis is not included.\r\n\r\nOn the other hand, the renamer will generate the expected SrcSpans that always include both parenthesis, or neither. This becomes an issue when you want to associate RenamedSource with its corresponding TypecheckedSource, as the SrcSpans no longer match and overlap partially.\r\n\r\nThis occurs due to this line in TcExpr.hs\r\n\r\n{{{#!hs\r\ntcApp m_herald (L _ (HsPar _ fun)) args res_ty\r\n = tcApp m_herald fun args res_ty\r\n}}}\r\n\r\nI have a work in progress fix here: https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a","type_of_failure":"OtherFailure","blocking":[]} >The typechecker doesn't preserve parenthesis that occur at the head of applications.
This results in some weird SrcSpans in the TypecheckedSource
For example, given code
```hs
foo a b c = (bar a) b c
```
The typechecker will emit an HsApp with head spanning over `bar a) b` and tail spanning over `c`.
Notice that the opening parenthesis is not included.
On the other hand, the renamer will generate the expected SrcSpans that always include both parenthesis, or neither. This becomes an issue when you want to associate RenamedSource with its corresponding TypecheckedSource, as the SrcSpans no longer match and overlap partially.
This occurs due to this line in TcExpr.hs
```hs
tcApp m_herald (L _ (HsPar _ fun)) args res_ty
= tcApp m_herald fun args res_ty
```
I have a work in progress fix here: https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  alanz, bgamari, gbaz 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Typechecker sometimes doesn't preserve HsPar in original source.","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["alanz","bgamari","gbaz"],"type":"Bug","description":"The typechecker doesn't preserve parenthesis that occur at the head of applications.\r\n\r\nThis results in some weird SrcSpans in the TypecheckedSource\r\n\r\nFor example, given code\r\n\r\n{{{#!hs\r\nfoo a b c = (bar a) b c\r\n}}}\r\n\r\nThe typechecker will emit an HsApp with head spanning over `bar a) b` and tail spanning over `c`.\r\nNotice that the opening parenthesis is not included.\r\n\r\nOn the other hand, the renamer will generate the expected SrcSpans that always include both parenthesis, or neither. This becomes an issue when you want to associate RenamedSource with its corresponding TypecheckedSource, as the SrcSpans no longer match and overlap partially.\r\n\r\nThis occurs due to this line in TcExpr.hs\r\n\r\n{{{#!hs\r\ntcApp m_herald (L _ (HsPar _ fun)) args res_ty\r\n = tcApp m_herald fun args res_ty\r\n}}}\r\n\r\nI have a work in progress fix here: https://github.com/wz1000/ghc/commit/3b6db5a35dc8677a7187e349a85ffd51f452452a","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15245Data family promotion is possible20190707T18:13:38ZVladislav ZavialovData family promotion is possibleThe User's Guide states that data families cannot be promoted, even with `XTypeInType`:
> We promote data types and newtypes; type synonyms and type/data families are not promoted.
>
> The flag TypeInType (which implies DataKinds) relaxes some of these restrictions, allowing:
>
> Promotion of type synonyms and type families, but not data families. GHC’s type theory just isn’t up to the task of promoting data families, which requires full dependent types.
And yet the following code typechecks and runs:
```hs
{# LANGUAGE TypeFamilies, TypeInType, TypeApplications #}
import Type.Reflection
data family K
data instance K = MkK
main = print (typeRep @'MkK)
```
Is this a GHC bug or a documentation bug? I asked in IRC but I'm still confused:
```
<intindex> The user guide states that data families aren't promoted even when XTypeInType is enabled. Where's the logic that ensures this? I checked with `data family K; data instance K = MkK` and I can use `'MkK` with no errors/warnings.
<intindex> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#overview "Promotion of type synonyms and type families, but not data families. GHC’s type theory just isn’t up to the task of promoting data families, which requires full dependent types."
<intindex> Is this info outdated?
<RyanGlScott> intindex: Is this in GHCi?
<RyanGlScott> It certainly fails in GHC
<RyanGlScott> But I think I understand why the former works
<intindex> RyanGlScott, yes, I'm checking this in GHCi
<RyanGlScott> intindex: So here's my understanding of how this works
<RyanGlScott> GHC kindchecks toplevel declarations using a rather primitive SCC analysis
<RyanGlScott> In particular, it's primitive in the sense that data family instances give it a lot of trouble
<RyanGlScott> If you tried taking your code and putting it into a standalone .hs file and compiling that, then it would definitely complain about a promoted use of MkT
<RyanGlScott> As luck would have it, though, you were trying things out in GHCi
<RyanGlScott> Which essentially checks each line of input as its own strongly connected group of declarations
<RyanGlScott> So you can define MkT on one line and promote it in subsequent lines, since they're separate in the sense
<RyanGlScott> *that sense
<intindex> this sounds related to Trac #12088, and then I could work around it in GHC by using `$(return [])`, so data families are actually promoted anyway and this has nothing to do with GHC needing more powerful type theory
<RyanGlScott> Well, it does need more powerful type theory in the sense that that's a prerequisite for making the SCC analysis for kindchecking sophisticated enough to handle this
<RyanGlScott> But yes, it's quite simple to work around by using Template Haskell to explicitly split up groups.
<intindex> https://gist.github.com/intindex/c6cc1e20c4b9b5c99af40ee4e23ecb61 this works and no template haskell involved
<intindex> The reason I'm asking is that I'm touching this part of the User's Guide and I don't know what to write there.
<RyanGlScott> Huh, now that's interesting
<intindex> RyanGlScott, the only check I could find that controls what's promoted and what's not is 'isLegacyPromotableDataCon'  and enabling XTypeInType disables this check.
<RyanGlScott> intindex: Right, that's baffling me
<RyanGlScott> Since that's supposed to be checked every time you promote a data constructor (I think)
<RyanGlScott> intindex: File a bug about that, I suppose
<RyanGlScott> Richard (who's sitting next to me right now) seems to think that that shouldn't be possible
<intindex> RyanGlScott, the thing is, I happily removed this check completely in D4748. Does this mean I have to restore a weaker version of it that only checks for data families? Why?
<intindex> Is it bad that XDataKinds promotes data family constructors? Looks like I can just remove the "restrictions" part of the user guide and be done with it
<RyanGlScott> intindex: In theory, that shouldn't be possible
<intindex> OK, then what the check should be? No data families, any other restrictions?
<RyanGlScott> I might qualify that with "no data family instances defined in the same module"
<RyanGlScott> (Or to be precise, in the same SCC, but that's probably too technical for the users' guide)
<intindex> Well, this sounds hard to check. I was thinking along the lines of keeping the 'not (isFamInstTyCon (dataConTyCon dc))' part of the check...
<RyanGlScott> Oh, I thought you were only changing the users' guide :)
<intindex> Well, at this point I'm confused if I should change only the user guide or the check as well. If data families shouldn't be promoted ever, then I'll change GHC. If the limitation is about the current SCC group, I can just mention Trac #12088 as a known infelicity in the User's Guide
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Documentation 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  RyanGlScott, goldfire 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Data family promotion is possible","status":"New","operating_system":"","component":"Documentation","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":["RyanGlScott","goldfire"],"type":"Bug","description":"The User's Guide states that data families cannot be promoted, even with `XTypeInType`:\r\n\r\n> We promote data types and newtypes; type synonyms and type/data families are not promoted.\r\n>\r\n> The flag TypeInType (which implies DataKinds) relaxes some of these restrictions, allowing:\r\n>\r\n> Promotion of type synonyms and type families, but not data families. GHC’s type theory just isn’t up to the task of promoting data families, which requires full dependent types.\r\n\r\nAnd yet the following code typechecks and runs:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies, TypeInType, TypeApplications #}\r\n\r\nimport Type.Reflection\r\n\r\ndata family K\r\ndata instance K = MkK\r\n\r\nmain = print (typeRep @'MkK)\r\n}}}\r\n\r\nIs this a GHC bug or a documentation bug? I asked in IRC but I'm still confused:\r\n\r\n{{{\r\n<intindex> The user guide states that data families aren't promoted even when XTypeInType is enabled. Where's the logic that ensures this? I checked with `data family K; data instance K = MkK` and I can use `'MkK` with no errors/warnings.\r\n<intindex> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#overview \"Promotion of type synonyms and type families, but not data families. GHC’s type theory just isn’t up to the task of promoting data families, which requires full dependent types.\"\r\n<intindex> Is this info outdated?\r\n<RyanGlScott> intindex: Is this in GHCi?\r\n<RyanGlScott> It certainly fails in GHC\r\n<RyanGlScott> But I think I understand why the former works\r\n<intindex> RyanGlScott, yes, I'm checking this in GHCi\r\n<RyanGlScott> intindex: So here's my understanding of how this works\r\n<RyanGlScott> GHC kindchecks toplevel declarations using a rather primitive SCC analysis\r\n<RyanGlScott> In particular, it's primitive in the sense that data family instances give it a lot of trouble\r\n<RyanGlScott> If you tried taking your code and putting it into a standalone .hs file and compiling that, then it would definitely complain about a promoted use of MkT\r\n<RyanGlScott> As luck would have it, though, you were trying things out in GHCi\r\n<RyanGlScott> Which essentially checks each line of input as its own strongly connected group of declarations\r\n<RyanGlScott> So you can define MkT on one line and promote it in subsequent lines, since they're separate in the sense\r\n<RyanGlScott> *that sense\r\n<intindex> this sounds related to Trac #12088, and then I could work around it in GHC by using `$(return [])`, so data families are actually promoted anyway and this has nothing to do with GHC needing more powerful type theory\r\n<RyanGlScott> Well, it does need more powerful type theory in the sense that that's a prerequisite for making the SCC analysis for kindchecking sophisticated enough to handle this\r\n<RyanGlScott> But yes, it's quite simple to work around by using Template Haskell to explicitly split up groups.\r\n<intindex> https://gist.github.com/intindex/c6cc1e20c4b9b5c99af40ee4e23ecb61 this works and no template haskell involved\r\n<intindex> The reason I'm asking is that I'm touching this part of the User's Guide and I don't know what to write there.\r\n<RyanGlScott> Huh, now that's interesting\r\n<intindex> RyanGlScott, the only check I could find that controls what's promoted and what's not is 'isLegacyPromotableDataCon'  and enabling XTypeInType disables this check.\r\n<RyanGlScott> intindex: Right, that's baffling me\r\n<RyanGlScott> Since that's supposed to be checked every time you promote a data constructor (I think)\r\n<RyanGlScott> intindex: File a bug about that, I suppose\r\n<RyanGlScott> Richard (who's sitting next to me right now) seems to think that that shouldn't be possible\r\n<intindex> RyanGlScott, the thing is, I happily removed this check completely in D4748. Does this mean I have to restore a weaker version of it that only checks for data families? Why?\r\n<intindex> Is it bad that XDataKinds promotes data family constructors? Looks like I can just remove the \"restrictions\" part of the user guide and be done with it\r\n<RyanGlScott> intindex: In theory, that shouldn't be possible\r\n<intindex> OK, then what the check should be? No data families, any other restrictions?\r\n<RyanGlScott> I might qualify that with \"no data family instances defined in the same module\"\r\n<RyanGlScott> (Or to be precise, in the same SCC, but that's probably too technical for the users' guide)\r\n<intindex> Well, this sounds hard to check. I was thinking along the lines of keeping the 'not (isFamInstTyCon (dataConTyCon dc))' part of the check...\r\n<RyanGlScott> Oh, I thought you were only changing the users' guide :)\r\n<intindex> Well, at this point I'm confused if I should change only the user guide or the check as well. If data families shouldn't be promoted ever, then I'll change GHC. If the limitation is about the current SCC group, I can just mention Trac #12088 as a known infelicity in the User's Guide\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} >The User's Guide states that data families cannot be promoted, even with `XTypeInType`:
> We promote data types and newtypes; type synonyms and type/data families are not promoted.
>
> The flag TypeInType (which implies DataKinds) relaxes some of these restrictions, allowing:
>
> Promotion of type synonyms and type families, but not data families. GHC’s type theory just isn’t up to the task of promoting data families, which requires full dependent types.
And yet the following code typechecks and runs:
```hs
{# LANGUAGE TypeFamilies, TypeInType, TypeApplications #}
import Type.Reflection
data family K
data instance K = MkK
main = print (typeRep @'MkK)
```
Is this a GHC bug or a documentation bug? I asked in IRC but I'm still confused:
```
<intindex> The user guide states that data families aren't promoted even when XTypeInType is enabled. Where's the logic that ensures this? I checked with `data family K; data instance K = MkK` and I can use `'MkK` with no errors/warnings.
<intindex> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#overview "Promotion of type synonyms and type families, but not data families. GHC’s type theory just isn’t up to the task of promoting data families, which requires full dependent types."
<intindex> Is this info outdated?
<RyanGlScott> intindex: Is this in GHCi?
<RyanGlScott> It certainly fails in GHC
<RyanGlScott> But I think I understand why the former works
<intindex> RyanGlScott, yes, I'm checking this in GHCi
<RyanGlScott> intindex: So here's my understanding of how this works
<RyanGlScott> GHC kindchecks toplevel declarations using a rather primitive SCC analysis
<RyanGlScott> In particular, it's primitive in the sense that data family instances give it a lot of trouble
<RyanGlScott> If you tried taking your code and putting it into a standalone .hs file and compiling that, then it would definitely complain about a promoted use of MkT
<RyanGlScott> As luck would have it, though, you were trying things out in GHCi
<RyanGlScott> Which essentially checks each line of input as its own strongly connected group of declarations
<RyanGlScott> So you can define MkT on one line and promote it in subsequent lines, since they're separate in the sense
<RyanGlScott> *that sense
<intindex> this sounds related to Trac #12088, and then I could work around it in GHC by using `$(return [])`, so data families are actually promoted anyway and this has nothing to do with GHC needing more powerful type theory
<RyanGlScott> Well, it does need more powerful type theory in the sense that that's a prerequisite for making the SCC analysis for kindchecking sophisticated enough to handle this
<RyanGlScott> But yes, it's quite simple to work around by using Template Haskell to explicitly split up groups.
<intindex> https://gist.github.com/intindex/c6cc1e20c4b9b5c99af40ee4e23ecb61 this works and no template haskell involved
<intindex> The reason I'm asking is that I'm touching this part of the User's Guide and I don't know what to write there.
<RyanGlScott> Huh, now that's interesting
<intindex> RyanGlScott, the only check I could find that controls what's promoted and what's not is 'isLegacyPromotableDataCon'  and enabling XTypeInType disables this check.
<RyanGlScott> intindex: Right, that's baffling me
<RyanGlScott> Since that's supposed to be checked every time you promote a data constructor (I think)
<RyanGlScott> intindex: File a bug about that, I suppose
<RyanGlScott> Richard (who's sitting next to me right now) seems to think that that shouldn't be possible
<intindex> RyanGlScott, the thing is, I happily removed this check completely in D4748. Does this mean I have to restore a weaker version of it that only checks for data families? Why?
<intindex> Is it bad that XDataKinds promotes data family constructors? Looks like I can just remove the "restrictions" part of the user guide and be done with it
<RyanGlScott> intindex: In theory, that shouldn't be possible
<intindex> OK, then what the check should be? No data families, any other restrictions?
<RyanGlScott> I might qualify that with "no data family instances defined in the same module"
<RyanGlScott> (Or to be precise, in the same SCC, but that's probably too technical for the users' guide)
<intindex> Well, this sounds hard to check. I was thinking along the lines of keeping the 'not (isFamInstTyCon (dataConTyCon dc))' part of the check...
<RyanGlScott> Oh, I thought you were only changing the users' guide :)
<intindex> Well, at this point I'm confused if I should change only the user guide or the check as well. If data families shouldn't be promoted ever, then I'll change GHC. If the limitation is about the current SCC group, I can just mention Trac #12088 as a known infelicity in the User's Guide
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Documentation 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  RyanGlScott, goldfire 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Data family promotion is possible","status":"New","operating_system":"","component":"Documentation","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":["RyanGlScott","goldfire"],"type":"Bug","description":"The User's Guide states that data families cannot be promoted, even with `XTypeInType`:\r\n\r\n> We promote data types and newtypes; type synonyms and type/data families are not promoted.\r\n>\r\n> The flag TypeInType (which implies DataKinds) relaxes some of these restrictions, allowing:\r\n>\r\n> Promotion of type synonyms and type families, but not data families. GHC’s type theory just isn’t up to the task of promoting data families, which requires full dependent types.\r\n\r\nAnd yet the following code typechecks and runs:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies, TypeInType, TypeApplications #}\r\n\r\nimport Type.Reflection\r\n\r\ndata family K\r\ndata instance K = MkK\r\n\r\nmain = print (typeRep @'MkK)\r\n}}}\r\n\r\nIs this a GHC bug or a documentation bug? I asked in IRC but I'm still confused:\r\n\r\n{{{\r\n<intindex> The user guide states that data families aren't promoted even when XTypeInType is enabled. Where's the logic that ensures this? I checked with `data family K; data instance K = MkK` and I can use `'MkK` with no errors/warnings.\r\n<intindex> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#overview \"Promotion of type synonyms and type families, but not data families. GHC’s type theory just isn’t up to the task of promoting data families, which requires full dependent types.\"\r\n<intindex> Is this info outdated?\r\n<RyanGlScott> intindex: Is this in GHCi?\r\n<RyanGlScott> It certainly fails in GHC\r\n<RyanGlScott> But I think I understand why the former works\r\n<intindex> RyanGlScott, yes, I'm checking this in GHCi\r\n<RyanGlScott> intindex: So here's my understanding of how this works\r\n<RyanGlScott> GHC kindchecks toplevel declarations using a rather primitive SCC analysis\r\n<RyanGlScott> In particular, it's primitive in the sense that data family instances give it a lot of trouble\r\n<RyanGlScott> If you tried taking your code and putting it into a standalone .hs file and compiling that, then it would definitely complain about a promoted use of MkT\r\n<RyanGlScott> As luck would have it, though, you were trying things out in GHCi\r\n<RyanGlScott> Which essentially checks each line of input as its own strongly connected group of declarations\r\n<RyanGlScott> So you can define MkT on one line and promote it in subsequent lines, since they're separate in the sense\r\n<RyanGlScott> *that sense\r\n<intindex> this sounds related to Trac #12088, and then I could work around it in GHC by using `$(return [])`, so data families are actually promoted anyway and this has nothing to do with GHC needing more powerful type theory\r\n<RyanGlScott> Well, it does need more powerful type theory in the sense that that's a prerequisite for making the SCC analysis for kindchecking sophisticated enough to handle this\r\n<RyanGlScott> But yes, it's quite simple to work around by using Template Haskell to explicitly split up groups.\r\n<intindex> https://gist.github.com/intindex/c6cc1e20c4b9b5c99af40ee4e23ecb61 this works and no template haskell involved\r\n<intindex> The reason I'm asking is that I'm touching this part of the User's Guide and I don't know what to write there.\r\n<RyanGlScott> Huh, now that's interesting\r\n<intindex> RyanGlScott, the only check I could find that controls what's promoted and what's not is 'isLegacyPromotableDataCon'  and enabling XTypeInType disables this check.\r\n<RyanGlScott> intindex: Right, that's baffling me\r\n<RyanGlScott> Since that's supposed to be checked every time you promote a data constructor (I think)\r\n<RyanGlScott> intindex: File a bug about that, I suppose\r\n<RyanGlScott> Richard (who's sitting next to me right now) seems to think that that shouldn't be possible\r\n<intindex> RyanGlScott, the thing is, I happily removed this check completely in D4748. Does this mean I have to restore a weaker version of it that only checks for data families? Why?\r\n<intindex> Is it bad that XDataKinds promotes data family constructors? Looks like I can just remove the \"restrictions\" part of the user guide and be done with it\r\n<RyanGlScott> intindex: In theory, that shouldn't be possible\r\n<intindex> OK, then what the check should be? No data families, any other restrictions?\r\n<RyanGlScott> I might qualify that with \"no data family instances defined in the same module\"\r\n<RyanGlScott> (Or to be precise, in the same SCC, but that's probably too technical for the users' guide)\r\n<intindex> Well, this sounds hard to check. I was thinking along the lines of keeping the 'not (isFamInstTyCon (dataConTyCon dc))' part of the check...\r\n<RyanGlScott> Oh, I thought you were only changing the users' guide :)\r\n<intindex> Well, at this point I'm confused if I should change only the user guide or the check as well. If data families shouldn't be promoted ever, then I'll change GHC. If the limitation is about the current SCC group, I can just mention Trac #12088 as a known infelicity in the User's Guide\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15277Move field name resolution to the typechecker20201203T22:24:34ZAdam GundryMove field name resolution to the typecheckerPer discussion on #15149, we plan to make the typechecker responsible for all field name lookup in record construction, patternmatching and updates. This should be simpler than the current story and let us get rid of `tcg_field_env`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Task 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Move field name resolution to the typechecker","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["ORF"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"Per discussion on #15149, we plan to make the typechecker responsible for all field name lookup in record construction, patternmatching and updates. This should be simpler than the current story and let us get rid of `tcg_field_env`.\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} >Per discussion on #15149, we plan to make the typechecker responsible for all field name lookup in record construction, patternmatching and updates. This should be simpler than the current story and let us get rid of `tcg_field_env`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Task 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Move field name resolution to the typechecker","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["ORF"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"Per discussion on #15149, we plan to make the typechecker responsible for all field name lookup in record construction, patternmatching and updates. This should be simpler than the current story and let us get rid of `tcg_field_env`.\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} >Adam GundryAdam Gundryhttps://gitlab.haskell.org/ghc/ghc//issues/15289isUnliftedType GHC panic on pattern with True :: Maybe20190707T18:13:25ZRemiisUnliftedType GHC panic on pattern with True :: Maybe```hs
{# LANGUAGE PatternSynonyms #}
{# LANGUAGE ScopedTypeVariables #}
module Oops where
pattern What = True :: Maybe
```
Fails on 8.4.3 with:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64unknownlinux):
isUnliftedType
(Maybe > {co_a1Dg3}) :: TYPE t_a1Dg9[tau:1]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1939:10 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
I'm currently cloning from git, and will try to get around to check it with HEAD over the next days. BTW, it's not a showstopper for me.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  low 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  aarch64 
</details>
<! {"blocked_by":[],"summary":"isUnliftedType GHC panic on pattern with True :: Maybe","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"aarch64","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{# LANGUAGE PatternSynonyms #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\nmodule Oops where\r\n\r\npattern What = True :: Maybe\r\n}}}\r\n\r\nFails on 8.4.3 with:\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64unknownlinux):\r\n\tisUnliftedType\r\n (Maybe > {co_a1Dg3}) :: TYPE t_a1Dg9[tau:1]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:1939:10 in ghc:Type\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nI'm currently cloning from git, and will try to get around to check it with HEAD over the next days. BTW, it's not a showstopper for me.","type_of_failure":"OtherFailure","blocking":[]} >```hs
{# LANGUAGE PatternSynonyms #}
{# LANGUAGE ScopedTypeVariables #}
module Oops where
pattern What = True :: Maybe
```
Fails on 8.4.3 with:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64unknownlinux):
isUnliftedType
(Maybe > {co_a1Dg3}) :: TYPE t_a1Dg9[tau:1]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1939:10 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
I'm currently cloning from git, and will try to get around to check it with HEAD over the next days. BTW, it's not a showstopper for me.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  low 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  aarch64 
</details>
<! {"blocked_by":[],"summary":"isUnliftedType GHC panic on pattern with True :: Maybe","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"aarch64","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{# LANGUAGE PatternSynonyms #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\nmodule Oops where\r\n\r\npattern What = True :: Maybe\r\n}}}\r\n\r\nFails on 8.4.3 with:\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64unknownlinux):\r\n\tisUnliftedType\r\n (Maybe > {co_a1Dg3}) :: TYPE t_a1Dg9[tau:1]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:1939:10 in ghc:Type\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nI'm currently cloning from git, and will try to get around to check it with HEAD over the next days. BTW, it's not a showstopper for me.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15305Erroneous "nonexhaustive pattern match" using nested GADT with strictness an...20200922T13:41:25ZjkoppelErroneous "nonexhaustive pattern match" using nested GADT with strictness annotationIn the following code, `fun` contains an exhaustive pattern match, but, when compiling with Wall, ghc erroneously reports a nonexhaustive pattern match.
```hs
data (:+:) f g a = Inl !(f a)  Inr !(g a)
data A
data B
data Foo l where
Foo :: Foo A
data Bar l where
Bar :: Bar B
type Sig = Foo :+: Bar
fun :: Sig B > Int
fun (Inr Bar) = 1
```
This report came from https://stackoverflow.com/questions/16225281/gadtsfailedexhaustivenesschecking . Without strictness annotations, this is indeed a failed exhaustive check, due to bottom. I spoke to Richard Eisenberg at PLDI a few days ago, and he informed me that, if this warning did not disappear with strictness annotations, it was a bug. I added strictness annotations, and it did not disappear. I've tried all combinations of using strictness annotations and/or running with `{# LANGUAGE Strict #}`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Erroneous \"nonexhaustive pattern match\" using nested GADT with strictness annotation","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"In the following code, `fun` contains an exhaustive pattern match, but, when compiling with Wall, ghc erroneously reports a nonexhaustive pattern match.\r\n\r\n{{{#!hs\r\n\r\ndata (:+:) f g a = Inl !(f a)  Inr !(g a)\r\n\r\ndata A\r\ndata B\r\n\r\ndata Foo l where\r\n Foo :: Foo A\r\n\r\ndata Bar l where\r\n Bar :: Bar B\r\n\r\ntype Sig = Foo :+: Bar\r\n\r\nfun :: Sig B > Int\r\nfun (Inr Bar) = 1\r\n\r\n}}}\r\n\r\nThis report came from https://stackoverflow.com/questions/16225281/gadtsfailedexhaustivenesschecking . Without strictness annotations, this is indeed a failed exhaustive check, due to bottom. I spoke to Richard Eisenberg at PLDI a few days ago, and he informed me that, if this warning did not disappear with strictness annotations, it was a bug. I added strictness annotations, and it did not disappear. I've tried all combinations of using strictness annotations and/or running with `{# LANGUAGE Strict #}`.","type_of_failure":"OtherFailure","blocking":[]} >In the following code, `fun` contains an exhaustive pattern match, but, when compiling with Wall, ghc erroneously reports a nonexhaustive pattern match.
```hs
data (:+:) f g a = Inl !(f a)  Inr !(g a)
data A
data B
data Foo l where
Foo :: Foo A
data Bar l where
Bar :: Bar B
type Sig = Foo :+: Bar
fun :: Sig B > Int
fun (Inr Bar) = 1
```
This report came from https://stackoverflow.com/questions/16225281/gadtsfailedexhaustivenesschecking . Without strictness annotations, this is indeed a failed exhaustive check, due to bottom. I spoke to Richard Eisenberg at PLDI a few days ago, and he informed me that, if this warning did not disappear with strictness annotations, it was a bug. I added strictness annotations, and it did not disappear. I've tried all combinations of using strictness annotations and/or running with `{# LANGUAGE Strict #}`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Erroneous \"nonexhaustive pattern match\" using nested GADT with strictness annotation","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"In the following code, `fun` contains an exhaustive pattern match, but, when compiling with Wall, ghc erroneously reports a nonexhaustive pattern match.\r\n\r\n{{{#!hs\r\n\r\ndata (:+:) f g a = Inl !(f a)  Inr !(g a)\r\n\r\ndata A\r\ndata B\r\n\r\ndata Foo l where\r\n Foo :: Foo A\r\n\r\ndata Bar l where\r\n Bar :: Bar B\r\n\r\ntype Sig = Foo :+: Bar\r\n\r\nfun :: Sig B > Int\r\nfun (Inr Bar) = 1\r\n\r\n}}}\r\n\r\nThis report came from https://stackoverflow.com/questions/16225281/gadtsfailedexhaustivenesschecking . Without strictness annotations, this is indeed a failed exhaustive check, due to bottom. I spoke to Richard Eisenberg at PLDI a few days ago, and he informed me that, if this warning did not disappear with strictness annotations, it was a bug. I added strictness annotations, and it did not disappear. I've tried all combinations of using strictness annotations and/or running with `{# LANGUAGE Strict #}`.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15308Error message prints explicit kinds when it shouldn't20190707T18:13:20ZRyan ScottError message prints explicit kinds when it shouldn'tWhen compiled, this program:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeInType #}
{# OPTIONS_GHC fnoprintexplicitkinds #}
module Bug where
import Data.Kind
data Foo (a :: Type) :: forall b. (a > b > Type) > Type where
MkFoo :: Foo a f
f :: Foo a f > String
f = show
```
Gives the following error:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a b f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show

13  f = show
 ^^^^
```
This error message is slightly incorrect, however. In "`No instance for (Show (Foo a b f))`", it claims that `Foo` has three visible type parameters, but it only has two. (I've even made sure to enable `fnoprintexplicitkinds` at the type to ensure that the invisible `b` kind shouldn't get printed, but it was anyway.)
This is a regression that was apparently introduced between GHC 8.0 and 8.2, since in GHC 8.0.2, it prints the correct thing:
```
$ /opt/ghc/8.0.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show
```
But it does not in GHC 8.2.1:
```
$ /opt/ghc/8.2.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a b f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show

13  f = show
 ^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Error message prints explicit kinds when it shouldn't","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When compiled, this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeInType #}\r\n{# OPTIONS_GHC fnoprintexplicitkinds #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata Foo (a :: Type) :: forall b. (a > b > Type) > Type where\r\n MkFoo :: Foo a f\r\n\r\nf :: Foo a f > String\r\nf = show\r\n}}}\r\n\r\nGives the following error:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:13:5: error:\r\n • No instance for (Show (Foo a b f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n \r\n13  f = show\r\n  ^^^^\r\n}}}\r\n\r\nThis error message is slightly incorrect, however. In \"`No instance for (Show (Foo a b f))`\", it claims that `Foo` has three visible type parameters, but it only has two. (I've even made sure to enable `fnoprintexplicitkinds` at the type to ensure that the invisible `b` kind shouldn't get printed, but it was anyway.)\r\n\r\nThis is a regression that was apparently introduced between GHC 8.0 and 8.2, since in GHC 8.0.2, it prints the correct thing:\r\n\r\n{{{\r\n$ /opt/ghc/8.0.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:13:5: error:\r\n • No instance for (Show (Foo a f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n}}}\r\n\r\nBut it does not in GHC 8.2.1:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:13:5: error:\r\n • No instance for (Show (Foo a b f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n \r\n13  f = show\r\n  ^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >When compiled, this program:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeInType #}
{# OPTIONS_GHC fnoprintexplicitkinds #}
module Bug where
import Data.Kind
data Foo (a :: Type) :: forall b. (a > b > Type) > Type where
MkFoo :: Foo a f
f :: Foo a f > String
f = show
```
Gives the following error:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a b f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show

13  f = show
 ^^^^
```
This error message is slightly incorrect, however. In "`No instance for (Show (Foo a b f))`", it claims that `Foo` has three visible type parameters, but it only has two. (I've even made sure to enable `fnoprintexplicitkinds` at the type to ensure that the invisible `b` kind shouldn't get printed, but it was anyway.)
This is a regression that was apparently introduced between GHC 8.0 and 8.2, since in GHC 8.0.2, it prints the correct thing:
```
$ /opt/ghc/8.0.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show
```
But it does not in GHC 8.2.1:
```
$ /opt/ghc/8.2.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:13:5: error:
• No instance for (Show (Foo a b f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show

13  f = show
 ^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Error message prints explicit kinds when it shouldn't","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When compiled, this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeInType #}\r\n{# OPTIONS_GHC fnoprintexplicitkinds #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata Foo (a :: Type) :: forall b. (a > b > Type) > Type where\r\n MkFoo :: Foo a f\r\n\r\nf :: Foo a f > String\r\nf = show\r\n}}}\r\n\r\nGives the following error:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:13:5: error:\r\n • No instance for (Show (Foo a b f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n \r\n13  f = show\r\n  ^^^^\r\n}}}\r\n\r\nThis error message is slightly incorrect, however. In \"`No instance for (Show (Foo a b f))`\", it claims that `Foo` has three visible type parameters, but it only has two. (I've even made sure to enable `fnoprintexplicitkinds` at the type to ensure that the invisible `b` kind shouldn't get printed, but it was anyway.)\r\n\r\nThis is a regression that was apparently introduced between GHC 8.0 and 8.2, since in GHC 8.0.2, it prints the correct thing:\r\n\r\n{{{\r\n$ /opt/ghc/8.0.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:13:5: error:\r\n • No instance for (Show (Foo a f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n}}}\r\n\r\nBut it does not in GHC 8.2.1:\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:13:5: error:\r\n • No instance for (Show (Foo a b f)) arising from a use of ‘show’\r\n • In the expression: show\r\n In an equation for ‘f’: f = show\r\n \r\n13  f = show\r\n  ^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15310Derive Generic1 instances for types of kind (k > *) > * that include applic...20190707T18:13:20ZcedricshockDerive Generic1 instances for types of kind (k > *) > * that include applications of the parameterThe `Generic1` class is polykinded. The `DeriveGeneric` extension can derive `Generic1` instances for types of kind `k > *` parameterized over a parameter with a kind other than `k ~ *`, but only if they don't apply the parameter to other types.
It currently cannot derive an instance for
```hs
newtype Fix f = In (f (Fix f))
deriving (Generic1)
```
or for
```hs
data Child f = Child {
ordinal :: Int,
nickname :: f String
}
deriving (Generic1)
```
It's possible to represent these types generically, either with composition that can include occurrences of the parameter or with new types that represent applications of the parameter.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  
 Type  FeatureRequest 
 TypeOfFailure  OtherFailure 
 Priority  low 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Derive Generic1 instances for types of kind (k > *) > * that include applications of the parameter","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"","keywords":["DeriveGeneric","Generic1"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"The `Generic1` class is polykinded. The `DeriveGeneric` extension can derive `Generic1` instances for types of kind `k > *` parameterized over a parameter with a kind other than `k ~ *`, but only if they don't apply the parameter to other types.\r\n\r\nIt currently cannot derive an instance for\r\n\r\n{{{#!hs\r\nnewtype Fix f = In (f (Fix f))\r\n deriving (Generic1)\r\n}}}\r\n\r\nor for \r\n\r\n{{{#!hs\r\ndata Child f = Child {\r\n ordinal :: Int,\r\n nickname :: f String\r\n}\r\n deriving (Generic1)\r\n}}}\r\n\r\nIt's possible to represent these types generically, either with composition that can include occurrences of the parameter or with new types that represent applications of the parameter.","type_of_failure":"OtherFailure","blocking":[]} >The `Generic1` class is polykinded. The `DeriveGeneric` extension can derive `Generic1` instances for types of kind `k > *` parameterized over a parameter with a kind other than `k ~ *`, but only if they don't apply the parameter to other types.
It currently cannot derive an instance for
```hs
newtype Fix f = In (f (Fix f))
deriving (Generic1)
```
or for
```hs
data Child f = Child {
ordinal :: Int,
nickname :: f String
}
deriving (Generic1)
```
It's possible to represent these types generically, either with composition that can include occurrences of the parameter or with new types that represent applications of the parameter.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  
 Type  FeatureRequest 
 TypeOfFailure  OtherFailure 
 Priority  low 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Derive Generic1 instances for types of kind (k > *) > * that include applications of the parameter","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"","keywords":["DeriveGeneric","Generic1"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"The `Generic1` class is polykinded. The `DeriveGeneric` extension can derive `Generic1` instances for types of kind `k > *` parameterized over a parameter with a kind other than `k ~ *`, but only if they don't apply the parameter to other types.\r\n\r\nIt currently cannot derive an instance for\r\n\r\n{{{#!hs\r\nnewtype Fix f = In (f (Fix f))\r\n deriving (Generic1)\r\n}}}\r\n\r\nor for \r\n\r\n{{{#!hs\r\ndata Child f = Child {\r\n ordinal :: Int,\r\n nickname :: f String\r\n}\r\n deriving (Generic1)\r\n}}}\r\n\r\nIt's possible to represent these types generically, either with composition that can include occurrences of the parameter or with new types that represent applications of the parameter.","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/15316Regarding coherence and implication loops in presence of QuantifiedConstraints20201003T12:38:44ZmniipRegarding coherence and implication loops in presence of QuantifiedConstraintsFirst of all this piece of code:
```hs
{# LANGUAGE RankNTypes, QuantifiedConstraints #}
 NB: disabling these if enabled:
{# LANGUAGE NoUndecidableInstances, NoUndecidableSuperClasses #}
import Data.Proxy
class Class a where
method :: a
subsume :: (Class a => Class b) => Proxy a > Proxy b > ((Class a => Class b) => r) > r
subsume _ _ x = x
value :: Proxy a > a
value p = subsume p p method
```
This produces a nonterminating `value` even though nothing warranting recursion was used.
Adding:
```hs
value' :: Class a => Proxy a > a
value' p = subsume p p method
```
Produces a `value'` that is legitimately equivalent to `method` in that it equals to the value in the dictionary whenever an instance exists (and doesn't typecheck otherwise). Thus two identical expressions in different instance contexts end up having different values (violating coherence?)
If we add:
```hs
joinSubsume :: Proxy a > ((Class a => Class a) => r) > r
joinSubsume p x = subsume p p x
```
The fact that this typechecks suggests that GHC is able to infer `Class a => Class a` at will, which doesn't seem wrong. However, the fact that `Class a` is solved from `Class a => Class a` via an infinite loop of implication constraints is questionable. Probably even outright wrong in absence of `UndecidableInstances`.
Another issue is the following:
```hs
{# LANGUAGE ConstraintKinds #}
subsume' :: Proxy c > ((c => c) => r) > r
subsume' _ x = x
```
```
• Reduction stack overflow; size = 201
When simplifying the following type: c
Use freductiondepth=0 to disable this check
(any upper bound you could choose might fail unpredictably with
minor updates to GHC, so disabling the check is recommended if
you're sure that type checking should terminate)
• In the type signature:
subsume' :: Proxy c > ((c => c) => r) > r
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Regarding coherence and implication loops in presence of QuantifiedConstraints","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["QuantifiedConstraints"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"First of all this piece of code:\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes, QuantifiedConstraints #}\r\n NB: disabling these if enabled:\r\n{# LANGUAGE NoUndecidableInstances, NoUndecidableSuperClasses #}\r\n\r\nimport Data.Proxy\r\n\r\nclass Class a where\r\n\t method :: a\r\n\r\nsubsume :: (Class a => Class b) => Proxy a > Proxy b > ((Class a => Class b) => r) > r\r\nsubsume _ _ x = x\r\n\r\nvalue :: Proxy a > a\r\nvalue p = subsume p p method\r\n}}}\r\n\r\nThis produces a nonterminating `value` even though nothing warranting recursion was used.\r\n\r\nAdding:\r\n{{{#!hs\r\nvalue' :: Class a => Proxy a > a\r\nvalue' p = subsume p p method\r\n}}}\r\nProduces a `value'` that is legitimately equivalent to `method` in that it equals to the value in the dictionary whenever an instance exists (and doesn't typecheck otherwise). Thus two identical expressions in different instance contexts end up having different values (violating coherence?)\r\n\r\nIf we add:\r\n{{{#!hs\r\njoinSubsume :: Proxy a > ((Class a => Class a) => r) > r\r\njoinSubsume p x = subsume p p x\r\n}}}\r\nThe fact that this typechecks suggests that GHC is able to infer `Class a => Class a` at will, which doesn't seem wrong. However, the fact that `Class a` is solved from `Class a => Class a` via an infinite loop of implication constraints is questionable. Probably even outright wrong in absence of `UndecidableInstances`.\r\n\r\nAnother issue is the following:\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\nsubsume' :: Proxy c > ((c => c) => r) > r\r\nsubsume' _ x = x\r\n}}}\r\n{{{\r\n • Reduction stack overflow; size = 201\r\n When simplifying the following type: c\r\n Use freductiondepth=0 to disable this check\r\n (any upper bound you could choose might fail unpredictably with\r\n minor updates to GHC, so disabling the check is recommended if\r\n you're sure that type checking should terminate)\r\n • In the type signature:\r\n subsume' :: Proxy c > ((c => c) => r) > r\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >First of all this piece of code:
```hs
{# LANGUAGE RankNTypes, QuantifiedConstraints #}
 NB: disabling these if enabled:
{# LANGUAGE NoUndecidableInstances, NoUndecidableSuperClasses #}
import Data.Proxy
class Class a where
method :: a
subsume :: (Class a => Class b) => Proxy a > Proxy b > ((Class a => Class b) => r) > r
subsume _ _ x = x
value :: Proxy a > a
value p = subsume p p method
```
This produces a nonterminating `value` even though nothing warranting recursion was used.
Adding:
```hs
value' :: Class a => Proxy a > a
value' p = subsume p p method
```
Produces a `value'` that is legitimately equivalent to `method` in that it equals to the value in the dictionary whenever an instance exists (and doesn't typecheck otherwise). Thus two identical expressions in different instance contexts end up having different values (violating coherence?)
If we add:
```hs
joinSubsume :: Proxy a > ((Class a => Class a) => r) > r
joinSubsume p x = subsume p p x
```
The fact that this typechecks suggests that GHC is able to infer `Class a => Class a` at will, which doesn't seem wrong. However, the fact that `Class a` is solved from `Class a => Class a` via an infinite loop of implication constraints is questionable. Probably even outright wrong in absence of `UndecidableInstances`.
Another issue is the following:
```hs
{# LANGUAGE ConstraintKinds #}
subsume' :: Proxy c > ((c => c) => r) > r
subsume' _ x = x
```
```
• Reduction stack overflow; size = 201
When simplifying the following type: c
Use freductiondepth=0 to disable this check
(any upper bound you could choose might fail unpredictably with
minor updates to GHC, so disabling the check is recommended if
you're sure that type checking should terminate)
• In the type signature:
subsume' :: Proxy c > ((c => c) => r) > r
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Regarding coherence and implication loops in presence of QuantifiedConstraints","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["QuantifiedConstraints"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"First of all this piece of code:\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes, QuantifiedConstraints #}\r\n NB: disabling these if enabled:\r\n{# LANGUAGE NoUndecidableInstances, NoUndecidableSuperClasses #}\r\n\r\nimport Data.Proxy\r\n\r\nclass Class a where\r\n\t method :: a\r\n\r\nsubsume :: (Class a => Class b) => Proxy a > Proxy b > ((Class a => Class b) => r) > r\r\nsubsume _ _ x = x\r\n\r\nvalue :: Proxy a > a\r\nvalue p = subsume p p method\r\n}}}\r\n\r\nThis produces a nonterminating `value` even though nothing warranting recursion was used.\r\n\r\nAdding:\r\n{{{#!hs\r\nvalue' :: Class a => Proxy a > a\r\nvalue' p = subsume p p method\r\n}}}\r\nProduces a `value'` that is legitimately equivalent to `method` in that it equals to the value in the dictionary whenever an instance exists (and doesn't typecheck otherwise). Thus two identical expressions in different instance contexts end up having different values (violating coherence?)\r\n\r\nIf we add:\r\n{{{#!hs\r\njoinSubsume :: Proxy a > ((Class a => Class a) => r) > r\r\njoinSubsume p x = subsume p p x\r\n}}}\r\nThe fact that this typechecks suggests that GHC is able to infer `Class a => Class a` at will, which doesn't seem wrong. However, the fact that `Class a` is solved from `Class a => Class a` via an infinite loop of implication constraints is questionable. Probably even outright wrong in absence of `UndecidableInstances`.\r\n\r\nAnother issue is the following:\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\nsubsume' :: Proxy c > ((c => c) => r) > r\r\nsubsume' _ x = x\r\n}}}\r\n{{{\r\n • Reduction stack overflow; size = 201\r\n When simplifying the following type: c\r\n Use freductiondepth=0 to disable this check\r\n (any upper bound you could choose might fail unpredictably with\r\n minor updates to GHC, so disabling the check is recommended if\r\n you're sure that type checking should terminate)\r\n • In the type signature:\r\n subsume' :: Proxy c > ((c => c) => r) > r\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.8.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc//issues/15318Core Lint error involving newtype family instances with wrappers20190707T18:13:18ZRyan ScottCore Lint error involving newtype family instances with wrappersThe following program gives a Core Lint error on GHC 8.4 and later:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
module Bug where
data family Sn a
newtype instance Sn (Either a b) where
SnC :: forall b a. Char > Sn (Either a b)
```
```
$ /opt/ghc/8.4.3/bin/ghc dcorelint Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Tidy Core ***
<no location info>: warning:
[in body of lambda with binder dt_aZm :: Char]
Fromtype of Cast differs from type of enclosed expression
Fromtype: R:SnEither a_auS b_auR
Type of enclosed expr: Sn (Either a_auS b_auR)
Actual enclosed expr: dt_aZm
`cast` (Sym (N:R:SnEither[0]
<a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0]
<a_auS>_N <b_auR>_N)
:: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *))
Coercion used in cast: Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
*** Offending Program ***
$WSnC [InlPrag=INLINE[2]] :: forall b a. Char > Sn (Either a b)
[GblId[DataConWrapper],
Arity=1,
Caf=NoCafRefs,
Str=<L,U>,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)
Tmpl= \ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >
(dt_aZm
`cast` (Sym (N:R:SnEither[0]
<a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))
`cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (R:SnEither a_auS b_auR :: *)
~R# (Sn (Either a_auS b_auR) :: *))}]
$WSnC
= \ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >
(dt_aZm
`cast` (Sym (N:R:SnEither[0]
<a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))
`cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (R:SnEither a_auS b_auR :: *)
~R# (Sn (Either a_auS b_auR) :: *))
$trModule1_r10g :: Addr#
[GblId, Caf=NoCafRefs]
$trModule1_r10g = "main"#
$trModule2_r10D :: TrName
[GblId, Caf=NoCafRefs]
$trModule2_r10D = TrNameS $trModule1_r10g
$trModule3_r10E :: Addr#
[GblId, Caf=NoCafRefs]
$trModule3_r10E = "Bug"#
$trModule4_r10F :: TrName
[GblId, Caf=NoCafRefs]
$trModule4_r10F = TrNameS $trModule3_r10E
$trModule :: Module
[GblId, Caf=NoCafRefs]
$trModule = Module $trModule2_r10D $trModule4_r10F
$krep_r10G :: KindRep
[GblId]
$krep_r10G = KindRepTyConApp $tcChar ([] @ KindRep)
$krep1_r10H :: KindRep
[GblId, Caf=NoCafRefs]
$krep1_r10H = KindRepVar 1#
$krep2_r10I :: KindRep
[GblId, Caf=NoCafRefs]
$krep2_r10I = KindRepVar 0#
$krep3_r10J :: [KindRep]
[GblId, Caf=NoCafRefs]
$krep3_r10J = : @ KindRep $krep2_r10I ([] @ KindRep)
$krep4_r10K :: [KindRep]
[GblId, Caf=NoCafRefs]
$krep4_r10K = : @ KindRep $krep1_r10H $krep3_r10J
$krep5_r10L :: KindRep
[GblId]
$krep5_r10L = KindRepTyConApp $tcEither $krep4_r10K
$tcSn1_r10M :: Addr#
[GblId, Caf=NoCafRefs]
$tcSn1_r10M = "Sn"#
$tcSn2_r10N :: TrName
[GblId, Caf=NoCafRefs]
$tcSn2_r10N = TrNameS $tcSn1_r10M
$tcSn :: TyCon
[GblId]
$tcSn
= TyCon
461968091845555535##
16320521938866097056##
$trModule
$tcSn2_r10N
0#
krep$*Arr*
$krep6_r10O :: [KindRep]
[GblId]
$krep6_r10O = : @ KindRep $krep5_r10L ([] @ KindRep)
$krep7_r10P :: KindRep
[GblId]
$krep7_r10P = KindRepTyConApp $tcSn $krep6_r10O
$krep8_r10Q :: KindRep
[GblId]
$krep8_r10Q = KindRepFun $krep_r10G $krep7_r10P
$tc'SnC1_r10R :: Addr#
[GblId, Caf=NoCafRefs]
$tc'SnC1_r10R = "'SnC"#
$tc'SnC2_r10S :: TrName
[GblId, Caf=NoCafRefs]
$tc'SnC2_r10S = TrNameS $tc'SnC1_r10R
$tc'SnC :: TyCon
[GblId]
$tc'SnC
= TyCon
3818830880305712792##
17484539998814842835##
$trModule
$tc'SnC2_r10S
2#
$krep8_r10Q
*** End of Offense ***
<no location info>: error:
Compilation had errors
```
If we look at the Core for `$WSnC`, we see the culprit:
```
$WSnC
= \ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >
(dt_aZm
`cast` (Sym (N:R:SnEither[0]
<a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))
`cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (R:SnEither a_auS b_auR :: *)
~R# (Sn (Either a_auS b_auR) :: *))
```
The inner cast goes from `Char` to `Sn (Either a b)`, but then the outer cast goes from `R:SnEither a b` to `Sn (Either a b)`, which is not transitive.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  mpickering 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error involving newtype family instances with wrappers","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":["mpickering"],"type":"Bug","description":"The following program gives a Core Lint error on GHC 8.4 and later:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\ndata family Sn a\r\nnewtype instance Sn (Either a b) where\r\n SnC :: forall b a. Char > Sn (Either a b)\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc dcorelint Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Tidy Core ***\r\n<no location info>: warning:\r\n [in body of lambda with binder dt_aZm :: Char]\r\n Fromtype of Cast differs from type of enclosed expression\r\n Fromtype: R:SnEither a_auS b_auR\r\n Type of enclosed expr: Sn (Either a_auS b_auR)\r\n Actual enclosed expr: dt_aZm\r\n `cast` (Sym (N:R:SnEither[0]\r\n <a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0]\r\n <a_auS>_N <b_auR>_N)\r\n :: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *))\r\n Coercion used in cast: Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n*** Offending Program ***\r\n$WSnC [InlPrag=INLINE[2]] :: forall b a. Char > Sn (Either a b)\r\n[GblId[DataConWrapper],\r\n Arity=1,\r\n Caf=NoCafRefs,\r\n Str=<L,U>,\r\n Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)\r\n Tmpl= \\ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >\r\n (dt_aZm\r\n `cast` (Sym (N:R:SnEither[0]\r\n <a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))\r\n `cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (R:SnEither a_auS b_auR :: *)\r\n ~R# (Sn (Either a_auS b_auR) :: *))}]\r\n$WSnC\r\n = \\ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >\r\n (dt_aZm\r\n `cast` (Sym (N:R:SnEither[0]\r\n <a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))\r\n `cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (R:SnEither a_auS b_auR :: *)\r\n ~R# (Sn (Either a_auS b_auR) :: *))\r\n\r\n$trModule1_r10g :: Addr#\r\n[GblId, Caf=NoCafRefs]\r\n$trModule1_r10g = \"main\"#\r\n\r\n$trModule2_r10D :: TrName\r\n[GblId, Caf=NoCafRefs]\r\n$trModule2_r10D = TrNameS $trModule1_r10g\r\n\r\n$trModule3_r10E :: Addr#\r\n[GblId, Caf=NoCafRefs]\r\n$trModule3_r10E = \"Bug\"#\r\n\r\n$trModule4_r10F :: TrName\r\n[GblId, Caf=NoCafRefs]\r\n$trModule4_r10F = TrNameS $trModule3_r10E\r\n\r\n$trModule :: Module\r\n[GblId, Caf=NoCafRefs]\r\n$trModule = Module $trModule2_r10D $trModule4_r10F\r\n\r\n$krep_r10G :: KindRep\r\n[GblId]\r\n$krep_r10G = KindRepTyConApp $tcChar ([] @ KindRep)\r\n\r\n$krep1_r10H :: KindRep\r\n[GblId, Caf=NoCafRefs]\r\n$krep1_r10H = KindRepVar 1#\r\n\r\n$krep2_r10I :: KindRep\r\n[GblId, Caf=NoCafRefs]\r\n$krep2_r10I = KindRepVar 0#\r\n\r\n$krep3_r10J :: [KindRep]\r\n[GblId, Caf=NoCafRefs]\r\n$krep3_r10J = : @ KindRep $krep2_r10I ([] @ KindRep)\r\n\r\n$krep4_r10K :: [KindRep]\r\n[GblId, Caf=NoCafRefs]\r\n$krep4_r10K = : @ KindRep $krep1_r10H $krep3_r10J\r\n\r\n$krep5_r10L :: KindRep\r\n[GblId]\r\n$krep5_r10L = KindRepTyConApp $tcEither $krep4_r10K\r\n\r\n$tcSn1_r10M :: Addr#\r\n[GblId, Caf=NoCafRefs]\r\n$tcSn1_r10M = \"Sn\"#\r\n\r\n$tcSn2_r10N :: TrName\r\n[GblId, Caf=NoCafRefs]\r\n$tcSn2_r10N = TrNameS $tcSn1_r10M\r\n\r\n$tcSn :: TyCon\r\n[GblId]\r\n$tcSn\r\n = TyCon\r\n 461968091845555535##\r\n 16320521938866097056##\r\n $trModule\r\n $tcSn2_r10N\r\n 0#\r\n krep$*Arr*\r\n\r\n$krep6_r10O :: [KindRep]\r\n[GblId]\r\n$krep6_r10O = : @ KindRep $krep5_r10L ([] @ KindRep)\r\n\r\n$krep7_r10P :: KindRep\r\n[GblId]\r\n$krep7_r10P = KindRepTyConApp $tcSn $krep6_r10O\r\n\r\n$krep8_r10Q :: KindRep\r\n[GblId]\r\n$krep8_r10Q = KindRepFun $krep_r10G $krep7_r10P\r\n\r\n$tc'SnC1_r10R :: Addr#\r\n[GblId, Caf=NoCafRefs]\r\n$tc'SnC1_r10R = \"'SnC\"#\r\n\r\n$tc'SnC2_r10S :: TrName\r\n[GblId, Caf=NoCafRefs]\r\n$tc'SnC2_r10S = TrNameS $tc'SnC1_r10R\r\n\r\n$tc'SnC :: TyCon\r\n[GblId]\r\n$tc'SnC\r\n = TyCon\r\n 3818830880305712792##\r\n 17484539998814842835##\r\n $trModule\r\n $tc'SnC2_r10S\r\n 2#\r\n $krep8_r10Q\r\n\r\n*** End of Offense ***\r\n\r\n\r\n<no location info>: error: \r\nCompilation had errors\r\n}}}\r\n\r\nIf we look at the Core for `$WSnC`, we see the culprit:\r\n\r\n{{{\r\n$WSnC\r\n = \\ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >\r\n (dt_aZm\r\n `cast` (Sym (N:R:SnEither[0]\r\n <a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))\r\n `cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (R:SnEither a_auS b_auR :: *)\r\n ~R# (Sn (Either a_auS b_auR) :: *))\r\n}}}\r\n\r\nThe inner cast goes from `Char` to `Sn (Either a b)`, but then the outer cast goes from `R:SnEither a b` to `Sn (Either a b)`, which is not transitive.","type_of_failure":"OtherFailure","blocking":[]} >The following program gives a Core Lint error on GHC 8.4 and later:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
module Bug where
data family Sn a
newtype instance Sn (Either a b) where
SnC :: forall b a. Char > Sn (Either a b)
```
```
$ /opt/ghc/8.4.3/bin/ghc dcorelint Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Tidy Core ***
<no location info>: warning:
[in body of lambda with binder dt_aZm :: Char]
Fromtype of Cast differs from type of enclosed expression
Fromtype: R:SnEither a_auS b_auR
Type of enclosed expr: Sn (Either a_auS b_auR)
Actual enclosed expr: dt_aZm
`cast` (Sym (N:R:SnEither[0]
<a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0]
<a_auS>_N <b_auR>_N)
:: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *))
Coercion used in cast: Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
*** Offending Program ***
$WSnC [InlPrag=INLINE[2]] :: forall b a. Char > Sn (Either a b)
[GblId[DataConWrapper],
Arity=1,
Caf=NoCafRefs,
Str=<L,U>,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)
Tmpl= \ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >
(dt_aZm
`cast` (Sym (N:R:SnEither[0]
<a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))
`cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (R:SnEither a_auS b_auR :: *)
~R# (Sn (Either a_auS b_auR) :: *))}]
$WSnC
= \ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >
(dt_aZm
`cast` (Sym (N:R:SnEither[0]
<a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))
`cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (R:SnEither a_auS b_auR :: *)
~R# (Sn (Either a_auS b_auR) :: *))
$trModule1_r10g :: Addr#
[GblId, Caf=NoCafRefs]
$trModule1_r10g = "main"#
$trModule2_r10D :: TrName
[GblId, Caf=NoCafRefs]
$trModule2_r10D = TrNameS $trModule1_r10g
$trModule3_r10E :: Addr#
[GblId, Caf=NoCafRefs]
$trModule3_r10E = "Bug"#
$trModule4_r10F :: TrName
[GblId, Caf=NoCafRefs]
$trModule4_r10F = TrNameS $trModule3_r10E
$trModule :: Module
[GblId, Caf=NoCafRefs]
$trModule = Module $trModule2_r10D $trModule4_r10F
$krep_r10G :: KindRep
[GblId]
$krep_r10G = KindRepTyConApp $tcChar ([] @ KindRep)
$krep1_r10H :: KindRep
[GblId, Caf=NoCafRefs]
$krep1_r10H = KindRepVar 1#
$krep2_r10I :: KindRep
[GblId, Caf=NoCafRefs]
$krep2_r10I = KindRepVar 0#
$krep3_r10J :: [KindRep]
[GblId, Caf=NoCafRefs]
$krep3_r10J = : @ KindRep $krep2_r10I ([] @ KindRep)
$krep4_r10K :: [KindRep]
[GblId, Caf=NoCafRefs]
$krep4_r10K = : @ KindRep $krep1_r10H $krep3_r10J
$krep5_r10L :: KindRep
[GblId]
$krep5_r10L = KindRepTyConApp $tcEither $krep4_r10K
$tcSn1_r10M :: Addr#
[GblId, Caf=NoCafRefs]
$tcSn1_r10M = "Sn"#
$tcSn2_r10N :: TrName
[GblId, Caf=NoCafRefs]
$tcSn2_r10N = TrNameS $tcSn1_r10M
$tcSn :: TyCon
[GblId]
$tcSn
= TyCon
461968091845555535##
16320521938866097056##
$trModule
$tcSn2_r10N
0#
krep$*Arr*
$krep6_r10O :: [KindRep]
[GblId]
$krep6_r10O = : @ KindRep $krep5_r10L ([] @ KindRep)
$krep7_r10P :: KindRep
[GblId]
$krep7_r10P = KindRepTyConApp $tcSn $krep6_r10O
$krep8_r10Q :: KindRep
[GblId]
$krep8_r10Q = KindRepFun $krep_r10G $krep7_r10P
$tc'SnC1_r10R :: Addr#
[GblId, Caf=NoCafRefs]
$tc'SnC1_r10R = "'SnC"#
$tc'SnC2_r10S :: TrName
[GblId, Caf=NoCafRefs]
$tc'SnC2_r10S = TrNameS $tc'SnC1_r10R
$tc'SnC :: TyCon
[GblId]
$tc'SnC
= TyCon
3818830880305712792##
17484539998814842835##
$trModule
$tc'SnC2_r10S
2#
$krep8_r10Q
*** End of Offense ***
<no location info>: error:
Compilation had errors
```
If we look at the Core for `$WSnC`, we see the culprit:
```
$WSnC
= \ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >
(dt_aZm
`cast` (Sym (N:R:SnEither[0]
<a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))
`cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)
:: (R:SnEither a_auS b_auR :: *)
~R# (Sn (Either a_auS b_auR) :: *))
```
The inner cast goes from `Char` to `Sn (Either a b)`, but then the outer cast goes from `R:SnEither a b` to `Sn (Either a b)`, which is not transitive.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  mpickering 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error involving newtype family instances with wrappers","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":["mpickering"],"type":"Bug","description":"The following program gives a Core Lint error on GHC 8.4 and later:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\ndata family Sn a\r\nnewtype instance Sn (Either a b) where\r\n SnC :: forall b a. Char > Sn (Either a b)\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc dcorelint Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Tidy Core ***\r\n<no location info>: warning:\r\n [in body of lambda with binder dt_aZm :: Char]\r\n Fromtype of Cast differs from type of enclosed expression\r\n Fromtype: R:SnEither a_auS b_auR\r\n Type of enclosed expr: Sn (Either a_auS b_auR)\r\n Actual enclosed expr: dt_aZm\r\n `cast` (Sym (N:R:SnEither[0]\r\n <a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0]\r\n <a_auS>_N <b_auR>_N)\r\n :: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *))\r\n Coercion used in cast: Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n*** Offending Program ***\r\n$WSnC [InlPrag=INLINE[2]] :: forall b a. Char > Sn (Either a b)\r\n[GblId[DataConWrapper],\r\n Arity=1,\r\n Caf=NoCafRefs,\r\n Str=<L,U>,\r\n Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)\r\n Tmpl= \\ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >\r\n (dt_aZm\r\n `cast` (Sym (N:R:SnEither[0]\r\n <a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))\r\n `cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (R:SnEither a_auS b_auR :: *)\r\n ~R# (Sn (Either a_auS b_auR) :: *))}]\r\n$WSnC\r\n = \\ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >\r\n (dt_aZm\r\n `cast` (Sym (N:R:SnEither[0]\r\n <a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))\r\n `cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (R:SnEither a_auS b_auR :: *)\r\n ~R# (Sn (Either a_auS b_auR) :: *))\r\n\r\n$trModule1_r10g :: Addr#\r\n[GblId, Caf=NoCafRefs]\r\n$trModule1_r10g = \"main\"#\r\n\r\n$trModule2_r10D :: TrName\r\n[GblId, Caf=NoCafRefs]\r\n$trModule2_r10D = TrNameS $trModule1_r10g\r\n\r\n$trModule3_r10E :: Addr#\r\n[GblId, Caf=NoCafRefs]\r\n$trModule3_r10E = \"Bug\"#\r\n\r\n$trModule4_r10F :: TrName\r\n[GblId, Caf=NoCafRefs]\r\n$trModule4_r10F = TrNameS $trModule3_r10E\r\n\r\n$trModule :: Module\r\n[GblId, Caf=NoCafRefs]\r\n$trModule = Module $trModule2_r10D $trModule4_r10F\r\n\r\n$krep_r10G :: KindRep\r\n[GblId]\r\n$krep_r10G = KindRepTyConApp $tcChar ([] @ KindRep)\r\n\r\n$krep1_r10H :: KindRep\r\n[GblId, Caf=NoCafRefs]\r\n$krep1_r10H = KindRepVar 1#\r\n\r\n$krep2_r10I :: KindRep\r\n[GblId, Caf=NoCafRefs]\r\n$krep2_r10I = KindRepVar 0#\r\n\r\n$krep3_r10J :: [KindRep]\r\n[GblId, Caf=NoCafRefs]\r\n$krep3_r10J = : @ KindRep $krep2_r10I ([] @ KindRep)\r\n\r\n$krep4_r10K :: [KindRep]\r\n[GblId, Caf=NoCafRefs]\r\n$krep4_r10K = : @ KindRep $krep1_r10H $krep3_r10J\r\n\r\n$krep5_r10L :: KindRep\r\n[GblId]\r\n$krep5_r10L = KindRepTyConApp $tcEither $krep4_r10K\r\n\r\n$tcSn1_r10M :: Addr#\r\n[GblId, Caf=NoCafRefs]\r\n$tcSn1_r10M = \"Sn\"#\r\n\r\n$tcSn2_r10N :: TrName\r\n[GblId, Caf=NoCafRefs]\r\n$tcSn2_r10N = TrNameS $tcSn1_r10M\r\n\r\n$tcSn :: TyCon\r\n[GblId]\r\n$tcSn\r\n = TyCon\r\n 461968091845555535##\r\n 16320521938866097056##\r\n $trModule\r\n $tcSn2_r10N\r\n 0#\r\n krep$*Arr*\r\n\r\n$krep6_r10O :: [KindRep]\r\n[GblId]\r\n$krep6_r10O = : @ KindRep $krep5_r10L ([] @ KindRep)\r\n\r\n$krep7_r10P :: KindRep\r\n[GblId]\r\n$krep7_r10P = KindRepTyConApp $tcSn $krep6_r10O\r\n\r\n$krep8_r10Q :: KindRep\r\n[GblId]\r\n$krep8_r10Q = KindRepFun $krep_r10G $krep7_r10P\r\n\r\n$tc'SnC1_r10R :: Addr#\r\n[GblId, Caf=NoCafRefs]\r\n$tc'SnC1_r10R = \"'SnC\"#\r\n\r\n$tc'SnC2_r10S :: TrName\r\n[GblId, Caf=NoCafRefs]\r\n$tc'SnC2_r10S = TrNameS $tc'SnC1_r10R\r\n\r\n$tc'SnC :: TyCon\r\n[GblId]\r\n$tc'SnC\r\n = TyCon\r\n 3818830880305712792##\r\n 17484539998814842835##\r\n $trModule\r\n $tc'SnC2_r10S\r\n 2#\r\n $krep8_r10Q\r\n\r\n*** End of Offense ***\r\n\r\n\r\n<no location info>: error: \r\nCompilation had errors\r\n}}}\r\n\r\nIf we look at the Core for `$WSnC`, we see the culprit:\r\n\r\n{{{\r\n$WSnC\r\n = \\ (@ b_auR) (@ a_auS) (dt_aZm [Occ=Once] :: Char) >\r\n (dt_aZm\r\n `cast` (Sym (N:R:SnEither[0]\r\n <a_auS>_N <b_auR>_N) ; Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (Char :: *) ~R# (Sn (Either a_auS b_auR) :: *)))\r\n `cast` (Sym (D:R:SnEither0[0] <a_auS>_N <b_auR>_N)\r\n :: (R:SnEither a_auS b_auR :: *)\r\n ~R# (Sn (Either a_auS b_auR) :: *))\r\n}}}\r\n\r\nThe inner cast goes from `Char` to `Sn (Either a b)`, but then the outer cast goes from `R:SnEither a b` to `Sn (Either a b)`, which is not transitive.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15330Error message prints invisible kind arguments in a visible matter20190707T18:13:08ZRyan ScottError message prints invisible kind arguments in a visible matterConsider the following program:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
import Data.Proxy
data T :: forall a. a > Type
f1 :: Proxy (T True)
f1 = "foo"
f2 :: forall (t :: forall a. a > Type).
Proxy (t True)
f2 = "foo"
```
This program doesn't typecheck (for good reason). The error messages, however, are a bit iffy:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:11:6: error:
• Couldn't match expected type ‘Proxy (T 'True)’
with actual type ‘[Char]’
• In the expression: "foo"
In an equation for ‘f1’: f1 = "foo"

11  f1 = "foo"
 ^^^^^
Bug.hs:15:6: error:
• Couldn't match expected type ‘Proxy (t Bool 'True)’
with actual type ‘[Char]’
• In the expression: "foo"
In an equation for ‘f2’: f2 = "foo"
• Relevant bindings include
f2 :: Proxy (t Bool 'True) (bound at Bug.hs:15:1)

15  f2 = "foo"
 ^^^^^
```
Note that in the error message for `f1`, the type `T 'True` is printed correctly—the invisible `Bool` argument is omitted. However, in the error message for `f2`, this is not the case, as the type `t Bool 'True` is printed. That `Bool` is an invisible argument as well, and should not be printed without the use of, say, `fprintexplicitkinds`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Error message prints invisible kind arguments in a visible matter","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes #} \r\n{# LANGUAGE TypeInType #} \r\nmodule Bug where \r\n \r\nimport Data.Kind \r\nimport Data.Proxy \r\n \r\ndata T :: forall a. a > Type \r\n \r\nf1 :: Proxy (T True)\r\nf1 = \"foo\"\r\n\r\nf2 :: forall (t :: forall a. a > Type).\r\n Proxy (t True)\r\nf2 = \"foo\"\r\n}}}\r\n\r\nThis program doesn't typecheck (for good reason). The error messages, however, are a bit iffy:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:11:6: error:\r\n • Couldn't match expected type ‘Proxy (T 'True)’\r\n with actual type ‘[Char]’\r\n • In the expression: \"foo\"\r\n In an equation for ‘f1’: f1 = \"foo\"\r\n \r\n11  f1 = \"foo\"\r\n  ^^^^^\r\n\r\nBug.hs:15:6: error:\r\n • Couldn't match expected type ‘Proxy (t Bool 'True)’\r\n with actual type ‘[Char]’\r\n • In the expression: \"foo\"\r\n In an equation for ‘f2’: f2 = \"foo\"\r\n • Relevant bindings include\r\n f2 :: Proxy (t Bool 'True) (bound at Bug.hs:15:1)\r\n \r\n15  f2 = \"foo\"\r\n  ^^^^^\r\n}}}\r\n\r\nNote that in the error message for `f1`, the type `T 'True` is printed correctly—the invisible `Bool` argument is omitted. However, in the error message for `f2`, this is not the case, as the type `t Bool 'True` is printed. That `Bool` is an invisible argument as well, and should not be printed without the use of, say, `fprintexplicitkinds`.","type_of_failure":"OtherFailure","blocking":[]} >Consider the following program:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
import Data.Proxy
data T :: forall a. a > Type
f1 :: Proxy (T True)
f1 = "foo"
f2 :: forall (t :: forall a. a > Type).
Proxy (t True)
f2 = "foo"
```
This program doesn't typecheck (for good reason). The error messages, however, are a bit iffy:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:11:6: error:
• Couldn't match expected type ‘Proxy (T 'True)’
with actual type ‘[Char]’
• In the expression: "foo"
In an equation for ‘f1’: f1 = "foo"

11  f1 = "foo"
 ^^^^^
Bug.hs:15:6: error:
• Couldn't match expected type ‘Proxy (t Bool 'True)’
with actual type ‘[Char]’
• In the expression: "foo"
In an equation for ‘f2’: f2 = "foo"
• Relevant bindings include
f2 :: Proxy (t Bool 'True) (bound at Bug.hs:15:1)

15  f2 = "foo"
 ^^^^^
```
Note that in the error message for `f1`, the type `T 'True` is printed correctly—the invisible `Bool` argument is omitted. However, in the error message for `f2`, this is not the case, as the type `t Bool 'True` is printed. That `Bool` is an invisible argument as well, and should not be printed without the use of, say, `fprintexplicitkinds`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Error message prints invisible kind arguments in a visible matter","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes #} \r\n{# LANGUAGE TypeInType #} \r\nmodule Bug where \r\n \r\nimport Data.Kind \r\nimport Data.Proxy \r\n \r\ndata T :: forall a. a > Type \r\n \r\nf1 :: Proxy (T True)\r\nf1 = \"foo\"\r\n\r\nf2 :: forall (t :: forall a. a > Type).\r\n Proxy (t True)\r\nf2 = \"foo\"\r\n}}}\r\n\r\nThis program doesn't typecheck (for good reason). The error messages, however, are a bit iffy:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:11:6: error:\r\n • Couldn't match expected type ‘Proxy (T 'True)’\r\n with actual type ‘[Char]’\r\n • In the expression: \"foo\"\r\n In an equation for ‘f1’: f1 = \"foo\"\r\n \r\n11  f1 = \"foo\"\r\n  ^^^^^\r\n\r\nBug.hs:15:6: error:\r\n • Couldn't match expected type ‘Proxy (t Bool 'True)’\r\n with actual type ‘[Char]’\r\n • In the expression: \"foo\"\r\n In an equation for ‘f2’: f2 = \"foo\"\r\n • Relevant bindings include\r\n f2 :: Proxy (t Bool 'True) (bound at Bug.hs:15:1)\r\n \r\n15  f2 = \"foo\"\r\n  ^^^^^\r\n}}}\r\n\r\nNote that in the error message for `f1`, the type `T 'True` is printed correctly—the invisible `Bool` argument is omitted. However, in the error message for `f2`, this is not the case, as the type `t Bool 'True` is printed. That `Bool` is an invisible argument as well, and should not be printed without the use of, say, `fprintexplicitkinds`.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15334(forall x. c x, forall x. d x) is not equivalent to forall x. (c x, d x)20190805T08:46:55ZRyan Scott(forall x. c x, forall x. d x) is not equivalent to forall x. (c x, d x)Consider the following code:
```hs
{# LANGUAGE DeriveTraversable #}
{# LANGUAGE ExistentialQuantification #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE QuantifiedConstraints #}
{# LANGUAGE StandaloneDeriving #}
{# LANGUAGE UndecidableInstances #}
module Foo where
import Data.Kind
type family F a :: Type > Type
newtype WrappedF a b = WrapF (F a b)
deriving instance Functor (F a) => Functor (WrappedF a)
deriving instance Foldable (F a) => Foldable (WrappedF a)
deriving instance Traversable (F a) => Traversable (WrappedF a)
data SomeF b = forall a. MkSomeF (WrappedF a b)
deriving instance (forall a. Functor (WrappedF a)) => Functor SomeF
deriving instance (forall a. Foldable (WrappedF a)) => Foldable SomeF
deriving instance ( forall a. Functor (WrappedF a)
, forall a. Foldable (WrappedF a)
, forall a. Traversable (WrappedF a)
) => Traversable SomeF
```
This typechecks. However, the last `Traversable SomeF` is a bit unfortunate in that is uses three separate `forall a.`s. I attempted to factor this out, like so:
```hs
deriving instance (forall a. ( Functor (WrappedF a)
, Foldable (WrappedF a)
, Traversable (WrappedF a)
)) => Traversable SomeF
```
But then the file no longer typechecked!
```
$ /opt/ghc/8.6.1/bin/ghc Foo.hs
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )
Foo.hs:21:1: error:
• Could not deduce (Functor (F a))
arising from the superclasses of an instance declaration
from the context: forall a.
(Functor (WrappedF a), Foldable (WrappedF a),
Traversable (WrappedF a))
bound by the instance declaration at Foo.hs:(21,1)(24,52)
• In the instance declaration for ‘Traversable SomeF’

21  deriving instance (forall a. ( Functor (WrappedF a)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
Foo.hs:21:1: error:
• Could not deduce (Foldable (F a))
arising from the superclasses of an instance declaration
from the context: forall a.
(Functor (WrappedF a), Foldable (WrappedF a),
Traversable (WrappedF a))
bound by the instance declaration at Foo.hs:(21,1)(24,52)
• In the instance declaration for ‘Traversable SomeF’

21  deriving instance (forall a. ( Functor (WrappedF a)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
Foo.hs:21:1: error:
• Could not deduce (Traversable (F a1))
arising from a use of ‘traverse’
from the context: forall a.
(Functor (WrappedF a), Foldable (WrappedF a),
Traversable (WrappedF a))
bound by the instance declaration at Foo.hs:(21,1)(24,52)
or from: Applicative f
bound by the type signature for:
traverse :: forall (f :: * > *) a b.
Applicative f =>
(a > f b) > SomeF a > f (SomeF b)
at Foo.hs:(21,1)(24,52)
• In the second argument of ‘fmap’, namely ‘(traverse f a1)’
In the expression: fmap (\ b1 > MkSomeF b1) (traverse f a1)
In an equation for ‘traverse’:
traverse f (MkSomeF a1) = fmap (\ b1 > MkSomeF b1) (traverse f a1)
When typechecking the code for ‘traverse’
in a derived instance for ‘Traversable SomeF’:
To see the code I am typechecking, use ddumpderiv

21  deriving instance (forall a. ( Functor (WrappedF a)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
```
Richard suspects that this is a bug in the way quantified constraints expands superclasses, so I decided to post it here.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"(forall x. c x, forall x. d x) is not equivalent to forall x. (c x, d x)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["QuantifiedConstraints"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following code:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DeriveTraversable #}\r\n{# LANGUAGE ExistentialQuantification #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\n{# LANGUAGE StandaloneDeriving #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Foo where\r\n\r\nimport Data.Kind\r\n\r\ntype family F a :: Type > Type\r\nnewtype WrappedF a b = WrapF (F a b)\r\nderiving instance Functor (F a) => Functor (WrappedF a)\r\nderiving instance Foldable (F a) => Foldable (WrappedF a)\r\nderiving instance Traversable (F a) => Traversable (WrappedF a)\r\n\r\ndata SomeF b = forall a. MkSomeF (WrappedF a b)\r\n\r\nderiving instance (forall a. Functor (WrappedF a)) => Functor SomeF\r\nderiving instance (forall a. Foldable (WrappedF a)) => Foldable SomeF\r\nderiving instance ( forall a. Functor (WrappedF a)\r\n , forall a. Foldable (WrappedF a)\r\n , forall a. Traversable (WrappedF a)\r\n ) => Traversable SomeF\r\n}}}\r\n\r\nThis typechecks. However, the last `Traversable SomeF` is a bit unfortunate in that is uses three separate `forall a.`s. I attempted to factor this out, like so:\r\n\r\n{{{#!hs\r\nderiving instance (forall a. ( Functor (WrappedF a)\r\n , Foldable (WrappedF a)\r\n , Traversable (WrappedF a)\r\n )) => Traversable SomeF\r\n}}}\r\n\r\nBut then the file no longer typechecked!\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Foo.hs\r\n[1 of 1] Compiling Foo ( Foo.hs, Foo.o )\r\n\r\nFoo.hs:21:1: error:\r\n • Could not deduce (Functor (F a))\r\n arising from the superclasses of an instance declaration\r\n from the context: forall a.\r\n (Functor (WrappedF a), Foldable (WrappedF a),\r\n Traversable (WrappedF a))\r\n bound by the instance declaration at Foo.hs:(21,1)(24,52)\r\n • In the instance declaration for ‘Traversable SomeF’\r\n \r\n21  deriving instance (forall a. ( Functor (WrappedF a)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n\r\nFoo.hs:21:1: error:\r\n • Could not deduce (Foldable (F a))\r\n arising from the superclasses of an instance declaration\r\n from the context: forall a.\r\n (Functor (WrappedF a), Foldable (WrappedF a),\r\n Traversable (WrappedF a))\r\n bound by the instance declaration at Foo.hs:(21,1)(24,52)\r\n • In the instance declaration for ‘Traversable SomeF’\r\n \r\n21  deriving instance (forall a. ( Functor (WrappedF a)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n\r\nFoo.hs:21:1: error:\r\n • Could not deduce (Traversable (F a1))\r\n arising from a use of ‘traverse’\r\n from the context: forall a.\r\n (Functor (WrappedF a), Foldable (WrappedF a),\r\n Traversable (WrappedF a))\r\n bound by the instance declaration at Foo.hs:(21,1)(24,52)\r\n or from: Applicative f\r\n bound by the type signature for:\r\n traverse :: forall (f :: * > *) a b.\r\n Applicative f =>\r\n (a > f b) > SomeF a > f (SomeF b)\r\n at Foo.hs:(21,1)(24,52)\r\n • In the second argument of ‘fmap’, namely ‘(traverse f a1)’\r\n In the expression: fmap (\\ b1 > MkSomeF b1) (traverse f a1)\r\n In an equation for ‘traverse’:\r\n traverse f (MkSomeF a1) = fmap (\\ b1 > MkSomeF b1) (traverse f a1)\r\n When typechecking the code for ‘traverse’\r\n in a derived instance for ‘Traversable SomeF’:\r\n To see the code I am typechecking, use ddumpderiv\r\n \r\n21  deriving instance (forall a. ( Functor (WrappedF a)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n}}}\r\n\r\nRichard suspects that this is a bug in the way quantified constraints expands superclasses, so I decided to post it here.","type_of_failure":"OtherFailure","blocking":[]} >Consider the following code:
```hs
{# LANGUAGE DeriveTraversable #}
{# LANGUAGE ExistentialQuantification #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE QuantifiedConstraints #}
{# LANGUAGE StandaloneDeriving #}
{# LANGUAGE UndecidableInstances #}
module Foo where
import Data.Kind
type family F a :: Type > Type
newtype WrappedF a b = WrapF (F a b)
deriving instance Functor (F a) => Functor (WrappedF a)
deriving instance Foldable (F a) => Foldable (WrappedF a)
deriving instance Traversable (F a) => Traversable (WrappedF a)
data SomeF b = forall a. MkSomeF (WrappedF a b)
deriving instance (forall a. Functor (WrappedF a)) => Functor SomeF
deriving instance (forall a. Foldable (WrappedF a)) => Foldable SomeF
deriving instance ( forall a. Functor (WrappedF a)
, forall a. Foldable (WrappedF a)
, forall a. Traversable (WrappedF a)
) => Traversable SomeF
```
This typechecks. However, the last `Traversable SomeF` is a bit unfortunate in that is uses three separate `forall a.`s. I attempted to factor this out, like so:
```hs
deriving instance (forall a. ( Functor (WrappedF a)
, Foldable (WrappedF a)
, Traversable (WrappedF a)
)) => Traversable SomeF
```
But then the file no longer typechecked!
```
$ /opt/ghc/8.6.1/bin/ghc Foo.hs
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )
Foo.hs:21:1: error:
• Could not deduce (Functor (F a))
arising from the superclasses of an instance declaration
from the context: forall a.
(Functor (WrappedF a), Foldable (WrappedF a),
Traversable (WrappedF a))
bound by the instance declaration at Foo.hs:(21,1)(24,52)
• In the instance declaration for ‘Traversable SomeF’

21  deriving instance (forall a. ( Functor (WrappedF a)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
Foo.hs:21:1: error:
• Could not deduce (Foldable (F a))
arising from the superclasses of an instance declaration
from the context: forall a.
(Functor (WrappedF a), Foldable (WrappedF a),
Traversable (WrappedF a))
bound by the instance declaration at Foo.hs:(21,1)(24,52)
• In the instance declaration for ‘Traversable SomeF’

21  deriving instance (forall a. ( Functor (WrappedF a)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
Foo.hs:21:1: error:
• Could not deduce (Traversable (F a1))
arising from a use of ‘traverse’
from the context: forall a.
(Functor (WrappedF a), Foldable (WrappedF a),
Traversable (WrappedF a))
bound by the instance declaration at Foo.hs:(21,1)(24,52)
or from: Applicative f
bound by the type signature for:
traverse :: forall (f :: * > *) a b.
Applicative f =>
(a > f b) > SomeF a > f (SomeF b)
at Foo.hs:(21,1)(24,52)
• In the second argument of ‘fmap’, namely ‘(traverse f a1)’
In the expression: fmap (\ b1 > MkSomeF b1) (traverse f a1)
In an equation for ‘traverse’:
traverse f (MkSomeF a1) = fmap (\ b1 > MkSomeF b1) (traverse f a1)
When typechecking the code for ‘traverse’
in a derived instance for ‘Traversable SomeF’:
To see the code I am typechecking, use ddumpderiv

21  deriving instance (forall a. ( Functor (WrappedF a)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
```
Richard suspects that this is a bug in the way quantified constraints expands superclasses, so I decided to post it here.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"(forall x. c x, forall x. d x) is not equivalent to forall x. (c x, d x)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["QuantifiedConstraints"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following code:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DeriveTraversable #}\r\n{# LANGUAGE ExistentialQuantification #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\n{# LANGUAGE StandaloneDeriving #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Foo where\r\n\r\nimport Data.Kind\r\n\r\ntype family F a :: Type > Type\r\nnewtype WrappedF a b = WrapF (F a b)\r\nderiving instance Functor (F a) => Functor (WrappedF a)\r\nderiving instance Foldable (F a) => Foldable (WrappedF a)\r\nderiving instance Traversable (F a) => Traversable (WrappedF a)\r\n\r\ndata SomeF b = forall a. MkSomeF (WrappedF a b)\r\n\r\nderiving instance (forall a. Functor (WrappedF a)) => Functor SomeF\r\nderiving instance (forall a. Foldable (WrappedF a)) => Foldable SomeF\r\nderiving instance ( forall a. Functor (WrappedF a)\r\n , forall a. Foldable (WrappedF a)\r\n , forall a. Traversable (WrappedF a)\r\n ) => Traversable SomeF\r\n}}}\r\n\r\nThis typechecks. However, the last `Traversable SomeF` is a bit unfortunate in that is uses three separate `forall a.`s. I attempted to factor this out, like so:\r\n\r\n{{{#!hs\r\nderiving instance (forall a. ( Functor (WrappedF a)\r\n , Foldable (WrappedF a)\r\n , Traversable (WrappedF a)\r\n )) => Traversable SomeF\r\n}}}\r\n\r\nBut then the file no longer typechecked!\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Foo.hs\r\n[1 of 1] Compiling Foo ( Foo.hs, Foo.o )\r\n\r\nFoo.hs:21:1: error:\r\n • Could not deduce (Functor (F a))\r\n arising from the superclasses of an instance declaration\r\n from the context: forall a.\r\n (Functor (WrappedF a), Foldable (WrappedF a),\r\n Traversable (WrappedF a))\r\n bound by the instance declaration at Foo.hs:(21,1)(24,52)\r\n • In the instance declaration for ‘Traversable SomeF’\r\n \r\n21  deriving instance (forall a. ( Functor (WrappedF a)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n\r\nFoo.hs:21:1: error:\r\n • Could not deduce (Foldable (F a))\r\n arising from the superclasses of an instance declaration\r\n from the context: forall a.\r\n (Functor (WrappedF a), Foldable (WrappedF a),\r\n Traversable (WrappedF a))\r\n bound by the instance declaration at Foo.hs:(21,1)(24,52)\r\n • In the instance declaration for ‘Traversable SomeF’\r\n \r\n21  deriving instance (forall a. ( Functor (WrappedF a)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n\r\nFoo.hs:21:1: error:\r\n • Could not deduce (Traversable (F a1))\r\n arising from a use of ‘traverse’\r\n from the context: forall a.\r\n (Functor (WrappedF a), Foldable (WrappedF a),\r\n Traversable (WrappedF a))\r\n bound by the instance declaration at Foo.hs:(21,1)(24,52)\r\n or from: Applicative f\r\n bound by the type signature for:\r\n traverse :: forall (f :: * > *) a b.\r\n Applicative f =>\r\n (a > f b) > SomeF a > f (SomeF b)\r\n at Foo.hs:(21,1)(24,52)\r\n • In the second argument of ‘fmap’, namely ‘(traverse f a1)’\r\n In the expression: fmap (\\ b1 > MkSomeF b1) (traverse f a1)\r\n In an equation for ‘traverse’:\r\n traverse f (MkSomeF a1) = fmap (\\ b1 > MkSomeF b1) (traverse f a1)\r\n When typechecking the code for ‘traverse’\r\n in a derived instance for ‘Traversable SomeF’:\r\n To see the code I am typechecking, use ddumpderiv\r\n \r\n21  deriving instance (forall a. ( Functor (WrappedF a)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n}}}\r\n\r\nRichard suspects that this is a bug in the way quantified constraints expands superclasses, so I decided to post it here.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15343Implicitly quantifying a kind variable causes GHC 8.6 to panic (coercionKind)20190707T18:13:05ZRyan ScottImplicitly quantifying a kind variable causes GHC 8.6 to panic (coercionKind)The following program panics on GHC 8.6 and later:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality
data family Sing :: forall k. k > Type
data SomeSing :: Type > Type where
SomeSing :: Sing (a :: k) > SomeSing k
class SingKind k where
type Demote k :: Type
fromSing :: Sing (a :: k) > Demote k
toSing :: Demote k > SomeSing k
data instance Sing (z :: a :~~: b) where
SHRefl :: Sing HRefl
instance SingKind (a :~~: b) where
type Demote (a :~~: b) = a :~~: b
fromSing SHRefl = HRefl
toSing HRefl = SomeSing SHRefl
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
(~>:~~:) :: forall (j :: Type) (k :: Type) (a :: j) (b :: k)
(p :: forall (z :: Type) (y :: z). (a :~~: y) ~> Type)
(r :: a :~~: b).
Sing r
> Apply p HRefl
> Apply p r
(~>:~~:) SHRefl pHRefl = pHRefl
type family Why (a :: j) (e :: a :~~: (y :: z)) :: Type where
Why a (_ :: a :~~: y) = y :~~: a
data WhySym (a :: j) :: forall (y :: z). (a :~~: y) ~> Type
 data WhySym (a :: j) :: forall z (y :: z). (a :~~: y) ~> Type
 The version above does NOT panic
type instance Apply (WhySym a) e = Why a e
hsym :: forall (j :: Type) (k :: Type) (a :: j) (b :: k).
a :~~: b > b :~~: a
hsym eq = case toSing eq of
SomeSing (singEq :: Sing r) >
(~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl
```
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180627 for x86_64unknownlinux):
coercionKind
Nth:3
(Inst {co_a1jI} (Coh <k_a1js[sk:1]>_N (Nth:0 (Sym {co_a1jI}))))
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:1887:9 in ghc:Coercion
```
As noted in the comments, replacing `WhySym` with a version that explicitly quantifies `z` avoids the panic.
This is a regression from GHC 8.4.3, in which the program simply errored:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:56:38: error:
• Expected kind ‘forall z (y :: z). (a1 :~~: y) ~> *’,
but ‘WhySym a’ has kind ‘forall (y :: z0).
TyFun (a1 :~~: y) * > *’
• In the type ‘(WhySym a)’
In the expression: (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl
In a case alternative:
SomeSing (singEq :: Sing r)
> (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl
• Relevant bindings include
singEq :: Sing a2 (bound at Bug.hs:55:23)
eq :: a1 :~~: b (bound at Bug.hs:54:6)
hsym :: (a1 :~~: b) > b :~~: a1 (bound at Bug.hs:54:1)

56  (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl
 ^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Implicitly quantifying a kind variable causes GHC 8.6 to panic (coercionKind)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics on GHC 8.6 and later:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\ndata family Sing :: forall k. k > Type\r\ndata SomeSing :: Type > Type where\r\n SomeSing :: Sing (a :: k) > SomeSing k\r\n\r\nclass SingKind k where\r\n type Demote k :: Type\r\n fromSing :: Sing (a :: k) > Demote k\r\n toSing :: Demote k > SomeSing k\r\n\r\ndata instance Sing (z :: a :~~: b) where\r\n SHRefl :: Sing HRefl\r\n\r\ninstance SingKind (a :~~: b) where\r\n type Demote (a :~~: b) = a :~~: b\r\n fromSing SHRefl = HRefl\r\n toSing HRefl = SomeSing SHRefl\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\n(~>:~~:) :: forall (j :: Type) (k :: Type) (a :: j) (b :: k)\r\n (p :: forall (z :: Type) (y :: z). (a :~~: y) ~> Type)\r\n (r :: a :~~: b).\r\n Sing r\r\n > Apply p HRefl\r\n > Apply p r\r\n(~>:~~:) SHRefl pHRefl = pHRefl\r\n\r\ntype family Why (a :: j) (e :: a :~~: (y :: z)) :: Type where\r\n Why a (_ :: a :~~: y) = y :~~: a\r\n\r\ndata WhySym (a :: j) :: forall (y :: z). (a :~~: y) ~> Type\r\n data WhySym (a :: j) :: forall z (y :: z). (a :~~: y) ~> Type\r\n The version above does NOT panic\r\ntype instance Apply (WhySym a) e = Why a e\r\n\r\nhsym :: forall (j :: Type) (k :: Type) (a :: j) (b :: k).\r\n a :~~: b > b :~~: a\r\nhsym eq = case toSing eq of\r\n SomeSing (singEq :: Sing r) >\r\n (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180627 for x86_64unknownlinux):\r\n coercionKind\r\n Nth:3\r\n (Inst {co_a1jI} (Coh <k_a1js[sk:1]>_N (Nth:0 (Sym {co_a1jI}))))\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:1887:9 in ghc:Coercion\r\n}}}\r\n\r\nAs noted in the comments, replacing `WhySym` with a version that explicitly quantifies `z` avoids the panic.\r\n\r\nThis is a regression from GHC 8.4.3, in which the program simply errored:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:56:38: error:\r\n • Expected kind ‘forall z (y :: z). (a1 :~~: y) ~> *’,\r\n but ‘WhySym a’ has kind ‘forall (y :: z0).\r\n TyFun (a1 :~~: y) * > *’\r\n • In the type ‘(WhySym a)’\r\n In the expression: (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl\r\n In a case alternative:\r\n SomeSing (singEq :: Sing r)\r\n > (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl\r\n • Relevant bindings include\r\n singEq :: Sing a2 (bound at Bug.hs:55:23)\r\n eq :: a1 :~~: b (bound at Bug.hs:54:6)\r\n hsym :: (a1 :~~: b) > b :~~: a1 (bound at Bug.hs:54:1)\r\n \r\n56  (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl\r\n  ^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program panics on GHC 8.6 and later:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality
data family Sing :: forall k. k > Type
data SomeSing :: Type > Type where
SomeSing :: Sing (a :: k) > SomeSing k
class SingKind k where
type Demote k :: Type
fromSing :: Sing (a :: k) > Demote k
toSing :: Demote k > SomeSing k
data instance Sing (z :: a :~~: b) where
SHRefl :: Sing HRefl
instance SingKind (a :~~: b) where
type Demote (a :~~: b) = a :~~: b
fromSing SHRefl = HRefl
toSing HRefl = SomeSing SHRefl
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
(~>:~~:) :: forall (j :: Type) (k :: Type) (a :: j) (b :: k)
(p :: forall (z :: Type) (y :: z). (a :~~: y) ~> Type)
(r :: a :~~: b).
Sing r
> Apply p HRefl
> Apply p r
(~>:~~:) SHRefl pHRefl = pHRefl
type family Why (a :: j) (e :: a :~~: (y :: z)) :: Type where
Why a (_ :: a :~~: y) = y :~~: a
data WhySym (a :: j) :: forall (y :: z). (a :~~: y) ~> Type
 data WhySym (a :: j) :: forall z (y :: z). (a :~~: y) ~> Type
 The version above does NOT panic
type instance Apply (WhySym a) e = Why a e
hsym :: forall (j :: Type) (k :: Type) (a :: j) (b :: k).
a :~~: b > b :~~: a
hsym eq = case toSing eq of
SomeSing (singEq :: Sing r) >
(~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl
```
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180627 for x86_64unknownlinux):
coercionKind
Nth:3
(Inst {co_a1jI} (Coh <k_a1js[sk:1]>_N (Nth:0 (Sym {co_a1jI}))))
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:1887:9 in ghc:Coercion
```
As noted in the comments, replacing `WhySym` with a version that explicitly quantifies `z` avoids the panic.
This is a regression from GHC 8.4.3, in which the program simply errored:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:56:38: error:
• Expected kind ‘forall z (y :: z). (a1 :~~: y) ~> *’,
but ‘WhySym a’ has kind ‘forall (y :: z0).
TyFun (a1 :~~: y) * > *’
• In the type ‘(WhySym a)’
In the expression: (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl
In a case alternative:
SomeSing (singEq :: Sing r)
> (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl
• Relevant bindings include
singEq :: Sing a2 (bound at Bug.hs:55:23)
eq :: a1 :~~: b (bound at Bug.hs:54:6)
hsym :: (a1 :~~: b) > b :~~: a1 (bound at Bug.hs:54:1)

56  (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl
 ^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Implicitly quantifying a kind variable causes GHC 8.6 to panic (coercionKind)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics on GHC 8.6 and later:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\ndata family Sing :: forall k. k > Type\r\ndata SomeSing :: Type > Type where\r\n SomeSing :: Sing (a :: k) > SomeSing k\r\n\r\nclass SingKind k where\r\n type Demote k :: Type\r\n fromSing :: Sing (a :: k) > Demote k\r\n toSing :: Demote k > SomeSing k\r\n\r\ndata instance Sing (z :: a :~~: b) where\r\n SHRefl :: Sing HRefl\r\n\r\ninstance SingKind (a :~~: b) where\r\n type Demote (a :~~: b) = a :~~: b\r\n fromSing SHRefl = HRefl\r\n toSing HRefl = SomeSing SHRefl\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\n(~>:~~:) :: forall (j :: Type) (k :: Type) (a :: j) (b :: k)\r\n (p :: forall (z :: Type) (y :: z). (a :~~: y) ~> Type)\r\n (r :: a :~~: b).\r\n Sing r\r\n > Apply p HRefl\r\n > Apply p r\r\n(~>:~~:) SHRefl pHRefl = pHRefl\r\n\r\ntype family Why (a :: j) (e :: a :~~: (y :: z)) :: Type where\r\n Why a (_ :: a :~~: y) = y :~~: a\r\n\r\ndata WhySym (a :: j) :: forall (y :: z). (a :~~: y) ~> Type\r\n data WhySym (a :: j) :: forall z (y :: z). (a :~~: y) ~> Type\r\n The version above does NOT panic\r\ntype instance Apply (WhySym a) e = Why a e\r\n\r\nhsym :: forall (j :: Type) (k :: Type) (a :: j) (b :: k).\r\n a :~~: b > b :~~: a\r\nhsym eq = case toSing eq of\r\n SomeSing (singEq :: Sing r) >\r\n (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180627 for x86_64unknownlinux):\r\n coercionKind\r\n Nth:3\r\n (Inst {co_a1jI} (Coh <k_a1js[sk:1]>_N (Nth:0 (Sym {co_a1jI}))))\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:1887:9 in ghc:Coercion\r\n}}}\r\n\r\nAs noted in the comments, replacing `WhySym` with a version that explicitly quantifies `z` avoids the panic.\r\n\r\nThis is a regression from GHC 8.4.3, in which the program simply errored:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:56:38: error:\r\n • Expected kind ‘forall z (y :: z). (a1 :~~: y) ~> *’,\r\n but ‘WhySym a’ has kind ‘forall (y :: z0).\r\n TyFun (a1 :~~: y) * > *’\r\n • In the type ‘(WhySym a)’\r\n In the expression: (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl\r\n In a case alternative:\r\n SomeSing (singEq :: Sing r)\r\n > (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl\r\n • Relevant bindings include\r\n singEq :: Sing a2 (bound at Bug.hs:55:23)\r\n eq :: a1 :~~: b (bound at Bug.hs:54:6)\r\n hsym :: (a1 :~~: b) > b :~~: a1 (bound at Bug.hs:54:1)\r\n \r\n56  (~>:~~:) @j @k @a @b @(WhySym a) @r singEq HRefl\r\n  ^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15346Core Lint error in GHC 8.6.1: Fromtype of Cast differs from type of enclosed...20190707T18:13:04ZRyan ScottCore Lint error in GHC 8.6.1: Fromtype of Cast differs from type of enclosed expressionThe following program typechecks on GHC 8.6.1alpha1:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE DefaultSignatures #}
{# LANGUAGE EmptyCase #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module SGenerics where
import Data.Kind
import Data.Type.Equality
import Data.Void

 singletons machinery

data family Sing :: forall k. k > Type
data instance Sing :: () > Type where
STuple0 :: Sing '()
type Refuted a = a > Void
data Decision a = Proved a  Disproved (Refuted a)

 A stripped down version of GHC.Generics

data U1 = MkU1
data instance Sing (z :: U1) where
SMkU1 :: Sing MkU1

class Generic (a :: Type) where
type Rep a :: Type
from :: a > Rep a
to :: Rep a > a
class PGeneric (a :: Type) where
type PFrom (x :: a) :: Rep a
type PTo (x :: Rep a) :: a
class SGeneric k where
sFrom :: forall (a :: k). Sing a > Sing (PFrom a)
sTo :: forall (a :: Rep k). Sing a > Sing (PTo a :: k)
sTof :: forall (a :: k). Sing a > PTo (PFrom a) :~: a
sFot :: forall (a :: Rep k). Sing a > PFrom (PTo a :: k) :~: a

instance Generic () where
type Rep () = U1
from () = MkU1
to MkU1 = ()
instance PGeneric () where
type PFrom '() = MkU1
type PTo 'MkU1 = '()
instance SGeneric () where
sFrom STuple0 = SMkU1
sTo SMkU1 = STuple0
sTof STuple0 = Refl
sFot SMkU1 = Refl

class SDecide k where
  Compute a proof or disproof of equality, given two singletons.
(%~) :: forall (a :: k) (b :: k). Sing a > Sing b > Decision (a :~: b)
default (%~) :: forall (a :: k) (b :: k). (SGeneric k, SDecide (Rep k))
=> Sing a > Sing b > Decision (a :~: b)
s1 %~ s2 = case sFrom s1 %~ sFrom s2 of
Proved (Refl :: PFrom a :~: PFrom b) >
let r :: PTo (PFrom a) :~: PTo (PFrom b)
r = Refl
sTof1 :: PTo (PFrom a) :~: a
sTof1 = sTof s1
sTof2 :: PTo (PFrom b) :~: b
sTof2 = sTof s2
in Proved (sym sTof1 `trans` r `trans` sTof2)
Disproved contra > Disproved (\Refl > contra Refl)
instance SDecide U1 where
SMkU1 %~ SMkU1 = Proved Refl
instance SDecide ()
```
However, it throws a Core Lint error with `dcorelint`. The full error is absolutely massive, so I'll attach it separately. Here is the toplevel bit:
```
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
In the expression: <elided>
Fromtype of Cast differs from type of enclosed expression
Fromtype: U1
Type of enclosed expr: Rep ()
Actual enclosed expr: PFrom a_a1Fm
Coercion used in cast: Sym (D:R:Rep()[0])
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error in GHC 8.6.1: Fromtype of Cast differs from type of enclosed expression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.6.1alpha1:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE DefaultSignatures #}\r\n{# LANGUAGE EmptyCase #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule SGenerics where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\nimport Data.Void\r\n\r\n\r\n singletons machinery\r\n\r\n\r\ndata family Sing :: forall k. k > Type\r\n\r\ndata instance Sing :: () > Type where\r\n STuple0 :: Sing '()\r\n\r\ntype Refuted a = a > Void\r\ndata Decision a = Proved a  Disproved (Refuted a)\r\n\r\n\r\n A stripped down version of GHC.Generics\r\n\r\n\r\ndata U1 = MkU1\r\ndata instance Sing (z :: U1) where\r\n SMkU1 :: Sing MkU1\r\n\r\n\r\n\r\nclass Generic (a :: Type) where\r\n type Rep a :: Type\r\n from :: a > Rep a\r\n to :: Rep a > a\r\n\r\nclass PGeneric (a :: Type) where\r\n type PFrom (x :: a) :: Rep a\r\n type PTo (x :: Rep a) :: a\r\n\r\nclass SGeneric k where\r\n sFrom :: forall (a :: k). Sing a > Sing (PFrom a)\r\n sTo :: forall (a :: Rep k). Sing a > Sing (PTo a :: k)\r\n sTof :: forall (a :: k). Sing a > PTo (PFrom a) :~: a\r\n sFot :: forall (a :: Rep k). Sing a > PFrom (PTo a :: k) :~: a\r\n\r\n\r\n\r\ninstance Generic () where\r\n type Rep () = U1\r\n from () = MkU1\r\n to MkU1 = ()\r\n\r\ninstance PGeneric () where\r\n type PFrom '() = MkU1\r\n type PTo 'MkU1 = '()\r\n\r\ninstance SGeneric () where\r\n sFrom STuple0 = SMkU1\r\n sTo SMkU1 = STuple0\r\n sTof STuple0 = Refl\r\n sFot SMkU1 = Refl\r\n\r\n\r\n\r\nclass SDecide k where\r\n   Compute a proof or disproof of equality, given two singletons.\r\n (%~) :: forall (a :: k) (b :: k). Sing a > Sing b > Decision (a :~: b)\r\n default (%~) :: forall (a :: k) (b :: k). (SGeneric k, SDecide (Rep k))\r\n => Sing a > Sing b > Decision (a :~: b)\r\n s1 %~ s2 = case sFrom s1 %~ sFrom s2 of\r\n Proved (Refl :: PFrom a :~: PFrom b) >\r\n let r :: PTo (PFrom a) :~: PTo (PFrom b)\r\n r = Refl\r\n\r\n sTof1 :: PTo (PFrom a) :~: a\r\n sTof1 = sTof s1\r\n\r\n sTof2 :: PTo (PFrom b) :~: b\r\n sTof2 = sTof s2\r\n in Proved (sym sTof1 `trans` r `trans` sTof2)\r\n Disproved contra > Disproved (\\Refl > contra Refl)\r\n\r\ninstance SDecide U1 where\r\n SMkU1 %~ SMkU1 = Proved Refl\r\n\r\ninstance SDecide ()\r\n}}}\r\n\r\nHowever, it throws a Core Lint error with `dcorelint`. The full error is absolutely massive, so I'll attach it separately. Here is the toplevel bit:\r\n\r\n{{{\r\n*** Core Lint errors : in result of Simplifier ***\r\n<no location info>: warning:\r\n In the expression: <elided>\r\n Fromtype of Cast differs from type of enclosed expression\r\n Fromtype: U1\r\n Type of enclosed expr: Rep ()\r\n Actual enclosed expr: PFrom a_a1Fm\r\n Coercion used in cast: Sym (D:R:Rep()[0])\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program typechecks on GHC 8.6.1alpha1:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE DefaultSignatures #}
{# LANGUAGE EmptyCase #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module SGenerics where
import Data.Kind
import Data.Type.Equality
import Data.Void

 singletons machinery

data family Sing :: forall k. k > Type
data instance Sing :: () > Type where
STuple0 :: Sing '()
type Refuted a = a > Void
data Decision a = Proved a  Disproved (Refuted a)

 A stripped down version of GHC.Generics

data U1 = MkU1
data instance Sing (z :: U1) where
SMkU1 :: Sing MkU1

class Generic (a :: Type) where
type Rep a :: Type
from :: a > Rep a
to :: Rep a > a
class PGeneric (a :: Type) where
type PFrom (x :: a) :: Rep a
type PTo (x :: Rep a) :: a
class SGeneric k where
sFrom :: forall (a :: k). Sing a > Sing (PFrom a)
sTo :: forall (a :: Rep k). Sing a > Sing (PTo a :: k)
sTof :: forall (a :: k). Sing a > PTo (PFrom a) :~: a
sFot :: forall (a :: Rep k). Sing a > PFrom (PTo a :: k) :~: a

instance Generic () where
type Rep () = U1
from () = MkU1
to MkU1 = ()
instance PGeneric () where
type PFrom '() = MkU1
type PTo 'MkU1 = '()
instance SGeneric () where
sFrom STuple0 = SMkU1
sTo SMkU1 = STuple0
sTof STuple0 = Refl
sFot SMkU1 = Refl

class SDecide k where
  Compute a proof or disproof of equality, given two singletons.
(%~) :: forall (a :: k) (b :: k). Sing a > Sing b > Decision (a :~: b)
default (%~) :: forall (a :: k) (b :: k). (SGeneric k, SDecide (Rep k))
=> Sing a > Sing b > Decision (a :~: b)
s1 %~ s2 = case sFrom s1 %~ sFrom s2 of
Proved (Refl :: PFrom a :~: PFrom b) >
let r :: PTo (PFrom a) :~: PTo (PFrom b)
r = Refl
sTof1 :: PTo (PFrom a) :~: a
sTof1 = sTof s1
sTof2 :: PTo (PFrom b) :~: b
sTof2 = sTof s2
in Proved (sym sTof1 `trans` r `trans` sTof2)
Disproved contra > Disproved (\Refl > contra Refl)
instance SDecide U1 where
SMkU1 %~ SMkU1 = Proved Refl
instance SDecide ()
```
However, it throws a Core Lint error with `dcorelint`. The full error is absolutely massive, so I'll attach it separately. Here is the toplevel bit:
```
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
In the expression: <elided>
Fromtype of Cast differs from type of enclosed expression
Fromtype: U1
Type of enclosed expr: Rep ()
Actual enclosed expr: PFrom a_a1Fm
Coercion used in cast: Sym (D:R:Rep()[0])
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error in GHC 8.6.1: Fromtype of Cast differs from type of enclosed expression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.6.1alpha1:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE DefaultSignatures #}\r\n{# LANGUAGE EmptyCase #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule SGenerics where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\nimport Data.Void\r\n\r\n\r\n singletons machinery\r\n\r\n\r\ndata family Sing :: forall k. k > Type\r\n\r\ndata instance Sing :: () > Type where\r\n STuple0 :: Sing '()\r\n\r\ntype Refuted a = a > Void\r\ndata Decision a = Proved a  Disproved (Refuted a)\r\n\r\n\r\n A stripped down version of GHC.Generics\r\n\r\n\r\ndata U1 = MkU1\r\ndata instance Sing (z :: U1) where\r\n SMkU1 :: Sing MkU1\r\n\r\n\r\n\r\nclass Generic (a :: Type) where\r\n type Rep a :: Type\r\n from :: a > Rep a\r\n to :: Rep a > a\r\n\r\nclass PGeneric (a :: Type) where\r\n type PFrom (x :: a) :: Rep a\r\n type PTo (x :: Rep a) :: a\r\n\r\nclass SGeneric k where\r\n sFrom :: forall (a :: k). Sing a > Sing (PFrom a)\r\n sTo :: forall (a :: Rep k). Sing a > Sing (PTo a :: k)\r\n sTof :: forall (a :: k). Sing a > PTo (PFrom a) :~: a\r\n sFot :: forall (a :: Rep k). Sing a > PFrom (PTo a :: k) :~: a\r\n\r\n\r\n\r\ninstance Generic () where\r\n type Rep () = U1\r\n from () = MkU1\r\n to MkU1 = ()\r\n\r\ninstance PGeneric () where\r\n type PFrom '() = MkU1\r\n type PTo 'MkU1 = '()\r\n\r\ninstance SGeneric () where\r\n sFrom STuple0 = SMkU1\r\n sTo SMkU1 = STuple0\r\n sTof STuple0 = Refl\r\n sFot SMkU1 = Refl\r\n\r\n\r\n\r\nclass SDecide k where\r\n   Compute a proof or disproof of equality, given two singletons.\r\n (%~) :: forall (a :: k) (b :: k). Sing a > Sing b > Decision (a :~: b)\r\n default (%~) :: forall (a :: k) (b :: k). (SGeneric k, SDecide (Rep k))\r\n => Sing a > Sing b > Decision (a :~: b)\r\n s1 %~ s2 = case sFrom s1 %~ sFrom s2 of\r\n Proved (Refl :: PFrom a :~: PFrom b) >\r\n let r :: PTo (PFrom a) :~: PTo (PFrom b)\r\n r = Refl\r\n\r\n sTof1 :: PTo (PFrom a) :~: a\r\n sTof1 = sTof s1\r\n\r\n sTof2 :: PTo (PFrom b) :~: b\r\n sTof2 = sTof s2\r\n in Proved (sym sTof1 `trans` r `trans` sTof2)\r\n Disproved contra > Disproved (\\Refl > contra Refl)\r\n\r\ninstance SDecide U1 where\r\n SMkU1 %~ SMkU1 = Proved Refl\r\n\r\ninstance SDecide ()\r\n}}}\r\n\r\nHowever, it throws a Core Lint error with `dcorelint`. The full error is absolutely massive, so I'll attach it separately. Here is the toplevel bit:\r\n\r\n{{{\r\n*** Core Lint errors : in result of Simplifier ***\r\n<no location info>: warning:\r\n In the expression: <elided>\r\n Fromtype of Cast differs from type of enclosed expression\r\n Fromtype: U1\r\n Type of enclosed expr: Rep ()\r\n Actual enclosed expr: PFrom a_a1Fm\r\n Coercion used in cast: Sym (D:R:Rep()[0])\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15347QuantifiedConstraints: Implication constraints with type families don't work20190918T06:46:06ZaaronvargoQuantifiedConstraints: Implication constraints with type families don't workThis may be related to #14860, but I think it's different.
The following code fails to compile:
```hs
{# LANGUAGE QuantifiedConstraints #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE GADTs #}
{# LANGUAGE ConstraintKinds #}
import Prelude()
import Data.Kind
data Dict c = c => Dict
type family F a :: Constraint
foo :: forall a b. (a => F b, a) => Dict (F b)
foo = Dict
```
```
• Could not deduce: F b arising from a use of ‘Dict’
from the context: (a => F b, a)
```
Yet the following all do compile:
```hs
bar :: forall a. F a => Dict (F a)
bar = Dict
baz :: forall a b. (a => b, a) => Dict b
baz = Dict
qux :: forall a b c. (a => c, a, c ~ F b) => Dict (F b)
qux = Dict
```
It seems that a wanted `F b` can be solved with a given `F b`, but not with a given `a => F b`, which is bizarre. The fact that `qux` still works is also strange, as it means that you get a different result if you first simplify by substituting `c = F b`.
As a more practical example, the following similarly fails to compile, due to the `Cod f` type family:
```hs
 in addition to the above extensions
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE FunctionalDependencies #}
class Ob p a
class (forall a. Ob (Dom f) a => Ob (Cod f) (f a)) => Functor f where
type Dom f
type Cod f
liftOb :: forall f a. (Functor f, Ob (Dom f) a) => Dict (Ob (Cod f) (f a))
liftOb = Dict
```
While a version which uses fundeps instead does compile:
```hs
class (forall a. Ob dom a => Ob cod (f a)) => Functor dom cod f  f > dom cod
liftOb :: forall f a dom cod. (Functor dom cod f, Ob dom a) => Dict (Ob cod (f a))
liftOb = Dict
```This may be related to #14860, but I think it's different.
The following code fails to compile:
```hs
{# LANGUAGE QuantifiedConstraints #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE GADTs #}
{# LANGUAGE ConstraintKinds #}
import Prelude()
import Data.Kind
data Dict c = c => Dict
type family F a :: Constraint
foo :: forall a b. (a => F b, a) => Dict (F b)
foo = Dict
```
```
• Could not deduce: F b arising from a use of ‘Dict’
from the context: (a => F b, a)
```
Yet the following all do compile:
```hs
bar :: forall a. F a => Dict (F a)
bar = Dict
baz :: forall a b. (a => b, a) => Dict b
baz = Dict
qux :: forall a b c. (a => c, a, c ~ F b) => Dict (F b)
qux = Dict
```
It seems that a wanted `F b` can be solved with a given `F b`, but not with a given `a => F b`, which is bizarre. The fact that `qux` still works is also strange, as it means that you get a different result if you first simplify by substituting `c = F b`.
As a more practical example, the following similarly fails to compile, due to the `Cod f` type family:
```hs
 in addition to the above extensions
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE FunctionalDependencies #}
class Ob p a
class (forall a. Ob (Dom f) a => Ob (Cod f) (f a)) => Functor f where
type Dom f
type Cod f
liftOb :: forall f a. (Functor f, Ob (Dom f) a) => Dict (Ob (Cod f) (f a))
liftOb = Dict
```
While a version which uses fundeps instead does compile:
```hs
class (forall a. Ob dom a => Ob cod (f a)) => Functor dom cod f  f > dom cod
liftOb :: forall f a dom cod. (Functor dom cod f, Ob dom a) => Dict (Ob cod (f a))
liftOb = Dict
```https://gitlab.haskell.org/ghc/ghc//issues/15351QuantifiedConstraints ignore FunctionalDependencies20201203T08:24:56ZaaronvargoQuantifiedConstraints ignore FunctionalDependenciesThe following code fails to compile:
```hs
{# LANGUAGE QuantifiedConstraints #}
{# LANGUAGE FunctionalDependencies #}
class C a b  a > b where
foo :: a > b
bar :: (forall a. C (f a) Int) => f a > String
bar = show . foo
```
```
• Could not deduce (Show a0) arising from a use of ‘show’
...
The type variable ‘a0’ is ambiguous
• Could not deduce (C (f a) a0) arising from a use of ‘foo’
...
The type variable ‘a0’ is ambiguous
```
Yet it ought to work, since this is perfectly fine with toplevel instances:
```hs
instance C [a] Int where ...
baz :: [a] > String
baz = show . foo
```The following code fails to compile:
```hs
{# LANGUAGE QuantifiedConstraints #}
{# LANGUAGE FunctionalDependencies #}
class C a b  a > b where
foo :: a > b
bar :: (forall a. C (f a) Int) => f a > String
bar = show . foo
```
```
• Could not deduce (Show a0) arising from a use of ‘show’
...
The type variable ‘a0’ is ambiguous
• Could not deduce (C (f a) a0) arising from a use of ‘foo’
...
The type variable ‘a0’ is ambiguous
```
Yet it ought to work, since this is perfectly fine with toplevel instances:
```hs
instance C [a] Int where ...
baz :: [a] > String
baz = show . foo
```https://gitlab.haskell.org/ghc/ghc//issues/15352False kind errors with implicitly bound kinds in GHC 8.620190707T18:13:02ZaaronvargoFalse kind errors with implicitly bound kinds in GHC 8.6This could be related to #15343.
The following code fails to compile with GHC 8.6.0.20180627, but does compile with 8.4:
```hs
{# LANGUAGE TypeInType #}  or PolyKinds
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE TypeFamilies #}
import Data.Kind
class C (x :: Type) (y :: k) where
type F y
```
```
• Expected a type, but ‘k’ has kind ‘k’
• In the kind ‘k’

7  class C (x :: Type) (y :: k) where
 ^
```
Yet all of the following slightly different examples still do compile:
```hs
 remove `x`
class C0 (y :: k) where type F0 y
 remove `F`
class C1 (x :: Type) (y :: k)
 remove the kind annotation from `x`
class C2 x (y :: k) where type F2 y
 switch the order of `x` and `y`
class C3 (y :: k) (x :: Type) where type F3 y
 make `k` an explicit parameter, with or without a kind annotation
class C4 k (x :: Type) (y :: k) where type F4 y
class C5 (k :: Type) (x :: Type) (y :: k) where type F5 y
 add a new parameter *with no kind annotation*
class C6 z (x :: Type) (y :: k) where type F6 y
```
Here's also my original example which failed to compile:
```hs
type Hom k = k > k > Type
type family Ob (p :: Hom k) :: k > Constraint
class ( obP ~ Ob p
, opP ~ Dom p
, obQ ~ Ob q
, opQ ~ Dom q
, p ~ Dom f
, q ~ Cod f
) => Functor' (obP :: i > Constraint)
(opP :: Hom i)
(p :: Hom i)
(obQ :: j > Constraint)
(opQ :: Hom j)
(q :: Hom j)
(f :: i > j) where
type Dom f :: Hom i
type Cod f :: Hom j
```
```
• Expected a type, but ‘j’ has kind ‘k’
• In the first argument of ‘Hom’, namely ‘j’
In the kind ‘Hom j’

34  type Cod f :: Hom j
 ^
```
The only way I can find to make this one compile is to make `i` and `j` explicit parameters with explicit kinds:
```hs
class ( obP ~ Ob p
, opP ~ Dom p
, obQ ~ Ob q
, opQ ~ Dom q
, p ~ Dom f
, q ~ Cod f
) => Functor' (i :: Type)
(j :: Type)
(obP :: i > Constraint)
(opP :: Hom i)
(p :: Hom i)
(obQ :: j > Constraint)
(opQ :: Hom j)
(q :: Hom j)
(f :: i > j) where
type Dom f :: Hom i
type Cod f :: Hom j
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"False kind errors with implicitly bound kinds in GHC 8.6","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This could be related to #15343.\r\n\r\nThe following code fails to compile with GHC 8.6.0.20180627, but does compile with 8.4:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeInType #}  or PolyKinds\r\n{# LANGUAGE MultiParamTypeClasses #}\r\n{# LANGUAGE TypeFamilies #}\r\n\r\nimport Data.Kind\r\n\r\nclass C (x :: Type) (y :: k) where\r\n type F y\r\n}}}\r\n\r\n{{{\r\n • Expected a type, but ‘k’ has kind ‘k’\r\n • In the kind ‘k’\r\n \r\n7  class C (x :: Type) (y :: k) where\r\n  ^\r\n}}}\r\n\r\nYet all of the following slightly different examples still do compile:\r\n\r\n{{{#!hs\r\n remove `x`\r\nclass C0 (y :: k) where type F0 y\r\n\r\n remove `F`\r\nclass C1 (x :: Type) (y :: k)\r\n\r\n remove the kind annotation from `x`\r\nclass C2 x (y :: k) where type F2 y\r\n\r\n switch the order of `x` and `y`\r\nclass C3 (y :: k) (x :: Type) where type F3 y\r\n\r\n make `k` an explicit parameter, with or without a kind annotation\r\nclass C4 k (x :: Type) (y :: k) where type F4 y\r\nclass C5 (k :: Type) (x :: Type) (y :: k) where type F5 y\r\n\r\n add a new parameter *with no kind annotation*\r\nclass C6 z (x :: Type) (y :: k) where type F6 y\r\n}}}\r\n\r\nHere's also my original example which failed to compile:\r\n\r\n{{{#!hs\r\ntype Hom k = k > k > Type\r\n\r\ntype family Ob (p :: Hom k) :: k > Constraint\r\n\r\nclass ( obP ~ Ob p\r\n , opP ~ Dom p\r\n , obQ ~ Ob q\r\n , opQ ~ Dom q\r\n , p ~ Dom f\r\n , q ~ Cod f\r\n ) => Functor' (obP :: i > Constraint)\r\n (opP :: Hom i)\r\n (p :: Hom i)\r\n (obQ :: j > Constraint)\r\n (opQ :: Hom j)\r\n (q :: Hom j)\r\n (f :: i > j) where\r\n type Dom f :: Hom i\r\n type Cod f :: Hom j\r\n}}}\r\n\r\n{{{\r\n • Expected a type, but ‘j’ has kind ‘k’\r\n • In the first argument of ‘Hom’, namely ‘j’\r\n In the kind ‘Hom j’\r\n \r\n34  type Cod f :: Hom j\r\n  ^\r\n}}}\r\n\r\nThe only way I can find to make this one compile is to make `i` and `j` explicit parameters with explicit kinds:\r\n\r\n{{{#!hs\r\nclass ( obP ~ Ob p\r\n , opP ~ Dom p\r\n , obQ ~ Ob q\r\n , opQ ~ Dom q\r\n , p ~ Dom f\r\n , q ~ Cod f\r\n ) => Functor' (i :: Type)\r\n (j :: Type)\r\n (obP :: i > Constraint)\r\n (opP :: Hom i)\r\n (p :: Hom i)\r\n (obQ :: j > Constraint)\r\n (opQ :: Hom j)\r\n (q :: Hom j)\r\n (f :: i > j) where\r\n type Dom f :: Hom i\r\n type Cod f :: Hom j\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >This could be related to #15343.
The following code fails to compile with GHC 8.6.0.20180627, but does compile with 8.4:
```hs
{# LANGUAGE TypeInType #}  or PolyKinds
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE TypeFamilies #}
import Data.Kind
class C (x :: Type) (y :: k) where
type F y
```
```
• Expected a type, but ‘k’ has kind ‘k’
• In the kind ‘k’

7  class C (x :: Type) (y :: k) where
 ^
```
Yet all of the following slightly different examples still do compile:
```hs
 remove `x`
class C0 (y :: k) where type F0 y
 remove `F`
class C1 (x :: Type) (y :: k)
 remove the kind annotation from `x`
class C2 x (y :: k) where type F2 y
 switch the order of `x` and `y`
class C3 (y :: k) (x :: Type) where type F3 y
 make `k` an explicit parameter, with or without a kind annotation
class C4 k (x :: Type) (y :: k) where type F4 y
class C5 (k :: Type) (x :: Type) (y :: k) where type F5 y
 add a new parameter *with no kind annotation*
class C6 z (x :: Type) (y :: k) where type F6 y
```
Here's also my original example which failed to compile:
```hs
type Hom k = k > k > Type
type family Ob (p :: Hom k) :: k > Constraint
class ( obP ~ Ob p
, opP ~ Dom p
, obQ ~ Ob q
, opQ ~ Dom q
, p ~ Dom f
, q ~ Cod f
) => Functor' (obP :: i > Constraint)
(opP :: Hom i)
(p :: Hom i)
(obQ :: j > Constraint)
(opQ :: Hom j)
(q :: Hom j)
(f :: i > j) where
type Dom f :: Hom i
type Cod f :: Hom j
```
```
• Expected a type, but ‘j’ has kind ‘k’
• In the first argument of ‘Hom’, namely ‘j’
In the kind ‘Hom j’

34  type Cod f :: Hom j
 ^
```
The only way I can find to make this one compile is to make `i` and `j` explicit parameters with explicit kinds:
```hs
class ( obP ~ Ob p
, opP ~ Dom p
, obQ ~ Ob q
, opQ ~ Dom q
, p ~ Dom f
, q ~ Cod f
) => Functor' (i :: Type)
(j :: Type)
(obP :: i > Constraint)
(opP :: Hom i)
(p :: Hom i)
(obQ :: j > Constraint)
(opQ :: Hom j)
(q :: Hom j)
(f :: i > j) where
type Dom f :: Hom i
type Cod f :: Hom j
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"False kind errors with implicitly bound kinds in GHC 8.6","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This could be related to #15343.\r\n\r\nThe following code fails to compile with GHC 8.6.0.20180627, but does compile with 8.4:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeInType #}  or PolyKinds\r\n{# LANGUAGE MultiParamTypeClasses #}\r\n{# LANGUAGE TypeFamilies #}\r\n\r\nimport Data.Kind\r\n\r\nclass C (x :: Type) (y :: k) where\r\n type F y\r\n}}}\r\n\r\n{{{\r\n • Expected a type, but ‘k’ has kind ‘k’\r\n • In the kind ‘k’\r\n \r\n7  class C (x :: Type) (y :: k) where\r\n  ^\r\n}}}\r\n\r\nYet all of the following slightly different examples still do compile:\r\n\r\n{{{#!hs\r\n remove `x`\r\nclass C0 (y :: k) where type F0 y\r\n\r\n remove `F`\r\nclass C1 (x :: Type) (y :: k)\r\n\r\n remove the kind annotation from `x`\r\nclass C2 x (y :: k) where type F2 y\r\n\r\n switch the order of `x` and `y`\r\nclass C3 (y :: k) (x :: Type) where type F3 y\r\n\r\n make `k` an explicit parameter, with or without a kind annotation\r\nclass C4 k (x :: Type) (y :: k) where type F4 y\r\nclass C5 (k :: Type) (x :: Type) (y :: k) where type F5 y\r\n\r\n add a new parameter *with no kind annotation*\r\nclass C6 z (x :: Type) (y :: k) where type F6 y\r\n}}}\r\n\r\nHere's also my original example which failed to compile:\r\n\r\n{{{#!hs\r\ntype Hom k = k > k > Type\r\n\r\ntype family Ob (p :: Hom k) :: k > Constraint\r\n\r\nclass ( obP ~ Ob p\r\n , opP ~ Dom p\r\n , obQ ~ Ob q\r\n , opQ ~ Dom q\r\n , p ~ Dom f\r\n , q ~ Cod f\r\n ) => Functor' (obP :: i > Constraint)\r\n (opP :: Hom i)\r\n (p :: Hom i)\r\n (obQ :: j > Constraint)\r\n (opQ :: Hom j)\r\n (q :: Hom j)\r\n (f :: i > j) where\r\n type Dom f :: Hom i\r\n type Cod f :: Hom j\r\n}}}\r\n\r\n{{{\r\n • Expected a type, but ‘j’ has kind ‘k’\r\n • In the first argument of ‘Hom’, namely ‘j’\r\n In the kind ‘Hom j’\r\n \r\n34  type Cod f :: Hom j\r\n  ^\r\n}}}\r\n\r\nThe only way I can find to make this one compile is to make `i` and `j` explicit parameters with explicit kinds:\r\n\r\n{{{#!hs\r\nclass ( obP ~ Ob p\r\n , opP ~ Dom p\r\n , obQ ~ Ob q\r\n , opQ ~ Dom q\r\n , p ~ Dom f\r\n , q ~ Cod f\r\n ) => Functor' (i :: Type)\r\n (j :: Type)\r\n (obP :: i > Constraint)\r\n (opP :: Hom i)\r\n (p :: Hom i)\r\n (obQ :: j > Constraint)\r\n (opQ :: Hom j)\r\n (q :: Hom j)\r\n (f :: i > j) where\r\n type Dom f :: Hom i\r\n type Cod f :: Hom j\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15361Error message displays redundant equality constraint20190707T18:13:00ZRyan ScottError message displays redundant equality constraintWhen compiling this program:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE KindSignatures #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality
foo :: forall (a :: Type) (b :: Type) (c :: Type).
a :~~: b > a :~~: c
foo HRefl = HRefl
```
GHC complains thus:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:12:13: error:
• Could not deduce: a ~ c
from the context: (* ~ *, b ~ a)
bound by a pattern with constructor:
HRefl :: forall k1 (a :: k1). a :~~: a,
in an equation for ‘foo’
at Bug.hs:12:59
‘a’ is a rigid type variable bound by
the type signature for:
foo :: forall a b c. (a :~~: b) > a :~~: c
at Bug.hs:(10,1)(11,27)
‘c’ is a rigid type variable bound by
the type signature for:
foo :: forall a b c. (a :~~: b) > a :~~: c
at Bug.hs:(10,1)(11,27)
Expected type: a :~~: c
Actual type: a :~~: a
• In the expression: HRefl
In an equation for ‘foo’: foo HRefl = HRefl
• Relevant bindings include
foo :: (a :~~: b) > a :~~: c (bound at Bug.hs:12:1)

12  foo HRefl = HRefl
 ^^^^^
```
That `* ~ *` constraint is entirely redundant.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Error message displays redundant equality constraint","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When compiling this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE KindSignatures #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\nfoo :: forall (a :: Type) (b :: Type) (c :: Type).\r\n a :~~: b > a :~~: c\r\nfoo HRefl = HRefl\r\n}}}\r\n\r\nGHC complains thus:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:12:13: error:\r\n • Could not deduce: a ~ c\r\n from the context: (* ~ *, b ~ a)\r\n bound by a pattern with constructor:\r\n HRefl :: forall k1 (a :: k1). a :~~: a,\r\n in an equation for ‘foo’\r\n at Bug.hs:12:59\r\n ‘a’ is a rigid type variable bound by\r\n the type signature for:\r\n foo :: forall a b c. (a :~~: b) > a :~~: c\r\n at Bug.hs:(10,1)(11,27)\r\n ‘c’ is a rigid type variable bound by\r\n the type signature for:\r\n foo :: forall a b c. (a :~~: b) > a :~~: c\r\n at Bug.hs:(10,1)(11,27)\r\n Expected type: a :~~: c\r\n Actual type: a :~~: a\r\n • In the expression: HRefl\r\n In an equation for ‘foo’: foo HRefl = HRefl\r\n • Relevant bindings include\r\n foo :: (a :~~: b) > a :~~: c (bound at Bug.hs:12:1)\r\n \r\n12  foo HRefl = HRefl\r\n  ^^^^^\r\n}}}\r\n\r\nThat `* ~ *` constraint is entirely redundant.","type_of_failure":"OtherFailure","blocking":[]} >When compiling this program:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE KindSignatures #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality
foo :: forall (a :: Type) (b :: Type) (c :: Type).
a :~~: b > a :~~: c
foo HRefl = HRefl
```
GHC complains thus:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:12:13: error:
• Could not deduce: a ~ c
from the context: (* ~ *, b ~ a)
bound by a pattern with constructor:
HRefl :: forall k1 (a :: k1). a :~~: a,
in an equation for ‘foo’
at Bug.hs:12:59
‘a’ is a rigid type variable bound by
the type signature for:
foo :: forall a b c. (a :~~: b) > a :~~: c
at Bug.hs:(10,1)(11,27)
‘c’ is a rigid type variable bound by
the type signature for:
foo :: forall a b c. (a :~~: b) > a :~~: c
at Bug.hs:(10,1)(11,27)
Expected type: a :~~: c
Actual type: a :~~: a
• In the expression: HRefl
In an equation for ‘foo’: foo HRefl = HRefl
• Relevant bindings include
foo :: (a :~~: b) > a :~~: c (bound at Bug.hs:12:1)

12  foo HRefl = HRefl
 ^^^^^
```
That `* ~ *` constraint is entirely redundant.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Error message displays redundant equality constraint","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When compiling this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE KindSignatures #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\nfoo :: forall (a :: Type) (b :: Type) (c :: Type).\r\n a :~~: b > a :~~: c\r\nfoo HRefl = HRefl\r\n}}}\r\n\r\nGHC complains thus:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:12:13: error:\r\n • Could not deduce: a ~ c\r\n from the context: (* ~ *, b ~ a)\r\n bound by a pattern with constructor:\r\n HRefl :: forall k1 (a :: k1). a :~~: a,\r\n in an equation for ‘foo’\r\n at Bug.hs:12:59\r\n ‘a’ is a rigid type variable bound by\r\n the type signature for:\r\n foo :: forall a b c. (a :~~: b) > a :~~: c\r\n at Bug.hs:(10,1)(11,27)\r\n ‘c’ is a rigid type variable bound by\r\n the type signature for:\r\n foo :: forall a b c. (a :~~: b) > a :~~: c\r\n at Bug.hs:(10,1)(11,27)\r\n Expected type: a :~~: c\r\n Actual type: a :~~: a\r\n • In the expression: HRefl\r\n In an equation for ‘foo’: foo HRefl = HRefl\r\n • Relevant bindings include\r\n foo :: (a :~~: b) > a :~~: c (bound at Bug.hs:12:1)\r\n \r\n12  foo HRefl = HRefl\r\n  ^^^^^\r\n}}}\r\n\r\nThat `* ~ *` constraint is entirely redundant.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15370Typed hole panic on GHC 8.6 (tcTyVarDetails)20190707T18:12:57ZRyan ScottTyped hole panic on GHC 8.6 (tcTyVarDetails)The following program panics on GHC 8.6 and HEAD:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality
import Data.Void
data family Sing :: forall k. k > Type
data (~>) :: Type > Type > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }
mkRefl :: n :~: j
mkRefl = Refl
right :: forall (r :: (x :~: y) ~> z).
Sing r > ()
right no =
case mkRefl @x @y of
Refl > applySing no _
```
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180627 for x86_64unknownlinux):
tcTyVarDetails
co_a1BG :: y_a1Bz[sk:1] ~# x_a1By[sk:1]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable
pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var
```
On GHC 8.4, this simply errors:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:23:10: error:
• Couldn't match type ‘n’ with ‘j’
‘n’ is a rigid type variable bound by
the type signature for:
mkRefl :: forall k1 (n :: k1) (j :: k1). n :~: j
at Bug.hs:22:117
‘j’ is a rigid type variable bound by
the type signature for:
mkRefl :: forall k1 (n :: k1) (j :: k1). n :~: j
at Bug.hs:22:117
Expected type: n :~: j
Actual type: n :~: n
• In the expression: Refl
In an equation for ‘mkRefl’: mkRefl = Refl
• Relevant bindings include
mkRefl :: n :~: j (bound at Bug.hs:23:1)

23  mkRefl = Refl
 ^^^^
Bug.hs:29:13: error:
• Couldn't match type ‘Sing (Apply r t0)’ with ‘()’
Expected type: ()
Actual type: Sing (Apply r t0)
• In the expression: applySing no _
In a case alternative: Refl > applySing no _
In the expression: case mkRefl @x @y of { Refl > applySing no _ }
• Relevant bindings include
no :: Sing r (bound at Bug.hs:27:7)
right :: Sing r > () (bound at Bug.hs:27:1)

29  Refl > applySing no _
 ^^^^^^^^^^^^^^
Bug.hs:29:26: error:
• Found hole: _ :: Sing t0
Where: ‘t0’ is an ambiguous type variable
‘y’, ‘x’, ‘k’ are rigid type variables bound by
the type signature for:
right :: forall k1 (x1 :: k1) (y1 :: k1) z (r :: (x1 :~: y1) ~> z).
Sing r > ()
at Bug.hs:(25,1)(26,21)
• In the second argument of ‘applySing’, namely ‘_’
In the expression: applySing no _
In a case alternative: Refl > applySing no _
• Relevant bindings include
no :: Sing r (bound at Bug.hs:27:7)
right :: Sing r > () (bound at Bug.hs:27:1)
Valid substitutions include
undefined :: forall (a :: TYPE r).
GHC.Stack.Types.HasCallStack =>
a
(imported from ‘Prelude’ at Bug.hs:7:810
(and originally defined in ‘GHC.Err’))

29  Refl > applySing no _
 ^
```
Note that this is distinct from #15142, as this is still reproducible on HEAD, even after commit 030211d21207dabb7a4bf21cc9af6fa5eb066db1.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Typed hole panic on GHC 8.6 (tcTyVarDetails)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType,","TypedHoles"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics on GHC 8.6 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\nimport Data.Void\r\n\r\ndata family Sing :: forall k. k > Type\r\n\r\ndata (~>) :: Type > Type > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }\r\n\r\nmkRefl :: n :~: j\r\nmkRefl = Refl\r\n\r\nright :: forall (r :: (x :~: y) ~> z).\r\n Sing r > ()\r\nright no =\r\n case mkRefl @x @y of\r\n Refl > applySing no _\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180627 for x86_64unknownlinux):\r\n tcTyVarDetails\r\n co_a1BG :: y_a1Bz[sk:1] ~# x_a1By[sk:1]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable\r\n pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var\r\n}}}\r\n\r\nOn GHC 8.4, this simply errors:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:23:10: error:\r\n • Couldn't match type ‘n’ with ‘j’\r\n ‘n’ is a rigid type variable bound by\r\n the type signature for:\r\n mkRefl :: forall k1 (n :: k1) (j :: k1). n :~: j\r\n at Bug.hs:22:117\r\n ‘j’ is a rigid type variable bound by\r\n the type signature for:\r\n mkRefl :: forall k1 (n :: k1) (j :: k1). n :~: j\r\n at Bug.hs:22:117\r\n Expected type: n :~: j\r\n Actual type: n :~: n\r\n • In the expression: Refl\r\n In an equation for ‘mkRefl’: mkRefl = Refl\r\n • Relevant bindings include\r\n mkRefl :: n :~: j (bound at Bug.hs:23:1)\r\n \r\n23  mkRefl = Refl\r\n  ^^^^\r\n\r\nBug.hs:29:13: error:\r\n • Couldn't match type ‘Sing (Apply r t0)’ with ‘()’\r\n Expected type: ()\r\n Actual type: Sing (Apply r t0)\r\n • In the expression: applySing no _\r\n In a case alternative: Refl > applySing no _\r\n In the expression: case mkRefl @x @y of { Refl > applySing no _ }\r\n • Relevant bindings include\r\n no :: Sing r (bound at Bug.hs:27:7)\r\n right :: Sing r > () (bound at Bug.hs:27:1)\r\n \r\n29  Refl > applySing no _\r\n  ^^^^^^^^^^^^^^\r\n\r\nBug.hs:29:26: error:\r\n • Found hole: _ :: Sing t0\r\n Where: ‘t0’ is an ambiguous type variable\r\n ‘y’, ‘x’, ‘k’ are rigid type variables bound by\r\n the type signature for:\r\n right :: forall k1 (x1 :: k1) (y1 :: k1) z (r :: (x1 :~: y1) ~> z).\r\n Sing r > ()\r\n at Bug.hs:(25,1)(26,21)\r\n • In the second argument of ‘applySing’, namely ‘_’\r\n In the expression: applySing no _\r\n In a case alternative: Refl > applySing no _\r\n • Relevant bindings include\r\n no :: Sing r (bound at Bug.hs:27:7)\r\n right :: Sing r > () (bound at Bug.hs:27:1)\r\n Valid substitutions include\r\n undefined :: forall (a :: TYPE r).\r\n GHC.Stack.Types.HasCallStack =>\r\n a\r\n (imported from ‘Prelude’ at Bug.hs:7:810\r\n (and originally defined in ‘GHC.Err’))\r\n \r\n29  Refl > applySing no _\r\n  ^\r\n}}}\r\n\r\nNote that this is distinct from #15142, as this is still reproducible on HEAD, even after commit 030211d21207dabb7a4bf21cc9af6fa5eb066db1.","type_of_failure":"OtherFailure","blocking":[]} >The following program panics on GHC 8.6 and HEAD:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality
import Data.Void
data family Sing :: forall k. k > Type
data (~>) :: Type > Type > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }
mkRefl :: n :~: j
mkRefl = Refl
right :: forall (r :: (x :~: y) ~> z).
Sing r > ()
right no =
case mkRefl @x @y of
Refl > applySing no _
```
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180627 for x86_64unknownlinux):
tcTyVarDetails
co_a1BG :: y_a1Bz[sk:1] ~# x_a1By[sk:1]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable
pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var
```
On GHC 8.4, this simply errors:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:23:10: error:
• Couldn't match type ‘n’ with ‘j’
‘n’ is a rigid type variable bound by
the type signature for:
mkRefl :: forall k1 (n :: k1) (j :: k1). n :~: j
at Bug.hs:22:117
‘j’ is a rigid type variable bound by
the type signature for:
mkRefl :: forall k1 (n :: k1) (j :: k1). n :~: j
at Bug.hs:22:117
Expected type: n :~: j
Actual type: n :~: n
• In the expression: Refl
In an equation for ‘mkRefl’: mkRefl = Refl
• Relevant bindings include
mkRefl :: n :~: j (bound at Bug.hs:23:1)

23  mkRefl = Refl
 ^^^^
Bug.hs:29:13: error:
• Couldn't match type ‘Sing (Apply r t0)’ with ‘()’
Expected type: ()
Actual type: Sing (Apply r t0)
• In the expression: applySing no _
In a case alternative: Refl > applySing no _
In the expression: case mkRefl @x @y of { Refl > applySing no _ }
• Relevant bindings include
no :: Sing r (bound at Bug.hs:27:7)
right :: Sing r > () (bound at Bug.hs:27:1)

29  Refl > applySing no _
 ^^^^^^^^^^^^^^
Bug.hs:29:26: error:
• Found hole: _ :: Sing t0
Where: ‘t0’ is an ambiguous type variable
‘y’, ‘x’, ‘k’ are rigid type variables bound by
the type signature for:
right :: forall k1 (x1 :: k1) (y1 :: k1) z (r :: (x1 :~: y1) ~> z).
Sing r > ()
at Bug.hs:(25,1)(26,21)
• In the second argument of ‘applySing’, namely ‘_’
In the expression: applySing no _
In a case alternative: Refl > applySing no _
• Relevant bindings include
no :: Sing r (bound at Bug.hs:27:7)
right :: Sing r > () (bound at Bug.hs:27:1)
Valid substitutions include
undefined :: forall (a :: TYPE r).
GHC.Stack.Types.HasCallStack =>
a
(imported from ‘Prelude’ at Bug.hs:7:810
(and originally defined in ‘GHC.Err’))

29  Refl > applySing no _
 ^
```
Note that this is distinct from #15142, as this is still reproducible on HEAD, even after commit 030211d21207dabb7a4bf21cc9af6fa5eb066db1.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Typed hole panic on GHC 8.6 (tcTyVarDetails)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType,","TypedHoles"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics on GHC 8.6 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\nimport Data.Void\r\n\r\ndata family Sing :: forall k. k > Type\r\n\r\ndata (~>) :: Type > Type > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }\r\n\r\nmkRefl :: n :~: j\r\nmkRefl = Refl\r\n\r\nright :: forall (r :: (x :~: y) ~> z).\r\n Sing r > ()\r\nright no =\r\n case mkRefl @x @y of\r\n Refl > applySing no _\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180627 for x86_64unknownlinux):\r\n tcTyVarDetails\r\n co_a1BG :: y_a1Bz[sk:1] ~# x_a1By[sk:1]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable\r\n pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var\r\n}}}\r\n\r\nOn GHC 8.4, this simply errors:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:23:10: error:\r\n • Couldn't match type ‘n’ with ‘j’\r\n ‘n’ is a rigid type variable bound by\r\n the type signature for:\r\n mkRefl :: forall k1 (n :: k1) (j :: k1). n :~: j\r\n at Bug.hs:22:117\r\n ‘j’ is a rigid type variable bound by\r\n the type signature for:\r\n mkRefl :: forall k1 (n :: k1) (j :: k1). n :~: j\r\n at Bug.hs:22:117\r\n Expected type: n :~: j\r\n Actual type: n :~: n\r\n • In the expression: Refl\r\n In an equation for ‘mkRefl’: mkRefl = Refl\r\n • Relevant bindings include\r\n mkRefl :: n :~: j (bound at Bug.hs:23:1)\r\n \r\n23  mkRefl = Refl\r\n  ^^^^\r\n\r\nBug.hs:29:13: error:\r\n • Couldn't match type ‘Sing (Apply r t0)’ with ‘()’\r\n Expected type: ()\r\n Actual type: Sing (Apply r t0)\r\n • In the expression: applySing no _\r\n In a case alternative: Refl > applySing no _\r\n In the expression: case mkRefl @x @y of { Refl > applySing no _ }\r\n • Relevant bindings include\r\n no :: Sing r (bound at Bug.hs:27:7)\r\n right :: Sing r > () (bound at Bug.hs:27:1)\r\n \r\n29  Refl > applySing no _\r\n  ^^^^^^^^^^^^^^\r\n\r\nBug.hs:29:26: error:\r\n • Found hole: _ :: Sing t0\r\n Where: ‘t0’ is an ambiguous type variable\r\n ‘y’, ‘x’, ‘k’ are rigid type variables bound by\r\n the type signature for:\r\n right :: forall k1 (x1 :: k1) (y1 :: k1) z (r :: (x1 :~: y1) ~> z).\r\n Sing r > ()\r\n at Bug.hs:(25,1)(26,21)\r\n • In the second argument of ‘applySing’, namely ‘_’\r\n In the expression: applySing no _\r\n In a case alternative: Refl > applySing no _\r\n • Relevant bindings include\r\n no :: Sing r (bound at Bug.hs:27:7)\r\n right :: Sing r > () (bound at Bug.hs:27:1)\r\n Valid substitutions include\r\n undefined :: forall (a :: TYPE r).\r\n GHC.Stack.Types.HasCallStack =>\r\n a\r\n (imported from ‘Prelude’ at Bug.hs:7:810\r\n (and originally defined in ‘GHC.Err’))\r\n \r\n29  Refl > applySing no _\r\n  ^\r\n}}}\r\n\r\nNote that this is distinct from #15142, as this is still reproducible on HEAD, even after commit 030211d21207dabb7a4bf21cc9af6fa5eb066db1.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1Matthías Páll GissurarsonMatthías Páll Gissurarsonhttps://gitlab.haskell.org/ghc/ghc//issues/15380Infinite typechecker loop in GHC 8.620190707T18:12:54ZRyan ScottInfinite typechecker loop in GHC 8.6The following program loops infinitely during typechecking with GHC 8.6.1 and HEAD:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
class Generic a where
type Rep a :: Type
class PGeneric a where
type To a (x :: Rep a) :: a
type family MDefault (x :: a) :: a where
MDefault x = To (M x)
class C a where
type M (x :: a) :: a
type M (x :: a) = MDefault x
```
In GHC 8.4.3, however this fails with a proper error:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:16: error:
• Occurs check: cannot construct the infinite kind:
a ~ Rep (M x) > M x
• In the type ‘To (M x)’
In the type family declaration for ‘MDefault’
• Type variable kinds: x :: a

15  MDefault x = To (M x)
 ^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Infinite typechecker loop in GHC 8.6","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program loops infinitely during typechecking with GHC 8.6.1 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\nclass Generic a where\r\n type Rep a :: Type\r\n\r\nclass PGeneric a where\r\n type To a (x :: Rep a) :: a\r\n\r\ntype family MDefault (x :: a) :: a where\r\n MDefault x = To (M x)\r\n\r\nclass C a where\r\n type M (x :: a) :: a\r\n type M (x :: a) = MDefault x\r\n}}}\r\n\r\nIn GHC 8.4.3, however this fails with a proper error:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:16: error:\r\n • Occurs check: cannot construct the infinite kind:\r\n a ~ Rep (M x) > M x\r\n • In the type ‘To (M x)’\r\n In the type family declaration for ‘MDefault’\r\n • Type variable kinds: x :: a\r\n \r\n15  MDefault x = To (M x)\r\n  ^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program loops infinitely during typechecking with GHC 8.6.1 and HEAD:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
class Generic a where
type Rep a :: Type
class PGeneric a where
type To a (x :: Rep a) :: a
type family MDefault (x :: a) :: a where
MDefault x = To (M x)
class C a where
type M (x :: a) :: a
type M (x :: a) = MDefault x
```
In GHC 8.4.3, however this fails with a proper error:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:16: error:
• Occurs check: cannot construct the infinite kind:
a ~ Rep (M x) > M x
• In the type ‘To (M x)’
In the type family declaration for ‘MDefault’
• Type variable kinds: x :: a

15  MDefault x = To (M x)
 ^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Infinite typechecker loop in GHC 8.6","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program loops infinitely during typechecking with GHC 8.6.1 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\nclass Generic a where\r\n type Rep a :: Type\r\n\r\nclass PGeneric a where\r\n type To a (x :: Rep a) :: a\r\n\r\ntype family MDefault (x :: a) :: a where\r\n MDefault x = To (M x)\r\n\r\nclass C a where\r\n type M (x :: a) :: a\r\n type M (x :: a) = MDefault x\r\n}}}\r\n\r\nIn GHC 8.4.3, however this fails with a proper error:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:16: error:\r\n • Occurs check: cannot construct the infinite kind:\r\n a ~ Rep (M x) > M x\r\n • In the type ‘To (M x)’\r\n In the type family declaration for ‘MDefault’\r\n • Type variable kinds: x :: a\r\n \r\n15  MDefault x = To (M x)\r\n  ^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15416Higher rank types in pattern synonyms20210123T01:13:41ZmniipHigher rank types in pattern synonyms```hs
{# LANGUAGE RankNTypes, PatternSynonyms, ViewPatterns #}
```
Consider the following two pattern synonyms:
```hs
pattern N :: () => () => forall r. r > (a > r) > r
pattern N < ((\f > f Nothing Just) > Nothing) where N = \n j > n
pattern J :: a > forall r. r > (a > r) > r
pattern J x < ((\f > f Nothing Just) > Just x) where J x = \n j > j x
```
The pattern synonym type declaration syntax is very fragile and awkward wrt quantifiers but that's a story for another ticket.
Now consider four ways to write the same function: using pattern synonyms we've defined above vs. using the exact view patterns they were defiend with; and using a series of equations vs. an explicit `case of`:
```hs
fooVPEqns, fooVPCase, fooPSEqns, fooPSCase :: (forall r. r > (a > r) > r) > Maybe a
fooVPEqns ((\f > f Nothing Just) > Nothing) = Nothing
fooVPEqns ((\f > f Nothing Just) > Just x) = Just x
fooVPCase v = case v of
((\f > f Nothing Just) > Nothing) > Nothing
((\f > f Nothing Just) > Just x) > Just x
fooPSEqns N = Nothing
fooPSEqns (J x) = Just x
fooPSCase v = case v of
N > Nothing
J x > Just x
```
Three of these compile and work fine, the fourth breaks:
```hs
QuantPatSyn.hs:22:9: error:
• Couldn't match expected type ‘r0 > (a > r0) > r0’
with actual type ‘forall r. r > (a0 > r) > r’
• In the pattern: N
In a case alternative: N > Nothing
In the expression:
case v of
N > Nothing
J x > Just x
• Relevant bindings include
v :: forall r. r > (a > r) > r (bound at QuantPatSyn.hs:21:11)
fooPSCase :: (forall r. r > (a > r) > r) > Maybe a
(bound at QuantPatSyn.hs:21:1)

22  N > Nothing
 ^
QuantPatSyn.hs:23:9: error:
• Couldn't match expected type ‘r0 > (a > r0) > r0’
with actual type ‘forall r. r > (a > r) > r’
• In the pattern: J x
In a case alternative: J x > Just x
In the expression:
case v of
N > Nothing
J x > Just x
• Relevant bindings include
v :: forall r. r > (a > r) > r (bound at QuantPatSyn.hs:21:11)
fooPSCase :: (forall r. r > (a > r) > r) > Maybe a
(bound at QuantPatSyn.hs:21:1)

23  J x > Just x
 ^^^
```
The exact wording of the error message (the appearance of `forall` in the "actual type") makes me think this is an error on the typechecker's side: the part of the typechecker that handles pattern synonyms doesn't handle higher rank types correctly.
Another symptom can be observed with the following:
```hs
pattern V :: Void > (forall r. r)
pattern V x < ((\f > f) > x) where V x = absurd x
barVPEqns, barVPCase, barPSEqns, barPSCase :: (forall r. r) > Void
barVPEqns ((\f > f) > x) = x
barVPCase v = case v of
((\f > f) > x) > x
barPSEqns (V x) = x
barPSCase v = case v of
V x > x
```
```hs
QuantPatSyn.hs:43:9: error:
• Cannot instantiate unification variable ‘r0’
with a type involving foralls: forall r. r
GHC doesn't yet support impredicative polymorphism
• In the pattern: V x
In a case alternative: V x > x
In the expression: case v of { V x > x }

43  V x > x
 ^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Higher rank types in pattern synonyms","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["PatternSynonyms"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{# LANGUAGE RankNTypes, PatternSynonyms, ViewPatterns #}\r\n}}}\r\nConsider the following two pattern synonyms:\r\n\r\n{{{#!hs\r\npattern N :: () => () => forall r. r > (a > r) > r\r\npattern N < ((\\f > f Nothing Just) > Nothing) where N = \\n j > n\r\n\r\npattern J :: a > forall r. r > (a > r) > r\r\npattern J x < ((\\f > f Nothing Just) > Just x) where J x = \\n j > j x\r\n}}}\r\n\r\nThe pattern synonym type declaration syntax is very fragile and awkward wrt quantifiers but that's a story for another ticket.\r\n\r\nNow consider four ways to write the same function: using pattern synonyms we've defined above vs. using the exact view patterns they were defiend with; and using a series of equations vs. an explicit `case of`:\r\n\r\n{{{#!hs\r\nfooVPEqns, fooVPCase, fooPSEqns, fooPSCase :: (forall r. r > (a > r) > r) > Maybe a\r\n\r\nfooVPEqns ((\\f > f Nothing Just) > Nothing) = Nothing\r\nfooVPEqns ((\\f > f Nothing Just) > Just x) = Just x\r\n\r\nfooVPCase v = case v of\r\n\t((\\f > f Nothing Just) > Nothing) > Nothing\r\n\t((\\f > f Nothing Just) > Just x) > Just x\r\n\r\nfooPSEqns N = Nothing\r\nfooPSEqns (J x) = Just x\r\n\r\nfooPSCase v = case v of\r\n\tN > Nothing\r\n\tJ x > Just x\r\n}}}\r\n\r\nThree of these compile and work fine, the fourth breaks:\r\n{{{#!hs\r\nQuantPatSyn.hs:22:9: error:\r\n • Couldn't match expected type ‘r0 > (a > r0) > r0’\r\n with actual type ‘forall r. r > (a0 > r) > r’\r\n • In the pattern: N\r\n In a case alternative: N > Nothing\r\n In the expression:\r\n case v of\r\n N > Nothing\r\n J x > Just x\r\n • Relevant bindings include\r\n v :: forall r. r > (a > r) > r (bound at QuantPatSyn.hs:21:11)\r\n fooPSCase :: (forall r. r > (a > r) > r) > Maybe a\r\n (bound at QuantPatSyn.hs:21:1)\r\n \r\n22  N > Nothing\r\n  ^\r\n\r\nQuantPatSyn.hs:23:9: error:\r\n • Couldn't match expected type ‘r0 > (a > r0) > r0’\r\n with actual type ‘forall r. r > (a > r) > r’\r\n • In the pattern: J x\r\n In a case alternative: J x > Just x\r\n In the expression:\r\n case v of\r\n N > Nothing\r\n J x > Just x\r\n • Relevant bindings include\r\n v :: forall r. r > (a > r) > r (bound at QuantPatSyn.hs:21:11)\r\n fooPSCase :: (forall r. r > (a > r) > r) > Maybe a\r\n (bound at QuantPatSyn.hs:21:1)\r\n \r\n23  J x > Just x\r\n  ^^^\r\n}}}\r\n\r\nThe exact wording of the error message (the appearance of `forall` in the \"actual type\") makes me think this is an error on the typechecker's side: the part of the typechecker that handles pattern synonyms doesn't handle higher rank types correctly.\r\n\r\nAnother symptom can be observed with the following:\r\n\r\n{{{#!hs\r\npattern V :: Void > (forall r. r)\r\npattern V x < ((\\f > f) > x) where V x = absurd x\r\n\r\nbarVPEqns, barVPCase, barPSEqns, barPSCase :: (forall r. r) > Void\r\n\r\nbarVPEqns ((\\f > f) > x) = x\r\n\r\nbarVPCase v = case v of\r\n\t((\\f > f) > x) > x\r\n\r\nbarPSEqns (V x) = x\r\n\r\nbarPSCase v = case v of\r\n\tV x > x\r\n}}}\r\n{{{#!hs\r\nQuantPatSyn.hs:43:9: error:\r\n • Cannot instantiate unification variable ‘r0’\r\n with a type involving foralls: forall r. r\r\n GHC doesn't yet support impredicative polymorphism\r\n • In the pattern: V x\r\n In a case alternative: V x > x\r\n In the expression: case v of { V x > x }\r\n \r\n43  V x > x\r\n  ^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >```hs
{# LANGUAGE RankNTypes, PatternSynonyms, ViewPatterns #}
```
Consider the following two pattern synonyms:
```hs
pattern N :: () => () => forall r. r > (a > r) > r
pattern N < ((\f > f Nothing Just) > Nothing) where N = \n j > n
pattern J :: a > forall r. r > (a > r) > r
pattern J x < ((\f > f Nothing Just) > Just x) where J x = \n j > j x
```
The pattern synonym type declaration syntax is very fragile and awkward wrt quantifiers but that's a story for another ticket.
Now consider four ways to write the same function: using pattern synonyms we've defined above vs. using the exact view patterns they were defiend with; and using a series of equations vs. an explicit `case of`:
```hs
fooVPEqns, fooVPCase, fooPSEqns, fooPSCase :: (forall r. r > (a > r) > r) > Maybe a
fooVPEqns ((\f > f Nothing Just) > Nothing) = Nothing
fooVPEqns ((\f > f Nothing Just) > Just x) = Just x
fooVPCase v = case v of
((\f > f Nothing Just) > Nothing) > Nothing
((\f > f Nothing Just) > Just x) > Just x
fooPSEqns N = Nothing
fooPSEqns (J x) = Just x
fooPSCase v = case v of
N > Nothing
J x > Just x
```
Three of these compile and work fine, the fourth breaks:
```hs
QuantPatSyn.hs:22:9: error:
• Couldn't match expected type ‘r0 > (a > r0) > r0’
with actual type ‘forall r. r > (a0 > r) > r’
• In the pattern: N
In a case alternative: N > Nothing
In the expression:
case v of
N > Nothing
J x > Just x
• Relevant bindings include
v :: forall r. r > (a > r) > r (bound at QuantPatSyn.hs:21:11)
fooPSCase :: (forall r. r > (a > r) > r) > Maybe a
(bound at QuantPatSyn.hs:21:1)

22  N > Nothing
 ^
QuantPatSyn.hs:23:9: error:
• Couldn't match expected type ‘r0 > (a > r0) > r0’
with actual type ‘forall r. r > (a > r) > r’
• In the pattern: J x
In a case alternative: J x > Just x
In the expression:
case v of
N > Nothing
J x > Just x
• Relevant bindings include
v :: forall r. r > (a > r) > r (bound at QuantPatSyn.hs:21:11)
fooPSCase :: (forall r. r > (a > r) > r) > Maybe a
(bound at QuantPatSyn.hs:21:1)

23  J x > Just x
 ^^^
```
The exact wording of the error message (the appearance of `forall` in the "actual type") makes me think this is an error on the typechecker's side: the part of the typechecker that handles pattern synonyms doesn't handle higher rank types correctly.
Another symptom can be observed with the following:
```hs
pattern V :: Void > (forall r. r)
pattern V x < ((\f > f) > x) where V x = absurd x
barVPEqns, barVPCase, barPSEqns, barPSCase :: (forall r. r) > Void
barVPEqns ((\f > f) > x) = x
barVPCase v = case v of
((\f > f) > x) > x
barPSEqns (V x) = x
barPSCase v = case v of
V x > x
```
```hs
QuantPatSyn.hs:43:9: error:
• Cannot instantiate unification variable ‘r0’
with a type involving foralls: forall r. r
GHC doesn't yet support impredicative polymorphism
• In the pattern: V x
In a case alternative: V x > x
In the expression: case v of { V x > x }

43  V x > x
 ^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Higher rank types in pattern synonyms","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["PatternSynonyms"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{# LANGUAGE RankNTypes, PatternSynonyms, ViewPatterns #}\r\n}}}\r\nConsider the following two pattern synonyms:\r\n\r\n{{{#!hs\r\npattern N :: () => () => forall r. r > (a > r) > r\r\npattern N < ((\\f > f Nothing Just) > Nothing) where N = \\n j > n\r\n\r\npattern J :: a > forall r. r > (a > r) > r\r\npattern J x < ((\\f > f Nothing Just) > Just x) where J x = \\n j > j x\r\n}}}\r\n\r\nThe pattern synonym type declaration syntax is very fragile and awkward wrt quantifiers but that's a story for another ticket.\r\n\r\nNow consider four ways to write the same function: using pattern synonyms we've defined above vs. using the exact view patterns they were defiend with; and using a series of equations vs. an explicit `case of`:\r\n\r\n{{{#!hs\r\nfooVPEqns, fooVPCase, fooPSEqns, fooPSCase :: (forall r. r > (a > r) > r) > Maybe a\r\n\r\nfooVPEqns ((\\f > f Nothing Just) > Nothing) = Nothing\r\nfooVPEqns ((\\f > f Nothing Just) > Just x) = Just x\r\n\r\nfooVPCase v = case v of\r\n\t((\\f > f Nothing Just) > Nothing) > Nothing\r\n\t((\\f > f Nothing Just) > Just x) > Just x\r\n\r\nfooPSEqns N = Nothing\r\nfooPSEqns (J x) = Just x\r\n\r\nfooPSCase v = case v of\r\n\tN > Nothing\r\n\tJ x > Just x\r\n}}}\r\n\r\nThree of these compile and work fine, the fourth breaks:\r\n{{{#!hs\r\nQuantPatSyn.hs:22:9: error:\r\n • Couldn't match expected type ‘r0 > (a > r0) > r0’\r\n with actual type ‘forall r. r > (a0 > r) > r’\r\n • In the pattern: N\r\n In a case alternative: N > Nothing\r\n In the expression:\r\n case v of\r\n N > Nothing\r\n J x > Just x\r\n • Relevant bindings include\r\n v :: forall r. r > (a > r) > r (bound at QuantPatSyn.hs:21:11)\r\n fooPSCase :: (forall r. r > (a > r) > r) > Maybe a\r\n (bound at QuantPatSyn.hs:21:1)\r\n \r\n22  N > Nothing\r\n  ^\r\n\r\nQuantPatSyn.hs:23:9: error:\r\n • Couldn't match expected type ‘r0 > (a > r0) > r0’\r\n with actual type ‘forall r. r > (a > r) > r’\r\n • In the pattern: J x\r\n In a case alternative: J x > Just x\r\n In the expression:\r\n case v of\r\n N > Nothing\r\n J x > Just x\r\n • Relevant bindings include\r\n v :: forall r. r > (a > r) > r (bound at QuantPatSyn.hs:21:11)\r\n fooPSCase :: (forall r. r > (a > r) > r) > Maybe a\r\n (bound at QuantPatSyn.hs:21:1)\r\n \r\n23  J x > Just x\r\n  ^^^\r\n}}}\r\n\r\nThe exact wording of the error message (the appearance of `forall` in the \"actual type\") makes me think this is an error on the typechecker's side: the part of the typechecker that handles pattern synonyms doesn't handle higher rank types correctly.\r\n\r\nAnother symptom can be observed with the following:\r\n\r\n{{{#!hs\r\npattern V :: Void > (forall r. r)\r\npattern V x < ((\\f > f) > x) where V x = absurd x\r\n\r\nbarVPEqns, barVPCase, barPSEqns, barPSCase :: (forall r. r) > Void\r\n\r\nbarVPEqns ((\\f > f) > x) = x\r\n\r\nbarVPCase v = case v of\r\n\t((\\f > f) > x) > x\r\n\r\nbarPSEqns (V x) = x\r\n\r\nbarPSCase v = case v of\r\n\tV x > x\r\n}}}\r\n{{{#!hs\r\nQuantPatSyn.hs:43:9: error:\r\n • Cannot instantiate unification variable ‘r0’\r\n with a type involving foralls: forall r. r\r\n GHC doesn't yet support impredicative polymorphism\r\n • In the pattern: V x\r\n In a case alternative: V x > x\r\n In the expression: case v of { V x > x }\r\n \r\n43  V x > x\r\n  ^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >9.2.1https://gitlab.haskell.org/ghc/ghc//issues/15419GHC 8.6.1 regression (buildKindCoercion)20190707T18:04:59ZRyan ScottGHC 8.6.1 regression (buildKindCoercion)The following program typechecks on GHC 8.4.1, but panics on GHC 8.6.1 and HEAD:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE DefaultSignatures #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE TypeInType #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind
data family Sing :: forall k. k > Type
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data instance Sing :: forall a b. (a, b) > Type where
STuple2 :: Sing x > Sing y > Sing '(x, y)
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (f `Apply` t) }

newtype Par1 p = Par1 p
newtype K1 c p = K1 c
data (f :*: g) p = f p :*: g p
data instance Sing :: forall p. Par1 p > Type where
SPar1 :: Sing x > Sing ('Par1 x)
data instance Sing :: forall k c (p :: k). K1 c p > Type where
SK1 :: Sing x > Sing ('K1 x)
data instance Sing :: forall k (f :: k > Type) (g :: k > Type) (p :: k).
(f :*: g) p > Type where
(:%*:) :: Sing x > Sing y > Sing (x ':*: y)
class Generic1 (f :: k > Type) where
type Rep1 f :: k > Type
from1 :: f a > Rep1 f a
to1 :: Rep1 f a > f a
class PGeneric1 (f :: k > Type) where
type From1 (z :: f a) :: Rep1 f a
type To1 (z :: Rep1 f a) :: f a
class SGeneric1 (f :: k > Type) where
sFrom1 :: forall (a :: k) (z :: f a). Sing z > Sing (From1 z)
sTo1 :: forall (a :: k) (r :: Rep1 f a). Sing r > Sing (To1 r :: f a)
instance Generic1 ((,) a) where
type Rep1 ((,) a) = K1 a :*: Par1
from1 (x, y) = K1 x :*: Par1 y
to1 (K1 x :*: Par1 y) = (x, y)
instance PGeneric1 ((,) a) where
type From1 '(x, y) = 'K1 x ':*: 'Par1 y
type To1 ('K1 x ':*: 'Par1 y) = '(x, y)
instance SGeneric1 ((,) a) where
sFrom1 (STuple2 x y) = SK1 x :%*: SPar1 y
sTo1 (SK1 x :%*: SPar1 y) = STuple2 x y

type family GenericFmap (g :: a ~> b) (x :: f a) :: f b where
GenericFmap g x = To1 (Fmap g (From1 x))
class PFunctor (f :: Type > Type) where
type Fmap (g :: a ~> b) (x :: f a) :: f b
type Fmap g x = GenericFmap g x
class SFunctor (f :: Type > Type) where
sFmap :: forall a b (g :: a ~> b) (x :: f a).
Sing g > Sing x > Sing (Fmap g x)
default sFmap :: forall a b (g :: a ~> b) (x :: f a).
( SGeneric1 f, SFunctor (Rep1 f)
, Fmap g x ~ GenericFmap g x )
=> Sing g > Sing x > Sing (Fmap g x)
sFmap sg sx = sTo1 (sFmap sg (sFrom1 sx))

instance PFunctor Par1 where
type Fmap f ('Par1 x) = 'Par1 (f `Apply` x)
instance PFunctor (K1 c) where
type Fmap _ ('K1 x) = 'K1 x
instance PFunctor (f :*: g) where
type Fmap h (x ':*: y) = Fmap h x ':*: Fmap h y
instance SFunctor Par1 where
sFmap sf (SPar1 sx) = SPar1 (sf `applySing` sx)
instance SFunctor (K1 c) where
sFmap _ (SK1 sx) = SK1 sx
instance (SFunctor f, SFunctor g) => SFunctor (f :*: g) where
sFmap sh (sx :%*: sy) = sFmap sh sx :%*: sFmap sh sy

instance PFunctor ((,) a)
 The line below causes the panic
instance SFunctor ((,) a)
```
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180714 for x86_64unknownlinux):
buildKindCoercion
K1 a_a1Nj :*: Par1
Rep1 ((,) a_a1Nj)
*
a_a1Nj
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:2069:9 in ghc:Coercion
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC 8.6.1 regression (buildKindCoercion)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.4.1, but panics on GHC 8.6.1 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE DefaultSignatures #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata family Sing :: forall k. k > Type\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\ndata instance Sing :: forall a b. (a, b) > Type where\r\n STuple2 :: Sing x > Sing y > Sing '(x, y)\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (f `Apply` t) }\r\n\r\n\r\n\r\nnewtype Par1 p = Par1 p\r\nnewtype K1 c p = K1 c\r\ndata (f :*: g) p = f p :*: g p\r\n\r\ndata instance Sing :: forall p. Par1 p > Type where\r\n SPar1 :: Sing x > Sing ('Par1 x)\r\ndata instance Sing :: forall k c (p :: k). K1 c p > Type where\r\n SK1 :: Sing x > Sing ('K1 x)\r\ndata instance Sing :: forall k (f :: k > Type) (g :: k > Type) (p :: k).\r\n (f :*: g) p > Type where\r\n (:%*:) :: Sing x > Sing y > Sing (x ':*: y)\r\n\r\nclass Generic1 (f :: k > Type) where\r\n type Rep1 f :: k > Type\r\n from1 :: f a > Rep1 f a\r\n to1 :: Rep1 f a > f a\r\n\r\nclass PGeneric1 (f :: k > Type) where\r\n type From1 (z :: f a) :: Rep1 f a\r\n type To1 (z :: Rep1 f a) :: f a\r\n\r\nclass SGeneric1 (f :: k > Type) where\r\n sFrom1 :: forall (a :: k) (z :: f a). Sing z > Sing (From1 z)\r\n sTo1 :: forall (a :: k) (r :: Rep1 f a). Sing r > Sing (To1 r :: f a)\r\n\r\ninstance Generic1 ((,) a) where\r\n type Rep1 ((,) a) = K1 a :*: Par1\r\n from1 (x, y) = K1 x :*: Par1 y\r\n to1 (K1 x :*: Par1 y) = (x, y)\r\n\r\ninstance PGeneric1 ((,) a) where\r\n type From1 '(x, y) = 'K1 x ':*: 'Par1 y\r\n type To1 ('K1 x ':*: 'Par1 y) = '(x, y)\r\n\r\ninstance SGeneric1 ((,) a) where\r\n sFrom1 (STuple2 x y) = SK1 x :%*: SPar1 y\r\n sTo1 (SK1 x :%*: SPar1 y) = STuple2 x y\r\n\r\n\r\n\r\ntype family GenericFmap (g :: a ~> b) (x :: f a) :: f b where\r\n GenericFmap g x = To1 (Fmap g (From1 x))\r\n\r\nclass PFunctor (f :: Type > Type) where\r\n type Fmap (g :: a ~> b) (x :: f a) :: f b\r\n type Fmap g x = GenericFmap g x\r\n\r\nclass SFunctor (f :: Type > Type) where\r\n sFmap :: forall a b (g :: a ~> b) (x :: f a).\r\n Sing g > Sing x > Sing (Fmap g x)\r\n default sFmap :: forall a b (g :: a ~> b) (x :: f a).\r\n ( SGeneric1 f, SFunctor (Rep1 f)\r\n , Fmap g x ~ GenericFmap g x )\r\n => Sing g > Sing x > Sing (Fmap g x)\r\n sFmap sg sx = sTo1 (sFmap sg (sFrom1 sx))\r\n\r\n\r\n\r\ninstance PFunctor Par1 where\r\n type Fmap f ('Par1 x) = 'Par1 (f `Apply` x)\r\ninstance PFunctor (K1 c) where\r\n type Fmap _ ('K1 x) = 'K1 x\r\ninstance PFunctor (f :*: g) where\r\n type Fmap h (x ':*: y) = Fmap h x ':*: Fmap h y\r\n\r\ninstance SFunctor Par1 where\r\n sFmap sf (SPar1 sx) = SPar1 (sf `applySing` sx)\r\ninstance SFunctor (K1 c) where\r\n sFmap _ (SK1 sx) = SK1 sx\r\ninstance (SFunctor f, SFunctor g) => SFunctor (f :*: g) where\r\n sFmap sh (sx :%*: sy) = sFmap sh sx :%*: sFmap sh sy\r\n\r\n\r\n\r\ninstance PFunctor ((,) a)\r\n The line below causes the panic\r\ninstance SFunctor ((,) a)\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180714 for x86_64unknownlinux):\r\n buildKindCoercion\r\n K1 a_a1Nj :*: Par1\r\n Rep1 ((,) a_a1Nj)\r\n *\r\n a_a1Nj\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:2069:9 in ghc:Coercion\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program typechecks on GHC 8.4.1, but panics on GHC 8.6.1 and HEAD:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE DefaultSignatures #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE TypeInType #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind
data family Sing :: forall k. k > Type
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data instance Sing :: forall a b. (a, b) > Type where
STuple2 :: Sing x > Sing y > Sing '(x, y)
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (f `Apply` t) }

newtype Par1 p = Par1 p
newtype K1 c p = K1 c
data (f :*: g) p = f p :*: g p
data instance Sing :: forall p. Par1 p > Type where
SPar1 :: Sing x > Sing ('Par1 x)
data instance Sing :: forall k c (p :: k). K1 c p > Type where
SK1 :: Sing x > Sing ('K1 x)
data instance Sing :: forall k (f :: k > Type) (g :: k > Type) (p :: k).
(f :*: g) p > Type where
(:%*:) :: Sing x > Sing y > Sing (x ':*: y)
class Generic1 (f :: k > Type) where
type Rep1 f :: k > Type
from1 :: f a > Rep1 f a
to1 :: Rep1 f a > f a
class PGeneric1 (f :: k > Type) where
type From1 (z :: f a) :: Rep1 f a
type To1 (z :: Rep1 f a) :: f a
class SGeneric1 (f :: k > Type) where
sFrom1 :: forall (a :: k) (z :: f a). Sing z > Sing (From1 z)
sTo1 :: forall (a :: k) (r :: Rep1 f a). Sing r > Sing (To1 r :: f a)
instance Generic1 ((,) a) where
type Rep1 ((,) a) = K1 a :*: Par1
from1 (x, y) = K1 x :*: Par1 y
to1 (K1 x :*: Par1 y) = (x, y)
instance PGeneric1 ((,) a) where
type From1 '(x, y) = 'K1 x ':*: 'Par1 y
type To1 ('K1 x ':*: 'Par1 y) = '(x, y)
instance SGeneric1 ((,) a) where
sFrom1 (STuple2 x y) = SK1 x :%*: SPar1 y
sTo1 (SK1 x :%*: SPar1 y) = STuple2 x y

type family GenericFmap (g :: a ~> b) (x :: f a) :: f b where
GenericFmap g x = To1 (Fmap g (From1 x))
class PFunctor (f :: Type > Type) where
type Fmap (g :: a ~> b) (x :: f a) :: f b
type Fmap g x = GenericFmap g x
class SFunctor (f :: Type > Type) where
sFmap :: forall a b (g :: a ~> b) (x :: f a).
Sing g > Sing x > Sing (Fmap g x)
default sFmap :: forall a b (g :: a ~> b) (x :: f a).
( SGeneric1 f, SFunctor (Rep1 f)
, Fmap g x ~ GenericFmap g x )
=> Sing g > Sing x > Sing (Fmap g x)
sFmap sg sx = sTo1 (sFmap sg (sFrom1 sx))

instance PFunctor Par1 where
type Fmap f ('Par1 x) = 'Par1 (f `Apply` x)
instance PFunctor (K1 c) where
type Fmap _ ('K1 x) = 'K1 x
instance PFunctor (f :*: g) where
type Fmap h (x ':*: y) = Fmap h x ':*: Fmap h y
instance SFunctor Par1 where
sFmap sf (SPar1 sx) = SPar1 (sf `applySing` sx)
instance SFunctor (K1 c) where
sFmap _ (SK1 sx) = SK1 sx
instance (SFunctor f, SFunctor g) => SFunctor (f :*: g) where
sFmap sh (sx :%*: sy) = sFmap sh sx :%*: sFmap sh sy

instance PFunctor ((,) a)
 The line below causes the panic
instance SFunctor ((,) a)
```
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180714 for x86_64unknownlinux):
buildKindCoercion
K1 a_a1Nj :*: Par1
Rep1 ((,) a_a1Nj)
*
a_a1Nj
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:2069:9 in ghc:Coercion
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC 8.6.1 regression (buildKindCoercion)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.4.1, but panics on GHC 8.6.1 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE DefaultSignatures #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata family Sing :: forall k. k > Type\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\ndata instance Sing :: forall a b. (a, b) > Type where\r\n STuple2 :: Sing x > Sing y > Sing '(x, y)\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (f `Apply` t) }\r\n\r\n\r\n\r\nnewtype Par1 p = Par1 p\r\nnewtype K1 c p = K1 c\r\ndata (f :*: g) p = f p :*: g p\r\n\r\ndata instance Sing :: forall p. Par1 p > Type where\r\n SPar1 :: Sing x > Sing ('Par1 x)\r\ndata instance Sing :: forall k c (p :: k). K1 c p > Type where\r\n SK1 :: Sing x > Sing ('K1 x)\r\ndata instance Sing :: forall k (f :: k > Type) (g :: k > Type) (p :: k).\r\n (f :*: g) p > Type where\r\n (:%*:) :: Sing x > Sing y > Sing (x ':*: y)\r\n\r\nclass Generic1 (f :: k > Type) where\r\n type Rep1 f :: k > Type\r\n from1 :: f a > Rep1 f a\r\n to1 :: Rep1 f a > f a\r\n\r\nclass PGeneric1 (f :: k > Type) where\r\n type From1 (z :: f a) :: Rep1 f a\r\n type To1 (z :: Rep1 f a) :: f a\r\n\r\nclass SGeneric1 (f :: k > Type) where\r\n sFrom1 :: forall (a :: k) (z :: f a). Sing z > Sing (From1 z)\r\n sTo1 :: forall (a :: k) (r :: Rep1 f a). Sing r > Sing (To1 r :: f a)\r\n\r\ninstance Generic1 ((,) a) where\r\n type Rep1 ((,) a) = K1 a :*: Par1\r\n from1 (x, y) = K1 x :*: Par1 y\r\n to1 (K1 x :*: Par1 y) = (x, y)\r\n\r\ninstance PGeneric1 ((,) a) where\r\n type From1 '(x, y) = 'K1 x ':*: 'Par1 y\r\n type To1 ('K1 x ':*: 'Par1 y) = '(x, y)\r\n\r\ninstance SGeneric1 ((,) a) where\r\n sFrom1 (STuple2 x y) = SK1 x :%*: SPar1 y\r\n sTo1 (SK1 x :%*: SPar1 y) = STuple2 x y\r\n\r\n\r\n\r\ntype family GenericFmap (g :: a ~> b) (x :: f a) :: f b where\r\n GenericFmap g x = To1 (Fmap g (From1 x))\r\n\r\nclass PFunctor (f :: Type > Type) where\r\n type Fmap (g :: a ~> b) (x :: f a) :: f b\r\n type Fmap g x = GenericFmap g x\r\n\r\nclass SFunctor (f :: Type > Type) where\r\n sFmap :: forall a b (g :: a ~> b) (x :: f a).\r\n Sing g > Sing x > Sing (Fmap g x)\r\n default sFmap :: forall a b (g :: a ~> b) (x :: f a).\r\n ( SGeneric1 f, SFunctor (Rep1 f)\r\n , Fmap g x ~ GenericFmap g x )\r\n => Sing g > Sing x > Sing (Fmap g x)\r\n sFmap sg sx = sTo1 (sFmap sg (sFrom1 sx))\r\n\r\n\r\n\r\ninstance PFunctor Par1 where\r\n type Fmap f ('Par1 x) = 'Par1 (f `Apply` x)\r\ninstance PFunctor (K1 c) where\r\n type Fmap _ ('K1 x) = 'K1 x\r\ninstance PFunctor (f :*: g) where\r\n type Fmap h (x ':*: y) = Fmap h x ':*: Fmap h y\r\n\r\ninstance SFunctor Par1 where\r\n sFmap sf (SPar1 sx) = SPar1 (sf `applySing` sx)\r\ninstance SFunctor (K1 c) where\r\n sFmap _ (SK1 sx) = SK1 sx\r\ninstance (SFunctor f, SFunctor g) => SFunctor (f :*: g) where\r\n sFmap sh (sx :%*: sy) = sFmap sh sx :%*: sFmap sh sy\r\n\r\n\r\n\r\ninstance PFunctor ((,) a)\r\n The line below causes the panic\r\ninstance SFunctor ((,) a)\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180714 for x86_64unknownlinux):\r\n buildKindCoercion\r\n K1 a_a1Nj :*: Par1\r\n Rep1 ((,) a_a1Nj)\r\n *\r\n a_a1Nj\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:2069:9 in ghc:Coercion\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc//issues/15472GHC HEAD type inference regression post"Remove decideKindGeneralisationPlan"20190707T18:04:35ZRyan ScottGHC HEAD type inference regression post"Remove decideKindGeneralisationPlan"Commit c955a514f033a12f6d0ab0fbacec3e18a5757ab5 (`Remove decideKindGeneralisationPlan`) causes the `singletons` library to no longer compile. Here is as minimal of an example as I can muster:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE UndecidableInstances #}
module Bug (sPermutations) where
import Data.Kind
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing :: forall k. k > Type
data instance Sing :: forall a. [a] > Type where
SNil :: Sing '[]
SCons :: Sing x > Sing xs > Sing (x:xs)
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }
type SingFunction1 f = forall t. Sing t > Sing (Apply f t)
singFun1 :: forall f. SingFunction1 f > Sing f
singFun1 f = SLambda f
type SingFunction2 f = forall t. Sing t > SingFunction1 (Apply f t)
singFun2 :: forall f. SingFunction2 f > Sing f
singFun2 f = SLambda (\x > singFun1 (f x))
type family Undefined :: k where {}
sUndefined :: a
sUndefined = undefined
type family LetGo k z x ys where
LetGo k z x '[] = z
LetGo k z x (y ': ys) = Apply (Apply k y) (LetGo k z x ys)
type family Foldr (k :: a ~> b ~> b) (x :: b) (xs :: [a]) :: b where
Foldr k z x = LetGo k z x x
sFoldr :: forall (t1 :: a ~> b ~> b) (t2 :: b) (t3 :: [a]).
Sing t1 > Sing t2 > Sing t3
> Sing (Foldr t1 t2 t3 :: b)
sFoldr (sK :: Sing k) (sZ :: Sing z) (sX :: Sing x)
= let sGo :: forall arg. Sing arg > Sing (LetGo k z x arg)
sGo SNil = sZ
sGo (SCons (sY :: Sing y) (sYs :: Sing ys))
= sK `applySing` sY `applySing` sGo sYs
in sGo sX
type family LetInterleave xs0 t ts is (a1 :: [a]) (a2 :: [[a]]) :: [[a]] where
LetInterleave xs0 t ts is a1 a2 = Undefined a1 a2
data LetInterleaveSym5 l_ahko l_ahkp l_ahkq l_ahkr (l_ahks :: [a]) :: [[a]] ~> [[a]]
type instance Apply (LetInterleaveSym5 l_ahko l_ahkp l_ahkq l_ahkr l_ahks) l_ahkn = LetInterleave l_ahko l_ahkp l_ahkq l_ahkr l_ahks l_ahkn
data LetInterleaveSym4 l_ahkv l_ahkw l_ahkx l_ahky :: forall a. [a] ~> [[a]] ~> [[a]]
type instance Apply (LetInterleaveSym4 l_ahkv l_ahkw l_ahkx l_ahky) l_ahku = LetInterleaveSym5 l_ahkv l_ahkw l_ahkx l_ahky l_ahku
data LetInterleaveSym3 l_ahkB l_ahkC l_ahkD l_ahkA
type instance Apply (LetInterleaveSym3 l_ahkB l_ahkC l_ahkD) l_ahkA = LetInterleaveSym4 l_ahkB l_ahkC l_ahkD l_ahkA
data LetInterleaveSym2 l_ahkG l_ahkH l_ahkF
type instance Apply (LetInterleaveSym2 l_ahkG l_ahkH) l_ahkF = LetInterleaveSym3 l_ahkG l_ahkH l_ahkF
data LetInterleaveSym1 l_ahkK l_ahkJ
type instance Apply (LetInterleaveSym1 l_ahkK) l_ahkJ = LetInterleaveSym2 l_ahkK l_ahkJ
data LetInterleaveSym0 l_ahkM
type instance Apply LetInterleaveSym0 l_ahkM = LetInterleaveSym1 l_ahkM
type family LetPerms xs0 a1 a2 where
LetPerms xs0 '[] _ = '[]
LetPerms xs0 (t ': ts) is =
Foldr (LetInterleaveSym4 xs0 t ts is) (LetPerms xs0 ts (t ': is)) (Permutations is)
{
$(singletons [d
permutations :: forall a. [a] > [[a]]
permutations xs0 = xs0 : perms xs0 []
where
perms [] _ = []
perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is)
where
interleave :: [a] > [[a]] > [[a]]
interleave = undefined
])
}
type family Permutations (xs0 :: [a]) :: [[a]] where
Permutations xs0 = xs0 ': LetPerms xs0 xs0 '[]
sPermutations :: forall (t1 :: [a]).
Sing t1 > Sing (Permutations t1 :: [[a]])
sPermutations (sXs0 :: Sing xs0)
= let sPerms :: forall arg1 arg2.
Sing arg1 > Sing arg2
> Sing (LetPerms xs0 arg1 arg2)
sPerms SNil _ = SNil
sPerms (SCons (sT :: Sing t) (sTs :: Sing ts)) (sIs :: Sing is)
= let sInterleave :: forall (t2 :: [a]) (t3 :: [[a]]).
Sing t2 > Sing t3
> Sing (LetInterleave xs0 t ts is t2 t3 :: [[a]])
sInterleave (sA1 :: Sing a1) (sA2 :: Sing a2)
= sUndefined sA1 sA2
in sFoldr (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)
(sPerms sTs (sT `SCons` sIs))
(sPermutations sIs)
in sXs0 `SCons` sPerms sXs0 SNil
```
After that commit, this program (which previously typechecked) now errors with:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:105:66: error:
• Could not deduce: t2 ~~ t30
from the context: arg1 ~ (x : xs)
bound by a pattern with constructor:
SCons :: forall a (x :: a) (xs :: [a]).
Sing x > Sing xs > Sing (x : xs),
in an equation for ‘sPerms’
at Bug.hs:99:1753
‘t2’ is a rigid type variable bound by
a type expected by the context:
SingFunction2 (LetInterleaveSym4 t1 x xs arg2)
at Bug.hs:105:2476
Expected type: Sing t
> Sing t2
> Sing (Apply (Apply (LetInterleaveSym4 t1 x xs arg2) t) t2)
Actual type: Sing t20
> Sing t30 > Sing (LetInterleave t1 x xs arg2 t20 t30)
• In the second argument of ‘singFun2’, namely ‘sInterleave’
In the first argument of ‘sFoldr’, namely
‘(singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)’
In the expression:
sFoldr
(singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)
(sPerms sTs (sT `SCons` sIs))
(sPermutations sIs)
• Relevant bindings include
sInterleave :: forall (t2 :: [a1]) (t3 :: [[a1]]).
Sing t2 > Sing t3 > Sing (LetInterleave t1 x xs arg2 t2 t3)
(bound at Bug.hs:103:17)
sIs :: Sing arg2 (bound at Bug.hs:99:57)
sTs :: Sing xs (bound at Bug.hs:99:39)
sT :: Sing x (bound at Bug.hs:99:24)
sPerms :: Sing arg1 > Sing arg2 > Sing (LetPerms t1 arg1 arg2)
(bound at Bug.hs:98:9)
sXs0 :: Sing t1 (bound at Bug.hs:94:16)
(Some bindings suppressed; use fmaxrelevantbinds=N or fnomaxrelevantbinds)

105  in sFoldr (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)
 ^^^^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  goldfire 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD type inference regression post\"Remove decideKindGeneralisationPlan\"","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"Commit c955a514f033a12f6d0ab0fbacec3e18a5757ab5 (`Remove decideKindGeneralisationPlan`) causes the `singletons` library to no longer compile. Here is as minimal of an example as I can muster:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug (sPermutations) where\r\n\r\nimport Data.Kind\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\ndata family Sing :: forall k. k > Type\r\ndata instance Sing :: forall a. [a] > Type where\r\n SNil :: Sing '[]\r\n SCons :: Sing x > Sing xs > Sing (x:xs)\r\n\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }\r\n\r\ntype SingFunction1 f = forall t. Sing t > Sing (Apply f t)\r\nsingFun1 :: forall f. SingFunction1 f > Sing f\r\nsingFun1 f = SLambda f\r\n\r\ntype SingFunction2 f = forall t. Sing t > SingFunction1 (Apply f t)\r\nsingFun2 :: forall f. SingFunction2 f > Sing f\r\nsingFun2 f = SLambda (\\x > singFun1 (f x))\r\n\r\ntype family Undefined :: k where {}\r\n\r\nsUndefined :: a\r\nsUndefined = undefined\r\n\r\ntype family LetGo k z x ys where\r\n LetGo k z x '[] = z\r\n LetGo k z x (y ': ys) = Apply (Apply k y) (LetGo k z x ys)\r\n\r\ntype family Foldr (k :: a ~> b ~> b) (x :: b) (xs :: [a]) :: b where\r\n Foldr k z x = LetGo k z x x\r\n\r\nsFoldr :: forall (t1 :: a ~> b ~> b) (t2 :: b) (t3 :: [a]).\r\n Sing t1 > Sing t2 > Sing t3\r\n > Sing (Foldr t1 t2 t3 :: b)\r\nsFoldr (sK :: Sing k) (sZ :: Sing z) (sX :: Sing x)\r\n = let sGo :: forall arg. Sing arg > Sing (LetGo k z x arg)\r\n sGo SNil = sZ\r\n sGo (SCons (sY :: Sing y) (sYs :: Sing ys))\r\n = sK `applySing` sY `applySing` sGo sYs\r\n in sGo sX\r\n\r\ntype family LetInterleave xs0 t ts is (a1 :: [a]) (a2 :: [[a]]) :: [[a]] where\r\n LetInterleave xs0 t ts is a1 a2 = Undefined a1 a2\r\ndata LetInterleaveSym5 l_ahko l_ahkp l_ahkq l_ahkr (l_ahks :: [a]) :: [[a]] ~> [[a]]\r\ntype instance Apply (LetInterleaveSym5 l_ahko l_ahkp l_ahkq l_ahkr l_ahks) l_ahkn = LetInterleave l_ahko l_ahkp l_ahkq l_ahkr l_ahks l_ahkn\r\ndata LetInterleaveSym4 l_ahkv l_ahkw l_ahkx l_ahky :: forall a. [a] ~> [[a]] ~> [[a]]\r\ntype instance Apply (LetInterleaveSym4 l_ahkv l_ahkw l_ahkx l_ahky) l_ahku = LetInterleaveSym5 l_ahkv l_ahkw l_ahkx l_ahky l_ahku\r\ndata LetInterleaveSym3 l_ahkB l_ahkC l_ahkD l_ahkA\r\ntype instance Apply (LetInterleaveSym3 l_ahkB l_ahkC l_ahkD) l_ahkA = LetInterleaveSym4 l_ahkB l_ahkC l_ahkD l_ahkA\r\ndata LetInterleaveSym2 l_ahkG l_ahkH l_ahkF\r\ntype instance Apply (LetInterleaveSym2 l_ahkG l_ahkH) l_ahkF = LetInterleaveSym3 l_ahkG l_ahkH l_ahkF\r\ndata LetInterleaveSym1 l_ahkK l_ahkJ\r\ntype instance Apply (LetInterleaveSym1 l_ahkK) l_ahkJ = LetInterleaveSym2 l_ahkK l_ahkJ\r\ndata LetInterleaveSym0 l_ahkM\r\ntype instance Apply LetInterleaveSym0 l_ahkM = LetInterleaveSym1 l_ahkM\r\n\r\ntype family LetPerms xs0 a1 a2 where\r\n LetPerms xs0 '[] _ = '[]\r\n LetPerms xs0 (t ': ts) is =\r\n Foldr (LetInterleaveSym4 xs0 t ts is) (LetPerms xs0 ts (t ': is)) (Permutations is)\r\n\r\n{\r\n$(singletons [d\r\n permutations :: forall a. [a] > [[a]]\r\n permutations xs0 = xs0 : perms xs0 []\r\n where\r\n perms [] _ = []\r\n perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is)\r\n where\r\n interleave :: [a] > [[a]] > [[a]]\r\n interleave = undefined\r\n ])\r\n}\r\n\r\ntype family Permutations (xs0 :: [a]) :: [[a]] where\r\n Permutations xs0 = xs0 ': LetPerms xs0 xs0 '[]\r\n\r\nsPermutations :: forall (t1 :: [a]).\r\n Sing t1 > Sing (Permutations t1 :: [[a]])\r\nsPermutations (sXs0 :: Sing xs0)\r\n = let sPerms :: forall arg1 arg2.\r\n Sing arg1 > Sing arg2\r\n > Sing (LetPerms xs0 arg1 arg2)\r\n sPerms SNil _ = SNil\r\n sPerms (SCons (sT :: Sing t) (sTs :: Sing ts)) (sIs :: Sing is)\r\n = let sInterleave :: forall (t2 :: [a]) (t3 :: [[a]]).\r\n Sing t2 > Sing t3\r\n > Sing (LetInterleave xs0 t ts is t2 t3 :: [[a]])\r\n sInterleave (sA1 :: Sing a1) (sA2 :: Sing a2)\r\n = sUndefined sA1 sA2\r\n in sFoldr (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)\r\n (sPerms sTs (sT `SCons` sIs))\r\n (sPermutations sIs)\r\n in sXs0 `SCons` sPerms sXs0 SNil\r\n}}}\r\n\r\nAfter that commit, this program (which previously typechecked) now errors with:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:105:66: error:\r\n • Could not deduce: t2 ~~ t30\r\n from the context: arg1 ~ (x : xs)\r\n bound by a pattern with constructor:\r\n SCons :: forall a (x :: a) (xs :: [a]).\r\n Sing x > Sing xs > Sing (x : xs),\r\n in an equation for ‘sPerms’\r\n at Bug.hs:99:1753\r\n ‘t2’ is a rigid type variable bound by\r\n a type expected by the context:\r\n SingFunction2 (LetInterleaveSym4 t1 x xs arg2)\r\n at Bug.hs:105:2476\r\n Expected type: Sing t\r\n > Sing t2\r\n > Sing (Apply (Apply (LetInterleaveSym4 t1 x xs arg2) t) t2)\r\n Actual type: Sing t20\r\n > Sing t30 > Sing (LetInterleave t1 x xs arg2 t20 t30)\r\n • In the second argument of ‘singFun2’, namely ‘sInterleave’\r\n In the first argument of ‘sFoldr’, namely\r\n ‘(singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)’\r\n In the expression:\r\n sFoldr\r\n (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)\r\n (sPerms sTs (sT `SCons` sIs))\r\n (sPermutations sIs)\r\n • Relevant bindings include\r\n sInterleave :: forall (t2 :: [a1]) (t3 :: [[a1]]).\r\n Sing t2 > Sing t3 > Sing (LetInterleave t1 x xs arg2 t2 t3)\r\n (bound at Bug.hs:103:17)\r\n sIs :: Sing arg2 (bound at Bug.hs:99:57)\r\n sTs :: Sing xs (bound at Bug.hs:99:39)\r\n sT :: Sing x (bound at Bug.hs:99:24)\r\n sPerms :: Sing arg1 > Sing arg2 > Sing (LetPerms t1 arg1 arg2)\r\n (bound at Bug.hs:98:9)\r\n sXs0 :: Sing t1 (bound at Bug.hs:94:16)\r\n (Some bindings suppressed; use fmaxrelevantbinds=N or fnomaxrelevantbinds)\r\n \r\n105  in sFoldr (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)\r\n  ^^^^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >Commit c955a514f033a12f6d0ab0fbacec3e18a5757ab5 (`Remove decideKindGeneralisationPlan`) causes the `singletons` library to no longer compile. Here is as minimal of an example as I can muster:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE UndecidableInstances #}
module Bug (sPermutations) where
import Data.Kind
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing :: forall k. k > Type
data instance Sing :: forall a. [a] > Type where
SNil :: Sing '[]
SCons :: Sing x > Sing xs > Sing (x:xs)
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }
type SingFunction1 f = forall t. Sing t > Sing (Apply f t)
singFun1 :: forall f. SingFunction1 f > Sing f
singFun1 f = SLambda f
type SingFunction2 f = forall t. Sing t > SingFunction1 (Apply f t)
singFun2 :: forall f. SingFunction2 f > Sing f
singFun2 f = SLambda (\x > singFun1 (f x))
type family Undefined :: k where {}
sUndefined :: a
sUndefined = undefined
type family LetGo k z x ys where
LetGo k z x '[] = z
LetGo k z x (y ': ys) = Apply (Apply k y) (LetGo k z x ys)
type family Foldr (k :: a ~> b ~> b) (x :: b) (xs :: [a]) :: b where
Foldr k z x = LetGo k z x x
sFoldr :: forall (t1 :: a ~> b ~> b) (t2 :: b) (t3 :: [a]).
Sing t1 > Sing t2 > Sing t3
> Sing (Foldr t1 t2 t3 :: b)
sFoldr (sK :: Sing k) (sZ :: Sing z) (sX :: Sing x)
= let sGo :: forall arg. Sing arg > Sing (LetGo k z x arg)
sGo SNil = sZ
sGo (SCons (sY :: Sing y) (sYs :: Sing ys))
= sK `applySing` sY `applySing` sGo sYs
in sGo sX
type family LetInterleave xs0 t ts is (a1 :: [a]) (a2 :: [[a]]) :: [[a]] where
LetInterleave xs0 t ts is a1 a2 = Undefined a1 a2
data LetInterleaveSym5 l_ahko l_ahkp l_ahkq l_ahkr (l_ahks :: [a]) :: [[a]] ~> [[a]]
type instance Apply (LetInterleaveSym5 l_ahko l_ahkp l_ahkq l_ahkr l_ahks) l_ahkn = LetInterleave l_ahko l_ahkp l_ahkq l_ahkr l_ahks l_ahkn
data LetInterleaveSym4 l_ahkv l_ahkw l_ahkx l_ahky :: forall a. [a] ~> [[a]] ~> [[a]]
type instance Apply (LetInterleaveSym4 l_ahkv l_ahkw l_ahkx l_ahky) l_ahku = LetInterleaveSym5 l_ahkv l_ahkw l_ahkx l_ahky l_ahku
data LetInterleaveSym3 l_ahkB l_ahkC l_ahkD l_ahkA
type instance Apply (LetInterleaveSym3 l_ahkB l_ahkC l_ahkD) l_ahkA = LetInterleaveSym4 l_ahkB l_ahkC l_ahkD l_ahkA
data LetInterleaveSym2 l_ahkG l_ahkH l_ahkF
type instance Apply (LetInterleaveSym2 l_ahkG l_ahkH) l_ahkF = LetInterleaveSym3 l_ahkG l_ahkH l_ahkF
data LetInterleaveSym1 l_ahkK l_ahkJ
type instance Apply (LetInterleaveSym1 l_ahkK) l_ahkJ = LetInterleaveSym2 l_ahkK l_ahkJ
data LetInterleaveSym0 l_ahkM
type instance Apply LetInterleaveSym0 l_ahkM = LetInterleaveSym1 l_ahkM
type family LetPerms xs0 a1 a2 where
LetPerms xs0 '[] _ = '[]
LetPerms xs0 (t ': ts) is =
Foldr (LetInterleaveSym4 xs0 t ts is) (LetPerms xs0 ts (t ': is)) (Permutations is)
{
$(singletons [d
permutations :: forall a. [a] > [[a]]
permutations xs0 = xs0 : perms xs0 []
where
perms [] _ = []
perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is)
where
interleave :: [a] > [[a]] > [[a]]
interleave = undefined
])
}
type family Permutations (xs0 :: [a]) :: [[a]] where
Permutations xs0 = xs0 ': LetPerms xs0 xs0 '[]
sPermutations :: forall (t1 :: [a]).
Sing t1 > Sing (Permutations t1 :: [[a]])
sPermutations (sXs0 :: Sing xs0)
= let sPerms :: forall arg1 arg2.
Sing arg1 > Sing arg2
> Sing (LetPerms xs0 arg1 arg2)
sPerms SNil _ = SNil
sPerms (SCons (sT :: Sing t) (sTs :: Sing ts)) (sIs :: Sing is)
= let sInterleave :: forall (t2 :: [a]) (t3 :: [[a]]).
Sing t2 > Sing t3
> Sing (LetInterleave xs0 t ts is t2 t3 :: [[a]])
sInterleave (sA1 :: Sing a1) (sA2 :: Sing a2)
= sUndefined sA1 sA2
in sFoldr (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)
(sPerms sTs (sT `SCons` sIs))
(sPermutations sIs)
in sXs0 `SCons` sPerms sXs0 SNil
```
After that commit, this program (which previously typechecked) now errors with:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:105:66: error:
• Could not deduce: t2 ~~ t30
from the context: arg1 ~ (x : xs)
bound by a pattern with constructor:
SCons :: forall a (x :: a) (xs :: [a]).
Sing x > Sing xs > Sing (x : xs),
in an equation for ‘sPerms’
at Bug.hs:99:1753
‘t2’ is a rigid type variable bound by
a type expected by the context:
SingFunction2 (LetInterleaveSym4 t1 x xs arg2)
at Bug.hs:105:2476
Expected type: Sing t
> Sing t2
> Sing (Apply (Apply (LetInterleaveSym4 t1 x xs arg2) t) t2)
Actual type: Sing t20
> Sing t30 > Sing (LetInterleave t1 x xs arg2 t20 t30)
• In the second argument of ‘singFun2’, namely ‘sInterleave’
In the first argument of ‘sFoldr’, namely
‘(singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)’
In the expression:
sFoldr
(singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)
(sPerms sTs (sT `SCons` sIs))
(sPermutations sIs)
• Relevant bindings include
sInterleave :: forall (t2 :: [a1]) (t3 :: [[a1]]).
Sing t2 > Sing t3 > Sing (LetInterleave t1 x xs arg2 t2 t3)
(bound at Bug.hs:103:17)
sIs :: Sing arg2 (bound at Bug.hs:99:57)
sTs :: Sing xs (bound at Bug.hs:99:39)
sT :: Sing x (bound at Bug.hs:99:24)
sPerms :: Sing arg1 > Sing arg2 > Sing (LetPerms t1 arg1 arg2)
(bound at Bug.hs:98:9)
sXs0 :: Sing t1 (bound at Bug.hs:94:16)
(Some bindings suppressed; use fmaxrelevantbinds=N or fnomaxrelevantbinds)

105  in sFoldr (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)
 ^^^^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  goldfire 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD type inference regression post\"Remove decideKindGeneralisationPlan\"","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"Commit c955a514f033a12f6d0ab0fbacec3e18a5757ab5 (`Remove decideKindGeneralisationPlan`) causes the `singletons` library to no longer compile. Here is as minimal of an example as I can muster:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug (sPermutations) where\r\n\r\nimport Data.Kind\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\ndata family Sing :: forall k. k > Type\r\ndata instance Sing :: forall a. [a] > Type where\r\n SNil :: Sing '[]\r\n SCons :: Sing x > Sing xs > Sing (x:xs)\r\n\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }\r\n\r\ntype SingFunction1 f = forall t. Sing t > Sing (Apply f t)\r\nsingFun1 :: forall f. SingFunction1 f > Sing f\r\nsingFun1 f = SLambda f\r\n\r\ntype SingFunction2 f = forall t. Sing t > SingFunction1 (Apply f t)\r\nsingFun2 :: forall f. SingFunction2 f > Sing f\r\nsingFun2 f = SLambda (\\x > singFun1 (f x))\r\n\r\ntype family Undefined :: k where {}\r\n\r\nsUndefined :: a\r\nsUndefined = undefined\r\n\r\ntype family LetGo k z x ys where\r\n LetGo k z x '[] = z\r\n LetGo k z x (y ': ys) = Apply (Apply k y) (LetGo k z x ys)\r\n\r\ntype family Foldr (k :: a ~> b ~> b) (x :: b) (xs :: [a]) :: b where\r\n Foldr k z x = LetGo k z x x\r\n\r\nsFoldr :: forall (t1 :: a ~> b ~> b) (t2 :: b) (t3 :: [a]).\r\n Sing t1 > Sing t2 > Sing t3\r\n > Sing (Foldr t1 t2 t3 :: b)\r\nsFoldr (sK :: Sing k) (sZ :: Sing z) (sX :: Sing x)\r\n = let sGo :: forall arg. Sing arg > Sing (LetGo k z x arg)\r\n sGo SNil = sZ\r\n sGo (SCons (sY :: Sing y) (sYs :: Sing ys))\r\n = sK `applySing` sY `applySing` sGo sYs\r\n in sGo sX\r\n\r\ntype family LetInterleave xs0 t ts is (a1 :: [a]) (a2 :: [[a]]) :: [[a]] where\r\n LetInterleave xs0 t ts is a1 a2 = Undefined a1 a2\r\ndata LetInterleaveSym5 l_ahko l_ahkp l_ahkq l_ahkr (l_ahks :: [a]) :: [[a]] ~> [[a]]\r\ntype instance Apply (LetInterleaveSym5 l_ahko l_ahkp l_ahkq l_ahkr l_ahks) l_ahkn = LetInterleave l_ahko l_ahkp l_ahkq l_ahkr l_ahks l_ahkn\r\ndata LetInterleaveSym4 l_ahkv l_ahkw l_ahkx l_ahky :: forall a. [a] ~> [[a]] ~> [[a]]\r\ntype instance Apply (LetInterleaveSym4 l_ahkv l_ahkw l_ahkx l_ahky) l_ahku = LetInterleaveSym5 l_ahkv l_ahkw l_ahkx l_ahky l_ahku\r\ndata LetInterleaveSym3 l_ahkB l_ahkC l_ahkD l_ahkA\r\ntype instance Apply (LetInterleaveSym3 l_ahkB l_ahkC l_ahkD) l_ahkA = LetInterleaveSym4 l_ahkB l_ahkC l_ahkD l_ahkA\r\ndata LetInterleaveSym2 l_ahkG l_ahkH l_ahkF\r\ntype instance Apply (LetInterleaveSym2 l_ahkG l_ahkH) l_ahkF = LetInterleaveSym3 l_ahkG l_ahkH l_ahkF\r\ndata LetInterleaveSym1 l_ahkK l_ahkJ\r\ntype instance Apply (LetInterleaveSym1 l_ahkK) l_ahkJ = LetInterleaveSym2 l_ahkK l_ahkJ\r\ndata LetInterleaveSym0 l_ahkM\r\ntype instance Apply LetInterleaveSym0 l_ahkM = LetInterleaveSym1 l_ahkM\r\n\r\ntype family LetPerms xs0 a1 a2 where\r\n LetPerms xs0 '[] _ = '[]\r\n LetPerms xs0 (t ': ts) is =\r\n Foldr (LetInterleaveSym4 xs0 t ts is) (LetPerms xs0 ts (t ': is)) (Permutations is)\r\n\r\n{\r\n$(singletons [d\r\n permutations :: forall a. [a] > [[a]]\r\n permutations xs0 = xs0 : perms xs0 []\r\n where\r\n perms [] _ = []\r\n perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is)\r\n where\r\n interleave :: [a] > [[a]] > [[a]]\r\n interleave = undefined\r\n ])\r\n}\r\n\r\ntype family Permutations (xs0 :: [a]) :: [[a]] where\r\n Permutations xs0 = xs0 ': LetPerms xs0 xs0 '[]\r\n\r\nsPermutations :: forall (t1 :: [a]).\r\n Sing t1 > Sing (Permutations t1 :: [[a]])\r\nsPermutations (sXs0 :: Sing xs0)\r\n = let sPerms :: forall arg1 arg2.\r\n Sing arg1 > Sing arg2\r\n > Sing (LetPerms xs0 arg1 arg2)\r\n sPerms SNil _ = SNil\r\n sPerms (SCons (sT :: Sing t) (sTs :: Sing ts)) (sIs :: Sing is)\r\n = let sInterleave :: forall (t2 :: [a]) (t3 :: [[a]]).\r\n Sing t2 > Sing t3\r\n > Sing (LetInterleave xs0 t ts is t2 t3 :: [[a]])\r\n sInterleave (sA1 :: Sing a1) (sA2 :: Sing a2)\r\n = sUndefined sA1 sA2\r\n in sFoldr (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)\r\n (sPerms sTs (sT `SCons` sIs))\r\n (sPermutations sIs)\r\n in sXs0 `SCons` sPerms sXs0 SNil\r\n}}}\r\n\r\nAfter that commit, this program (which previously typechecked) now errors with:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:105:66: error:\r\n • Could not deduce: t2 ~~ t30\r\n from the context: arg1 ~ (x : xs)\r\n bound by a pattern with constructor:\r\n SCons :: forall a (x :: a) (xs :: [a]).\r\n Sing x > Sing xs > Sing (x : xs),\r\n in an equation for ‘sPerms’\r\n at Bug.hs:99:1753\r\n ‘t2’ is a rigid type variable bound by\r\n a type expected by the context:\r\n SingFunction2 (LetInterleaveSym4 t1 x xs arg2)\r\n at Bug.hs:105:2476\r\n Expected type: Sing t\r\n > Sing t2\r\n > Sing (Apply (Apply (LetInterleaveSym4 t1 x xs arg2) t) t2)\r\n Actual type: Sing t20\r\n > Sing t30 > Sing (LetInterleave t1 x xs arg2 t20 t30)\r\n • In the second argument of ‘singFun2’, namely ‘sInterleave’\r\n In the first argument of ‘sFoldr’, namely\r\n ‘(singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)’\r\n In the expression:\r\n sFoldr\r\n (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)\r\n (sPerms sTs (sT `SCons` sIs))\r\n (sPermutations sIs)\r\n • Relevant bindings include\r\n sInterleave :: forall (t2 :: [a1]) (t3 :: [[a1]]).\r\n Sing t2 > Sing t3 > Sing (LetInterleave t1 x xs arg2 t2 t3)\r\n (bound at Bug.hs:103:17)\r\n sIs :: Sing arg2 (bound at Bug.hs:99:57)\r\n sTs :: Sing xs (bound at Bug.hs:99:39)\r\n sT :: Sing x (bound at Bug.hs:99:24)\r\n sPerms :: Sing arg1 > Sing arg2 > Sing (LetPerms t1 arg1 arg2)\r\n (bound at Bug.hs:98:9)\r\n sXs0 :: Sing t1 (bound at Bug.hs:94:16)\r\n (Some bindings suppressed; use fmaxrelevantbinds=N or fnomaxrelevantbinds)\r\n \r\n105  in sFoldr (singFun2 @(LetInterleaveSym4 xs0 t ts is) sInterleave)\r\n  ^^^^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15473GHC 8.6+ loops infinitely on an UndecidableInstances error message20190707T18:04:35ZRyan ScottGHC 8.6+ loops infinitely on an UndecidableInstances error messageThis regression was introduced in commit e1b5a1174e42e390855b153015ce5227b3251d89 (`Fix a nasty bug in piResultTys`), which is present in the `ghc8.6` and `master` branches. To observe the issue, try compiling the following program:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
 {# LANGUAGE UndecidableInstances #}
module Bug where
type family Undefined :: k where {}
type family LetInterleave xs t ts is (a_ahkO :: [a]) (a_ahkP :: [[a]]) :: [[a]] where
LetInterleave xs t ts is y z = Undefined y z
```
You'll get this far:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:11:3: error:
• Variables ‘a, a’ occur more often
in the type family application
```
Before GHC hangs. (I was unable to kill this with Ctrl+C; I had to resort to `kill 9`.)
Interestingly, the commit f8618a9b15177ee8c84771b927cb3583c9cd8408 (`Remove the typechecking knot.`) does not appear to have an effect on this.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  simonpj 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC 8.6+ loops infinitely on an UndecidableInstances error message","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["simonpj"],"type":"Bug","description":"This regression was introduced in commit e1b5a1174e42e390855b153015ce5227b3251d89 (`Fix a nasty bug in piResultTys`), which is present in the `ghc8.6` and `master` branches. To observe the issue, try compiling the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n {# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\ntype family Undefined :: k where {}\r\n\r\ntype family LetInterleave xs t ts is (a_ahkO :: [a]) (a_ahkP :: [[a]]) :: [[a]] where\r\n LetInterleave xs t ts is y z = Undefined y z\r\n}}}\r\n\r\nYou'll get this far:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:11:3: error:\r\n • Variables ‘a, a’ occur more often\r\n in the type family application\r\n}}}\r\n\r\nBefore GHC hangs. (I was unable to kill this with Ctrl+C; I had to resort to `kill 9`.)\r\n\r\nInterestingly, the commit f8618a9b15177ee8c84771b927cb3583c9cd8408 (`Remove the typechecking knot.`) does not appear to have an effect on this.","type_of_failure":"OtherFailure","blocking":[]} >This regression was introduced in commit e1b5a1174e42e390855b153015ce5227b3251d89 (`Fix a nasty bug in piResultTys`), which is present in the `ghc8.6` and `master` branches. To observe the issue, try compiling the following program:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
 {# LANGUAGE UndecidableInstances #}
module Bug where
type family Undefined :: k where {}
type family LetInterleave xs t ts is (a_ahkO :: [a]) (a_ahkP :: [[a]]) :: [[a]] where
LetInterleave xs t ts is y z = Undefined y z
```
You'll get this far:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:11:3: error:
• Variables ‘a, a’ occur more often
in the type family application
```
Before GHC hangs. (I was unable to kill this with Ctrl+C; I had to resort to `kill 9`.)
Interestingly, the commit f8618a9b15177ee8c84771b927cb3583c9cd8408 (`Remove the typechecking knot.`) does not appear to have an effect on this.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  simonpj 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC 8.6+ loops infinitely on an UndecidableInstances error message","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["simonpj"],"type":"Bug","description":"This regression was introduced in commit e1b5a1174e42e390855b153015ce5227b3251d89 (`Fix a nasty bug in piResultTys`), which is present in the `ghc8.6` and `master` branches. To observe the issue, try compiling the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n {# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\ntype family Undefined :: k where {}\r\n\r\ntype family LetInterleave xs t ts is (a_ahkO :: [a]) (a_ahkP :: [[a]]) :: [[a]] where\r\n LetInterleave xs t ts is y z = Undefined y z\r\n}}}\r\n\r\nYou'll get this far:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:11:3: error:\r\n • Variables ‘a, a’ occur more often\r\n in the type family application\r\n}}}\r\n\r\nBefore GHC hangs. (I was unable to kill this with Ctrl+C; I had to resort to `kill 9`.)\r\n\r\nInterestingly, the commit f8618a9b15177ee8c84771b927cb3583c9cd8408 (`Remove the typechecking knot.`) does not appear to have an effect on this.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15505Assertion failures in tests T7224, T9201, LevPolyBounded20190707T18:04:27ZÖmer Sinan AğacanAssertion failures in tests T7224, T9201, LevPolyBoundedTo reproduce, build GHC HEAD with slow validate settings, then run the tests. Outputs:
```
=====> T7224(normal) 9 of 15 [0, 2, 0]
cd "polykinds/T7224.run" && "/home/omer/haskell/ghc/inplace/test spaces/ghcstage2" c T7224.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput
Actual stderr output differs from expected:
diff uw "polykinds/T7224.run/T7224.stderr.normalised" "polykinds/T7224.run/T7224.comp.stderr.normalised"
 polykinds/T7224.run/T7224.stderr.normalised 20180811 13:33:16.874459507 +0300
+++ polykinds/T7224.run/T7224.comp.stderr.normalised 20180811 13:33:16.874459507 +0300
@@ 1,13 +1,11 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 8.7.20180809 for x86_64unknownlinux):
+ ASSERT failed!
+ Typecorrect unfilled coercion hole {co_asw}
+ Call stack:
+ CallStack (from HasCallStack):
+ callStackDoc, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ pprPanic, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ assertPprPanic, called at compiler/typecheck/TcHsSyn.hs:<line>:<column> in <packageid>:TcHsSyn
T7224.hs:6:19:
 Expected kind ‘i’, but ‘i’ has kind ‘*’
 In the first argument of ‘m’, namely ‘i’
 In the type signature: ret' :: a > m i i a
 In the class declaration for ‘PMonad'’

T7224.hs:7:14:
 Expected kind ‘i’, but ‘i’ has kind ‘*’
 In the first argument of ‘m’, namely ‘i’
 In the type signature:
 bind' :: m i j a > (a > m j k b) > m i k b
 In the class declaration for ‘PMonad'’
+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for T7224(normal)
=====> T9201(normal) 11 of 15 [0, 3, 0]
cd "typecheck/should_fail/T9201.run" && "/home/omer/haskell/ghc/inplace/test spaces/ghcstage2" c T9201.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput
Actual stderr output differs from expected:
diff uw "typecheck/should_fail/T9201.run/T9201.stderr.normalised" "typecheck/should_fail/T9201.run/T9201.comp.stderr.normalised"
 typecheck/should_fail/T9201.run/T9201.stderr.normalised 20180811 13:33:21.058404868 +0300
+++ typecheck/should_fail/T9201.run/T9201.comp.stderr.normalised 20180811 13:33:21.058404868 +0300
@@ 1,7 +1,11 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 8.7.20180809 for x86_64unknownlinux):
+ ASSERT failed!
+ Typecorrect unfilled coercion hole {co_asr}
+ Call stack:
+ CallStack (from HasCallStack):
+ callStackDoc, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ pprPanic, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ assertPprPanic, called at compiler/typecheck/TcHsSyn.hs:<line>:<column> in <packageid>:TcHsSyn
T9201.hs:6:17:
 Expected kind ‘x’, but ‘a’ has kind ‘y’
 In the first argument of ‘f’, namely ‘a’
 In the second argument of ‘d’, namely ‘(f a)’
 In the type signature:
 ret :: d a (f a)
+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for T9201(normal)
=====> LevPolyBounded(normal) 12 of 15 [0, 4, 0]
cd "typecheck/should_fail/LevPolyBounded.run" && "/home/omer/haskell/ghc/inplace/test spaces/ghcstage2" c LevPolyBounded.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput
Actual stderr output differs from expected:
diff uw "typecheck/should_fail/LevPolyBounded.run/LevPolyBounded.stderr.normalised" "typecheck/should_fail/LevPolyBounded.run/LevPolyBounded.comp.stderr.normalised"
 typecheck/should_fail/LevPolyBounded.run/LevPolyBounded.stderr.normalised 20180811 13:33:21.150403667 +0300
+++ typecheck/should_fail/LevPolyBounded.run/LevPolyBounded.comp.stderr.normalised 20180811 13:33:21.150403667 +0300
@@ 1,5 +1,11 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 8.7.20180809 for x86_64unknownlinux):
+ ASSERT failed!
+ Typecorrect unfilled coercion hole {co_avm}
+ Call stack:
+ CallStack (from HasCallStack):
+ callStackDoc, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ pprPanic, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ assertPprPanic, called at compiler/typecheck/TcHsSyn.hs:<line>:<column> in <packageid>:TcHsSyn
LevPolyBounded.hs:10:15:
 Expected a type, but ‘a’ has kind ‘TYPE r’
 In the type signature: LevPolyBounded.minBound :: a
 In the class declaration for ‘XBounded’
+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for LevPolyBounded(normal)
```To reproduce, build GHC HEAD with slow validate settings, then run the tests. Outputs:
```
=====> T7224(normal) 9 of 15 [0, 2, 0]
cd "polykinds/T7224.run" && "/home/omer/haskell/ghc/inplace/test spaces/ghcstage2" c T7224.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput
Actual stderr output differs from expected:
diff uw "polykinds/T7224.run/T7224.stderr.normalised" "polykinds/T7224.run/T7224.comp.stderr.normalised"
 polykinds/T7224.run/T7224.stderr.normalised 20180811 13:33:16.874459507 +0300
+++ polykinds/T7224.run/T7224.comp.stderr.normalised 20180811 13:33:16.874459507 +0300
@@ 1,13 +1,11 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 8.7.20180809 for x86_64unknownlinux):
+ ASSERT failed!
+ Typecorrect unfilled coercion hole {co_asw}
+ Call stack:
+ CallStack (from HasCallStack):
+ callStackDoc, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ pprPanic, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ assertPprPanic, called at compiler/typecheck/TcHsSyn.hs:<line>:<column> in <packageid>:TcHsSyn
T7224.hs:6:19:
 Expected kind ‘i’, but ‘i’ has kind ‘*’
 In the first argument of ‘m’, namely ‘i’
 In the type signature: ret' :: a > m i i a
 In the class declaration for ‘PMonad'’

T7224.hs:7:14:
 Expected kind ‘i’, but ‘i’ has kind ‘*’
 In the first argument of ‘m’, namely ‘i’
 In the type signature:
 bind' :: m i j a > (a > m j k b) > m i k b
 In the class declaration for ‘PMonad'’
+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for T7224(normal)
=====> T9201(normal) 11 of 15 [0, 3, 0]
cd "typecheck/should_fail/T9201.run" && "/home/omer/haskell/ghc/inplace/test spaces/ghcstage2" c T9201.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput
Actual stderr output differs from expected:
diff uw "typecheck/should_fail/T9201.run/T9201.stderr.normalised" "typecheck/should_fail/T9201.run/T9201.comp.stderr.normalised"
 typecheck/should_fail/T9201.run/T9201.stderr.normalised 20180811 13:33:21.058404868 +0300
+++ typecheck/should_fail/T9201.run/T9201.comp.stderr.normalised 20180811 13:33:21.058404868 +0300
@@ 1,7 +1,11 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 8.7.20180809 for x86_64unknownlinux):
+ ASSERT failed!
+ Typecorrect unfilled coercion hole {co_asr}
+ Call stack:
+ CallStack (from HasCallStack):
+ callStackDoc, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ pprPanic, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ assertPprPanic, called at compiler/typecheck/TcHsSyn.hs:<line>:<column> in <packageid>:TcHsSyn
T9201.hs:6:17:
 Expected kind ‘x’, but ‘a’ has kind ‘y’
 In the first argument of ‘f’, namely ‘a’
 In the second argument of ‘d’, namely ‘(f a)’
 In the type signature:
 ret :: d a (f a)
+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for T9201(normal)
=====> LevPolyBounded(normal) 12 of 15 [0, 4, 0]
cd "typecheck/should_fail/LevPolyBounded.run" && "/home/omer/haskell/ghc/inplace/test spaces/ghcstage2" c LevPolyBounded.hs dcorelint dcmmlint nouserpackagedb rtsopts fnowarnmissedspecialisations fshowwarninggroups fdiagnosticscolor=never fnodiagnosticsshowcaret dnodebugoutput
Actual stderr output differs from expected:
diff uw "typecheck/should_fail/LevPolyBounded.run/LevPolyBounded.stderr.normalised" "typecheck/should_fail/LevPolyBounded.run/LevPolyBounded.comp.stderr.normalised"
 typecheck/should_fail/LevPolyBounded.run/LevPolyBounded.stderr.normalised 20180811 13:33:21.150403667 +0300
+++ typecheck/should_fail/LevPolyBounded.run/LevPolyBounded.comp.stderr.normalised 20180811 13:33:21.150403667 +0300
@@ 1,5 +1,11 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 8.7.20180809 for x86_64unknownlinux):
+ ASSERT failed!
+ Typecorrect unfilled coercion hole {co_avm}
+ Call stack:
+ CallStack (from HasCallStack):
+ callStackDoc, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ pprPanic, called at compiler/utils/Outputable.hs:<line>:<column> in <packageid>:Outputable
+ assertPprPanic, called at compiler/typecheck/TcHsSyn.hs:<line>:<column> in <packageid>:TcHsSyn
LevPolyBounded.hs:10:15:
 Expected a type, but ‘a’ has kind ‘TYPE r’
 In the type signature: LevPolyBounded.minBound :: a
 In the class declaration for ‘XBounded’
+Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
*** unexpected failure for LevPolyBounded(normal)
```8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15515Bogus "No instance" error when type families appear in kinds20190707T18:04:23ZRyan ScottBogus "No instance" error when type families appear in kindsThe following code typechecks:
```hs
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
import Data.Proxy
class C a where
c :: Proxy a
type family F
data D :: F > Type
instance C (D :: F > Type) where
c = undefined
```
However, if we try to actually //use// that `C D` instance, like so:
```hs
c' :: Proxy (D :: F > Type)
c' = c @(D :: F > Type)
```
Then GHC gives a rather flummoxing error message:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:20:6: error:
• No instance for (C D) arising from a use of ‘c’
• In the expression: c @(D :: F > Type)
In an equation for ‘c'’: c' = c @(D :: F > Type)

20  c' = c @(D :: F > Type)
 ^^^^^^^^^^^^^^^^^^^
```
But that error is clearly misleading, as we defined such a `C D` instance directly above it!
The use of the type family `F` in the kind of `D` appears to play an important role in this bug. If I change `F` to be a data type (e.g., `data F`), then `c'` is accepted.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Bogus \"No instance\" error when type families appear in kinds","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code typechecks:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Proxy\r\n\r\nclass C a where\r\n c :: Proxy a\r\n\r\ntype family F\r\n\r\ndata D :: F > Type\r\n\r\ninstance C (D :: F > Type) where\r\n c = undefined\r\n}}}\r\n\r\nHowever, if we try to actually //use// that `C D` instance, like so:\r\n\r\n{{{#!hs\r\nc' :: Proxy (D :: F > Type)\r\nc' = c @(D :: F > Type)\r\n}}}\r\n\r\nThen GHC gives a rather flummoxing error message:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:20:6: error:\r\n • No instance for (C D) arising from a use of ‘c’\r\n • In the expression: c @(D :: F > Type)\r\n In an equation for ‘c'’: c' = c @(D :: F > Type)\r\n \r\n20  c' = c @(D :: F > Type)\r\n  ^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nBut that error is clearly misleading, as we defined such a `C D` instance directly above it!\r\n\r\nThe use of the type family `F` in the kind of `D` appears to play an important role in this bug. If I change `F` to be a data type (e.g., `data F`), then `c'` is accepted.","type_of_failure":"OtherFailure","blocking":[]} >The following code typechecks:
```hs
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
import Data.Proxy
class C a where
c :: Proxy a
type family F
data D :: F > Type
instance C (D :: F > Type) where
c = undefined
```
However, if we try to actually //use// that `C D` instance, like so:
```hs
c' :: Proxy (D :: F > Type)
c' = c @(D :: F > Type)
```
Then GHC gives a rather flummoxing error message:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:20:6: error:
• No instance for (C D) arising from a use of ‘c’
• In the expression: c @(D :: F > Type)
In an equation for ‘c'’: c' = c @(D :: F > Type)

20  c' = c @(D :: F > Type)
 ^^^^^^^^^^^^^^^^^^^
```
But that error is clearly misleading, as we defined such a `C D` instance directly above it!
The use of the type family `F` in the kind of `D` appears to play an important role in this bug. If I change `F` to be a data type (e.g., `data F`), then `c'` is accepted.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Bogus \"No instance\" error when type families appear in kinds","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code typechecks:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Proxy\r\n\r\nclass C a where\r\n c :: Proxy a\r\n\r\ntype family F\r\n\r\ndata D :: F > Type\r\n\r\ninstance C (D :: F > Type) where\r\n c = undefined\r\n}}}\r\n\r\nHowever, if we try to actually //use// that `C D` instance, like so:\r\n\r\n{{{#!hs\r\nc' :: Proxy (D :: F > Type)\r\nc' = c @(D :: F > Type)\r\n}}}\r\n\r\nThen GHC gives a rather flummoxing error message:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:20:6: error:\r\n • No instance for (C D) arising from a use of ‘c’\r\n • In the expression: c @(D :: F > Type)\r\n In an equation for ‘c'’: c' = c @(D :: F > Type)\r\n \r\n20  c' = c @(D :: F > Type)\r\n  ^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nBut that error is clearly misleading, as we defined such a `C D` instance directly above it!\r\n\r\nThe use of the type family `F` in the kind of `D` appears to play an important role in this bug. If I change `F` to be a data type (e.g., `data F`), then `c'` is accepted.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15549Core Lint error with EmptyCase20190707T18:04:11ZRyan ScottCore Lint error with EmptyCaseThe following program gives a Core Lint error on GHC 8.2.2 and later:
```hs
{# LANGUAGE EmptyCase #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind
import Data.Void
data family Sing (a :: k)
data V1 :: Type > Type
data instance Sing (z :: V1 p)
class Generic a where
type Rep a :: Type > Type
to :: Rep a x > a
class PGeneric a where
type To (z :: Rep a x) :: a
class SGeneric a where
sTo :: forall x (r :: Rep a x). Sing r > Sing (To r :: a)

instance Generic Void where
type Rep Void = V1
to x = case x of {}
type family EmptyCase (a :: j) :: k where
instance PGeneric Void where
type To x = EmptyCase x
instance SGeneric Void where
sTo x = case x of
```
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs dcorelint fforcerecomp
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘(Sing (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R’
Function kind = forall k. k > *
Arg kinds = [(V1 x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’
Function kind = V1 x_a12p > *
Arg kinds = [(r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’
Function kind = V1 x_a12p > *
Arg kinds = [(r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
<no location info>: warning:
In the type ‘R:SingV1z x_a12p r_a12q’
Kind application error in type ‘R:SingV1z x_a12p r_a12q’
Function kind = forall p > V1 p > *
Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
<no location info>: warning:
In the type ‘R:SingV1z x_a12p r_a12q’
Kind application error in type ‘R:SingV1z x_a12p r_a12q’
Function kind = forall p > V1 p > *
Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
*** Offending Program ***
<elided>
$csTo_a12n :: forall x (r :: Rep Void x). Sing r > Sing (To r)
[LclId,
Arity=1,
Str=<L,U>x,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
$csTo_a12n
= \ (@ x_a12p)
(@ (r_a12q :: Rep Void x_a12p))
(x_aZ8 :: Sing r_a12q) >
case x_aZ8
`cast` ((Sing
(D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R ; D:R:SingV1z0[0]
<x_a12p>_N <r_a12q>_N
:: (Sing r_a12q :: *) ~R# (R:SingV1z x_a12p r_a12q :: *))
of nt_s13T {
}
```
GHC 8.0.2 does not appear to suffer from this Core Lint error.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error with empty closed type family","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program gives a Core Lint error on GHC 8.2.2 and later:\r\n\r\n{{{#!hs\r\n{# LANGUAGE EmptyCase #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Void\r\n\r\ndata family Sing (a :: k)\r\n\r\ndata V1 :: Type > Type\r\ndata instance Sing (z :: V1 p)\r\n\r\nclass Generic a where\r\n type Rep a :: Type > Type\r\n to :: Rep a x > a\r\n\r\nclass PGeneric a where\r\n type To (z :: Rep a x) :: a\r\n\r\nclass SGeneric a where\r\n sTo :: forall x (r :: Rep a x). Sing r > Sing (To r :: a)\r\n\r\n\r\n\r\ninstance Generic Void where\r\n type Rep Void = V1\r\n to x = case x of {}\r\n\r\ntype family EmptyCase (a :: j) :: k where\r\n\r\ninstance PGeneric Void where\r\n type To x = EmptyCase x\r\n\r\ninstance SGeneric Void where\r\n sTo x = case x of\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs dcorelint fforcerecomp \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Simplifier ***\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘(Sing (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R’\r\n Function kind = forall k. k > *\r\n Arg kinds = [(V1 x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’\r\n Function kind = V1 x_a12p > *\r\n Arg kinds = [(r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’\r\n Function kind = V1 x_a12p > *\r\n Arg kinds = [(r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n<no location info>: warning:\r\n In the type ‘R:SingV1z x_a12p r_a12q’\r\n Kind application error in type ‘R:SingV1z x_a12p r_a12q’\r\n Function kind = forall p > V1 p > *\r\n Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n<no location info>: warning:\r\n In the type ‘R:SingV1z x_a12p r_a12q’\r\n Kind application error in type ‘R:SingV1z x_a12p r_a12q’\r\n Function kind = forall p > V1 p > *\r\n Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\n$csTo_a12n :: forall x (r :: Rep Void x). Sing r > Sing (To r)\r\n[LclId,\r\n Arity=1,\r\n Str=<L,U>x,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]\r\n$csTo_a12n\r\n = \\ (@ x_a12p)\r\n (@ (r_a12q :: Rep Void x_a12p))\r\n (x_aZ8 :: Sing r_a12q) >\r\n case x_aZ8\r\n `cast` ((Sing\r\n (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R ; D:R:SingV1z0[0]\r\n <x_a12p>_N <r_a12q>_N\r\n :: (Sing r_a12q :: *) ~R# (R:SingV1z x_a12p r_a12q :: *))\r\n of nt_s13T {\r\n }\r\n}}}\r\n\r\nGHC 8.0.2 does not appear to suffer from this Core Lint error.","type_of_failure":"OtherFailure","blocking":[]} >The following program gives a Core Lint error on GHC 8.2.2 and later:
```hs
{# LANGUAGE EmptyCase #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind
import Data.Void
data family Sing (a :: k)
data V1 :: Type > Type
data instance Sing (z :: V1 p)
class Generic a where
type Rep a :: Type > Type
to :: Rep a x > a
class PGeneric a where
type To (z :: Rep a x) :: a
class SGeneric a where
sTo :: forall x (r :: Rep a x). Sing r > Sing (To r :: a)

instance Generic Void where
type Rep Void = V1
to x = case x of {}
type family EmptyCase (a :: j) :: k where
instance PGeneric Void where
type To x = EmptyCase x
instance SGeneric Void where
sTo x = case x of
```
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs dcorelint fforcerecomp
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘(Sing (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R’
Function kind = forall k. k > *
Arg kinds = [(V1 x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’
Function kind = V1 x_a12p > *
Arg kinds = [(r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’
Function kind = V1 x_a12p > *
Arg kinds = [(r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
<no location info>: warning:
In the type ‘R:SingV1z x_a12p r_a12q’
Kind application error in type ‘R:SingV1z x_a12p r_a12q’
Function kind = forall p > V1 p > *
Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
<no location info>: warning:
In the type ‘R:SingV1z x_a12p r_a12q’
Kind application error in type ‘R:SingV1z x_a12p r_a12q’
Function kind = forall p > V1 p > *
Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
*** Offending Program ***
<elided>
$csTo_a12n :: forall x (r :: Rep Void x). Sing r > Sing (To r)
[LclId,
Arity=1,
Str=<L,U>x,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
$csTo_a12n
= \ (@ x_a12p)
(@ (r_a12q :: Rep Void x_a12p))
(x_aZ8 :: Sing r_a12q) >
case x_aZ8
`cast` ((Sing
(D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R ; D:R:SingV1z0[0]
<x_a12p>_N <r_a12q>_N
:: (Sing r_a12q :: *) ~R# (R:SingV1z x_a12p r_a12q :: *))
of nt_s13T {
}
```
GHC 8.0.2 does not appear to suffer from this Core Lint error.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error with empty closed type family","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program gives a Core Lint error on GHC 8.2.2 and later:\r\n\r\n{{{#!hs\r\n{# LANGUAGE EmptyCase #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Void\r\n\r\ndata family Sing (a :: k)\r\n\r\ndata V1 :: Type > Type\r\ndata instance Sing (z :: V1 p)\r\n\r\nclass Generic a where\r\n type Rep a :: Type > Type\r\n to :: Rep a x > a\r\n\r\nclass PGeneric a where\r\n type To (z :: Rep a x) :: a\r\n\r\nclass SGeneric a where\r\n sTo :: forall x (r :: Rep a x). Sing r > Sing (To r :: a)\r\n\r\n\r\n\r\ninstance Generic Void where\r\n type Rep Void = V1\r\n to x = case x of {}\r\n\r\ntype family EmptyCase (a :: j) :: k where\r\n\r\ninstance PGeneric Void where\r\n type To x = EmptyCase x\r\n\r\ninstance SGeneric Void where\r\n sTo x = case x of\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs dcorelint fforcerecomp \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Simplifier ***\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘(Sing (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R’\r\n Function kind = forall k. k > *\r\n Arg kinds = [(V1 x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’\r\n Function kind = V1 x_a12p > *\r\n Arg kinds = [(r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’\r\n Function kind = V1 x_a12p > *\r\n Arg kinds = [(r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n<no location info>: warning:\r\n In the type ‘R:SingV1z x_a12p r_a12q’\r\n Kind application error in type ‘R:SingV1z x_a12p r_a12q’\r\n Function kind = forall p > V1 p > *\r\n Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n<no location info>: warning:\r\n In the type ‘R:SingV1z x_a12p r_a12q’\r\n Kind application error in type ‘R:SingV1z x_a12p r_a12q’\r\n Function kind = forall p > V1 p > *\r\n Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\n$csTo_a12n :: forall x (r :: Rep Void x). Sing r > Sing (To r)\r\n[LclId,\r\n Arity=1,\r\n Str=<L,U>x,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]\r\n$csTo_a12n\r\n = \\ (@ x_a12p)\r\n (@ (r_a12q :: Rep Void x_a12p))\r\n (x_aZ8 :: Sing r_a12q) >\r\n case x_aZ8\r\n `cast` ((Sing\r\n (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R ; D:R:SingV1z0[0]\r\n <x_a12p>_N <r_a12q>_N\r\n :: (Sing r_a12q :: *) ~R# (R:SingV1z x_a12p r_a12q :: *))\r\n of nt_s13T {\r\n }\r\n}}}\r\n\r\nGHC 8.0.2 does not appear to suffer from this Core Lint error.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15557Reduce type families in equations' RHS when testing equation compatibility20190707T18:04:08ZmniipReduce type families in equations' RHS when testing equation compatibilityThe reference I found for closed type families with compatible equations is: https://www.microsoft.com/enus/research/wpcontent/uploads/2016/07/popl137eisenberg.pdf
There in Definition 8 in section 3.4 it states:
Definition 8 (Compatibility implementation). The test for compatibility, written compat(p, q), checks that unify(lhsp, lhsq) = Ω implies Ω(rhsp) = Ω(rhsq). If unify(lhsp, lhsq) fails, compat(p, q) holds vacuously.
Examine the following families:
```hs
type family If (a :: Bool) (b :: k) (c :: k) :: k where
If False a b = b
If True a b = a
type family Eql (a :: k) (b :: k) :: Bool where
Eql a a = True
Eql _ _ = False
type family Test (a :: Maybe k) (b :: Maybe k) :: Maybe k where
Test (Just x) (Just y) = If (Eql x y) (Just x) Nothing
Test a a = a
Test Nothing _ = Nothing
Test _ Nothing = Nothing
```
Applying the check to the equations 1 and 2 of `Test` we get:
unify(\<`Just x`, `Just y`\>, \<`a`, `a`\>) = Ω = \[`a` \> `Just x`, `y` \> `x`\]
Ω(`a`) = `Just x` = `If (Eql x x) (Just x) Nothing` = Ω(`If (Eql x y) (Just x) Nothing`)
Therefore the equations must be compatible, and when tidying `forall a. p a > p (Test a a)` the application should reduce to `forall a. p a > p a`
That doesn't happen:
```hs
> :t undefined :: p a > p (Test a a)
p a > p (Test a a)
```
Examining the IfaceAxBranches (cf #15546) we see:
```hs
axiom D:R:Test::
Test a ('Just x) ('Just y) = If (Eql x y) ('Just x) 'Nothing
Test k a a = a
(incompatible indices: [0])
Test k 'Nothing _ = 'Nothing
Test k _ 'Nothing = 'Nothing
```
GHC did not consider the two equations compatible.
Digging into why, I came across this ticket: #8423, in which a potentially unbounded (and indefinite) number of type family reductions was necessary to evidence Ω(rhsp) = Ω(rhsq). I don't claim to fully understand goldfire's [ticket:8423\#comment:80951](https://gitlab.haskell.org//ghc/ghc/issues/8423#note_80951), but the issue is clear: reducing type families while doing a compartibility check might depend on other compatibility checks already being done, including a check depending on itself in which case we are interested in the biggest fixed point (why?).
The family here doesn't require any of that special consideration because `Eql x x` reduces right away without any compatibility checks, and `If` is essentially open (indeed making `If` open doesn't help anything).
This brings the question: is something like goldfire's described algorithm (or a simplification thereof) something we would like to have in GHC or is that too complex? What is the status on the implementation of that algorithm?
P.S: An interesting workaround is adding an `If t c c = c` equation (compatible), and then writing `Test` as:
```hs
type family Test (a :: Maybe k) (b :: Maybe k) :: Maybe k where
Test (Just x) (Just y) = If (Eql (Just x) (Just y)) (Just x) Nothing
Test a a = If (Eql a a) a Nothing
Test Nothing a = If (Eql Nothing a) Nothing Nothing
Test a Nothing = If (Eql a Nothing) Nothing Nothing
```
This lets GHC discover the necessary equalities without reducing type families, yet erase the workaround'ed type family applications immediately.
P.P.S: In [ticket:15546\#comment:158797](https://gitlab.haskell.org//ghc/ghc/issues/15546#note_158797) I mixed up left and right, it's the RHS that should be/are not reduced. This probably confused SPJ a lot.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  FeatureRequest 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  goldfire, simonpj 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Reduce type families in equations' RHS when testing equation compatibility","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":["goldfire","simonpj"],"type":"FeatureRequest","description":"The reference I found for closed type families with compatible equations is: https://www.microsoft.com/enus/research/wpcontent/uploads/2016/07/popl137eisenberg.pdf\r\n\r\nThere in Definition 8 in section 3.4 it states:\r\n\r\nDefinition 8 (Compatibility implementation). The test for compatibility, written compat(p, q), checks that unify(lhsp, lhsq) = Ω implies Ω(rhsp) = Ω(rhsq). If unify(lhsp, lhsq) fails, compat(p, q) holds vacuously.\r\n\r\nExamine the following families:\r\n\r\n{{{#!hs\r\ntype family If (a :: Bool) (b :: k) (c :: k) :: k where\r\n If False a b = b\r\n If True a b = a\r\n\r\ntype family Eql (a :: k) (b :: k) :: Bool where\r\n Eql a a = True\r\n Eql _ _ = False\r\n\r\ntype family Test (a :: Maybe k) (b :: Maybe k) :: Maybe k where\r\n Test (Just x) (Just y) = If (Eql x y) (Just x) Nothing\r\n Test a a = a\r\n Test Nothing _ = Nothing\r\n Test _ Nothing = Nothing\r\n}}}\r\n\r\nApplying the check to the equations 1 and 2 of `Test` we get:\r\n\r\nunify(<`Just x`, `Just y`>, <`a`, `a`>) = Ω = [`a` > `Just x`, `y` > `x`]\r\n\r\nΩ(`a`) = `Just x` = `If (Eql x x) (Just x) Nothing` = Ω(`If (Eql x y) (Just x) Nothing`)\r\n\r\nTherefore the equations must be compatible, and when tidying `forall a. p a > p (Test a a)` the application should reduce to `forall a. p a > p a`\r\n\r\nThat doesn't happen:\r\n{{{#!hs\r\n> :t undefined :: p a > p (Test a a)\r\np a > p (Test a a)\r\n}}}\r\n\r\nExamining the IfaceAxBranches (cf #15546) we see:\r\n{{{#!hs\r\n axiom D:R:Test::\r\n Test a ('Just x) ('Just y) = If (Eql x y) ('Just x) 'Nothing\r\n Test k a a = a\r\n (incompatible indices: [0])\r\n Test k 'Nothing _ = 'Nothing\r\n Test k _ 'Nothing = 'Nothing\r\n}}}\r\n\r\nGHC did not consider the two equations compatible.\r\n\r\nDigging into why, I came across this ticket: #8423, in which a potentially unbounded (and indefinite) number of type family reductions was necessary to evidence Ω(rhsp) = Ω(rhsq). I don't claim to fully understand goldfire's ticket:8423#comment:10, but the issue is clear: reducing type families while doing a compartibility check might depend on other compatibility checks already being done, including a check depending on itself in which case we are interested in the biggest fixed point (why?).\r\n\r\nThe family here doesn't require any of that special consideration because `Eql x x` reduces right away without any compatibility checks, and `If` is essentially open (indeed making `If` open doesn't help anything).\r\n\r\nThis brings the question: is something like goldfire's described algorithm (or a simplification thereof) something we would like to have in GHC or is that too complex? What is the status on the implementation of that algorithm?\r\n\r\nP.S: An interesting workaround is adding an `If t c c = c` equation (compatible), and then writing `Test` as:\r\n{{{#!hs\r\ntype family Test (a :: Maybe k) (b :: Maybe k) :: Maybe k where\r\n Test (Just x) (Just y) = If (Eql (Just x) (Just y)) (Just x) Nothing\r\n Test a a = If (Eql a a) a Nothing\r\n Test Nothing a = If (Eql Nothing a) Nothing Nothing\r\n Test a Nothing = If (Eql a Nothing) Nothing Nothing\r\n}}}\r\n\r\nThis lets GHC discover the necessary equalities without reducing type families, yet erase the workaround'ed type family applications immediately.\r\n\r\nP.P.S: In ticket:15546#comment:4 I mixed up left and right, it's the RHS that should be/are not reduced. This probably confused SPJ a lot.","type_of_failure":"OtherFailure","blocking":[]} >The reference I found for closed type families with compatible equations is: https://www.microsoft.com/enus/research/wpcontent/uploads/2016/07/popl137eisenberg.pdf
There in Definition 8 in section 3.4 it states:
Definition 8 (Compatibility implementation). The test for compatibility, written compat(p, q), checks that unify(lhsp, lhsq) = Ω implies Ω(rhsp) = Ω(rhsq). If unify(lhsp, lhsq) fails, compat(p, q) holds vacuously.
Examine the following families:
```hs
type family If (a :: Bool) (b :: k) (c :: k) :: k where
If False a b = b
If True a b = a
type family Eql (a :: k) (b :: k) :: Bool where
Eql a a = True
Eql _ _ = False
type family Test (a :: Maybe k) (b :: Maybe k) :: Maybe k where
Test (Just x) (Just y) = If (Eql x y) (Just x) Nothing
Test a a = a
Test Nothing _ = Nothing
Test _ Nothing = Nothing
```
Applying the check to the equations 1 and 2 of `Test` we get:
unify(\<`Just x`, `Just y`\>, \<`a`, `a`\>) = Ω = \[`a` \> `Just x`, `y` \> `x`\]
Ω(`a`) = `Just x` = `If (Eql x x) (Just x) Nothing` = Ω(`If (Eql x y) (Just x) Nothing`)
Therefore the equations must be compatible, and when tidying `forall a. p a > p (Test a a)` the application should reduce to `forall a. p a > p a`
That doesn't happen:
```hs
> :t undefined :: p a > p (Test a a)
p a > p (Test a a)
```
Examining the IfaceAxBranches (cf #15546) we see:
```hs
axiom D:R:Test::
Test a ('Just x) ('Just y) = If (Eql x y) ('Just x) 'Nothing
Test k a a = a
(incompatible indices: [0])
Test k 'Nothing _ = 'Nothing
Test k _ 'Nothing = 'Nothing
```
GHC did not consider the two equations compatible.
Digging into why, I came across this ticket: #8423, in which a potentially unbounded (and indefinite) number of type family reductions was necessary to evidence Ω(rhsp) = Ω(rhsq). I don't claim to fully understand goldfire's [ticket:8423\#comment:80951](https://gitlab.haskell.org//ghc/ghc/issues/8423#note_80951), but the issue is clear: reducing type families while doing a compartibility check might depend on other compatibility checks already being done, including a check depending on itself in which case we are interested in the biggest fixed point (why?).
The family here doesn't require any of that special consideration because `Eql x x` reduces right away without any compatibility checks, and `If` is essentially open (indeed making `If` open doesn't help anything).
This brings the question: is something like goldfire's described algorithm (or a simplification thereof) something we would like to have in GHC or is that too complex? What is the status on the implementation of that algorithm?
P.S: An interesting workaround is adding an `If t c c = c` equation (compatible), and then writing `Test` as:
```hs
type family Test (a :: Maybe k) (b :: Maybe k) :: Maybe k where
Test (Just x) (Just y) = If (Eql (Just x) (Just y)) (Just x) Nothing
Test a a = If (Eql a a) a Nothing
Test Nothing a = If (Eql Nothing a) Nothing Nothing
Test a Nothing = If (Eql a Nothing) Nothing Nothing
```
This lets GHC discover the necessary equalities without reducing type families, yet erase the workaround'ed type family applications immediately.
P.P.S: In [ticket:15546\#comment:158797](https://gitlab.haskell.org//ghc/ghc/issues/15546#note_158797) I mixed up left and right, it's the RHS that should be/are not reduced. This probably confused SPJ a lot.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  FeatureRequest 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  goldfire, simonpj 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Reduce type families in equations' RHS when testing equation compatibility","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":["goldfire","simonpj"],"type":"FeatureRequest","description":"The reference I found for closed type families with compatible equations is: https://www.microsoft.com/enus/research/wpcontent/uploads/2016/07/popl137eisenberg.pdf\r\n\r\nThere in Definition 8 in section 3.4 it states:\r\n\r\nDefinition 8 (Compatibility implementation). The test for compatibility, written compat(p, q), checks that unify(lhsp, lhsq) = Ω implies Ω(rhsp) = Ω(rhsq). If unify(lhsp, lhsq) fails, compat(p, q) holds vacuously.\r\n\r\nExamine the following families:\r\n\r\n{{{#!hs\r\ntype family If (a :: Bool) (b :: k) (c :: k) :: k where\r\n If False a b = b\r\n If True a b = a\r\n\r\ntype family Eql (a :: k) (b :: k) :: Bool where\r\n Eql a a = True\r\n Eql _ _ = False\r\n\r\ntype family Test (a :: Maybe k) (b :: Maybe k) :: Maybe k where\r\n Test (Just x) (Just y) = If (Eql x y) (Just x) Nothing\r\n Test a a = a\r\n Test Nothing _ = Nothing\r\n Test _ Nothing = Nothing\r\n}}}\r\n\r\nApplying the check to the equations 1 and 2 of `Test` we get:\r\n\r\nunify(<`Just x`, `Just y`>, <`a`, `a`>) = Ω = [`a` > `Just x`, `y` > `x`]\r\n\r\nΩ(`a`) = `Just x` = `If (Eql x x) (Just x) Nothing` = Ω(`If (Eql x y) (Just x) Nothing`)\r\n\r\nTherefore the equations must be compatible, and when tidying `forall a. p a > p (Test a a)` the application should reduce to `forall a. p a > p a`\r\n\r\nThat doesn't happen:\r\n{{{#!hs\r\n> :t undefined :: p a > p (Test a a)\r\np a > p (Test a a)\r\n}}}\r\n\r\nExamining the IfaceAxBranches (cf #15546) we see:\r\n{{{#!hs\r\n axiom D:R:Test::\r\n Test a ('Just x) ('Just y) = If (Eql x y) ('Just x) 'Nothing\r\n Test k a a = a\r\n (incompatible indices: [0])\r\n Test k 'Nothing _ = 'Nothing\r\n Test k _ 'Nothing = 'Nothing\r\n}}}\r\n\r\nGHC did not consider the two equations compatible.\r\n\r\nDigging into why, I came across this ticket: #8423, in which a potentially unbounded (and indefinite) number of type family reductions was necessary to evidence Ω(rhsp) = Ω(rhsq). I don't claim to fully understand goldfire's ticket:8423#comment:10, but the issue is clear: reducing type families while doing a compartibility check might depend on other compatibility checks already being done, including a check depending on itself in which case we are interested in the biggest fixed point (why?).\r\n\r\nThe family here doesn't require any of that special consideration because `Eql x x` reduces right away without any compatibility checks, and `If` is essentially open (indeed making `If` open doesn't help anything).\r\n\r\nThis brings the question: is something like goldfire's described algorithm (or a simplification thereof) something we would like to have in GHC or is that too complex? What is the status on the implementation of that algorithm?\r\n\r\nP.S: An interesting workaround is adding an `If t c c = c` equation (compatible), and then writing `Test` as:\r\n{{{#!hs\r\ntype family Test (a :: Maybe k) (b :: Maybe k) :: Maybe k where\r\n Test (Just x) (Just y) = If (Eql (Just x) (Just y)) (Just x) Nothing\r\n Test a a = If (Eql a a) a Nothing\r\n Test Nothing a = If (Eql Nothing a) Nothing Nothing\r\n Test a Nothing = If (Eql a Nothing) Nothing Nothing\r\n}}}\r\n\r\nThis lets GHC discover the necessary equalities without reducing type families, yet erase the workaround'ed type family applications immediately.\r\n\r\nP.P.S: In ticket:15546#comment:4 I mixed up left and right, it's the RHS that should be/are not reduced. This probably confused SPJ a lot.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15577TypeApplicationsrelated infinite loop (GHC 8.6+ only)20190830T12:55:21ZRyan ScottTypeApplicationsrelated infinite loop (GHC 8.6+ only)The following program will loop infinitely when compiled on GHC 8.6 or HEAD:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality
data family Sing :: forall k. k > Type
class Generic1 (f :: k > Type) where
type Rep1 f :: k > Type
class PGeneric1 (f :: k > Type) where
type From1 (z :: f a) :: Rep1 f a
type To1 (z :: Rep1 f a) :: f a
class SGeneric1 (f :: k > Type) where
sFrom1 :: forall (a :: k) (z :: f a). Sing z > Sing (From1 z)
sTo1 :: forall (a :: k) (r :: Rep1 f a). Sing r > Sing (To1 r :: f a)
class (PGeneric1 f, SGeneric1 f) => VGeneric1 (f :: k > Type) where
sTof1 :: forall (a :: k) (z :: f a). Sing z > To1 (From1 z) :~: z
sFot1 :: forall (a :: k) (r :: Rep1 f a). Sing r > From1 (To1 r :: f a) :~: r
foo :: forall (f :: Type > Type) (a :: Type) (r :: Rep1 f a).
VGeneric1 f
=> Sing r > From1 (To1 r :: f a) :~: r
foo x
 Refl < sFot1  Uncommenting the line below makes it work again:
 @Type
@f @a @r x
= Refl
```
This is a regression from GHC 8.4, since compiling this program with 8.4 simply errors:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:35:20: error:
• Expecting one more argument to ‘f’
Expected a type, but ‘f’ has kind ‘* > *’
• In the type ‘f’
In a stmt of a pattern guard for
an equation for ‘foo’:
Refl < sFot1 @f @a @r x
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl

35  @f @a @r x
 ^
Bug.hs:35:23: error:
• Expected kind ‘f1 > *’, but ‘a’ has kind ‘*’
• In the type ‘a’
In a stmt of a pattern guard for
an equation for ‘foo’:
Refl < sFot1 @f @a @r x
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl
• Relevant bindings include
x :: Sing r1 (bound at Bug.hs:32:5)
foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)

35  @f @a @r x
 ^
Bug.hs:35:26: error:
• Couldn't match kind ‘* > *’ with ‘*’
When matching kinds
f1 :: * > *
Rep1 f1 a1 :: *
Expected kind ‘f1’, but ‘r’ has kind ‘Rep1 f1 a1’
• In the type ‘r’
In a stmt of a pattern guard for
an equation for ‘foo’:
Refl < sFot1 @f @a @r x
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl
• Relevant bindings include
x :: Sing r1 (bound at Bug.hs:32:5)
foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)

35  @f @a @r x
 ^
Bug.hs:35:28: error:
• Couldn't match kind ‘*’ with ‘GHC.Types.RuntimeRep’
When matching kinds
a1 :: *
'GHC.Types.LiftedRep :: GHC.Types.RuntimeRep
• In the fourth argument of ‘sFot1’, namely ‘x’
In a stmt of a pattern guard for
an equation for ‘foo’:
Refl < sFot1 @f @a @r x
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl
• Relevant bindings include
x :: Sing r1 (bound at Bug.hs:32:5)
foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)

35  @f @a @r x
 ^
Bug.hs:36:5: error:
• Could not deduce: From1 (To1 r1) ~ r1
from the context: r0 ~ From1 (To1 r0)
bound by a pattern with constructor:
Refl :: forall k (a :: k). a :~: a,
in a pattern binding in
pattern guard for
an equation for ‘foo’
at Bug.hs:33:58
‘r1’ is a rigid type variable bound by
the type signature for:
foo :: forall (f1 :: * > *) a1 (r1 :: Rep1 f1 a1).
VGeneric1 f1 =>
Sing r1 > From1 (To1 r1) :~: r1
at Bug.hs:(29,1)(31,43)
Expected type: From1 (To1 r1) :~: r1
Actual type: r1 :~: r1
• In the expression: Refl
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl
• Relevant bindings include
x :: Sing r1 (bound at Bug.hs:32:5)
foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)

36  = Refl
 ^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"TypeApplicationsrelated infinite loop (GHC 8.6+ only)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeApplications,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program will loop infinitely when compiled on GHC 8.6 or HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\ndata family Sing :: forall k. k > Type\r\n\r\nclass Generic1 (f :: k > Type) where\r\n type Rep1 f :: k > Type\r\n\r\nclass PGeneric1 (f :: k > Type) where\r\n type From1 (z :: f a) :: Rep1 f a\r\n type To1 (z :: Rep1 f a) :: f a\r\n\r\nclass SGeneric1 (f :: k > Type) where\r\n sFrom1 :: forall (a :: k) (z :: f a). Sing z > Sing (From1 z)\r\n sTo1 :: forall (a :: k) (r :: Rep1 f a). Sing r > Sing (To1 r :: f a)\r\n\r\nclass (PGeneric1 f, SGeneric1 f) => VGeneric1 (f :: k > Type) where\r\n sTof1 :: forall (a :: k) (z :: f a). Sing z > To1 (From1 z) :~: z\r\n sFot1 :: forall (a :: k) (r :: Rep1 f a). Sing r > From1 (To1 r :: f a) :~: r\r\n\r\nfoo :: forall (f :: Type > Type) (a :: Type) (r :: Rep1 f a).\r\n VGeneric1 f\r\n => Sing r > From1 (To1 r :: f a) :~: r\r\nfoo x\r\n  Refl < sFot1  Uncommenting the line below makes it work again:\r\n  @Type\r\n @f @a @r x\r\n = Refl\r\n}}}\r\n\r\nThis is a regression from GHC 8.4, since compiling this program with 8.4 simply errors:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:35:20: error:\r\n • Expecting one more argument to ‘f’\r\n Expected a type, but ‘f’ has kind ‘* > *’\r\n • In the type ‘f’\r\n In a stmt of a pattern guard for\r\n an equation for ‘foo’:\r\n Refl < sFot1 @f @a @r x\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n \r\n35  @f @a @r x\r\n  ^\r\n\r\nBug.hs:35:23: error:\r\n • Expected kind ‘f1 > *’, but ‘a’ has kind ‘*’\r\n • In the type ‘a’\r\n In a stmt of a pattern guard for\r\n an equation for ‘foo’:\r\n Refl < sFot1 @f @a @r x\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n • Relevant bindings include\r\n x :: Sing r1 (bound at Bug.hs:32:5)\r\n foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)\r\n \r\n35  @f @a @r x\r\n  ^\r\n\r\nBug.hs:35:26: error:\r\n • Couldn't match kind ‘* > *’ with ‘*’\r\n When matching kinds\r\n f1 :: * > *\r\n Rep1 f1 a1 :: *\r\n Expected kind ‘f1’, but ‘r’ has kind ‘Rep1 f1 a1’\r\n • In the type ‘r’\r\n In a stmt of a pattern guard for\r\n an equation for ‘foo’:\r\n Refl < sFot1 @f @a @r x\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n • Relevant bindings include\r\n x :: Sing r1 (bound at Bug.hs:32:5)\r\n foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)\r\n \r\n35  @f @a @r x\r\n  ^\r\n\r\nBug.hs:35:28: error:\r\n • Couldn't match kind ‘*’ with ‘GHC.Types.RuntimeRep’\r\n When matching kinds\r\n a1 :: *\r\n 'GHC.Types.LiftedRep :: GHC.Types.RuntimeRep\r\n • In the fourth argument of ‘sFot1’, namely ‘x’\r\n In a stmt of a pattern guard for\r\n an equation for ‘foo’:\r\n Refl < sFot1 @f @a @r x\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n • Relevant bindings include\r\n x :: Sing r1 (bound at Bug.hs:32:5)\r\n foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)\r\n \r\n35  @f @a @r x\r\n  ^\r\n\r\nBug.hs:36:5: error:\r\n • Could not deduce: From1 (To1 r1) ~ r1\r\n from the context: r0 ~ From1 (To1 r0)\r\n bound by a pattern with constructor:\r\n Refl :: forall k (a :: k). a :~: a,\r\n in a pattern binding in\r\n pattern guard for\r\n an equation for ‘foo’\r\n at Bug.hs:33:58\r\n ‘r1’ is a rigid type variable bound by\r\n the type signature for:\r\n foo :: forall (f1 :: * > *) a1 (r1 :: Rep1 f1 a1).\r\n VGeneric1 f1 =>\r\n Sing r1 > From1 (To1 r1) :~: r1\r\n at Bug.hs:(29,1)(31,43)\r\n Expected type: From1 (To1 r1) :~: r1\r\n Actual type: r1 :~: r1\r\n • In the expression: Refl\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n • Relevant bindings include\r\n x :: Sing r1 (bound at Bug.hs:32:5)\r\n foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)\r\n \r\n36  = Refl\r\n  ^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program will loop infinitely when compiled on GHC 8.6 or HEAD:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
import Data.Type.Equality
data family Sing :: forall k. k > Type
class Generic1 (f :: k > Type) where
type Rep1 f :: k > Type
class PGeneric1 (f :: k > Type) where
type From1 (z :: f a) :: Rep1 f a
type To1 (z :: Rep1 f a) :: f a
class SGeneric1 (f :: k > Type) where
sFrom1 :: forall (a :: k) (z :: f a). Sing z > Sing (From1 z)
sTo1 :: forall (a :: k) (r :: Rep1 f a). Sing r > Sing (To1 r :: f a)
class (PGeneric1 f, SGeneric1 f) => VGeneric1 (f :: k > Type) where
sTof1 :: forall (a :: k) (z :: f a). Sing z > To1 (From1 z) :~: z
sFot1 :: forall (a :: k) (r :: Rep1 f a). Sing r > From1 (To1 r :: f a) :~: r
foo :: forall (f :: Type > Type) (a :: Type) (r :: Rep1 f a).
VGeneric1 f
=> Sing r > From1 (To1 r :: f a) :~: r
foo x
 Refl < sFot1  Uncommenting the line below makes it work again:
 @Type
@f @a @r x
= Refl
```
This is a regression from GHC 8.4, since compiling this program with 8.4 simply errors:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:35:20: error:
• Expecting one more argument to ‘f’
Expected a type, but ‘f’ has kind ‘* > *’
• In the type ‘f’
In a stmt of a pattern guard for
an equation for ‘foo’:
Refl < sFot1 @f @a @r x
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl

35  @f @a @r x
 ^
Bug.hs:35:23: error:
• Expected kind ‘f1 > *’, but ‘a’ has kind ‘*’
• In the type ‘a’
In a stmt of a pattern guard for
an equation for ‘foo’:
Refl < sFot1 @f @a @r x
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl
• Relevant bindings include
x :: Sing r1 (bound at Bug.hs:32:5)
foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)

35  @f @a @r x
 ^
Bug.hs:35:26: error:
• Couldn't match kind ‘* > *’ with ‘*’
When matching kinds
f1 :: * > *
Rep1 f1 a1 :: *
Expected kind ‘f1’, but ‘r’ has kind ‘Rep1 f1 a1’
• In the type ‘r’
In a stmt of a pattern guard for
an equation for ‘foo’:
Refl < sFot1 @f @a @r x
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl
• Relevant bindings include
x :: Sing r1 (bound at Bug.hs:32:5)
foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)

35  @f @a @r x
 ^
Bug.hs:35:28: error:
• Couldn't match kind ‘*’ with ‘GHC.Types.RuntimeRep’
When matching kinds
a1 :: *
'GHC.Types.LiftedRep :: GHC.Types.RuntimeRep
• In the fourth argument of ‘sFot1’, namely ‘x’
In a stmt of a pattern guard for
an equation for ‘foo’:
Refl < sFot1 @f @a @r x
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl
• Relevant bindings include
x :: Sing r1 (bound at Bug.hs:32:5)
foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)

35  @f @a @r x
 ^
Bug.hs:36:5: error:
• Could not deduce: From1 (To1 r1) ~ r1
from the context: r0 ~ From1 (To1 r0)
bound by a pattern with constructor:
Refl :: forall k (a :: k). a :~: a,
in a pattern binding in
pattern guard for
an equation for ‘foo’
at Bug.hs:33:58
‘r1’ is a rigid type variable bound by
the type signature for:
foo :: forall (f1 :: * > *) a1 (r1 :: Rep1 f1 a1).
VGeneric1 f1 =>
Sing r1 > From1 (To1 r1) :~: r1
at Bug.hs:(29,1)(31,43)
Expected type: From1 (To1 r1) :~: r1
Actual type: r1 :~: r1
• In the expression: Refl
In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl
• Relevant bindings include
x :: Sing r1 (bound at Bug.hs:32:5)
foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)

36  = Refl
 ^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"TypeApplicationsrelated infinite loop (GHC 8.6+ only)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":["TypeApplications,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program will loop infinitely when compiled on GHC 8.6 or HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Type.Equality\r\n\r\ndata family Sing :: forall k. k > Type\r\n\r\nclass Generic1 (f :: k > Type) where\r\n type Rep1 f :: k > Type\r\n\r\nclass PGeneric1 (f :: k > Type) where\r\n type From1 (z :: f a) :: Rep1 f a\r\n type To1 (z :: Rep1 f a) :: f a\r\n\r\nclass SGeneric1 (f :: k > Type) where\r\n sFrom1 :: forall (a :: k) (z :: f a). Sing z > Sing (From1 z)\r\n sTo1 :: forall (a :: k) (r :: Rep1 f a). Sing r > Sing (To1 r :: f a)\r\n\r\nclass (PGeneric1 f, SGeneric1 f) => VGeneric1 (f :: k > Type) where\r\n sTof1 :: forall (a :: k) (z :: f a). Sing z > To1 (From1 z) :~: z\r\n sFot1 :: forall (a :: k) (r :: Rep1 f a). Sing r > From1 (To1 r :: f a) :~: r\r\n\r\nfoo :: forall (f :: Type > Type) (a :: Type) (r :: Rep1 f a).\r\n VGeneric1 f\r\n => Sing r > From1 (To1 r :: f a) :~: r\r\nfoo x\r\n  Refl < sFot1  Uncommenting the line below makes it work again:\r\n  @Type\r\n @f @a @r x\r\n = Refl\r\n}}}\r\n\r\nThis is a regression from GHC 8.4, since compiling this program with 8.4 simply errors:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:35:20: error:\r\n • Expecting one more argument to ‘f’\r\n Expected a type, but ‘f’ has kind ‘* > *’\r\n • In the type ‘f’\r\n In a stmt of a pattern guard for\r\n an equation for ‘foo’:\r\n Refl < sFot1 @f @a @r x\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n \r\n35  @f @a @r x\r\n  ^\r\n\r\nBug.hs:35:23: error:\r\n • Expected kind ‘f1 > *’, but ‘a’ has kind ‘*’\r\n • In the type ‘a’\r\n In a stmt of a pattern guard for\r\n an equation for ‘foo’:\r\n Refl < sFot1 @f @a @r x\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n • Relevant bindings include\r\n x :: Sing r1 (bound at Bug.hs:32:5)\r\n foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)\r\n \r\n35  @f @a @r x\r\n  ^\r\n\r\nBug.hs:35:26: error:\r\n • Couldn't match kind ‘* > *’ with ‘*’\r\n When matching kinds\r\n f1 :: * > *\r\n Rep1 f1 a1 :: *\r\n Expected kind ‘f1’, but ‘r’ has kind ‘Rep1 f1 a1’\r\n • In the type ‘r’\r\n In a stmt of a pattern guard for\r\n an equation for ‘foo’:\r\n Refl < sFot1 @f @a @r x\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n • Relevant bindings include\r\n x :: Sing r1 (bound at Bug.hs:32:5)\r\n foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)\r\n \r\n35  @f @a @r x\r\n  ^\r\n\r\nBug.hs:35:28: error:\r\n • Couldn't match kind ‘*’ with ‘GHC.Types.RuntimeRep’\r\n When matching kinds\r\n a1 :: *\r\n 'GHC.Types.LiftedRep :: GHC.Types.RuntimeRep\r\n • In the fourth argument of ‘sFot1’, namely ‘x’\r\n In a stmt of a pattern guard for\r\n an equation for ‘foo’:\r\n Refl < sFot1 @f @a @r x\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n • Relevant bindings include\r\n x :: Sing r1 (bound at Bug.hs:32:5)\r\n foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)\r\n \r\n35  @f @a @r x\r\n  ^\r\n\r\nBug.hs:36:5: error:\r\n • Could not deduce: From1 (To1 r1) ~ r1\r\n from the context: r0 ~ From1 (To1 r0)\r\n bound by a pattern with constructor:\r\n Refl :: forall k (a :: k). a :~: a,\r\n in a pattern binding in\r\n pattern guard for\r\n an equation for ‘foo’\r\n at Bug.hs:33:58\r\n ‘r1’ is a rigid type variable bound by\r\n the type signature for:\r\n foo :: forall (f1 :: * > *) a1 (r1 :: Rep1 f1 a1).\r\n VGeneric1 f1 =>\r\n Sing r1 > From1 (To1 r1) :~: r1\r\n at Bug.hs:(29,1)(31,43)\r\n Expected type: From1 (To1 r1) :~: r1\r\n Actual type: r1 :~: r1\r\n • In the expression: Refl\r\n In an equation for ‘foo’: foo x  Refl < sFot1 @f @a @r x = Refl\r\n • Relevant bindings include\r\n x :: Sing r1 (bound at Bug.hs:32:5)\r\n foo :: Sing r1 > From1 (To1 r1) :~: r1 (bound at Bug.hs:32:1)\r\n \r\n36  = Refl\r\n  ^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.8.2Alp MestanogullariBen GamariAlp Mestanogullarihttps://gitlab.haskell.org/ghc/ghc//issues/15596When a type application cannot be applied to an identifier due to the absence...20210125T16:37:52ZkindaroWhen a type application cannot be applied to an identifier due to the absence of an explicit type signature, let the error just say so!Consider this code:
```hs
{# language TypeApplications #}
module TypeApplicationsErrorMessage where
f = (+)
g = f @Integer
```
This is what happens when I try to compile it:
```hs
% ghc TypeApplicationsErrorMessage.hs
[1 of 1] Compiling TypeApplicationsErrorMessage ( TypeApplicationsErrorMessage.hs, TypeApplicationsErrorMessage.o )
TypeApplicationsErrorMessage.hs:6:5: error:
• Cannot apply expression of type ‘a0 > a0 > a0’
to a visible type argument ‘Integer’
• In the expression: f @Integer
In an equation for ‘g’: g = f @Integer

6  g = f @Integer
 ^^^^^^^^^^
```
This error is easily fixed by supplying an explicit type signature to `f`. So, perhaps the error message could just say so?
I am observing this with `The Glorious Glasgow Haskell Compilation System, version 8.6.0.20180810`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  
 Type  FeatureRequest 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"When a type application cannot be applied to an identifier due to the absence of an explicit type signature, let the error just say so!","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"Consider this code:\r\n\r\n{{{#!hs\r\n{# language TypeApplications #}\r\n\r\nmodule TypeApplicationsErrorMessage where\r\n\r\nf = (+)\r\ng = f @Integer\r\n}}}\r\n\r\nThis is what happens when I try to compile it:\r\n\r\n{{{#!hs\r\n% ghc TypeApplicationsErrorMessage.hs\r\n[1 of 1] Compiling TypeApplicationsErrorMessage ( TypeApplicationsErrorMessage.hs, TypeApplicationsErrorMessage.o )\r\n\r\nTypeApplicationsErrorMessage.hs:6:5: error:\r\n • Cannot apply expression of type ‘a0 > a0 > a0’\r\n to a visible type argument ‘Integer’\r\n • In the expression: f @Integer\r\n In an equation for ‘g’: g = f @Integer\r\n \r\n6  g = f @Integer\r\n  ^^^^^^^^^^\r\n}}}\r\n\r\nThis error is easily fixed by supplying an explicit type signature to `f`. So, perhaps the error message could just say so?\r\n\r\nI am observing this with `The Glorious Glasgow Haskell Compilation System, version 8.6.0.20180810`.","type_of_failure":"OtherFailure","blocking":[]} >Consider this code:
```hs
{# language TypeApplications #}
module TypeApplicationsErrorMessage where
f = (+)
g = f @Integer
```
This is what happens when I try to compile it:
```hs
% ghc TypeApplicationsErrorMessage.hs
[1 of 1] Compiling TypeApplicationsErrorMessage ( TypeApplicationsErrorMessage.hs, TypeApplicationsErrorMessage.o )
TypeApplicationsErrorMessage.hs:6:5: error:
• Cannot apply expression of type ‘a0 > a0 > a0’
to a visible type argument ‘Integer’
• In the expression: f @Integer
In an equation for ‘g’: g = f @Integer

6  g = f @Integer
 ^^^^^^^^^^
```
This error is easily fixed by supplying an explicit type signature to `f`. So, perhaps the error message could just say so?
I am observing this with `The Glorious Glasgow Haskell Compilation System, version 8.6.0.20180810`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  
 Type  FeatureRequest 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"When a type application cannot be applied to an identifier due to the absence of an explicit type signature, let the error just say so!","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"Consider this code:\r\n\r\n{{{#!hs\r\n{# language TypeApplications #}\r\n\r\nmodule TypeApplicationsErrorMessage where\r\n\r\nf = (+)\r\ng = f @Integer\r\n}}}\r\n\r\nThis is what happens when I try to compile it:\r\n\r\n{{{#!hs\r\n% ghc TypeApplicationsErrorMessage.hs\r\n[1 of 1] Compiling TypeApplicationsErrorMessage ( TypeApplicationsErrorMessage.hs, TypeApplicationsErrorMessage.o )\r\n\r\nTypeApplicationsErrorMessage.hs:6:5: error:\r\n • Cannot apply expression of type ‘a0 > a0 > a0’\r\n to a visible type argument ‘Integer’\r\n • In the expression: f @Integer\r\n In an equation for ‘g’: g = f @Integer\r\n \r\n6  g = f @Integer\r\n  ^^^^^^^^^^\r\n}}}\r\n\r\nThis error is easily fixed by supplying an explicit type signature to `f`. So, perhaps the error message could just say so?\r\n\r\nI am observing this with `The Glorious Glasgow Haskell Compilation System, version 8.6.0.20180810`.","type_of_failure":"OtherFailure","blocking":[]} >9.2.1https://gitlab.haskell.org/ghc/ghc//issues/15621Error message involving type families points to wrong location20210125T16:37:52ZRyan ScottError message involving type families points to wrong locationConsider the following program:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Type.Equality
type family F a
f :: ()
f =
let a :: F Int :~: F Int
a = Refl
b :: F Int :~: F Bool
b = Refl
in ()
```
This doesn't typecheck, which isn't surprising, since `F Int` doesn't equal `F Bool` in the definition of `b`. What //is// surprising is where the error message points to:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:12:11: error:
• Couldn't match type ‘F Int’ with ‘F Bool’
Expected type: F Int :~: F Int
Actual type: F Bool :~: F Bool
NB: ‘F’ is a noninjective type family
• In the expression: Refl
In an equation for ‘a’: a = Refl
In the expression:
let
a :: F Int :~: F Int
a = Refl
b :: F Int :~: F Bool
....
in ()

12  a = Refl
 ^^^^
```
This claims that the error message arises from the definition of `a`, which is completely wrong! As evidence, if you comment out `b`, then the program typechecks again.
Another interesting facet of this bug is that if you comment out `a`:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Type.Equality
type family F a
f :: ()
f =
let { a :: F Int :~: F Int
a = Refl }
b :: F Int :~: F Bool
b = Refl
in ()
```
Then the error message will actually point to `b` this time:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:11: error:
• Couldn't match type ‘F Int’ with ‘F Bool’
Expected type: F Int :~: F Bool
Actual type: F Bool :~: F Bool
NB: ‘F’ is a noninjective type family
• In the expression: Refl
In an equation for ‘b’: b = Refl
In the expression:
let
b :: F Int :~: F Bool
b = Refl
in ()

15  b = Refl
 ^^^^
```
The use of type families appears to be important to triggering this bug, since I can't observe this behavior without the use of `F`.
This is a regression that was introduced at some point between GHC 8.0.2 and 8.2.2, since 8.2.2 gives the incorrect error message shown above, while 8.0.2 points to the right location:
```
$ /opt/ghc/8.0.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:11: error:
• Couldn't match type ‘F Int’ with ‘F Bool’
Expected type: F Int :~: F Bool
Actual type: F Int :~: F Int
NB: ‘F’ is a type function, and may not be injective
• In the expression: Refl
In an equation for ‘b’: b = Refl
In the expression:
let
a :: F Int :~: F Int
a = Refl
b :: F Int :~: F Bool
....
in ()
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Error message involving type families points to wrong location","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Type.Equality\r\n\r\ntype family F a\r\n\r\nf :: ()\r\nf =\r\n let a :: F Int :~: F Int\r\n a = Refl\r\n\r\n b :: F Int :~: F Bool\r\n b = Refl\r\n in ()\r\n}}}\r\n\r\nThis doesn't typecheck, which isn't surprising, since `F Int` doesn't equal `F Bool` in the definition of `b`. What //is// surprising is where the error message points to:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:12:11: error:\r\n • Couldn't match type ‘F Int’ with ‘F Bool’\r\n Expected type: F Int :~: F Int\r\n Actual type: F Bool :~: F Bool\r\n NB: ‘F’ is a noninjective type family\r\n • In the expression: Refl\r\n In an equation for ‘a’: a = Refl\r\n In the expression:\r\n let\r\n a :: F Int :~: F Int\r\n a = Refl\r\n b :: F Int :~: F Bool\r\n ....\r\n in ()\r\n \r\n12  a = Refl\r\n  ^^^^\r\n}}}\r\n\r\nThis claims that the error message arises from the definition of `a`, which is completely wrong! As evidence, if you comment out `b`, then the program typechecks again.\r\n\r\nAnother interesting facet of this bug is that if you comment out `a`:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Type.Equality\r\n\r\ntype family F a\r\n\r\nf :: ()\r\nf =\r\n let { a :: F Int :~: F Int\r\n a = Refl }\r\n\r\n b :: F Int :~: F Bool\r\n b = Refl\r\n in ()\r\n}}}\r\n\r\nThen the error message will actually point to `b` this time:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:11: error:\r\n • Couldn't match type ‘F Int’ with ‘F Bool’\r\n Expected type: F Int :~: F Bool\r\n Actual type: F Bool :~: F Bool\r\n NB: ‘F’ is a noninjective type family\r\n • In the expression: Refl\r\n In an equation for ‘b’: b = Refl\r\n In the expression:\r\n let\r\n b :: F Int :~: F Bool\r\n b = Refl\r\n in ()\r\n \r\n15  b = Refl\r\n  ^^^^\r\n}}}\r\n\r\nThe use of type families appears to be important to triggering this bug, since I can't observe this behavior without the use of `F`.\r\n\r\nThis is a regression that was introduced at some point between GHC 8.0.2 and 8.2.2, since 8.2.2 gives the incorrect error message shown above, while 8.0.2 points to the right location:\r\n\r\n{{{\r\n$ /opt/ghc/8.0.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:11: error:\r\n • Couldn't match type ‘F Int’ with ‘F Bool’\r\n Expected type: F Int :~: F Bool\r\n Actual type: F Int :~: F Int\r\n NB: ‘F’ is a type function, and may not be injective\r\n • In the expression: Refl\r\n In an equation for ‘b’: b = Refl\r\n In the expression:\r\n let\r\n a :: F Int :~: F Int\r\n a = Refl\r\n b :: F Int :~: F Bool\r\n ....\r\n in ()\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >Consider the following program:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Type.Equality
type family F a
f :: ()
f =
let a :: F Int :~: F Int
a = Refl
b :: F Int :~: F Bool
b = Refl
in ()
```
This doesn't typecheck, which isn't surprising, since `F Int` doesn't equal `F Bool` in the definition of `b`. What //is// surprising is where the error message points to:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:12:11: error:
• Couldn't match type ‘F Int’ with ‘F Bool’
Expected type: F Int :~: F Int
Actual type: F Bool :~: F Bool
NB: ‘F’ is a noninjective type family
• In the expression: Refl
In an equation for ‘a’: a = Refl
In the expression:
let
a :: F Int :~: F Int
a = Refl
b :: F Int :~: F Bool
....
in ()

12  a = Refl
 ^^^^
```
This claims that the error message arises from the definition of `a`, which is completely wrong! As evidence, if you comment out `b`, then the program typechecks again.
Another interesting facet of this bug is that if you comment out `a`:
```hs
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Type.Equality
type family F a
f :: ()
f =
let { a :: F Int :~: F Int
a = Refl }
b :: F Int :~: F Bool
b = Refl
in ()
```
Then the error message will actually point to `b` this time:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:11: error:
• Couldn't match type ‘F Int’ with ‘F Bool’
Expected type: F Int :~: F Bool
Actual type: F Bool :~: F Bool
NB: ‘F’ is a noninjective type family
• In the expression: Refl
In an equation for ‘b’: b = Refl
In the expression:
let
b :: F Int :~: F Bool
b = Refl
in ()

15  b = Refl
 ^^^^
```
The use of type families appears to be important to triggering this bug, since I can't observe this behavior without the use of `F`.
This is a regression that was introduced at some point between GHC 8.0.2 and 8.2.2, since 8.2.2 gives the incorrect error message shown above, while 8.0.2 points to the right location:
```
$ /opt/ghc/8.0.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:11: error:
• Couldn't match type ‘F Int’ with ‘F Bool’
Expected type: F Int :~: F Bool
Actual type: F Int :~: F Int
NB: ‘F’ is a type function, and may not be injective
• In the expression: Refl
In an equation for ‘b’: b = Refl
In the expression:
let
a :: F Int :~: F Int
a = Refl
b :: F Int :~: F Bool
....
in ()
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Error message involving type families points to wrong location","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Type.Equality\r\n\r\ntype family F a\r\n\r\nf :: ()\r\nf =\r\n let a :: F Int :~: F Int\r\n a = Refl\r\n\r\n b :: F Int :~: F Bool\r\n b = Refl\r\n in ()\r\n}}}\r\n\r\nThis doesn't typecheck, which isn't surprising, since `F Int` doesn't equal `F Bool` in the definition of `b`. What //is// surprising is where the error message points to:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:12:11: error:\r\n • Couldn't match type ‘F Int’ with ‘F Bool’\r\n Expected type: F Int :~: F Int\r\n Actual type: F Bool :~: F Bool\r\n NB: ‘F’ is a noninjective type family\r\n • In the expression: Refl\r\n In an equation for ‘a’: a = Refl\r\n In the expression:\r\n let\r\n a :: F Int :~: F Int\r\n a = Refl\r\n b :: F Int :~: F Bool\r\n ....\r\n in ()\r\n \r\n12  a = Refl\r\n  ^^^^\r\n}}}\r\n\r\nThis claims that the error message arises from the definition of `a`, which is completely wrong! As evidence, if you comment out `b`, then the program typechecks again.\r\n\r\nAnother interesting facet of this bug is that if you comment out `a`:\r\n\r\n{{{#!hs\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Type.Equality\r\n\r\ntype family F a\r\n\r\nf :: ()\r\nf =\r\n let { a :: F Int :~: F Int\r\n a = Refl }\r\n\r\n b :: F Int :~: F Bool\r\n b = Refl\r\n in ()\r\n}}}\r\n\r\nThen the error message will actually point to `b` this time:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:11: error:\r\n • Couldn't match type ‘F Int’ with ‘F Bool’\r\n Expected type: F Int :~: F Bool\r\n Actual type: F Bool :~: F Bool\r\n NB: ‘F’ is a noninjective type family\r\n • In the expression: Refl\r\n In an equation for ‘b’: b = Refl\r\n In the expression:\r\n let\r\n b :: F Int :~: F Bool\r\n b = Refl\r\n in ()\r\n \r\n15  b = Refl\r\n  ^^^^\r\n}}}\r\n\r\nThe use of type families appears to be important to triggering this bug, since I can't observe this behavior without the use of `F`.\r\n\r\nThis is a regression that was introduced at some point between GHC 8.0.2 and 8.2.2, since 8.2.2 gives the incorrect error message shown above, while 8.0.2 points to the right location:\r\n\r\n{{{\r\n$ /opt/ghc/8.0.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:11: error:\r\n • Couldn't match type ‘F Int’ with ‘F Bool’\r\n Expected type: F Int :~: F Bool\r\n Actual type: F Int :~: F Int\r\n NB: ‘F’ is a type function, and may not be injective\r\n • In the expression: Refl\r\n In an equation for ‘b’: b = Refl\r\n In the expression:\r\n let\r\n a :: F Int :~: F Int\r\n a = Refl\r\n b :: F Int :~: F Bool\r\n ....\r\n in ()\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >9.2.1https://gitlab.haskell.org/ghc/ghc//issues/15624defertypeerrors and equality constraints20190707T18:03:42ZKrzysztof Gogolewskidefertypeerrors and equality constraintsConsider
```
{# OPTIONS_GHC fdefertypeerrors #}
x = const True ('a' + 'a')
y = const True (not 'a')
```
Currently `x` is True, but `y` is undefined. I think it would make sense for both to be True.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  low 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"defertypeerrors and equality constraints","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider\r\n\r\n{{{\r\n{# OPTIONS_GHC fdefertypeerrors #}\r\nx = const True ('a' + 'a')\r\ny = const True (not 'a')\r\n}}}\r\n\r\nCurrently `x` is True, but `y` is undefined. I think it would make sense for both to be True.","type_of_failure":"OtherFailure","blocking":[]} >Consider
```
{# OPTIONS_GHC fdefertypeerrors #}
x = const True ('a' + 'a')
y = const True (not 'a')
```
Currently `x` is True, but `y` is undefined. I think it would make sense for both to be True.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  low 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"defertypeerrors and equality constraints","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider\r\n\r\n{{{\r\n{# OPTIONS_GHC fdefertypeerrors #}\r\nx = const True ('a' + 'a')\r\ny = const True (not 'a')\r\n}}}\r\n\r\nCurrently `x` is True, but `y` is undefined. I think it would make sense for both to be True.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15629"No skolem info" panic (GHC 8.6 only)20190707T18:03:40ZRyan Scott"No skolem info" panic (GHC 8.6 only)The following program:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind
import Data.Proxy
import GHC.Generics
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing :: forall k. k > Type
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }
singFun1 :: forall f. (forall t. Sing t > Sing (Apply f t)) > Sing f
singFun1 f = SLambda f
data From1Sym0 :: forall k (f :: k > Type) (a :: k). f a ~> Rep1 f a
data To1Sym0 :: forall k (f :: k > Type) (a :: k). Rep1 f a ~> f a
type family ((f :: b ~> c) :. (g :: a ~> b)) (x :: a) :: c where
(f :. g) x = Apply f (Apply g x)
data (.@#@$$$) :: forall b c a. (b ~> c) > (a ~> b) > (a ~> c)
type instance Apply (f .@#@$$$ g) x = (f :. g) x
(%.) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).
Sing f > Sing g > Sing x > Sing ((f :. g) x)
(sf %. sg) sx = applySing sf (applySing sg sx)
(%.$$$) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).
Sing f > Sing g > Sing (f .@#@$$$ g)
sf %.$$$ sg = singFun1 (sf %. sg)
f :: forall (m :: Type > Type) x. Proxy (m x) > ()
f _ = ()
where
sFrom1Fun :: forall ab. Sing (From1Sym0 :: m ab ~> Rep1 m ab)
sFrom1Fun = undefined
sTo1Fun :: forall ab. Sing (To1Sym0 :: Rep1 m ab ~> m ab)
sTo1Fun = undefined
sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
```
Panics on GHC 8.6:
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:50:39: error:
• Expected kind ‘m z ~> Rep1 m ab1’,
but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’
• In the first argument of ‘(.@#@$$$)’, namely
‘(From1Sym0 :: m z ~> Rep1 m z)’
In the first argument of ‘Sing’, namely
‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)’
In the type signature:
sFrom1To1Fun :: forall ab.
Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)

50  sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:51:20: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180823 for x86_64unknownlinux):
No skolem info:
[ab_a1UW[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors
```
But merely errors on GHC 8.4.3:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:50:39: error:
• Expected kind ‘m z ~> Rep1 m ab2’,
but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’
• In the first argument of ‘(.@#@$$$)’, namely
‘(From1Sym0 :: m z ~> Rep1 m z)’
In the first argument of ‘Sing’, namely
‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)’
In the type signature:
sFrom1To1Fun :: forall ab.
Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)

50  sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:51:20: error:
• Couldn't match type ‘ab1’ with ‘z1’
because type variable ‘z1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)
at Bug.hs:50:5112
Expected type: Sing From1Sym0
Actual type: Sing From1Sym0
• In the first argument of ‘(%.$$$)’, namely ‘sFrom1Fun’
In the expression: sFrom1Fun %.$$$ sTo1Fun
In an equation for ‘sFrom1To1Fun’:
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
• Relevant bindings include
sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)
(bound at Bug.hs:51:5)

51  sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
 ^^^^^^^^^
Bug.hs:51:36: error:
• Couldn't match type ‘ab’ with ‘z1’
because type variable ‘z1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)
at Bug.hs:50:5112
Expected type: Sing To1Sym0
Actual type: Sing To1Sym0
• In the second argument of ‘(%.$$$)’, namely ‘sTo1Fun’
In the expression: sFrom1Fun %.$$$ sTo1Fun
In an equation for ‘sFrom1To1Fun’:
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
• Relevant bindings include
sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)
(bound at Bug.hs:51:5)

51  sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
 ^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1beta1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"\"No skolem info\" panic (GHC 8.6 only)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1beta1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Proxy\r\nimport GHC.Generics\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\ndata family Sing :: forall k. k > Type\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }\r\nsingFun1 :: forall f. (forall t. Sing t > Sing (Apply f t)) > Sing f\r\nsingFun1 f = SLambda f\r\n\r\ndata From1Sym0 :: forall k (f :: k > Type) (a :: k). f a ~> Rep1 f a\r\ndata To1Sym0 :: forall k (f :: k > Type) (a :: k). Rep1 f a ~> f a\r\n\r\ntype family ((f :: b ~> c) :. (g :: a ~> b)) (x :: a) :: c where\r\n (f :. g) x = Apply f (Apply g x)\r\n\r\ndata (.@#@$$$) :: forall b c a. (b ~> c) > (a ~> b) > (a ~> c)\r\ntype instance Apply (f .@#@$$$ g) x = (f :. g) x\r\n\r\n(%.) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).\r\n Sing f > Sing g > Sing x > Sing ((f :. g) x)\r\n(sf %. sg) sx = applySing sf (applySing sg sx)\r\n\r\n(%.$$$) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).\r\n Sing f > Sing g > Sing (f .@#@$$$ g)\r\nsf %.$$$ sg = singFun1 (sf %. sg)\r\n\r\nf :: forall (m :: Type > Type) x. Proxy (m x) > ()\r\nf _ = ()\r\n where\r\n sFrom1Fun :: forall ab. Sing (From1Sym0 :: m ab ~> Rep1 m ab)\r\n sFrom1Fun = undefined\r\n\r\n sTo1Fun :: forall ab. Sing (To1Sym0 :: Rep1 m ab ~> m ab)\r\n sTo1Fun = undefined\r\n\r\n sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n}}}\r\n\r\nPanics on GHC 8.6:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:50:39: error:\r\n • Expected kind ‘m z ~> Rep1 m ab1’,\r\n but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’\r\n • In the first argument of ‘(.@#@$$$)’, namely\r\n ‘(From1Sym0 :: m z ~> Rep1 m z)’\r\n In the first argument of ‘Sing’, namely\r\n ‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)’\r\n In the type signature:\r\n sFrom1To1Fun :: forall ab.\r\n Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)\r\n \r\n50  sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:51:20: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180823 for x86_64unknownlinux):\r\n No skolem info:\r\n [ab_a1UW[sk:1]]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors\r\n}}}\r\n\r\nBut merely errors on GHC 8.4.3:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:50:39: error:\r\n • Expected kind ‘m z ~> Rep1 m ab2’,\r\n but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’\r\n • In the first argument of ‘(.@#@$$$)’, namely\r\n ‘(From1Sym0 :: m z ~> Rep1 m z)’\r\n In the first argument of ‘Sing’, namely\r\n ‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)’\r\n In the type signature:\r\n sFrom1To1Fun :: forall ab.\r\n Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)\r\n \r\n50  sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:51:20: error:\r\n • Couldn't match type ‘ab1’ with ‘z1’\r\n because type variable ‘z1’ would escape its scope\r\n This (rigid, skolem) type variable is bound by\r\n the type signature for:\r\n sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n at Bug.hs:50:5112\r\n Expected type: Sing From1Sym0\r\n Actual type: Sing From1Sym0\r\n • In the first argument of ‘(%.$$$)’, namely ‘sFrom1Fun’\r\n In the expression: sFrom1Fun %.$$$ sTo1Fun\r\n In an equation for ‘sFrom1To1Fun’:\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n • Relevant bindings include\r\n sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n (bound at Bug.hs:51:5)\r\n \r\n51  sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n  ^^^^^^^^^\r\n\r\nBug.hs:51:36: error:\r\n • Couldn't match type ‘ab’ with ‘z1’\r\n because type variable ‘z1’ would escape its scope\r\n This (rigid, skolem) type variable is bound by\r\n the type signature for:\r\n sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n at Bug.hs:50:5112\r\n Expected type: Sing To1Sym0\r\n Actual type: Sing To1Sym0\r\n • In the second argument of ‘(%.$$$)’, namely ‘sTo1Fun’\r\n In the expression: sFrom1Fun %.$$$ sTo1Fun\r\n In an equation for ‘sFrom1To1Fun’:\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n • Relevant bindings include\r\n sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n (bound at Bug.hs:51:5)\r\n \r\n51  sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n  ^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program:
```hs
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind
import Data.Proxy
import GHC.Generics
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing :: forall k. k > Type
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }
singFun1 :: forall f. (forall t. Sing t > Sing (Apply f t)) > Sing f
singFun1 f = SLambda f
data From1Sym0 :: forall k (f :: k > Type) (a :: k). f a ~> Rep1 f a
data To1Sym0 :: forall k (f :: k > Type) (a :: k). Rep1 f a ~> f a
type family ((f :: b ~> c) :. (g :: a ~> b)) (x :: a) :: c where
(f :. g) x = Apply f (Apply g x)
data (.@#@$$$) :: forall b c a. (b ~> c) > (a ~> b) > (a ~> c)
type instance Apply (f .@#@$$$ g) x = (f :. g) x
(%.) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).
Sing f > Sing g > Sing x > Sing ((f :. g) x)
(sf %. sg) sx = applySing sf (applySing sg sx)
(%.$$$) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).
Sing f > Sing g > Sing (f .@#@$$$ g)
sf %.$$$ sg = singFun1 (sf %. sg)
f :: forall (m :: Type > Type) x. Proxy (m x) > ()
f _ = ()
where
sFrom1Fun :: forall ab. Sing (From1Sym0 :: m ab ~> Rep1 m ab)
sFrom1Fun = undefined
sTo1Fun :: forall ab. Sing (To1Sym0 :: Rep1 m ab ~> m ab)
sTo1Fun = undefined
sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
```
Panics on GHC 8.6:
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:50:39: error:
• Expected kind ‘m z ~> Rep1 m ab1’,
but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’
• In the first argument of ‘(.@#@$$$)’, namely
‘(From1Sym0 :: m z ~> Rep1 m z)’
In the first argument of ‘Sing’, namely
‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)’
In the type signature:
sFrom1To1Fun :: forall ab.
Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)

50  sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:51:20: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180823 for x86_64unknownlinux):
No skolem info:
[ab_a1UW[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors
```
But merely errors on GHC 8.4.3:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:50:39: error:
• Expected kind ‘m z ~> Rep1 m ab2’,
but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’
• In the first argument of ‘(.@#@$$$)’, namely
‘(From1Sym0 :: m z ~> Rep1 m z)’
In the first argument of ‘Sing’, namely
‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)’
In the type signature:
sFrom1To1Fun :: forall ab.
Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)

50  sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:51:20: error:
• Couldn't match type ‘ab1’ with ‘z1’
because type variable ‘z1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)
at Bug.hs:50:5112
Expected type: Sing From1Sym0
Actual type: Sing From1Sym0
• In the first argument of ‘(%.$$$)’, namely ‘sFrom1Fun’
In the expression: sFrom1Fun %.$$$ sTo1Fun
In an equation for ‘sFrom1To1Fun’:
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
• Relevant bindings include
sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)
(bound at Bug.hs:51:5)

51  sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
 ^^^^^^^^^
Bug.hs:51:36: error:
• Couldn't match type ‘ab’ with ‘z1’
because type variable ‘z1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)
at Bug.hs:50:5112
Expected type: Sing To1Sym0
Actual type: Sing To1Sym0
• In the second argument of ‘(%.$$$)’, namely ‘sTo1Fun’
In the expression: sFrom1Fun %.$$$ sTo1Fun
In an equation for ‘sFrom1To1Fun’:
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
• Relevant bindings include
sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)
(bound at Bug.hs:51:5)

51  sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
 ^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1beta1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"\"No skolem info\" panic (GHC 8.6 only)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1beta1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Proxy\r\nimport GHC.Generics\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\ndata family Sing :: forall k. k > Type\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t > Sing (Apply f t) }\r\nsingFun1 :: forall f. (forall t. Sing t > Sing (Apply f t)) > Sing f\r\nsingFun1 f = SLambda f\r\n\r\ndata From1Sym0 :: forall k (f :: k > Type) (a :: k). f a ~> Rep1 f a\r\ndata To1Sym0 :: forall k (f :: k > Type) (a :: k). Rep1 f a ~> f a\r\n\r\ntype family ((f :: b ~> c) :. (g :: a ~> b)) (x :: a) :: c where\r\n (f :. g) x = Apply f (Apply g x)\r\n\r\ndata (.@#@$$$) :: forall b c a. (b ~> c) > (a ~> b) > (a ~> c)\r\ntype instance Apply (f .@#@$$$ g) x = (f :. g) x\r\n\r\n(%.) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).\r\n Sing f > Sing g > Sing x > Sing ((f :. g) x)\r\n(sf %. sg) sx = applySing sf (applySing sg sx)\r\n\r\n(%.$$$) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).\r\n Sing f > Sing g > Sing (f .@#@$$$ g)\r\nsf %.$$$ sg = singFun1 (sf %. sg)\r\n\r\nf :: forall (m :: Type > Type) x. Proxy (m x) > ()\r\nf _ = ()\r\n where\r\n sFrom1Fun :: forall ab. Sing (From1Sym0 :: m ab ~> Rep1 m ab)\r\n sFrom1Fun = undefined\r\n\r\n sTo1Fun :: forall ab. Sing (To1Sym0 :: Rep1 m ab ~> m ab)\r\n sTo1Fun = undefined\r\n\r\n sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n}}}\r\n\r\nPanics on GHC 8.6:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:50:39: error:\r\n • Expected kind ‘m z ~> Rep1 m ab1’,\r\n but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’\r\n • In the first argument of ‘(.@#@$$$)’, namely\r\n ‘(From1Sym0 :: m z ~> Rep1 m z)’\r\n In the first argument of ‘Sing’, namely\r\n ‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)’\r\n In the type signature:\r\n sFrom1To1Fun :: forall ab.\r\n Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)\r\n \r\n50  sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:51:20: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180823 for x86_64unknownlinux):\r\n No skolem info:\r\n [ab_a1UW[sk:1]]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors\r\n}}}\r\n\r\nBut merely errors on GHC 8.4.3:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:50:39: error:\r\n • Expected kind ‘m z ~> Rep1 m ab2’,\r\n but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’\r\n • In the first argument of ‘(.@#@$$$)’, namely\r\n ‘(From1Sym0 :: m z ~> Rep1 m z)’\r\n In the first argument of ‘Sing’, namely\r\n ‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)’\r\n In the type signature:\r\n sFrom1To1Fun :: forall ab.\r\n Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)\r\n \r\n50  sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:51:20: error:\r\n • Couldn't match type ‘ab1’ with ‘z1’\r\n because type variable ‘z1’ would escape its scope\r\n This (rigid, skolem) type variable is bound by\r\n the type signature for:\r\n sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n at Bug.hs:50:5112\r\n Expected type: Sing From1Sym0\r\n Actual type: Sing From1Sym0\r\n • In the first argument of ‘(%.$$$)’, namely ‘sFrom1Fun’\r\n In the expression: sFrom1Fun %.$$$ sTo1Fun\r\n In an equation for ‘sFrom1To1Fun’:\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n • Relevant bindings include\r\n sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n (bound at Bug.hs:51:5)\r\n \r\n51  sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n  ^^^^^^^^^\r\n\r\nBug.hs:51:36: error:\r\n • Couldn't match type ‘ab’ with ‘z1’\r\n because type variable ‘z1’ would escape its scope\r\n This (rigid, skolem) type variable is bound by\r\n the type signature for:\r\n sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n at Bug.hs:50:5112\r\n Expected type: Sing To1Sym0\r\n Actual type: Sing To1Sym0\r\n • In the second argument of ‘(%.$$$)’, namely ‘sTo1Fun’\r\n In the expression: sFrom1Fun %.$$$ sTo1Fun\r\n In an equation for ‘sFrom1To1Fun’:\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n • Relevant bindings include\r\n sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n (bound at Bug.hs:51:5)\r\n \r\n51  sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n  ^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15639Surprising failure combining QuantifiedConstraints with Coercible20190707T18:03:38ZDavid FeuerSurprising failure combining QuantifiedConstraints with CoercibleI don't understand what's going wrong here.
```hs
 Fishy.hs
{# language RankNTypes, QuantifiedConstraints, RoleAnnotations #}
module Fishy (Yeah, yeahCoercible) where
import Data.Coerce
data Yeah_ a = Yeah_ Int
newtype Yeah a = Yeah (Yeah_ a)
type role Yeah representational
yeahCoercible :: ((forall a b. Coercible (Yeah a) (Yeah b)) => r) > r
yeahCoercible r = r
 Fishy2.hs
module Fishy2 where
import Fishy
import Data.Type.Coercion
import Data.Coerce
yeah :: Coercion [Yeah a] [Yeah b]
yeah = yeahCoercible Coercion
```
I get
```
Fishy2.hs:8:22: error:
• Couldn't match representation of type ‘a’ with that of ‘b’
arising from a use of ‘Coercion’
‘a’ is a rigid type variable bound by
the type signature for:
yeah :: forall a b. Coercion [Yeah a] [Yeah b]
at Fishy2.hs:7:134
‘b’ is a rigid type variable bound by
the type signature for:
yeah :: forall a b. Coercion [Yeah a] [Yeah b]
at Fishy2.hs:7:134
• In the first argument of ‘yeahCoercible’, namely ‘Coercion’
In the expression: yeahCoercible Coercion
In an equation for ‘yeah’: yeah = yeahCoercible Coercion
• Relevant bindings include
yeah :: Coercion [Yeah a] [Yeah b] (bound at Fishy2.hs:8:1)

8  yeah = yeahCoercible Coercion

```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Surprising failure combining QuantifiedConstraints with Coercible","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I don't understand what's going wrong here.\r\n\r\n{{{#!hs\r\n Fishy.hs\r\n{# language RankNTypes, QuantifiedConstraints, RoleAnnotations #}\r\nmodule Fishy (Yeah, yeahCoercible) where\r\nimport Data.Coerce\r\n\r\ndata Yeah_ a = Yeah_ Int\r\nnewtype Yeah a = Yeah (Yeah_ a)\r\ntype role Yeah representational\r\n\r\nyeahCoercible :: ((forall a b. Coercible (Yeah a) (Yeah b)) => r) > r\r\nyeahCoercible r = r\r\n\r\n\r\n Fishy2.hs\r\n\r\nmodule Fishy2 where\r\n\r\nimport Fishy\r\nimport Data.Type.Coercion\r\nimport Data.Coerce\r\n\r\nyeah :: Coercion [Yeah a] [Yeah b]\r\nyeah = yeahCoercible Coercion\r\n}}}\r\n\r\nI get\r\n\r\n{{{\r\nFishy2.hs:8:22: error:\r\n • Couldn't match representation of type ‘a’ with that of ‘b’\r\n arising from a use of ‘Coercion’\r\n ‘a’ is a rigid type variable bound by\r\n the type signature for:\r\n yeah :: forall a b. Coercion [Yeah a] [Yeah b]\r\n at Fishy2.hs:7:134\r\n ‘b’ is a rigid type variable bound by\r\n the type signature for:\r\n yeah :: forall a b. Coercion [Yeah a] [Yeah b]\r\n at Fishy2.hs:7:134\r\n • In the first argument of ‘yeahCoercible’, namely ‘Coercion’\r\n In the expression: yeahCoercible Coercion\r\n In an equation for ‘yeah’: yeah = yeahCoercible Coercion\r\n • Relevant bindings include\r\n yeah :: Coercion [Yeah a] [Yeah b] (bound at Fishy2.hs:8:1)\r\n \r\n8  yeah = yeahCoercible Coercion\r\n \r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >I don't understand what's going wrong here.
```hs
 Fishy.hs
{# language RankNTypes, QuantifiedConstraints, RoleAnnotations #}
module Fishy (Yeah, yeahCoercible) where
import Data.Coerce
data Yeah_ a = Yeah_ Int
newtype Yeah a = Yeah (Yeah_ a)
type role Yeah representational
yeahCoercible :: ((forall a b. Coercible (Yeah a) (Yeah b)) => r) > r
yeahCoercible r = r
 Fishy2.hs
module Fishy2 where
import Fishy
import Data.Type.Coercion
import Data.Coerce
yeah :: Coercion [Yeah a] [Yeah b]
yeah = yeahCoercible Coercion
```
I get
```
Fishy2.hs:8:22: error:
• Couldn't match representation of type ‘a’ with that of ‘b’
arising from a use of ‘Coercion’
‘a’ is a rigid type variable bound by
the type signature for:
yeah :: forall a b. Coercion [Yeah a] [Yeah b]
at Fishy2.hs:7:134
‘b’ is a rigid type variable bound by
the type signature for:
yeah :: forall a b. Coercion [Yeah a] [Yeah b]
at Fishy2.hs:7:134
• In the first argument of ‘yeahCoercible’, namely ‘Coercion’
In the expression: yeahCoercible Coercion
In an equation for ‘yeah’: yeah = yeahCoercible Coercion
• Relevant bindings include
yeah :: Coercion [Yeah a] [Yeah b] (bound at Fishy2.hs:8:1)

8  yeah = yeahCoercible Coercion

```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Surprising failure combining QuantifiedConstraints with Coercible","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I don't understand what's going wrong here.\r\n\r\n{{{#!hs\r\n Fishy.hs\r\n{# language RankNTypes, QuantifiedConstraints, RoleAnnotations #}\r\nmodule Fishy (Yeah, yeahCoercible) where\r\nimport Data.Coerce\r\n\r\ndata Yeah_ a = Yeah_ Int\r\nnewtype Yeah a = Yeah (Yeah_ a)\r\ntype role Yeah representational\r\n\r\nyeahCoercible :: ((forall a b. Coercible (Yeah a) (Yeah b)) => r) > r\r\nyeahCoercible r = r\r\n\r\n\r\n Fishy2.hs\r\n\r\nmodule Fishy2 where\r\n\r\nimport Fishy\r\nimport Data.Type.Coercion\r\nimport Data.Coerce\r\n\r\nyeah :: Coercion [Yeah a] [Yeah b]\r\nyeah = yeahCoercible Coercion\r\n}}}\r\n\r\nI get\r\n\r\n{{{\r\nFishy2.hs:8:22: error:\r\n • Couldn't match representation of type ‘a’ with that of ‘b’\r\n arising from a use of ‘Coercion’\r\n ‘a’ is a rigid type variable bound by\r\n the type signature for:\r\n yeah :: forall a b. Coercion [Yeah a] [Yeah b]\r\n at Fishy2.hs:7:134\r\n ‘b’ is a rigid type variable bound by\r\n the type signature for:\r\n yeah :: forall a b. Coercion [Yeah a] [Yeah b]\r\n at Fishy2.hs:7:134\r\n • In the first argument of ‘yeahCoercible’, namely ‘Coercion’\r\n In the expression: yeahCoercible Coercion\r\n In an equation for ‘yeah’: yeah = yeahCoercible Coercion\r\n • Relevant bindings include\r\n yeah :: Coercion [Yeah a] [Yeah b] (bound at Fishy2.hs:8:1)\r\n \r\n8  yeah = yeahCoercible Coercion\r\n \r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15678Provide the provenance of unification variables in error messages when possible20210125T16:36:44ZRyan ScottProvide the provenance of unification variables in error messages when possibleConsider the following code:
```hs
module Foo where
x :: Int
x = const 42 _
```
When compiles, this gives the following suggestion:
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Foo ( Bug.hs, Bug.o )
Bug.hs:4:14: error:
• Found hole: _ :: b0
Where: ‘b0’ is an ambiguous type variable
• In the second argument of ‘const’, namely ‘_’
In the expression: const 42 _
In an equation for ‘x’: x = const 42 _
• Relevant bindings include x :: Int (bound at Bug.hs:4:1)
Valid hole fits include
x :: Int (bound at Bug.hs:4:1)
otherwise :: Bool
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘GHC.Base’))
False :: Bool
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘GHC.Types’))
True :: Bool
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘GHC.Types’))
lines :: String > [String]
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘base4.12.0.0:Data.OldList’))
unlines :: [String] > String
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘base4.12.0.0:Data.OldList’))
(Some hole fits suppressed; use fmaxvalidholefits=N or fnomaxvalidholefits)

4  x = const 42 _
 ^
```
One thing that's rather ugly about this is the use of the type `b0`. What exactly //is// `b0` anyway? The only hint that the error message gives is that it's an ambiguous type variable. But that's not terribly helpful to figure out where `b0` arises from. Ambiguous type variables like this one arise quite frequently when writing Haskell code, and it can often take some sleuthing to figure out why they pop up.
simonpj had one suggestion for making ambiguous type variables less confusing: report their provenance whenever possible. There is one notable example of a situation where it's simple to explain from where exactly in the source code a unification variable originates: function applications. In particular, the program above applies the function `const 42` to `_`, which means that the type of `const 42` is instantiated to be `b0 > Int`. Let's report this! Something like:
```
• Found hole: _ :: b0
Where: ‘b0’ is an ambiguous type variable
Arising from an application of
(const 42 :: b0 > Int)
In the expression: const 42 _
```
This would go a long way to clearing up what GHC is thinking when it reports these ambiguous type variable errors. While we can't easily report the provenance of //every// ambiguous type variables, those arising from function applications are quite doable. We might be able to reuse the `CtOrigin` machinery (or take heavy inspiration from it) to accomplish this feat.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  Tritlo 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Provide the provenance of unification variables in error messages when possible","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":["TypeErrors"],"differentials":[],"test_case":"","architecture":"","cc":["Tritlo"],"type":"Bug","description":"Consider the following code:\r\n\r\n{{{#!hs\r\nmodule Foo where\r\n\r\nx :: Int\r\nx = const 42 _\r\n}}}\r\n\r\nWhen compiles, this gives the following suggestion:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Foo ( Bug.hs, Bug.o )\r\n\r\nBug.hs:4:14: error:\r\n • Found hole: _ :: b0\r\n Where: ‘b0’ is an ambiguous type variable\r\n • In the second argument of ‘const’, namely ‘_’\r\n In the expression: const 42 _\r\n In an equation for ‘x’: x = const 42 _\r\n • Relevant bindings include x :: Int (bound at Bug.hs:4:1)\r\n Valid hole fits include\r\n x :: Int (bound at Bug.hs:4:1)\r\n otherwise :: Bool\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘GHC.Base’))\r\n False :: Bool\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘GHC.Types’))\r\n True :: Bool\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘GHC.Types’))\r\n lines :: String > [String]\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘base4.12.0.0:Data.OldList’))\r\n unlines :: [String] > String\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘base4.12.0.0:Data.OldList’))\r\n (Some hole fits suppressed; use fmaxvalidholefits=N or fnomaxvalidholefits)\r\n \r\n4  x = const 42 _\r\n  ^\r\n}}}\r\n\r\nOne thing that's rather ugly about this is the use of the type `b0`. What exactly //is// `b0` anyway? The only hint that the error message gives is that it's an ambiguous type variable. But that's not terribly helpful to figure out where `b0` arises from. Ambiguous type variables like this one arise quite frequently when writing Haskell code, and it can often take some sleuthing to figure out why they pop up.\r\n\r\nsimonpj had one suggestion for making ambiguous type variables less confusing: report their provenance whenever possible. There is one notable example of a situation where it's simple to explain from where exactly in the source code a unification variable originates: function applications. In particular, the program above applies the function `const 42` to `_`, which means that the type of `const 42` is instantiated to be `b0 > Int`. Let's report this! Something like:\r\n\r\n{{{\r\n • Found hole: _ :: b0\r\n Where: ‘b0’ is an ambiguous type variable\r\n Arising from an application of\r\n (const 42 :: b0 > Int)\r\n In the expression: const 42 _\r\n}}}\r\n\r\nThis would go a long way to clearing up what GHC is thinking when it reports these ambiguous type variable errors. While we can't easily report the provenance of //every// ambiguous type variables, those arising from function applications are quite doable. We might be able to reuse the `CtOrigin` machinery (or take heavy inspiration from it) to accomplish this feat.","type_of_failure":"OtherFailure","blocking":[]} >Consider the following code:
```hs
module Foo where
x :: Int
x = const 42 _
```
When compiles, this gives the following suggestion:
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Foo ( Bug.hs, Bug.o )
Bug.hs:4:14: error:
• Found hole: _ :: b0
Where: ‘b0’ is an ambiguous type variable
• In the second argument of ‘const’, namely ‘_’
In the expression: const 42 _
In an equation for ‘x’: x = const 42 _
• Relevant bindings include x :: Int (bound at Bug.hs:4:1)
Valid hole fits include
x :: Int (bound at Bug.hs:4:1)
otherwise :: Bool
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘GHC.Base’))
False :: Bool
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘GHC.Types’))
True :: Bool
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘GHC.Types’))
lines :: String > [String]
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘base4.12.0.0:Data.OldList’))
unlines :: [String] > String
(imported from ‘Prelude’ at Bug.hs:1:810
(and originally defined in ‘base4.12.0.0:Data.OldList’))
(Some hole fits suppressed; use fmaxvalidholefits=N or fnomaxvalidholefits)

4  x = const 42 _
 ^
```
One thing that's rather ugly about this is the use of the type `b0`. What exactly //is// `b0` anyway? The only hint that the error message gives is that it's an ambiguous type variable. But that's not terribly helpful to figure out where `b0` arises from. Ambiguous type variables like this one arise quite frequently when writing Haskell code, and it can often take some sleuthing to figure out why they pop up.
simonpj had one suggestion for making ambiguous type variables less confusing: report their provenance whenever possible. There is one notable example of a situation where it's simple to explain from where exactly in the source code a unification variable originates: function applications. In particular, the program above applies the function `const 42` to `_`, which means that the type of `const 42` is instantiated to be `b0 > Int`. Let's report this! Something like:
```
• Found hole: _ :: b0
Where: ‘b0’ is an ambiguous type variable
Arising from an application of
(const 42 :: b0 > Int)
In the expression: const 42 _
```
This would go a long way to clearing up what GHC is thinking when it reports these ambiguous type variable errors. While we can't easily report the provenance of //every// ambiguous type variables, those arising from function applications are quite doable. We might be able to reuse the `CtOrigin` machinery (or take heavy inspiration from it) to accomplish this feat.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  Tritlo 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Provide the provenance of unification variables in error messages when possible","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":["TypeErrors"],"differentials":[],"test_case":"","architecture":"","cc":["Tritlo"],"type":"Bug","description":"Consider the following code:\r\n\r\n{{{#!hs\r\nmodule Foo where\r\n\r\nx :: Int\r\nx = const 42 _\r\n}}}\r\n\r\nWhen compiles, this gives the following suggestion:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Foo ( Bug.hs, Bug.o )\r\n\r\nBug.hs:4:14: error:\r\n • Found hole: _ :: b0\r\n Where: ‘b0’ is an ambiguous type variable\r\n • In the second argument of ‘const’, namely ‘_’\r\n In the expression: const 42 _\r\n In an equation for ‘x’: x = const 42 _\r\n • Relevant bindings include x :: Int (bound at Bug.hs:4:1)\r\n Valid hole fits include\r\n x :: Int (bound at Bug.hs:4:1)\r\n otherwise :: Bool\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘GHC.Base’))\r\n False :: Bool\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘GHC.Types’))\r\n True :: Bool\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘GHC.Types’))\r\n lines :: String > [String]\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘base4.12.0.0:Data.OldList’))\r\n unlines :: [String] > String\r\n (imported from ‘Prelude’ at Bug.hs:1:810\r\n (and originally defined in ‘base4.12.0.0:Data.OldList’))\r\n (Some hole fits suppressed; use fmaxvalidholefits=N or fnomaxvalidholefits)\r\n \r\n4  x = const 42 _\r\n  ^\r\n}}}\r\n\r\nOne thing that's rather ugly about this is the use of the type `b0`. What exactly //is// `b0` anyway? The only hint that the error message gives is that it's an ambiguous type variable. But that's not terribly helpful to figure out where `b0` arises from. Ambiguous type variables like this one arise quite frequently when writing Haskell code, and it can often take some sleuthing to figure out why they pop up.\r\n\r\nsimonpj had one suggestion for making ambiguous type variables less confusing: report their provenance whenever possible. There is one notable example of a situation where it's simple to explain from where exactly in the source code a unification variable originates: function applications. In particular, the program above applies the function `const 42` to `_`, which means that the type of `const 42` is instantiated to be `b0 > Int`. Let's report this! Something like:\r\n\r\n{{{\r\n • Found hole: _ :: b0\r\n Where: ‘b0’ is an ambiguous type variable\r\n Arising from an application of\r\n (const 42 :: b0 > Int)\r\n In the expression: const 42 _\r\n}}}\r\n\r\nThis would go a long way to clearing up what GHC is thinking when it reports these ambiguous type variable errors. While we can't easily report the provenance of //every// ambiguous type variables, those arising from function applications are quite doable. We might be able to reuse the `CtOrigin` machinery (or take heavy inspiration from it) to accomplish this feat.","type_of_failure":"OtherFailure","blocking":[]} >9.2.1Matthías Páll GissurarsonMatthías Páll Gissurarsonhttps://gitlab.haskell.org/ghc/ghc//issues/15691Marking Pred(S n) = n as injective20190707T18:03:26ZIcelandjackMarking Pred(S n) = n as injectiveShould `Pred` be injective? Please close the ticket if this is a known limitation
```hs
{# Language DataKinds, TypeFamilyDependencies #}
data N = O  S N
type family
Pred n = res  res > n where
Pred(S n) = n
```
fails with
```
• Type family equation violates injectivity annotation.
RHS of injective type family equation is a bare type variable
but these LHS type and kind patterns are not bare variables: ‘'S n’
Pred ('S n) = n  Defined at 462.hs:7:2
• In the equations for closed type family ‘Pred’
In the type family declaration for ‘Pred’

7  Pred(S n) = n
 ^^^^^^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Marking Pred(S n) = n as injective","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":["InjectiveFamilies","TypeFamilies,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Should `Pred` be injective? Please close the ticket if this is a known limitation \r\n\r\n{{{#!hs\r\n{# Language DataKinds, TypeFamilyDependencies #}\r\n\r\ndata N = O  S N\r\n\r\ntype family\r\n Pred n = res  res > n where\r\n Pred(S n) = n\r\n}}}\r\n\r\nfails with\r\n\r\n{{{\r\n • Type family equation violates injectivity annotation.\r\n RHS of injective type family equation is a bare type variable\r\n but these LHS type and kind patterns are not bare variables: ‘'S n’\r\n Pred ('S n) = n  Defined at 462.hs:7:2\r\n • In the equations for closed type family ‘Pred’\r\n In the type family declaration for ‘Pred’\r\n \r\n7  Pred(S n) = n\r\n  ^^^^^^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >Should `Pred` be injective? Please close the ticket if this is a known limitation
```hs
{# Language DataKinds, TypeFamilyDependencies #}
data N = O  S N
type family
Pred n = res  res > n where
Pred(S n) = n
```
fails with
```
• Type family equation violates injectivity annotation.
RHS of injective type family equation is a bare type variable
but these LHS type and kind patterns are not bare variables: ‘'S n’
Pred ('S n) = n  Defined at 462.hs:7:2
• In the equations for closed type family ‘Pred’
In the type family declaration for ‘Pred’

7  Pred(S n) = n
 ^^^^^^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Marking Pred(S n) = n as injective","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":["InjectiveFamilies","TypeFamilies,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Should `Pred` be injective? Please close the ticket if this is a known limitation \r\n\r\n{{{#!hs\r\n{# Language DataKinds, TypeFamilyDependencies #}\r\n\r\ndata N = O  S N\r\n\r\ntype family\r\n Pred n = res  res > n where\r\n Pred(S n) = n\r\n}}}\r\n\r\nfails with\r\n\r\n{{{\r\n • Type family equation violates injectivity annotation.\r\n RHS of injective type family equation is a bare type variable\r\n but these LHS type and kind patterns are not bare variables: ‘'S n’\r\n Pred ('S n) = n  Defined at 462.hs:7:2\r\n • In the equations for closed type family ‘Pred’\r\n In the type family declaration for ‘Pred’\r\n \r\n7  Pred(S n) = n\r\n  ^^^^^^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15704Different saturations of the same polymorphickinded type constructor aren't ...20190707T18:03:22ZmniipDifferent saturations of the same polymorphickinded type constructor aren't seen as apart types```hs
{# LANGUAGE TypeFamilies, PolyKinds #}
module A where
data family D :: k
type family F (a :: k) :: *
type instance F (D Int) = Int
type instance F (f a b) = Char
type instance F (D Int Bool) = Char
```
The last equation, even though a specialization of the middle one, trips up the equality consistency check:
```hs
a.hs:9:15: error:
Conflicting family instance declarations:
F (D Int) = Int  Defined at a.hs:9:15
F (D Int Bool) = Char  Defined at a.hs:10:15

9  type instance F (D Int) = Int
 ^
```
So GHC is able to infer that `D Int ~/~ f a b` because `D ~/~ f a`, but for some reason the same reasoning doesn't work for `D ~/~ D a`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Different saturations of the same polymorphickinded type constructor aren't seen as apart types","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{# LANGUAGE TypeFamilies, PolyKinds #}\r\n\r\nmodule A where\r\n\r\ndata family D :: k\r\n\r\ntype family F (a :: k) :: *\r\n\r\ntype instance F (D Int) = Int\r\ntype instance F (f a b) = Char\r\ntype instance F (D Int Bool) = Char\r\n}}}\r\n\r\nThe last equation, even though a specialization of the middle one, trips up the equality consistency check:\r\n{{{#!hs\r\na.hs:9:15: error:\r\n Conflicting family instance declarations:\r\n F (D Int) = Int  Defined at a.hs:9:15\r\n F (D Int Bool) = Char  Defined at a.hs:10:15\r\n \r\n9  type instance F (D Int) = Int\r\n  ^\r\n}}}\r\n\r\nSo GHC is able to infer that `D Int ~/~ f a b` because `D ~/~ f a`, but for some reason the same reasoning doesn't work for `D ~/~ D a`.","type_of_failure":"OtherFailure","blocking":[]} >```hs
{# LANGUAGE TypeFamilies, PolyKinds #}
module A where
data family D :: k
type family F (a :: k) :: *
type instance F (D Int) = Int
type instance F (f a b) = Char
type instance F (D Int Bool) = Char
```
The last equation, even though a specialization of the middle one, trips up the equality consistency check:
```hs
a.hs:9:15: error:
Conflicting family instance declarations:
F (D Int) = Int  Defined at a.hs:9:15
F (D Int Bool) = Char  Defined at a.hs:10:15

9  type instance F (D Int) = Int
 ^
```
So GHC is able to infer that `D Int ~/~ f a b` because `D ~/~ f a`, but for some reason the same reasoning doesn't work for `D ~/~ D a`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Different saturations of the same polymorphickinded type constructor aren't seen as apart types","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":["TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{# LANGUAGE TypeFamilies, PolyKinds #}\r\n\r\nmodule A where\r\n\r\ndata family D :: k\r\n\r\ntype family F (a :: k) :: *\r\n\r\ntype instance F (D Int) = Int\r\ntype instance F (f a b) = Char\r\ntype instance F (D Int Bool) = Char\r\n}}}\r\n\r\nThe last equation, even though a specialization of the middle one, trips up the equality consistency check:\r\n{{{#!hs\r\na.hs:9:15: error:\r\n Conflicting family instance declarations:\r\n F (D Int) = Int  Defined at a.hs:9:15\r\n F (D Int Bool) = Char  Defined at a.hs:10:15\r\n \r\n9  type instance F (D Int) = Int\r\n  ^\r\n}}}\r\n\r\nSo GHC is able to infer that `D Int ~/~ f a b` because `D ~/~ f a`, but for some reason the same reasoning doesn't work for `D ~/~ D a`.","type_of_failure":"OtherFailure","blocking":[]} >8.6.1mniipmniiphttps://gitlab.haskell.org/ghc/ghc//issues/15707More liberally kinded coercions for newtypes20190707T18:03:21ZmniipMore liberally kinded coercions for newtypesConsider the infinite data family (possible thanks to #12369):
```hs
data family I :: k > k
newtype instance I a = I0 (a)
newtype instance I a x = I1 (a x)
newtype instance I a x y = I2 (a x y)
newtype instance I a x y z = I3 (a x y z)
...
```
We end up with a family of etacontracted coercions:
```hs
forall (a :: *). a ~R I a
forall (a :: k > *). a ~R I a
forall (a :: k > l > *). a ~R I a
forall (a :: k > l > m > *). a ~R I a
...
```
What if we could somehow indicate that we desire a polykinded newtype (so to speak) with a coercion `forall (a :: k). a ~R I a`
Maybe even do so by default: `newtype I a = I0 a` would create such a polykinded coercion. Though the `I0` data constructor and pattern would still only use the \*kinded restriction of it.
We could then recover other constructors with:
```hs
i1 :: a x > I a x
i1 = coerce
...
```Consider the infinite data family (possible thanks to #12369):
```hs
data family I :: k > k
newtype instance I a = I0 (a)
newtype instance I a x = I1 (a x)
newtype instance I a x y = I2 (a x y)
newtype instance I a x y z = I3 (a x y z)
...
```
We end up with a family of etacontracted coercions:
```hs
forall (a :: *). a ~R I a
forall (a :: k > *). a ~R I a
forall (a :: k > l > *). a ~R I a
forall (a :: k > l > m > *). a ~R I a
...
```
What if we could somehow indicate that we desire a polykinded newtype (so to speak) with a coercion `forall (a :: k). a ~R I a`
Maybe even do so by default: `newtype I a = I0 a` would create such a polykinded coercion. Though the `I0` data constructor and pattern would still only use the \*kinded restriction of it.
We could then recover other constructors with:
```hs
i1 :: a x > I a x
i1 = coerce
...
```8.6.1https://gitlab.haskell.org/ghc/ghc//issues/15708Crossmodule SPECIALZE pragmas aren't typechecked in O020190707T18:03:21ZregnatCrossmodule SPECIALZE pragmas aren't typechecked in O0If a module defines a `SPECIALIZE` pragma for a value defined in another module, then the signature of this pragma won't be typecheck by `ghc O0` (but it will be if the `SPECIALIZE` pragma is in the same module as the value).
For example, given
```hs
 Foo.hs
module Foo where
foo :: a > a
foo = id

 Bar.hs
module Bar where
import Foo
{# SPECIALIZE foo :: Int > Bool #}
```
running `ghc make Bar.hs` will run fine, while `ghc make O2 Bar.hs` will complain:
```
Bar.hs:5:1: error:
• Couldn't match type ‘Bool’ with ‘Int’
Expected type: Int > Int
Actual type: Int > Bool
• In the SPECIALISE pragma {# SPECIALIZE foo :: Int > Bool #}

5  {# SPECIALIZE foo :: Int > Bool #}
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Tested on ghc 8.6.1 and 8.4.3
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Crossmodule SPECIALZE pragmas aren't typechecked in O0","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If a module defines a `SPECIALIZE` pragma for a value defined in another module, then the signature of this pragma won't be typecheck by `ghc O0` (but it will be if the `SPECIALIZE` pragma is in the same module as the value).\r\n\r\nFor example, given\r\n\r\n{{{#!hs\r\n Foo.hs\r\nmodule Foo where\r\n\r\nfoo :: a > a\r\nfoo = id\r\n\r\n\r\n\r\n Bar.hs\r\nmodule Bar where\r\n\r\nimport Foo\r\n\r\n{# SPECIALIZE foo :: Int > Bool #}\r\n}}}\r\n\r\nrunning `ghc make Bar.hs` will run fine, while `ghc make O2 Bar.hs` will complain:\r\n\r\n{{{\r\nBar.hs:5:1: error:\r\n • Couldn't match type ‘Bool’ with ‘Int’\r\n Expected type: Int > Int\r\n Actual type: Int > Bool\r\n • In the SPECIALISE pragma {# SPECIALIZE foo :: Int > Bool #}\r\n \r\n5  {# SPECIALIZE foo :: Int > Bool #}\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nTested on ghc 8.6.1 and 8.4.3","type_of_failure":"OtherFailure","blocking":[]} >If a module defines a `SPECIALIZE` pragma for a value defined in another module, then the signature of this pragma won't be typecheck by `ghc O0` (but it will be if the `SPECIALIZE` pragma is in the same module as the value).
For example, given
```hs
 Foo.hs
module Foo where
foo :: a > a
foo = id

 Bar.hs
module Bar where
import Foo
{# SPECIALIZE foo :: Int > Bool #}
```
running `ghc make Bar.hs` will run fine, while `ghc make O2 Bar.hs` will complain:
```
Bar.hs:5:1: error:
• Couldn't match type ‘Bool’ with ‘Int’
Expected type: Int > Int
Actual type: Int > Bool
• In the SPECIALISE pragma {# SPECIALIZE foo :: Int > Bool #}

5  {# SPECIALIZE foo :: Int > Bool #}
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Tested on ghc 8.6.1 and 8.4.3
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Crossmodule SPECIALZE pragmas aren't typechecked in O0","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If a module defines a `SPECIALIZE` pragma for a value defined in another module, then the signature of this pragma won't be typecheck by `ghc O0` (but it will be if the `SPECIALIZE` pragma is in the same module as the value).\r\n\r\nFor example, given\r\n\r\n{{{#!hs\r\n Foo.hs\r\nmodule Foo where\r\n\r\nfoo :: a > a\r\nfoo = id\r\n\r\n\r\n\r\n Bar.hs\r\nmodule Bar where\r\n\r\nimport Foo\r\n\r\n{# SPECIALIZE foo :: Int > Bool #}\r\n}}}\r\n\r\nrunning `ghc make Bar.hs` will run fine, while `ghc make O2 Bar.hs` will complain:\r\n\r\n{{{\r\nBar.hs:5:1: error:\r\n • Couldn't match type ‘Bool’ with ‘Int’\r\n Expected type: Int > Int\r\n Actual type: Int > Bool\r\n • In the SPECIALISE pragma {# SPECIALIZE foo :: Int > Bool #}\r\n \r\n5  {# SPECIALIZE foo :: Int > Bool #}\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nTested on ghc 8.6.1 and 8.4.3","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/15772Strange constraint error that disappears when adding another toplevel declar...20201226T13:06:22ZAndres LöhStrange constraint error that disappears when adding another toplevel declarationConsider this program:
```hs
{# LANGUAGE DataKinds, TypeFamilies, TypeOperators, UndecidableInstances #}
module CURepro where
import Data.Kind
data NP (f :: Type > Type) (xs :: [Type])
type family Curry (f :: Type > Type) (xs :: [Type]) (r :: Type) (a :: Type) :: Constraint where
Curry f xs r (f x > a) = (xs ~ (x : Tail xs), Curry f (Tail xs) r a)
Curry f xs r a = (xs ~ '[], r ~ a)
type family Tail (a :: [Type]) :: [Type] where
Tail (_ : xs) = xs
uncurry_NP :: (Curry f xs r a) => (NP f xs > r) > a
uncurry_NP = undefined
fun_NP :: NP Id xs > ()
fun_NP = undefined
newtype Id a = MkId a
 test1 :: ()
 test1 = uncurry_NP fun_NP (MkId 5)
test2 :: ()
test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)
```
With GHC 8.6.1 (and also 8.4.3), this produces the following error message:
```
CURepro.hs:27:9: error:
• Couldn't match type ‘Tail t0’ with ‘Bool : Tail (Tail t0)’
arising from a use of ‘uncurry_NP’
The type variable ‘t0’ is ambiguous
• In the expression:
uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)
In an equation for ‘test2’:
test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)

27  test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
However, uncommenting the definition of `test1` makes the whole program check without error!
I think both versions of the program should be accepted.
I've tried to extract this from a much larger failing example, but did not manage to make it any smaller than this. In particular, the fact that `NP` is parameterised over a type constructor `f` seems to be somehow essential to trigger this.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Strange constraint error that disappears when adding another toplevel declaration","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider this program:\r\n{{{#!hs\r\n{# LANGUAGE DataKinds, TypeFamilies, TypeOperators, UndecidableInstances #}\r\nmodule CURepro where\r\n\r\nimport Data.Kind\r\n\r\ndata NP (f :: Type > Type) (xs :: [Type])\r\n\r\ntype family Curry (f :: Type > Type) (xs :: [Type]) (r :: Type) (a :: Type) :: Constraint where\r\n Curry f xs r (f x > a) = (xs ~ (x : Tail xs), Curry f (Tail xs) r a)\r\n Curry f xs r a = (xs ~ '[], r ~ a)\r\n\r\ntype family Tail (a :: [Type]) :: [Type] where\r\n Tail (_ : xs) = xs\r\n\r\nuncurry_NP :: (Curry f xs r a) => (NP f xs > r) > a\r\nuncurry_NP = undefined\r\n\r\nfun_NP :: NP Id xs > ()\r\nfun_NP = undefined\r\n\r\nnewtype Id a = MkId a\r\n\r\n test1 :: ()\r\n test1 = uncurry_NP fun_NP (MkId 5)\r\n\r\ntest2 :: ()\r\ntest2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)\r\n}}}\r\n\r\nWith GHC 8.6.1 (and also 8.4.3), this produces the following error message:\r\n{{{\r\nCURepro.hs:27:9: error:\r\n • Couldn't match type ‘Tail t0’ with ‘Bool : Tail (Tail t0)’\r\n arising from a use of ‘uncurry_NP’\r\n The type variable ‘t0’ is ambiguous\r\n • In the expression:\r\n uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)\r\n In an equation for ‘test2’:\r\n test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)\r\n \r\n27  test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nHowever, uncommenting the definition of `test1` makes the whole program check without error!\r\n\r\nI think both versions of the program should be accepted.\r\n\r\nI've tried to extract this from a much larger failing example, but did not manage to make it any smaller than this. In particular, the fact that `NP` is parameterised over a type constructor `f` seems to be somehow essential to trigger this.","type_of_failure":"OtherFailure","blocking":[]} >Consider this program:
```hs
{# LANGUAGE DataKinds, TypeFamilies, TypeOperators, UndecidableInstances #}
module CURepro where
import Data.Kind
data NP (f :: Type > Type) (xs :: [Type])
type family Curry (f :: Type > Type) (xs :: [Type]) (r :: Type) (a :: Type) :: Constraint where
Curry f xs r (f x > a) = (xs ~ (x : Tail xs), Curry f (Tail xs) r a)
Curry f xs r a = (xs ~ '[], r ~ a)
type family Tail (a :: [Type]) :: [Type] where
Tail (_ : xs) = xs
uncurry_NP :: (Curry f xs r a) => (NP f xs > r) > a
uncurry_NP = undefined
fun_NP :: NP Id xs > ()
fun_NP = undefined
newtype Id a = MkId a
 test1 :: ()
 test1 = uncurry_NP fun_NP (MkId 5)
test2 :: ()
test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)
```
With GHC 8.6.1 (and also 8.4.3), this produces the following error message:
```
CURepro.hs:27:9: error:
• Couldn't match type ‘Tail t0’ with ‘Bool : Tail (Tail t0)’
arising from a use of ‘uncurry_NP’
The type variable ‘t0’ is ambiguous
• In the expression:
uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)
In an equation for ‘test2’:
test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)

27  test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
However, uncommenting the definition of `test1` makes the whole program check without error!
I think both versions of the program should be accepted.
I've tried to extract this from a much larger failing example, but did not manage to make it any smaller than this. In particular, the fact that `NP` is parameterised over a type constructor `f` seems to be somehow essential to trigger this.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Strange constraint error that disappears when adding another toplevel declaration","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider this program:\r\n{{{#!hs\r\n{# LANGUAGE DataKinds, TypeFamilies, TypeOperators, UndecidableInstances #}\r\nmodule CURepro where\r\n\r\nimport Data.Kind\r\n\r\ndata NP (f :: Type > Type) (xs :: [Type])\r\n\r\ntype family Curry (f :: Type > Type) (xs :: [Type]) (r :: Type) (a :: Type) :: Constraint where\r\n Curry f xs r (f x > a) = (xs ~ (x : Tail xs), Curry f (Tail xs) r a)\r\n Curry f xs r a = (xs ~ '[], r ~ a)\r\n\r\ntype family Tail (a :: [Type]) :: [Type] where\r\n Tail (_ : xs) = xs\r\n\r\nuncurry_NP :: (Curry f xs r a) => (NP f xs > r) > a\r\nuncurry_NP = undefined\r\n\r\nfun_NP :: NP Id xs > ()\r\nfun_NP = undefined\r\n\r\nnewtype Id a = MkId a\r\n\r\n test1 :: ()\r\n test1 = uncurry_NP fun_NP (MkId 5)\r\n\r\ntest2 :: ()\r\ntest2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)\r\n}}}\r\n\r\nWith GHC 8.6.1 (and also 8.4.3), this produces the following error message:\r\n{{{\r\nCURepro.hs:27:9: error:\r\n • Couldn't match type ‘Tail t0’ with ‘Bool : Tail (Tail t0)’\r\n arising from a use of ‘uncurry_NP’\r\n The type variable ‘t0’ is ambiguous\r\n • In the expression:\r\n uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)\r\n In an equation for ‘test2’:\r\n test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)\r\n \r\n27  test2 = uncurry_NP fun_NP (MkId True) (MkId 5) (MkId True)\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nHowever, uncommenting the definition of `test1` makes the whole program check without error!\r\n\r\nI think both versions of the program should be accepted.\r\n\r\nI've tried to extract this from a much larger failing example, but did not manage to make it any smaller than this. In particular, the fact that `NP` is parameterised over a type constructor `f` seems to be somehow essential to trigger this.","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/15778GHC HEADonly panic (zonkTcTyVarToTyVar)20190707T18:03:02ZRyan ScottGHC HEADonly panic (zonkTcTyVarToTyVar)The following program typechecks on GHC 8.0.1 through 8.6.1:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
type a ~> b = a > b > Type
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing (a :: k)
data Flarble (a :: Type) where
MkFlarble :: Flarble Bool
data instance Sing (z :: Flarble a) where
SMkFlarble :: Sing MkFlarble
elimFlarble :: forall a
(p :: forall x. Flarble x ~> Type)
(f :: Flarble a).
Sing f
> Apply p MkFlarble
> Apply p f
elimFlarble s@SMkFlarble pMkFlarble =
case s of
(_ :: Sing (MkFlarble :: Flarble probablyABadIdea)) >
pMkFlarble
```
However, it panics on GHC HEAD:
```
$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20181015 for x86_64unknownlinux):
zonkTcTyVarToTyVar
probablyABadIdea_aWn[tau:2]
Bool
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcMType.hs:1627:34 in ghc:TcMType
```
If I replace `probablyABadIdea` with `Bool`, then it typechecks again.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEADonly panic (zonkTcTyVarToTyVar)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.0.1 through 8.6.1:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype a ~> b = a > b > Type\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\ndata family Sing (a :: k)\r\n\r\ndata Flarble (a :: Type) where\r\n MkFlarble :: Flarble Bool\r\ndata instance Sing (z :: Flarble a) where\r\n SMkFlarble :: Sing MkFlarble\r\n\r\nelimFlarble :: forall a\r\n (p :: forall x. Flarble x ~> Type)\r\n (f :: Flarble a).\r\n Sing f\r\n > Apply p MkFlarble\r\n > Apply p f\r\nelimFlarble s@SMkFlarble pMkFlarble =\r\n case s of\r\n (_ :: Sing (MkFlarble :: Flarble probablyABadIdea)) >\r\n pMkFlarble\r\n}}}\r\n\r\nHowever, it panics on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20181015 for x86_64unknownlinux):\r\n zonkTcTyVarToTyVar\r\n probablyABadIdea_aWn[tau:2]\r\n Bool\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcMType.hs:1627:34 in ghc:TcMType\r\n}}}\r\n\r\nIf I replace `probablyABadIdea` with `Bool`, then it typechecks again.","type_of_failure":"OtherFailure","blocking":[]} >The following program typechecks on GHC 8.0.1 through 8.6.1:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
type a ~> b = a > b > Type
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing (a :: k)
data Flarble (a :: Type) where
MkFlarble :: Flarble Bool
data instance Sing (z :: Flarble a) where
SMkFlarble :: Sing MkFlarble
elimFlarble :: forall a
(p :: forall x. Flarble x ~> Type)
(f :: Flarble a).
Sing f
> Apply p MkFlarble
> Apply p f
elimFlarble s@SMkFlarble pMkFlarble =
case s of
(_ :: Sing (MkFlarble :: Flarble probablyABadIdea)) >
pMkFlarble
```
However, it panics on GHC HEAD:
```
$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20181015 for x86_64unknownlinux):
zonkTcTyVarToTyVar
probablyABadIdea_aWn[tau:2]
Bool
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcMType.hs:1627:34 in ghc:TcMType
```
If I replace `probablyABadIdea` with `Bool`, then it typechecks again.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.5 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEADonly panic (zonkTcTyVarToTyVar)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.0.1 through 8.6.1:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype a ~> b = a > b > Type\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\ndata family Sing (a :: k)\r\n\r\ndata Flarble (a :: Type) where\r\n MkFlarble :: Flarble Bool\r\ndata instance Sing (z :: Flarble a) where\r\n SMkFlarble :: Sing MkFlarble\r\n\r\nelimFlarble :: forall a\r\n (p :: forall x. Flarble x ~> Type)\r\n (f :: Flarble a).\r\n Sing f\r\n > Apply p MkFlarble\r\n > Apply p f\r\nelimFlarble s@SMkFlarble pMkFlarble =\r\n case s of\r\n (_ :: Sing (MkFlarble :: Flarble probablyABadIdea)) >\r\n pMkFlarble\r\n}}}\r\n\r\nHowever, it panics on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20181015 for x86_64unknownlinux):\r\n zonkTcTyVarToTyVar\r\n probablyABadIdea_aWn[tau:2]\r\n Bool\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcMType.hs:1627:34 in ghc:TcMType\r\n}}}\r\n\r\nIf I replace `probablyABadIdea` with `Bool`, then it typechecks again.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15796Core Lint error with invalid newtype declaration20190707T18:02:56ZIcelandjackCore Lint error with invalid newtype declarationThis gives a Core Lint error
```hs
{# Language QuantifiedConstraints #}
{# Language TypeApplications #}
{# Language TypeOperators #}
{# Language PolyKinds #}
{# Language FlexibleInstances #}
{# Language DataKinds #}
{# Language TypeFamilies #}
{# Language MultiParamTypeClasses #}
{# Language ConstraintKinds #}
{# Language UndecidableInstances #}
{# Language GADTs #}
{# Options_GHC dcorelint #}
import Data.Kind
type Cat ob = ob > ob > Type
class Ríki (obj :: Type) where
type (>) :: Cat obj
class Varpi (f :: dom > cod)
newtype
(··>) :: Cat (a > b) where
Natu :: Varpi f
=> (forall xx. f xx > f' xx)
> (f ··> f')
instance
Ríki cod
=> 
Ríki (dom > cod)
where
type (>) = (··>) @dom @cod
```
```
$ ghci ignoredotghci 568_bug.hs
GHCi, version 8.7.20181017: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( 568_bug.hs, interpreted )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20181017 for x86_64unknownlinux):
Core Lint error
<no location info>: warning:
In the type ‘(··>)’
Found TcTyCon: ··>[tc]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/FamInst.hs:171:31 in ghc:FamInst
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
> :q
Leaving GHCi.
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This gives a Core Lint error\r\n\r\n{{{#!hs\r\n{# Language QuantifiedConstraints #}\r\n{# Language TypeApplications #}\r\n{# Language TypeOperators #}\r\n{# Language PolyKinds #}\r\n{# Language FlexibleInstances #}\r\n{# Language DataKinds #}\r\n{# Language TypeFamilies #}\r\n{# Language MultiParamTypeClasses #}\r\n{# Language ConstraintKinds #}\r\n{# Language UndecidableInstances #}\r\n{# Language GADTs #}\r\n\r\n{# Options_GHC dcorelint #}\r\n\r\nimport Data.Kind\r\n\r\ntype Cat ob = ob > ob > Type\r\n\r\nclass Ríki (obj :: Type) where\r\n type (>) :: Cat obj\r\n\r\nclass Varpi (f :: dom > cod)\r\n\r\nnewtype\r\n (··>) :: Cat (a > b) where\r\n Natu :: Varpi f\r\n => (forall xx. f xx > f' xx)\r\n > (f ··> f')\r\n\r\ninstance\r\n Ríki cod\r\n => \r\n Ríki (dom > cod)\r\n where\r\n\r\n type (>) = (··>) @dom @cod\r\n}}}\r\n\r\n{{{\r\n$ ghci ignoredotghci 568_bug.hs\r\nGHCi, version 8.7.20181017: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling Main ( 568_bug.hs, interpreted )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20181017 for x86_64unknownlinux):\r\n Core Lint error\r\n <no location info>: warning:\r\n In the type ‘(··>)’\r\n Found TcTyCon: ··>[tc]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/FamInst.hs:171:31 in ghc:FamInst\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n> :q\r\nLeaving GHCi.\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >This gives a Core Lint error
```hs
{# Language QuantifiedConstraints #}
{# Language TypeApplications #}
{# Language TypeOperators #}
{# Language PolyKinds #}
{# Language FlexibleInstances #}
{# Language DataKinds #}
{# Language TypeFamilies #}
{# Language MultiParamTypeClasses #}
{# Language ConstraintKinds #}
{# Language UndecidableInstances #}
{# Language GADTs #}
{# Options_GHC dcorelint #}
import Data.Kind
type Cat ob = ob > ob > Type
class Ríki (obj :: Type) where
type (>) :: Cat obj
class Varpi (f :: dom > cod)
newtype
(··>) :: Cat (a > b) where
Natu :: Varpi f
=> (forall xx. f xx > f' xx)
> (f ··> f')
instance
Ríki cod
=> 
Ríki (dom > cod)
where
type (>) = (··>) @dom @cod
```
```
$ ghci ignoredotghci 568_bug.hs
GHCi, version 8.7.20181017: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( 568_bug.hs, interpreted )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20181017 for x86_64unknownlinux):
Core Lint error
<no location info>: warning:
In the type ‘(··>)’
Found TcTyCon: ··>[tc]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/FamInst.hs:171:31 in ghc:FamInst
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
> :q
Leaving GHCi.
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.1 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This gives a Core Lint error\r\n\r\n{{{#!hs\r\n{# Language QuantifiedConstraints #}\r\n{# Language TypeApplications #}\r\n{# Language TypeOperators #}\r\n{# Language PolyKinds #}\r\n{# Language FlexibleInstances #}\r\n{# Language DataKinds #}\r\n{# Language TypeFamilies #}\r\n{# Language MultiParamTypeClasses #}\r\n{# Language ConstraintKinds #}\r\n{# Language UndecidableInstances #}\r\n{# Language GADTs #}\r\n\r\n{# Options_GHC dcorelint #}\r\n\r\nimport Data.Kind\r\n\r\ntype Cat ob = ob > ob > Type\r\n\r\nclass Ríki (obj :: Type) where\r\n type (>) :: Cat obj\r\n\r\nclass Varpi (f :: dom > cod)\r\n\r\nnewtype\r\n (··>) :: Cat (a > b) where\r\n Natu :: Varpi f\r\n => (forall xx. f xx > f' xx)\r\n > (f ··> f')\r\n\r\ninstance\r\n Ríki cod\r\n => \r\n Ríki (dom > cod)\r\n where\r\n\r\n type (>) = (··>) @dom @cod\r\n}}}\r\n\r\n{{{\r\n$ ghci ignoredotghci 568_bug.hs\r\nGHCi, version 8.7.20181017: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling Main ( 568_bug.hs, interpreted )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20181017 for x86_64unknownlinux):\r\n Core Lint error\r\n <no location info>: warning:\r\n In the type ‘(··>)’\r\n Found TcTyCon: ··>[tc]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/FamInst.hs:171:31 in ghc:FamInst\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n> :q\r\nLeaving GHCi.\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.6.2https://gitlab.haskell.org/ghc/ghc//issues/15829Add a test case for tricky type synonyms involving visible dependent kinds20190707T18:02:49ZRyan ScottAdd a test case for tricky type synonyms involving visible dependent kindsThis code does not typecheck on GHC 8.6.1:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
module Bug where
import Data.Kind
data A :: Type > Type
data B a :: A a > Type
type C a = B a
```
However, it //does// typecheck on GHC HEAD, after commit 5e45ad10ffca1ad175b10f6ef3327e1ed8ba25f3 (Finish fix for #14880.). This is very cool, although it does alarm me that there is no test case which checks for this at the moment. Let's add one to ensure that this stays fixed.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Add a test case for tricky type synonyms involving visible dependent kinds","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This code does not typecheck on GHC 8.6.1:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata A :: Type > Type\r\ndata B a :: A a > Type\r\ntype C a = B a\r\n}}}\r\n\r\nHowever, it //does// typecheck on GHC HEAD, after commit 5e45ad10ffca1ad175b10f6ef3327e1ed8ba25f3 (Finish fix for #14880.). This is very cool, although it does alarm me that there is no test case which checks for this at the moment. Let's add one to ensure that this stays fixed.","type_of_failure":"OtherFailure","blocking":[]} >This code does not typecheck on GHC 8.6.1:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
module Bug where
import Data.Kind
data A :: Type > Type
data B a :: A a > Type
type C a = B a
```
However, it //does// typecheck on GHC HEAD, after commit 5e45ad10ffca1ad175b10f6ef3327e1ed8ba25f3 (Finish fix for #14880.). This is very cool, although it does alarm me that there is no test case which checks for this at the moment. Let's add one to ensure that this stays fixed.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Add a test case for tricky type synonyms involving visible dependent kinds","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This code does not typecheck on GHC 8.6.1:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata A :: Type > Type\r\ndata B a :: A a > Type\r\ntype C a = B a\r\n}}}\r\n\r\nHowever, it //does// typecheck on GHC HEAD, after commit 5e45ad10ffca1ad175b10f6ef3327e1ed8ba25f3 (Finish fix for #14880.). This is very cool, although it does alarm me that there is no test case which checks for this at the moment. Let's add one to ensure that this stays fixed.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15869Discrepancy between seemingly equivalent type synonym and type family20190707T18:02:38ZRyan ScottDiscrepancy between seemingly equivalent type synonym and type familyConsider the following code:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE ImpredicativeTypes #}
{# LANGUAGE LiberalTypeSynonyms #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
type KindOf1 (a :: k) = k
type family KindOf2 (a :: k) :: Type where
KindOf2 (a :: k) = k
data A (a :: Type) :: a > Type
type family Apply1 (f :: KindOf1 A) (a :: Type) (x :: a) :: Type where
Apply1 f a x = f a x
```
`Apply1` kindchecks, which is just peachy. Note that `Apply1` uses `KindOf1`, which is a type synonym. Suppose I wanted to swap out `KindOf1` for `KindOf2`, which is (seemingly) an equivalent type family. I can define this:
```hs
type family Apply2 (f :: KindOf2 A)  (f :: forall a > a > Type)
(a :: Type)
(x :: a)
:: Type where
Apply2 f a x = f a x
```
However, GHC rejects this!
```
$ /opt/ghc/8.6.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:25:10: error:
• Expecting two more arguments to ‘f’
Expected kind ‘KindOf2 A’, but ‘f’ has kind ‘* > a > *’
• In the first argument of ‘Apply2’, namely ‘f’
In the type family declaration for ‘Apply2’

25  Apply2 f a x = f a x
 ^
```
I find this quite surprising, since I would have expected `KindOf1` and `KindOf2` to be functionally equivalent. Even providing explicit `forall`s does not make it kindcheck:
```hs
type family Apply2 (f :: KindOf2 A)  (f :: forall a > a > Type)
(a :: Type)
(x :: a)
:: Type where
forall (f :: KindOf2 A) (a :: Type) (x :: a).
Apply2 f a x = f a x
```
Although the error message does change a bit:
```
$ ~/Software/ghc3/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:26:20: error:
• Expected kind ‘* > a > *’, but ‘f’ has kind ‘KindOf2 A’
• In the type ‘f a x’
In the type family declaration for ‘Apply2’

26  Apply2 f a x = f a x
 ^^^^^
```Consider the following code:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE ImpredicativeTypes #}
{# LANGUAGE LiberalTypeSynonyms #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
type KindOf1 (a :: k) = k
type family KindOf2 (a :: k) :: Type where
KindOf2 (a :: k) = k
data A (a :: Type) :: a > Type
type family Apply1 (f :: KindOf1 A) (a :: Type) (x :: a) :: Type where
Apply1 f a x = f a x
```
`Apply1` kindchecks, which is just peachy. Note that `Apply1` uses `KindOf1`, which is a type synonym. Suppose I wanted to swap out `KindOf1` for `KindOf2`, which is (seemingly) an equivalent type family. I can define this:
```hs
type family Apply2 (f :: KindOf2 A)  (f :: forall a > a > Type)
(a :: Type)
(x :: a)
:: Type where
Apply2 f a x = f a x
```
However, GHC rejects this!
```
$ /opt/ghc/8.6.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:25:10: error:
• Expecting two more arguments to ‘f’
Expected kind ‘KindOf2 A’, but ‘f’ has kind ‘* > a > *’
• In the first argument of ‘Apply2’, namely ‘f’
In the type family declaration for ‘Apply2’

25  Apply2 f a x = f a x
 ^
```
I find this quite surprising, since I would have expected `KindOf1` and `KindOf2` to be functionally equivalent. Even providing explicit `forall`s does not make it kindcheck:
```hs
type family Apply2 (f :: KindOf2 A)  (f :: forall a > a > Type)
(a :: Type)
(x :: a)
:: Type where
forall (f :: KindOf2 A) (a :: Type) (x :: a).
Apply2 f a x = f a x
```
Although the error message does change a bit:
```
$ ~/Software/ghc3/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:26:20: error:
• Expected kind ‘* > a > *’, but ‘f’ has kind ‘KindOf2 A’
• In the type ‘f a x’
In the type family declaration for ‘Apply2’

26  Apply2 f a x = f a x
 ^^^^^
```https://gitlab.haskell.org/ghc/ghc//issues/15870No skolem info panic20190707T18:02:38ZsheafNo skolem info panicI've been toying with some typelevel lenses and running into some issues with kind unification, when I ran into a panic:
```
bug.hs:30:34: error:ghc.exe: panic! (the 'impossible' happened)
(GHC version 8.6.2 for x86_64unknownmingw32):
No skolem info:
[k_a1Hgj]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\utils\Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler\\typecheck\\TcErrors.hs:2891:5 in ghc:TcErrors
```
Here's a boiled down version (with a bit of extraneous code left in for context, as it's so short):
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE FlexibleInstances #}
{# LANGUAGE GADTs #}
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
data Optic a where
Index :: Nat > Optic a
Name :: Symbol > Optic a
(:.:) :: Optic a > Optic b > Optic a  composition
class Gettable a (optic :: Optic a) where
type Get a (optic :: Optic a)
{
some basic instances, e.g.
instance Gettable (a,b) (Index 0) where
type Get (a,b) (Index 0) = a
...
}
instance forall a b (g1 :: Optic a) (g2 :: Optic b).
( Gettable a g1
, b ~ Get a g1
, Gettable b g2
) => Gettable a (g1 :.: g2) where
type Get a (g1 :.: g2) = Get a g2
```
The program I am actually trying to write has the instance declaration changed to
```hs
instance forall a b (g1 :: Optic a) (g2 :: Optic (Get a g1)).
( Gettable a g1
, b ~ Get a g1
, Gettable b g2
) => Gettable a (g1 :.: g2) where
type Get a (g1 :.: g2) = Get (Get a g1) g2
```
but GHC complains that it can't match kinds:
```
• Expected kind ‘Optic b’, but ‘g2’ has kind ‘Optic (Get a g1)’
• In the second argument of ‘Gettable’, namely ‘g2’
In the instance declaration for ‘Gettable a (g1 :.: g2)’

20  , Gettable b g2

```
I don't know if there is a way around that, and I'd be interested to hear any advice.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"No skolem info panic","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I've been toying with some typelevel lenses and running into some issues with kind unification, when I ran into a panic:\r\n\r\n\r\n{{{\r\nbug.hs:30:34: error:ghc.exe: panic! (the 'impossible' happened)\r\n (GHC version 8.6.2 for x86_64unknownmingw32):\r\n No skolem info:\r\n [k_a1Hgj]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler\\utils\\Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler\\\\typecheck\\\\TcErrors.hs:2891:5 in ghc:TcErrors\r\n}}}\r\n\r\nHere's a boiled down version (with a bit of extraneous code left in for context, as it's so short):\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE FlexibleInstances #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE MultiParamTypeClasses #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n\r\ndata Optic a where\r\n Index :: Nat > Optic a\r\n Name :: Symbol > Optic a\r\n (:.:) :: Optic a > Optic b > Optic a  composition\r\n\r\nclass Gettable a (optic :: Optic a) where\r\n type Get a (optic :: Optic a)\r\n\r\n{\r\nsome basic instances, e.g.\r\ninstance Gettable (a,b) (Index 0) where\r\n type Get (a,b) (Index 0) = a\r\n...\r\n}\r\n\r\ninstance forall a b (g1 :: Optic a) (g2 :: Optic b).\r\n ( Gettable a g1\r\n , b ~ Get a g1\r\n , Gettable b g2\r\n ) => Gettable a (g1 :.: g2) where\r\n type Get a (g1 :.: g2) = Get a g2\r\n}}}\r\n\r\nThe program I am actually trying to write has the instance declaration changed to\r\n{{{#!hs\r\ninstance forall a b (g1 :: Optic a) (g2 :: Optic (Get a g1)).\r\n ( Gettable a g1\r\n , b ~ Get a g1\r\n , Gettable b g2\r\n ) => Gettable a (g1 :.: g2) where\r\n type Get a (g1 :.: g2) = Get (Get a g1) g2\r\n}}}\r\nbut GHC complains that it can't match kinds:\r\n\r\n{{{\r\n • Expected kind ‘Optic b’, but ‘g2’ has kind ‘Optic (Get a g1)’\r\n • In the second argument of ‘Gettable’, namely ‘g2’\r\n In the instance declaration for ‘Gettable a (g1 :.: g2)’\r\n \r\n20  , Gettable b g2\r\n \r\n}}}\r\nI don't know if there is a way around that, and I'd be interested to hear any advice.\r\n","type_of_failure":"OtherFailure","blocking":[]} >I've been toying with some typelevel lenses and running into some issues with kind unification, when I ran into a panic:
```
bug.hs:30:34: error:ghc.exe: panic! (the 'impossible' happened)
(GHC version 8.6.2 for x86_64unknownmingw32):
No skolem info:
[k_a1Hgj]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\utils\Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler\\typecheck\\TcErrors.hs:2891:5 in ghc:TcErrors
```
Here's a boiled down version (with a bit of extraneous code left in for context, as it's so short):
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE FlexibleInstances #}
{# LANGUAGE GADTs #}
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
data Optic a where
Index :: Nat > Optic a
Name :: Symbol > Optic a
(:.:) :: Optic a > Optic b > Optic a  composition
class Gettable a (optic :: Optic a) where
type Get a (optic :: Optic a)
{
some basic instances, e.g.
instance Gettable (a,b) (Index 0) where
type Get (a,b) (Index 0) = a
...
}
instance forall a b (g1 :: Optic a) (g2 :: Optic b).
( Gettable a g1
, b ~ Get a g1
, Gettable b g2
) => Gettable a (g1 :.: g2) where
type Get a (g1 :.: g2) = Get a g2
```
The program I am actually trying to write has the instance declaration changed to
```hs
instance forall a b (g1 :: Optic a) (g2 :: Optic (Get a g1)).
( Gettable a g1
, b ~ Get a g1
, Gettable b g2
) => Gettable a (g1 :.: g2) where
type Get a (g1 :.: g2) = Get (Get a g1) g2
```
but GHC complains that it can't match kinds:
```
• Expected kind ‘Optic b’, but ‘g2’ has kind ‘Optic (Get a g1)’
• In the second argument of ‘Gettable’, namely ‘g2’
In the instance declaration for ‘Gettable a (g1 :.: g2)’

20  , Gettable b g2

```
I don't know if there is a way around that, and I'd be interested to hear any advice.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"No skolem info panic","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I've been toying with some typelevel lenses and running into some issues with kind unification, when I ran into a panic:\r\n\r\n\r\n{{{\r\nbug.hs:30:34: error:ghc.exe: panic! (the 'impossible' happened)\r\n (GHC version 8.6.2 for x86_64unknownmingw32):\r\n No skolem info:\r\n [k_a1Hgj]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler\\utils\\Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler\\\\typecheck\\\\TcErrors.hs:2891:5 in ghc:TcErrors\r\n}}}\r\n\r\nHere's a boiled down version (with a bit of extraneous code left in for context, as it's so short):\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE FlexibleInstances #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE MultiParamTypeClasses #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n\r\ndata Optic a where\r\n Index :: Nat > Optic a\r\n Name :: Symbol > Optic a\r\n (:.:) :: Optic a > Optic b > Optic a  composition\r\n\r\nclass Gettable a (optic :: Optic a) where\r\n type Get a (optic :: Optic a)\r\n\r\n{\r\nsome basic instances, e.g.\r\ninstance Gettable (a,b) (Index 0) where\r\n type Get (a,b) (Index 0) = a\r\n...\r\n}\r\n\r\ninstance forall a b (g1 :: Optic a) (g2 :: Optic b).\r\n ( Gettable a g1\r\n , b ~ Get a g1\r\n , Gettable b g2\r\n ) => Gettable a (g1 :.: g2) where\r\n type Get a (g1 :.: g2) = Get a g2\r\n}}}\r\n\r\nThe program I am actually trying to write has the instance declaration changed to\r\n{{{#!hs\r\ninstance forall a b (g1 :: Optic a) (g2 :: Optic (Get a g1)).\r\n ( Gettable a g1\r\n , b ~ Get a g1\r\n , Gettable b g2\r\n ) => Gettable a (g1 :.: g2) where\r\n type Get a (g1 :.: g2) = Get (Get a g1) g2\r\n}}}\r\nbut GHC complains that it can't match kinds:\r\n\r\n{{{\r\n • Expected kind ‘Optic b’, but ‘g2’ has kind ‘Optic (Get a g1)’\r\n • In the second argument of ‘Gettable’, namely ‘g2’\r\n In the instance declaration for ‘Gettable a (g1 :.: g2)’\r\n \r\n20  , Gettable b g2\r\n \r\n}}}\r\nI don't know if there is a way around that, and I'd be interested to hear any advice.\r\n","type_of_failure":"OtherFailure","blocking":[]} >8.6.3https://gitlab.haskell.org/ghc/ghc//issues/15883GHC panic: newtype F rep = F (forall (a :: TYPE rep). a)20200117T16:43:24ZIcelandjackGHC panic: newtype F rep = F (forall (a :: TYPE rep). a)```hs
{# Language RankNTypes #}
{# Language KindSignatures #}
{# Language PolyKinds #}
import GHC.Exts
newtype Foo rep = MkFoo (forall (a :: TYPE rep). a)
```
```
$ ~/code/unmodifiedghc/inplace/bin/ghcstage2 interactive ignoredotghci /tmp/U.hs
GHCi, version 8.7.20181029: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( /tmp/U.hs, interpreted )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20181029 for x86_64unknownlinux):
isUnliftedType
forall (a :: TYPE rep_a1AA[sk:0]). a :: TYPE rep_a1AA[sk:0]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:2332:10 in ghc:Type
isUnliftedType, called at compiler/typecheck/TcTyClsDecls.hs:3055:25 in ghc:TcTyClsDecls
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
>
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC panic: newtype F rep = F (forall (a :: TYPE rep). a)","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{# Language RankNTypes #}\r\n{# Language KindSignatures #}\r\n{# Language PolyKinds #}\r\n\r\nimport GHC.Exts\r\n\r\nnewtype Foo rep = MkFoo (forall (a :: TYPE rep). a)\r\n}}}\r\n\r\n{{{\r\n$ ~/code/unmodifiedghc/inplace/bin/ghcstage2 interactive ignoredotghci /tmp/U.hs\r\nGHCi, version 8.7.20181029: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling Main ( /tmp/U.hs, interpreted )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20181029 for x86_64unknownlinux):\r\n isUnliftedType\r\n forall (a :: TYPE rep_a1AA[sk:0]). a :: TYPE rep_a1AA[sk:0]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:2332:10 in ghc:Type\r\n isUnliftedType, called at compiler/typecheck/TcTyClsDecls.hs:3055:25 in ghc:TcTyClsDecls\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n>\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >```hs
{# Language RankNTypes #}
{# Language KindSignatures #}
{# Language PolyKinds #}
import GHC.Exts
newtype Foo rep = MkFoo (forall (a :: TYPE rep). a)
```
```
$ ~/code/unmodifiedghc/inplace/bin/ghcstage2 interactive ignoredotghci /tmp/U.hs
GHCi, version 8.7.20181029: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( /tmp/U.hs, interpreted )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20181029 for x86_64unknownlinux):
isUnliftedType
forall (a :: TYPE rep_a1AA[sk:0]). a :: TYPE rep_a1AA[sk:0]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:2332:10 in ghc:Type
isUnliftedType, called at compiler/typecheck/TcTyClsDecls.hs:3055:25 in ghc:TcTyClsDecls
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
>
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC panic: newtype F rep = F (forall (a :: TYPE rep). a)","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{# Language RankNTypes #}\r\n{# Language KindSignatures #}\r\n{# Language PolyKinds #}\r\n\r\nimport GHC.Exts\r\n\r\nnewtype Foo rep = MkFoo (forall (a :: TYPE rep). a)\r\n}}}\r\n\r\n{{{\r\n$ ~/code/unmodifiedghc/inplace/bin/ghcstage2 interactive ignoredotghci /tmp/U.hs\r\nGHCi, version 8.7.20181029: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling Main ( /tmp/U.hs, interpreted )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20181029 for x86_64unknownlinux):\r\n isUnliftedType\r\n forall (a :: TYPE rep_a1AA[sk:0]). a :: TYPE rep_a1AA[sk:0]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:2332:10 in ghc:Type\r\n isUnliftedType, called at compiler/typecheck/TcTyClsDecls.hs:3055:25 in ghc:TcTyClsDecls\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n>\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.10.1https://gitlab.haskell.org/ghc/ghc//issues/15954LiberalTypeSynonyms unsaturation check doesn't kick in20190707T18:02:18ZRyan ScottLiberalTypeSynonyms unsaturation check doesn't kick inGHC accepts this program:
```hs
{# LANGUAGE ImpredicativeTypes #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
module Bug where
import GHC.Exts (Any)
type KindOf (a :: k) = k
type A a = (Any :: a)
type KA = KindOf A
```
But it really oughtn't to. After all, we have an unsaturated use of `A` in `KindOf A`, and we don't have `LiberalTypeSynonyms` enabled!
What's even stranger is that there seems to be something about this exact setup that sneaks by `LiberalTypeSynonyms`' validity checks. If I add another argument to `A`:
```hs
type A x a = (Any :: a)
```
Then it //does// error:
```
$ /opt/ghc/8.6.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:10:1: error:
• Illegal polymorphic type: forall a > a
Perhaps you intended to use LiberalTypeSynonyms
• In the type synonym declaration for ‘KA’

10  type KA = KindOf A
 ^^^^^^^^^^^^^^^^^^
```
Similarly, if I use something besides `KindOf`:
```hs
{# LANGUAGE ImpredicativeTypes #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
module Bug where
import GHC.Exts (Any)
type A a = (Any :: a)
type B a = Int
type C = B A
```
Then I also get the same `Illegal polymorphic type: forall a > a` error.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"LiberalTypeSynonyms unsaturation check doesn't kick in","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC accepts this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ImpredicativeTypes #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\nmodule Bug where\r\n\r\nimport GHC.Exts (Any)\r\n\r\ntype KindOf (a :: k) = k\r\ntype A a = (Any :: a)\r\ntype KA = KindOf A\r\n}}}\r\n\r\nBut it really oughtn't to. After all, we have an unsaturated use of `A` in `KindOf A`, and we don't have `LiberalTypeSynonyms` enabled!\r\n\r\nWhat's even stranger is that there seems to be something about this exact setup that sneaks by `LiberalTypeSynonyms`' validity checks. If I add another argument to `A`:\r\n\r\n{{{#!hs\r\ntype A x a = (Any :: a)\r\n}}}\r\n\r\nThen it //does// error:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:10:1: error:\r\n • Illegal polymorphic type: forall a > a\r\n Perhaps you intended to use LiberalTypeSynonyms\r\n • In the type synonym declaration for ‘KA’\r\n \r\n10  type KA = KindOf A\r\n  ^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nSimilarly, if I use something besides `KindOf`:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ImpredicativeTypes #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\nmodule Bug where\r\n\r\nimport GHC.Exts (Any)\r\n\r\ntype A a = (Any :: a)\r\ntype B a = Int\r\ntype C = B A\r\n}}}\r\n\r\nThen I also get the same `Illegal polymorphic type: forall a > a` error.","type_of_failure":"OtherFailure","blocking":[]} >GHC accepts this program:
```hs
{# LANGUAGE ImpredicativeTypes #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
module Bug where
import GHC.Exts (Any)
type KindOf (a :: k) = k
type A a = (Any :: a)
type KA = KindOf A
```
But it really oughtn't to. After all, we have an unsaturated use of `A` in `KindOf A`, and we don't have `LiberalTypeSynonyms` enabled!
What's even stranger is that there seems to be something about this exact setup that sneaks by `LiberalTypeSynonyms`' validity checks. If I add another argument to `A`:
```hs
type A x a = (Any :: a)
```
Then it //does// error:
```
$ /opt/ghc/8.6.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:10:1: error:
• Illegal polymorphic type: forall a > a
Perhaps you intended to use LiberalTypeSynonyms
• In the type synonym declaration for ‘KA’

10  type KA = KindOf A
 ^^^^^^^^^^^^^^^^^^
```
Similarly, if I use something besides `KindOf`:
```hs
{# LANGUAGE ImpredicativeTypes #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
module Bug where
import GHC.Exts (Any)
type A a = (Any :: a)
type B a = Int
type C = B A
```
Then I also get the same `Illegal polymorphic type: forall a > a` error.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.2 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"LiberalTypeSynonyms unsaturation check doesn't kick in","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC accepts this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ImpredicativeTypes #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\nmodule Bug where\r\n\r\nimport GHC.Exts (Any)\r\n\r\ntype KindOf (a :: k) = k\r\ntype A a = (Any :: a)\r\ntype KA = KindOf A\r\n}}}\r\n\r\nBut it really oughtn't to. After all, we have an unsaturated use of `A` in `KindOf A`, and we don't have `LiberalTypeSynonyms` enabled!\r\n\r\nWhat's even stranger is that there seems to be something about this exact setup that sneaks by `LiberalTypeSynonyms`' validity checks. If I add another argument to `A`:\r\n\r\n{{{#!hs\r\ntype A x a = (Any :: a)\r\n}}}\r\n\r\nThen it //does// error:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.2/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:10:1: error:\r\n • Illegal polymorphic type: forall a > a\r\n Perhaps you intended to use LiberalTypeSynonyms\r\n • In the type synonym declaration for ‘KA’\r\n \r\n10  type KA = KindOf A\r\n  ^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nSimilarly, if I use something besides `KindOf`:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ImpredicativeTypes #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\nmodule Bug where\r\n\r\nimport GHC.Exts (Any)\r\n\r\ntype A a = (Any :: a)\r\ntype B a = Int\r\ntype C = B A\r\n}}}\r\n\r\nThen I also get the same `Illegal polymorphic type: forall a > a` error.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15962Type family & typeclass interaction suppresses errors20190707T18:02:16ZmadgenType family & typeclass interaction suppresses errorsThe following program despite having a hole and an undefined variable `iDontExist` \*quietly\* fails to compile on 8.4.3 and 8.4.4. It produces errors as expected on 8.6.1 and 8.6.2.
By quietly failing, I mean it fails on CLI but without producing any error messages and in GHCI. It just says "Failed, no modules loaded."
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE FlexibleInstances #}
module Bug where
import Data.Kind (Type)
type Exp a = a > Type
type family Eval (e :: Exp a) :: a
data OpKind = Conjunction
data Dual (k :: OpKind) :: Exp OpKind
data Map :: (a > Exp b) > [ a ] > Exp [ b ]
type instance Eval (Map f (a ': as)) = Eval (f a) ': Eval (Map f as)
data Big :: [ OpKind ] > Type where
Big :: [ Big ks ] > Big ('Conjunction ': ks)
dualBig :: Big ks > Big (Eval (Map Dual ks))
dualBig = _
instance Semigroup (Big a) where
Big xs <> Big ys = Big (xs <> ys)
instance Monoid (Big ('Conjunction ': ks)) where
mempty = iDontExist
flatten :: Monoid (Big ks) => Big (k ': k ': ks) > Big ks
flatten = undefined
```
Sorry, the example is a bit big but almost any change causes the errors to appear again including the `Monoid` constraint on `flatten`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Type family & typeclass interaction suppresses errors","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"⊥","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["error","family,","message","type","typeclass,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program despite having a hole and an undefined variable `iDontExist` *quietly* fails to compile on 8.4.3 and 8.4.4. It produces errors as expected on 8.6.1 and 8.6.2.\r\n\r\nBy quietly failing, I mean it fails on CLI but without producing any error messages and in GHCI. It just says \"Failed, no modules loaded.\"\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE FlexibleInstances #}\r\n\r\nmodule Bug where\r\n\r\nimport Data.Kind (Type)\r\n\r\ntype Exp a = a > Type\r\ntype family Eval (e :: Exp a) :: a\r\n\r\ndata OpKind = Conjunction\r\n\r\ndata Dual (k :: OpKind) :: Exp OpKind\r\n\r\ndata Map :: (a > Exp b) > [ a ] > Exp [ b ]\r\n\r\ntype instance Eval (Map f (a ': as)) = Eval (f a) ': Eval (Map f as)\r\n\r\ndata Big :: [ OpKind ] > Type where\r\n Big :: [ Big ks ] > Big ('Conjunction ': ks)\r\n\r\ndualBig :: Big ks > Big (Eval (Map Dual ks))\r\ndualBig = _\r\n\r\ninstance Semigroup (Big a) where\r\n Big xs <> Big ys = Big (xs <> ys)\r\n\r\ninstance Monoid (Big ('Conjunction ': ks)) where\r\n mempty = iDontExist\r\n\r\nflatten :: Monoid (Big ks) => Big (k ': k ': ks) > Big ks\r\nflatten = undefined\r\n}}} \r\n\r\nSorry, the example is a bit big but almost any change causes the errors to appear again including the `Monoid` constraint on `flatten`.","type_of_failure":"OtherFailure","blocking":[]} >The following program despite having a hole and an undefined variable `iDontExist` \*quietly\* fails to compile on 8.4.3 and 8.4.4. It produces errors as expected on 8.6.1 and 8.6.2.
By quietly failing, I mean it fails on CLI but without producing any error messages and in GHCI. It just says "Failed, no modules loaded."
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE FlexibleInstances #}
module Bug where
import Data.Kind (Type)
type Exp a = a > Type
type family Eval (e :: Exp a) :: a
data OpKind = Conjunction
data Dual (k :: OpKind) :: Exp OpKind
data Map :: (a > Exp b) > [ a ] > Exp [ b ]
type instance Eval (Map f (a ': as)) = Eval (f a) ': Eval (Map f as)
data Big :: [ OpKind ] > Type where
Big :: [ Big ks ] > Big ('Conjunction ': ks)
dualBig :: Big ks > Big (Eval (Map Dual ks))
dualBig = _
instance Semigroup (Big a) where
Big xs <> Big ys = Big (xs <> ys)
instance Monoid (Big ('Conjunction ': ks)) where
mempty = iDontExist
flatten :: Monoid (Big ks) => Big (k ': k ': ks) > Big ks
flatten = undefined
```
Sorry, the example is a bit big but almost any change causes the errors to appear again including the `Monoid` constraint on `flatten`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.4.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Type family & typeclass interaction suppresses errors","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"⊥","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["error","family,","message","type","typeclass,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program despite having a hole and an undefined variable `iDontExist` *quietly* fails to compile on 8.4.3 and 8.4.4. It produces errors as expected on 8.6.1 and 8.6.2.\r\n\r\nBy quietly failing, I mean it fails on CLI but without producing any error messages and in GHCI. It just says \"Failed, no modules loaded.\"\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE FlexibleInstances #}\r\n\r\nmodule Bug where\r\n\r\nimport Data.Kind (Type)\r\n\r\ntype Exp a = a > Type\r\ntype family Eval (e :: Exp a) :: a\r\n\r\ndata OpKind = Conjunction\r\n\r\ndata Dual (k :: OpKind) :: Exp OpKind\r\n\r\ndata Map :: (a > Exp b) > [ a ] > Exp [ b ]\r\n\r\ntype instance Eval (Map f (a ': as)) = Eval (f a) ': Eval (Map f as)\r\n\r\ndata Big :: [ OpKind ] > Type where\r\n Big :: [ Big ks ] > Big ('Conjunction ': ks)\r\n\r\ndualBig :: Big ks > Big (Eval (Map Dual ks))\r\ndualBig = _\r\n\r\ninstance Semigroup (Big a) where\r\n Big xs <> Big ys = Big (xs <> ys)\r\n\r\ninstance Monoid (Big ('Conjunction ': ks)) where\r\n mempty = iDontExist\r\n\r\nflatten :: Monoid (Big ks) => Big (k ': k ': ks) > Big ks\r\nflatten = undefined\r\n}}} \r\n\r\nSorry, the example is a bit big but almost any change causes the errors to appear again including the `Monoid` constraint on `flatten`.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/15989Adding extra quantified constraints leads to resolution failure20190707T18:02:08ZerorAdding extra quantified constraints leads to resolution failure```
{# LANGUAGE QuantifiedConstraints, FlexibleContexts #}
import Control.Monad.Reader
data T x = T
ok :: ( forall x x'. MonadReader (T x) (m x') )
=> m y Bool
ok = fmap not (pure True)
bad :: ( forall x x'. MonadReader (T x) (m x')
, forall x. Monad (m x) )
=> m y Bool
bad = fmap not (pure True)
better :: ( forall x x'. MonadReader (T x) (m x')
, forall x. Applicative (m x)
, forall x. Functor (m x) )
=> m y Bool
better = fmap not (pure True)
```
`ok` and `better` compile, but `bad` fails to resolve, despite having strictly more in the context than `ok`:
```
BadQC.hs:15:7: error:
• Could not deduce (Functor (m y)) arising from a use of ‘fmap’
from the context: (forall x x'. MonadReader (T x) (m x'),
forall x. Monad (m x))
bound by the type signature for:
bad :: forall (m :: * > * > *) y.
(forall x x'. MonadReader (T x) (m x'), forall x. Monad (m x)) =>
m y Bool
at BadQC.hs:(12,1)(14,15)
• In the expression: fmap not (pure True)
In an equation for ‘bad’: bad = fmap not (pure True)

15  bad = fmap not (pure True)
 ^^^^^^^^^^^^^^^^^^^^
BadQC.hs:15:17: error:
• Could not deduce (Applicative (m y)) arising from a use of ‘pure’
from the context: (forall x x'. MonadReader (T x) (m x'),
forall x. Monad (m x))
bound by the type signature for:
bad :: forall (m :: * > * > *) y.
(forall x x'. MonadReader (T x) (m x'), forall x. Monad (m x)) =>
m y Bool
at BadQC.hs:(12,1)(14,15)
• In the second argument of ‘fmap’, namely ‘(pure True)’
In the expression: fmap not (pure True)
In an equation for ‘bad’: bad = fmap not (pure True)

15  bad = fmap not (pure True)
 ^^^^^^^^^
Failed, no modules loaded.
```
Also:
 `( forall x. MonadReader (T x) (m x), forall x. Monad (m x) )` compiles — the error seems to require two quantified type variables
 `( forall x x'. Monad (m x), forall x. Monad (m x) )` reports an ambiguity error on the constraint, which makes sense; if I turn on `AllowAmbiguousTypes`, it fails with the same error as above — the error isn't caused by MPTCs, and it doesn't matter that `x'` is unused
 `( forall x x'. Foldable (m x), forall x. Monad (m x) )` and `( forall x x'. Monad (m x), forall x. Foldable (m x) )` compile — being in the same class hierarchy matters
 `( forall x x'. Applicative (m x), forall x. Monad (m x) )` fails on `fmap` (but not `pure`) — which is the superclass doesn't seem to matter```
{# LANGUAGE QuantifiedConstraints, FlexibleContexts #}
import Control.Monad.Reader
data T x = T
ok :: ( forall x x'. MonadReader (T x) (m x') )
=> m y Bool
ok = fmap not (pure True)
bad :: ( forall x x'. MonadReader (T x) (m x')
, forall x. Monad (m x) )
=> m y Bool
bad = fmap not (pure True)
better :: ( forall x x'. MonadReader (T x) (m x')
, forall x. Applicative (m x)
, forall x. Functor (m x) )
=> m y Bool
better = fmap not (pure True)
```
`ok` and `better` compile, but `bad` fails to resolve, despite having strictly more in the context than `ok`:
```
BadQC.hs:15:7: error:
• Could not deduce (Functor (m y)) arising from a use of ‘fmap’
from the context: (forall x x'. MonadReader (T x) (m x'),
forall x. Monad (m x))
bound by the type signature for:
bad :: forall (m :: * > * > *) y.
(forall x x'. MonadReader (T x) (m x'), forall x. Monad (m x)) =>
m y Bool
at BadQC.hs:(12,1)(14,15)
• In the expression: fmap not (pure True)
In an equation for ‘bad’: bad = fmap not (pure True)

15  bad = fmap not (pure True)
 ^^^^^^^^^^^^^^^^^^^^
BadQC.hs:15:17: error:
• Could not deduce (Applicative (m y)) arising from a use of ‘pure’
from the context: (forall x x'. MonadReader (T x) (m x'),
forall x. Monad (m x))
bound by the type signature for:
bad :: forall (m :: * > * > *) y.
(forall x x'. MonadReader (T x) (m x'), forall x. Monad (m x)) =>
m y Bool
at BadQC.hs:(12,1)(14,15)
• In the second argument of ‘fmap’, namely ‘(pure True)’
In the expression: fmap not (pure True)
In an equation for ‘bad’: bad = fmap not (pure True)

15  bad = fmap not (pure True)
 ^^^^^^^^^
Failed, no modules loaded.
```
Also:
 `( forall x. MonadReader (T x) (m x), forall x. Monad (m x) )` compiles — the error seems to require two quantified type variables
 `( forall x x'. Monad (m x), forall x. Monad (m x) )` reports an ambiguity error on the constraint, which makes sense; if I turn on `AllowAmbiguousTypes`, it fails with the same error as above — the error isn't caused by MPTCs, and it doesn't matter that `x'` is unused
 `( forall x x'. Foldable (m x), forall x. Monad (m x) )` and `( forall x x'. Monad (m x), forall x. Foldable (m x) )` compile — being in the same class hierarchy matters
 `( forall x x'. Applicative (m x), forall x. Monad (m x) )` fails on `fmap` (but not `pure`) — which is the superclass doesn't seem to matter8.6.3https://gitlab.haskell.org/ghc/ghc//issues/16008GHC HEAD type family regression involving invisible arguments20190707T18:02:02ZRyan ScottGHC HEAD type family regression involving invisible argumentsThe following code compiles on GHC 8.0.2 through 8.6.2:
```hs
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
class C k where
type S :: k > Type
data D :: Type > Type
data SD :: forall a. D a > Type
instance C (D a) where
type S = SD
```
But fails to compile on GHC HEAD (commit 73cce63f33ee80f5095085141df9313ac70d1cfa):
```
$ ~/Software/ghc2/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:3: error:
• Type indexes must match class instance head
Expected: S @(D a)
Actual: S @(D a1)
• In the type instance declaration for ‘S’
In the instance declaration for ‘C (D a)’

15  type S = SD
 ^^^^^^^^^^^
```
This regression prevents [the stitch library](https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.tar.gz) from compiling.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD type family regression involving invisible arguments","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code compiles on GHC 8.0.2 through 8.6.2:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\nclass C k where\r\n type S :: k > Type\r\n\r\ndata D :: Type > Type\r\ndata SD :: forall a. D a > Type\r\n\r\ninstance C (D a) where\r\n type S = SD\r\n}}}\r\n\r\nBut fails to compile on GHC HEAD (commit 73cce63f33ee80f5095085141df9313ac70d1cfa):\r\n\r\n{{{\r\n$ ~/Software/ghc2/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:3: error:\r\n • Type indexes must match class instance head\r\n Expected: S @(D a)\r\n Actual: S @(D a1)\r\n • In the type instance declaration for ‘S’\r\n In the instance declaration for ‘C (D a)’\r\n \r\n15  type S = SD\r\n  ^^^^^^^^^^^\r\n}}}\r\n\r\nThis regression prevents [https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.tar.gz the stitch library] from compiling.","type_of_failure":"OtherFailure","blocking":[]} >The following code compiles on GHC 8.0.2 through 8.6.2:
```hs
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
class C k where
type S :: k > Type
data D :: Type > Type
data SD :: forall a. D a > Type
instance C (D a) where
type S = SD
```
But fails to compile on GHC HEAD (commit 73cce63f33ee80f5095085141df9313ac70d1cfa):
```
$ ~/Software/ghc2/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:15:3: error:
• Type indexes must match class instance head
Expected: S @(D a)
Actual: S @(D a1)
• In the type instance declaration for ‘S’
In the instance declaration for ‘C (D a)’

15  type S = SD
 ^^^^^^^^^^^
```
This regression prevents [the stitch library](https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.tar.gz) from compiling.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEAD type family regression involving invisible arguments","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code compiles on GHC 8.0.2 through 8.6.2:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\nclass C k where\r\n type S :: k > Type\r\n\r\ndata D :: Type > Type\r\ndata SD :: forall a. D a > Type\r\n\r\ninstance C (D a) where\r\n type S = SD\r\n}}}\r\n\r\nBut fails to compile on GHC HEAD (commit 73cce63f33ee80f5095085141df9313ac70d1cfa):\r\n\r\n{{{\r\n$ ~/Software/ghc2/inplace/bin/ghcstage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:15:3: error:\r\n • Type indexes must match class instance head\r\n Expected: S @(D a)\r\n Actual: S @(D a1)\r\n • In the type instance declaration for ‘S’\r\n In the instance declaration for ‘C (D a)’\r\n \r\n15  type S = SD\r\n  ^^^^^^^^^^^\r\n}}}\r\n\r\nThis regression prevents [https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.tar.gz the stitch library] from compiling.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/16033Rankn typechecking regression between GHC 8.4 and 8.620190707T18:01:56ZRyan ScottRankn typechecking regression between GHC 8.4 and 8.6The following program typechecks on GHC 7.0.4 through 8.4.4:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
module Bug where
f :: (forall a. a > forall b. b > c) > ()
f (_ :: forall a. a > forall b. b > c) = ()
```
However, it does not typecheck on GHC 8.6.3:
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:7:4: error:
• Couldn't match type ‘b0 > c1’ with ‘forall b. b > c’
Expected type: a > forall b. b > c
Actual type: a > b0 > c1
• When checking that the pattern signature:
forall a. a > forall b. b > c
fits the type of its context: forall a. a > forall b. b > c1
In the pattern: _ :: forall a. a > forall b. b > c
In an equation for ‘f’:
f (_ :: forall a. a > forall b. b > c) = ()
• Relevant bindings include
f :: (forall a. a > forall b. b > c1) > () (bound at Bug.hs:7:1)

7  f (_ :: forall a. a > forall b. b > c) = ()
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```The following program typechecks on GHC 7.0.4 through 8.4.4:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
module Bug where
f :: (forall a. a > forall b. b > c) > ()
f (_ :: forall a. a > forall b. b > c) = ()
```
However, it does not typecheck on GHC 8.6.3:
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:7:4: error:
• Couldn't match type ‘b0 > c1’ with ‘forall b. b > c’
Expected type: a > forall b. b > c
Actual type: a > b0 > c1
• When checking that the pattern signature:
forall a. a > forall b. b > c
fits the type of its context: forall a. a > forall b. b > c1
In the pattern: _ :: forall a. a > forall b. b > c
In an equation for ‘f’:
f (_ :: forall a. a > forall b. b > c) = ()
• Relevant bindings include
f :: (forall a. a > forall b. b > c1) > () (bound at Bug.hs:7:1)

7  f (_ :: forall a. a > forall b. b > c) = ()
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```8.8.1https://gitlab.haskell.org/ghc/ghc//issues/16059checkValidType is defeated by a type synonym20200714T17:14:18ZRyan ScottcheckValidType is defeated by a type synonymGHC throws an error message on this code:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
module Bug where
f :: forall b (a :: Eq b => b). Int
f = 42
```
```
$ ~/Software/ghc/inplace/bin/ghcstage2 interactive Bug.hs
GHCi, version 8.7.20181211: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:6:6: error:
• Illegal constraint in a kind: Eq b => b
• In the type signature: f :: forall b (a :: Eq b => b). Int

6  f :: forall b (a :: Eq b => b). Int
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
However, it does //not// throw an error message if you hide `Eq b => b` behind a type synonym, as the following variant of the code above is accepted:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
module Bug where
type Foo b = Eq b => b
f :: forall b (a :: Foo b). Int
f = 42
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"checkValidType is defeated by a type synonym","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC throws an error message on this code:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\nmodule Bug where\r\n\r\nf :: forall b (a :: Eq b => b). Int\r\nf = 42\r\n}}}\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 interactive Bug.hs\r\nGHCi, version 8.7.20181211: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:6:6: error:\r\n • Illegal constraint in a kind: Eq b => b\r\n • In the type signature: f :: forall b (a :: Eq b => b). Int\r\n \r\n6  f :: forall b (a :: Eq b => b). Int\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nHowever, it does //not// throw an error message if you hide `Eq b => b` behind a type synonym, as the following variant of the code above is accepted:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\nmodule Bug where\r\n\r\ntype Foo b = Eq b => b\r\n\r\nf :: forall b (a :: Foo b). Int\r\nf = 42\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >GHC throws an error message on this code:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
module Bug where
f :: forall b (a :: Eq b => b). Int
f = 42
```
```
$ ~/Software/ghc/inplace/bin/ghcstage2 interactive Bug.hs
GHCi, version 8.7.20181211: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:6:6: error:
• Illegal constraint in a kind: Eq b => b
• In the type signature: f :: forall b (a :: Eq b => b). Int

6  f :: forall b (a :: Eq b => b). Int
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
However, it does //not// throw an error message if you hide `Eq b => b` behind a type synonym, as the following variant of the code above is accepted:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
module Bug where
type Foo b = Eq b => b
f :: forall b (a :: Foo b). Int
f = 42
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"checkValidType is defeated by a type synonym","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC throws an error message on this code:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\nmodule Bug where\r\n\r\nf :: forall b (a :: Eq b => b). Int\r\nf = 42\r\n}}}\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghcstage2 interactive Bug.hs\r\nGHCi, version 8.7.20181211: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:6:6: error:\r\n • Illegal constraint in a kind: Eq b => b\r\n • In the type signature: f :: forall b (a :: Eq b => b). Int\r\n \r\n6  f :: forall b (a :: Eq b => b). Int\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}\r\n\r\nHowever, it does //not// throw an error message if you hide `Eq b => b` behind a type synonym, as the following variant of the code above is accepted:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\nmodule Bug where\r\n\r\ntype Foo b = Eq b => b\r\n\r\nf :: forall b (a :: Foo b). Int\r\nf = 42\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/16113T14740 fails in debugged compiler20190707T18:01:24ZBen GamariT14740 fails in debugged compiler```patch
 parser/should_fail/T14740.run/T14740.stderr.normalised 20181230 16:06:27.120170052 +0000
+++ parser/should_fail/T14740.run/T14740.comp.stderr.normalised 20181230 16:06:27.120170052 +0000
@@ 1,4 +1,5 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 8.7.20181230 for x86_64unknownlinux):
+ ASSERT failed! file compiler/types/TyCoRep.hs, line 911
T14740.hs:5:7:
 Expecting a lifted type, but ‘(# #)’ is unlifted
 In the type signature: x :: ((# #)) => ()
+Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  goldfire, simonpj 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"T14740 fails in debugged compiler","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire","simonpj"],"type":"Bug","description":"{{{#!patch\r\n parser/should_fail/T14740.run/T14740.stderr.normalised\t20181230 16:06:27.120170052 +0000\r\n+++ parser/should_fail/T14740.run/T14740.comp.stderr.normalised\t20181230 16:06:27.120170052 +0000\r\n@@ 1,4 +1,5 @@\r\n+ghc: panic! (the 'impossible' happened)\r\n+ (GHC version 8.7.20181230 for x86_64unknownlinux):\r\n+\tASSERT failed! file compiler/types/TyCoRep.hs, line 911\r\n \r\nT14740.hs:5:7:\r\n Expecting a lifted type, but ‘(# #)’ is unlifted\r\n In the type signature: x :: ((# #)) => ()\r\n+Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >```patch
 parser/should_fail/T14740.run/T14740.stderr.normalised 20181230 16:06:27.120170052 +0000
+++ parser/should_fail/T14740.run/T14740.comp.stderr.normalised 20181230 16:06:27.120170052 +0000
@@ 1,4 +1,5 @@
+ghc: panic! (the 'impossible' happened)
+ (GHC version 8.7.20181230 for x86_64unknownlinux):
+ ASSERT failed! file compiler/types/TyCoRep.hs, line 911
T14740.hs:5:7:
 Expecting a lifted type, but ‘(# #)’ is unlifted
 In the type signature: x :: ((# #)) => ()
+Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  high 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  goldfire, simonpj 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"T14740 fails in debugged compiler","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire","simonpj"],"type":"Bug","description":"{{{#!patch\r\n parser/should_fail/T14740.run/T14740.stderr.normalised\t20181230 16:06:27.120170052 +0000\r\n+++ parser/should_fail/T14740.run/T14740.comp.stderr.normalised\t20181230 16:06:27.120170052 +0000\r\n@@ 1,4 +1,5 @@\r\n+ghc: panic! (the 'impossible' happened)\r\n+ (GHC version 8.7.20181230 for x86_64unknownlinux):\r\n+\tASSERT failed! file compiler/types/TyCoRep.hs, line 911\r\n \r\nT14740.hs:5:7:\r\n Expecting a lifted type, but ‘(# #)’ is unlifted\r\n In the type signature: x :: ((# #)) => ()\r\n+Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/16115Missing associated type instance not reported with error20200123T19:38:55ZDavid FeuerMissing associated type instance not reported with errorI noticed [this SO question](https://stackoverflow.com/questions/53987924/haskellcouldntmatchexpectedtypeitemnatwithactualtype) was caused by a warning disappearing as a result of the error it caused.
```hs
{# language TypeFamilies, DataKinds #}
module NoWarning where
data Nat = Zero  Succ Nat deriving Show
class FromList a where
type Item a :: *
fromList :: [Item a] > a
instance FromList Nat where
fromList [] = Zero
fromList (a:as) = Succ (fromList as :: Nat)
fish :: Nat
fish = fromList [(),(),()]
```
If you delete `fish`, you get a nice warning:
```
NoWarning.hs:8:1: warning: [Wmissingmethods]
• No explicit associated type or default declaration for ‘Item’
• In the instance declaration for ‘FromList Nat’

8  instance FromList Nat where
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^...
```
But with `fish`, all you get is
```
NoWarning.hs:13:18: error:
• Couldn't match expected type ‘Item Nat’ with actual type ‘()’
• In the expression: ()
In the first argument of ‘fromList’, namely ‘[(), (), ()]’
In the expression: fromList [(), (), ()]

13  fish = fromList [(),(),()]

```
That warning is the proper explanation of the problem, and it's just missing!
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Missing associated type instance not reported with error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I noticed [https://stackoverflow.com/questions/53987924/haskellcouldntmatchexpectedtypeitemnatwithactualtype this SO question] was caused by a warning disappearing as a result of the error it caused.\r\n\r\n{{{#!hs\r\n{# language TypeFamilies, DataKinds #}\r\nmodule NoWarning where\r\ndata Nat = Zero  Succ Nat deriving Show\r\nclass FromList a where\r\n type Item a :: *\r\n fromList :: [Item a] > a\r\n\r\ninstance FromList Nat where\r\n fromList [] = Zero\r\n fromList (a:as) = Succ (fromList as :: Nat)\r\n\r\nfish :: Nat\r\nfish = fromList [(),(),()]\r\n}}}\r\n\r\nIf you delete `fish`, you get a nice warning:\r\n\r\n{{{\r\nNoWarning.hs:8:1: warning: [Wmissingmethods]\r\n • No explicit associated type or default declaration for ‘Item’\r\n • In the instance declaration for ‘FromList Nat’\r\n \r\n8  instance FromList Nat where\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n\r\n}}}\r\n\r\nBut with `fish`, all you get is\r\n\r\n{{{\r\nNoWarning.hs:13:18: error:\r\n • Couldn't match expected type ‘Item Nat’ with actual type ‘()’\r\n • In the expression: ()\r\n In the first argument of ‘fromList’, namely ‘[(), (), ()]’\r\n In the expression: fromList [(), (), ()]\r\n \r\n13  fish = fromList [(),(),()]\r\n  \r\n}}}\r\n\r\nThat warning is the proper explanation of the problem, and it's just missing!","type_of_failure":"OtherFailure","blocking":[]} >I noticed [this SO question](https://stackoverflow.com/questions/53987924/haskellcouldntmatchexpectedtypeitemnatwithactualtype) was caused by a warning disappearing as a result of the error it caused.
```hs
{# language TypeFamilies, DataKinds #}
module NoWarning where
data Nat = Zero  Succ Nat deriving Show
class FromList a where
type Item a :: *
fromList :: [Item a] > a
instance FromList Nat where
fromList [] = Zero
fromList (a:as) = Succ (fromList as :: Nat)
fish :: Nat
fish = fromList [(),(),()]
```
If you delete `fish`, you get a nice warning:
```
NoWarning.hs:8:1: warning: [Wmissingmethods]
• No explicit associated type or default declaration for ‘Item’
• In the instance declaration for ‘FromList Nat’

8  instance FromList Nat where
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^...
```
But with `fish`, all you get is
```
NoWarning.hs:13:18: error:
• Couldn't match expected type ‘Item Nat’ with actual type ‘()’
• In the expression: ()
In the first argument of ‘fromList’, namely ‘[(), (), ()]’
In the expression: fromList [(), (), ()]

13  fish = fromList [(),(),()]

```
That warning is the proper explanation of the problem, and it's just missing!
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Missing associated type instance not reported with error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I noticed [https://stackoverflow.com/questions/53987924/haskellcouldntmatchexpectedtypeitemnatwithactualtype this SO question] was caused by a warning disappearing as a result of the error it caused.\r\n\r\n{{{#!hs\r\n{# language TypeFamilies, DataKinds #}\r\nmodule NoWarning where\r\ndata Nat = Zero  Succ Nat deriving Show\r\nclass FromList a where\r\n type Item a :: *\r\n fromList :: [Item a] > a\r\n\r\ninstance FromList Nat where\r\n fromList [] = Zero\r\n fromList (a:as) = Succ (fromList as :: Nat)\r\n\r\nfish :: Nat\r\nfish = fromList [(),(),()]\r\n}}}\r\n\r\nIf you delete `fish`, you get a nice warning:\r\n\r\n{{{\r\nNoWarning.hs:8:1: warning: [Wmissingmethods]\r\n • No explicit associated type or default declaration for ‘Item’\r\n • In the instance declaration for ‘FromList Nat’\r\n \r\n8  instance FromList Nat where\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n\r\n}}}\r\n\r\nBut with `fish`, all you get is\r\n\r\n{{{\r\nNoWarning.hs:13:18: error:\r\n • Couldn't match expected type ‘Item Nat’ with actual type ‘()’\r\n • In the expression: ()\r\n In the first argument of ‘fromList’, namely ‘[(), (), ()]’\r\n In the expression: fromList [(), (), ()]\r\n \r\n13  fish = fromList [(),(),()]\r\n  \r\n}}}\r\n\r\nThat warning is the proper explanation of the problem, and it's just missing!","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/16127Panic: piResultTys1 in compiler/types/Type.hs:1022:520210504T09:33:33ZSerge KosyrevPanic: piResultTys1 in compiler/types/Type.hs:1022:5I apologize in advance for a nonminimised repro.
The panic (with a small `ddumptctrace` excerpt, but full log also attached):
```
tcPolyExprNC
Check{Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])}
tcSkolemise
tcInferId
voc_a4TB2 :: Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
tcCheckId
voc_a4TB2
Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
Check{Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])}
tcWrapResult
Actual: Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
Expected: Check{Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])}
tc_sub_type_ds
ty_actual = Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
ty_expected = Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])
deeply_instantiate final subst
origin: arising from a use of ‘voc_a4TB2’
type: Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
new type: Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
subst: [TCvSubst
In scope: InScope {i_a4TMf}
Type env: []
Co env: []]
u_tys
tclvl 2
Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
~
Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])
arising from a type equality Vocab
i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
~
Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])
<no location info>: error:
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.1 for x86_64unknownlinux):
piResultTys1
*
[i_a4TNv[tau:2], Present * k_a4TNy[tau:2] i_a4TNv[tau:2]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1022:5 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Repro (requires Nix & some download time, provides hard repro guarantees in return):
```
$ git clone https://github.com/deepfire/holotype
$ cd holotype
$ git reset hard 5c80e9239a3c18d67106920db8f832abc7bd9a93
$ nixshell
[nixshell:~/holotype]$ cabal build lib:holotype
```I apologize in advance for a nonminimised repro.
The panic (with a small `ddumptctrace` excerpt, but full log also attached):
```
tcPolyExprNC
Check{Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])}
tcSkolemise
tcInferId
voc_a4TB2 :: Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
tcCheckId
voc_a4TB2
Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
Check{Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])}
tcWrapResult
Actual: Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
Expected: Check{Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])}
tc_sub_type_ds
ty_actual = Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
ty_expected = Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])
deeply_instantiate final subst
origin: arising from a use of ‘voc_a4TB2’
type: Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
new type: Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
subst: [TCvSubst
In scope: InScope {i_a4TMf}
Type env: []
Co env: []]
u_tys
tclvl 2
Vocab i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
~
Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])
arising from a type equality Vocab
i_a4TMf[sk:1] (Present * * i_a4TMf[sk:1])
~
Vocab
*
(k_a4TNy[tau:2] > Constraint)
i_a4TNv[tau:2]
(Present * k_a4TNy[tau:2] i_a4TNv[tau:2])
<no location info>: error:
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.1 for x86_64unknownlinux):
piResultTys1
*
[i_a4TNv[tau:2], Present * k_a4TNy[tau:2] i_a4TNv[tau:2]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1022:5 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Repro (requires Nix & some download time, provides hard repro guarantees in return):
```
$ git clone https://github.com/deepfire/holotype
$ cd holotype
$ git reset hard 5c80e9239a3c18d67106920db8f832abc7bd9a93
$ nixshell
[nixshell:~/holotype]$ cabal build lib:holotype
```https://gitlab.haskell.org/ghc/ghc//issues/16141StrictData and TypeFamilies regression20190714T10:09:05ZRyan ScottStrictData and TypeFamilies regressionThe credit goes to wuzzeb for originally discovering this bug [here](https://www.reddit.com/r/haskell/comments/ad9a7k/strictdata_typefamilies_and_ghc_86/). I've minimized their test case slightly below:
```hs
{# LANGUAGE StrictData #}
{# LANGUAGE TypeFamilies #}
module Bug where
data family T
newtype instance T = MkT Int deriving Eq
```
With optimization enabled, this program compiles with GHC 8.0.2 through 8.4.4, but not with 8.6.3 or HEAD:
```
$ /opt/ghc/8.4.4/bin/ghc fforcerecomp O Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
$ /opt/ghc/8.6.3/bin/ghc fforcerecomp O Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:6:39: error:
• Couldn't match a lifted type with an unlifted type
arising from the coercion of the method ‘==’
from type ‘GHC.Prim.Int# > GHC.Prim.Int# > Bool’
to type ‘T > T > Bool’
• When deriving the instance for (Eq T)

6  newtype instance T = MkT Int deriving Eq
 ^^
```
Based on the error message, it appears as if GHC mistakenly believes that the representation type of the `T` instance is `Int#`, rather than `Int`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"StrictData and TypeFamilies regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The credit goes to wuzzeb for originally discovering this bug [https://www.reddit.com/r/haskell/comments/ad9a7k/strictdata_typefamilies_and_ghc_86/ here]. I've minimized their test case slightly below:\r\n\r\n{{{#!hs\r\n{# LANGUAGE StrictData #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\ndata family T\r\nnewtype instance T = MkT Int deriving Eq\r\n}}}\r\n\r\nWith optimization enabled, this program compiles with GHC 8.0.2 through 8.4.4, but not with 8.6.3 or HEAD:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.4/bin/ghc fforcerecomp O Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\n$ /opt/ghc/8.6.3/bin/ghc fforcerecomp O Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:6:39: error:\r\n • Couldn't match a lifted type with an unlifted type\r\n arising from the coercion of the method ‘==’\r\n from type ‘GHC.Prim.Int# > GHC.Prim.Int# > Bool’\r\n to type ‘T > T > Bool’\r\n • When deriving the instance for (Eq T)\r\n \r\n6  newtype instance T = MkT Int deriving Eq\r\n  ^^\r\n}}}\r\n\r\nBased on the error message, it appears as if GHC mistakenly believes that the representation type of the `T` instance is `Int#`, rather than `Int`.","type_of_failure":"OtherFailure","blocking":[]} >The credit goes to wuzzeb for originally discovering this bug [here](https://www.reddit.com/r/haskell/comments/ad9a7k/strictdata_typefamilies_and_ghc_86/). I've minimized their test case slightly below:
```hs
{# LANGUAGE StrictData #}
{# LANGUAGE TypeFamilies #}
module Bug where
data family T
newtype instance T = MkT Int deriving Eq
```
With optimization enabled, this program compiles with GHC 8.0.2 through 8.4.4, but not with 8.6.3 or HEAD:
```
$ /opt/ghc/8.4.4/bin/ghc fforcerecomp O Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
$ /opt/ghc/8.6.3/bin/ghc fforcerecomp O Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:6:39: error:
• Couldn't match a lifted type with an unlifted type
arising from the coercion of the method ‘==’
from type ‘GHC.Prim.Int# > GHC.Prim.Int# > Bool’
to type ‘T > T > Bool’
• When deriving the instance for (Eq T)

6  newtype instance T = MkT Int deriving Eq
 ^^
```
Based on the error message, it appears as if GHC mistakenly believes that the representation type of the `T` instance is `Int#`, rather than `Int`.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"StrictData and TypeFamilies regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The credit goes to wuzzeb for originally discovering this bug [https://www.reddit.com/r/haskell/comments/ad9a7k/strictdata_typefamilies_and_ghc_86/ here]. I've minimized their test case slightly below:\r\n\r\n{{{#!hs\r\n{# LANGUAGE StrictData #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\ndata family T\r\nnewtype instance T = MkT Int deriving Eq\r\n}}}\r\n\r\nWith optimization enabled, this program compiles with GHC 8.0.2 through 8.4.4, but not with 8.6.3 or HEAD:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.4/bin/ghc fforcerecomp O Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\n$ /opt/ghc/8.6.3/bin/ghc fforcerecomp O Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:6:39: error:\r\n • Couldn't match a lifted type with an unlifted type\r\n arising from the coercion of the method ‘==’\r\n from type ‘GHC.Prim.Int# > GHC.Prim.Int# > Bool’\r\n to type ‘T > T > Bool’\r\n • When deriving the instance for (Eq T)\r\n \r\n6  newtype instance T = MkT Int deriving Eq\r\n  ^^\r\n}}}\r\n\r\nBased on the error message, it appears as if GHC mistakenly believes that the representation type of the `T` instance is `Int#`, rather than `Int`.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/16154Wredundantconstraints: False positive20190707T18:01:16ZFumiaki KinoshitaWredundantconstraints: False positiveGHC produces a warning for the attached source, although it won't compile if the suggested constraints are removed:
```
redundantconstraint.hs:24:1: warning: [Wredundantconstraints]
• Redundant constraints: (KnownNat 42, Capture 42 p)
• In the type signature for:
foo :: Foo 42

24  foo :: Foo 42
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Wredundantconstraints: False positive","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC produces a warning for the attached source, although it won't compile if the suggested constraints are removed:\r\n\r\n{{{\r\nredundantconstraint.hs:24:1: warning: [Wredundantconstraints]\r\n • Redundant constraints: (KnownNat 42, Capture 42 p)\r\n • In the type signature for:\r\n foo :: Foo 42\r\n \r\n24  foo :: Foo 42\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} >GHC produces a warning for the attached source, although it won't compile if the suggested constraints are removed:
```
redundantconstraint.hs:24:1: warning: [Wredundantconstraints]
• Redundant constraints: (KnownNat 42, Capture 42 p)
• In the type signature for:
foo :: Foo 42

24  foo :: Foo 42
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Wredundantconstraints: False positive","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC produces a warning for the attached source, although it won't compile if the suggested constraints are removed:\r\n\r\n{{{\r\nredundantconstraint.hs:24:1: warning: [Wredundantconstraints]\r\n • Redundant constraints: (KnownNat 42, Capture 42 p)\r\n • In the type signature for:\r\n foo :: Foo 42\r\n \r\n24  foo :: Foo 42\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/16184GHC said to report a bug20190707T18:01:03ZTheKing01GHC said to report a bugI tried to run
```hs
{# LANGUAGE Rank2Types, PartialTypeSignatures #}
import Control.Monad
newtype Search b = Search {optimum :: forall a. Ord a => (b > a) > b}
instance Monad Search where
return a = Search $ const a
Search ma >>= f = Search $ \p >
optimum (f (ma (\a > p (optimum (f a) p)))) p
instance Functor Search where
fmap = liftM
instance Applicative Search where
pure = return
(<*>) = ap
pair a b = Search $ \p > if p a >= p b then a else b
toList s = igo [] where
igo ls = let x = optimum s (\x' > x' `notElem` ls) in if x `elem` ls then ls else igo (x:ls)
cantor :: Search (Integer > Bool)
cantor = let
igo :: _
igo p n = q n (optimum cantor $ q n) where
q n a = p undefined
in Search igo
main = return ()
```
When run, it said
```
source_file.hs:24:5:
No instance for (Ord a)
When checking that ‘igo’ has the specified type
igo :: forall t a t1. (t > a) > t1 > a
Probable cause: the inferred type is ambiguous
In the expression:
let
igo :: _
igo p n
= q n (optimum cantor $ q n)
where
q n a = ...
in Search igo
In an equation for ‘cantor’:
cantor
= let
igo :: _
igo p n
= q n (optimum cantor $ q n)
where
...
in Search igo
source_file.hs:26:15:
Couldn't match type ‘t’ with ‘Integer > Bool’
‘t’ is untouchable
inside the constraints (Ord a1)
bound by a type expected by the context:
Ord a1 => ((Integer > Bool) > a1) > Integer > Bool
at source_file.hs:26:817ghc: panic! (the 'impossible' happened)
(GHC version 7.10.3 for x86_64unknownlinux):
No skolem info: t_aU3[sk]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Since it said to report a bug, I am.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  7.10.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC said to report a bug","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":["panic,","skolem"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I tried to run\r\n{{{#!hs\r\n{# LANGUAGE Rank2Types, PartialTypeSignatures #}\r\nimport Control.Monad\r\nnewtype Search b = Search {optimum :: forall a. Ord a => (b > a) > b}\r\n\r\ninstance Monad Search where\r\n return a = Search $ const a\r\n Search ma >>= f = Search $ \\p >\r\n optimum (f (ma (\\a > p (optimum (f a) p)))) p\r\n\r\ninstance Functor Search where\r\n fmap = liftM\r\n\r\ninstance Applicative Search where\r\n pure = return\r\n (<*>) = ap\r\n\r\npair a b = Search $ \\p > if p a >= p b then a else b\r\ntoList s = igo [] where\r\n igo ls = let x = optimum s (\\x' > x' `notElem` ls) in if x `elem` ls then ls else igo (x:ls)\r\n\r\ncantor :: Search (Integer > Bool)\r\ncantor = let\r\n igo :: _\r\n igo p n = q n (optimum cantor $ q n) where\r\n q n a = p undefined\r\n in Search igo\r\n\r\nmain = return ()\r\n}}}\r\n\r\nWhen run, it said\r\n\r\n{{{\r\nsource_file.hs:24:5:\r\n No instance for (Ord a)\r\n When checking that ‘igo’ has the specified type\r\n igo :: forall t a t1. (t > a) > t1 > a\r\n Probable cause: the inferred type is ambiguous\r\n In the expression:\r\n let\r\n igo :: _\r\n igo p n\r\n = q n (optimum cantor $ q n)\r\n where\r\n q n a = ...\r\n in Search igo\r\n In an equation for ‘cantor’:\r\n cantor\r\n = let\r\n igo :: _\r\n igo p n\r\n = q n (optimum cantor $ q n)\r\n where\r\n ...\r\n in Search igo\r\n\r\nsource_file.hs:26:15:\r\n Couldn't match type ‘t’ with ‘Integer > Bool’\r\n ‘t’ is untouchable\r\n inside the constraints (Ord a1)\r\n bound by a type expected by the context:\r\n Ord a1 => ((Integer > Bool) > a1) > Integer > Bool\r\n at source_file.hs:26:817ghc: panic! (the 'impossible' happened)\r\n (GHC version 7.10.3 for x86_64unknownlinux):\r\n\tNo skolem info: t_aU3[sk]\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nSince it said to report a bug, I am.","type_of_failure":"OtherFailure","blocking":[]} >I tried to run
```hs
{# LANGUAGE Rank2Types, PartialTypeSignatures #}
import Control.Monad
newtype Search b = Search {optimum :: forall a. Ord a => (b > a) > b}
instance Monad Search where
return a = Search $ const a
Search ma >>= f = Search $ \p >
optimum (f (ma (\a > p (optimum (f a) p)))) p
instance Functor Search where
fmap = liftM
instance Applicative Search where
pure = return
(<*>) = ap
pair a b = Search $ \p > if p a >= p b then a else b
toList s = igo [] where
igo ls = let x = optimum s (\x' > x' `notElem` ls) in if x `elem` ls then ls else igo (x:ls)
cantor :: Search (Integer > Bool)
cantor = let
igo :: _
igo p n = q n (optimum cantor $ q n) where
q n a = p undefined
in Search igo
main = return ()
```
When run, it said
```
source_file.hs:24:5:
No instance for (Ord a)
When checking that ‘igo’ has the specified type
igo :: forall t a t1. (t > a) > t1 > a
Probable cause: the inferred type is ambiguous
In the expression:
let
igo :: _
igo p n
= q n (optimum cantor $ q n)
where
q n a = ...
in Search igo
In an equation for ‘cantor’:
cantor
= let
igo :: _
igo p n
= q n (optimum cantor $ q n)
where
...
in Search igo
source_file.hs:26:15:
Couldn't match type ‘t’ with ‘Integer > Bool’
‘t’ is untouchable
inside the constraints (Ord a1)
bound by a type expected by the context:
Ord a1 => ((Integer > Bool) > a1) > Integer > Bool
at source_file.hs:26:817ghc: panic! (the 'impossible' happened)
(GHC version 7.10.3 for x86_64unknownlinux):
No skolem info: t_aU3[sk]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Since it said to report a bug, I am.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  7.10.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC said to report a bug","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":["panic,","skolem"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I tried to run\r\n{{{#!hs\r\n{# LANGUAGE Rank2Types, PartialTypeSignatures #}\r\nimport Control.Monad\r\nnewtype Search b = Search {optimum :: forall a. Ord a => (b > a) > b}\r\n\r\ninstance Monad Search where\r\n return a = Search $ const a\r\n Search ma >>= f = Search $ \\p >\r\n optimum (f (ma (\\a > p (optimum (f a) p)))) p\r\n\r\ninstance Functor Search where\r\n fmap = liftM\r\n\r\ninstance Applicative Search where\r\n pure = return\r\n (<*>) = ap\r\n\r\npair a b = Search $ \\p > if p a >= p b then a else b\r\ntoList s = igo [] where\r\n igo ls = let x = optimum s (\\x' > x' `notElem` ls) in if x `elem` ls then ls else igo (x:ls)\r\n\r\ncantor :: Search (Integer > Bool)\r\ncantor = let\r\n igo :: _\r\n igo p n = q n (optimum cantor $ q n) where\r\n q n a = p undefined\r\n in Search igo\r\n\r\nmain = return ()\r\n}}}\r\n\r\nWhen run, it said\r\n\r\n{{{\r\nsource_file.hs:24:5:\r\n No instance for (Ord a)\r\n When checking that ‘igo’ has the specified type\r\n igo :: forall t a t1. (t > a) > t1 > a\r\n Probable cause: the inferred type is ambiguous\r\n In the expression:\r\n let\r\n igo :: _\r\n igo p n\r\n = q n (optimum cantor $ q n)\r\n where\r\n q n a = ...\r\n in Search igo\r\n In an equation for ‘cantor’:\r\n cantor\r\n = let\r\n igo :: _\r\n igo p n\r\n = q n (optimum cantor $ q n)\r\n where\r\n ...\r\n in Search igo\r\n\r\nsource_file.hs:26:15:\r\n Couldn't match type ‘t’ with ‘Integer > Bool’\r\n ‘t’ is untouchable\r\n inside the constraints (Ord a1)\r\n bound by a type expected by the context:\r\n Ord a1 => ((Integer > Bool) > a1) > Integer > Bool\r\n at source_file.hs:26:817ghc: panic! (the 'impossible' happened)\r\n (GHC version 7.10.3 for x86_64unknownlinux):\r\n\tNo skolem info: t_aU3[sk]\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nSince it said to report a bug, I am.","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/16188GHC HEADonly panic (buildKindCoercion)20190707T18:01:01ZRyan ScottGHC HEADonly panic (buildKindCoercion)The following program compiles without issue on GHC 8.6.3:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE GADTs #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind (Type)
import Data.Type.Bool (type (&&))
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: a ~> b) (x :: a) :: b
data family Sing :: forall k. k > Type
data instance Sing :: Bool > Type where
SFalse :: Sing False
STrue :: Sing True
(%&&) :: forall (x :: Bool) (y :: Bool).
Sing x > Sing y > Sing (x && y)
SFalse %&& _ = SFalse
STrue %&& a = a
data RegExp :: Type > Type where
App :: RegExp t > RegExp t > RegExp t
data instance Sing :: forall t. RegExp t > Type where
SApp :: Sing re1 > Sing re2 > Sing (App re1 re2)
data ReNotEmptySym0 :: forall t. RegExp t ~> Bool
type instance Apply ReNotEmptySym0 r = ReNotEmpty r
type family ReNotEmpty (r :: RegExp t) :: Bool where
ReNotEmpty (App re1 re2) = ReNotEmpty re1 && ReNotEmpty re2
sReNotEmpty :: forall t (r :: RegExp t).
Sing r > Sing (Apply ReNotEmptySym0 r :: Bool)
sReNotEmpty (SApp sre1 sre2) = sReNotEmpty sre1 %&& sReNotEmpty sre2
blah :: forall (t :: Type) (re :: RegExp t).
Sing re > ()
blah (SApp sre1 sre2)
= case (sReNotEmpty sre1, sReNotEmpty sre2) of
(STrue, STrue) > ()
```
However, it panics on GHC HEAD:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20190114 for x86_64unknownlinux):
buildKindCoercion
Any
ReNotEmpty re2_a1hm
Bool
t_a1hg
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:2427:9 in ghc:Coercion
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEADonly panic (buildKindCoercion)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program compiles without issue on GHC 8.6.3:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind (Type)\r\nimport Data.Type.Bool (type (&&))\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: a ~> b) (x :: a) :: b\r\ndata family Sing :: forall k. k > Type\r\n\r\ndata instance Sing :: Bool > Type where\r\n SFalse :: Sing False\r\n STrue :: Sing True\r\n\r\n(%&&) :: forall (x :: Bool) (y :: Bool).\r\n Sing x > Sing y > Sing (x && y)\r\nSFalse %&& _ = SFalse\r\nSTrue %&& a = a\r\n\r\ndata RegExp :: Type > Type where\r\n App :: RegExp t > RegExp t > RegExp t\r\n\r\ndata instance Sing :: forall t. RegExp t > Type where\r\n SApp :: Sing re1 > Sing re2 > Sing (App re1 re2)\r\n\r\ndata ReNotEmptySym0 :: forall t. RegExp t ~> Bool\r\ntype instance Apply ReNotEmptySym0 r = ReNotEmpty r\r\n\r\ntype family ReNotEmpty (r :: RegExp t) :: Bool where\r\n ReNotEmpty (App re1 re2) = ReNotEmpty re1 && ReNotEmpty re2\r\n\r\nsReNotEmpty :: forall t (r :: RegExp t).\r\n Sing r > Sing (Apply ReNotEmptySym0 r :: Bool)\r\nsReNotEmpty (SApp sre1 sre2) = sReNotEmpty sre1 %&& sReNotEmpty sre2\r\n\r\nblah :: forall (t :: Type) (re :: RegExp t).\r\n Sing re > ()\r\nblah (SApp sre1 sre2)\r\n = case (sReNotEmpty sre1, sReNotEmpty sre2) of\r\n (STrue, STrue) > ()\r\n}}}\r\n\r\nHowever, it panics on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20190114 for x86_64unknownlinux):\r\n buildKindCoercion\r\n Any\r\n ReNotEmpty re2_a1hm\r\n Bool\r\n t_a1hg\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:2427:9 in ghc:Coercion\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program compiles without issue on GHC 8.6.3:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE GADTs #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeOperators #}
{# LANGUAGE UndecidableInstances #}
module Bug where
import Data.Kind (Type)
import Data.Type.Bool (type (&&))
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: a ~> b) (x :: a) :: b
data family Sing :: forall k. k > Type
data instance Sing :: Bool > Type where
SFalse :: Sing False
STrue :: Sing True
(%&&) :: forall (x :: Bool) (y :: Bool).
Sing x > Sing y > Sing (x && y)
SFalse %&& _ = SFalse
STrue %&& a = a
data RegExp :: Type > Type where
App :: RegExp t > RegExp t > RegExp t
data instance Sing :: forall t. RegExp t > Type where
SApp :: Sing re1 > Sing re2 > Sing (App re1 re2)
data ReNotEmptySym0 :: forall t. RegExp t ~> Bool
type instance Apply ReNotEmptySym0 r = ReNotEmpty r
type family ReNotEmpty (r :: RegExp t) :: Bool where
ReNotEmpty (App re1 re2) = ReNotEmpty re1 && ReNotEmpty re2
sReNotEmpty :: forall t (r :: RegExp t).
Sing r > Sing (Apply ReNotEmptySym0 r :: Bool)
sReNotEmpty (SApp sre1 sre2) = sReNotEmpty sre1 %&& sReNotEmpty sre2
blah :: forall (t :: Type) (re :: RegExp t).
Sing re > ()
blah (SApp sre1 sre2)
= case (sReNotEmpty sre1, sReNotEmpty sre2) of
(STrue, STrue) > ()
```
However, it panics on GHC HEAD:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20190114 for x86_64unknownlinux):
buildKindCoercion
Any
ReNotEmpty re2_a1hm
Bool
t_a1hg
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/types/Coercion.hs:2427:9 in ghc:Coercion
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEADonly panic (buildKindCoercion)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program compiles without issue on GHC 8.6.3:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeOperators #}\r\n{# LANGUAGE UndecidableInstances #}\r\nmodule Bug where\r\n\r\nimport Data.Kind (Type)\r\nimport Data.Type.Bool (type (&&))\r\n\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: a ~> b) (x :: a) :: b\r\ndata family Sing :: forall k. k > Type\r\n\r\ndata instance Sing :: Bool > Type where\r\n SFalse :: Sing False\r\n STrue :: Sing True\r\n\r\n(%&&) :: forall (x :: Bool) (y :: Bool).\r\n Sing x > Sing y > Sing (x && y)\r\nSFalse %&& _ = SFalse\r\nSTrue %&& a = a\r\n\r\ndata RegExp :: Type > Type where\r\n App :: RegExp t > RegExp t > RegExp t\r\n\r\ndata instance Sing :: forall t. RegExp t > Type where\r\n SApp :: Sing re1 > Sing re2 > Sing (App re1 re2)\r\n\r\ndata ReNotEmptySym0 :: forall t. RegExp t ~> Bool\r\ntype instance Apply ReNotEmptySym0 r = ReNotEmpty r\r\n\r\ntype family ReNotEmpty (r :: RegExp t) :: Bool where\r\n ReNotEmpty (App re1 re2) = ReNotEmpty re1 && ReNotEmpty re2\r\n\r\nsReNotEmpty :: forall t (r :: RegExp t).\r\n Sing r > Sing (Apply ReNotEmptySym0 r :: Bool)\r\nsReNotEmpty (SApp sre1 sre2) = sReNotEmpty sre1 %&& sReNotEmpty sre2\r\n\r\nblah :: forall (t :: Type) (re :: RegExp t).\r\n Sing re > ()\r\nblah (SApp sre1 sre2)\r\n = case (sReNotEmpty sre1, sReNotEmpty sre2) of\r\n (STrue, STrue) > ()\r\n}}}\r\n\r\nHowever, it panics on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghcstage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20190114 for x86_64unknownlinux):\r\n buildKindCoercion\r\n Any\r\n ReNotEmpty re2_a1hm\r\n Bool\r\n t_a1hg\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Coercion.hs:2427:9 in ghc:Coercion\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.8.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc//issues/16204GHC HEADonly Core Lint error (Argument value doesn't match argument type)20190707T18:00:58ZRyan ScottGHC HEADonly Core Lint error (Argument value doesn't match argument type)The following program passes Core Lint on GHC 8.6.3:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE GADTs #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
module Bug where
import Data.Kind

 singletons machinery

data family Sing :: forall k. k > Type
data SomeSing :: Type > Type where
SomeSing :: Sing (a :: k) > SomeSing k

 (Simplified) GHC.Generics

class Generic (a :: Type) where
type Rep a :: Type
from :: a > Rep a
to :: Rep a > a
class PGeneric (a :: Type) where
 type PFrom ...
type PTo (x :: Rep a) :: a
class SGeneric k where
 sFrom :: ...
sTo :: forall (a :: Rep k). Sing a > Sing (PTo a :: k)

class SingKind k where
type Demote k :: Type
 fromSing :: ...
toSing :: Demote k > SomeSing k
genericToSing :: forall k.
( SingKind k, SGeneric k, SingKind (Rep k)
, Generic (Demote k), Rep (Demote k) ~ Demote (Rep k) )
=> Demote k > SomeSing k
genericToSing d = withSomeSing @(Rep k) (from d) $ SomeSing . sTo
withSomeSing :: forall k r
. SingKind k
=> Demote k
> (forall (a :: k). Sing a > r)
> r
withSomeSing x f =
case toSing x of
SomeSing x' > f x'
```
But not on GHC HEAD:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs dcorelint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Desugar (before optimization) ***
<no location info>: warning:
In the expression: $ @ 'LiftedRep
@ (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)
@ (SomeSing k_a1cV)
(withSomeSing
@ (Rep k_a1cV)
@ (SomeSing k_a1cV)
$dSingKind_a1d5
((from
@ (Demote k_a1cV)
$dGeneric_a1d7
(d_aX7
`cast` (Sub co_a1dK
:: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))
`cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N))
:: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))
(\ (@ (a_a1dc :: Rep k_a1cV)) >
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
>_R <Sing (PTo Any)>_R
:: (Sing Any > Sing (PTo Any))
~R# (Sing Any > Sing (PTo Any)))))
Argument value doesn't match argument type:
Fun type:
(forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)
> SomeSing k_a1cV
Arg type: forall (a :: Rep k_a1cV). Sing Any > SomeSing k_a1cV
Arg:
\ (@ (a_a1dc :: Rep k_a1cV)) >
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
>_R <Sing (PTo Any)>_R
:: (Sing Any > Sing (PTo Any)) ~R# (Sing Any > Sing (PTo Any))))
*** Offending Program ***
<elided>
genericToSing
:: forall k.
(SingKind k, SGeneric k, SingKind (Rep k), Generic (Demote k),
Rep (Demote k) ~ Demote (Rep k)) =>
Demote k > SomeSing k
[LclIdX]
genericToSing
= \ (@ k_a1cV)
($dSingKind_a1cX :: SingKind k_a1cV)
($dSGeneric_a1cY :: SGeneric k_a1cV)
($dSingKind_a1cZ :: SingKind (Rep k_a1cV))
($dGeneric_a1d0 :: Generic (Demote k_a1cV))
($d~_a1d1 :: Rep (Demote k_a1cV) ~ Demote (Rep k_a1cV)) >
let {
co_a1dQ :: Demote (Rep k_a1cV) ~# Demote (Rep k_a1cV)
[LclId[CoVarId]]
co_a1dQ = CO: <Demote (Rep k_a1cV)>_N } in
let {
co_a1dO :: Rep k_a1cV ~# Rep k_a1cV
[LclId[CoVarId]]
co_a1dO = CO: <Rep k_a1cV>_N } in
let {
$dSingKind_a1dT :: SingKind (Rep k_a1cV)
[LclId]
$dSingKind_a1dT
= $dSingKind_a1cZ
`cast` (Sub (Sym (SingKind (Sym co_a1dO))_N)
:: SingKind (Rep k_a1cV[sk:1])
~R# SingKind (Rep k_a1cV[sk:1])) } in
let {
$dSingKind_a1d5 :: SingKind (Rep k_a1cV)
[LclId]
$dSingKind_a1d5
= $dSingKind_a1dT
`cast` ((SingKind (Sym co_a1dO))_R
:: SingKind (Rep k_a1cV[sk:1])
~R# SingKind (Rep k_a1cV[sk:1])) } in
let {
co_a1dM :: Rep (Demote k_a1cV) ~# Rep (Demote k_a1cV)
[LclId[CoVarId]]
co_a1dM = CO: <Rep (Demote k_a1cV)>_N } in
let {
co_a1dK :: Demote k_a1cV ~# Demote k_a1cV
[LclId[CoVarId]]
co_a1dK = CO: <Demote k_a1cV>_N } in
let {
$dGeneric_a1dU :: Generic (Demote k_a1cV)
[LclId]
$dGeneric_a1dU
= $dGeneric_a1d0
`cast` (Sub (Sym (Generic (Sym co_a1dK))_N)
:: Generic (Demote k_a1cV[sk:1])
~R# Generic (Demote k_a1cV[sk:1])) } in
let {
$dGeneric_a1d7 :: Generic (Demote k_a1cV)
[LclId]
$dGeneric_a1d7 = $dGeneric_a1dU } in
case eq_sel
@ * @ (Rep (Demote k_a1cV)) @ (Demote (Rep k_a1cV)) $d~_a1d1
of co_a1dI
{ __DEFAULT >
let {
co_a1dR :: Rep (Demote k_a1cV) ~# Demote (Rep k_a1cV)
[LclId[CoVarId]]
co_a1dR
= CO: ((Sym co_a1dM ; (Rep
(Sym co_a1dK))_N) ; co_a1dI) ; Sym (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N) } in
\ (d_aX7 :: Demote k_a1cV) >
$ @ 'LiftedRep
@ (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)
@ (SomeSing k_a1cV)
(withSomeSing
@ (Rep k_a1cV)
@ (SomeSing k_a1cV)
$dSingKind_a1d5
((from
@ (Demote k_a1cV)
$dGeneric_a1d7
(d_aX7
`cast` (Sub co_a1dK
:: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))
`cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N))
:: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))
(\ (@ (a_a1dc :: Rep k_a1cV)) >
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
>_R <Sing (PTo Any)>_R
:: (Sing Any > Sing (PTo Any)) ~R# (Sing Any > Sing (PTo Any)))))
}
```
I'm not sure if this is related to #16188 (see #16188\##16204), but this Core Lint error is technically different from the one in that ticket, so I decided to open a new issue for this.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  #16188 
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEADonly Core Lint error (Argument value doesn't match argument type)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[16188],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program passes Core Lint on GHC 8.6.3:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\n\r\n singletons machinery\r\n\r\n\r\ndata family Sing :: forall k. k > Type\r\ndata SomeSing :: Type > Type where\r\n SomeSing :: Sing (a :: k) > SomeSing k\r\n\r\n\r\n (Simplified) GHC.Generics\r\n\r\n\r\nclass Generic (a :: Type) where\r\n type Rep a :: Type\r\n from :: a > Rep a\r\n to :: Rep a > a\r\n\r\nclass PGeneric (a :: Type) where\r\n  type PFrom ...\r\n type PTo (x :: Rep a) :: a\r\n\r\nclass SGeneric k where\r\n  sFrom :: ...\r\n sTo :: forall (a :: Rep k). Sing a > Sing (PTo a :: k)\r\n\r\n\r\n\r\nclass SingKind k where\r\n type Demote k :: Type\r\n  fromSing :: ...\r\n toSing :: Demote k > SomeSing k\r\n\r\ngenericToSing :: forall k.\r\n ( SingKind k, SGeneric k, SingKind (Rep k)\r\n , Generic (Demote k), Rep (Demote k) ~ Demote (Rep k) )\r\n => Demote k > SomeSing k\r\ngenericToSing d = withSomeSing @(Rep k) (from d) $ SomeSing . sTo\r\n\r\nwithSomeSing :: forall k r\r\n . SingKind k\r\n => Demote k\r\n > (forall (a :: k). Sing a > r)\r\n > r\r\nwithSomeSing x f =\r\n case toSing x of\r\n SomeSing x' > f x'\r\n}}}\r\n\r\nBut not on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs dcorelint \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Desugar (before optimization) ***\r\n<no location info>: warning:\r\n In the expression: $ @ 'LiftedRep\r\n @ (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n (withSomeSing\r\n @ (Rep k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n $dSingKind_a1d5\r\n ((from\r\n @ (Demote k_a1cV)\r\n $dGeneric_a1d7\r\n (d_aX7\r\n `cast` (Sub co_a1dK\r\n :: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))\r\n `cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N))\r\n :: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))\r\n (\\ (@ (a_a1dc :: Rep k_a1cV)) >\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n >_R <Sing (PTo Any)>_R\r\n :: (Sing Any > Sing (PTo Any))\r\n ~R# (Sing Any > Sing (PTo Any)))))\r\n Argument value doesn't match argument type:\r\n Fun type:\r\n (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)\r\n > SomeSing k_a1cV\r\n Arg type: forall (a :: Rep k_a1cV). Sing Any > SomeSing k_a1cV\r\n Arg:\r\n \\ (@ (a_a1dc :: Rep k_a1cV)) >\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n >_R <Sing (PTo Any)>_R\r\n :: (Sing Any > Sing (PTo Any)) ~R# (Sing Any > Sing (PTo Any))))\r\n*** Offending Program ***\r\n<elided>\r\ngenericToSing\r\n :: forall k.\r\n (SingKind k, SGeneric k, SingKind (Rep k), Generic (Demote k),\r\n Rep (Demote k) ~ Demote (Rep k)) =>\r\n Demote k > SomeSing k\r\n[LclIdX]\r\ngenericToSing\r\n = \\ (@ k_a1cV)\r\n ($dSingKind_a1cX :: SingKind k_a1cV)\r\n ($dSGeneric_a1cY :: SGeneric k_a1cV)\r\n ($dSingKind_a1cZ :: SingKind (Rep k_a1cV))\r\n ($dGeneric_a1d0 :: Generic (Demote k_a1cV))\r\n ($d~_a1d1 :: Rep (Demote k_a1cV) ~ Demote (Rep k_a1cV)) >\r\n let {\r\n co_a1dQ :: Demote (Rep k_a1cV) ~# Demote (Rep k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dQ = CO: <Demote (Rep k_a1cV)>_N } in\r\n let {\r\n co_a1dO :: Rep k_a1cV ~# Rep k_a1cV\r\n [LclId[CoVarId]]\r\n co_a1dO = CO: <Rep k_a1cV>_N } in\r\n let {\r\n $dSingKind_a1dT :: SingKind (Rep k_a1cV)\r\n [LclId]\r\n $dSingKind_a1dT\r\n = $dSingKind_a1cZ\r\n `cast` (Sub (Sym (SingKind (Sym co_a1dO))_N)\r\n :: SingKind (Rep k_a1cV[sk:1])\r\n ~R# SingKind (Rep k_a1cV[sk:1])) } in\r\n let {\r\n $dSingKind_a1d5 :: SingKind (Rep k_a1cV)\r\n [LclId]\r\n $dSingKind_a1d5\r\n = $dSingKind_a1dT\r\n `cast` ((SingKind (Sym co_a1dO))_R\r\n :: SingKind (Rep k_a1cV[sk:1])\r\n ~R# SingKind (Rep k_a1cV[sk:1])) } in\r\n let {\r\n co_a1dM :: Rep (Demote k_a1cV) ~# Rep (Demote k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dM = CO: <Rep (Demote k_a1cV)>_N } in\r\n let {\r\n co_a1dK :: Demote k_a1cV ~# Demote k_a1cV\r\n [LclId[CoVarId]]\r\n co_a1dK = CO: <Demote k_a1cV>_N } in\r\n let {\r\n $dGeneric_a1dU :: Generic (Demote k_a1cV)\r\n [LclId]\r\n $dGeneric_a1dU\r\n = $dGeneric_a1d0\r\n `cast` (Sub (Sym (Generic (Sym co_a1dK))_N)\r\n :: Generic (Demote k_a1cV[sk:1])\r\n ~R# Generic (Demote k_a1cV[sk:1])) } in\r\n let {\r\n $dGeneric_a1d7 :: Generic (Demote k_a1cV)\r\n [LclId]\r\n $dGeneric_a1d7 = $dGeneric_a1dU } in\r\n case eq_sel\r\n @ * @ (Rep (Demote k_a1cV)) @ (Demote (Rep k_a1cV)) $d~_a1d1\r\n of co_a1dI\r\n { __DEFAULT >\r\n let {\r\n co_a1dR :: Rep (Demote k_a1cV) ~# Demote (Rep k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dR\r\n = CO: ((Sym co_a1dM ; (Rep\r\n (Sym co_a1dK))_N) ; co_a1dI) ; Sym (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N) } in\r\n \\ (d_aX7 :: Demote k_a1cV) >\r\n $ @ 'LiftedRep\r\n @ (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n (withSomeSing\r\n @ (Rep k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n $dSingKind_a1d5\r\n ((from\r\n @ (Demote k_a1cV)\r\n $dGeneric_a1d7\r\n (d_aX7\r\n `cast` (Sub co_a1dK\r\n :: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))\r\n `cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N))\r\n :: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))\r\n (\\ (@ (a_a1dc :: Rep k_a1cV)) >\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n >_R <Sing (PTo Any)>_R\r\n :: (Sing Any > Sing (PTo Any)) ~R# (Sing Any > Sing (PTo Any)))))\r\n }\r\n}}}\r\n\r\nI'm not sure if this is related to #16188 (see https://ghc.haskell.org/trac/ghc/ticket/16188#comment:1), but this Core Lint error is technically different from the one in that ticket, so I decided to open a new issue for this.","type_of_failure":"OtherFailure","blocking":[]} >The following program passes Core Lint on GHC 8.6.3:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE FlexibleContexts #}
{# LANGUAGE GADTs #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
module Bug where
import Data.Kind

 singletons machinery

data family Sing :: forall k. k > Type
data SomeSing :: Type > Type where
SomeSing :: Sing (a :: k) > SomeSing k

 (Simplified) GHC.Generics

class Generic (a :: Type) where
type Rep a :: Type
from :: a > Rep a
to :: Rep a > a
class PGeneric (a :: Type) where
 type PFrom ...
type PTo (x :: Rep a) :: a
class SGeneric k where
 sFrom :: ...
sTo :: forall (a :: Rep k). Sing a > Sing (PTo a :: k)

class SingKind k where
type Demote k :: Type
 fromSing :: ...
toSing :: Demote k > SomeSing k
genericToSing :: forall k.
( SingKind k, SGeneric k, SingKind (Rep k)
, Generic (Demote k), Rep (Demote k) ~ Demote (Rep k) )
=> Demote k > SomeSing k
genericToSing d = withSomeSing @(Rep k) (from d) $ SomeSing . sTo
withSomeSing :: forall k r
. SingKind k
=> Demote k
> (forall (a :: k). Sing a > r)
> r
withSomeSing x f =
case toSing x of
SomeSing x' > f x'
```
But not on GHC HEAD:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs dcorelint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Desugar (before optimization) ***
<no location info>: warning:
In the expression: $ @ 'LiftedRep
@ (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)
@ (SomeSing k_a1cV)
(withSomeSing
@ (Rep k_a1cV)
@ (SomeSing k_a1cV)
$dSingKind_a1d5
((from
@ (Demote k_a1cV)
$dGeneric_a1d7
(d_aX7
`cast` (Sub co_a1dK
:: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))
`cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N))
:: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))
(\ (@ (a_a1dc :: Rep k_a1cV)) >
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
>_R <Sing (PTo Any)>_R
:: (Sing Any > Sing (PTo Any))
~R# (Sing Any > Sing (PTo Any)))))
Argument value doesn't match argument type:
Fun type:
(forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)
> SomeSing k_a1cV
Arg type: forall (a :: Rep k_a1cV). Sing Any > SomeSing k_a1cV
Arg:
\ (@ (a_a1dc :: Rep k_a1cV)) >
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
>_R <Sing (PTo Any)>_R
:: (Sing Any > Sing (PTo Any)) ~R# (Sing Any > Sing (PTo Any))))
*** Offending Program ***
<elided>
genericToSing
:: forall k.
(SingKind k, SGeneric k, SingKind (Rep k), Generic (Demote k),
Rep (Demote k) ~ Demote (Rep k)) =>
Demote k > SomeSing k
[LclIdX]
genericToSing
= \ (@ k_a1cV)
($dSingKind_a1cX :: SingKind k_a1cV)
($dSGeneric_a1cY :: SGeneric k_a1cV)
($dSingKind_a1cZ :: SingKind (Rep k_a1cV))
($dGeneric_a1d0 :: Generic (Demote k_a1cV))
($d~_a1d1 :: Rep (Demote k_a1cV) ~ Demote (Rep k_a1cV)) >
let {
co_a1dQ :: Demote (Rep k_a1cV) ~# Demote (Rep k_a1cV)
[LclId[CoVarId]]
co_a1dQ = CO: <Demote (Rep k_a1cV)>_N } in
let {
co_a1dO :: Rep k_a1cV ~# Rep k_a1cV
[LclId[CoVarId]]
co_a1dO = CO: <Rep k_a1cV>_N } in
let {
$dSingKind_a1dT :: SingKind (Rep k_a1cV)
[LclId]
$dSingKind_a1dT
= $dSingKind_a1cZ
`cast` (Sub (Sym (SingKind (Sym co_a1dO))_N)
:: SingKind (Rep k_a1cV[sk:1])
~R# SingKind (Rep k_a1cV[sk:1])) } in
let {
$dSingKind_a1d5 :: SingKind (Rep k_a1cV)
[LclId]
$dSingKind_a1d5
= $dSingKind_a1dT
`cast` ((SingKind (Sym co_a1dO))_R
:: SingKind (Rep k_a1cV[sk:1])
~R# SingKind (Rep k_a1cV[sk:1])) } in
let {
co_a1dM :: Rep (Demote k_a1cV) ~# Rep (Demote k_a1cV)
[LclId[CoVarId]]
co_a1dM = CO: <Rep (Demote k_a1cV)>_N } in
let {
co_a1dK :: Demote k_a1cV ~# Demote k_a1cV
[LclId[CoVarId]]
co_a1dK = CO: <Demote k_a1cV>_N } in
let {
$dGeneric_a1dU :: Generic (Demote k_a1cV)
[LclId]
$dGeneric_a1dU
= $dGeneric_a1d0
`cast` (Sub (Sym (Generic (Sym co_a1dK))_N)
:: Generic (Demote k_a1cV[sk:1])
~R# Generic (Demote k_a1cV[sk:1])) } in
let {
$dGeneric_a1d7 :: Generic (Demote k_a1cV)
[LclId]
$dGeneric_a1d7 = $dGeneric_a1dU } in
case eq_sel
@ * @ (Rep (Demote k_a1cV)) @ (Demote (Rep k_a1cV)) $d~_a1d1
of co_a1dI
{ __DEFAULT >
let {
co_a1dR :: Rep (Demote k_a1cV) ~# Demote (Rep k_a1cV)
[LclId[CoVarId]]
co_a1dR
= CO: ((Sym co_a1dM ; (Rep
(Sym co_a1dK))_N) ; co_a1dI) ; Sym (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N) } in
\ (d_aX7 :: Demote k_a1cV) >
$ @ 'LiftedRep
@ (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)
@ (SomeSing k_a1cV)
(withSomeSing
@ (Rep k_a1cV)
@ (SomeSing k_a1cV)
$dSingKind_a1d5
((from
@ (Demote k_a1cV)
$dGeneric_a1d7
(d_aX7
`cast` (Sub co_a1dK
:: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))
`cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote
(Sym co_a1dO))_N))
:: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))
(\ (@ (a_a1dc :: Rep k_a1cV)) >
let {
$dSGeneric_a1dm :: SGeneric k_a1cV
[LclId]
$dSGeneric_a1dm = $dSGeneric_a1cY } in
. @ (Sing (PTo Any))
@ (SomeSing k_a1cV)
@ (Sing Any)
(SomeSing @ k_a1cV @ (PTo Any))
((sTo @ k_a1cV $dSGeneric_a1dm @ Any)
`cast` (Sym (Sing
(Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R
>_R <Sing (PTo Any)>_R
:: (Sing Any > Sing (PTo Any)) ~R# (Sing Any > Sing (PTo Any)))))
}
```
I'm not sure if this is related to #16188 (see #16188\##16204), but this Core Lint error is technically different from the one in that ticket, so I decided to open a new issue for this.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  #16188 
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEADonly Core Lint error (Argument value doesn't match argument type)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[16188],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program passes Core Lint on GHC 8.6.3:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE FlexibleContexts #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\n\r\n singletons machinery\r\n\r\n\r\ndata family Sing :: forall k. k > Type\r\ndata SomeSing :: Type > Type where\r\n SomeSing :: Sing (a :: k) > SomeSing k\r\n\r\n\r\n (Simplified) GHC.Generics\r\n\r\n\r\nclass Generic (a :: Type) where\r\n type Rep a :: Type\r\n from :: a > Rep a\r\n to :: Rep a > a\r\n\r\nclass PGeneric (a :: Type) where\r\n  type PFrom ...\r\n type PTo (x :: Rep a) :: a\r\n\r\nclass SGeneric k where\r\n  sFrom :: ...\r\n sTo :: forall (a :: Rep k). Sing a > Sing (PTo a :: k)\r\n\r\n\r\n\r\nclass SingKind k where\r\n type Demote k :: Type\r\n  fromSing :: ...\r\n toSing :: Demote k > SomeSing k\r\n\r\ngenericToSing :: forall k.\r\n ( SingKind k, SGeneric k, SingKind (Rep k)\r\n , Generic (Demote k), Rep (Demote k) ~ Demote (Rep k) )\r\n => Demote k > SomeSing k\r\ngenericToSing d = withSomeSing @(Rep k) (from d) $ SomeSing . sTo\r\n\r\nwithSomeSing :: forall k r\r\n . SingKind k\r\n => Demote k\r\n > (forall (a :: k). Sing a > r)\r\n > r\r\nwithSomeSing x f =\r\n case toSing x of\r\n SomeSing x' > f x'\r\n}}}\r\n\r\nBut not on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs dcorelint \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Desugar (before optimization) ***\r\n<no location info>: warning:\r\n In the expression: $ @ 'LiftedRep\r\n @ (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n (withSomeSing\r\n @ (Rep k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n $dSingKind_a1d5\r\n ((from\r\n @ (Demote k_a1cV)\r\n $dGeneric_a1d7\r\n (d_aX7\r\n `cast` (Sub co_a1dK\r\n :: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))\r\n `cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N))\r\n :: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))\r\n (\\ (@ (a_a1dc :: Rep k_a1cV)) >\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n >_R <Sing (PTo Any)>_R\r\n :: (Sing Any > Sing (PTo Any))\r\n ~R# (Sing Any > Sing (PTo Any)))))\r\n Argument value doesn't match argument type:\r\n Fun type:\r\n (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)\r\n > SomeSing k_a1cV\r\n Arg type: forall (a :: Rep k_a1cV). Sing Any > SomeSing k_a1cV\r\n Arg:\r\n \\ (@ (a_a1dc :: Rep k_a1cV)) >\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n >_R <Sing (PTo Any)>_R\r\n :: (Sing Any > Sing (PTo Any)) ~R# (Sing Any > Sing (PTo Any))))\r\n*** Offending Program ***\r\n<elided>\r\ngenericToSing\r\n :: forall k.\r\n (SingKind k, SGeneric k, SingKind (Rep k), Generic (Demote k),\r\n Rep (Demote k) ~ Demote (Rep k)) =>\r\n Demote k > SomeSing k\r\n[LclIdX]\r\ngenericToSing\r\n = \\ (@ k_a1cV)\r\n ($dSingKind_a1cX :: SingKind k_a1cV)\r\n ($dSGeneric_a1cY :: SGeneric k_a1cV)\r\n ($dSingKind_a1cZ :: SingKind (Rep k_a1cV))\r\n ($dGeneric_a1d0 :: Generic (Demote k_a1cV))\r\n ($d~_a1d1 :: Rep (Demote k_a1cV) ~ Demote (Rep k_a1cV)) >\r\n let {\r\n co_a1dQ :: Demote (Rep k_a1cV) ~# Demote (Rep k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dQ = CO: <Demote (Rep k_a1cV)>_N } in\r\n let {\r\n co_a1dO :: Rep k_a1cV ~# Rep k_a1cV\r\n [LclId[CoVarId]]\r\n co_a1dO = CO: <Rep k_a1cV>_N } in\r\n let {\r\n $dSingKind_a1dT :: SingKind (Rep k_a1cV)\r\n [LclId]\r\n $dSingKind_a1dT\r\n = $dSingKind_a1cZ\r\n `cast` (Sub (Sym (SingKind (Sym co_a1dO))_N)\r\n :: SingKind (Rep k_a1cV[sk:1])\r\n ~R# SingKind (Rep k_a1cV[sk:1])) } in\r\n let {\r\n $dSingKind_a1d5 :: SingKind (Rep k_a1cV)\r\n [LclId]\r\n $dSingKind_a1d5\r\n = $dSingKind_a1dT\r\n `cast` ((SingKind (Sym co_a1dO))_R\r\n :: SingKind (Rep k_a1cV[sk:1])\r\n ~R# SingKind (Rep k_a1cV[sk:1])) } in\r\n let {\r\n co_a1dM :: Rep (Demote k_a1cV) ~# Rep (Demote k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dM = CO: <Rep (Demote k_a1cV)>_N } in\r\n let {\r\n co_a1dK :: Demote k_a1cV ~# Demote k_a1cV\r\n [LclId[CoVarId]]\r\n co_a1dK = CO: <Demote k_a1cV>_N } in\r\n let {\r\n $dGeneric_a1dU :: Generic (Demote k_a1cV)\r\n [LclId]\r\n $dGeneric_a1dU\r\n = $dGeneric_a1d0\r\n `cast` (Sub (Sym (Generic (Sym co_a1dK))_N)\r\n :: Generic (Demote k_a1cV[sk:1])\r\n ~R# Generic (Demote k_a1cV[sk:1])) } in\r\n let {\r\n $dGeneric_a1d7 :: Generic (Demote k_a1cV)\r\n [LclId]\r\n $dGeneric_a1d7 = $dGeneric_a1dU } in\r\n case eq_sel\r\n @ * @ (Rep (Demote k_a1cV)) @ (Demote (Rep k_a1cV)) $d~_a1d1\r\n of co_a1dI\r\n { __DEFAULT >\r\n let {\r\n co_a1dR :: Rep (Demote k_a1cV) ~# Demote (Rep k_a1cV)\r\n [LclId[CoVarId]]\r\n co_a1dR\r\n = CO: ((Sym co_a1dM ; (Rep\r\n (Sym co_a1dK))_N) ; co_a1dI) ; Sym (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N) } in\r\n \\ (d_aX7 :: Demote k_a1cV) >\r\n $ @ 'LiftedRep\r\n @ (forall (a :: Rep k_a1cV). Sing a > SomeSing k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n (withSomeSing\r\n @ (Rep k_a1cV)\r\n @ (SomeSing k_a1cV)\r\n $dSingKind_a1d5\r\n ((from\r\n @ (Demote k_a1cV)\r\n $dGeneric_a1d7\r\n (d_aX7\r\n `cast` (Sub co_a1dK\r\n :: Demote k_a1cV[sk:1] ~R# Demote k_a1cV[sk:1])))\r\n `cast` (Sub (Sym (Sym co_a1dR ; Sym co_a1dM) ; (Sym co_a1dQ ; (Demote\r\n (Sym co_a1dO))_N))\r\n :: Rep (Demote k_a1cV[sk:1]) ~R# Demote (Rep k_a1cV[sk:1]))))\r\n (\\ (@ (a_a1dc :: Rep k_a1cV)) >\r\n let {\r\n $dSGeneric_a1dm :: SGeneric k_a1cV\r\n [LclId]\r\n $dSGeneric_a1dm = $dSGeneric_a1cY } in\r\n . @ (Sing (PTo Any))\r\n @ (SomeSing k_a1cV)\r\n @ (Sing Any)\r\n (SomeSing @ k_a1cV @ (PTo Any))\r\n ((sTo @ k_a1cV $dSGeneric_a1dm @ Any)\r\n `cast` (Sym (Sing\r\n (Sym co_a1dO) (Sym (GRefl nominal Any co_a1dO)))_R\r\n >_R <Sing (PTo Any)>_R\r\n :: (Sing Any > Sing (PTo Any)) ~R# (Sing Any > Sing (PTo Any)))))\r\n }\r\n}}}\r\n\r\nI'm not sure if this is related to #16188 (see https://ghc.haskell.org/trac/ghc/ticket/16188#comment:1), but this Core Lint error is technically different from the one in that ticket, so I decided to open a new issue for this.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/16221Core Lint error with a data type20190707T18:00:55ZKrzysztof GogolewskiCore Lint error with a data typeThe following data declaration fails `dcorelint`
```haskell
{# LANGUAGE PolyKinds, ExplicitForAll, ExistentialQuantification #}
module T16221 where
data T0 a = forall k (b :: k). MkT0 (T0 b) !Int
```
The test case was extracted from T14066a, the bang is to force the data type to have a wrapper. This has been present at least since GHC 8.0.
```
<no location info>: warning:
In the type ‘T0 a_a1wY’
Kind application error in type ‘T0 a_a1wY’
Function kind = forall k. k > *
Arg kinds = [(k_X1x2, *), (a_a1wY, k_a1wZ)]
Fun: k_X1x2
(a_a1wY, k_a1wZ)
<no location info>: warning:
In the expression: MkT0
@ k_X1x2 @ a_a1wY @ k_X1x2 @ b_a1x0 dt_a1xC dt_X1xK
Kinds don't match in type application:
Type variable: a_X1xw :: k_X1x2
Arg type: a_a1wY :: k_a1wZ
Linted Arg kind: k_a1wZ
<no location info>: warning:
In the type ‘T0 a_a1wY’
Kind application error in type ‘T0 a_a1wY’
Function kind = forall k. k > *
Arg kinds = [(k_X1x2, *), (a_a1wY, k_a1wZ)]
Fun: k_X1x2
(a_a1wY, k_a1wZ)
<no location info>: warning:
In the expression: MkT0
@ k_X1x2 @ a_a1wY @ k_X1x2 @ b_a1x0 dt_a1xC dt_X1xK
Kinds don't match in type application:
Type variable: a_X1xw :: k_X1x2
Arg type: a_a1wY :: k_a1wZ
Linted Arg kind: k_a1wZ
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error with a data type","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following data declaration fails `dcorelint`\r\n\r\n{{{\r\n#!haskell\r\n{# LANGUAGE PolyKinds, ExplicitForAll, ExistentialQuantification #}\r\n\r\nmodule T16221 where\r\ndata T0 a = forall k (b :: k). MkT0 (T0 b) !Int\r\n}}}\r\n\r\nThe test case was extracted from T14066a, the bang is to force the data type to have a wrapper. This has been present at least since GHC 8.0.\r\n\r\n{{{\r\n<no location info>: warning:\r\n In the type ‘T0 a_a1wY’\r\n Kind application error in type ‘T0 a_a1wY’\r\n Function kind = forall k. k > *\r\n Arg kinds = [(k_X1x2, *), (a_a1wY, k_a1wZ)]\r\n Fun: k_X1x2\r\n (a_a1wY, k_a1wZ)\r\n<no location info>: warning:\r\n In the expression: MkT0\r\n @ k_X1x2 @ a_a1wY @ k_X1x2 @ b_a1x0 dt_a1xC dt_X1xK\r\n Kinds don't match in type application:\r\n Type variable: a_X1xw :: k_X1x2\r\n Arg type: a_a1wY :: k_a1wZ\r\n Linted Arg kind: k_a1wZ\r\n<no location info>: warning:\r\n In the type ‘T0 a_a1wY’\r\n Kind application error in type ‘T0 a_a1wY’\r\n Function kind = forall k. k > *\r\n Arg kinds = [(k_X1x2, *), (a_a1wY, k_a1wZ)]\r\n Fun: k_X1x2\r\n (a_a1wY, k_a1wZ)\r\n<no location info>: warning:\r\n In the expression: MkT0\r\n @ k_X1x2 @ a_a1wY @ k_X1x2 @ b_a1x0 dt_a1xC dt_X1xK\r\n Kinds don't match in type application:\r\n Type variable: a_X1xw :: k_X1x2\r\n Arg type: a_a1wY :: k_a1wZ\r\n Linted Arg kind: k_a1wZ\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following data declaration fails `dcorelint`
```haskell
{# LANGUAGE PolyKinds, ExplicitForAll, ExistentialQuantification #}
module T16221 where
data T0 a = forall k (b :: k). MkT0 (T0 b) !Int
```
The test case was extracted from T14066a, the bang is to force the data type to have a wrapper. This has been present at least since GHC 8.0.
```
<no location info>: warning:
In the type ‘T0 a_a1wY’
Kind application error in type ‘T0 a_a1wY’
Function kind = forall k. k > *
Arg kinds = [(k_X1x2, *), (a_a1wY, k_a1wZ)]
Fun: k_X1x2
(a_a1wY, k_a1wZ)
<no location info>: warning:
In the expression: MkT0
@ k_X1x2 @ a_a1wY @ k_X1x2 @ b_a1x0 dt_a1xC dt_X1xK
Kinds don't match in type application:
Type variable: a_X1xw :: k_X1x2
Arg type: a_a1wY :: k_a1wZ
Linted Arg kind: k_a1wZ
<no location info>: warning:
In the type ‘T0 a_a1wY’
Kind application error in type ‘T0 a_a1wY’
Function kind = forall k. k > *
Arg kinds = [(k_X1x2, *), (a_a1wY, k_a1wZ)]
Fun: k_X1x2
(a_a1wY, k_a1wZ)
<no location info>: warning:
In the expression: MkT0
@ k_X1x2 @ a_a1wY @ k_X1x2 @ b_a1x0 dt_a1xC dt_X1xK
Kinds don't match in type application:
Type variable: a_X1xw :: k_X1x2
Arg type: a_a1wY :: k_a1wZ
Linted Arg kind: k_a1wZ
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Core Lint error with a data type","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following data declaration fails `dcorelint`\r\n\r\n{{{\r\n#!haskell\r\n{# LANGUAGE PolyKinds, ExplicitForAll, ExistentialQuantification #}\r\n\r\nmodule T16221 where\r\ndata T0 a = forall k (b :: k). MkT0 (T0 b) !Int\r\n}}}\r\n\r\nThe test case was extracted from T14066a, the bang is to force the data type to have a wrapper. This has been present at least since GHC 8.0.\r\n\r\n{{{\r\n<no location info>: warning:\r\n In the type ‘T0 a_a1wY’\r\n Kind application error in type ‘T0 a_a1wY’\r\n Function kind = forall k. k > *\r\n Arg kinds = [(k_X1x2, *), (a_a1wY, k_a1wZ)]\r\n Fun: k_X1x2\r\n (a_a1wY, k_a1wZ)\r\n<no location info>: warning:\r\n In the expression: MkT0\r\n @ k_X1x2 @ a_a1wY @ k_X1x2 @ b_a1x0 dt_a1xC dt_X1xK\r\n Kinds don't match in type application:\r\n Type variable: a_X1xw :: k_X1x2\r\n Arg type: a_a1wY :: k_a1wZ\r\n Linted Arg kind: k_a1wZ\r\n<no location info>: warning:\r\n In the type ‘T0 a_a1wY’\r\n Kind application error in type ‘T0 a_a1wY’\r\n Function kind = forall k. k > *\r\n Arg kinds = [(k_X1x2, *), (a_a1wY, k_a1wZ)]\r\n Fun: k_X1x2\r\n (a_a1wY, k_a1wZ)\r\n<no location info>: warning:\r\n In the expression: MkT0\r\n @ k_X1x2 @ a_a1wY @ k_X1x2 @ b_a1x0 dt_a1xC dt_X1xK\r\n Kinds don't match in type application:\r\n Type variable: a_X1xw :: k_X1x2\r\n Arg type: a_a1wY :: k_a1wZ\r\n Linted Arg kind: k_a1wZ\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.10.1https://gitlab.haskell.org/ghc/ghc//issues/16225GHC HEADonly Core Lint error (Trans coercion mismatch)20190707T18:00:54ZRyan ScottGHC HEADonly Core Lint error (Trans coercion mismatch)The following code compiles on GHC 8.0.2 through GHC 8.6.3 with `dcorelint`:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE GADTs #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
data family Sing :: k > Type
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: a ~> b) (x :: a) :: b
data TyCon1 :: (k1 > k2) > (k1 ~> k2)
type instance Apply (TyCon1 f) x = f x
data SomeApply :: (k ~> Type) > Type where
SomeApply :: Apply f a > SomeApply f
f :: SomeApply (TyCon1 Sing :: k ~> Type)
> SomeApply (TyCon1 Sing :: k ~> Type)
f (SomeApply s)
= SomeApply s
```
However, it chokes on GHC HEAD:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 interactive Bug.hs dcorelint
GHCi, version 8.7.20190120: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
*** Core Lint errors : in result of Desugar (before optimization) ***
<no location info>: warning:
In the expression: SomeApply
@ k_a1Dz
@ (TyCon1 Sing)
@ Any
(s_a1Bq
`cast` (Sub (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N
<*>_N
<Sing>_N
<a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N <*>_N <Sing>_N <Any>_N))
:: Apply (TyCon1 Sing) a_a1DB ~R# Apply (TyCon1 Sing) Any))
Trans coercion mismatch: D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N <*>_N <Sing>_N <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N
<*>_N
<Sing>_N
<Any>_N)
Apply (TyCon1 Sing) a_a1DB
Sing a_a1DB
Sing Any
Apply (TyCon1 Sing) Any
*** Offending Program ***
<elided>
f :: forall k. SomeApply (TyCon1 Sing) > SomeApply (TyCon1 Sing)
[LclIdX]
f = \ (@ k_a1Dz) (ds_d1EV :: SomeApply (TyCon1 Sing)) >
case ds_d1EV of wild_00 { SomeApply @ a_a1DB s_a1Bq >
break<0>(s_a1Bq)
SomeApply
@ k_a1Dz
@ (TyCon1 Sing)
@ Any
(s_a1Bq
`cast` (Sub (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N <*>_N <Sing>_N <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N
<*>_N
<Sing>_N
<Any>_N))
:: Apply (TyCon1 Sing) a_a1DB ~R# Apply (TyCon1 Sing) Any))
}
```
Note that if I change the definition of `Sing` to this:
```hs
data family Sing (a :: k)
```
Then the error goes away.
Also, if I extend `SomeProxy` with an additional `proxy` field:
```hs
data SomeApply :: (k ~> Type) > Type where
SomeApply :: proxy a > Apply f a > SomeApply f
f :: SomeApply (TyCon1 Sing :: k ~> Type)
> SomeApply (TyCon1 Sing :: k ~> Type)
f (SomeApply p s)
= SomeApply p s
```
Then the error also goes away. Perhaps `a` being ambiguous plays an important role here?
Possibly related to #16188 or #16204.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEADonly Core Lint error (Trans coercion mismatch)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code compiles on GHC 8.0.2 through GHC 8.6.3 with `dcorelint`:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata family Sing :: k > Type\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: a ~> b) (x :: a) :: b\r\n\r\ndata TyCon1 :: (k1 > k2) > (k1 ~> k2)\r\ntype instance Apply (TyCon1 f) x = f x\r\n\r\ndata SomeApply :: (k ~> Type) > Type where\r\n SomeApply :: Apply f a > SomeApply f\r\n\r\nf :: SomeApply (TyCon1 Sing :: k ~> Type)\r\n > SomeApply (TyCon1 Sing :: k ~> Type)\r\nf (SomeApply s)\r\n = SomeApply s\r\n}}}\r\n\r\nHowever, it chokes on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 interactive Bug.hs dcorelint\r\nGHCi, version 8.7.20190120: https://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n*** Core Lint errors : in result of Desugar (before optimization) ***\r\n<no location info>: warning:\r\n In the expression: SomeApply\r\n @ k_a1Dz\r\n @ (TyCon1 Sing)\r\n @ Any\r\n (s_a1Bq\r\n `cast` (Sub (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N\r\n <*>_N\r\n <Sing>_N\r\n <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N <*>_N <Sing>_N <Any>_N))\r\n :: Apply (TyCon1 Sing) a_a1DB ~R# Apply (TyCon1 Sing) Any))\r\n Trans coercion mismatch: D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N <*>_N <Sing>_N <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N\r\n <*>_N\r\n <Sing>_N\r\n <Any>_N)\r\n Apply (TyCon1 Sing) a_a1DB\r\n Sing a_a1DB\r\n Sing Any\r\n Apply (TyCon1 Sing) Any\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\nf :: forall k. SomeApply (TyCon1 Sing) > SomeApply (TyCon1 Sing)\r\n[LclIdX]\r\nf = \\ (@ k_a1Dz) (ds_d1EV :: SomeApply (TyCon1 Sing)) >\r\n case ds_d1EV of wild_00 { SomeApply @ a_a1DB s_a1Bq >\r\n break<0>(s_a1Bq)\r\n SomeApply\r\n @ k_a1Dz\r\n @ (TyCon1 Sing)\r\n @ Any\r\n (s_a1Bq\r\n `cast` (Sub (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N <*>_N <Sing>_N <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N\r\n <*>_N\r\n <Sing>_N\r\n <Any>_N))\r\n :: Apply (TyCon1 Sing) a_a1DB ~R# Apply (TyCon1 Sing) Any))\r\n }\r\n}}}\r\n\r\nNote that if I change the definition of `Sing` to this:\r\n\r\n{{{#!hs\r\ndata family Sing (a :: k)\r\n}}}\r\n\r\nThen the error goes away.\r\n\r\nAlso, if I extend `SomeProxy` with an additional `proxy` field:\r\n\r\n{{{#!hs\r\ndata SomeApply :: (k ~> Type) > Type where\r\n SomeApply :: proxy a > Apply f a > SomeApply f\r\n\r\nf :: SomeApply (TyCon1 Sing :: k ~> Type)\r\n > SomeApply (TyCon1 Sing :: k ~> Type)\r\nf (SomeApply p s)\r\n = SomeApply p s\r\n}}}\r\n\r\nThen the error also goes away. Perhaps `a` being ambiguous plays an important role here?\r\n\r\nPossibly related to #16188 or #16204.","type_of_failure":"OtherFailure","blocking":[]} >The following code compiles on GHC 8.0.2 through GHC 8.6.3 with `dcorelint`:
```hs
{# LANGUAGE AllowAmbiguousTypes #}
{# LANGUAGE GADTs #}
{# LANGUAGE TypeFamilies #}
{# LANGUAGE TypeInType #}
{# LANGUAGE TypeOperators #}
module Bug where
import Data.Kind
data family Sing :: k > Type
data TyFun :: Type > Type > Type
type a ~> b = TyFun a b > Type
infixr 0 ~>
type family Apply (f :: a ~> b) (x :: a) :: b
data TyCon1 :: (k1 > k2) > (k1 ~> k2)
type instance Apply (TyCon1 f) x = f x
data SomeApply :: (k ~> Type) > Type where
SomeApply :: Apply f a > SomeApply f
f :: SomeApply (TyCon1 Sing :: k ~> Type)
> SomeApply (TyCon1 Sing :: k ~> Type)
f (SomeApply s)
= SomeApply s
```
However, it chokes on GHC HEAD:
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 interactive Bug.hs dcorelint
GHCi, version 8.7.20190120: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
*** Core Lint errors : in result of Desugar (before optimization) ***
<no location info>: warning:
In the expression: SomeApply
@ k_a1Dz
@ (TyCon1 Sing)
@ Any
(s_a1Bq
`cast` (Sub (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N
<*>_N
<Sing>_N
<a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N <*>_N <Sing>_N <Any>_N))
:: Apply (TyCon1 Sing) a_a1DB ~R# Apply (TyCon1 Sing) Any))
Trans coercion mismatch: D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N <*>_N <Sing>_N <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N
<*>_N
<Sing>_N
<Any>_N)
Apply (TyCon1 Sing) a_a1DB
Sing a_a1DB
Sing Any
Apply (TyCon1 Sing) Any
*** Offending Program ***
<elided>
f :: forall k. SomeApply (TyCon1 Sing) > SomeApply (TyCon1 Sing)
[LclIdX]
f = \ (@ k_a1Dz) (ds_d1EV :: SomeApply (TyCon1 Sing)) >
case ds_d1EV of wild_00 { SomeApply @ a_a1DB s_a1Bq >
break<0>(s_a1Bq)
SomeApply
@ k_a1Dz
@ (TyCon1 Sing)
@ Any
(s_a1Bq
`cast` (Sub (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N <*>_N <Sing>_N <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]
<k_a1Dz>_N
<*>_N
<Sing>_N
<Any>_N))
:: Apply (TyCon1 Sing) a_a1DB ~R# Apply (TyCon1 Sing) Any))
}
```
Note that if I change the definition of `Sing` to this:
```hs
data family Sing (a :: k)
```
Then the error goes away.
Also, if I extend `SomeProxy` with an additional `proxy` field:
```hs
data SomeApply :: (k ~> Type) > Type where
SomeApply :: proxy a > Apply f a > SomeApply f
f :: SomeApply (TyCon1 Sing :: k ~> Type)
> SomeApply (TyCon1 Sing :: k ~> Type)
f (SomeApply p s)
= SomeApply p s
```
Then the error also goes away. Perhaps `a` being ambiguous plays an important role here?
Possibly related to #16188 or #16204.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  highest 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC HEADonly Core Lint error (Trans coercion mismatch)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code compiles on GHC 8.0.2 through GHC 8.6.3 with `dcorelint`:\r\n\r\n{{{#!hs\r\n{# LANGUAGE AllowAmbiguousTypes #}\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE TypeFamilies #}\r\n{# LANGUAGE TypeInType #}\r\n{# LANGUAGE TypeOperators #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata family Sing :: k > Type\r\ndata TyFun :: Type > Type > Type\r\ntype a ~> b = TyFun a b > Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: a ~> b) (x :: a) :: b\r\n\r\ndata TyCon1 :: (k1 > k2) > (k1 ~> k2)\r\ntype instance Apply (TyCon1 f) x = f x\r\n\r\ndata SomeApply :: (k ~> Type) > Type where\r\n SomeApply :: Apply f a > SomeApply f\r\n\r\nf :: SomeApply (TyCon1 Sing :: k ~> Type)\r\n > SomeApply (TyCon1 Sing :: k ~> Type)\r\nf (SomeApply s)\r\n = SomeApply s\r\n}}}\r\n\r\nHowever, it chokes on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc4/inplace/bin/ghcstage2 interactive Bug.hs dcorelint\r\nGHCi, version 8.7.20190120: https://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n*** Core Lint errors : in result of Desugar (before optimization) ***\r\n<no location info>: warning:\r\n In the expression: SomeApply\r\n @ k_a1Dz\r\n @ (TyCon1 Sing)\r\n @ Any\r\n (s_a1Bq\r\n `cast` (Sub (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N\r\n <*>_N\r\n <Sing>_N\r\n <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N <*>_N <Sing>_N <Any>_N))\r\n :: Apply (TyCon1 Sing) a_a1DB ~R# Apply (TyCon1 Sing) Any))\r\n Trans coercion mismatch: D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N <*>_N <Sing>_N <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N\r\n <*>_N\r\n <Sing>_N\r\n <Any>_N)\r\n Apply (TyCon1 Sing) a_a1DB\r\n Sing a_a1DB\r\n Sing Any\r\n Apply (TyCon1 Sing) Any\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\nf :: forall k. SomeApply (TyCon1 Sing) > SomeApply (TyCon1 Sing)\r\n[LclIdX]\r\nf = \\ (@ k_a1Dz) (ds_d1EV :: SomeApply (TyCon1 Sing)) >\r\n case ds_d1EV of wild_00 { SomeApply @ a_a1DB s_a1Bq >\r\n break<0>(s_a1Bq)\r\n SomeApply\r\n @ k_a1Dz\r\n @ (TyCon1 Sing)\r\n @ Any\r\n (s_a1Bq\r\n `cast` (Sub (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N <*>_N <Sing>_N <a_a1DB>_N ; Sym (D:R:ApplyabTyCon1x[0]\r\n <k_a1Dz>_N\r\n <*>_N\r\n <Sing>_N\r\n <Any>_N))\r\n :: Apply (TyCon1 Sing) a_a1DB ~R# Apply (TyCon1 Sing) Any))\r\n }\r\n}}}\r\n\r\nNote that if I change the definition of `Sing` to this:\r\n\r\n{{{#!hs\r\ndata family Sing (a :: k)\r\n}}}\r\n\r\nThen the error goes away.\r\n\r\nAlso, if I extend `SomeProxy` with an additional `proxy` field:\r\n\r\n{{{#!hs\r\ndata SomeApply :: (k ~> Type) > Type where\r\n SomeApply :: proxy a > Apply f a > SomeApply f\r\n\r\nf :: SomeApply (TyCon1 Sing :: k ~> Type)\r\n > SomeApply (TyCon1 Sing :: k ~> Type)\r\nf (SomeApply p s)\r\n = SomeApply p s\r\n}}}\r\n\r\nThen the error also goes away. Perhaps `a` being ambiguous plays an important role here?\r\n\r\nPossibly related to #16188 or #16204.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/16232Add setField to HasField20210607T07:38:21ZAdam GundryAdd setField to HasFieldThis ticket is to track the implementation of https://github.com/ghcproposals/ghcproposals/blob/master/proposals/0042recordsetfield.rst
I've made a start on the implementation but have a question on which I'd appreciate some input: how should the dictionary for `HasField` be generated?
To recap, recall that at present, `HasField x r a` is coercible to `r > a` so the dictionary can be constructed merely by taking the selector function for the field and wrapping it in an appropriate coercion.
With the proposal, `HasField x r a` will instead be represented as `r > (a > r, a)` where the first component of the tuple is an update function. The problem is how to define this update function in Core. This function should perform case analysis on the record data type, where each case replaces the value of the field being updated and preserves all the other fields. For example, given a data type `data T = MkT { foo :: Int, bar :: Bool }` we need to generate
```hs
\ r x > case r of MkT {foo = _, bar = bar} > MkT { foo = x, bar = bar }
```
The most obvious approach is to generate welltyped Core for the update function directly, but this seems to be rather complex, in particular because of the worker/wrapper distinction, as one ends up reconstructing much of the typechecking/desugaring for record pattern matching and construction. This also seems like a lot of work to do every time a `HasField` constraint is solved.
Would it be reasonable to generate update functions for fields at definition sites, as we do for selector functions? I've implemented this in the past, and it is relatively simple to generate renamed syntax to feed in to the typechecker. However, this would add some overhead for every field, even if `HasField` was not subsequently used, and would require some naming scheme for update functions.
Or are there other options? Is there some way to solve a `HasField` constraint and construct its dictionary by emitting renamed syntax for subsequent typechecking, such that subsequently solving similar constraints will use the same dictionary?
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  FeatureRequest 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  NeilMitchell, simonpj 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Add setField to HasField","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["ORF"],"differentials":[],"test_case":"","architecture":"","cc":["NeilMitchell","simonpj"],"type":"FeatureRequest","description":"This ticket is to track the implementation of https://github.com/ghcproposals/ghcproposals/blob/master/proposals/0042recordsetfield.rst\r\n\r\nI've made a start on the implementation but have a question on which I'd appreciate some input: how should the dictionary for `HasField` be generated?\r\n\r\nTo recap, recall that at present, `HasField x r a` is coercible to `r > a` so the dictionary can be constructed merely by taking the selector function for the field and wrapping it in an appropriate coercion.\r\n\r\nWith the proposal, `HasField x r a` will instead be represented as `r > (a > r, a)` where the first component of the tuple is an update function. The problem is how to define this update function in Core. This function should perform case analysis on the record data type, where each case replaces the value of the field being updated and preserves all the other fields. For example, given a data type `data T = MkT { foo :: Int, bar :: Bool }` we need to generate\r\n{{{#!hs\r\n\\ r x > case r of MkT {foo = _, bar = bar} > MkT { foo = x, bar = bar }\r\n}}}\r\n\r\nThe most obvious approach is to generate welltyped Core for the update function directly, but this seems to be rather complex, in particular because of the worker/wrapper distinction, as one ends up reconstructing much of the typechecking/desugaring for record pattern matching and construction. This also seems like a lot of work to do every time a `HasField` constraint is solved.\r\n\r\nWould it be reasonable to generate update functions for fields at definition sites, as we do for selector functions? I've implemented this in the past, and it is relatively simple to generate renamed syntax to feed in to the typechecker. However, this would add some overhead for every field, even if `HasField` was not subsequently used, and would require some naming scheme for update functions.\r\n\r\nOr are there other options? Is there some way to solve a `HasField` constraint and construct its dictionary by emitting renamed syntax for subsequent typechecking, such that subsequently solving similar constraints will use the same dictionary?","type_of_failure":"OtherFailure","blocking":[]} >This ticket is to track the implementation of https://github.com/ghcproposals/ghcproposals/blob/master/proposals/0042recordsetfield.rst
I've made a start on the implementation but have a question on which I'd appreciate some input: how should the dictionary for `HasField` be generated?
To recap, recall that at present, `HasField x r a` is coercible to `r > a` so the dictionary can be constructed merely by taking the selector function for the field and wrapping it in an appropriate coercion.
With the proposal, `HasField x r a` will instead be represented as `r > (a > r, a)` where the first component of the tuple is an update function. The problem is how to define this update function in Core. This function should perform case analysis on the record data type, where each case replaces the value of the field being updated and preserves all the other fields. For example, given a data type `data T = MkT { foo :: Int, bar :: Bool }` we need to generate
```hs
\ r x > case r of MkT {foo = _, bar = bar} > MkT { foo = x, bar = bar }
```
The most obvious approach is to generate welltyped Core for the update function directly, but this seems to be rather complex, in particular because of the worker/wrapper distinction, as one ends up reconstructing much of the typechecking/desugaring for record pattern matching and construction. This also seems like a lot of work to do every time a `HasField` constraint is solved.
Would it be reasonable to generate update functions for fields at definition sites, as we do for selector functions? I've implemented this in the past, and it is relatively simple to generate renamed syntax to feed in to the typechecker. However, this would add some overhead for every field, even if `HasField` was not subsequently used, and would require some naming scheme for update functions.
Or are there other options? Is there some way to solve a `HasField` constraint and construct its dictionary by emitting renamed syntax for subsequent typechecking, such that subsequently solving similar constraints will use the same dictionary?
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  FeatureRequest 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  NeilMitchell, simonpj 
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Add setField to HasField","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["ORF"],"differentials":[],"test_case":"","architecture":"","cc":["NeilMitchell","simonpj"],"type":"FeatureRequest","description":"This ticket is to track the implementation of https://github.com/ghcproposals/ghcproposals/blob/master/proposals/0042recordsetfield.rst\r\n\r\nI've made a start on the implementation but have a question on which I'd appreciate some input: how should the dictionary for `HasField` be generated?\r\n\r\nTo recap, recall that at present, `HasField x r a` is coercible to `r > a` so the dictionary can be constructed merely by taking the selector function for the field and wrapping it in an appropriate coercion.\r\n\r\nWith the proposal, `HasField x r a` will instead be represented as `r > (a > r, a)` where the first component of the tuple is an update function. The problem is how to define this update function in Core. This function should perform case analysis on the record data type, where each case replaces the value of the field being updated and preserves all the other fields. For example, given a data type `data T = MkT { foo :: Int, bar :: Bool }` we need to generate\r\n{{{#!hs\r\n\\ r x > case r of MkT {foo = _, bar = bar} > MkT { foo = x, bar = bar }\r\n}}}\r\n\r\nThe most obvious approach is to generate welltyped Core for the update function directly, but this seems to be rather complex, in particular because of the worker/wrapper distinction, as one ends up reconstructing much of the typechecking/desugaring for record pattern matching and construction. This also seems like a lot of work to do every time a `HasField` constraint is solved.\r\n\r\nWould it be reasonable to generate update functions for fields at definition sites, as we do for selector functions? I've implemented this in the past, and it is relatively simple to generate renamed syntax to feed in to the typechecker. However, this would add some overhead for every field, even if `HasField` was not subsequently used, and would require some naming scheme for update functions.\r\n\r\nOr are there other options? Is there some way to solve a `HasField` constraint and construct its dictionary by emitting renamed syntax for subsequent typechecking, such that subsequently solving similar constraints will use the same dictionary?","type_of_failure":"OtherFailure","blocking":[]} >Adam GundryAdam Gundryhttps://gitlab.haskell.org/ghc/ghc//issues/16244Couldn't match kind ‘k1’ with ‘k1’20200505T09:44:28ZRyan ScottCouldn't match kind ‘k1’ with ‘k1’The following program gives a hopelessly confusing error message on GHC 8.6.3 and HEAD:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE DataKinds #}
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE PolyKinds #}
module Bug where
import Data.Kind
type Const a b = a
type SameKind (a :: k) (b :: k) = (() :: Constraint)
class SameKind a b => C (k :: Const Type a) (b :: k)
```
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:11:18: error:
• Couldn't match kind ‘k1’ with ‘k1’
• In the second argument of ‘SameKind’, namely ‘b’
In the class declaration for ‘C’

11  class SameKind a b => C (k :: Const Type a) (b :: k)
 ^
```
I imagine that the real issue is that `SameKind a b` would force `a :: k`, which would be illscoped. But figuring that out from this strange error message requires a lot of thought.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Couldn't match kind ‘k1’ with ‘k1’","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program gives a hopelessly confusing error message on GHC 8.6.3 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE MultiParamTypeClasses #}\r\n{# LANGUAGE PolyKinds #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype Const a b = a\r\ntype SameKind (a :: k) (b :: k) = (() :: Constraint)\r\nclass SameKind a b => C (k :: Const Type a) (b :: k)\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:11:18: error:\r\n • Couldn't match kind ‘k1’ with ‘k1’\r\n • In the second argument of ‘SameKind’, namely ‘b’\r\n In the class declaration for ‘C’\r\n \r\n11  class SameKind a b => C (k :: Const Type a) (b :: k)\r\n  ^\r\n}}}\r\n\r\nI imagine that the real issue is that `SameKind a b` would force `a :: k`, which would be illscoped. But figuring that out from this strange error message requires a lot of thought.","type_of_failure":"OtherFailure","blocking":[]} >The following program gives a hopelessly confusing error message on GHC 8.6.3 and HEAD:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE DataKinds #}
{# LANGUAGE MultiParamTypeClasses #}
{# LANGUAGE PolyKinds #}
module Bug where
import Data.Kind
type Const a b = a
type SameKind (a :: k) (b :: k) = (() :: Constraint)
class SameKind a b => C (k :: Const Type a) (b :: k)
```
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:11:18: error:
• Couldn't match kind ‘k1’ with ‘k1’
• In the second argument of ‘SameKind’, namely ‘b’
In the class declaration for ‘C’

11  class SameKind a b => C (k :: Const Type a) (b :: k)
 ^
```
I imagine that the real issue is that `SameKind a b` would force `a :: k`, which would be illscoped. But figuring that out from this strange error message requires a lot of thought.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Couldn't match kind ‘k1’ with ‘k1’","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program gives a hopelessly confusing error message on GHC 8.6.3 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE MultiParamTypeClasses #}\r\n{# LANGUAGE PolyKinds #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype Const a b = a\r\ntype SameKind (a :: k) (b :: k) = (() :: Constraint)\r\nclass SameKind a b => C (k :: Const Type a) (b :: k)\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:11:18: error:\r\n • Couldn't match kind ‘k1’ with ‘k1’\r\n • In the second argument of ‘SameKind’, namely ‘b’\r\n In the class declaration for ‘C’\r\n \r\n11  class SameKind a b => C (k :: Const Type a) (b :: k)\r\n  ^\r\n}}}\r\n\r\nI imagine that the real issue is that `SameKind a b` would force `a :: k`, which would be illscoped. But figuring that out from this strange error message requires a lot of thought.","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/16245GHC panic (No skolem info) with RankNTypes and strange scoping20201231T13:44:06ZRyan ScottGHC panic (No skolem info) with RankNTypes and strange scopingThe following program panics with GHC 8.6.3 and HEAD:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE QuantifiedConstraints #}
module Bug where
import Data.Kind
type Const a b = a
type SameKind (a :: k) (b :: k) = (() :: Constraint)
class (forall (b :: k). SameKind a b) => C (k :: Const Type a)
```
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:11:36: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.6.3 for x86_64unknownlinux):
No skolem info:
[k1_a1X4[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors
```
As with #16244, I imagine that the real culprit is that `SameKind a b` would force `a :: k`, which would be illscoped.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC panic (No skolem info) with QuantifiedConstraints and strange scoping","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":["QuantifiedConstraints","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics with GHC 8.6.3 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype Const a b = a\r\ntype SameKind (a :: k) (b :: k) = (() :: Constraint)\r\nclass (forall (b :: k). SameKind a b) => C (k :: Const Type a)\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:11:36: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.3 for x86_64unknownlinux):\r\n No skolem info:\r\n [k1_a1X4[sk:1]]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors\r\n}}}\r\n\r\nAs with #16244, I imagine that the real culprit is that `SameKind a b` would force `a :: k`, which would be illscoped.","type_of_failure":"OtherFailure","blocking":[]} >The following program panics with GHC 8.6.3 and HEAD:
```hs
{# LANGUAGE ConstraintKinds #}
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE QuantifiedConstraints #}
module Bug where
import Data.Kind
type Const a b = a
type SameKind (a :: k) (b :: k) = (() :: Constraint)
class (forall (b :: k). SameKind a b) => C (k :: Const Type a)
```
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:11:36: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.6.3 for x86_64unknownlinux):
No skolem info:
[k1_a1X4[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors
```
As with #16244, I imagine that the real culprit is that `SameKind a b` would force `a :: k`, which would be illscoped.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC panic (No skolem info) with QuantifiedConstraints and strange scoping","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":["QuantifiedConstraints","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program panics with GHC 8.6.3 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE ConstraintKinds #}\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE QuantifiedConstraints #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype Const a b = a\r\ntype SameKind (a :: k) (b :: k) = (() :: Constraint)\r\nclass (forall (b :: k). SameKind a b) => C (k :: Const Type a)\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.3/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:11:36: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.3 for x86_64unknownlinux):\r\n No skolem info:\r\n [k1_a1X4[sk:1]]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors\r\n}}}\r\n\r\nAs with #16244, I imagine that the real culprit is that `SameKind a b` would force `a :: k`, which would be illscoped.","type_of_failure":"OtherFailure","blocking":[]} >https://gitlab.haskell.org/ghc/ghc//issues/16247GHC 8.6 Core Lint regression (Kind application error)20190707T18:00:49ZRyan ScottGHC 8.6 Core Lint regression (Kind application error)The following program produces a Core Lint error on GHC 8.6.3 and HEAD:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
data SameKind :: forall k. k > k > Type
data Foo :: forall a k (b :: k). SameKind a b > Type where
MkFoo :: Foo sameKind
```
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs dcorelint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of CorePrep ***
<no location info>: warning:
In the type ‘forall k (a :: k) k (b :: k) (sameKind :: SameKind
a b).
Foo sameKind’
Kind application error in type ‘SameKind a_aWE b_aWG’
Function kind = forall k. k > k > *
Arg kinds = [(k_aWF, *), (a_aWE, k_aWD), (b_aWG, k_aWF)]
Fun: k_aWF
(a_aWE, k_aWD)
*** Offending Program ***
<elided>
MkFoo
:: forall k (a :: k) k (b :: k) (sameKind :: SameKind a b).
Foo sameKind
```
(Confusingly, the type of `MkFoo` is rendered as `forall k (a :: k) k (b :: k) (sameKind :: SameKind a b). Foo sameKind` in that `dcorelint` error, but I think it really should be `forall k1 (a :: k1) k2 (b :: k2) (sameKind :: SameKind a b). Foo sameKind`.)
On GHC 8.4.4 and earlier, this simply produces an error message:
```
$ /opt/ghc/8.4.4/bin/ghc Bug.hs dcorelint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:9:13: error:
• These kind and type variables: a k (b :: k)
are out of dependency order. Perhaps try this ordering:
k (a :: k) (b :: k)
• In the kind ‘forall a k (b :: k). SameKind a b > Type’

9  data Foo :: forall a k (b :: k). SameKind a b > Type where
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC 8.6 Core Lint regression (Kind application error)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program produces a Core Lint error on GHC 8.6.3 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata SameKind :: forall k. k > k > Type\r\ndata Foo :: forall a k (b :: k). SameKind a b > Type where\r\n MkFoo :: Foo sameKind\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.6.3/bin/ghc Bug.hs dcorelint \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of CorePrep ***\r\n<no location info>: warning:\r\n In the type ‘forall k (a :: k) k (b :: k) (sameKind :: SameKind\r\n a b).\r\n Foo sameKind’\r\n Kind application error in type ‘SameKind a_aWE b_aWG’\r\n Function kind = forall k. k > k > *\r\n Arg kinds = [(k_aWF, *), (a_aWE, k_aWD), (b_aWG, k_aWF)]\r\n Fun: k_aWF\r\n (a_aWE, k_aWD)\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\nMkFoo\r\n :: forall k (a :: k) k (b :: k) (sameKind :: SameKind a b).\r\n Foo sameKind\r\n}}}\r\n\r\n(Confusingly, the type of `MkFoo` is rendered as `forall k (a :: k) k (b :: k) (sameKind :: SameKind a b). Foo sameKind` in that `dcorelint` error, but I think it really should be `forall k1 (a :: k1) k2 (b :: k2) (sameKind :: SameKind a b). Foo sameKind`.)\r\n\r\nOn GHC 8.4.4 and earlier, this simply produces an error message:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.4/bin/ghc Bug.hs dcorelint\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:9:13: error:\r\n • These kind and type variables: a k (b :: k)\r\n are out of dependency order. Perhaps try this ordering:\r\n k (a :: k) (b :: k)\r\n • In the kind ‘forall a k (b :: k). SameKind a b > Type’\r\n \r\n9  data Foo :: forall a k (b :: k). SameKind a b > Type where\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >The following program produces a Core Lint error on GHC 8.6.3 and HEAD:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE ScopedTypeVariables #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
data SameKind :: forall k. k > k > Type
data Foo :: forall a k (b :: k). SameKind a b > Type where
MkFoo :: Foo sameKind
```
```
$ /opt/ghc/8.6.3/bin/ghc Bug.hs dcorelint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of CorePrep ***
<no location info>: warning:
In the type ‘forall k (a :: k) k (b :: k) (sameKind :: SameKind
a b).
Foo sameKind’
Kind application error in type ‘SameKind a_aWE b_aWG’
Function kind = forall k. k > k > *
Arg kinds = [(k_aWF, *), (a_aWE, k_aWD), (b_aWG, k_aWF)]
Fun: k_aWF
(a_aWE, k_aWD)
*** Offending Program ***
<elided>
MkFoo
:: forall k (a :: k) k (b :: k) (sameKind :: SameKind a b).
Foo sameKind
```
(Confusingly, the type of `MkFoo` is rendered as `forall k (a :: k) k (b :: k) (sameKind :: SameKind a b). Foo sameKind` in that `dcorelint` error, but I think it really should be `forall k1 (a :: k1) k2 (b :: k2) (sameKind :: SameKind a b). Foo sameKind`.)
On GHC 8.4.4 and earlier, this simply produces an error message:
```
$ /opt/ghc/8.4.4/bin/ghc Bug.hs dcorelint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:9:13: error:
• These kind and type variables: a k (b :: k)
are out of dependency order. Perhaps try this ordering:
k (a :: k) (b :: k)
• In the kind ‘forall a k (b :: k). SameKind a b > Type’

9  data Foo :: forall a k (b :: k). SameKind a b > Type where
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.6.3 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"GHC 8.6 Core Lint regression (Kind application error)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.10.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program produces a Core Lint error on GHC 8.6.3 and HEAD:\r\n\r\n{{{#!hs\r\n{# LANGUAGE GADTs #}\r\n{# LANGUAGE ScopedTypeVariables #}\r\n{# LANGUAGE TypeInType #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata SameKind :: forall k. k > k > Type\r\ndata Foo :: forall a k (b :: k). SameKind a b > Type where\r\n MkFoo :: Foo sameKind\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.6.3/bin/ghc Bug.hs dcorelint \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of CorePrep ***\r\n<no location info>: warning:\r\n In the type ‘forall k (a :: k) k (b :: k) (sameKind :: SameKind\r\n a b).\r\n Foo sameKind’\r\n Kind application error in type ‘SameKind a_aWE b_aWG’\r\n Function kind = forall k. k > k > *\r\n Arg kinds = [(k_aWF, *), (a_aWE, k_aWD), (b_aWG, k_aWF)]\r\n Fun: k_aWF\r\n (a_aWE, k_aWD)\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\nMkFoo\r\n :: forall k (a :: k) k (b :: k) (sameKind :: SameKind a b).\r\n Foo sameKind\r\n}}}\r\n\r\n(Confusingly, the type of `MkFoo` is rendered as `forall k (a :: k) k (b :: k) (sameKind :: SameKind a b). Foo sameKind` in that `dcorelint` error, but I think it really should be `forall k1 (a :: k1) k2 (b :: k2) (sameKind :: SameKind a b). Foo sameKind`.)\r\n\r\nOn GHC 8.4.4 and earlier, this simply produces an error message:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.4/bin/ghc Bug.hs dcorelint\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:9:13: error:\r\n • These kind and type variables: a k (b :: k)\r\n are out of dependency order. Perhaps try this ordering:\r\n k (a :: k) (b :: k)\r\n • In the kind ‘forall a k (b :: k). SameKind a b > Type’\r\n \r\n9  data Foo :: forall a k (b :: k). SameKind a b > Type where\r\n  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} >8.10.1https://gitlab.haskell.org/ghc/ghc//issues/16255Visible kind application defeats type family with higherrank result kind20190707T18:00:47ZRyan ScottVisible kind application defeats type family with higherrank result kindAfter #15740, GHC now (correctly) rejects this program:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
module Bug where
import Data.Kind
data SBool :: Bool > Type
type family F :: forall k. k > Type where
F = SBool
```
```
$ ~/Software/ghc5/inplace/bin/ghcstage2 interactive Bug.hs
GHCi, version 8.7.20190115: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:12:7: error:
• Expected kind ‘forall k. k > *’,
but ‘SBool’ has kind ‘Bool > *’
• In the type ‘SBool’
In the type family declaration for ‘F’

12  F = SBool
 ^^^^^
```
However, there's a very simple way to circumvent this: add a visible kind application to `F`'s equation.
```hs
type family F :: forall k. k > Type where
F @Bool = SBool
```
If I understand things correctly, GHC shouldn't allow this.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Visible kind application defeats type family with higherrank result kind","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeApplications,","TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"After #15740, GHC now (correctly) rejects this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata SBool :: Bool > Type\r\ntype family F :: forall k. k > Type where\r\n F = SBool\r\n}}}\r\n{{{\r\n$ ~/Software/ghc5/inplace/bin/ghcstage2 interactive Bug.hs\r\nGHCi, version 8.7.20190115: https://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:12:7: error:\r\n • Expected kind ‘forall k. k > *’,\r\n but ‘SBool’ has kind ‘Bool > *’\r\n • In the type ‘SBool’\r\n In the type family declaration for ‘F’\r\n \r\n12  F = SBool\r\n  ^^^^^\r\n}}}\r\n\r\nHowever, there's a very simple way to circumvent this: add a visible kind application to `F`'s equation.\r\n\r\n{{{#!hs\r\ntype family F :: forall k. k > Type where\r\n F @Bool = SBool\r\n}}}\r\n\r\nIf I understand things correctly, GHC shouldn't allow this.","type_of_failure":"OtherFailure","blocking":[]} >After #15740, GHC now (correctly) rejects this program:
```hs
{# LANGUAGE DataKinds #}
{# LANGUAGE PolyKinds #}
{# LANGUAGE RankNTypes #}
{# LANGUAGE TypeApplications #}
{# LANGUAGE TypeFamilies #}
module Bug where
import Data.Kind
data SBool :: Bool > Type
type family F :: forall k. k > Type where
F = SBool
```
```
$ ~/Software/ghc5/inplace/bin/ghcstage2 interactive Bug.hs
GHCi, version 8.7.20190115: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:12:7: error:
• Expected kind ‘forall k. k > *’,
but ‘SBool’ has kind ‘Bool > *’
• In the type ‘SBool’
In the type family declaration for ‘F’

12  F = SBool
 ^^^^^
```
However, there's a very simple way to circumvent this: add a visible kind application to `F`'s equation.
```hs
type family F :: forall k. k > Type where
F @Bool = SBool
```
If I understand things correctly, GHC shouldn't allow this.
<details><summary>Trac metadata</summary>
 Trac field  Value 
    
 Version  8.7 
 Type  Bug 
 TypeOfFailure  OtherFailure 
 Priority  normal 
 Resolution  Unresolved 
 Component  Compiler (Type checker) 
 Test case  
 Differential revisions  
 BlockedBy  
 Related  
 Blocking  
 CC  
 Operating system  
 Architecture  
</details>
<! {"blocked_by":[],"summary":"Visible kind application defeats type family with higherrank result kind","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["TypeApplications,","TypeFamilies"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"After #15740, GHC now (correctly) rejects this program:\r\n\r\n{{{#!hs\r\n{# LANGUAGE DataKinds #}\r\n{# LANGUAGE PolyKinds #}\r\n{# LANGUAGE RankNTypes #}\r\n{# LANGUAGE TypeApplications #}\r\n{# LANGUAGE TypeFamilies #}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata SBool :: Bool > Type\r\ntype family F :: forall k. k > Type where\r\n F = SBool\r\n}}}\r\n{{{\r\n$ ~/Software/ghc5/inplace/bin/ghcstage2 interactive Bug.hs\r\nGHCi, version 8.7.20190115: https://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Bug.hs, interpreted )\r\n\r\nBug.hs:12:7: error:\r\n • Expected kind ‘forall k. k > *’,\r\n but ‘SBool’ has kind ‘Bool > *’\r\n • In the type ‘SBool’\r\n In the type family declaration for ‘F’\r\n \r\n12  F = SBool\r\n  ^^^^^\r\n}}}\r\n\r\nHowever, there's a very simple way to circumvent this: add a visible kind application to `F`'s equation.\r\n\r\n{{{#!hs\r\ntype family F :: forall k. k > Type where\r\n F @Bool = SBool\r\n}}}\r\n\r\nIf I understand things correctly, GHC shouldn't allow this.","type_of_failure":"OtherFailure","blocking":[]} >8.8.1https://gitlab.haskell.org/ghc/ghc//issues/16334Named wildcards in kinds20200326T11:47:19ZVladislav ZavialovNamed wildcards in kindsThis works:
```
Prelude> :set XNamedWildCards XPartialTypeSignatures XPolyKinds
Prelude> k :: (Int :: _); k = 42
<interactive>:2:14: warning: [Wpartialtypesignatures]
• Found type wildcard ‘_’ standing for ‘*’
• In the type signature: k :: (Int :: _)
```
And this doesn't:
```
Prelude> k :: (Int :: _t); k = 42
<interactive>:3:7: error:
• Expected kind ‘_t’, but ‘Int’ has kind ‘*’
• In the type signature: k :: (Int :: _t)
```
The issue, I suspect, is in `partition_nwcs`, which ignores kind variables for some reason.This works:
```
Prelude> :set XNamedWildCards XPartialTypeSignatures XPolyKinds
Prelude> k :: (Int :: _); k = 42
<interactive>:2:14: warning: [Wpartialtypesignatures]
• Found type wildcard ‘_’ standing for ‘*’
• In the type signature: k :: (Int :: _)
```
And this doesn't:
```
Prelude> k :: (Int :: _t); k = 42
<interactive>:3:7: error:
• Expected kind ‘_t’, but ‘Int’ has kind ‘*’
• In the type signature: k :: (Int :: _t)
```
The issue, I suspect, is in `partition_nwcs`, which ignores kind variables for some reason.8.10.1https://gitlab.haskell.org/ghc/ghc//issues/16347GHC HEAD regression: piResultTys120190707T18:00:25ZRyan ScottGHC HEAD regression: piResultTys1The following program typechecks on GHC 8.0.2 through 8.6.3, but panics on HEAD:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
data T f :: f Type > Type where
MkT :: T f a
```
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20190219 for x86_64unknownlinux):
piResultTys1
k_a10k[tau:1]
[*]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1063:5 in ghc:Type
```The following program typechecks on GHC 8.0.2 through 8.6.3, but panics on HEAD:
```hs
{# LANGUAGE GADTs #}
{# LANGUAGE TypeInType #}
module Bug where
import Data.Kind
data T f :: f Type > Type where
MkT :: T f a
```
```
$ ~/Software/ghc4/inplace/bin/ghcstage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghcstage2: panic! (the 'impossible' happened)
(GHC version 8.7.20190219 for x86_64unknownlinux):
piResultTys1
k_a10k[tau:1]
[*]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1063:5 in ghc:Type
```8.10.1https://gitlab.haskell.org/ghc/ghc//issues/16356