[英]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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.