3 ms·
> Point-free means you have all that wiring in your head, without assistance from the notation. I completely agree. It fatigues me to read unnecessarily point-
by trealira 3y ago
> Point-free means you have all that wiring in your head, without assistance from the notation.
I completely agree. It fatigues me to read unnecessarily point-free programming. I have to translate it into a point-ful style in my head to understand it.
For example, you could take this piece of Haskell code and make it more point-free. I think it's readable at first, if redundant (you could remove the last parameter xs, for example).
-- map: apply the function f to each element of the list xs
map :: (a -> b) -> [a] -> [b]
map f xs = foldr (\x xs -> f x : xs) [] xs
Some people would prefer to write it like this:
map :: (a -> b) -> [a] -> [b]
map f = foldr ((:) . f) []
That lambda takes more effort to parse and think about, though, at least for me. The first version was pretty readable. Now, when I read "((:) . f)" I'm thinking "okay, so the function f takes an argument, and passes the result to the (:) function, which normally takes two parameters; with one argument, it returns another function that takes one list parameter and returns it with the result of "f x" prepended to it." And to do this, I have to know implicitly how many arguments the function (:) takes in order to parse and understand it correctly (though in this case, it's obvious, because (:) is ubiquitous).
Pointfree.io would take what I wrote and transform it into
map = flip foldr ([]) . ((:) .)
But I'm pretty sure no one would write that. It takes even more effort to correctly parse this.
That said, I don't write any Haskell. I just used to try to, but found I didn't like it.