I am currently learning Haskell. I am trying to write a function which given two list of n distinct elements returns true if one is a permutation of the other. I am doing this as an exercise.
I first wrote it as :
isPermut :: (Eq a)=>[a]->[a]->Bool
isPermut u v = foldl (\acc x -> acc && (elem x u)) True v
This seems to work. I now try to rewrite it without lambda expression. So I try :
isPermut :: (Eq a)=>[a]->[a]->Bool
isPermut u v = foldl (&& (flip $ elem u)) True v
This gives me a compile error :
Couldn't match expected type `b0 -> Bool' with actual type `Bool'
Expected type: Bool -> b0 -> Bool
Actual type: Bool -> Bool
In the first argument of `foldl', namely `(&& (flip $ elem u))'
In the expression: foldl (&& (flip $ elem u)) True v
What does this error mean? What is the correct way to write the function without lambda? Thanks.