I started to learn Haskell. I'm curious about why in Haskell the function is taken as the first argument for the higher order functions for lists. For example here is a definition of map
:
map :: (a -> b) -> [a] -> [b]
It means that I can use it either in prefix or operator form like that:
-- yields [3,5,7]
map (+ 2) [1,3,5]
-- we can chain like that
filter (< 4) (map (+ 2) [1,3,5])
-- or in operator form
(+ 2) `map` [1,3,5]
(< 4) `filter` ((+ 2) `map` [1,3,5])
In Scala the same can be written as follows:
List(1,3,5) map (_ + 2)
// we can chain as follows:
List(1,3,5) map (_ + 2) filter (_ < 4)
So the order is reversed and we take the function as the second argument. What is the reason on arguments ordering in Haskell?