GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:58:32Zhttps://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.1https://gitlab.haskell.org/ghc/ghc/-/issues/4395T1735(ghci) failing with core-lint error2019-07-07T18:59:12ZSimon MarlowT1735(ghci) failing with core-lint errorexcerpt from the error message:
```
GHCi, version 7.1.20101013: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ....excerpt from the error message:
```
GHCi, version 7.1.20101013: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
[1 of 6] Compiling T1735_Help.Context ( T1735_Help/Context.hs, interpreted )
[2 of 6] Compiling T1735_Help.State ( T1735_Help/State.hs, interpreted )
[3 of 6] Compiling T1735_Help.Basics ( T1735_Help/Basics.hs, interpreted )
[4 of 6] Compiling T1735_Help.Instances ( T1735_Help/Instances.hs, interpreted )
[5 of 6] Compiling T1735_Help.Xml ( T1735_Help/Xml.hs, interpreted )
*** Core Lint errors : in result of Tidy Core ***
{-# LINE 122 "T1735_Help/Xml.hs #-}:
[RHS of T1735_Help.Xml.typeNotValue :: forall a_a1NJ.
T1735_Help.Xml.Xml a_a1NJ =>
a_a1NJ -> a_a1NJ]
Demand type has 2 arguments, rhs has 1 arguments, T1735_Help.Xml.typeNotValue
Binder's strictness signature: DmdType TTb
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.12.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":"T1735(ghci) failing with core-lint error","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.12.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"excerpt from the error message:\r\n\r\n{{{\r\nGHCi, version 7.1.20101013: http://www.haskell.org/ghc/ :? for help\r\nLoading package ghc-prim ... linking ... done.\r\nLoading package integer-gmp ... linking ... done.\r\nLoading package base ... linking ... done.\r\nLoading package ffi-1.0 ... linking ... done.\r\n[1 of 6] Compiling T1735_Help.Context ( T1735_Help/Context.hs, interpreted )\r\n[2 of 6] Compiling T1735_Help.State ( T1735_Help/State.hs, interpreted )\r\n[3 of 6] Compiling T1735_Help.Basics ( T1735_Help/Basics.hs, interpreted )\r\n[4 of 6] Compiling T1735_Help.Instances ( T1735_Help/Instances.hs, interpreted )\r\n[5 of 6] Compiling T1735_Help.Xml ( T1735_Help/Xml.hs, interpreted )\r\n*** Core Lint errors : in result of Tidy Core ***\r\n{-# LINE 122 \"T1735_Help/Xml.hs #-}:\r\n [RHS of T1735_Help.Xml.typeNotValue :: forall a_a1NJ.\r\n T1735_Help.Xml.Xml a_a1NJ =>\r\n a_a1NJ -> a_a1NJ]\r\n Demand type has 2 arguments, rhs has 1 arguments, T1735_Help.Xml.typeNotValue\r\n Binder's strictness signature: DmdType TTb\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.0.1Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/4394IPRun failure2021-11-02T09:27:32ZSimon MarlowIPRun failuretypecheck/should_run/IPRun is currently failing all ways:
```
=====> IPRun(normal) 1973 of 2622 [0, 24, 0]
cd ./typecheck/should_run && '/64playpen/simonmar/nightly/HEAD-cam-04-unx/x86_64-unknown-linux/inplace/bin/ghc-stage2' -fforce-re...typecheck/should_run/IPRun is currently failing all ways:
```
=====> IPRun(normal) 1973 of 2622 [0, 24, 0]
cd ./typecheck/should_run && '/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 -o IPRun IPRun.hs >IPRun.comp.stderr 2>&1
Compile failed (status 256) errors were:
[1 of 1] Compiling Main ( IPRun.hs, IPRun.o )
IPRun.hs:13:18:
Ambiguous type variable `a' in the constraint:
(Num a) arising from the literal `5'
Probable fix: add a type signature that fixes these type variable(s)
In the expression: 5
In the expression: let ?x = 5 in \ () -> ?x
In an equation for `f2': f2 () = let ?x = 5 in \ () -> ?x
IPRun.hs:24:13:
Ambiguous type variable `a1' in the constraint:
(Show a1) arising from a use of `print'
Probable fix: add a type signature that fixes these type variable(s)
In a stmt of a 'do' expression: print (f2 () ())
In the expression:
do { print (f0 ());
print (f1 ());
print (f2 () ());
print (f3 ()) }
In the expression:
let ?x = 0
in
do { print (f0 ());
print (f1 ());
print (f2 () ());
.... }
*** unexpected failure for IPRun(normal)
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.12.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":"IPRun failure","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.12.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"typecheck/should_run/IPRun is currently failing all ways:\r\n\r\n{{{\r\n=====> IPRun(normal) 1973 of 2622 [0, 24, 0]\r\ncd ./typecheck/should_run && '/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 -o IPRun IPRun.hs >IPRun.comp.stderr 2>&1\r\nCompile failed (status 256) errors were:\r\n[1 of 1] Compiling Main ( IPRun.hs, IPRun.o )\r\n\r\nIPRun.hs:13:18:\r\n Ambiguous type variable `a' in the constraint:\r\n (Num a) arising from the literal `5'\r\n Probable fix: add a type signature that fixes these type variable(s)\r\n In the expression: 5\r\n In the expression: let ?x = 5 in \\ () -> ?x\r\n In an equation for `f2': f2 () = let ?x = 5 in \\ () -> ?x\r\n\r\nIPRun.hs:24:13:\r\n Ambiguous type variable `a1' in the constraint:\r\n (Show a1) arising from a use of `print'\r\n Probable fix: add a type signature that fixes these type variable(s)\r\n In a stmt of a 'do' expression: print (f2 () ())\r\n In the expression:\r\n do { print (f0 ());\r\n print (f1 ());\r\n print (f2 () ());\r\n print (f3 ()) }\r\n In the expression:\r\n let ?x = 0\r\n in\r\n do { print (f0 ());\r\n print (f1 ());\r\n print (f2 () ());\r\n .... }\r\n\r\n*** unexpected failure for IPRun(normal)\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/4392tcrun020 failure2019-07-07T18:59:13ZSimon Marlowtcrun020 failure```
tcrun020 is currently failing all ways:
=====> tcrun020(normal) 1947 of 2622 [0, 12, 0]
cd ./typecheck/should_run && '/64playpen/simonmar/nightly/HEAD-cam-04-unx/x86_64-unknown-linux/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lin...```
tcrun020 is currently failing all ways:
=====> tcrun020(normal) 1947 of 2622 [0, 12, 0]
cd ./typecheck/should_run && '/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 -o tcrun020 tcrun020.hs >tcrun020.comp.stderr 2>&1
Compile failed (status 256) errors were:
[1 of 1] Compiling Main ( tcrun020.hs, tcrun020.o )
tcrun020.hs:15:21:
Illegal instance declaration for `C1 m Bool'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are type *variables*,
and each type variable appears at most once in the instance head.
Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `C1 m Bool'
*** unexpected failure for tcrun020(normal)
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.12.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":"tcrun020 failure","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.12.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\ntcrun020 is currently failing all ways:\r\n\r\n=====> tcrun020(normal) 1947 of 2622 [0, 12, 0]\r\ncd ./typecheck/should_run && '/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 -o tcrun020 tcrun020.hs >tcrun020.comp.stderr 2>&1\r\nCompile failed (status 256) errors were:\r\n[1 of 1] Compiling Main ( tcrun020.hs, tcrun020.o )\r\n\r\ntcrun020.hs:15:21:\r\n Illegal instance declaration for `C1 m Bool'\r\n (All instance types must be of the form (T a1 ... an)\r\n where a1 ... an are type *variables*,\r\n and each type variable appears at most once in the instance head.\r\n Use -XFlexibleInstances if you want to disable this.)\r\n In the instance declaration for `C1 m Bool'\r\n\r\n*** unexpected failure for tcrun020(normal)\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/4385Type-level natural numbers2019-07-07T18:59:14ZIavor S. DiatchkiType-level natural numbersNatural numbers at the type-level have many uses, especially in contexts where programmers need to manipulate data with statically known sizes. A simple form of this feature has been present in many programming languages for a long time ...Natural numbers at the type-level have many uses, especially in contexts where programmers need to manipulate data with statically known sizes. A simple form of this feature has been present in many programming languages for a long time (e.g., sub-range types in Pascal, array type in C, etc.). The feature is particularly useful when combined with polymorphism as illustrated by more recent programming languages (e.g., Cyclone, BlueSpec, Cryptol, Habit).
Existing features of Haskell's type system---such as polymorphism, kinds, and qualified types---make it particularly suitable for adding support for type level naturals in a natural way!
Indeed, there are quite a few Haskell libraries available on Hackage that implement support for type-level numbers in various forms. These libraries are being used by other packages and projects (e.g., the Kansas Lava project, and the type-safe bindings to the LLVM library).
Supporting natural number types directly in the compiler would help these projects, and others, by improving on the existing libraries in the following ways:
- a standard implementation,
- a better notation,
- better error messages,
- a more efficient implementation,
- more complete support for numeric operations.
I have started on an implementation of this feature, and my GHC branch is available in a darcs repository at the following URL:
```
http://code.galois.com/darcs/ghc-type-naturals/
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | |
| 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":"Type-level natural numbers","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"diatchki"},"version":"","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"Natural numbers at the type-level have many uses, especially in contexts where programmers need to manipulate data with statically known sizes. A simple form of this feature has been present in many programming languages for a long time (e.g., sub-range types in Pascal, array type in C, etc.). The feature is particularly useful when combined with polymorphism as illustrated by more recent programming languages (e.g., Cyclone, BlueSpec, Cryptol, Habit).\r\n\r\nExisting features of Haskell's type system---such as polymorphism, kinds, and qualified types---make it particularly suitable for adding support for type level naturals in a natural way!\r\n\r\nIndeed, there are quite a few Haskell libraries available on Hackage that implement support for type-level numbers in various forms. These libraries are being used by other packages and projects (e.g., the Kansas Lava project, and the type-safe bindings to the LLVM library).\r\n\r\nSupporting natural number types directly in the compiler would help these projects, and others, by improving on the existing libraries in the following ways:\r\n * a standard implementation,\r\n * a better notation,\r\n * better error messages,\r\n * a more efficient implementation,\r\n * more complete support for numeric operations.\r\n\r\nI have started on an implementation of this feature, and my GHC branch is available in a darcs repository at the following URL:\r\n{{{\r\nhttp://code.galois.com/darcs/ghc-type-naturals/\r\n}}}\r\n\r\n\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1Iavor S. DiatchkiIavor S. Diatchkihttps://gitlab.haskell.org/ghc/ghc/-/issues/4364Template Haskell: Cycle in type synonym declarations2019-07-07T18:59:20ZIan Lynagh <igloo@earth.li>Template Haskell: Cycle in type synonym declarations`type-level-numbers-0.1` doesn't build with 7.0.1 RC 1. Here's the essence:
```
{-# LANGUAGE TemplateHaskell #-}
module Q where
data Z
type N0 = $( [t| Z |] )
type N1 = $( [t| Z |] )
```
```
$ ghc --make m.hs
[1 of 1] Compiling Q ...`type-level-numbers-0.1` doesn't build with 7.0.1 RC 1. Here's the essence:
```
{-# LANGUAGE TemplateHaskell #-}
module Q where
data Z
type N0 = $( [t| Z |] )
type N1 = $( [t| Z |] )
```
```
$ ghc --make m.hs
[1 of 1] Compiling Q ( m.hs, m.o )
m.hs:7:1:
Cycle in type synonym declarations:
m.hs:7:1-23: type N0 = $([t| Z |])
m.hs:8:1-23: type N1 = $([t| Z |])
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.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":"Template Haskell: Cycle in type synonym declarations","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.1","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"simonpj"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"`type-level-numbers-0.1` doesn't build with 7.0.1 RC 1. Here's the essence:\r\n\r\n{{{\r\n{-# LANGUAGE TemplateHaskell #-}\r\nmodule Q where\r\n\r\ndata Z\r\n\r\ntype N0 = $( [t| Z |] )\r\ntype N1 = $( [t| Z |] )\r\n}}}\r\n\r\n{{{\r\n$ ghc --make m.hs\r\n[1 of 1] Compiling Q ( m.hs, m.o )\r\n\r\nm.hs:7:1:\r\n Cycle in type synonym declarations:\r\n m.hs:7:1-23: type N0 = $([t| Z |])\r\n m.hs:8:1-23: type N1 = $([t| Z |])\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.8.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/4361Typechecker regression2019-07-07T18:59:21ZIan Lynagh <igloo@earth.li>Typechecker regressionHere's the essence of the regression DoCon showed up, reported here:
http://www.haskell.org/pipermail/glasgow-haskell-bugs/2010-September/025511.html
```
{-# LANGUAGE FlexibleContexts #-}
module Pol3_ (moduloBasisx) where
class Commut...Here's the essence of the regression DoCon showed up, reported here:
http://www.haskell.org/pipermail/glasgow-haskell-bugs/2010-September/025511.html
```
{-# LANGUAGE FlexibleContexts #-}
module Pol3_ (moduloBasisx) where
class CommutativeRing a
class CommutativeRing a => LinSolvRing a
class LinSolvRing a => EuclideanRing a
instance EuclideanRing a => LinSolvRing (Pol a)
instance CommutativeRing a => CommutativeRing (Pol a)
data Pol a = MkPol
upLinSolvRing :: LinSolvRing a => a -> ()
upLinSolvRing = undefined
moduloBasisx :: (LinSolvRing (Pol a), CommutativeRing a) => Pol a -> ()
moduloBasisx p = let x = upLinSolvRing p
in ()
```
```
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.2
$ ghc --make Pol3_
[1 of 1] Compiling Pol3_ ( Pol3_.hs, Pol3_.o )
$
```
```
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.0.20100924
$ ghc --make Pol3_
[1 of 1] Compiling Pol3_ ( Pol3_.hs, Pol3_.o )
Pol3_.hs:19:26:
Could not deduce (EuclideanRing a)
from the context (LinSolvRing (Pol a), CommutativeRing a)
arising from a use of `upLinSolvRing'
Possible fix:
add (EuclideanRing a) to the context of
the type signature for `moduloBasisx'
In the expression: upLinSolvRing p
In an equation for `x': x = upLinSolvRing p
In the expression: let x = upLinSolvRing p in ()
$
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.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 regression","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"7.0.1","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"simonpj"},"version":"7.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here's the essence of the regression DoCon showed up, reported here:\r\nhttp://www.haskell.org/pipermail/glasgow-haskell-bugs/2010-September/025511.html\r\n\r\n{{{\r\n{-# LANGUAGE FlexibleContexts #-}\r\n\r\nmodule Pol3_ (moduloBasisx) where\r\n\r\nclass CommutativeRing a\r\nclass CommutativeRing a => LinSolvRing a\r\nclass LinSolvRing a => EuclideanRing a\r\n\r\ninstance EuclideanRing a => LinSolvRing (Pol a)\r\ninstance CommutativeRing a => CommutativeRing (Pol a)\r\n\r\ndata Pol a = MkPol\r\n\r\nupLinSolvRing :: LinSolvRing a => a -> ()\r\nupLinSolvRing = undefined\r\n\r\nmoduloBasisx :: (LinSolvRing (Pol a), CommutativeRing a) => Pol a -> ()\r\nmoduloBasisx p = let x = upLinSolvRing p\r\n in ()\r\n}}}\r\n\r\n{{{\r\n$ ghc --version\r\nThe Glorious Glasgow Haskell Compilation System, version 6.12.2\r\n$ ghc --make Pol3_\r\n[1 of 1] Compiling Pol3_ ( Pol3_.hs, Pol3_.o )\r\n$\r\n}}}\r\n\r\n{{{\r\n$ ghc --version\r\nThe Glorious Glasgow Haskell Compilation System, version 7.0.0.20100924\r\n$ ghc --make Pol3_\r\n[1 of 1] Compiling Pol3_ ( Pol3_.hs, Pol3_.o )\r\n\r\nPol3_.hs:19:26:\r\n Could not deduce (EuclideanRing a)\r\n from the context (LinSolvRing (Pol a), CommutativeRing a)\r\n arising from a use of `upLinSolvRing'\r\n Possible fix:\r\n add (EuclideanRing a) to the context of\r\n the type signature for `moduloBasisx'\r\n In the expression: upLinSolvRing p\r\n In an equation for `x': x = upLinSolvRing p\r\n In the expression: let x = upLinSolvRing p in ()\r\n$\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.0.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/4358infinite loop on unification with a type family context2019-07-07T18:59:21Zpatrick_premontinfinite loop on unification with a type family contextThe following throws ghc (and ghci) in a loop (ghc-7.0.0.20100925 for i386-unknown-mingw32)
and it eventually aborts with "ghc.exe: out of memory".
```
> {-# LANGUAGE TypeFamilies, Rank2Types, FlexibleContexts #-}
> type family T a
> ...The following throws ghc (and ghci) in a loop (ghc-7.0.0.20100925 for i386-unknown-mingw32)
and it eventually aborts with "ghc.exe: out of memory".
```
> {-# LANGUAGE TypeFamilies, Rank2Types, FlexibleContexts #-}
> type family T a
> t2 :: forall a. ((T a ~ a) => a) -> a
> t2 = t
> t :: forall a. ((T a ~ a) => a) -> a
> t = undefined
```
Using ghc 6.12.1 we do not get a loop, but a puzzling error:
typeBug.lhs:9:7:
Couldn't match expected type `(T a ~ a) => a'
against inferred type `(T a \~ a) =\> a'
Expected type: (T a \~ a) =\> a
Inferred type: (T a \~ a) =\> a
In the expression: t
> In the definition of \`t2': t2 = t
I presume that the non-injectivity of type family T triggers the problem however
the following produces no errors in either version of the compiler.
```
> ok2 :: forall a. T a -> a
> ok2 = ok
> ok :: forall a. T a -> a
> ok = undefined
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 6.12.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":"infinite loop on unification with a type family context","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.12.1","keywords":["context","family","infinite","loop","type"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following throws ghc (and ghci) in a loop (ghc-7.0.0.20100925 for i386-unknown-mingw32)\r\nand it eventually aborts with \"ghc.exe: out of memory\".\r\n\r\n{{{\r\n\r\n> {-# LANGUAGE TypeFamilies, Rank2Types, FlexibleContexts #-}\r\n\r\n> type family T a\r\n\r\n> t2 :: forall a. ((T a ~ a) => a) -> a\r\n> t2 = t\r\n \r\n> t :: forall a. ((T a ~ a) => a) -> a\r\n> t = undefined\r\n\r\n}}}\r\n\r\nUsing ghc 6.12.1 we do not get a loop, but a puzzling error:\r\n\r\ntypeBug.lhs:9:7:\r\n Couldn't match expected type `(T a ~ a) => a'\r\n against inferred type `(T a ~ a) => a'\r\n Expected type: (T a ~ a) => a\r\n Inferred type: (T a ~ a) => a\r\n In the expression: t\r\n In the definition of `t2': t2 = t\r\n\r\nI presume that the non-injectivity of type family T triggers the problem however\r\nthe following produces no errors in either version of the compiler.\r\n\r\n{{{\r\n\r\n> ok2 :: forall a. T a -> a\r\n> ok2 = ok\r\n \r\n> ok :: forall a. T a -> a\r\n> ok = undefined\r\n\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/4356type instance doesn't work when the type is (->)2019-07-07T18:59:22ZSjoerd Visschertype instance doesn't work when the type is (->)This doesn't work in 7.0.0.20100924.
It works fine in 6.12.3.
```
{-# LANGUAGE TypeFamilies #-}
type family T t :: * -> * -> *
type instance T Bool = (->)
f :: T Bool Bool Bool
f = not
```
This is the error:
```
Couldn't match typ...This doesn't work in 7.0.0.20100924.
It works fine in 6.12.3.
```
{-# LANGUAGE TypeFamilies #-}
type family T t :: * -> * -> *
type instance T Bool = (->)
f :: T Bool Bool Bool
f = not
```
This is the error:
```
Couldn't match type `T Bool' with `(->)'
Expected type: T Bool Bool Bool
Actual type: Bool -> Bool
In the expression: not
In an equation for `f': f = not
```7.0.1Simon Peyton JonesSimon Peyton Jones