The following code works in GHC 7.8.4:
import Data.Coerce
coerceNewtype :: (Coercible (o r) (n m' r)) => [o r] -> [n m' r]
coerceNewtype = coerce
but in 7.10 I get 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
I'm not quite sure where the magic happens in Data.Coerce
, but given that coerce
has the signature (Coercible a b) => a -> b
, I think the function above should still compile in 7.10. Any ideas why the behavior is different, or how I can get use coercible with polymorphic types in 7.10?
There's nothing wrong with your code.
The error is due to a bug in the type-checker. The issue tracker says this will be fixed in GHC 7.11.
Posting simply to provide an answer, since the original author doesn't post one. Feel free to add details if you wish (and are able).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With