I need to return for example either an integer or a Boolean in a recursive function.
An example code of my problem:
findInt :: [Int] -> Either Int Bool
findInt (x:xs) =
if x == 1 then x
else False : findInt xs
Then the error says couldn't match expected type "Either Int Bool" with actual type "Int". But I want to check whether the element is in this list and if it does it will return the element and tell me if it's not by returning a Boolean.
findInt [...] == ...for various cases. - Jon PurdyFalsefollowed by the result of calllingfindInton the remainder of the list; when given an empy list, raise an error”, which doesn’t make much sense, so it’s difficult to determine what you’re trying to do in order to help you. - Jon Purdy