>>start to use (in Haskell) "flip", "uncurry
This I think lines up with the general Forth advice to avoid stack juggling (swap, roll, over, dup etc).
Sure, but some amount of stack juggling is unavoidable once you allow for multiple arguments/return values. It's a rare case when function arguments simply map "naturally" to the top values on the stack.
Joy allows to return a concatenation on top of stack. That's a single element that can contain several elements, just like tuple in Haskell.
Re:Concatenation is composition
by chriswarbo on Monday July 18, 2022 @02:00PM
(#32141271)
Point-free style can be useful as an intermediate step when refactoring, since making code point-free (a) is largely mechanical (although judgement can still useful to avoid horrible results!), and (b) removes many of the abstractions and variable names in the code.
The latter are often historical baggage, telling us what the code used to do, or was meant to do; whilst a point-free version shows us more directly what it actually does.
If the point-free version makes sense as-is, we can leave it; but that's rarely the case. Usually, we'll introduce a few abstractions and variables; but this time they'll be more appropriate for the current codebase.
Re:Concatenation is composition
by heavenlyblue on Monday July 18, 2022 @05:29PM
(#32144076)
You can also look at the generated assembly to figure out exactly what the code does
Re:Concatenation is composition
by chriswarbo on Tuesday July 19, 2022 @05:36AM
(#32149372)
Assembly obfuscates the implementation with memory allocation, garbage collection, etc. which is often worse than even 'the wrong' (i.e. legacy) abstractions in a high level language.
Re:Concatenation is composition
by Xophmeister on Monday July 18, 2022 @05:49AM
(#32136346)
In my (admittedly newbie) experience, it's particularly useful when application of your function is going to be in a context where η-reduction is natural. For example, your fmap is going to look cleaner without a wrapping lambda inside it.
And for other people, such as myself, it depends on the particular case.
I think that point-free style can be clearer and more concise in certain cases (particularly when you're chaining a sequence of operations), but you can also really overdo it. I think when you start to use (in Haskell) "flip", "uncurry", etc., the question is whether it wouldn't be more readable to just name the arguments instead. But obviously, people are going to have varying levels of tolerance for such things.