GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:33:08Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/10899Polytype accepted in RHS of default associated type2019-07-07T18:33:08ZRichard Eisenbergrae@richarde.devPolytype accepted in RHS of default associated typeThis hogwash is accepted:
```
class C a where
type F a
type F a = forall m. m a
```
I will fix.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Versi...This hogwash is accepted:
```
class C a where
type F a
type F a = forall m. m a
```
I will fix.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.10.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Polytype accepted in RHS of default associated type","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"7.10.3","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"7.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This hogwash is accepted:\r\n\r\n{{{\r\nclass C a where\r\n type F a\r\n type F a = forall m. m a\r\n}}}\r\n\r\nI will fix.","type_of_failure":"OtherFailure","blocking":[]} -->7.10.3Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/10715Possible regression in Coercible a (X a) between 7.8 and 7.102019-07-07T18:34:24ZinakiPossible regression in Coercible a (X a) between 7.8 and 7.10In upgrading to7.10, code of the form
```hs
{-# LANGUAGE FlexibleContexts #-}
import Data.Coerce (coerce, Coercible)
data X a
doCoerce :: Coercible a (X a) => a -> X a
doCoerce = coerce
```
fails to compile in 7.10.1 and 7.10.2 with ...In upgrading to7.10, code of the form
```hs
{-# LANGUAGE FlexibleContexts #-}
import Data.Coerce (coerce, Coercible)
data X a
doCoerce :: Coercible a (X a) => a -> X a
doCoerce = coerce
```
fails to compile in 7.10.1 and 7.10.2 with the error
```
testCoerce.hs:6:13:
Could not deduce (a ~ X a)
from the context (Coercible a (X a))
bound by the type signature for
doCoerce :: Coercible a (X a) => a -> X a
at testCoerce.hs:6:13-41
‘a’ is a rigid type variable bound by
the type signature for doCoerce :: Coercible a (X a) => a -> X a
at testCoerce.hs:6:13
Relevant role signatures: type role X phantom
In the ambiguity check for the type signature for ‘doCoerce’:
doCoerce :: forall a. Coercible a (X a) => a -> X a
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘doCoerce’:
doCoerce :: Coercible a (X a) => a -> X a
```
while it works in 7.8.4.
Surprisingly (to me at least), the code works in 7.10.1 and 7.10.2 if I change it to
```hs
{-# LANGUAGE FlexibleContexts #-}
import Data.Coerce (coerce, Coercible)
data X a
doCoerce :: Coercible a (X b) => a -> X a
doCoerce = coerce
```
while it fails to compile in 7.8.4 with the error
```
testCoerce.hs:6:13:
Could not coerce from ‘a’ to ‘X b0’
because ‘a’ and ‘X b0’ are different types.
arising from the ambiguity check for ‘doCoerce’
from the context (Coercible a (X b))
bound by the type signature for
doCoerce :: Coercible a (X b) => a -> X a
at testCoerce.hs:6:13-41
The type variable ‘b0’ is ambiguous
In the ambiguity check for:
forall a b. Coercible a (X b) => a -> X a
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘doCoerce’:
doCoerce :: Coercible a (X b) => a -> X a
```
The coercion pattern may look a bit funny, but it is rather useful when one has newtypes of the form
```hs
newtype Y = Y (ForeignPtr Y)
```
which appear naturally when writing bindings to C libraries, and one wants to get access to the underlying ForeignPtr from Y (here X is ForeignPtr). The relevant Coercible instance here is Coercible Y (ForeignPtr Y), as above.
I would have expected the version with context "Coercible a (X a)" to be accepted, as 7.8.4 does, since it seems to be a specialization of the more general coerce, but maybe I am missing something?7.10.3Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/10713Type family not reducing over data family2019-07-07T18:34:28ZacowleyType family not reducing over data familyGiven this code,
```
type family TEq t s where
TEq t t = 'True
TEq t s = 'False
data family T a
```
I expected this GHCi interaction to reduce:
`:kind! TEq (T Int) (T Bool)`
But it does not. It does reduce (to `'True`) if you inst...Given this code,
```
type family TEq t s where
TEq t t = 'True
TEq t s = 'False
data family T a
```
I expected this GHCi interaction to reduce:
`:kind! TEq (T Int) (T Bool)`
But it does not. It does reduce (to `'True`) if you instead ask,
`:kind! TEq (T Int) (T Int)`
Tested on GHC 7.10.2
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.10.2 |
| 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 family not reducing over data family","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Given this code,\r\n\r\n{{{\r\ntype family TEq t s where\r\n TEq t t = 'True\r\n TEq t s = 'False\r\ndata family T a\r\n}}}\r\n\r\nI expected this GHCi interaction to reduce:\r\n`:kind! TEq (T Int) (T Bool)`\r\n\r\nBut it does not. It does reduce (to `'True`) if you instead ask,\r\n\r\n`:kind! TEq (T Int) (T Int)`\r\n\r\nTested on GHC 7.10.2\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.10.3Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/10495Poor error message for Coercible constraint unsatisfiability2019-07-07T18:35:40ZRichard Eisenbergrae@richarde.devPoor error message for Coercible constraint unsatisfiabilityIf I say
```
import Data.Coerce
foo = coerce
```
I get
```
Couldn't match representation of type ‘a0’ with that of ‘b0’
‘a0’ is untouchable
inside the constraints: ()
bound by the inferred type of foo :: a0 ...If I say
```
import Data.Coerce
foo = coerce
```
I get
```
Couldn't match representation of type ‘a0’ with that of ‘b0’
‘a0’ is untouchable
inside the constraints: ()
bound by the inferred type of foo :: a0 -> b0
at /Users/rae/temp/bug/App.hs:3:1-12
Relevant bindings include
foo :: a0 -> b0 (bound at /Users/rae/temp/bug/App.hs:3:1)
In the expression: coerce
In an equation for ‘foo’: foo = coerce
```
How awful. Eta-expanding `foo` works fine, though.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Total inability to infer type for coerce","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"7.11","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If I say\r\n\r\n{{{\r\nimport Data.Coerce\r\n\r\nfoo = coerce\r\n}}}\r\n\r\nI get\r\n\r\n{{{\r\n Couldn't match representation of type ‘a0’ with that of ‘b0’\r\n ‘a0’ is untouchable\r\n inside the constraints: ()\r\n bound by the inferred type of foo :: a0 -> b0\r\n at /Users/rae/temp/bug/App.hs:3:1-12\r\n Relevant bindings include\r\n foo :: a0 -> b0 (bound at /Users/rae/temp/bug/App.hs:3:1)\r\n In the expression: coerce\r\n In an equation for ‘foo’: foo = coerce\r\n}}}\r\n\r\nHow awful. Eta-expanding `foo` works fine, though.","type_of_failure":"OtherFailure","blocking":[]} -->7.10.3Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.dev