繁体   English   中英

可与GHC 7.10一起强制执行

[英]Coercible with GHC 7.10

以下代码适用于GHC 7.8.4:

import Data.Coerce
coerceNewtype :: (Coercible (o r) (n m' r)) => [o r] -> [n m' r]
coerceNewtype = coerce

但在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

我不太确定Data.Coerce中的魔法发生在Data.Coerce ,但鉴于coerce有签名(Coercible ab) => a -> b ,我认为上面的函数仍然应该在7.10中编译。 任何想法为什么行为不同,或者如何在7.10中使用多态类型强制使用?

您的代码没有任何问题。

该错误是由于类型检查器中的错误 问题跟踪器表示这将在GHC 7.11中修复。


发布只是为了提供答案,因为原作者没有发布一个。 如果您愿意(并且能够),请随意添加详细信息。

暂无
暂无

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

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