Il seguente codice funziona in GHC 7.8.4:Coercible con GHC 7.10
import Data.Coerce
coerceNewtype :: (Coercible (o r) (n m' r)) => [o r] -> [n m' r]
coerceNewtype = coerce
ma in 7.10 ottengo l'errore:
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
Io non sono abbastanza sicuro dove la magia accade in Data.Coerce
, ma dato che coerce
ha la firma (Coercible a b) => a -> b
, penso che la funzione sopra riportata debba ancora essere compilata in 7.10. Qualche idea per cui il comportamento è diverso, o come posso usare coercible con i tipi polimorfici in 7.10?
Modificare la segnatura del tipo a '(Coercible a b, a ~ (o r), b ~ (n m 'r)) => [o r] -> [n m' r]' e l'errore scompare. Questo è su ghc-7.10.1. Questo mi sembra un insetto. – user2407038
Hrm, sembrava troppo semplice per essere un bug. Segnalato [qui] (https://ghc.haskell.org/trac/ghc/ticket/10428) – crockeea
Uno di voi potrebbe trasformare questi commenti in una risposta in modo che la domanda non venga visualizzata come non risposta? @ user2407038 –