简体   繁体   English

可与GHC 7.10一起强制执行

[英]Coercible with GHC 7.10

The following code works in GHC 7.8.4: 以下代码适用于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: 但在7.10我收到错误:

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 ab) => a -> b , I think the function above should still compile in 7.10. 我不太确定Data.Coerce中的魔法发生在Data.Coerce ,但鉴于coerce有签名(Coercible ab) => a -> b ,我认为上面的函数仍然应该在7.10中编译。 Any ideas why the behavior is different, or how I can get use coercible with polymorphic types in 7.10? 任何想法为什么行为不同,或者如何在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. 问题跟踪器表示这将在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). 如果您愿意(并且能够),请随意添加详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM