GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2022-02-08T15:14:11Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/11463Template Haskell applies too many arguments to kind synonym2022-02-08T15:14:11ZRyan ScottTemplate Haskell applies too many arguments to kind synonymRunning the following code:
```hs
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeInType #-}
module IdStarK where
import Data.Kind
import Language.Haskell.TH
type Id a = a
data Proxy (a :: Id k) = Proxy
$(return [])
main :: IO ()
...Running the following code:
```hs
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeInType #-}
module IdStarK where
import Data.Kind
import Language.Haskell.TH
type Id a = a
data Proxy (a :: Id k) = Proxy
$(return [])
main :: IO ()
main = do
putStrLn $(reify ''Proxy >>= stringE . pprint)
putStrLn $(reify ''Proxy >>= stringE . show)
```
Gives a result I wouldn't have expected:
```
$ /opt/ghc/head/bin/runghc IdStarK.hs
data IdStarK.Proxy (a_0 :: IdStarK.Id * k_1) = IdStarK.Proxy
TyConI (DataD [] IdStarK.Proxy [KindedTV a_1627394516 (AppT (AppT (ConT IdStarK.Id) StarT) (VarT k_1627394515))] Nothing [NormalC IdStarK.Proxy []] [])
```
From the output, it appears that `Id` is being applied to *two* arguments, both `*` and `k`! Perhaps this indirectly (or directly) a consequence of #11376?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 8.0.1-rc1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | #11376 |
| Blocking | |
| CC | goldfire |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Template Haskell applies too many arguments to kind synonym","status":"New","operating_system":"","component":"Template Haskell","related":[11376],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc1","keywords":["TypeApplications","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":["goldfire"],"type":"Bug","description":"Running the following code:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE TypeInType #-}\r\nmodule IdStarK where\r\n\r\nimport Data.Kind\r\nimport Language.Haskell.TH\r\n\r\ntype Id a = a\r\ndata Proxy (a :: Id k) = Proxy\r\n\r\n$(return [])\r\n\r\nmain :: IO ()\r\nmain = do\r\n putStrLn $(reify ''Proxy >>= stringE . pprint)\r\n putStrLn $(reify ''Proxy >>= stringE . show)\r\n}}}\r\n\r\nGives a result I wouldn't have expected:\r\n\r\n{{{\r\n$ /opt/ghc/head/bin/runghc IdStarK.hs \r\ndata IdStarK.Proxy (a_0 :: IdStarK.Id * k_1) = IdStarK.Proxy\r\nTyConI (DataD [] IdStarK.Proxy [KindedTV a_1627394516 (AppT (AppT (ConT IdStarK.Id) StarT) (VarT k_1627394515))] Nothing [NormalC IdStarK.Proxy []] [])\r\n}}}\r\n\r\nFrom the output, it appears that `Id` is being applied to ''two'' arguments, both `*` and `k`! Perhaps this indirectly (or directly) a consequence of #11376?","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11453Kinds in type synonym/data declarations can unexpectedly unify2019-07-07T18:30:21ZRyan ScottKinds in type synonym/data declarations can unexpectedly unifyWhile trying out ideas to fix [this lens issue](https://github.com/ekmett/lens/issues/626), I noticed a couple of peculiar things about kinds in type synonym and data declarations. For example:
```
$ /opt/ghc/head/bin/ghci -XTypeInType ...While trying out ideas to fix [this lens issue](https://github.com/ekmett/lens/issues/626), I noticed a couple of peculiar things about kinds in type synonym and data declarations. For example:
```
$ /opt/ghc/head/bin/ghci -XTypeInType -XRankNTypes -XTypeOperators
GHCi, version 8.1.20160113: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/xnux/.ghci
λ> import Data.Kind
λ> type Wat (a :: k2) (b :: k3) = forall (f :: k1 -> *). Either (f a) (f b)
λ> :i Wat
type Wat (a :: k1) (b :: k1) =
forall (f :: k1 -> *). Either (f a) (f b)
-- Defined at <interactive>:2:1
```
This is pretty odd for two reasons. One, the kind `k1` was never specified (either existentially or as a visible kind binder), so that definition should have been rejected. But even if we do use an existential kind:
```
λ> type Wat (a :: k2) (b :: k3) = forall k1 (f :: k1 -> *). Either (f a) (f b)
λ> :i Wat
type Wat (a :: k1) (b :: k1) =
forall k2 (f :: k2 -> *). Either (f a) (f b)
-- Defined at <interactive>:4:1
```
We still see the second issue: GHC thinks that the type variables `a` and `b` have the same kind `k1`, when they should have separate kinds `k1` and `k2`! That behavior is very surprising to me, since it seems like GHC is choosing to unify two kind variables that should be rigid.
Note that this doesn't happen if you use explicit kind binders:
```
type Wat k2 k3 (a :: k2) (b :: k3) = forall k1 (f :: k1 -> *). Either (f a) (f b)
<interactive>:6:74: error:
• Expected kind ‘k1’, but ‘a’ has kind ‘k2’
• In the first argument of ‘f’, namely ‘a’
In the first argument of ‘Either’, namely ‘f a’
In the type ‘forall k1 (f :: k1 -> *). Either (f a) (f b)’
<interactive>:6:80: error:
• Expected kind ‘k1’, but ‘b’ has kind ‘k3’
• In the first argument of ‘f’, namely ‘b’
In the second argument of ‘Either’, namely ‘f b’
In the type ‘forall k1 (f :: k1 -> *). Either (f a) (f b)’
```
only when the kinds are specified but not visible.
<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":"Kinds in type synonym/data declarations can unexpectedly unify","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":"While trying out ideas to fix [https://github.com/ekmett/lens/issues/626 this lens issue], I noticed a couple of peculiar things about kinds in type synonym and data declarations. For example:\r\n\r\n{{{\r\n$ /opt/ghc/head/bin/ghci -XTypeInType -XRankNTypes -XTypeOperators\r\nGHCi, version 8.1.20160113: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/xnux/.ghci\r\nλ> import Data.Kind\r\nλ> type Wat (a :: k2) (b :: k3) = forall (f :: k1 -> *). Either (f a) (f b)\r\nλ> :i Wat\r\ntype Wat (a :: k1) (b :: k1) =\r\n forall (f :: k1 -> *). Either (f a) (f b)\r\n -- Defined at <interactive>:2:1\r\n}}}\r\n\r\nThis is pretty odd for two reasons. One, the kind {{{k1}}} was never specified (either existentially or as a visible kind binder), so that definition should have been rejected. But even if we do use an existential kind:\r\n\r\n{{{\r\nλ> type Wat (a :: k2) (b :: k3) = forall k1 (f :: k1 -> *). Either (f a) (f b)\r\nλ> :i Wat\r\ntype Wat (a :: k1) (b :: k1) =\r\n forall k2 (f :: k2 -> *). Either (f a) (f b)\r\n -- Defined at <interactive>:4:1\r\n}}}\r\n\r\nWe still see the second issue: GHC thinks that the type variables `a` and `b` have the same kind `k1`, when they should have separate kinds `k1` and `k2`! That behavior is very surprising to me, since it seems like GHC is choosing to unify two kind variables that should be rigid.\r\n\r\nNote that this doesn't happen if you use explicit kind binders:\r\n\r\n{{{\r\ntype Wat k2 k3 (a :: k2) (b :: k3) = forall k1 (f :: k1 -> *). Either (f a) (f b)\r\n\r\n<interactive>:6:74: error:\r\n • Expected kind ‘k1’, but ‘a’ has kind ‘k2’\r\n • In the first argument of ‘f’, namely ‘a’\r\n In the first argument of ‘Either’, namely ‘f a’\r\n In the type ‘forall k1 (f :: k1 -> *). Either (f a) (f b)’\r\n\r\n<interactive>:6:80: error:\r\n • Expected kind ‘k1’, but ‘b’ has kind ‘k3’\r\n • In the first argument of ‘f’, namely ‘b’\r\n In the second argument of ‘Either’, namely ‘f b’\r\n In the type ‘forall k1 (f :: k1 -> *). Either (f a) (f b)’\r\n}}}\r\n\r\nonly when the kinds are specified but not visible.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/11416GHC mistakenly believes datatype with type synonym in its type can't be eta-r...2019-07-07T18:30:31ZRyan ScottGHC mistakenly believes datatype with type synonym in its type can't be eta-reducedI uncovered this when playing around with `-XTypeInType`:
```hs
{-# LANGUAGE DeriveFunctor, TypeInType #-}
module CantEtaReduce1 where
import Data.Kind
type ConstantT a b = a
newtype T (f :: * -> *) (a :: ConstantT * f) = T (f a) deri...I uncovered this when playing around with `-XTypeInType`:
```hs
{-# LANGUAGE DeriveFunctor, TypeInType #-}
module CantEtaReduce1 where
import Data.Kind
type ConstantT a b = a
newtype T (f :: * -> *) (a :: ConstantT * f) = T (f a) deriving Functor
```
This fails because it thinks that you can't reduce the last type variable of `T`, since it mentions another type variable (`f`):
```
• Cannot eta-reduce to an instance of form
instance (...) => Functor (T f)
• In the newtype declaration for ‘T
```
But it *should* be able to, since `ConstantT * f` reduces to `*`, and the equivalent declaration `newtype T (f :: * -> *) (a :: *) = ...` eta-reduces just fine.
I marked this as appearing in GHC 8.1 since you need `-XTypeInType` to have kind synonyms, but this can also happen in earlier GHC versions with data families:
```hs
{-# LANGUAGE DeriveFunctor, PolyKinds, TypeFamilies #-}
module CantEtaReduce2 where
type ConstantT a b = a
data family T (f :: * -> *) (a :: *)
newtype instance T f (ConstantT a f) = T (f a) deriving Functor
```
I believe the fix will be to apply `coreView` with precision to parts of the code which typecheck `deriving` statements so that these type synonyms are peeled off.
<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":"GHC mistakenly believes datatype with type synonym in its type can't be eta-reduced","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 uncovered this when playing around with `-XTypeInType`:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DeriveFunctor, TypeInType #-}\r\nmodule CantEtaReduce1 where\r\n\r\nimport Data.Kind\r\n\r\ntype ConstantT a b = a\r\nnewtype T (f :: * -> *) (a :: ConstantT * f) = T (f a) deriving Functor\r\n}}}\r\n\r\nThis fails because it thinks that you can't reduce the last type variable of `T`, since it mentions another type variable (`f`):\r\n\r\n{{{\r\n • Cannot eta-reduce to an instance of form\r\n instance (...) => Functor (T f)\r\n • In the newtype declaration for ‘T\r\n}}}\r\n\r\nBut it ''should'' be able to, since `ConstantT * f` reduces to `*`, and the equivalent declaration `newtype T (f :: * -> *) (a :: *) = ...` eta-reduces just fine.\r\n\r\nI marked this as appearing in GHC 8.1 since you need `-XTypeInType` to have kind synonyms, but this can also happen in earlier GHC versions with data families:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DeriveFunctor, PolyKinds, TypeFamilies #-}\r\nmodule CantEtaReduce2 where\r\n\r\ntype ConstantT a b = a\r\ndata family T (f :: * -> *) (a :: *)\r\nnewtype instance T f (ConstantT a f) = T (f a) deriving Functor\r\n}}}\r\n\r\nI believe the fix will be to apply `coreView` with precision to parts of the code which typecheck `deriving` statements so that these type synonyms are peeled off.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11410Quantification over unlifted type variable2019-07-07T18:30:32ZRichard Eisenbergrae@richarde.devQuantification over unlifted type variableThis silliness is accepted:
```
data X (a :: TYPE 'Unlifted) = X
```
I will fix.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version |...This silliness is accepted:
```
data X (a :: TYPE 'Unlifted) = X
```
I will fix.
<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 | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Quantification over unlifted type variable","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"8.1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This silliness is accepted:\r\n\r\n{{{\r\ndata X (a :: TYPE 'Unlifted) = X\r\n}}}\r\n\r\nI will fix.","type_of_failure":"OtherFailure","blocking":[]} -->Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11407-XTypeInType uses up all memory when used in data family instance2019-07-07T18:30:33ZRyan Scott-XTypeInType uses up all memory when used in data family instanceCompiling this code with GHC 8.1 causes all my memory to be used very quickly:
```hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module TypeInTypeEatsAllMemory where
import Data.Kind
type Const a b = a
data family UhOh ...Compiling this code with GHC 8.1 causes all my memory to be used very quickly:
```hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module TypeInTypeEatsAllMemory where
import Data.Kind
type Const a b = a
data family UhOh (f :: k1) (a :: k2) (b :: k3)
data instance UhOh (f :: * -> * -> *) (a :: forall a) (b :: Const * a) = UhOh
```
On the other hand, this code compiles without issue:
```hs
{-# LANGUAGE TypeInType #-}
module TypeInTypeEatsAllMemory where
import Data.Kind
type Const a b = a
data UhOh (f :: * -> * -> *) (a :: forall a) (b :: Const * a) = UhOh
```
<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":"-XTypeInType uses up all memory when used in data family instance","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":"Compiling this code with GHC 8.1 causes all my memory to be used very quickly:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\nmodule TypeInTypeEatsAllMemory where\r\n\r\nimport Data.Kind\r\n\r\ntype Const a b = a\r\n\r\ndata family UhOh (f :: k1) (a :: k2) (b :: k3)\r\ndata instance UhOh (f :: * -> * -> *) (a :: forall a) (b :: Const * a) = UhOh\r\n}}}\r\n\r\nOn the other hand, this code compiles without issue:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TypeInType #-}\r\nmodule TypeInTypeEatsAllMemory where\r\n\r\nimport Data.Kind\r\n\r\ntype Const a b = a\r\n\r\ndata UhOh (f :: * -> * -> *) (a :: forall a) (b :: Const * a) = UhOh\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11405Incorrect failure of type-level skolem escape check2019-07-07T18:30:34ZRichard Eisenbergrae@richarde.devIncorrect failure of type-level skolem escape checkFrom [D1739](https://phabricator.haskell.org/D1739).
When you say
```hs
undefined :: forall (v :: Levity). forall (a :: TYPE v). (?callStack :: CallStack) => a
```
you get a skolem escape failure because GHC things that the kind of `(...From [D1739](https://phabricator.haskell.org/D1739).
When you say
```hs
undefined :: forall (v :: Levity). forall (a :: TYPE v). (?callStack :: CallStack) => a
```
you get a skolem escape failure because GHC things that the kind of `(?callStack :: CallStack) => a` is `TYPE v`. It should be `*`.
I will fix.8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11404The type variable used in a kind is still used2019-07-07T18:30:34ZRichard Eisenbergrae@richarde.devThe type variable used in a kind is still usedFrom [D1739](https://phabricator.haskell.org/D1739).
When you say
```
undefined :: forall (v :: Levity) (a :: TYPE v). (?callStack :: CallStack) => a
```
you get a warning that `v` is unused.
I will fix.
<details><summary>Trac metad...From [D1739](https://phabricator.haskell.org/D1739).
When you say
```
undefined :: forall (v :: Levity) (a :: TYPE v). (?callStack :: CallStack) => a
```
you get a warning that `v` is unused.
I will fix.
<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 | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"The type variable used in a kind is still used","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"8.1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"From Phab:D1739.\r\n\r\nWhen you say\r\n\r\n{{{\r\nundefined :: forall (v :: Levity) (a :: TYPE v). (?callStack :: CallStack) => a\r\n}}}\r\n\r\nyou get a warning that `v` is unused.\r\n\r\nI will fix.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11401No match in record selector ctev_dest2019-07-07T18:30:35ZLemmingNo match in record selector ctev_destWith the llvm-tf package I got the following problem:
```
$ cat RecordSelectorCtevDest.hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module RecordSelectorCtevDest where
newty...With the llvm-tf package I got the following problem:
```
$ cat RecordSelectorCtevDest.hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module RecordSelectorCtevDest where
newtype Value a = Value a
newtype CodeGen r a = CodeGen a
bind :: CodeGen r a -> (a -> CodeGen r b) -> CodeGen r b
bind (CodeGen a) k = k a
class
(f ~ CalledFunction g, r ~ CallerResult g, g ~ CallerFunction f r) =>
CallArgs f g r where
type CalledFunction g :: *
type CallerResult g :: *
type CallerFunction f r :: *
call :: f -> g
instance CallArgs (IO a) (CodeGen r (Value a)) r where
type CalledFunction (CodeGen r (Value a)) = IO a
type CallerResult (CodeGen r (Value a)) = r
type CallerFunction (IO a) r = CodeGen r (Value a)
call = undefined
instance CallArgs b b' r => CallArgs (a -> b) (Value a -> b') r where
type CalledFunction (Value a -> b') = a -> CalledFunction b'
type CallerResult (Value a -> b') = CallerResult b'
type CallerFunction (a -> b) r = Value a -> CallerFunction b r
call = undefined
test :: IO a -> (a -> IO ()) -> CodeGen () (Value ())
test start stop = bind (call start) (call stop)
$ ghci-8.0.0.20160109 RecordSelectorCtevDest.hs
GHCi, version 8.0.0.20160109: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling RecordSelectorCtevDest ( RecordSelectorCtevDest.hs, interpreted )
*** Exception: No match in record selector ctev_dest
```
The problem disappears when I remove the 'r' parameter from CodeGen, CallArgs and CallerFunction and remove the CallerResult consequently.8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://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.dev