I am trying to solve Hutton 2016 exercise 7.2a. My attempt gets the same error message as the one below. The problem with the error message below is that it is for the book's solved example, so I have no idea how to make it work. I suspect I have GHCi configured wrong, or an old version that is buggy on Mac, or such.Help is appreciated.Also, at this point I am having trouble reading these function declarations.all :: (a -> Bool) -> [Bool] -> Boolall b ls = and (map b ls)My try:all :: -- name of function defined(a -> -- maps to "all"Bool -- maps to boolean function b) -> [Bool] -- maps to input ls-> Bool -- maps to return type of "all"all b ls = and (map b ls)OR (right?)all :: -- name of function defined(a -> Bool) function of type a returns bool-> [Bool] -- maps to input ls-> Bool -- maps to return type of "all"all b ls = and (map b ls)------Book exampleall :: (a -- maps to "all"-> Bool -- input function type) -> [Bool] -- implied list of things mapped over-> Bool -- returnedall p = and . map pOR (right?)all :: -- name of defined function(a -> Bool) -- input function of type a returns type Bool-> [Bool] -- implied list to work on-> Bool -- return typeall p = and . map p============================-- CODE{--2. Without looking at the definitions from the standard prelude, define the following higher-order library functions on lists.a.Decide if all elements of a list satisfy a predicate:all :: (a -> Bool) -> [Bool] -> Boolb.Decide if any element of a list satisfies a predicate:any :: (a -> Bool) -> [Bool] -> Boolc.Select elements from a list while they satisfy a predicate:takeWhile :: (a -> Bool) -> [a] -> [a]d.Remove elements from a list while they satisfy a predicate: dropWhile :: (a -> Bool) -> [a] -> [a]Note: in the prelude the first two of these functions are generic functions rather than being specific to the type of lists.Hutton, Graham. Programming in Haskell (Kindle Locations 2806-2819). Cambridge University Press. Kindle Edition.--}import Prelude hiding (all){-- My attempt. Presumably bad.-- I swear GHCi was happy with it yesterday.all :: (a -> Bool) -> [Bool] -> Boolall b ls = and (map b ls)--}-- from bookall :: (a -> Bool) -> [Bool] -> Boolall p = and . map p{-->From GHCi on MacPrelude> :r[1 of 1] Compiling Main ( ex7_2a.hs, interpreted )ex7_2a.hs:30:9: error:• Couldn't match type ‘a’ with ‘Bool’‘a’ is a rigid type variable bound bythe type signature for:all :: forall a. (a -> Bool) -> [Bool] -> Boolat ex7_2a.hs:29:1-36Expected type: [Bool] -> BoolActual type: [a] -> Bool• In the expression: and . map pIn an equation for ‘all’: all p = and . map p• Relevant bindings includep :: a -> Bool (bound at ex7_2a.hs:30:5)all :: (a -> Bool) -> [Bool] -> Bool (bound at ex7_2a.hs:30:1)|30 | all p = and . map p| ^^^^^^^^^^^Failed, no modules loaded.--}
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners