Search code examples
haskelluser-defined-types

Haskell- No instance for (Foldable ((->) [Type]) arising from a use of ‘null’


I have the following error, kept in mind that "Booleano" corresponds to an user-define type.

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*

Im working with this code:

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

The type Prop it's for making logic arguments, so, Prop isn't a key problem. Thanks for the help, if you need another especification, please tell me.


Solution

  • Since filter has type (a -> Bool) -> [a] -> [a] your definition for aux2 looks weird. The second argument to filter is a simple list, not a function (aux in your case). You either need more arguments to aux or skip aux to get the types right:

    aux2 :: Prop -> [Estados] -> [Booleano]
    aux2 a b = filter comparador2 (aux a b)
    
    
    aux2 :: [Booleano] -> [Booleano]
    aux2 = filter comparador2