GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:29:43Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/11582Redundant constraints warning complains that (a ~ b) is redundant2019-07-07T18:29:43ZBen GamariRedundant constraints warning complains that (a ~ b) is redundantLemming came up with an interesting example where the redundant constraints warning is arguable a bit too trigger-happy in #10635. Consider,
```hs
asTypeOf :: a -> a -> a
asTypeOf x _ = x
```
We could equivalently rewrite this with an ...Lemming came up with an interesting example where the redundant constraints warning is arguable a bit too trigger-happy in #10635. Consider,
```hs
asTypeOf :: a -> a -> a
asTypeOf x _ = x
```
We could equivalently rewrite this with an equality constraint,
```hs
asTypeOf1 :: (a ~ b) => a -> b -> a
asTypeOf1 x _ = x
```
If compiled with GHC 8.0 with `-Wredundant-constraints` we see a warning,
```
hi.hs:4:1: warning:
• Redundant constraint: a ~ b
• In the type signature for:
asTypeOf1 :: (a ~ b) => a -> b -> a
```
But is this really unused? We may not have referenced the constraint in the RHS, but surely the typechecker has gleaned something from it.
Perhaps we should simply ignore equality constraints when generating redundant constraint warnings?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1-rc2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | Lemming |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Redundant constraints warning complains that (a ~ b) is redundant","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["Lemming"],"type":"Bug","description":"Lemming came up with an interesting example where the redundant constraints warning is arguable a bit too trigger-happy in #10635. Consider,\r\n{{{#!hs\r\nasTypeOf :: a -> a -> a\r\nasTypeOf x _ = x\r\n}}}\r\nWe could equivalently rewrite this with an equality constraint,\r\n{{{#!hs\r\nasTypeOf1 :: (a ~ b) => a -> b -> a\r\nasTypeOf1 x _ = x\r\n}}}\r\nIf compiled with GHC 8.0 with `-Wredundant-constraints` we see a warning,\r\n{{{\r\nhi.hs:4:1: warning:\r\n • Redundant constraint: a ~ b\r\n • In the type signature for:\r\n asTypeOf1 :: (a ~ b) => a -> b -> a\r\n}}}\r\nBut is this really unused? We may not have referenced the constraint in the RHS, but surely the typechecker has gleaned something from it.\r\n\r\nPerhaps we should simply ignore equality constraints when generating redundant constraint warnings?","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11573Inferred CallStacks expose implicit parameter2019-07-07T18:29:45ZBen GamariInferred CallStacks expose implicit parameterIt was noticed (in a thread on ghc-devs) that introducing a CallStack-carrying term into the RHS of a let binding in GHCi produces a type which itself carries a callstack.
I could be wrong but as far as I know this is a bug: the solver ...It was noticed (in a thread on ghc-devs) that introducing a CallStack-carrying term into the RHS of a let binding in GHCi produces a type which itself carries a callstack.
I could be wrong but as far as I know this is a bug: the solver should never introduce a constraint that the user didn't write; it should merely provide an empty callstack in the event that a callstack constraint can't be solved.
```
Prelude> let myList = [1, 2, 3 :: Integer]
Prelude> let myList' = myList ++ undefined
Prelude> :t myList
myList :: [Integer]
Prelude> :t myList'
myList' :: (?callStack::GHC.Stack.Types.CallStack) => [Integer]
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1-rc2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | gridaphobe |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"CallStacks show up unexpectedly in type of local binding in GHCi","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["gridaphobe"],"type":"Bug","description":"It was noticed (in a thread on ghc-devs) that introducing a CallStack-carrying term into the RHS of a let binding in GHCi produces a type which itself carries a callstack.\r\n\r\nI could be wrong but as far as I know this is a bug: the solver should never introduce a constraint that the user didn't write; it should merely provide an empty callstack in the event that a callstack constraint can't be solved.\r\n\r\n{{{\r\nPrelude> let myList = [1, 2, 3 :: Integer]\r\nPrelude> let myList' = myList ++ undefined\r\nPrelude> :t myList\r\nmyList :: [Integer]\r\nPrelude> :t myList'\r\nmyList' :: (?callStack::GHC.Stack.Types.CallStack) => [Integer]\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Eric SeidelEric Seidelhttps://gitlab.haskell.org/ghc/ghc/-/issues/11541Type errors sometimes has a lot of irrelevant information2019-07-07T18:29:54Zlennart@augustsson.netType errors sometimes has a lot of irrelevant informationHere's an example.
The essential part of the error message is
```
Couldn't match type `DeclS IString TLoc' with `DeclHeadS IString l'
```
This is buried somewhere in the middle. Fixing this problem makes all the others go away. It ...Here's an example.
The essential part of the error message is
```
Couldn't match type `DeclS IString TLoc' with `DeclHeadS IString l'
```
This is buried somewhere in the middle. Fixing this problem makes all the others go away. It seems ghc spits out constraints that it hasn't solved, but they are unsolved because there was a type error.
Full message:
```
Stem\Mu\Deriving.hs:214:93:
No instance for (Integral b0) arising from a use of `constr'
The type variable `b0' is ambiguous
Note: there are several potential instances:
instance Integral Int -- Defined in `GHC.Real'
instance Integral Integer -- Defined in `GHC.Real'
instance Integral GHC.Types.Word -- Defined in `GHC.Real'
...plus 8 others
In the first argument of `zipWith', namely `constr'
In the second argument of `($)', namely `zipWith constr qs [0 .. ]'
In the expression: List () $ zipWith constr qs [0 .. ]
Stem\Mu\Deriving.hs:214:103:
No instance for (Enum b0)
arising from the arithmetic sequence `0 .. '
The type variable `b0' is ambiguous
Note: there are several potential instances:
instance Enum GeneralCategory -- Defined in `Data.Char'
instance Enum InlInfo -- Defined in `Cortex.Stem.Mu.Util'
instance Enum Double -- Defined in `GHC.Float'
...plus 24 others
In the third argument of `zipWith', namely `[0 .. ]'
In the second argument of `($)', namely `zipWith constr qs [0 .. ]'
In the expression: List () $ zipWith constr qs [0 .. ]
Stem\Mu\Deriving.hs:214:104:
No instance for (Num b0) arising from the literal `0'
The type variable `b0' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the expression: 0
In the third argument of `zipWith', namely `[0 .. ]'
In the second argument of `($)', namely `zipWith constr qs [0 .. ]'
Stem\Mu\Deriving.hs:285:28:
No instance for (Integral a0) arising from a use of `list'
The type variable `a0' is ambiguous
Note: there are several potential instances:
instance Integral Int -- Defined in `GHC.Real'
instance Integral Integer -- Defined in `GHC.Real'
instance Integral GHC.Types.Word -- Defined in `GHC.Real'
...plus 8 others
In the second argument of `($)', namely
`list
10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)'
In the second argument of `($)', namely
`shows
$ list
10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)'
In the expression:
method (PApp () (UnQual () $ dropAnn n) (map (PVar ()) vs))
$ shows
$ list
10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)
Stem\Mu\Deriving.hs:285:33:
No instance for (Num a0) arising from the literal `10'
The type variable `a0' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the first argument of `list', namely `10'
In the second argument of `($)', namely
`list
10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)'
In the second argument of `($)', namely
`shows
$ list
10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)'
Stem\Mu\Deriving.hs:285:72:
No instance for (Integral a1) arising from a use of `mkInt'
The type variable `a1' is ambiguous
Note: there are several potential instances:
instance Integral Int -- Defined in `GHC.Real'
instance Integral Integer -- Defined in `GHC.Real'
instance Integral GHC.Types.Word -- Defined in `GHC.Real'
...plus 8 others
In the first argument of `ashow', namely `(mkInt () 11)'
In the first argument of `(.)', namely `ashow (mkInt () 11)'
In the first argument of `map', namely
`(ashow (mkInt () 11) . qvar)'
Stem\Mu\Deriving.hs:285:81:
No instance for (Num a1) arising from the literal `11'
The type variable `a1' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the second argument of `mkInt', namely `11'
In the first argument of `ashow', namely `(mkInt () 11)'
In the first argument of `(.)', namely `ashow (mkInt () 11)'
Stem\Mu\Deriving.hs:288:44:
No instance for (Show a3) arising from a use of `var'
The type variable `a3' is ambiguous
Note: there are several potential instances:
instance Show GeneralCategory -- Defined in `Data.Char'
instance Show IString -- Defined in `Cortex.Utils.IString'
instance Show a => Show (Cortex.Utils.List.Down a)
-- Defined in `Cortex.Utils.List'
...plus 171 others
In the second argument of `PVar', namely `(var 0)'
In the second argument of `PInfixApp', namely `(PVar () (var 0))'
In the first argument of `method', namely
`(PInfixApp
() (PVar () (var 0)) (UnQual () $ dropAnn n) (PVar () (var 1)))'
Stem\Mu\Deriving.hs:288:48:
No instance for (Num a3) arising from the literal `0'
The type variable `a3' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the first argument of `var', namely `0'
In the second argument of `PVar', namely `(var 0)'
In the second argument of `PInfixApp', namely `(PVar () (var 0))'
Stem\Mu\Deriving.hs:288:86:
No instance for (Show a4) arising from a use of `var'
The type variable `a4' is ambiguous
Note: there are several potential instances:
instance Show GeneralCategory -- Defined in `Data.Char'
instance Show IString -- Defined in `Cortex.Utils.IString'
instance Show a => Show (Cortex.Utils.List.Down a)
-- Defined in `Cortex.Utils.List'
...plus 171 others
In the second argument of `PVar', namely `(var 1)'
In the fourth argument of `PInfixApp', namely `(PVar () (var 1))'
In the first argument of `method', namely
`(PInfixApp
() (PVar () (var 0)) (UnQual () $ dropAnn n) (PVar () (var 1)))'
Stem\Mu\Deriving.hs:288:90:
No instance for (Num a4) arising from the literal `1'
The type variable `a4' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the first argument of `var', namely `1'
In the second argument of `PVar', namely `(var 1)'
In the fourth argument of `PInfixApp', namely `(PVar () (var 1))'
Stem\Mu\Deriving.hs:289:28:
No instance for (Integral a5) arising from a use of `list'
The type variable `a5' is ambiguous
Note: there are several potential instances:
instance Integral Int -- Defined in `GHC.Real'
instance Integral Integer -- Defined in `GHC.Real'
instance Integral GHC.Types.Word -- Defined in `GHC.Real'
...plus 8 others
In the second argument of `($)', namely
`list
(precOf n)
[ashow pp $ qvar $ var 0, mkstr (nameString n),
ashow pp $ qvar $ var 1]'
In the second argument of `($)', namely
`shows
$ list
(precOf n)
[ashow pp $ qvar $ var 0, mkstr (nameString n),
ashow pp $ qvar $ var 1]'
In the expression:
method
(PInfixApp
() (PVar () (var 0)) (UnQual () $ dropAnn n) (PVar () (var 1)))
$ shows
$ list
(precOf n)
[ashow pp $ qvar $ var 0, mkstr (nameString n),
ashow pp $ qvar $ var 1]
Stem\Mu\Deriving.hs:289:34:
No instance for (Num a5) arising from a use of `precOf'
The type variable `a5' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the first argument of `list', namely `(precOf n)'
In the second argument of `($)', namely
`list
(precOf n)
[ashow pp $ qvar $ var 0, mkstr (nameString n),
ashow pp $ qvar $ var 1]'
In the second argument of `($)', namely
`shows
$ list
(precOf n)
[ashow pp $ qvar $ var 0, mkstr (nameString n),
ashow pp $ qvar $ var 1]'
Stem\Mu\Deriving.hs:289:63:
No instance for (Show a6) arising from a use of `var'
The type variable `a6' is ambiguous
Note: there are several potential instances:
instance Show GeneralCategory -- Defined in `Data.Char'
instance Show IString -- Defined in `Cortex.Utils.IString'
instance Show a => Show (Cortex.Utils.List.Down a)
-- Defined in `Cortex.Utils.List'
...plus 171 others
In the second argument of `($)', namely `var 0'
In the second argument of `($)', namely `qvar $ var 0'
In the expression: ashow pp $ qvar $ var 0
Stem\Mu\Deriving.hs:289:67:
No instance for (Num a6) arising from the literal `0'
The type variable `a6' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the first argument of `var', namely `0'
In the second argument of `($)', namely `var 0'
In the second argument of `($)', namely `qvar $ var 0'
Stem\Mu\Deriving.hs:289:110:
No instance for (Show a7) arising from a use of `var'
The type variable `a7' is ambiguous
Note: there are several potential instances:
instance Show GeneralCategory -- Defined in `Data.Char'
instance Show IString -- Defined in `Cortex.Utils.IString'
instance Show a => Show (Cortex.Utils.List.Down a)
-- Defined in `Cortex.Utils.List'
...plus 171 others
In the second argument of `($)', namely `var 1'
In the second argument of `($)', namely `qvar $ var 1'
In the expression: ashow pp $ qvar $ var 1
Stem\Mu\Deriving.hs:289:114:
No instance for (Num a7) arising from the literal `1'
The type variable `a7' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the first argument of `var', namely `1'
In the second argument of `($)', namely `var 1'
In the second argument of `($)', namely `qvar $ var 1'
Stem\Mu\Deriving.hs:290:37:
No instance for (Integral a2) arising from a use of `mkInt'
The type variable `a2' is ambiguous
Note: there are several potential instances:
instance Integral Int -- Defined in `GHC.Real'
instance Integral Integer -- Defined in `GHC.Real'
instance Integral GHC.Types.Word -- Defined in `GHC.Real'
...plus 8 others
In the expression: mkInt () (precOf n + 1)
In an equation for `pp': pp = mkInt () (precOf n + 1)
In an equation for `sh':
sh (QualConDecl _ _ _ (InfixConDecl _ t1 n t2))
= method
(PInfixApp
() (PVar () (var 0)) (UnQual () $ dropAnn n) (PVar () (var 1)))
$ shows
$ list
(precOf n)
[ashow pp $ qvar $ var 0, mkstr (nameString n),
ashow pp $ qvar $ var 1]
where
pp = mkInt () (precOf n + 1)
Stem\Mu\Deriving.hs:290:56:
No instance for (Num a2) arising from a use of `+'
The type variable `a2' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the second argument of `mkInt', namely `(precOf n + 1)'
In the expression: mkInt () (precOf n + 1)
In an equation for `pp': pp = mkInt () (precOf n + 1)
Stem\Mu\Deriving.hs:297:47:
No instance for (Integral a8) arising from a use of `mkInt'
The type variable `a8' is ambiguous
Note: there are several potential instances:
instance Integral Int -- Defined in `GHC.Real'
instance Integral Integer -- Defined in `GHC.Real'
instance Integral GHC.Types.Word -- Defined in `GHC.Real'
...plus 8 others
In the first argument of `ashow', namely `(mkInt () 0)'
In the second argument of `aapp', namely
`ashow (mkInt () 0) (qvar $ dropAnn n)'
In the expression:
mkstr (nameString n & " = ")
`aapp` ashow (mkInt () 0) (qvar $ dropAnn n)
Stem\Mu\Deriving.hs:297:56:
No instance for (Num a8) arising from the literal `0'
The type variable `a8' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the second argument of `mkInt', namely `0'
In the first argument of `ashow', namely `(mkInt () 0)'
In the second argument of `aapp', namely
`ashow (mkInt () 0) (qvar $ dropAnn n)'
Stem\Mu\Deriving.hs:337:44:
No instance for (Show a10) arising from a use of `varx'
The type variable `a10' is ambiguous
Note: there are several potential instances:
instance Show GeneralCategory -- Defined in `Data.Char'
instance Show IString -- Defined in `Cortex.Utils.IString'
instance Show a => Show (Cortex.Utils.List.Down a)
-- Defined in `Cortex.Utils.List'
...plus 171 others
In the first argument of `map', namely `varx'
In the expression: map varx [0, 1]
In a pattern binding: [x0, x1] = map varx [0, 1]
Stem\Mu\Deriving.hs:337:50:
No instance for (Num a10) arising from the literal `0'
The type variable `a10' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the expression: 0
In the second argument of `map', namely `[0, 1]'
In the expression: map varx [0, 1]
Stem\Mu\Deriving.hs:338:44:
No instance for (Show a9) arising from a use of `vary'
The type variable `a9' is ambiguous
Note: there are several potential instances:
instance Show GeneralCategory -- Defined in `Data.Char'
instance Show IString -- Defined in `Cortex.Utils.IString'
instance Show a => Show (Cortex.Utils.List.Down a)
-- Defined in `Cortex.Utils.List'
...plus 171 others
In the first argument of `map', namely `vary'
In the expression: map vary [0, 1]
In a pattern binding: [y0, y1] = map vary [0, 1]
Stem\Mu\Deriving.hs:338:50:
No instance for (Num a9) arising from the literal `0'
The type variable `a9' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the expression: 0
In the second argument of `map', namely `[0, 1]'
In the expression: map vary [0, 1]
Stem\Mu\Deriving.hs:366:33:
Couldn't match type `DeclS IString TLoc' with `DeclHeadS IString l'
Expected type: DeclHead l
Actual type: Decl TLoc
Relevant bindings include
n :: Name l (bound at Stem\Mu\Deriving.hs:366:10)
vs :: [TyVarBind l] (bound at Stem\Mu\Deriving.hs:366:13)
In the first argument of `splitDeclHead', namely `dh'
In the expression: splitDeclHead dh
Stem\Mu\Deriving.hs:392:44:
No instance for (Show a14) arising from a use of `varx'
The type variable `a14' is ambiguous
Note: there are several potential instances:
instance Show GeneralCategory -- Defined in `Data.Char'
instance Show IString -- Defined in `Cortex.Utils.IString'
instance Show a => Show (Cortex.Utils.List.Down a)
-- Defined in `Cortex.Utils.List'
...plus 171 others
In the first argument of `map', namely `varx'
In the expression: map varx [0, 1]
In a pattern binding: [x0, x1] = map varx [0, 1]
Stem\Mu\Deriving.hs:392:50:
No instance for (Num a14) arising from the literal `0'
The type variable `a14' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the expression: 0
In the second argument of `map', namely `[0, 1]'
In the expression: map varx [0, 1]
Stem\Mu\Deriving.hs:393:44:
No instance for (Show a13) arising from a use of `vary'
The type variable `a13' is ambiguous
Note: there are several potential instances:
instance Show GeneralCategory -- Defined in `Data.Char'
instance Show IString -- Defined in `Cortex.Utils.IString'
instance Show a => Show (Cortex.Utils.List.Down a)
-- Defined in `Cortex.Utils.List'
...plus 171 others
In the first argument of `map', namely `vary'
In the expression: map vary [0, 1]
In a pattern binding: [y0, y1] = map vary [0, 1]
Stem\Mu\Deriving.hs:393:50:
No instance for (Num a13) arising from the literal `0'
The type variable `a13' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus 12 others
In the expression: 0
In the second argument of `map', namely `[0, 1]'
In the expression: map vary [0, 1]
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.8.3 |
| 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":"Type errors sometimes has a lot of irrelevant information","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.8.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here's an example.\r\nThe essential part of the error message is\r\n{{{\r\n Couldn't match type `DeclS IString TLoc' with `DeclHeadS IString l'\r\n}}}\r\nThis is buried somewhere in the middle. Fixing this problem makes all the others go away. It seems ghc spits out constraints that it hasn't solved, but they are unsolved because there was a type error.\r\n\r\nFull message:\r\n{{{\r\nStem\\Mu\\Deriving.hs:214:93:\r\n No instance for (Integral b0) arising from a use of `constr'\r\n The type variable `b0' is ambiguous\r\n Note: there are several potential instances:\r\n instance Integral Int -- Defined in `GHC.Real'\r\n instance Integral Integer -- Defined in `GHC.Real'\r\n instance Integral GHC.Types.Word -- Defined in `GHC.Real'\r\n ...plus 8 others\r\n In the first argument of `zipWith', namely `constr'\r\n In the second argument of `($)', namely `zipWith constr qs [0 .. ]'\r\n In the expression: List () $ zipWith constr qs [0 .. ]\r\n\r\nStem\\Mu\\Deriving.hs:214:103:\r\n No instance for (Enum b0)\r\n arising from the arithmetic sequence `0 .. '\r\n The type variable `b0' is ambiguous\r\n Note: there are several potential instances:\r\n instance Enum GeneralCategory -- Defined in `Data.Char'\r\n instance Enum InlInfo -- Defined in `Cortex.Stem.Mu.Util'\r\n instance Enum Double -- Defined in `GHC.Float'\r\n ...plus 24 others\r\n In the third argument of `zipWith', namely `[0 .. ]'\r\n In the second argument of `($)', namely `zipWith constr qs [0 .. ]'\r\n In the expression: List () $ zipWith constr qs [0 .. ]\r\n\r\nStem\\Mu\\Deriving.hs:214:104:\r\n No instance for (Num b0) arising from the literal `0'\r\n The type variable `b0' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the expression: 0\r\n In the third argument of `zipWith', namely `[0 .. ]'\r\n In the second argument of `($)', namely `zipWith constr qs [0 .. ]'\r\n\r\nStem\\Mu\\Deriving.hs:285:28:\r\n No instance for (Integral a0) arising from a use of `list'\r\n The type variable `a0' is ambiguous\r\n Note: there are several potential instances:\r\n instance Integral Int -- Defined in `GHC.Real'\r\n instance Integral Integer -- Defined in `GHC.Real'\r\n instance Integral GHC.Types.Word -- Defined in `GHC.Real'\r\n ...plus 8 others\r\n In the second argument of `($)', namely\r\n `list\r\n 10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)'\r\n In the second argument of `($)', namely\r\n `shows\r\n $ list\r\n 10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)'\r\n In the expression:\r\n method (PApp () (UnQual () $ dropAnn n) (map (PVar ()) vs))\r\n $ shows\r\n $ list\r\n 10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)\r\n\r\nStem\\Mu\\Deriving.hs:285:33:\r\n No instance for (Num a0) arising from the literal `10'\r\n The type variable `a0' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the first argument of `list', namely `10'\r\n In the second argument of `($)', namely\r\n `list\r\n 10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)'\r\n In the second argument of `($)', namely\r\n `shows\r\n $ list\r\n 10 (mkstr (nameString n) : map (ashow (mkInt () 11) . qvar) vs)'\r\n\r\nStem\\Mu\\Deriving.hs:285:72:\r\n No instance for (Integral a1) arising from a use of `mkInt'\r\n The type variable `a1' is ambiguous\r\n Note: there are several potential instances:\r\n instance Integral Int -- Defined in `GHC.Real'\r\n instance Integral Integer -- Defined in `GHC.Real'\r\n instance Integral GHC.Types.Word -- Defined in `GHC.Real'\r\n ...plus 8 others\r\n In the first argument of `ashow', namely `(mkInt () 11)'\r\n In the first argument of `(.)', namely `ashow (mkInt () 11)'\r\n In the first argument of `map', namely\r\n `(ashow (mkInt () 11) . qvar)'\r\n\r\nStem\\Mu\\Deriving.hs:285:81:\r\n No instance for (Num a1) arising from the literal `11'\r\n The type variable `a1' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the second argument of `mkInt', namely `11'\r\n In the first argument of `ashow', namely `(mkInt () 11)'\r\n In the first argument of `(.)', namely `ashow (mkInt () 11)'\r\n\r\nStem\\Mu\\Deriving.hs:288:44:\r\n No instance for (Show a3) arising from a use of `var'\r\n The type variable `a3' is ambiguous\r\n Note: there are several potential instances:\r\n instance Show GeneralCategory -- Defined in `Data.Char'\r\n instance Show IString -- Defined in `Cortex.Utils.IString'\r\n instance Show a => Show (Cortex.Utils.List.Down a)\r\n -- Defined in `Cortex.Utils.List'\r\n ...plus 171 others\r\n In the second argument of `PVar', namely `(var 0)'\r\n In the second argument of `PInfixApp', namely `(PVar () (var 0))'\r\n In the first argument of `method', namely\r\n `(PInfixApp\r\n () (PVar () (var 0)) (UnQual () $ dropAnn n) (PVar () (var 1)))'\r\n\r\nStem\\Mu\\Deriving.hs:288:48:\r\n No instance for (Num a3) arising from the literal `0'\r\n The type variable `a3' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the first argument of `var', namely `0'\r\n In the second argument of `PVar', namely `(var 0)'\r\n In the second argument of `PInfixApp', namely `(PVar () (var 0))'\r\n\r\nStem\\Mu\\Deriving.hs:288:86:\r\n No instance for (Show a4) arising from a use of `var'\r\n The type variable `a4' is ambiguous\r\n Note: there are several potential instances:\r\n instance Show GeneralCategory -- Defined in `Data.Char'\r\n instance Show IString -- Defined in `Cortex.Utils.IString'\r\n instance Show a => Show (Cortex.Utils.List.Down a)\r\n -- Defined in `Cortex.Utils.List'\r\n ...plus 171 others\r\n In the second argument of `PVar', namely `(var 1)'\r\n In the fourth argument of `PInfixApp', namely `(PVar () (var 1))'\r\n In the first argument of `method', namely\r\n `(PInfixApp\r\n () (PVar () (var 0)) (UnQual () $ dropAnn n) (PVar () (var 1)))'\r\n\r\nStem\\Mu\\Deriving.hs:288:90:\r\n No instance for (Num a4) arising from the literal `1'\r\n The type variable `a4' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the first argument of `var', namely `1'\r\n In the second argument of `PVar', namely `(var 1)'\r\n In the fourth argument of `PInfixApp', namely `(PVar () (var 1))'\r\n\r\nStem\\Mu\\Deriving.hs:289:28:\r\n No instance for (Integral a5) arising from a use of `list'\r\n The type variable `a5' is ambiguous\r\n Note: there are several potential instances:\r\n instance Integral Int -- Defined in `GHC.Real'\r\n instance Integral Integer -- Defined in `GHC.Real'\r\n instance Integral GHC.Types.Word -- Defined in `GHC.Real'\r\n ...plus 8 others\r\n In the second argument of `($)', namely\r\n `list\r\n (precOf n)\r\n [ashow pp $ qvar $ var 0, mkstr (nameString n),\r\n ashow pp $ qvar $ var 1]'\r\n In the second argument of `($)', namely\r\n `shows\r\n $ list\r\n (precOf n)\r\n [ashow pp $ qvar $ var 0, mkstr (nameString n),\r\n ashow pp $ qvar $ var 1]'\r\n In the expression:\r\n method\r\n (PInfixApp\r\n () (PVar () (var 0)) (UnQual () $ dropAnn n) (PVar () (var 1)))\r\n $ shows\r\n $ list\r\n (precOf n)\r\n [ashow pp $ qvar $ var 0, mkstr (nameString n),\r\n ashow pp $ qvar $ var 1]\r\n\r\nStem\\Mu\\Deriving.hs:289:34:\r\n No instance for (Num a5) arising from a use of `precOf'\r\n The type variable `a5' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the first argument of `list', namely `(precOf n)'\r\n In the second argument of `($)', namely\r\n `list\r\n (precOf n)\r\n [ashow pp $ qvar $ var 0, mkstr (nameString n),\r\n ashow pp $ qvar $ var 1]'\r\n In the second argument of `($)', namely\r\n `shows\r\n $ list\r\n (precOf n)\r\n [ashow pp $ qvar $ var 0, mkstr (nameString n),\r\n ashow pp $ qvar $ var 1]'\r\n\r\nStem\\Mu\\Deriving.hs:289:63:\r\n No instance for (Show a6) arising from a use of `var'\r\n The type variable `a6' is ambiguous\r\n Note: there are several potential instances:\r\n instance Show GeneralCategory -- Defined in `Data.Char'\r\n instance Show IString -- Defined in `Cortex.Utils.IString'\r\n instance Show a => Show (Cortex.Utils.List.Down a)\r\n -- Defined in `Cortex.Utils.List'\r\n ...plus 171 others\r\n In the second argument of `($)', namely `var 0'\r\n In the second argument of `($)', namely `qvar $ var 0'\r\n In the expression: ashow pp $ qvar $ var 0\r\n\r\nStem\\Mu\\Deriving.hs:289:67:\r\n No instance for (Num a6) arising from the literal `0'\r\n The type variable `a6' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the first argument of `var', namely `0'\r\n In the second argument of `($)', namely `var 0'\r\n In the second argument of `($)', namely `qvar $ var 0'\r\n\r\nStem\\Mu\\Deriving.hs:289:110:\r\n No instance for (Show a7) arising from a use of `var'\r\n The type variable `a7' is ambiguous\r\n Note: there are several potential instances:\r\n instance Show GeneralCategory -- Defined in `Data.Char'\r\n instance Show IString -- Defined in `Cortex.Utils.IString'\r\n instance Show a => Show (Cortex.Utils.List.Down a)\r\n -- Defined in `Cortex.Utils.List'\r\n ...plus 171 others\r\n In the second argument of `($)', namely `var 1'\r\n In the second argument of `($)', namely `qvar $ var 1'\r\n In the expression: ashow pp $ qvar $ var 1\r\n\r\nStem\\Mu\\Deriving.hs:289:114:\r\n No instance for (Num a7) arising from the literal `1'\r\n The type variable `a7' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the first argument of `var', namely `1'\r\n In the second argument of `($)', namely `var 1'\r\n In the second argument of `($)', namely `qvar $ var 1'\r\n\r\nStem\\Mu\\Deriving.hs:290:37:\r\n No instance for (Integral a2) arising from a use of `mkInt'\r\n The type variable `a2' is ambiguous\r\n Note: there are several potential instances:\r\n instance Integral Int -- Defined in `GHC.Real'\r\n instance Integral Integer -- Defined in `GHC.Real'\r\n instance Integral GHC.Types.Word -- Defined in `GHC.Real'\r\n ...plus 8 others\r\n In the expression: mkInt () (precOf n + 1)\r\n In an equation for `pp': pp = mkInt () (precOf n + 1)\r\n In an equation for `sh':\r\n sh (QualConDecl _ _ _ (InfixConDecl _ t1 n t2))\r\n = method\r\n (PInfixApp\r\n () (PVar () (var 0)) (UnQual () $ dropAnn n) (PVar () (var 1)))\r\n $ shows\r\n $ list\r\n (precOf n)\r\n [ashow pp $ qvar $ var 0, mkstr (nameString n),\r\n ashow pp $ qvar $ var 1]\r\n where\r\n pp = mkInt () (precOf n + 1)\r\n\r\nStem\\Mu\\Deriving.hs:290:56:\r\n No instance for (Num a2) arising from a use of `+'\r\n The type variable `a2' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the second argument of `mkInt', namely `(precOf n + 1)'\r\n In the expression: mkInt () (precOf n + 1)\r\n In an equation for `pp': pp = mkInt () (precOf n + 1)\r\n\r\nStem\\Mu\\Deriving.hs:297:47:\r\n No instance for (Integral a8) arising from a use of `mkInt'\r\n The type variable `a8' is ambiguous\r\n Note: there are several potential instances:\r\n instance Integral Int -- Defined in `GHC.Real'\r\n instance Integral Integer -- Defined in `GHC.Real'\r\n instance Integral GHC.Types.Word -- Defined in `GHC.Real'\r\n ...plus 8 others\r\n In the first argument of `ashow', namely `(mkInt () 0)'\r\n In the second argument of `aapp', namely\r\n `ashow (mkInt () 0) (qvar $ dropAnn n)'\r\n In the expression:\r\n mkstr (nameString n & \" = \")\r\n `aapp` ashow (mkInt () 0) (qvar $ dropAnn n)\r\n\r\nStem\\Mu\\Deriving.hs:297:56:\r\n No instance for (Num a8) arising from the literal `0'\r\n The type variable `a8' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the second argument of `mkInt', namely `0'\r\n In the first argument of `ashow', namely `(mkInt () 0)'\r\n In the second argument of `aapp', namely\r\n `ashow (mkInt () 0) (qvar $ dropAnn n)'\r\n\r\nStem\\Mu\\Deriving.hs:337:44:\r\n No instance for (Show a10) arising from a use of `varx'\r\n The type variable `a10' is ambiguous\r\n Note: there are several potential instances:\r\n instance Show GeneralCategory -- Defined in `Data.Char'\r\n instance Show IString -- Defined in `Cortex.Utils.IString'\r\n instance Show a => Show (Cortex.Utils.List.Down a)\r\n -- Defined in `Cortex.Utils.List'\r\n ...plus 171 others\r\n In the first argument of `map', namely `varx'\r\n In the expression: map varx [0, 1]\r\n In a pattern binding: [x0, x1] = map varx [0, 1]\r\n\r\nStem\\Mu\\Deriving.hs:337:50:\r\n No instance for (Num a10) arising from the literal `0'\r\n The type variable `a10' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the expression: 0\r\n In the second argument of `map', namely `[0, 1]'\r\n In the expression: map varx [0, 1]\r\n\r\nStem\\Mu\\Deriving.hs:338:44:\r\n No instance for (Show a9) arising from a use of `vary'\r\n The type variable `a9' is ambiguous\r\n Note: there are several potential instances:\r\n instance Show GeneralCategory -- Defined in `Data.Char'\r\n instance Show IString -- Defined in `Cortex.Utils.IString'\r\n instance Show a => Show (Cortex.Utils.List.Down a)\r\n -- Defined in `Cortex.Utils.List'\r\n ...plus 171 others\r\n In the first argument of `map', namely `vary'\r\n In the expression: map vary [0, 1]\r\n In a pattern binding: [y0, y1] = map vary [0, 1]\r\n\r\nStem\\Mu\\Deriving.hs:338:50:\r\n No instance for (Num a9) arising from the literal `0'\r\n The type variable `a9' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the expression: 0\r\n In the second argument of `map', namely `[0, 1]'\r\n In the expression: map vary [0, 1]\r\n\r\nStem\\Mu\\Deriving.hs:366:33:\r\n Couldn't match type `DeclS IString TLoc' with `DeclHeadS IString l'\r\n Expected type: DeclHead l\r\n Actual type: Decl TLoc\r\n Relevant bindings include\r\n n :: Name l (bound at Stem\\Mu\\Deriving.hs:366:10)\r\n vs :: [TyVarBind l] (bound at Stem\\Mu\\Deriving.hs:366:13)\r\n In the first argument of `splitDeclHead', namely `dh'\r\n In the expression: splitDeclHead dh\r\n\r\nStem\\Mu\\Deriving.hs:392:44:\r\n No instance for (Show a14) arising from a use of `varx'\r\n The type variable `a14' is ambiguous\r\n Note: there are several potential instances:\r\n instance Show GeneralCategory -- Defined in `Data.Char'\r\n instance Show IString -- Defined in `Cortex.Utils.IString'\r\n instance Show a => Show (Cortex.Utils.List.Down a)\r\n -- Defined in `Cortex.Utils.List'\r\n ...plus 171 others\r\n In the first argument of `map', namely `varx'\r\n In the expression: map varx [0, 1]\r\n In a pattern binding: [x0, x1] = map varx [0, 1]\r\n\r\nStem\\Mu\\Deriving.hs:392:50:\r\n No instance for (Num a14) arising from the literal `0'\r\n The type variable `a14' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the expression: 0\r\n In the second argument of `map', namely `[0, 1]'\r\n In the expression: map varx [0, 1]\r\n\r\nStem\\Mu\\Deriving.hs:393:44:\r\n No instance for (Show a13) arising from a use of `vary'\r\n The type variable `a13' is ambiguous\r\n Note: there are several potential instances:\r\n instance Show GeneralCategory -- Defined in `Data.Char'\r\n instance Show IString -- Defined in `Cortex.Utils.IString'\r\n instance Show a => Show (Cortex.Utils.List.Down a)\r\n -- Defined in `Cortex.Utils.List'\r\n ...plus 171 others\r\n In the first argument of `map', namely `vary'\r\n In the expression: map vary [0, 1]\r\n In a pattern binding: [y0, y1] = map vary [0, 1]\r\n\r\nStem\\Mu\\Deriving.hs:393:50:\r\n No instance for (Num a13) arising from the literal `0'\r\n The type variable `a13' is ambiguous\r\n Note: there are several potential instances:\r\n instance Num Double -- Defined in `GHC.Float'\r\n instance Num Float -- Defined in `GHC.Float'\r\n instance Integral a => Num (GHC.Real.Ratio a)\r\n -- Defined in `GHC.Real'\r\n ...plus 12 others\r\n In the expression: 0\r\n In the second argument of `map', namely `[0, 1]'\r\n In the expression: map vary [0, 1]\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11524Something is amiss with quantification in pattern synonym type signatures2019-07-07T18:30:04ZBen GamariSomething is amiss with quantification in pattern synonym type signaturesConsider this program,
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeInType #-}
module Test where
data AType (a :: k) where
AMaybe :: ATyp...Consider this program,
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeInType #-}
module Test where
data AType (a :: k) where
AMaybe :: AType Maybe
AInt :: AType Int
AApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). AType a -> AType b -> AType (a b)
pattern PApp :: () => (fun ~ a b) => AType a -> AType b -> AType fun
--pattern PApp :: forall k (fun :: k) k1 (a :: k1 -> k) (b :: k1).
-- () => (fun ~ a b) => AType a -> AType b -> AType fun
pattern PApp fun arg <- AApp fun arg
```
I would have thought that the two type signatures would be equivalent. However, when I use the quantified signature GHC complains with,
```
hi.hs:14:34: error:
• Expected kind ‘AType a’, but ‘fun’ has kind ‘AType a1’
• In the declaration for pattern synonym ‘PApp’
• Relevant bindings include
arg :: AType b1 (bound at hi.hs:14:34)
fun :: AType a1 (bound at hi.hs:14:30)
```
Moreover, if I use the un-quantified signature and ask GHCi for the full type signature, it gives me the precisely the quantified type that it rejected previously,
```
λ> :info PApp
pattern PApp :: forall k (fun :: k) k1 (a :: k1
-> k) (b :: k1). () => fun ~ a b => AType a
-> AType b
-> AType fun
-- Defined at hi.hs:14:1
```
Very odd.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1-rc1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | mpickering |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Something is amiss with quantification in pattern synonym type signatures","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["mpickering"],"type":"Bug","description":"Consider this program,\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE PolyKinds #-}\r\n{-# LANGUAGE ExplicitForAll #-}\r\n{-# LANGUAGE PatternSynonyms #-}\r\n{-# LANGUAGE TypeInType #-}\r\n\r\nmodule Test where\r\n\r\ndata AType (a :: k) where\r\n AMaybe :: AType Maybe\r\n AInt :: AType Int\r\n AApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). AType a -> AType b -> AType (a b)\r\n\r\npattern PApp :: () => (fun ~ a b) => AType a -> AType b -> AType fun\r\n--pattern PApp :: forall k (fun :: k) k1 (a :: k1 -> k) (b :: k1).\r\n-- () => (fun ~ a b) => AType a -> AType b -> AType fun\r\npattern PApp fun arg <- AApp fun arg\r\n}}}\r\n\r\nI would have thought that the two type signatures would be equivalent. However, when I use the quantified signature GHC complains with,\r\n{{{\r\nhi.hs:14:34: error:\r\n • Expected kind ‘AType a’, but ‘fun’ has kind ‘AType a1’\r\n • In the declaration for pattern synonym ‘PApp’\r\n • Relevant bindings include\r\n arg :: AType b1 (bound at hi.hs:14:34)\r\n fun :: AType a1 (bound at hi.hs:14:30)\r\n}}}\r\n\r\nMoreover, if I use the un-quantified signature and ask GHCi for the full type signature, it gives me the precisely the quantified type that it rejected previously,\r\n\r\n{{{\r\nλ> :info PApp\r\npattern PApp :: forall k (fun :: k) k1 (a :: k1\r\n -> k) (b :: k1). () => fun ~ a b => AType a\r\n -> AType b\r\n -> AType fun\r\n \t-- Defined at hi.hs:14:1\r\n}}}\r\n\r\nVery odd.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11520GHC falls into a hole if given incorrect kind signature2019-07-07T18:30:05ZBen GamariGHC falls into a hole if given incorrect kind signatureIf one provides an incorrect kind signature GHC throws up. For instance, this non-sense,
```hs
{-# LANGUAGE RankNTypes, PolyKinds, TypeInType, GADTs, UndecidableSuperClasses #-}
module Play where
import GHC.Types hiding (TyCon)
data ...If one provides an incorrect kind signature GHC throws up. For instance, this non-sense,
```hs
{-# LANGUAGE RankNTypes, PolyKinds, TypeInType, GADTs, UndecidableSuperClasses #-}
module Play where
import GHC.Types hiding (TyCon)
data TypeRep (a :: k)
class Typeable k => Typeable (a :: k) where
typeRep :: TypeRep a
data Compose (f :: k1 -> *) (g :: k2 -> k1) (a :: k2) = Compose (f (g a))
-- Note how the kind signature on g is incorrect
instance (Typeable f, Typeable (g :: k), Typeable k) => Typeable (Compose f g) where
typeRep = undefined
```
fails with
```
λ> :load Bug.hs
[1 of 1] Compiling Play ( Bug.hs, interpreted )
ghc: panic! (the 'impossible' happened)
(GHC version 8.1.20160122 for x86_64-unknown-linux):
fvProv falls into a hole {abet}
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11485Very unhelpful message resulting from kind mismatch2019-07-07T18:30:13ZRyan ScottVery unhelpful message resulting from kind mismatchThe following code:
```hs
module Foo where
import Data.Typeable
tyConOf :: Typeable a => Proxy a -> TyCon
tyConOf = typeRepTyCon . typeRep
tcList :: TyCon
tcList = tyConOf (Proxy :: Proxy [])
```
fails because `-XPolyKinds` is not e...The following code:
```hs
module Foo where
import Data.Typeable
tyConOf :: Typeable a => Proxy a -> TyCon
tyConOf = typeRepTyCon . typeRep
tcList :: TyCon
tcList = tyConOf (Proxy :: Proxy [])
```
fails because `-XPolyKinds` is not enabled. But the error message that you get is quite different on GHC 7.10 and 8.0.
On GHC 7.10.3:
```
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )
Foo.hs:9:19:
Couldn't match kind ‘* -> *’ with ‘*’
Expected type: Proxy a0
Actual type: Proxy []
In the first argument of ‘tyConOf’, namely ‘(Proxy :: Proxy [])’
In the expression: tyConOf (Proxy :: Proxy [])
In an equation for ‘tcList’: tcList = tyConOf (Proxy :: Proxy [])
```
But on GHC 8.0.1-rc1:
```
Foo.hs:9:19: error:
• Expected kind ‘Proxy []’,
but ‘Data.Proxy.Proxy :: Proxy []’ has kind ‘Proxy []’
• In the first argument of ‘tyConOf’, namely ‘(Proxy :: Proxy [])’
In the expression: tyConOf (Proxy :: Proxy [])
In an equation for ‘tcList’: tcList = tyConOf (Proxy :: Proxy [])
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1-rc1 |
| 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":"Very unhelpful message resulting from kind mismatch","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following code:\r\n\r\n{{{#!hs\r\nmodule Foo where\r\n\r\nimport Data.Typeable\r\n\r\ntyConOf :: Typeable a => Proxy a -> TyCon\r\ntyConOf = typeRepTyCon . typeRep\r\n\r\ntcList :: TyCon\r\ntcList = tyConOf (Proxy :: Proxy [])\r\n}}}\r\n\r\nfails because `-XPolyKinds` is not enabled. But the error message that you get is quite different on GHC 7.10 and 8.0.\r\n\r\nOn GHC 7.10.3:\r\n\r\n{{{\r\n[1 of 1] Compiling Foo ( Foo.hs, Foo.o )\r\n\r\nFoo.hs:9:19:\r\n Couldn't match kind ‘* -> *’ with ‘*’\r\n Expected type: Proxy a0\r\n Actual type: Proxy []\r\n In the first argument of ‘tyConOf’, namely ‘(Proxy :: Proxy [])’\r\n In the expression: tyConOf (Proxy :: Proxy [])\r\n In an equation for ‘tcList’: tcList = tyConOf (Proxy :: Proxy [])\r\n}}}\r\n\r\nBut on GHC 8.0.1-rc1:\r\n\r\n{{{\r\nFoo.hs:9:19: error: \r\n • Expected kind ‘Proxy []’, \r\n but ‘Data.Proxy.Proxy :: Proxy []’ has kind ‘Proxy []’ \r\n • In the first argument of ‘tyConOf’, namely ‘(Proxy :: Proxy [])’ \r\n In the expression: tyConOf (Proxy :: Proxy [])\r\n In an equation for ‘tcList’: tcList = tyConOf (Proxy :: Proxy [])\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11480UndecidableSuperClasses causes the compiler to spin with UndecidableInstances2019-07-07T18:30:14ZEdward KmettUndecidableSuperClasses causes the compiler to spin with UndecidableInstancesLooks like I spoke too soon when I said all my examples worked in #10318 -- it doesn't seem to work when the superclass cycle gets sufficiently interesting, possibly caused by the use of `PolyKinds` in the style mentioned in #9201.
I to...Looks like I spoke too soon when I said all my examples worked in #10318 -- it doesn't seem to work when the superclass cycle gets sufficiently interesting, possibly caused by the use of `PolyKinds` in the style mentioned in #9201.
I took my `hask` code, and removed the shimming hacks above, and the following stripped down example sends the compiler into an infinite loop, which I believe should be able to work:
```hs
{-# language KindSignatures, PolyKinds, TypeFamilies,
NoImplicitPrelude, FlexibleContexts,
MultiParamTypeClasses, GADTs,
ConstraintKinds, FlexibleInstances,
FunctionalDependencies, UndecidableSuperClasses #-}
import GHC.Types (Constraint)
import qualified Prelude
data Nat (c :: i -> i -> *) (d :: j -> j -> *) (f :: i -> j) (g :: i -> j)
class Functor p (Nat p (->)) p => Category (p :: i -> i -> *)
class (Category dom, Category cod) => Functor (dom :: i -> i -> *) (cod :: j -> j -> *) (f :: i -> j) | f -> dom cod
instance (Category c, Category d) => Category (Nat c d)
instance (Category c, Category d) => Functor (Nat c d) (Nat (Nat c d) (->)) (Nat c d)
instance (Category c, Category d) => Functor (Nat c d) (->) (Nat c d f)
instance Category (->)
instance Functor (->) (->) ((->) e)
instance Functor (->) (Nat (->) (->)) (->)
```
Sorry for the largish example, but I don't know how to strip it down smaller than the 6 instances that remain.
One potentially telling observation is that without the instances it compiles, and produces what I expect, so the `UndecidableSuperClasses` part seems to be letting the classes compile, but there seems to be a bad interaction with the way the instances work.
Also, in this stripped down form, I can remove the use of `UndecidableInstances` and that avoids the spinning problem, but once I flesh it out further I need `UndecidableInstances` in the "real" version of the problem.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"UndecidableSuperClasses causes the compiler to spin with UndecidableInstances","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":["PolyKinds,","UndecidableSuperClasses"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Looks like I spoke too soon when I said all my examples worked in #10318 -- it doesn't seem to work when the superclass cycle gets sufficiently interesting, possibly caused by the use of `PolyKinds` in the style mentioned in #9201.\r\n\r\nI took my `hask` code, and removed the shimming hacks above, and the following stripped down example sends the compiler into an infinite loop, which I believe should be able to work:\r\n\r\n{{{#!hs\r\n{-# language KindSignatures, PolyKinds, TypeFamilies, \r\n NoImplicitPrelude, FlexibleContexts,\r\n MultiParamTypeClasses, GADTs, \r\n ConstraintKinds, FlexibleInstances, \r\n FunctionalDependencies, UndecidableSuperClasses #-}\r\n\r\nimport GHC.Types (Constraint)\r\nimport qualified Prelude\r\n\r\ndata Nat (c :: i -> i -> *) (d :: j -> j -> *) (f :: i -> j) (g :: i -> j)\r\n\r\nclass Functor p (Nat p (->)) p => Category (p :: i -> i -> *)\r\nclass (Category dom, Category cod) => Functor (dom :: i -> i -> *) (cod :: j -> j -> *) (f :: i -> j) | f -> dom cod\r\n\r\ninstance (Category c, Category d) => Category (Nat c d)\r\ninstance (Category c, Category d) => Functor (Nat c d) (Nat (Nat c d) (->)) (Nat c d)\r\ninstance (Category c, Category d) => Functor (Nat c d) (->) (Nat c d f)\r\n\r\ninstance Category (->)\r\ninstance Functor (->) (->) ((->) e)\r\ninstance Functor (->) (Nat (->) (->)) (->)\r\n}}}\r\n\r\nSorry for the largish example, but I don't know how to strip it down smaller than the 6 instances that remain.\r\n\r\nOne potentially telling observation is that without the instances it compiles, and produces what I expect, so the `UndecidableSuperClasses` part seems to be letting the classes compile, but there seems to be a bad interaction with the way the instances work.\r\n\r\nAlso, in this stripped down form, I can remove the use of `UndecidableInstances` and that avoids the spinning problem, but once I flesh it out further I need `UndecidableInstances` in the \"real\" version of the problem.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11471Kind polymorphism and unboxed types: bad things are happening2019-07-07T18:30:16ZBen GamariKind polymorphism and unboxed types: bad things are happeningThis Note, found in TyCoRep, needs to be updated to reflect `TypeInType`. It should not reference `OpenKind`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---...This Note, found in TyCoRep, needs to be updated to reflect `TypeInType`. It should not reference `OpenKind`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.3 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Note [The kind invariant] in TyCoRep needs to be updated","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"This Note, found in TyCoRep, needs to be updated to reflect `TypeInType`. It should not reference `OpenKind`.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11466Constraint synonym with Implicit Parameter2019-07-07T18:30:18ZJoachim Breitnermail@joachim-breitner.deConstraint synonym with Implicit ParameterThis:
```
{-# LANGUAGE ConstraintKinds, ImplicitParams #-}
module Foo where
type Foo = ?foo::()
```
gives
```
Foo.hs:3:1: error:
• Illegal implicit parameter ‘?foo::()’
• In the type synonym declaration for ‘Foo’
```
in GHC H...This:
```
{-# LANGUAGE ConstraintKinds, ImplicitParams #-}
module Foo where
type Foo = ?foo::()
```
gives
```
Foo.hs:3:1: error:
• Illegal implicit parameter ‘?foo::()’
• In the type synonym declaration for ‘Foo’
```
in GHC HEAD. It used to work in GHC-7.10. Did not check GHC-8.0.
<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":"Constraint synonym with Implicit Parameter","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":"This:\r\n{{{\r\n{-# LANGUAGE ConstraintKinds, ImplicitParams #-}\r\nmodule Foo where\r\ntype Foo = ?foo::()\r\n}}}\r\ngives\r\n{{{\r\nFoo.hs:3:1: error:\r\n • Illegal implicit parameter ‘?foo::()’\r\n • In the type synonym declaration for ‘Foo’\r\n}}}\r\nin GHC HEAD. It used to work in GHC-7.10. Did not check GHC-8.0.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11458Terrible failure of type inference in visible type application2019-07-07T18:30:20ZSimon Peyton JonesTerrible failure of type inference in visible type applicationConsider
```
-- optIntArg :: (Maybe Int -> t2) -> (t2,t2)
optIntArg f = (f Nothing, f (Just True))
```
This is rejected (by HEAD)
```
T11379a.hs:5:30: error:
* Couldn't match type `a' with `Bool'
`a' is a rigid type variable...Consider
```
-- optIntArg :: (Maybe Int -> t2) -> (t2,t2)
optIntArg f = (f Nothing, f (Just True))
```
This is rejected (by HEAD)
```
T11379a.hs:5:30: error:
* Couldn't match type `a' with `Bool'
`a' is a rigid type variable bound by
a type expected by the context:
forall a. Maybe a
at T11379a.hs:5:30
Expected type: forall a. Maybe a
Actual type: Maybe Bool
* In the first argument of `f', namely `(Just True)'
In the expression: f (Just True)
In the expression: (f Nothing, f (Just True))
```
but if you put the tuple components the other way round, it works fine
```
optIntArg f = (f (Just True), f Nothing)
```
Adding the commented-out signature also makes it work fine.
I'm almost certain that this is caused by visible type application; perhaps `Nothing` gets delayed instantiation, and then `f`'s type becomes `forall a. Maybe a`. Utterly bogus.
I suspect it'll be fixed by Richards `ReturnTv` work, but let's make sure it is. We can't release this!!
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Terrible failure of type inference in visible type application","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider\r\n{{{\r\n-- optIntArg :: (Maybe Int -> t2) -> (t2,t2)\r\noptIntArg f = (f Nothing, f (Just True))\r\n}}}\r\nThis is rejected (by HEAD)\r\n{{{\r\nT11379a.hs:5:30: error:\r\n * Couldn't match type `a' with `Bool'\r\n `a' is a rigid type variable bound by\r\n a type expected by the context:\r\n forall a. Maybe a\r\n at T11379a.hs:5:30\r\n Expected type: forall a. Maybe a\r\n Actual type: Maybe Bool\r\n * In the first argument of `f', namely `(Just True)'\r\n In the expression: f (Just True)\r\n In the expression: (f Nothing, f (Just True))\r\n}}}\r\nbut if you put the tuple components the other way round, it works fine\r\n{{{\r\noptIntArg f = (f (Just True), f Nothing)\r\n}}}\r\nAdding the commented-out signature also makes it work fine.\r\n\r\nI'm almost certain that this is caused by visible type application; perhaps `Nothing` gets delayed instantiation, and then `f`'s type becomes `forall a. Maybe a`. Utterly bogus.\r\n\r\nI suspect it'll be fixed by Richards `ReturnTv` work, but let's make sure it is. We can't release this!!\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11428ImpredicativeTypes causes GHC panic with 8.0.1-rc12019-07-07T18:30:27ZRyan ScottImpredicativeTypes causes GHC panic with 8.0.1-rc1I noticed this issue when attempting to compile `conduit` with GHC 8.0.1-rc1 (specifically, the [Data.Conduit.Internal.Pipe](https://github.com/snoyberg/conduit/blob/master/conduit/Data/Conduit/Internal/Pipe.hs) module). This (greatly si...I noticed this issue when attempting to compile `conduit` with GHC 8.0.1-rc1 (specifically, the [Data.Conduit.Internal.Pipe](https://github.com/snoyberg/conduit/blob/master/conduit/Data/Conduit/Internal/Pipe.hs) module). This (greatly simplified) code, which compiles without issue on GHC 7.10.3:
```hs
{-# LANGUAGE ImpredicativeTypes #-}
module Data.Conduit.Internal.Pipe where
data Pipe o r =
HaveOutput (Pipe o r) o
mapOutputMaybe :: (o1 -> Maybe o2) -> Pipe o1 r -> Pipe o2 r
mapOutputMaybe f (HaveOutput p o) =
maybe id (\o' p' -> HaveOutput p' o') (f o) (mapOutputMaybe f p)
```
emits a GHC panic with GHC 8.0.1-rc1:
```
[1 of 1] Compiling Data.Conduit.Internal.Pipe ( Wat.hs, interpreted )
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.0.20160111 for x86_64-unknown-linux):
matchExpectedFunTys
<>
a_a15Z[tau:5] -> b_a15Y[tau:5]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Note that this code does not require `-XImpredicativeTypes`, and removing the pragma makes the code compile again.
Marking as high since it's a regression, but not highest because `-XImpredicativeTypes` has long been broken (see also #11319). Still, this currently happens on code in the wild, and perhaps it would be worth turning this into a more sensible error.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1-rc1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"ImpredicativeTypes causes GHC panic with 8.0.1-rc1","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc1","keywords":["ImpredicativeTypes"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I noticed this issue when attempting to compile `conduit` with GHC 8.0.1-rc1 (specifically, the [https://github.com/snoyberg/conduit/blob/master/conduit/Data/Conduit/Internal/Pipe.hs Data.Conduit.Internal.Pipe] module). This (greatly simplified) code, which compiles without issue on GHC 7.10.3:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE ImpredicativeTypes #-}\r\nmodule Data.Conduit.Internal.Pipe where\r\n\r\ndata Pipe o r =\r\n HaveOutput (Pipe o r) o\r\n\r\nmapOutputMaybe :: (o1 -> Maybe o2) -> Pipe o1 r -> Pipe o2 r\r\nmapOutputMaybe f (HaveOutput p o) =\r\n maybe id (\\o' p' -> HaveOutput p' o') (f o) (mapOutputMaybe f p)\r\n}}}\r\n\r\nemits a GHC panic with GHC 8.0.1-rc1:\r\n\r\n{{{\r\n[1 of 1] Compiling Data.Conduit.Internal.Pipe ( Wat.hs, interpreted )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.0.0.20160111 for x86_64-unknown-linux):\r\n\tmatchExpectedFunTys\r\n <>\r\n a_a15Z[tau:5] -> b_a15Y[tau:5]\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nNote that this code does not require `-XImpredicativeTypes`, and removing the pragma makes the code compile again.\r\n\r\nMarking as high since it's a regression, but not highest because `-XImpredicativeTypes` has long been broken (see also #11319). Still, this currently happens on code in the wild, and perhaps it would be worth turning this into a more sensible error.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://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/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/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/11397Type mismatch in local definitions in Haskell 98 code2019-07-07T18:30:36ZLemmingType mismatch in local definitions in Haskell 98 codeHere is the affected code with all package dependencies removes:
```
$ cat PairMismatch.hs
module PairMismatch (inverseFrequencyModulationChunk) where
newtype VectorLazy a = VectorLazy a
newtype Vector a = Vector a
newtype Pointer a = ...Here is the affected code with all package dependencies removes:
```
$ cat PairMismatch.hs
module PairMismatch (inverseFrequencyModulationChunk) where
newtype VectorLazy a = VectorLazy a
newtype Vector a = Vector a
newtype Pointer a = Pointer a
empty :: VectorLazy a
empty = undefined
cons :: Vector a -> Pointer a
cons = undefined
unfoldrResult :: (a -> Either c (b, a)) -> a -> (VectorLazy b, c)
unfoldrResult = undefined
switchL :: b -> (a -> Pointer a -> b) -> Pointer a -> b
switchL = undefined
inverseFrequencyModulationChunk ::
(Num t, Ord t) =>
(s -> Maybe (t,s)) -> (t,s) -> Vector v -> (VectorLazy v, Maybe (t,s))
inverseFrequencyModulationChunk nextC (phase,cst0) chunk =
let {-
switch ::
(Maybe (t, s) -> r) ->
((t, v) -> (s, Pointer v) -> r) ->
t ->
(s, Pointer v) -> r
-}
switch l r t (cp0,xp0) =
maybe
(l Nothing)
(\(c1,cp1) ->
switchL
(l (Just (t,cp0)))
(\x1 xp1 -> r (t+c1,x1) (cp1,xp1))
xp0)
(nextC cp0)
{-
go ::
(t,v) -> (s, Pointer v) ->
Either (Maybe (t,s)) (v, ((t,v), (s, Pointer v)))
-}
go (c,x) cxp =
if c<1
then switch Left go c cxp
else Right (x, ((c-1,x),cxp))
in switch ((,) empty)
(curry $ unfoldrResult (uncurry go))
phase (cst0, cons chunk)
$ ghci-8.0.0.20160109 PairMismatch.hs
GHCi, version 8.0.0.20160109: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling PairMismatch ( PairMismatch.hs, interpreted )
PairMismatch.hs:35:24: error:
• Couldn't match type ‘a’ with ‘(t, s)’
‘a’ is a rigid type variable bound by
a type expected by the context:
forall a. Maybe a
at PairMismatch.hs:35:24
Expected type: forall a. Maybe a
Actual type: Maybe (t, s)
• In the first argument of ‘l’, namely ‘(Just (t, cp0))’
In the first argument of ‘switchL’, namely ‘(l (Just (t, cp0)))’
In the expression:
switchL
(l (Just (t, cp0))) (\ x1 xp1 -> r (t + c1, x1) (cp1, xp1)) xp0
• Relevant bindings include
cp1 :: s (bound at PairMismatch.hs:33:20)
c1 :: t (bound at PairMismatch.hs:33:17)
cp0 :: s (bound at PairMismatch.hs:30:22)
t :: t (bound at PairMismatch.hs:30:19)
r :: (t, t1) -> (s, Pointer t1) -> b
(bound at PairMismatch.hs:30:17)
switch :: ((forall a. Maybe a) -> b)
-> ((t, t1) -> (s, Pointer t1) -> b) -> t -> (s, Pointer t1) -> b
(bound at PairMismatch.hs:30:8)
inverseFrequencyModulationChunk :: (s -> Maybe (t, s))
-> (t, s) -> Vector v -> (VectorLazy v, Maybe (t, s))
(bound at PairMismatch.hs:22:1)
(Some bindings suppressed; use -fmax-relevant-binds=N or -fno-max-relevant-binds)
Failed, modules loaded: none.
```
It works with GHC-7.10.3 and before.
I may try to further simplify the code and choose a better ticket header, if I got an idea what went wrong.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.1-rc1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Type mismatch in local definitions in Haskell 98 code","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1-rc1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here is the affected code with all package dependencies removes:\r\n{{{\r\n$ cat PairMismatch.hs\r\nmodule PairMismatch (inverseFrequencyModulationChunk) where\r\n\r\nnewtype VectorLazy a = VectorLazy a\r\nnewtype Vector a = Vector a\r\nnewtype Pointer a = Pointer a\r\n\r\nempty :: VectorLazy a\r\nempty = undefined\r\n\r\ncons :: Vector a -> Pointer a\r\ncons = undefined\r\n\r\nunfoldrResult :: (a -> Either c (b, a)) -> a -> (VectorLazy b, c)\r\nunfoldrResult = undefined\r\n\r\nswitchL :: b -> (a -> Pointer a -> b) -> Pointer a -> b\r\nswitchL = undefined\r\n\r\ninverseFrequencyModulationChunk ::\r\n (Num t, Ord t) =>\r\n (s -> Maybe (t,s)) -> (t,s) -> Vector v -> (VectorLazy v, Maybe (t,s))\r\ninverseFrequencyModulationChunk nextC (phase,cst0) chunk =\r\n let {-\r\n switch ::\r\n (Maybe (t, s) -> r) ->\r\n ((t, v) -> (s, Pointer v) -> r) ->\r\n t ->\r\n (s, Pointer v) -> r\r\n -}\r\n switch l r t (cp0,xp0) =\r\n maybe\r\n (l Nothing)\r\n (\\(c1,cp1) ->\r\n switchL\r\n (l (Just (t,cp0)))\r\n (\\x1 xp1 -> r (t+c1,x1) (cp1,xp1))\r\n xp0)\r\n (nextC cp0)\r\n\r\n {-\r\n go ::\r\n (t,v) -> (s, Pointer v) ->\r\n Either (Maybe (t,s)) (v, ((t,v), (s, Pointer v)))\r\n -}\r\n go (c,x) cxp =\r\n if c<1\r\n then switch Left go c cxp\r\n else Right (x, ((c-1,x),cxp))\r\n\r\n in switch ((,) empty)\r\n (curry $ unfoldrResult (uncurry go))\r\n phase (cst0, cons chunk)\r\n\r\n$ ghci-8.0.0.20160109 PairMismatch.hs \r\nGHCi, version 8.0.0.20160109: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling PairMismatch ( PairMismatch.hs, interpreted )\r\n\r\nPairMismatch.hs:35:24: error:\r\n • Couldn't match type ‘a’ with ‘(t, s)’\r\n ‘a’ is a rigid type variable bound by\r\n a type expected by the context:\r\n forall a. Maybe a\r\n at PairMismatch.hs:35:24\r\n Expected type: forall a. Maybe a\r\n Actual type: Maybe (t, s)\r\n • In the first argument of ‘l’, namely ‘(Just (t, cp0))’\r\n In the first argument of ‘switchL’, namely ‘(l (Just (t, cp0)))’\r\n In the expression:\r\n switchL\r\n (l (Just (t, cp0))) (\\ x1 xp1 -> r (t + c1, x1) (cp1, xp1)) xp0\r\n • Relevant bindings include\r\n cp1 :: s (bound at PairMismatch.hs:33:20)\r\n c1 :: t (bound at PairMismatch.hs:33:17)\r\n cp0 :: s (bound at PairMismatch.hs:30:22)\r\n t :: t (bound at PairMismatch.hs:30:19)\r\n r :: (t, t1) -> (s, Pointer t1) -> b\r\n (bound at PairMismatch.hs:30:17)\r\n switch :: ((forall a. Maybe a) -> b)\r\n -> ((t, t1) -> (s, Pointer t1) -> b) -> t -> (s, Pointer t1) -> b\r\n (bound at PairMismatch.hs:30:8)\r\n inverseFrequencyModulationChunk :: (s -> Maybe (t, s))\r\n -> (t, s) -> Vector v -> (VectorLazy v, Maybe (t, s))\r\n (bound at PairMismatch.hs:22:1)\r\n (Some bindings suppressed; use -fmax-relevant-binds=N or -fno-max-relevant-binds)\r\nFailed, modules loaded: none.\r\n}}}\r\nIt works with GHC-7.10.3 and before.\r\nI may try to further simplify the code and choose a better ticket header, if I got an idea what went wrong.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/11391TypeError is fragile2019-07-07T18:30:37ZBen GamariTypeError is fragileConsider this use of the new `TypeError` feature,
```hs
{-# LANGUAGE TypeInType, TypeFamilies, UndecidableInstances #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Kind
import GHC.TypeLits (TypeError, ErrorMessage(..))
type fami...Consider this use of the new `TypeError` feature,
```hs
{-# LANGUAGE TypeInType, TypeFamilies, UndecidableInstances #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Kind
import GHC.TypeLits (TypeError, ErrorMessage(..))
type family Resolve (t :: Type -> Type) :: Type -> Type where
Resolve _ = TypeError (Text "ERROR")
```
#### The okay case
Given something like,
```hs
testOK :: Resolve [] Int
testOK = []
```
we find that things work as expected,
```
• ERROR
• In the expression: [] :: Resolve [] Int
In an equation for ‘testOK’: testOK = [] :: Resolve [] Int
```
#### The bad case
However, it is very easy to fool GHC into not yielding the desired error message. For instance,
```hs
testNOTOK1 :: Resolve [] Int
testNOTOK1 = ()
```
gives us this a unification error,
```
• Couldn't match type ‘()’ with ‘(TypeError ...)’
Expected type: Resolve [] Int
Actual type: ()
```
This clearly isn't what we expected.
#### The tricky case
Another way we can fool the typechecker is to make it attempt instance resolution on our `TypeError`,
```hs
testNOTOK2 :: Resolve [] Int
testNOTOK2 = 1
```
Which results in,
```
• No instance for (Num (TypeError ...))
arising from the literal ‘1’
• In the expression: 1
In an equation for ‘testNOTOK2’: testNOTOK2 = 1
```8.0.1Iavor S. DiatchkiIavor S. Diatchkihttps://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/11364Possible type-checker regression in GHC 8.02019-07-07T18:30:44ZHerbert Valerio Riedelhvr@gnu.orgPossible type-checker regression in GHC 8.0The following code fragment works with GHCs prior to GHC 8.0 but not with GHC 8.0:
```hs
{-# LANGUAGE RoleAnnotations #-}
{-# LANGUAGE IncoherentInstances #-}
{-# LANGUAGE RankNTypes #-}
module Issue where
import Data.Coerce (coerce)
...The following code fragment works with GHCs prior to GHC 8.0 but not with GHC 8.0:
```hs
{-# LANGUAGE RoleAnnotations #-}
{-# LANGUAGE IncoherentInstances #-}
{-# LANGUAGE RankNTypes #-}
module Issue where
import Data.Coerce (coerce)
data Proxy a = Proxy
newtype Catch a = Catch a
class Throws e
type role Throws representational
instance Throws (Catch e)
newtype Wrap e a = Wrap { unWrap :: Throws e => a }
coerceWrap :: Wrap e a -> Wrap (Catch e) a
coerceWrap = coerce
unthrow :: proxy e -> (Throws e => a) -> a
unthrow _ = unWrap . coerceWrap . Wrap
{- this works in GHC 7.10.3, but fails in GHC 8.0 with
GHCi, version 8.0.0.20160105: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Issue ( Issue.hs, interpreted )
Issue.hs:25:13: error:
• Could not deduce (Throws e)
from the context: Throws e0
bound by a type expected by the context:
Throws e0 => a
at Issue.hs:26:13-38
Possible fix:
add (Throws e) to the context of
the type signature for:
unthrow :: proxy e -> (Throws e => a) -> a
• In the expression: unWrap . coerceWrap . Wrap
In an equation for ‘unthrow’: unthrow _ = unWrap . coerceWrap . Wrap
Failed, modules loaded: none.
-}
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------------------- |
| Version | 7.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | bgamari, goldfire, 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":"7.10.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["bgamari","goldfire","simonpj"],"type":"Bug","description":"The following code fragment works with GHCs prior to GHC 8.0 but not with GHC 8.0:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE RoleAnnotations #-}\r\n{-# LANGUAGE IncoherentInstances #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n\r\nmodule Issue where\r\n\r\nimport Data.Coerce (coerce)\r\n\r\ndata Proxy a = Proxy\r\n\r\nnewtype Catch a = Catch a\r\n\r\nclass Throws e\r\n\r\ntype role Throws representational\r\n\r\ninstance Throws (Catch e)\r\n\r\nnewtype Wrap e a = Wrap { unWrap :: Throws e => a }\r\n\r\ncoerceWrap :: Wrap e a -> Wrap (Catch e) a\r\ncoerceWrap = coerce\r\n\r\nunthrow :: proxy e -> (Throws e => a) -> a\r\nunthrow _ = unWrap . coerceWrap . Wrap\r\n\r\n{- this works in GHC 7.10.3, but fails in GHC 8.0 with\r\n\r\nGHCi, version 8.0.0.20160105: http://www.haskell.org/ghc/ :? for help\r\n[1 of 1] Compiling Issue ( Issue.hs, interpreted )\r\n\r\nIssue.hs:25:13: error:\r\n • Could not deduce (Throws e)\r\n from the context: Throws e0\r\n bound by a type expected by the context:\r\n Throws e0 => a\r\n at Issue.hs:26:13-38\r\n Possible fix:\r\n add (Throws e) to the context of\r\n the type signature for:\r\n unthrow :: proxy e -> (Throws e => a) -> a\r\n • In the expression: unWrap . coerceWrap . Wrap\r\n In an equation for ‘unthrow’: unthrow _ = unWrap . coerceWrap . Wrap\r\nFailed, modules loaded: none.\r\n-}\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/11361Test tc253 doesn't pass with reversed uniques2019-07-07T18:30:44ZniteriaTest tc253 doesn't pass with reversed uniquesIt fails with:
```
tc253.hs:23:7: error:
• Couldn't match type ‘Maybe Int’ with ‘(String, Bool)’
Expected type: Maybe Int -> (String, Int) -> Maybe Int
Actual type: Fam Int Bool -> Fam Int Int -> Fam Int Bool
• In ...It fails with:
```
tc253.hs:23:7: error:
• Couldn't match type ‘Maybe Int’ with ‘(String, Bool)’
Expected type: Maybe Int -> (String, Int) -> Maybe Int
Actual type: Fam Int Bool -> Fam Int Int -> Fam Int Bool
• In the expression: inc (undefined :: Int)
In an equation for ‘foo’: foo = inc (undefined :: Int)
```
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=tc253`
I suspect this is related to #11148 since the symptoms are similar.
<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, simonmar, simonpj |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Test tc253 doesn't pass with reversed uniques","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","simonmar","simonpj"],"type":"Bug","description":"It fails with:\r\n\r\n{{{\r\ntc253.hs:23:7: error:\r\n • Couldn't match type ‘Maybe Int’ with ‘(String, Bool)’\r\n Expected type: Maybe Int -> (String, Int) -> Maybe Int\r\n Actual type: Fam Int Bool -> Fam Int Int -> Fam Int Bool\r\n • In the expression: inc (undefined :: Int)\r\n In an equation for ‘foo’: foo = inc (undefined :: Int)\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=tc253`\r\n\r\n\r\nI suspect this is related to #11148 since the symptoms are similar.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1niterianiteriahttps://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.1