GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:57:39Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/4952Typechecking regression2019-07-07T18:57:39ZIan Lynagh <igloo@earth.li>Typechecking regression1. 0.1 accepts this module (cut down from hashed-storage-0.5.4):
```
{-# LANGUAGE UndecidableInstances,
MultiParamTypeClasses,
KindSignatures,
FlexibleInstances,
FunctionalDependencies...1. 0.1 accepts this module (cut down from hashed-storage-0.5.4):
```
{-# LANGUAGE UndecidableInstances,
MultiParamTypeClasses,
KindSignatures,
FlexibleInstances,
FunctionalDependencies #-}
module Storage.Hashed.Monad () where
class Monad m => TreeRO m where
withDirectory :: (MonadError e m) => Int -> m a -> m a
expandTo :: (MonadError e m) => Int -> m Int
instance (Monad m, MonadError e m) => TreeRO (M m) where
expandTo = undefined
withDirectory dir _ = do
_ <- expandTo dir
undefined
data M (m :: * -> *) a
instance Monad m => Monad (M m) where
(>>=) = undefined
return = undefined
instance MonadError e m => MonadError e (M m)
class Monad m => MonadError e m | m -> e
```
but 7.0 branch says:
```
[1 of 1] Compiling Storage.Hashed.Monad ( Storage/Hashed/Monad.hs, interpreted )
Storage/Hashed/Monad.hs:17:12:
Could not deduce (MonadError e1 m) arising from a use of `expandTo'
from the context (Monad m, MonadError e m)
bound by the instance declaration
at Storage/Hashed/Monad.hs:14:10-50
or from (MonadError e1 (M m))
bound by the type signature for
withDirectory :: MonadError e1 (M m) => Int -> M m a -> M m a
at Storage/Hashed/Monad.hs:(16,5)-(18,15)
Possible fix:
add (MonadError e1 m) to the context of
the type signature for
withDirectory :: MonadError e1 (M m) => Int -> M m a -> M m a
or the instance declaration
In a stmt of a 'do' expression: _ <- expandTo dir
In the expression:
do { _ <- expandTo dir;
undefined }
In an equation for `withDirectory':
withDirectory dir _
= do { _ <- expandTo dir;
undefined }
Failed, modules loaded: none.
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.1 |
| 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":"Typechecking regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.2","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"7.0.1 accepts this module (cut down from hashed-storage-0.5.4):\r\n{{{\r\n{-# LANGUAGE UndecidableInstances,\r\n MultiParamTypeClasses,\r\n KindSignatures,\r\n FlexibleInstances,\r\n FunctionalDependencies #-}\r\n\r\nmodule Storage.Hashed.Monad () where\r\n\r\nclass Monad m => TreeRO m where\r\n withDirectory :: (MonadError e m) => Int -> m a -> m a\r\n expandTo :: (MonadError e m) => Int -> m Int\r\n\r\ninstance (Monad m, MonadError e m) => TreeRO (M m) where\r\n expandTo = undefined\r\n withDirectory dir _ = do\r\n _ <- expandTo dir\r\n undefined\r\n\r\ndata M (m :: * -> *) a\r\n\r\ninstance Monad m => Monad (M m) where\r\n (>>=) = undefined\r\n return = undefined\r\n\r\ninstance MonadError e m => MonadError e (M m)\r\n\r\nclass Monad m => MonadError e m | m -> e\r\n}}}\r\nbut 7.0 branch says:\r\n{{{\r\n[1 of 1] Compiling Storage.Hashed.Monad ( Storage/Hashed/Monad.hs, interpreted )\r\n\r\nStorage/Hashed/Monad.hs:17:12:\r\n Could not deduce (MonadError e1 m) arising from a use of `expandTo'\r\n from the context (Monad m, MonadError e m)\r\n bound by the instance declaration\r\n at Storage/Hashed/Monad.hs:14:10-50\r\n or from (MonadError e1 (M m))\r\n bound by the type signature for\r\n withDirectory :: MonadError e1 (M m) => Int -> M m a -> M m a\r\n at Storage/Hashed/Monad.hs:(16,5)-(18,15)\r\n Possible fix:\r\n add (MonadError e1 m) to the context of\r\n the type signature for\r\n withDirectory :: MonadError e1 (M m) => Int -> M m a -> M m a\r\n or the instance declaration\r\n In a stmt of a 'do' expression: _ <- expandTo dir\r\n In the expression:\r\n do { _ <- expandTo dir;\r\n undefined }\r\n In an equation for `withDirectory':\r\n withDirectory dir _\r\n = do { _ <- expandTo dir;\r\n undefined }\r\nFailed, modules loaded: none.\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.0.2Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/4949TH typechecking regression2019-07-07T18:57:39ZIan Lynagh <igloo@earth.li>TH typechecking regressionThe 7.0 branch (and HEAD) behaves differently to 7.0.1 on this modules:
```
{-# LANGUAGE TemplateHaskell #-}
module Foo where
import Language.Haskell.TH
x :: Int
x = let args = [| show $(varE (mkName "x")) |]
in undefined
```
1. ...The 7.0 branch (and HEAD) behaves differently to 7.0.1 on this modules:
```
{-# LANGUAGE TemplateHaskell #-}
module Foo where
import Language.Haskell.TH
x :: Int
x = let args = [| show $(varE (mkName "x")) |]
in undefined
```
1. 0.1 accepted it, while we now get:
```
Foo.hs:7:19:
Ambiguous type variable `a0' in the constraint:
(Show a0) arising from a use of `show'
Probable fix: add a type signature that fixes these type variable(s)
In the Template Haskell quotation [| show ($(varE (mkName "x"))) |]
In the expression: [| show ($(varE (mkName "x"))) |]
In an equation for `args': args = [| show ($(varE (mkName "x"))) |]
```
This affects these packages:
```
CCA
Printf-TH
grammar-combinators
hacanon-light
hamlet
rowrecord
th-lift
web-routes-quasi
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.1 |
| 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":"TH typechecking regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.2","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The 7.0 branch (and HEAD) behaves differently to 7.0.1 on this modules:\r\n{{{\r\n{-# LANGUAGE TemplateHaskell #-}\r\nmodule Foo where\r\n\r\nimport Language.Haskell.TH\r\n\r\nx :: Int\r\nx = let args = [| show $(varE (mkName \"x\")) |]\r\n in undefined\r\n}}}\r\n\r\n7.0.1 accepted it, while we now get:\r\n{{{\r\nFoo.hs:7:19:\r\n Ambiguous type variable `a0' in the constraint:\r\n (Show a0) arising from a use of `show'\r\n Probable fix: add a type signature that fixes these type variable(s)\r\n In the Template Haskell quotation [| show ($(varE (mkName \"x\"))) |]\r\n In the expression: [| show ($(varE (mkName \"x\"))) |]\r\n In an equation for `args': args = [| show ($(varE (mkName \"x\"))) |]\r\n}}}\r\n\r\nThis affects these packages:\r\n{{{\r\nCCA\r\nPrintf-TH\r\ngrammar-combinators\r\nhacanon-light\r\nhamlet\r\nrowrecord\r\nth-lift\r\nweb-routes-quasi\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.0.2Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/4940Bad error message using poly pat bind with MonoPatBinds2019-07-07T18:57:46ZbatterseapowerBad error message using poly pat bind with MonoPatBindsThis program:
```
foo :: a -> a
bar :: a -> a
(foo, bar) = (\x -> x, \y -> y)
main = print $ foo $ bar 1
```
Is trying to pattern-bind a polymorphic function. The error message is dreadful:
```
/Users/mbolingbroke/Junk/PolyPatBinds.h...This program:
```
foo :: a -> a
bar :: a -> a
(foo, bar) = (\x -> x, \y -> y)
main = print $ foo $ bar 1
```
Is trying to pattern-bind a polymorphic function. The error message is dreadful:
```
/Users/mbolingbroke/Junk/PolyPatBinds.hs:5:15:
Couldn't match expected type `t -> t1'
with actual type `forall a. a -> a'
The lambda expression `\ x -> x' has one argument one argument,
but its type `forall a. a -> a' has none
In the expression: \ x -> x
In the expression: (\ x -> x, \ y -> y)
```
The issues are:
1. It repeats itself: "one argument one argument"
1. It is patently incorrect: the type forall a. a -\> a DOES have one argument in the standard nomenclature
1. It does not point the user towards the fix (-XNoMonoPatBinds)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.1 |
| Type | FeatureRequest |
| 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":"Bad error message using poly pat bind with MonoPatBinds","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"This program:\r\n\r\n{{{\r\nfoo :: a -> a\r\nbar :: a -> a\r\n(foo, bar) = (\\x -> x, \\y -> y)\r\n\r\nmain = print $ foo $ bar 1\r\n}}}\r\n\r\nIs trying to pattern-bind a polymorphic function. The error message is dreadful:\r\n\r\n{{{\r\n/Users/mbolingbroke/Junk/PolyPatBinds.hs:5:15:\r\n Couldn't match expected type `t -> t1'\r\n with actual type `forall a. a -> a'\r\n The lambda expression `\\ x -> x' has one argument one argument,\r\n but its type `forall a. a -> a' has none\r\n In the expression: \\ x -> x\r\n In the expression: (\\ x -> x, \\ y -> y)\r\n}}}\r\n\r\nThe issues are:\r\n\r\n1. It repeats itself: \"one argument one argument\"\r\n2. It is patently incorrect: the type forall a. a -> a DOES have one argument in the standard nomenclature\r\n3. It does not point the user towards the fix (-XNoMonoPatBinds)","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4935New type error in GHC 7.1 with TypeFamilies, Rank2Types2019-07-07T18:57:51Zpatrick_premontNew type error in GHC 7.1 with TypeFamilies, Rank2TypesThe following produces a type error with ghc-7.1.20110126. No error is reported by ghc-7.0.1.
```
condBug.lhs:48:29:
Could not deduce (a ~ CondV c a (f a))
from the context (TBool c, Functor f)
bound by the type signature ...The following produces a type error with ghc-7.1.20110126. No error is reported by ghc-7.0.1.
```
condBug.lhs:48:29:
Could not deduce (a ~ CondV c a (f a))
from the context (TBool c, Functor f)
bound by the type signature for
condMap :: (TBool c, Functor f) =>
(a -> b) -> Cond c f a -> Cond c f b
at condBug.lhs:48:3-40
or from (c ~ TFalse)
bound by a type expected by the context:
c ~ TFalse => CondV c a (f a) -> b
at condBug.lhs:48:24-40
`a' is a rigid type variable bound by
the type signature for
condMap :: (TBool c, Functor f) =>
(a -> b) -> Cond c f a -> Cond c f b
at condBug.lhs:48:3
Expected type: CondV c a (f a) -> b
Actual type: a -> b
In the first argument of `cond', namely `g'
In the expression: cond g (fmap g) n
```
```
> {-# LANGUAGE TypeFamilies, Rank2Types, ScopedTypeVariables #-}
> import Control.Applicative
> data TFalse
> data TTrue
> data Tagged b a = Tagged {at :: a}
> type At b = forall a. Tagged b a -> a
> class TBool b where onTBool :: (b ~ TFalse => c) -> (b ~ TTrue => c) -> Tagged b c
> instance TBool TFalse where onTBool f _ = Tagged $ f
> instance TBool TTrue where onTBool _ t = Tagged $ t
> type family CondV c f t
> type instance CondV TFalse f t = f
> type instance CondV TTrue f t = t
> newtype Cond c f a = Cond {getCond :: CondV c a (f a)}
> cond :: forall c f a g. (TBool c, Functor g) => (c ~ TFalse => g a) -> (c ~ TTrue => g (f a)) -> g (Cond c f a)
> cond f t = (at :: At c) $ onTBool (fmap Cond f) (fmap Cond t)
> condMap :: (TBool c, Functor f) => (a -> b) -> Cond c f a -> Cond c f b
> condMap g (Cond n) = cond g (fmap g) n
> main = undefined
```
The type error seems inappropriate. Given the defintion of 'CondV', and the 'c \~ TFalse'
available form the context, shouldn't the compiler see that 'CondV c a (f a) \~ a' ?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.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":"New type error in GHC 7.1 with TypeFamilies, Rank2Types","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following produces a type error with ghc-7.1.20110126. No error is reported by ghc-7.0.1.\r\n\r\n{{{\r\ncondBug.lhs:48:29:\r\n Could not deduce (a ~ CondV c a (f a))\r\n from the context (TBool c, Functor f)\r\n bound by the type signature for\r\n condMap :: (TBool c, Functor f) =>\r\n (a -> b) -> Cond c f a -> Cond c f b\r\n at condBug.lhs:48:3-40\r\n or from (c ~ TFalse)\r\n bound by a type expected by the context:\r\n c ~ TFalse => CondV c a (f a) -> b\r\n at condBug.lhs:48:24-40\r\n `a' is a rigid type variable bound by\r\n the type signature for\r\n condMap :: (TBool c, Functor f) =>\r\n (a -> b) -> Cond c f a -> Cond c f b\r\n at condBug.lhs:48:3\r\n Expected type: CondV c a (f a) -> b\r\n Actual type: a -> b\r\n In the first argument of `cond', namely `g'\r\n In the expression: cond g (fmap g) n\r\n}}}\r\n\r\n{{{\r\n\r\n> {-# LANGUAGE TypeFamilies, Rank2Types, ScopedTypeVariables #-}\r\n\r\n> import Control.Applicative\r\n\r\n> data TFalse\r\n> data TTrue\r\n\r\n> data Tagged b a = Tagged {at :: a}\r\n> type At b = forall a. Tagged b a -> a\r\n\r\n> class TBool b where onTBool :: (b ~ TFalse => c) -> (b ~ TTrue => c) -> Tagged b c\r\n> instance TBool TFalse where onTBool f _ = Tagged $ f\r\n> instance TBool TTrue where onTBool _ t = Tagged $ t\r\n\r\n> type family CondV c f t\r\n> type instance CondV TFalse f t = f\r\n> type instance CondV TTrue f t = t\r\n\r\n> newtype Cond c f a = Cond {getCond :: CondV c a (f a)}\r\n> cond :: forall c f a g. (TBool c, Functor g) => (c ~ TFalse => g a) -> (c ~ TTrue => g (f a)) -> g (Cond c f a)\r\n> cond f t = (at :: At c) $ onTBool (fmap Cond f) (fmap Cond t)\r\n> condMap :: (TBool c, Functor f) => (a -> b) -> Cond c f a -> Cond c f b\r\n> condMap g (Cond n) = cond g (fmap g) n\r\n \r\n> main = undefined\r\n\r\n}}}\r\n\r\nThe type error seems inappropriate. Given the defintion of 'CondV', and the 'c ~ TFalse'\r\navailable form the context, shouldn't the compiler see that 'CondV c a (f a) ~ a' ?\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4921report ambiguous type variables more consistently2019-07-07T18:57:55ZSaizanreport ambiguous type variables more consistently```
{-# LANGUAGE MultiParamTypeClasses #-}
module Amb where ...```
{-# LANGUAGE MultiParamTypeClasses #-}
module Amb where
class C a b where
f :: (a,b)
instance C Int Char where
f = undefined
{-
x = fst f
/home/saizan/snippets/Amb.hs:7:8:
Ambiguous type variables `a', `b' in the constraint:
`C a b'
arising from a use of `f' at /home/saizan/snippets/Amb.hs:7:8
Possible cause: the monomorphism restriction applied to the following:
x :: a (bound at /home/saizan/snippets/Amb.hs:7:0)
Probable fix: give these definition(s) an explicit type signature
or use -XNoMonomorphismRestriction
Failed, modules loaded: none.
-}
{-
y = fst f :: Int
/home/saizan/snippets/Amb.hs:21:8:
No instance for (C Int b)
arising from a use of `f' at /home/saizan/snippets/Amb.hs:21:8
Possible fix: add an instance declaration for (C Int b)
In the first argument of `fst', namely `f'
In the expression: fst f :: Int
In the definition of `y': y = fst f :: Int
Failed, modules loaded: none.
-}
```
Both x and y have the same problem, there isn't enough type information to let the typechecker decide on an instance, so it seems they should produce similar error messages.
In particular, the error for y is quite confusing since it can be reasonably interpreted as saying there's no type b for which there's an instance C Int b, which in fact is not true, so i think explicitly mentioning the ambiguity like in the first message would help many to understand the problem better.
I can see though that an "instance C Int b" could make sense, more often than C a b, so maybe "Possible fix: add an instance declaration for (C Int b)" should be conserved, even if it still has the problem of expressing that the second argument needs to be a variable.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 7.0.1 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"report ambiguous type variables more consistently","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"{{{\r\n{-# LANGUAGE MultiParamTypeClasses #-} \r\nmodule Amb where \r\n \r\nclass C a b where \r\n f :: (a,b) \r\n \r\ninstance C Int Char where \r\n f = undefined \r\n \r\n{- \r\nx = fst f \r\n/home/saizan/snippets/Amb.hs:7:8: \r\n Ambiguous type variables `a', `b' in the constraint: \r\n `C a b' \r\n arising from a use of `f' at /home/saizan/snippets/Amb.hs:7:8 \r\n Possible cause: the monomorphism restriction applied to the following: \r\n x :: a (bound at /home/saizan/snippets/Amb.hs:7:0) \r\n Probable fix: give these definition(s) an explicit type signature \r\n or use -XNoMonomorphismRestriction \r\nFailed, modules loaded: none. \r\n-} \r\n \r\n{- \r\ny = fst f :: Int \r\n \r\n/home/saizan/snippets/Amb.hs:21:8: \r\n No instance for (C Int b) \r\n arising from a use of `f' at /home/saizan/snippets/Amb.hs:21:8 \r\n Possible fix: add an instance declaration for (C Int b) \r\n In the first argument of `fst', namely `f' \r\n In the expression: fst f :: Int \r\n In the definition of `y': y = fst f :: Int \r\nFailed, modules loaded: none. \r\n-}\r\n}}}\r\n\r\nBoth x and y have the same problem, there isn't enough type information to let the typechecker decide on an instance, so it seems they should produce similar error messages.\r\n\r\nIn particular, the error for y is quite confusing since it can be reasonably interpreted as saying there's no type b for which there's an instance C Int b, which in fact is not true, so i think explicitly mentioning the ambiguity like in the first message would help many to understand the problem better.\r\n\r\nI can see though that an \"instance C Int b\" could make sense, more often than C a b, so maybe \"Possible fix: add an instance declaration for (C Int b)\" should be conserved, even if it still has the problem of expressing that the second argument needs to be a variable.","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/4856Performance regression in the type checker regression for GADTs and type fami...2019-07-07T18:58:11ZManuel M T ChakravartyPerformance regression in the type checker regression for GADTs and type familiesThe GHC 7.0.2 RC1 shows poor performance when compiling `Data.Array.Accelerate`. In particular, to type check a particular module, GHC 7.02 takes several minutes, while GHC's resident memory grows to 350MB. In contrast, GHC 6.12.3 compil...The GHC 7.0.2 RC1 shows poor performance when compiling `Data.Array.Accelerate`. In particular, to type check a particular module, GHC 7.02 takes several minutes, while GHC's resident memory grows to 350MB. In contrast, GHC 6.12.3 compiles the same module in a few seconds.
How to reproduce the problem:
1. Download the latest version of `Data.Array.Accelerate` with darcs from [http://code.haskell.org/accelerate/](http://code.haskell.org/accelerate/)
1. Change directory to the new `accelerate` darcs repo.
1. Invoke GHCi as `ghci -Iinclude`.
1. Issue the GHCi command: `:l Data/Array/Accelerate/Smart.hs`
You will notice that `Data.Arra.Accelerate.Array.Sugar`, which is heavy in type classes and type families, already requires a noticeable time to compile — this is already a performance regression from 6.12.3. The module `Data.Array.Accelerate.Smart` requires an even much longer time to compile.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.1 |
| Type | Bug |
| TypeOfFailure | ValidProgramRejected |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Performance regression in the type checker regression for GADTs and type families","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The GHC 7.0.2 RC1 shows poor performance when compiling `Data.Array.Accelerate`. In particular, to type check a particular module, GHC 7.02 takes several minutes, while GHC's resident memory grows to 350MB. In contrast, GHC 6.12.3 compiles the same module in a few seconds.\r\n\r\nHow to reproduce the problem:\r\n\r\n 0. Download the latest version of `Data.Array.Accelerate` with darcs from [http://code.haskell.org/accelerate/]\r\n 1. Change directory to the new `accelerate` darcs repo.\r\n 2. Invoke GHCi as `ghci -Iinclude`.\r\n 3. Issue the GHCi command: `:l Data/Array/Accelerate/Smart.hs`\r\n\r\nYou will notice that `Data.Arra.Accelerate.Array.Sugar`, which is heavy in type classes and type families, already requires a noticeable time to compile — this is already a performance regression from 6.12.3. The module `Data.Array.Accelerate.Smart` requires an even much longer time to compile.","type_of_failure":"ValidProgramRejected","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4801Typechecker performance regression 6.12 -> 7.0.12019-07-07T18:58:29ZSimon MarlowTypechecker performance regression 6.12 -> 7.0.1The attached module is a smaller version of the example in #4505.
With GHC 6.12.3 it takes 4s to compile (x86_64/Linux), whereas with 7.0.1 it takes 282s. HEAD seems about the same as 7.0.1.
<details><summary>Trac metadata</summary>
|...The attached module is a smaller version of the example in #4505.
With GHC 6.12.3 it takes 4s to compile (x86_64/Linux), whereas with 7.0.1 it takes 282s. HEAD seems about the same as 7.0.1.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.1 |
| 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":"Typechecker performance regression 6.12 -> 7.0.1","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.2","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The attached module is a smaller version of the example in #4505.\r\n\r\nWith GHC 6.12.3 it takes 4s to compile (x86_64/Linux), whereas with 7.0.1 it takes 282s. HEAD seems about the same as 7.0.1.","type_of_failure":"OtherFailure","blocking":[]} -->7.0.2Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/4798Make HsIf more polymorphic with RebindableSyntax2019-07-07T18:58:30ZnschMake HsIf more polymorphic with RebindableSyntaxCurrently, ifThenElse is typed this way:
```
ifThenElse :: pred_ty -> b_ty -> b_ty -> res_ty
```
I propose to change this to:
```
ifThenElse :: pred_ty -> b1_ty -> b2_ty -> res_ty
```
to support expressions like this:
```
ifThenElse...Currently, ifThenElse is typed this way:
```
ifThenElse :: pred_ty -> b_ty -> b_ty -> res_ty
```
I propose to change this to:
```
ifThenElse :: pred_ty -> b1_ty -> b2_ty -> res_ty
```
to support expressions like this:
```
ifThenElse :: Maybe a -> (a -> b) -> b -> b
ifThenElse (Just a) f _ = f a
ifThenElse Nothing _ e = e
example :: String
example = if Just 2
then \v -> show v
else "No value"
```
The fix is very simple and just one more line to add to the typechecker. Patch is attached.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.1 |
| Type | FeatureRequest |
| 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":"Make HsIf more polymorphic with RebindableSyntax","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"nsch"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"Currently, ifThenElse is typed this way:\r\n\r\n{{{\r\nifThenElse :: pred_ty -> b_ty -> b_ty -> res_ty\r\n}}}\r\n\r\nI propose to change this to:\r\n\r\n{{{\r\nifThenElse :: pred_ty -> b1_ty -> b2_ty -> res_ty\r\n}}}\r\n\r\nto support expressions like this:\r\n\r\n{{{\r\nifThenElse :: Maybe a -> (a -> b) -> b -> b\r\nifThenElse (Just a) f _ = f a\r\nifThenElse Nothing _ e = e\r\n\r\nexample :: String\r\nexample = if Just 2\r\n then \\v -> show v\r\n else \"No value\"\r\n}}}\r\n\r\nThe fix is very simple and just one more line to add to the typechecker. Patch is attached.","type_of_failure":"OtherFailure","blocking":[]} -->nschnschhttps://gitlab.haskell.org/ghc/ghc/-/issues/4529Deriving Data does not work for attached code2019-07-07T18:58:32ZmitarDeriving Data does not work for attached codeFor attached code I get this error:
```
Test2.hs:19:48:
Could not deduce (Real r, Random r)
from the context (Data r, Typeable1 t)
arising from a use of `f'
Possible fix:
add (Real r, Random r) to the context o...For attached code I get this error:
```
Test2.hs:19:48:
Could not deduce (Real r, Random r)
from the context (Data r, Typeable1 t)
arising from a use of `f'
Possible fix:
add (Real r, Random r) to the context of
the type signature for `dataCast1'
or the instance declaration
In the first argument of `gcast1', namely `f'
In the expression: gcast1 f
In an equation for `dataCast1': dataCast1 f = gcast1 f
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | mmitar@gmail.com |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Deriving Data does not work for attached code","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["mmitar@gmail.com"],"type":"Bug","description":"For attached code I get this error:\r\n\r\n{{{\r\nTest2.hs:19:48:\r\n Could not deduce (Real r, Random r)\r\n from the context (Data r, Typeable1 t)\r\n arising from a use of `f'\r\n Possible fix:\r\n add (Real r, Random r) to the context of\r\n the type signature for `dataCast1'\r\n or the instance declaration\r\n In the first argument of `gcast1', namely `f'\r\n In the expression: gcast1 f\r\n In an equation for `dataCast1': dataCast1 f = gcast1 f\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4528stand-alone deriving sometimes fails for GADTs2019-07-07T18:58:33Znestrastand-alone deriving sometimes fails for GADTsConsider the following module
```
{-# LANGUAGE GADTs, StandaloneDeriving #-}
module Foo where
data Foo a where
A, B :: Foo Int
deriving instance Enum (Foo a)
```
Loading it into GHCi causes the following message:
```
ghc: panic! (...Consider the following module
```
{-# LANGUAGE GADTs, StandaloneDeriving #-}
module Foo where
data Foo a where
A, B :: Foo Int
deriving instance Enum (Foo a)
```
Loading it into GHCi causes the following message:
```
ghc: panic! (the 'impossible' happened)
(GHC version 7.0.1 for x86_64-unknown-linux):
maybe_is_tagToEnum_call.extract_constr_Ids
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
In the case of Bounded instead of Enum in the original code, it does not work either but the error message is more "even-tempered":
```
Foo.hs:7:1:
Couldn't match type `a' with `Int'
`a' is a rigid type variable bound by
the instance declaration at Foo.hs:7:32
In the expression: A
In an equation for `minBound': minBound = A
When typechecking the code for `minBound'
in a standalone derived instance for `Bounded (Foo a)':
To see the code I am typechecking, use -ddump-deriv
In the instance declaration for `Bounded (Foo a)'
Foo.hs:7:1:
Couldn't match type `a' with `Int'
`a' is a rigid type variable bound by
the instance declaration at Foo.hs:7:32
In the expression: B
In an equation for `maxBound': maxBound = B
When typechecking the code for `maxBound'
in a standalone derived instance for `Bounded (Foo a)':
To see the code I am typechecking, use -ddump-deriv
In the instance declaration for `Bounded (Foo a)'
Failed, modules loaded: none.
```
I suspect that this is also a bug, as it would be perfectly reasonable to have minBound and maxBound for a type such as Foo Int.
A similar deriving fails also for Read class, among those I tried.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.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":"stand-alone deriving sometimes fails for GADTs","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":["GADTs","deriving","mechanism,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following module\r\n\r\n{{{\r\n{-# LANGUAGE GADTs, StandaloneDeriving #-}\r\nmodule Foo where\r\n\r\ndata Foo a where\r\n A, B :: Foo Int\r\n\r\nderiving instance Enum (Foo a)\r\n}}}\r\n\r\nLoading it into GHCi causes the following message:\r\n\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 7.0.1 for x86_64-unknown-linux):\r\n maybe_is_tagToEnum_call.extract_constr_Ids\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nIn the case of Bounded instead of Enum in the original code, it does not work either but the error message is more \"even-tempered\":\r\n\r\n{{{\r\nFoo.hs:7:1:\r\n Couldn't match type `a' with `Int'\r\n `a' is a rigid type variable bound by\r\n the instance declaration at Foo.hs:7:32\r\n In the expression: A\r\n In an equation for `minBound': minBound = A\r\n When typechecking the code for `minBound'\r\n in a standalone derived instance for `Bounded (Foo a)':\r\n To see the code I am typechecking, use -ddump-deriv\r\n In the instance declaration for `Bounded (Foo a)'\r\n\r\nFoo.hs:7:1:\r\n Couldn't match type `a' with `Int'\r\n `a' is a rigid type variable bound by\r\n the instance declaration at Foo.hs:7:32\r\n In the expression: B\r\n In an equation for `maxBound': maxBound = B\r\n When typechecking the code for `maxBound'\r\n in a standalone derived instance for `Bounded (Foo a)':\r\n To see the code I am typechecking, use -ddump-deriv\r\n In the instance declaration for `Bounded (Foo a)'\r\nFailed, modules loaded: none.\r\n}}}\r\n\r\nI suspect that this is also a bug, as it would be perfectly reasonable to have minBound and maxBound for a type such as Foo Int.\r\n\r\nA similar deriving fails also for Read class, among those I tried. \r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4525Type synonyms not expanded consistently in errors2019-07-07T18:58:34ZIan Lynagh <igloo@earth.li>Type synonyms not expanded consistently in errorsWith this module:
```
type Foo = Int
x :: Char
x = f
f :: Foo
f = 5
```
GHC says:
```
g.hs:5:5:
Couldn't match expected type `Char' with actual type `Int'
Expected type: Char
Actual type: Foo
In the expression: f
...With this module:
```
type Foo = Int
x :: Char
x = f
f :: Foo
f = 5
```
GHC says:
```
g.hs:5:5:
Couldn't match expected type `Char' with actual type `Int'
Expected type: Char
Actual type: Foo
In the expression: f
In an equation for `x': x = f
```
Note that the first line talks about `Int`, whereas the third line talks about `Foo`. I'd expect both to talk about `Foo`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.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":"Type synonyms not expanded consistently in errors","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.4.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"With this module:\r\n{{{\r\ntype Foo = Int\r\n\r\nx :: Char\r\nx = f\r\n\r\nf :: Foo\r\nf = 5\r\n}}}\r\nGHC says:\r\n{{{\r\ng.hs:5:5:\r\n Couldn't match expected type `Char' with actual type `Int'\r\n Expected type: Char\r\n Actual type: Foo\r\n In the expression: f\r\n In an equation for `x': x = f\r\n}}}\r\nNote that the first line talks about `Int`, whereas the third line talks about `Foo`. I'd expect both to talk about `Foo`.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/4524Template variable unbound in rewrite rule2019-07-07T18:58:34ZguestTemplate variable unbound in rewrite ruleI was trying to compile the latest darcs source (darcs get --lazy http://darcs.net) using ghc7. I had to modify darcs.cabal to add !NoMonoLocalBinds to 3 places (just search for extensions, and add it to the END of the lists).
When I do...I was trying to compile the latest darcs source (darcs get --lazy http://darcs.net) using ghc7. I had to modify darcs.cabal to add !NoMonoLocalBinds to 3 places (just search for extensions, and add it to the END of the lists).
When I do a build I get this:
```
[ 65 of 154] Compiling Darcs.Patch.V1.Commute ( src/Darcs/Patch/V1/Commute.lhs, dist/build/Darcs/Patch/V1/Commute.o )
ghc: panic! (the 'impossible' happened)
(GHC version 7.0.1 for i386-unknown-linux):
Template variable unbound in rewrite rule
sg_s2vkQ{tv} [co]
[x{tv a2uFt} [sk], y{tv a2uFu} [sk], sg_s2vkQ{tv} [co],
sc_s2vkR{v} [lid], sc_s2vkS{v} [lid]]
[x{tv X2uJc} [sk], y{tv X2uJe} [sk], sg_s2vkQ{tv} [co],
sc_s2vkR{v} [lid], sc_s2vkS{v} [lid]]
[TYPE y{tv a2uFu} [sk], TYPE y{tv a2uFu} [sk],
TYPE x{tv a2uFt} [sk], TYPE x{tv a2uFt} [sk],
TYPE x{tv a2uFt} [sk], sc_s2vkS{v} [lid], sc_s2vkR{v} [lid],
darcs-2.5:Darcs.Witnesses.Ordered.NilRL{v ruI5} [gid[DataCon]]
@ darcs-2.5:Darcs.Patch.V1.Core.Patch{tc r1EYF}
@ x{tv a2uFt} [sk]
@ x{tv a2uFt} [sk]
@ x{tv a2uFt} [sk]]
[TYPE y{tv a2uFu} [sk], TYPE y{tv a2uFu} [sk],
TYPE x{tv a2uFt} [sk], TYPE x{tv a2uFt} [sk],
TYPE x{tv a2uFt} [sk], wild_s2vhT{v} [lid], sc_s2vke{v} [lid],
darcs-2.5:Darcs.Witnesses.Ordered.NilRL{v ruI5} [gid[DataCon]]
@ darcs-2.5:Darcs.Patch.V1.Core.Patch{tc r1EYF}
@ x{tv a2uFt} [sk]
@ x{tv a2uFt} [sk]
@ x{tv a2uFt} [sk]]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
As an additional data point, this module builds correctly without !NoMonoLocalBinds. The reason I was adding !NoMonoLocalBinds to the .cabal file is because I can't use `#if __GLASGOW_HASKELL >= 700` to conditionally add in this language flag. The reason is because ghc6 will not correctly understand the language flag appearing inside a CPP \#if/\#endif block and I want this code to compile on ghc6 and 7.
Please let me know if I can provide additional information to help reproduce this bug. My email address is dagitj on gmail, also on CC of this ticket.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | dagitj@gmail.com |
| Operating system | Unknown/Multiple |
| Architecture | Unknown/Multiple |
</details>
<!-- {"blocked_by":[],"summary":"Template variable unbound in rewrite rule","status":"New","operating_system":"Unknown/Multiple","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown/Multiple","cc":["dagitj@gmail.com"],"type":"Bug","description":"I was trying to compile the latest darcs source (darcs get --lazy http://darcs.net) using ghc7. I had to modify darcs.cabal to add !NoMonoLocalBinds to 3 places (just search for extensions, and add it to the END of the lists).\r\n\r\nWhen I do a build I get this:\r\n{{{\r\n[ 65 of 154] Compiling Darcs.Patch.V1.Commute ( src/Darcs/Patch/V1/Commute.lhs, dist/build/Darcs/Patch/V1/Commute.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 7.0.1 for i386-unknown-linux):\r\n\tTemplate variable unbound in rewrite rule\r\n sg_s2vkQ{tv} [co]\r\n [x{tv a2uFt} [sk], y{tv a2uFu} [sk], sg_s2vkQ{tv} [co],\r\n sc_s2vkR{v} [lid], sc_s2vkS{v} [lid]]\r\n [x{tv X2uJc} [sk], y{tv X2uJe} [sk], sg_s2vkQ{tv} [co],\r\n sc_s2vkR{v} [lid], sc_s2vkS{v} [lid]]\r\n [TYPE y{tv a2uFu} [sk], TYPE y{tv a2uFu} [sk],\r\n TYPE x{tv a2uFt} [sk], TYPE x{tv a2uFt} [sk],\r\n TYPE x{tv a2uFt} [sk], sc_s2vkS{v} [lid], sc_s2vkR{v} [lid],\r\n darcs-2.5:Darcs.Witnesses.Ordered.NilRL{v ruI5} [gid[DataCon]]\r\n @ darcs-2.5:Darcs.Patch.V1.Core.Patch{tc r1EYF}\r\n @ x{tv a2uFt} [sk]\r\n @ x{tv a2uFt} [sk]\r\n @ x{tv a2uFt} [sk]]\r\n [TYPE y{tv a2uFu} [sk], TYPE y{tv a2uFu} [sk],\r\n TYPE x{tv a2uFt} [sk], TYPE x{tv a2uFt} [sk],\r\n TYPE x{tv a2uFt} [sk], wild_s2vhT{v} [lid], sc_s2vke{v} [lid],\r\n darcs-2.5:Darcs.Witnesses.Ordered.NilRL{v ruI5} [gid[DataCon]]\r\n @ darcs-2.5:Darcs.Patch.V1.Core.Patch{tc r1EYF}\r\n @ x{tv a2uFt} [sk]\r\n @ x{tv a2uFt} [sk]\r\n @ x{tv a2uFt} [sk]]\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nAs an additional data point, this module builds correctly without !NoMonoLocalBinds. The reason I was adding !NoMonoLocalBinds to the .cabal file is because I can't use `#if __GLASGOW_HASKELL >= 700` to conditionally add in this language flag. The reason is because ghc6 will not correctly understand the language flag appearing inside a CPP #if/#endif block and I want this code to compile on ghc6 and 7.\r\n\r\nPlease let me know if I can provide additional information to help reproduce this bug. My email address is dagitj on gmail, also on CC of this ticket.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4499"skolem type variable" is bad for usability (and beginners)2019-07-07T18:58:43Zguest"skolem type variable" is bad for usability (and beginners)I believe the new type error message in GHC7 that mentions "skolem" is a hindrance to usability because "skolem" is not a well known term, even in the Haskell community.
I believe using this terminology, even though correct, is going to...I believe the new type error message in GHC7 that mentions "skolem" is a hindrance to usability because "skolem" is not a well known term, even in the Haskell community.
I believe using this terminology, even though correct, is going to confuse people. When I do a google search for:
> haskell skolem type variable
This wiki page does show up:
http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7
Which is great, but after reading it I still don't know \*what\* a skolem type variable is. I now have a trick for working around some instances of the problem created by the changes in the ghc7 type checker, but I'm still none of the wiser as to what is skolem (or why I should care).
I consider this change in error message text to be a regression in the usability of GHC, which in version 6 had the best type error messages of any Haskell compiler. I don't think mentioning skolem is a bad thing (interested parties will learn about skolems), but I think throwing the term around as if the average Haskell programmer already knows what it means is a regression.
Please consider rephrasing this error message.
In the example from the wiki page linked above, what about changing the error message to be similar to this:
```
Foo.hs:7:11:
Couldn't match type `s' with `s1'
because the type variable `s' would escape: `s1'
Hint: `s' is a skolem type variable
The type variable `s' bound by the polymorphic type `forall s. ST s a'
The following variables have types that mention s
fill :: STRef s a -> ST s () (bound at Foo.hs:10:11)
In the first argument of `runST', namely
`(do { r <- newSTRef x; fill r; readSTRef r })'
```
My point is that the new term, skolem, is de-emphasized but still mentioned for the sake of googling and experts.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | dagitj@gmail.com |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"\"skolem type variable\" is bad for usability (and beginners)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":["skolem"],"differentials":[],"test_case":"","architecture":"","cc":["dagitj@gmail.com"],"type":"Bug","description":"I believe the new type error message in GHC7 that mentions \"skolem\" is a hindrance to usability because \"skolem\" is not a well known term, even in the Haskell community.\r\n\r\nI believe using this terminology, even though correct, is going to confuse people. When I do a google search for:\r\n haskell skolem type variable\r\n\r\nThis wiki page does show up:\r\nhttp://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7\r\n\r\nWhich is great, but after reading it I still don't know *what* a skolem type variable is. I now have a trick for working around some instances of the problem created by the changes in the ghc7 type checker, but I'm still none of the wiser as to what is skolem (or why I should care).\r\n\r\nI consider this change in error message text to be a regression in the usability of GHC, which in version 6 had the best type error messages of any Haskell compiler. I don't think mentioning skolem is a bad thing (interested parties will learn about skolems), but I think throwing the term around as if the average Haskell programmer already knows what it means is a regression.\r\n\r\nPlease consider rephrasing this error message.\r\n\r\nIn the example from the wiki page linked above, what about changing the error message to be similar to this:\r\n{{{\r\nFoo.hs:7:11:\r\n Couldn't match type `s' with `s1'\r\n because the type variable `s' would escape: `s1'\r\n Hint: `s' is a skolem type variable\r\n The type variable `s' bound by the polymorphic type `forall s. ST s a'\r\n The following variables have types that mention s\r\n fill :: STRef s a -> ST s () (bound at Foo.hs:10:11)\r\n In the first argument of `runST', namely\r\n `(do { r <- newSTRef x; fill r; readSTRef r })'\r\n}}}\r\n\r\nMy point is that the new term, skolem, is de-emphasized but still mentioned for the sake of googling and experts.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4494Another regression with type families2019-07-07T18:58:44Zrl@cse.unsw.edu.auAnother regression with type familiesProgram (compile with !ScopedTypeVariables):
```
type family H s a b
class D (G v) => C v where
type G v
type F v
foo :: v -> H (F v) (G v) v
class D s where
bar :: (forall t. Maybe t -> a) -> s -> H a s r -> r
call :: forall...Program (compile with !ScopedTypeVariables):
```
type family H s a b
class D (G v) => C v where
type G v
type F v
foo :: v -> H (F v) (G v) v
class D s where
bar :: (forall t. Maybe t -> a) -> s -> H a s r -> r
call :: forall v. C v => F v -> v
call x = bar (\_ -> x)
(undefined :: G v)
(foo (undefined :: v))
bar' :: C v => (forall t. Maybe t -> F v) -> G v -> H (F v) (G v) v -> v
bar' = bar
```
The current head (even with today's typechecker patch) complains:
```
Could not deduce (H a (G v) v ~ H (F v) (G v) v)
from the context (C v)
```
But if I change `bar` to `bar'` in the rhs of `foo`, it all works fine. 6.12.3 accepts both programs.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.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":"Another regression with type families","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Program (compile with !ScopedTypeVariables):\r\n\r\n{{{\r\ntype family H s a b\r\n\r\nclass D (G v) => C v where\r\n type G v\r\n type F v\r\n foo :: v -> H (F v) (G v) v\r\n\r\nclass D s where\r\n bar :: (forall t. Maybe t -> a) -> s -> H a s r -> r\r\n\r\ncall :: forall v. C v => F v -> v\r\ncall x = bar (\\_ -> x)\r\n (undefined :: G v)\r\n (foo (undefined :: v))\r\n\r\nbar' :: C v => (forall t. Maybe t -> F v) -> G v -> H (F v) (G v) v -> v\r\nbar' = bar\r\n}}}\r\n\r\nThe current head (even with today's typechecker patch) complains:\r\n\r\n{{{\r\n Could not deduce (H a (G v) v ~ H (F v) (G v) v)\r\n from the context (C v)\r\n}}}\r\n\r\nBut if I change `bar` to `bar'` in the rhs of `foo`, it all works fine. 6.12.3 accepts both programs.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4492Type families regression2021-01-03T00:19:55Zrl@cse.unsw.edu.auType families regressionHere is a small program:
```
type family F a b
type instance F (Maybe a) b = b -> F a b
class C a where
go :: (forall a. Maybe a -> b -> a) -> a -> F a b
instance C a => C (Maybe a) where
go f a b = go f (f a b)
```
The current h...Here is a small program:
```
type family F a b
type instance F (Maybe a) b = b -> F a b
class C a where
go :: (forall a. Maybe a -> b -> a) -> a -> F a b
instance C a => C (Maybe a) where
go f a b = go f (f a b)
```
The current head complains:
```
Could not deduce (F a b ~ F a b) from the context (C a)
NB: `F' is a type function, and may not be injective
Expected type: b -> F a b
Actual type: F (Maybe a) b
```
1. 12.3 accepts it.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.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":"Type families regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here is a small program:\r\n\r\n{{{\r\ntype family F a b\r\ntype instance F (Maybe a) b = b -> F a b\r\n\r\nclass C a where\r\n go :: (forall a. Maybe a -> b -> a) -> a -> F a b\r\n\r\ninstance C a => C (Maybe a) where\r\n go f a b = go f (f a b)\r\n}}}\r\n\r\nThe current head complains:\r\n\r\n{{{\r\n Could not deduce (F a b ~ F a b) from the context (C a)\r\n NB: `F' is a type function, and may not be injective\r\n Expected type: b -> F a b\r\n Actual type: F (Maybe a) b\r\n}}}\r\n\r\n6.12.3 accepts it.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4482Allow type variables to be instantiated as a typeclass2019-07-07T18:58:47ZgidynAllow type variables to be instantiated as a typeclassAllow code such as
```
x = [1,True]::[Show]
```
This would eliminate the need for manual wrapper types, which bloat code with type plumbing.
<details><summary>Trac metadata</summary>
| Trac field | Value ...Allow code such as
```
x = [1,True]::[Show]
```
This would eliminate the need for manual wrapper types, which bloat code with type plumbing.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.12.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | gideon@accursoft.com |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Allow type variables to be instantiated as a typeclass","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.12.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["gideon@accursoft.com"],"type":"Bug","description":"Allow code such as\r\n{{{\r\nx = [1,True]::[Show]\r\n}}}\r\nThis would eliminate the need for manual wrapper types, which bloat code with type plumbing.","type_of_failure":"OtherFailure","blocking":[]} -->7.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/4479Implement TDNR2021-01-08T20:29:07ZgidynImplement TDNRA request to implement [TDNR](https://wiki.haskell.org/TypeDirectedNameResolution).A request to implement [TDNR](https://wiki.haskell.org/TypeDirectedNameResolution).8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/4418Superclass functional dependencies are ignored during instance selection2019-07-07T18:59:06ZreinerpSuperclass functional dependencies are ignored during instance selectionThe following example compiles with ghc-6.12.3, but not with ghc-7.0.0.20100924:
```
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module Ambiguity where
class C1 a b | b -> a
class (C1 a b) => C2 a b where
foo :: b...The following example compiles with ghc-6.12.3, but not with ghc-7.0.0.20100924:
```
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module Ambiguity where
class C1 a b | b -> a
class (C1 a b) => C2 a b where
foo :: b -> b
data A = A
data B = B
instance C1 A B
instance C2 A B
-- this is accepted by both 6.12.3 and 7
runFoo :: C2 a b => b -> b
runFoo = foo
-- this is accepted by 6.12.3, but not by 7
runFoo2 :: B -> B
runFoo2 = foo
```
A straightforward fix is to add the `b -> a` fundep to the `C2` class as well.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.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":"Superclass functional dependencies are ignored during instance selection","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following example compiles with ghc-6.12.3, but not with ghc-7.0.0.20100924:\r\n{{{\r\n{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}\r\n\r\nmodule Ambiguity where\r\n\r\nclass C1 a b | b -> a\r\nclass (C1 a b) => C2 a b where\r\n foo :: b -> b\r\n\r\ndata A = A\r\ndata B = B\r\ninstance C1 A B\r\ninstance C2 A B\r\n\r\n-- this is accepted by both 6.12.3 and 7\r\nrunFoo :: C2 a b => b -> b\r\nrunFoo = foo\r\n\r\n-- this is accepted by 6.12.3, but not by 7\r\nrunFoo2 :: B -> B\r\nrunFoo2 = foo\r\n}}}\r\n\r\nA straightforward fix is to add the {{{b -> a}}} fundep to the {{{C2}}} class as well.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4404RecordWildCards2019-07-07T18:59:10ZIan Lynagh <igloo@earth.li>RecordWildCardsWith this module:
```
{-# LANGUAGE RecordWildCards #-}
module TT where
data T = T {t1, t2 :: Int}
f :: T -> Int
f d = x
where T {t1 = x, ..} = d
g :: T -> Int
g (T {t1 = x, ..}) = x
```
`f` gives warnings about t2 being unused:...With this module:
```
{-# LANGUAGE RecordWildCards #-}
module TT where
data T = T {t1, t2 :: Int}
f :: T -> Int
f d = x
where T {t1 = x, ..} = d
g :: T -> Int
g (T {t1 = x, ..}) = x
```
`f` gives warnings about t2 being unused:
```
$ ghc -Wall -c n.hs
n.hs:9:11: Warning: Defined but not used: `t2'
```
which is probably not what we want for variables bound by a wildcard. Reported by Serge here:
http://www.haskell.org/pipermail/glasgow-haskell-bugs/2010-October/025858.html
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.12.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":"RecordWildCards","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.4.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.12.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"With this module:\r\n{{{\r\n{-# LANGUAGE RecordWildCards #-}\r\n\r\nmodule TT where\r\n\r\ndata T = T {t1, t2 :: Int}\r\n\r\nf :: T -> Int\r\nf d = x\r\n where T {t1 = x, ..} = d\r\n\r\ng :: T -> Int\r\ng (T {t1 = x, ..}) = x\r\n}}}\r\n`f` gives warnings about t2 being unused:\r\n{{{\r\n$ ghc -Wall -c n.hs\r\n\r\nn.hs:9:11: Warning: Defined but not used: `t2'\r\n}}}\r\nwhich is probably not what we want for variables bound by a wildcard. Reported by Serge here:\r\nhttp://www.haskell.org/pipermail/glasgow-haskell-bugs/2010-October/025858.html\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.4.1Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/4396tc003(hpc) failing with link error2019-07-07T18:59:12ZSimon Marlowtc003(hpc) failing with link error```
=====> tc003(hpc) 1980 of 2622 [0, 37, 0]
cd ./typecheck/should_compile && '/64playpen/simonmar/nightly/HEAD-cam-04-unx/x86_64-unknown-linux/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-pac...```
=====> tc003(hpc) 1980 of 2622 [0, 37, 0]
cd ./typecheck/should_compile && '/64playpen/simonmar/nightly/HEAD-cam-04-unx/x86_64-unknown-linux/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-conf -rtsopts -c tc003.hs -O -fhpc -fno-warn-incomplete-patterns >tc003.comp.stderr 2>&1
Compile failed (status 256) errors were:
/tmp/ghc14267_0/ghc14267_0.s: Assembler messages:
/tmp/ghc14267_0/ghc14267_0.s:173:0:
Error: symbol `ShouldSucceed_e_closure' is already defined
/tmp/ghc14267_0/ghc14267_0.s:196:0:
Error: symbol `ShouldSucceed_e_info' is already defined
/tmp/ghc14267_0/ghc14267_0.s:237:0:
Error: symbol `ShouldSucceed_d_closure' is already defined
/tmp/ghc14267_0/ghc14267_0.s:260:0:
Error: symbol `ShouldSucceed_d_info' is already defined
*** unexpected failure for tc003(hpc)
```
Apparently the simplifier is generating multiple bindings for `d` and `e`. (Core Lint ought to check for this too).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.1 |
| 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":"tc003(hpc) failing with link error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\n=====> tc003(hpc) 1980 of 2622 [0, 37, 0]\r\ncd ./typecheck/should_compile && '/64playpen/simonmar/nightly/HEAD-cam-04-unx/x86_64-unknown-linux/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-conf -rtsopts -c tc003.hs -O -fhpc -fno-warn-incomplete-patterns >tc003.comp.stderr 2>&1\r\nCompile failed (status 256) errors were:\r\n/tmp/ghc14267_0/ghc14267_0.s: Assembler messages:\r\n\r\n/tmp/ghc14267_0/ghc14267_0.s:173:0:\r\n Error: symbol `ShouldSucceed_e_closure' is already defined\r\n\r\n/tmp/ghc14267_0/ghc14267_0.s:196:0:\r\n Error: symbol `ShouldSucceed_e_info' is already defined\r\n\r\n/tmp/ghc14267_0/ghc14267_0.s:237:0:\r\n Error: symbol `ShouldSucceed_d_closure' is already defined\r\n\r\n/tmp/ghc14267_0/ghc14267_0.s:260:0:\r\n Error: symbol `ShouldSucceed_d_info' is already defined\r\n\r\n*** unexpected failure for tc003(hpc)\r\n}}}\r\n\r\nApparently the simplifier is generating multiple bindings for `d` and `e`. (Core Lint ought to check for this too).","type_of_failure":"OtherFailure","blocking":[]} -->7.0.1