I tried to implement this challenge from Hackerrank (No Idea! | HackerRank) in Haskell where you add 1 to your count if the number is in set A and subtract -1 if the number is in set B.
import qualified Data.Set as Set
setA :: Set.Set Int
setA = Set.fromList [3,1]
setB :: Set.Set Int
setB = Set.fromList [5,7]
numbers :: List
numbers = [1,5,3]
happinessF :: [Int] -> Set.Set Int -> Set.Set Int -> Int
happinessF set1 set2 = foldr ((+) . cond) 0
where cond x
| Set.member x set1 = 1
| Set.member x set2 = -1
| otherwise = 0
When I run this code, I get an error saying:
Couldnât match expected type: Set.Set Int with actual type: [Int]
Any ideas why this code isnât working?