{"body":"-- Tried to define the same all function this way using recursion but gives error\r\nall''' :: (a -> Bool) -> [a] -> Bool\r\nall''' f [] = True\r\nall''' f (x:xs) = f x && all''' xs\r\n{- this is the error\r\n2-functions-higherorder.hs:10:26: error:\r\n    • Couldn't match expected type ‘Bool’\r\n                  with actual type ‘[a0] -> Bool’\r\n    • Probable cause: ‘all''’ is applied to too few arguments\r\n      In the second argument of ‘(&&)’, namely ‘all''' xs’\r\n      In the expression: f x && all''' xs\r\n      In an equation for ‘all'''’: all''' f (x : xs) = f x && all''' xs\r\n   |\r\n10 | all''' f (x:xs) = f x && all''' xs\r\n   |                          ^^^^^^^^\r\n\r\n2-functions-higherorder.hs:10:32: error:\r\n    • Couldn't match expected type ‘a0 -> Bool’ with actual type ‘[a]’\r\n    • In the first argument of ‘all''’, namely ‘xs’\r\n      In the second argument of ‘(&&)’, namely ‘all'' xs’\r\n      In the expression: f x && all'' xs\r\n    • Relevant bindings include\r\n        xs :: [a] (bound at 2-functions-higherorder.hs:10:13)\r\n        x :: a (bound at 2-functions-higherorder.hs:10:11)\r\n        f :: a -> Bool (bound at 2-functions-higherorder.hs:10:8)\r\n        all''' :: (a -> Bool) -> [a] -> Bool\r\n          (bound at 2-functions-higherorder.hs:9:1)\r\n   |\r\n10 | all''' f (x:xs) = f x && all'' xs\r\n\r\n-}","name":"function definition to Decide if all elements of a list satisfy a predicate","extension":"hs","url":"https://www.irccloud.com/pastebin/BDYGOBhK/function+definition+to+Decide+if+all+elements+of+a+list+satisfy+a+predicate","modified":1646517853,"id":"BDYGOBhK","size":1361,"lines":31,"own_paste":false,"theme":"","date":1646517549}