我有以下错误,请记住“Booleano”对应于用户定义类型。
Prop.hs:173:28: error:
• No instance for (Foldable ((->) [Booleano]))
arising from a use of ‘null’
• In the first argument of ‘(==)’, namely ‘(null aux2)’
In the expression: ((null aux2) == True)
In the expression:
if ((null aux2) == True) then Falso else Verdadero
Prop.hs:184:16: error:
• No instance for (Eq Booleano) arising from a use of ‘==’
• In the expression: x == Falso
In an equation for ‘comparador2’: comparador2 x = x == Falso*
我正在使用此代码:
type Estados = [(String,Booleano)]
esTautologia :: Prop -> [Estados] -> Booleano
esTautologia p est = if (null aux2 == True ) then
Falso
else
Verdadero
aux :: Prop -> [Estados] -> [Booleano]
aux p est= map (interp p) est
aux2:: [Booleano] -> [Booleano]
aux2= filter comparador2 aux
comparador2:: Booleano -> Bool
comparador2 x= x == Falso
类型Prop用于制作逻辑参数,因此,Prop不是关键问题。 感谢您的帮助,如果您需要另外的说明,请告诉我。
答案 0 :(得分:0)
由于filter
的类型为(a -> Bool) -> [a] -> [a]
,因此aux2
的定义看起来很奇怪。 filter
的第二个参数是一个简单的列表,而不是函数(在您的情况下为aux
)。您需要更多aux
参数或跳过aux
才能获得正确的类型:
aux2 :: Prop -> [Estados] -> [Booleano]
aux2 a b = filter comparador2 (aux a b)
aux2 :: [Booleano] -> [Booleano]
aux2 = filter comparador2