I was trying to make a function that compares a given item with a list and if the item is on the list it returns a Boolean.
when compiling it, it throws this error at me and I do not understand what it refers to. I would appreciate your help ...
Occurs check: cannot construct the infinite type: a ~ [a] • In the second argument of ‘(/=)’, namely ‘xs’ In the second argument of ‘(&&)’, namely ‘n /= xs’ In the expression: n /= x && n /= xs • Relevant bindings include n :: a (bound at Listas.hs:22:17) xs :: [a] (bound at Listas.hs:22:13) x :: a (bound at Listas.hs:22:11) elemento :: [a] -> a -> Bool (bound at Listas.hs:21:1) | 22 | elemento (x:xs) n = if n /= x && n /= xs then False else True
this is the code:
elemento :: (Eq a) => [a] -> a -> Bool elemento  a = error "no hay elementos en la lista" elemento (x:xs) n = if n /= x && n /= xs then False else True