GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:30:35Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/11400* is not an indexed type family2019-07-07T18:30:35ZRyan Scott* is not an indexed type familyI can't seem to create an indexed data family using the kind `*` with `-XTypeInType` enabled. I have to work around it by using `Type`:
```
$ /opt/ghc/head/bin/ghci
GHCi, version 8.1.20160108: http://www.haskell.org/ghc/ :? for help
λ>...I can't seem to create an indexed data family using the kind `*` with `-XTypeInType` enabled. I have to work around it by using `Type`:
```
$ /opt/ghc/head/bin/ghci
GHCi, version 8.1.20160108: http://www.haskell.org/ghc/ :? for help
λ> :set -XTypeInType -XTypeFamilies
λ> import Data.Kind
λ> data family IdxProxy k (a :: k)
λ> data instance IdxProxy * a
<interactive>:5:1: error:
• Illegal family instance for ‘*’
(* is not an indexed type family)
• In the data instance declaration for ‘*’
λ> data instance IdxProxy Type a
λ> :kind! IdxProxy *
IdxProxy * :: * -> *
= IdxProxy *
λ> :kind! IdxProxy Type
IdxProxy Type :: Type -> *
= IdxProxy Type
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"* is not an indexed type family","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"I can't seem to create an indexed data family using the kind `*` with `-XTypeInType` enabled. I have to work around it by using `Type`:\r\n\r\n{{{\r\n$ /opt/ghc/head/bin/ghci\r\nGHCi, version 8.1.20160108: http://www.haskell.org/ghc/ :? for help\r\nλ> :set -XTypeInType -XTypeFamilies \r\nλ> import Data.Kind\r\nλ> data family IdxProxy k (a :: k)\r\nλ> data instance IdxProxy * a\r\n\r\n<interactive>:5:1: error:\r\n • Illegal family instance for ‘*’\r\n (* is not an indexed type family)\r\n • In the data instance declaration for ‘*’\r\nλ> data instance IdxProxy Type a\r\nλ> :kind! IdxProxy *\r\nIdxProxy * :: * -> *\r\n= IdxProxy *\r\nλ> :kind! IdxProxy Type\r\nIdxProxy Type :: Type -> *\r\n= IdxProxy Type\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.2.2https://gitlab.haskell.org/ghc/ghc/-/issues/11399Ill-kinded instance head involving -XTypeInType can invoke GHC panic2019-07-07T18:30:35ZRyan ScottIll-kinded instance head involving -XTypeInType can invoke GHC panicThis code:
```hs
{-# LANGUAGE FlexibleInstances, TypeInType #-}
module FvProvFallsIntoAHole where
import Data.Kind
newtype UhOh (k :: * -> *) (a :: k *) = UhOh (k *)
instance Functor k => Functor (UhOh k) where
```
produces this GHC ...This code:
```hs
{-# LANGUAGE FlexibleInstances, TypeInType #-}
module FvProvFallsIntoAHole where
import Data.Kind
newtype UhOh (k :: * -> *) (a :: k *) = UhOh (k *)
instance Functor k => Functor (UhOh k) where
```
produces this GHC panic:
```
$ /opt/ghc/head/bin/ghc FvProvFallsIntoAHole.hs
[1 of 1] Compiling FvProvFallsIntoAHole ( FvProvFallsIntoAHole.hs, FvProvFallsIntoAHole.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.1.20160108 for x86_64-unknown-linux):
fvProv falls into a hole {aq6}
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Ill-kinded instance head involving -XTypeInType can invoke GHC panic","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"This code:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE FlexibleInstances, TypeInType #-}\r\nmodule FvProvFallsIntoAHole where\r\n\r\nimport Data.Kind\r\n\r\nnewtype UhOh (k :: * -> *) (a :: k *) = UhOh (k *)\r\ninstance Functor k => Functor (UhOh k) where\r\n}}}\r\n\r\nproduces this GHC panic:\r\n\r\n{{{\r\n$ /opt/ghc/head/bin/ghc FvProvFallsIntoAHole.hs\r\n[1 of 1] Compiling FvProvFallsIntoAHole ( FvProvFallsIntoAHole.hs, FvProvFallsIntoAHole.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.1.20160108 for x86_64-unknown-linux):\r\n fvProv falls into a hole {aq6}\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11376Inconsistent specified type variables among functions and datatypes/classes w...2019-07-07T18:30:40ZRyan ScottInconsistent specified type variables among functions and datatypes/classes when using -XTypeApplicationsOriginally reported [here](https://mail.haskell.org/pipermail/ghc-devs/2016-January/010915.html). When applying types via `-XTypeApplications`, the type/kind that gets instantiated seems to be different depending on whether you're using ...Originally reported [here](https://mail.haskell.org/pipermail/ghc-devs/2016-January/010915.html). When applying types via `-XTypeApplications`, the type/kind that gets instantiated seems to be different depending on whether you're using functions, datatypes, or typeclasses.
Here's an example contrasting functions and datatypes:
```
$ /opt/ghc/head/bin/ghci
GHCi, version 8.1.20160106: http://www.haskell.org/ghc/ :? for help
λ> :set -fprint-explicit-kinds -XTypeApplications -XTypeInType
λ> data Prox a = Prox
λ> prox :: Prox a; prox = Prox
λ> :t prox
prox :: forall k (a :: k). Prox k a
λ> :t prox @Int
prox @Int :: Prox * Int
λ> :t Prox
Prox :: forall k (a :: k). Prox k a
λ> :t Prox @Int
Prox @Int :: Prox Int a
```
This is the core of the problem: with a function, `Int` seems to be applied to type variable `a`, whereas with data types, `Int` appears to be applied to the kind variable `k`. This confuses me, since `k` wasn't specified anywhere in the definition of `Prox`.
Andres Löh also [observed](https://mail.haskell.org/pipermail/ghc-devs/2016-January/010916.html) a similar discrepancy between functions and typeclasses:
```
λ> :set -XScopedTypeVariables
λ> class C a where c :: ()
λ> d :: forall a. C a => (); d = c @_ @a
λ> :t d
d :: forall k (a :: k). C k a => ()
λ> :t d @Int
d @Int :: C * Int => ()
λ> :t c
c :: forall k (a :: k). C k a => ()
λ> :t c @Int
c @Int :: C Int a => ()
λ> :t c @_ @Int
c @_ @Int :: C * Int => ()
```
EDIT: See also documentation infelicity in [ticket:11376\#comment:113518](https://gitlab.haskell.org//ghc/ghc/issues/11376#note_113518).
EDIT: Most of this is fix, as of March 25. But the data family stuff in [ticket:11376\#comment:114637](https://gitlab.haskell.org//ghc/ghc/issues/11376#note_114637) is still outstanding, and we need a test case.8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11362T6137 doesn't pass with reversed uniques2019-07-07T18:30:44ZniteriaT6137 doesn't pass with reversed uniquesIt fails with (full trace https://phabricator.haskell.org/P81):
```
*** Core Lint errors : in result of Tidy Core ***
<no location info>: warning:
[in body of lambda with binder dt_a18nYf :: In
...It fails with (full trace https://phabricator.haskell.org/P81):
```
*** Core Lint errors : in result of Tidy Core ***
<no location info>: warning:
[in body of lambda with binder dt_a18nYf :: In
f_a18o2M
(Sum1 r_a18o2L (In ('F f_a18o2M) r_a18o2L))
o_a18o2K]
Kind application error in
coercion ‘Sym
(TFCo:R:InioFro[0]
<o_a18nYC>_N <i_a18nYD>_N <f_a18o2M>_N) <r_a18o2L>_N <o_a18o2K>_N’
Function kind = Code (Sum i_a18nYD o_a18nYC) o_a18nYC -> *
Arg kinds = [(o_a18o2K, o_a18nYC)]
<no location info>: warning:
[in body of lambda with binder dt_a18nYf :: In
f_a18o2M
(Sum1 r_a18o2L (In ('F f_a18o2M) r_a18o2L))
o_a18o2K]
Kind application error in
coercion ‘Sym
(TFCo:R:InioFro[0]
<o_a18nYC>_N <i_a18nYD>_N <f_a18o2M>_N) <r_a18o2L>_N <o_a18o2K>_N’
Function kind = Code (Sum i_a18nYD o_a18nYC) o_a18nYC -> *
Arg kinds = [(o_a18o2K, o_a18nYC)]
```
Steps to reproduce:
1. Add line
`TEST_HC_OPTS += -dinitial-unique=16777000 -dunique-increment=-1`
after line
`TEST_HC_OPTS = -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-$(GhcPackageDbFlag) -rtsopts $(EXTRA_HC_OPTS)`
in `mk/test.mk`
1. `make TESTS=T6137`
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | --------------------------- |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire, simonmar, simonpj |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"T6137 doesn't pass with reversed uniques","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire","simonmar","simonpj"],"type":"Bug","description":"It fails with (full trace https://phabricator.haskell.org/P81):\r\n\r\n{{{\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_a18nYf :: In\r\n f_a18o2M\r\n (Sum1 r_a18o2L (In ('F f_a18o2M) r_a18o2L))\r\n o_a18o2K]\r\n Kind application error in\r\n coercion ‘Sym\r\n (TFCo:R:InioFro[0]\r\n <o_a18nYC>_N <i_a18nYD>_N <f_a18o2M>_N) <r_a18o2L>_N <o_a18o2K>_N’\r\n Function kind = Code (Sum i_a18nYD o_a18nYC) o_a18nYC -> *\r\n Arg kinds = [(o_a18o2K, o_a18nYC)]\r\n<no location info>: warning:\r\n [in body of lambda with binder dt_a18nYf :: In\r\n f_a18o2M\r\n (Sum1 r_a18o2L (In ('F f_a18o2M) r_a18o2L))\r\n o_a18o2K]\r\n Kind application error in\r\n coercion ‘Sym\r\n (TFCo:R:InioFro[0]\r\n <o_a18nYC>_N <i_a18nYD>_N <f_a18o2M>_N) <r_a18o2L>_N <o_a18o2K>_N’\r\n Function kind = Code (Sum i_a18nYD o_a18nYC) o_a18nYC -> *\r\n Arg kinds = [(o_a18o2K, o_a18nYC)]\r\n}}}\r\n\r\n\r\nSteps to reproduce:\r\n\r\n1. Add line\r\n`TEST_HC_OPTS += -dinitial-unique=16777000 -dunique-increment=-1` \r\n\r\nafter line\r\n\r\n`TEST_HC_OPTS = -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-$(GhcPackageDbFlag) -rtsopts $(EXTRA_HC_OPTS)` \r\n\r\nin `mk/test.mk`\r\n\r\n2. `make TESTS=T6137`\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1niterianiteriahttps://gitlab.haskell.org/ghc/ghc/-/issues/11357Regression when deriving Generic1 on poly-kinded data family2019-07-07T18:30:45ZRyan ScottRegression when deriving Generic1 on poly-kinded data familyOn GHC 7.10.3, the following code compiles:
```hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module ProxyFam where
import GHC.Generics (Generic1)
data family...On GHC 7.10.3, the following code compiles:
```hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module ProxyFam where
import GHC.Generics (Generic1)
data family ProxyFam (a :: k)
data instance ProxyFam (a :: k) = ProxyCon deriving Generic1
```
But on GHC 8.1, it fails:
```
$ /opt/ghc/head/bin/ghc ProxyFam.hs
[1 of 1] Compiling ProxyFam ( ProxyFam.hs, ProxyFam.o )
ProxyFam.hs:10:53: error:
• Can't make a derived instance of ‘Generic1 ProxyFam’:
ProxyFam must not be instantiated; try deriving `ProxyFam k a' instead
• In the data instance declaration for ‘ProxyFam’
```
I'm not sure what exactly is going on here, but I have a hunch. The `Generic1` typeclass is of kind `* -> *`, which means that in a `Generic1 ProxyFam` instance, the kind of `a` is instantiated to `*`.
Curiously, though, the same error does *not* appear when `deriving Generic` for a normal datatype (e.g., `data ProxyFam (a :: k) = ProxyCon deriving Generic1`).
Richard, I'm stuck as to how to fix this. I suspect this was triggered by `-XTypeInType`-related changes, specifically, [this change](http://git.haskell.org/ghc.git/blobdiff/6e56ac58a6905197412d58e32792a04a63b94d7e..6746549772c5cc0ac66c0fce562f297f4d4b80a2:/compiler/typecheck/TcGenGenerics.hs):
```diff
diff --git a/compiler/typecheck/TcGenGenerics.hs b/compiler/typecheck/TcGenGenerics.hs
index 2c5b80e..fb18517 100644 (file)
--- a/compiler/typecheck/TcGenGenerics.hs
+++ b/compiler/typecheck/TcGenGenerics.hs
@@ -147,7 +146,7 @@ canDoGenerics tc tc_args
--
-- Data family indices can be instantiated; the `tc_args` here are
-- the representation tycon args
- (if (all isTyVarTy (filterOut isKind tc_args))
+ (if (all isTyVarTy (filterOutInvisibleTypes tc tc_args))
then IsValid
else NotValid (tc_name <+> text "must not be instantiated;" <+>
text "try deriving `" <> tc_name <+> tc_tys <>
```
What exactly does `filterOutInvisibleTypes` do?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------------ |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (CodeGen) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Regression when deriving Generic1 on poly-kinded data family","status":"New","operating_system":"","component":"Compiler (CodeGen)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":["Generics,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"On GHC 7.10.3, the following code compiles:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DeriveGeneric #-}\r\n{-# LANGUAGE KindSignatures #-}\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\nmodule ProxyFam where\r\n\r\nimport GHC.Generics (Generic1)\r\n\r\ndata family ProxyFam (a :: k)\r\ndata instance ProxyFam (a :: k) = ProxyCon deriving Generic1\r\n}}}\r\n\r\nBut on GHC 8.1, it fails:\r\n\r\n{{{\r\n$ /opt/ghc/head/bin/ghc ProxyFam.hs \r\n[1 of 1] Compiling ProxyFam ( ProxyFam.hs, ProxyFam.o )\r\n\r\nProxyFam.hs:10:53: error:\r\n • Can't make a derived instance of ‘Generic1 ProxyFam’:\r\n ProxyFam must not be instantiated; try deriving `ProxyFam k a' instead\r\n • In the data instance declaration for ‘ProxyFam’\r\n}}}\r\n\r\nI'm not sure what exactly is going on here, but I have a hunch. The `Generic1` typeclass is of kind `* -> *`, which means that in a `Generic1 ProxyFam` instance, the kind of `a` is instantiated to `*`.\r\n\r\nCuriously, though, the same error does ''not'' appear when `deriving Generic` for a normal datatype (e.g., `data ProxyFam (a :: k) = ProxyCon deriving Generic1`).\r\n\r\nRichard, I'm stuck as to how to fix this. I suspect this was triggered by `-XTypeInType`-related changes, specifically, [http://git.haskell.org/ghc.git/blobdiff/6e56ac58a6905197412d58e32792a04a63b94d7e..6746549772c5cc0ac66c0fce562f297f4d4b80a2:/compiler/typecheck/TcGenGenerics.hs this change]:\r\n\r\n{{{#!diff\r\ndiff --git a/compiler/typecheck/TcGenGenerics.hs b/compiler/typecheck/TcGenGenerics.hs\r\nindex 2c5b80e..fb18517 100644 (file)\r\n--- a/compiler/typecheck/TcGenGenerics.hs\r\n+++ b/compiler/typecheck/TcGenGenerics.hs\r\n@@ -147,7 +146,7 @@ canDoGenerics tc tc_args\r\n --\r\n -- Data family indices can be instantiated; the `tc_args` here are\r\n -- the representation tycon args\r\n- (if (all isTyVarTy (filterOut isKind tc_args))\r\n+ (if (all isTyVarTy (filterOutInvisibleTypes tc tc_args))\r\n then IsValid\r\n else NotValid (tc_name <+> text \"must not be instantiated;\" <+>\r\n text \"try deriving `\" <> tc_name <+> tc_tys <>\r\n}}}\r\n\r\nWhat exactly does `filterOutInvisibleTypes` do?","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11356GHC panic2019-07-07T18:30:46ZIcelandjackGHC panicThe attached file causes GHC (version 8.1.20160102) panic.
I tried shrinking, attached code is bogus at this point.
Interestingly inlining the type synonym `T = Nat` into Category's superclass context fixes the panic, and causes a regu...The attached file causes GHC (version 8.1.20160102) panic.
I tried shrinking, attached code is bogus at this point.
Interestingly inlining the type synonym `T = Nat` into Category's superclass context fixes the panic, and causes a regular error.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.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":"GHC panic","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The attached file causes GHC (version 8.1.20160102) panic.\r\n\r\nI tried shrinking, attached code is bogus at this point.\r\n\r\nInterestingly inlining the type synonym `T = Nat` into Category's superclass context fixes the panic, and causes a regular error.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11339Possible type-checker regression in GHC 8.02019-07-07T18:30:52ZHerbert Valerio Riedelhvr@gnu.orgPossible type-checker regression in GHC 8.0The following code (extracted from hackage:microlens) type-checks on GHC 7.10 but **not** on GHC 8.0/8.1:
```hs
{-# LANGUAGE RankNTypes, ScopedTypeVariables #-}
module Failing where
import Control.Applicative ( Const(Const, getConst) ...The following code (extracted from hackage:microlens) type-checks on GHC 7.10 but **not** on GHC 8.0/8.1:
```hs
{-# LANGUAGE RankNTypes, ScopedTypeVariables #-}
module Failing where
import Control.Applicative ( Const(Const, getConst) )
import Data.Functor.Identity ( Identity(Identity) )
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
failing :: forall s t a b . Traversal s t a b -> Traversal s t a b -> Traversal s t a b
failing left right afb s = case pins t of
[] -> right afb s
_ -> t afb
where
-- t :: (a -> f b) -> f t
-- TYPECHECKS with GHC 7.10, but not with GHC 8.x:
Bazaar { getBazaar = t } = left sell s
-- FAILS TO TYPECHECK with GHC 7.10 and GHC 8.x:
-- t = getBazaar (left sell s)
sell :: a -> Bazaar a b b
sell w = Bazaar ($ w)
pins :: ((a -> Const [Identity a] b) -> Const [Identity a] t) -> [Identity a]
pins f = getConst (f (\ra -> Const [Identity ra]))
newtype Bazaar a b t = Bazaar { getBazaar :: (forall f. Applicative f => (a -> f b) -> f t) }
instance Functor (Bazaar a b) where
fmap f (Bazaar k) = Bazaar (fmap f . k)
instance Applicative (Bazaar a b) where
pure a = Bazaar $ \_ -> pure a
Bazaar mf <*> Bazaar ma = Bazaar $ \afb -> mf afb <*> ma afb
```
The following error is emitted on GHC 8.0:
```
failing.hs:13:11: error:
• Couldn't match type ‘f’ with ‘Const [Identity a]’
‘f’ is a rigid type variable bound by
the type signature for:
failing :: forall (f :: * -> *). Applicative f => Traversal s t a b -> Traversal s t a b -> (a -> f b) -> s -> f t
at failing.hs:11:1
Expected type: a -> Const [Identity a] b
Actual type: a -> f b
• In the first argument of ‘t’, namely ‘afb’
In the expression: t afb
In a case alternative: _ -> t afb
• Relevant bindings include
t :: (a -> Const [Identity a] b) -> Const [Identity a] t (bound at failing.hs:18:26)
sell :: a -> Bazaar a b b (bound at failing.hs:24:5)
pins :: ((a -> Const [Identity a] b) -> Const [Identity a] t) -> [Identity a] (bound at failing.hs:27:5)
afb :: a -> f b (bound at failing.hs:11:20)
right :: Traversal s t a b (bound at failing.hs:11:14)
left :: Traversal s t a b (bound at failing.hs:11:9)
failing :: Traversal s t a b -> Traversal s t a b -> Traversal s t a b (bound at failing.hs:11:1)
```
I don't understand why `Bazaar t = ...` vs `t = getBazaar ...` makes a difference in GHC 7.10 at all. So I'm not sure if this is a regression or actually something that got fixed in GHC 8.0...
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | bgamari, simonpj |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Possible type-checker regression in GHC 8.0","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["bgamari","simonpj"],"type":"Bug","description":"The following code (extracted from hackage:microlens) type-checks on GHC 7.10 but '''not''' on GHC 8.0/8.1:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE RankNTypes, ScopedTypeVariables #-}\r\n\r\nmodule Failing where\r\n\r\nimport Control.Applicative ( Const(Const, getConst) )\r\nimport Data.Functor.Identity ( Identity(Identity) )\r\n\r\ntype Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t\r\n\r\nfailing :: forall s t a b . Traversal s t a b -> Traversal s t a b -> Traversal s t a b\r\nfailing left right afb s = case pins t of\r\n [] -> right afb s\r\n _ -> t afb\r\n where\r\n -- t :: (a -> f b) -> f t\r\n\r\n -- TYPECHECKS with GHC 7.10, but not with GHC 8.x:\r\n Bazaar { getBazaar = t } = left sell s\r\n\r\n -- FAILS TO TYPECHECK with GHC 7.10 and GHC 8.x:\r\n -- t = getBazaar (left sell s)\r\n\r\n sell :: a -> Bazaar a b b\r\n sell w = Bazaar ($ w)\r\n\r\n pins :: ((a -> Const [Identity a] b) -> Const [Identity a] t) -> [Identity a]\r\n pins f = getConst (f (\\ra -> Const [Identity ra]))\r\n\r\nnewtype Bazaar a b t = Bazaar { getBazaar :: (forall f. Applicative f => (a -> f b) -> f t) }\r\n\r\ninstance Functor (Bazaar a b) where\r\n fmap f (Bazaar k) = Bazaar (fmap f . k)\r\n\r\ninstance Applicative (Bazaar a b) where\r\n pure a = Bazaar $ \\_ -> pure a\r\n Bazaar mf <*> Bazaar ma = Bazaar $ \\afb -> mf afb <*> ma afb\r\n}}}\r\n\r\nThe following error is emitted on GHC 8.0:\r\n\r\n{{{\r\nfailing.hs:13:11: error:\r\n • Couldn't match type ‘f’ with ‘Const [Identity a]’\r\n ‘f’ is a rigid type variable bound by\r\n the type signature for:\r\n failing :: forall (f :: * -> *). Applicative f => Traversal s t a b -> Traversal s t a b -> (a -> f b) -> s -> f t\r\n at failing.hs:11:1\r\n Expected type: a -> Const [Identity a] b\r\n Actual type: a -> f b\r\n • In the first argument of ‘t’, namely ‘afb’\r\n In the expression: t afb\r\n In a case alternative: _ -> t afb\r\n • Relevant bindings include\r\n t :: (a -> Const [Identity a] b) -> Const [Identity a] t (bound at failing.hs:18:26)\r\n sell :: a -> Bazaar a b b (bound at failing.hs:24:5)\r\n pins :: ((a -> Const [Identity a] b) -> Const [Identity a] t) -> [Identity a] (bound at failing.hs:27:5)\r\n afb :: a -> f b (bound at failing.hs:11:20)\r\n right :: Traversal s t a b (bound at failing.hs:11:14)\r\n left :: Traversal s t a b (bound at failing.hs:11:9)\r\n failing :: Traversal s t a b -> Traversal s t a b -> Traversal s t a b (bound at failing.hs:11:1)\r\n}}}\r\n\r\n\r\nI don't understand why `Bazaar t = ...` vs `t = getBazaar ...` makes a difference in GHC 7.10 at all. So I'm not sure if this is a regression or actually something that got fixed in GHC 8.0...","type_of_failure":"OtherFailure","blocking":[]} -->8.0.2Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/11334GHC panic when calling typeOf on a promoted data constructor2019-07-07T18:30:53ZRyan ScottGHC panic when calling typeOf on a promoted data constructorHere's what I did in GHCi to trigger the panic:
```
$ inplace/bin/ghc-stage2 --interactive
GHCi, version 8.1.20160101: http://www.haskell.org/ghc/ :? for help
λ> :set -XDataKinds
λ> :m Data.Typeable Data.Functor.Compose
λ> typeOf (Prox...Here's what I did in GHCi to trigger the panic:
```
$ inplace/bin/ghc-stage2 --interactive
GHCi, version 8.1.20160101: http://www.haskell.org/ghc/ :? for help
λ> :set -XDataKinds
λ> :m Data.Typeable Data.Functor.Compose
λ> typeOf (Proxy :: Proxy 'Compose)
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.1.20160101 for x86_64-unknown-linux):
piResultTy
*
TYPE 'Lifted *
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Enabling `-XPolyKinds` doesn't trigger the error, though; #10343 will be triggered instead:
```
λ> :set -XPolyKinds
λ> typeOf (Proxy :: Proxy 'Compose)
<interactive>:5:1: error:
• No instance for (Typeable a0) arising from a use of ‘typeOf’
• In the expression: typeOf (Proxy :: Proxy Compose)
In an equation for ‘it’: it = typeOf (Proxy :: Proxy Compose)
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC panic when calling typeOf on a promoted data constructor","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"Here's what I did in GHCi to trigger the panic:\r\n\r\n{{{\r\n$ inplace/bin/ghc-stage2 --interactive\r\nGHCi, version 8.1.20160101: http://www.haskell.org/ghc/ :? for help\r\nλ> :set -XDataKinds\r\nλ> :m Data.Typeable Data.Functor.Compose\r\nλ> typeOf (Proxy :: Proxy 'Compose)\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 8.1.20160101 for x86_64-unknown-linux):\r\n piResultTy\r\n *\r\n TYPE 'Lifted *\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nEnabling `-XPolyKinds` doesn't trigger the error, though; #10343 will be triggered instead:\r\n\r\n{{{\r\nλ> :set -XPolyKinds\r\nλ> typeOf (Proxy :: Proxy 'Compose)\r\n\r\n<interactive>:5:1: error:\r\n • No instance for (Typeable a0) arising from a use of ‘typeOf’\r\n • In the expression: typeOf (Proxy :: Proxy Compose)\r\n In an equation for ‘it’: it = typeOf (Proxy :: Proxy Compose)\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11266Can't :browse some modules with GHCi 7.112019-07-07T18:31:12ZRyan ScottCan't :browse some modules with GHCi 7.11Trying to `:browse` certain modules with GHCi fails with GHC 7.11:
```
$ inplace/bin/ghc-stage2 --interactive
GHCi, version 7.11.20151219: http://www.haskell.org/ghc/ :? for help
λ> :browse GHC.Base
($) ::
forall (w :: GHC.Types.Levi...Trying to `:browse` certain modules with GHCi fails with GHC 7.11:
```
$ inplace/bin/ghc-stage2 --interactive
GHCi, version 7.11.20151219: http://www.haskell.org/ghc/ :? for help
λ> :browse GHC.Base
($) ::
forall (w :: GHC.Types.Levity) a (b :: TYPE w). (a -> b) -> a -> b
($!) :: (a -> b) -> a -> b
<lots of output elided>
data Ordering*** Exception: No match in record selector tyConTyVars
λ> :browse GHC.Exts
class GHC.Exts.IsList l where
type family GHC.Exts.Item l
Kind: * -> *
GHC.Exts.fromList :: [GHC.Exts.Item l] -> l
GHC.Exts.fromListN :: Int -> [GHC.Exts.Item l] -> l
GHC.Exts.toList :: l -> [GHC.Exts.Item l]
{-# MINIMAL fromList, toList #-}
<lots of output elided>
data GHC.Prim.MutableByteArray# a*** Exception: No match in record selector tyConTyVars
λ> :browse GHC.Prim
*** Exception: No match in record selector tyConTyVars
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Can't :browse some modules with GHCi 7.11","status":"New","operating_system":"","component":"GHCi","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Trying to `:browse` certain modules with GHCi fails with GHC 7.11:\r\n\r\n{{{\r\n$ inplace/bin/ghc-stage2 --interactive\r\nGHCi, version 7.11.20151219: http://www.haskell.org/ghc/ :? for help\r\nλ> :browse GHC.Base\r\n($) ::\r\n forall (w :: GHC.Types.Levity) a (b :: TYPE w). (a -> b) -> a -> b\r\n($!) :: (a -> b) -> a -> b\r\n<lots of output elided>\r\ndata Ordering*** Exception: No match in record selector tyConTyVars\r\nλ> :browse GHC.Exts\r\nclass GHC.Exts.IsList l where\r\n type family GHC.Exts.Item l\r\n Kind: * -> *\r\n GHC.Exts.fromList :: [GHC.Exts.Item l] -> l\r\n GHC.Exts.fromListN :: Int -> [GHC.Exts.Item l] -> l\r\n GHC.Exts.toList :: l -> [GHC.Exts.Item l]\r\n {-# MINIMAL fromList, toList #-}\r\n<lots of output elided>\r\ndata GHC.Prim.MutableByteArray# a*** Exception: No match in record selector tyConTyVars\r\nλ> :browse GHC.Prim\r\n*** Exception: No match in record selector tyConTyVars\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11252:kind command hides the explicit kind2019-07-07T18:31:15ZIcelandjack:kind command hides the explicit kind```hs
-- /tmp/test.hs
{-# LANGUAGE TypeInType #-}
data Proxy1 k (a :: k) = P1
data Proxy2 (a :: k) = P2
```
if I load the following into ghci (head) the `:kind` command gives the same result
```haskell
% ghci -ignore-dot-ghci /tmp/t...```hs
-- /tmp/test.hs
{-# LANGUAGE TypeInType #-}
data Proxy1 k (a :: k) = P1
data Proxy2 (a :: k) = P2
```
if I load the following into ghci (head) the `:kind` command gives the same result
```haskell
% ghci -ignore-dot-ghci /tmp/test.hs
GHCi, version 7.11.20151216: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( test.hs, interpreted )
Ok, modules loaded: Main.
*Main> :kind Proxy1
Proxy1 :: k -> *
*Main> :kind Proxy2
Proxy2 :: k -> *
```
edit: I asked on \#ghc, was told this was undesirable8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11246Regression typechecking type synonym which includes `Any`.2019-07-07T18:31:17ZMatthew PickeringRegression typechecking type synonym which includes `Any`.```hs
module Foo where
import GHC.Exts
type Key a = Any
```
produces the error message on HEAD but compiles on 7.8.3 and 7.10.1 (thanks to Reid for testing).
```
unsafeany.hs:5:1: error:
• The type family ‘Any’ should have no arg...```hs
module Foo where
import GHC.Exts
type Key a = Any
```
produces the error message on HEAD but compiles on 7.8.3 and 7.10.1 (thanks to Reid for testing).
```
unsafeany.hs:5:1: error:
• The type family ‘Any’ should have no arguments, but has been given none
• In the type synonym declaration for ‘Key’
Failed, modules loaded: none.
```8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11241Kind-level PartialTypeSignatures causes internal error2019-07-07T18:31:19ZAdam GundryKind-level PartialTypeSignatures causes internal errorConsider the following module:
```hs
{-# LANGUAGE ExplicitForAll, KindSignatures, PartialTypeSignatures #-}
foo :: forall (a :: _) . a -> a
foo = id
```
In HEAD, this fails with an internal errror:
```
• GHC internal error: ‘_’...Consider the following module:
```hs
{-# LANGUAGE ExplicitForAll, KindSignatures, PartialTypeSignatures #-}
foo :: forall (a :: _) . a -> a
foo = id
```
In HEAD, this fails with an internal errror:
```
• GHC internal error: ‘_’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: []
• In the kind ‘_’
In the type signature:
foo :: forall (a :: _). a -> a
```
I would expect it to succeed and figure out that the wildcard is `*`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Kind-level PartialTypeSignatures causes internal error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"Consider the following module:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE ExplicitForAll, KindSignatures, PartialTypeSignatures #-}\r\n\r\nfoo :: forall (a :: _) . a -> a \r\nfoo = id \r\n}}}\r\n\r\nIn HEAD, this fails with an internal errror:\r\n\r\n{{{\r\n • GHC internal error: ‘_’ is not in scope during type checking, but it passed the renamer\r\n tcl_env of environment: []\r\n • In the kind ‘_’\r\n In the type signature:\r\n foo :: forall (a :: _). a -> a\r\n}}}\r\n\r\nI would expect it to succeed and figure out that the wildcard is `*`.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11196TypeInType performance regressions2021-03-31T16:11:18ZRichard Eisenbergrae@richarde.devTypeInType performance regressionsThis ticket is to track the handful of performance regressions seen with the addition of `TypeInType`. It is quite possibly a good idea to break these out into separate tickets, but until we investigate, they're all bundled here.
The re...This ticket is to track the handful of performance regressions seen with the addition of `TypeInType`. It is quite possibly a good idea to break these out into separate tickets, but until we investigate, they're all bundled here.
The regressions are (all in bytes allocated, unless otherwise noted):
- T3064, up by 14.9%
- T5030, up by 61.8%
- T5837, up by 13%
- T5321Fun, up by 11%
- T5631, up by 39%
- T9872d, **down** by 22% (see below)
- T9872a, up by 33.6%
- T9872c, up by 59.4%
- T9872b, up by 49.4%
- T9675, up by 29.7%, and peak megabytes allocated up by 28.4%
- haddock.base, up by 12.4%
- haddock.Cabal, up by 9.5%
I did add an optimization around type family reduction (the function `zonk_eq_types` in !TcCanonical) that could cause such a drastic reduction.8.4.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.dev