Haskell- 没有因使用“null”而产生的 (Foldable ((->) [Type]) 实例
Haskell- No instance for (Foldable ((->) [Type]) arising from a use of ‘null’
我有以下错误,请记住 "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 不是关键问题。
感谢您的帮助,如果您需要其他规格,请告诉我。
由于 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
我有以下错误,请记住 "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 不是关键问题。 感谢您的帮助,如果您需要其他规格,请告诉我。
由于 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