Let's say I have this code:
import qualified Data.Map as Map
import qualified Data.Set as Set
let s = Set.fromList [0,1,2]
m = Map.fromList [(1,"a"),(2,"b"),(3,"c")]
in Map.filterWithKey (\k _ -> Set.member k s) m
I wanted to get rid of the lambda expression:
Map.filterWithKey (flip Set.member s . const) m
but it does not compile. and I can’t understand why .. Please help.
Couldn't match type ‘Bool’ with ‘[Char] -> Bool’
Expected type: (b0 -> a) -> Set.Set (b0 -> a) -> [Char] -> Bool
Actual type: (b0 -> a) -> Set.Set (b0 -> a) -> Bool
In the first argument of ‘flip’, namely ‘Set.member’
In the first argument of ‘(.)’, namely ‘flip Set.member s’
source
share