GHC cannot match representations using Coercible constraint
The following code compiles in 7.8.4 but fails in 7.10.1:
import Data.Coerce
coerceNewtype :: (Coercible (o r) (n m' r)) => [o r] -> [n m' r]
coerceNewtype = coerce
with the error
Couldn't match representation of type ‘n m' r’ with that of ‘o r’
arising from trying to show that the representations of
‘[o r]’ and
‘[n m' r]’ are the same
Relevant role signatures: type role [] representational
However, the following compiles:
{-# LANGUAGE TypeFamilies #-}
import Data.Coerce
coerceNewtype :: (Coercible a b, a ~ (o r), b ~ (n m' r)) => [o r] -> [n m' r]
coerceNewtype = coerce
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |