1

当我尝试从http://michaeldadams.org/papers/scrap_your_zippers/ScrapYourZippers.hs编译代码时,我得到:

ScrapYourZipper.hs:249:15: Not in scope: type variable ‘hole’   
ScrapYourZipper.hs:251:27: Not in scope: type variable ‘root’
ScrapYourZipper.hs:252:20: Not in scope: type variable ‘hole’ 
ScrapYourZipper.hs:252:25: Not in scope: type variable ‘root’

发生这种情况的代码部分:

245    data Context hole root where
246    CtxtNull :: Context a a
247    CtxtCons ::
248      forall rights parent. (Data parent) =>
249        Left (hole -> rights)
250        -> Right rights parent
251        -> Context parent root
252        -> Context hole root

有什么想法/指示出了什么问题?

PS:抱歉帖子命名不好,想不出有意义的东西。

4

2 回答 2

4

我将该数据声明替换为:

data Context hole root where
    CtxtNull :: Context a a
    CtxtCons :: (Data parent) => Left (hole -> rights) -> Right rights parent -> Context parent root -> Context hole root

(即只是删除forall子句)并编译。

于 2015-01-08T07:05:32.173 回答
0

第 248 行应该是

forall rights parent root hole. (Data parent) =>

在旧版本中,GHC 可能在这里更宽容......

于 2015-01-08T07:06:55.753 回答