Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coercible with GHC 7.10

Tags:

haskell

ghc

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?

like image 666
crockeea Avatar asked May 18 '15 00:05

crockeea


1 Answers

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).

like image 149
Bakuriu Avatar answered Jan 04 '23 02:01

Bakuriu