问题
我的代码包括一个名为 Tests 的模块,它定义了以下内容:
broken :: SetRBT Int
broken = insertRBT 1 $ emptySetRBT (<)
我可以broken
在 REPL 中进行评估:
All> broken
RedBlackTree.RedBlackTree (_impl#==#Prelude.Eq#Prelude.Int) (_impl#==#Prelude.Eq#Prelude.Int) (_def#<#Prelude.Ord (_inst#Prelude.Ord#Prelude.Int)) (RedBlackTree.Tree RedBlackTree.Black 1 RedBlackTree.Empty RedBlackTree.Empty)
All>
但是,我无法评估broken
' 的定义的 RHS:
All> insertRBT 1 $ emptySetRBT (<)
PAKCS_Main_Exp.curry, line 3.18: Error:
Undefined type RedBlackTree.RedBlackTree
ERROR occurred during parsing!
All>
或者我相信,直到我尝试附加类型签名:
All> insertRBT 1 $ emptySetRBT (<) :: SetRBT Int
RedBlackTree.RedBlackTree (_impl#==#Prelude.Eq#Prelude.Int) (_impl#==#Prelude.Eq#Prelude.Int) (_def#<#Prelude.Ord (_inst#Prelude.Ord#Prelude.Int)) (RedBlackTree.Tree RedBlackTree.Black 1 RedBlackTree.Empty RedBlackTree.Empty)
All>
我可以在需要时附加类型签名,或者更一般地说,执行错误消息建议我应该执行的任何操作。但是我怎么知道将上述错误消息解释为“您必须附加类型签名”?更一般地说,鉴于(见下文)加载了 RedBlackTree,该类型错误甚至意味着什么?
我正在加载的内容
每次我启动 PAKCS 时,我都会运行:l All
. 加载一个模块,该模块在相关部分读取,
module All ( module M
) where
import FiniteMap as M
import SetRBT as M
import RedBlackTree as M
import Tests as M
这个成语让我可以加载所有我需要的东西(还有其他东西),而不会产生很长的提示。
如果我运行:modules
它看起来应该定义 RedBlackTree:
All> :modules
Currently loaded modules:
All (loaded from ./.curry/pakcs/All.pl)
Prelude (loaded from /home/jeff/logic/curry/install/pakcs-2.0.2/lib/.curry/pakcs/Prelude.pl)
FiniteMap (loaded from /home/jeff/logic/curry/install/pakcs-2.0.2/lib/.curry/pakcs/FiniteMap.pl)
SetRBT (loaded from /home/jeff/logic/curry/install/pakcs-2.0.2/lib/.curry/pakcs/SetRBT.pl)
RedBlackTree (loaded from /home/jeff/logic/curry/install/pakcs-2.0.2/lib/.curry/pakcs/RedBlackTree.pl)
Tests (loaded from ./.curry/pakcs/Tests.pl)
All>