【发布时间】:2011-12-01 03:13:17
【问题描述】:
如果有人可以通过编译 monadiccp 帮助我研究这个问题,我将不胜感激。有一个我无法理解的打字问题。
重现步骤
- 安装了最新版本的 ghc;我有 7.0.3
cabal install Monatroncabal unpack monadiccpghci Control/CP/ComposableTransformers.hs
我收到此错误,
Control/CP/ComposableTransformers.hs:246:31:
Couldn't match expected type `Tree solver0 a1 -> Tree solver0 a1'
with actual type `forall a2. Tree solver a2 -> Tree solver a2'
Expected type: Tree solver0 a1 -> Tree solver0 a1
Actual type: Bound solver
In the second argument of `BBP', namely `bound''
In the second argument of `($)', namely `BBP (v + 1) bound''
Failed, modules loaded: Control.CP.Transformers, Control.CP.SearchTree, Control.CP.Solver, Control.CP.Queue, Control.CP.Debug, Control.CP.PriorityQueue, Control.Mixin.Mixin.
这是一个奇怪的观察。如果有人更改有问题的行,
continue $ BBP (v + 1) bound'
具有错误中给定类型的特征,
continue $ BBP (v + 1) (undefined :: Tree solver0 a1 -> Tree solver0 a1)
那么它可以工作,但是如果引入一个虚拟变量,
let x = (undefined :: Tree solver0 a1 -> Tree solver0 a1)
continue $ BBP (v + 1) x
类型错误变得更加难以理解(我可能需要正式学习打字),
Control/CP/ComposableTransformers.hs:247:19:
Couldn't match type `a10' with `a1'
because type variable `a1' would escape its scope
This (rigid, skolem) type variable is bound by
a type expected by the context: Tree solver a1 -> Tree solver a1
The following variables have types that mention a10
x :: Tree solver a10 -> Tree solver a10
(bound at Control/CP/ComposableTransformers.hs:246:12)
In the second argument of `BBP', namely `x'
In the second argument of `($)', namely `BBP (v + 1) x'
In the expression: continue $ BBP (v + 1) x
我们将不胜感激任何对这种情况的了解(包括解决问题)。不久前我向开发者发送了一封电子邮件,但他没有回复。
【问题讨论】:
标签: generics haskell types typeerror