I'm currently attempting to do this problem from the ebook, Haskell School of Music:
Define a function applyAll that, given a list of functions [ f1, f2, ..., fn ] and a value v, returns the result f1 (f2 (...(fn v)...)).
For example: applyAll [simple 2 2, (+3)] 5 ⇒ 20
Currently I have
simple :: Integer -> Integer -> Integer -> Integer
simple x y z = x * (y + z)
applyAll :: [(f -> a)] -> a -> a
applyAll [f] v = foldr (.) v [f]
a = (applyAll [simple 2 2, (+3)] 5)
print a
Which gives me the error:
Couldn't match type `f' with `a0 -> f'
`f' is a rigid type variable bound by
the type signature for applyAll :: [f -> a] -> a -> a
Expected type: (f -> a) -> a -> a
Actual type: (f -> a) -> (a0 -> f) -> a0 -> a
In the first argument of `foldr', namely `(.)'
In the expression: foldr (.) v [f]
I'm assuming it has something to do with the type signature, but nothing I've tried so far has yielded results.