I'm am training funtional Haskell and cannot usderstand what is wrong with this:
maxBy :: (a -> Int) -> a -> a -> a
maxBy measure a b = max (measure a) (measure b)
Here are examples how this maxBy function should work:
maxBy (*2) 3 5 ==> 5
maxBy length [1,2,3] [4,5] ==> [1,2,3]
maxBy head [1,2,3] [4,5] ==> [4,5]
Error message is:
Couldn't match expected type ‘a’ with actual type ‘Int’ ‘a’ is a rigid type variable bound by the type signature for: maxBy :: forall a. (a -> Int) -> a -> a -> a