3 ms·
Just taking the first examples from the Haskell wiki: sum = foldr (+) 0 foldr (f . g) e rather than sum' xs = foldr (+) 0 xs foldr f' e
by lmm 9y ago
Just taking the first examples from the Haskell wiki:
sum = foldr (+) 0
foldr (f . g) e
rather than
sum' xs = foldr (+) 0 xs
foldr f' e
where f' a b = f (g a) b
The idea is that you define loads of tiny functions at higher order, like the sum example, and these are very simple and easy to maintain because every function is a one-liner. I don't know how to respond to the complaint that the example is just syntactic, because it's fundamentally a syntactic construct (at least unless we get to the point of e.g. summing a list of functions to get their composition): the pointfree style is completely equivalent to the pointed style, it's just argued to be a less noisy syntax, that therefore increases readability and maintainability.