我有一个看起来像这样的模块:
module Network where
import Prelude hiding ((==))
import Sort
import Message
data Pair = Conn Loc Loc | Disconn Loc Loc deriving(Show,Eq)
data NC = EmpNC | Inn Pair NC
instance Eq NC where
EmpNC == EmpNC = True
(Inn p nc1) == nc2 = (nc_include p nc2) && (nc1 == nc2)
_ == _ = False
nc_include::Pair->NC->Bool
nc_include p EmpNC = False
nc_include p1 (Inn p2 nc) = (p1 == p2) || (nc_include p1 nc)
奇怪的是,对于我说的最后一行(p1 == p2) ,我无法将预期类型 NC 与实际类型对错误匹配。这意味着 p1 应该是 NC 而不是 Pair。我不知道,你能帮忙吗? [编辑] 隐藏(==)形式的前奏是因为无论我有“==”运算符,我都会遇到歧义错误。如果您也为此提出更好的解决方案,我将不胜感激:D