by eru · 4y ago · 0 comments
Hey, that's basically how any function with more than one argument is implemented in Haskell. (Look up currying.)
It's not so much that this style is 'awful' in any universal sense; it's more that Go is terrible, terrible host language for anything in this style.
add x y = x + y
There is no functions returning functions here, just a normal addition. It is perfectly readable.
Haskell just decided to have a syntax (and type system) that can handle this without inducing nausea in the programmer.
As with everything, this comes with trade-offs. For example, Haskell's syntax (and type system) have a much harder time dealing with optional arguments. Something that eg Python does just fine, and that even C handles OK in the form of varargs.