We had to write lambda function in Haskell but it always shows errors. What do I do wrong? all codes have the same kind of error, but I don't understand how to make them right.
length' :: [a] -> [a] -> Int
length' [] = 0
length' (x:xs) (y:ys) = \n -> if length (x:xs) > (y:ys) then 1 else if (x:xs) == (y:ys) then 0 else if (x:xs) < (y:ys) then -1
find :: a -> [a] -> Bool
find p [] = False
find p xs = \p -> if p `elem` xs then True else False
remove y [] = []
remove y (x:xs) = \xs -> if y == x then xs else x: remove y xs
• Couldn't match expected type ‘Bool’ with actual type ‘a -> Bool’
• The lambda expression ‘\ p -> ...’ has one argument,
but its type ‘Bool’ has none
In the expression: \ p -> if p `elem` xs then True else False
In an equation for ‘find’:
find p xs = \ p -> if p `elem` xs then True else False
the errors are the same
Couldn't match expected type ‘[t]’ with actual type ‘[t] -> [t]’
• The lambda expression ‘\ xs -> ...’ has one argument,
but its type ‘[t]’ has none
In the expression: \ xs -> if y == x then xs else x : remove y xs
In an equation for ‘remove’: