I just know that it's it easy partial application and it's that it can (and does, for Haskell) simplify the syntax?
-
This question is valuable in its own right because it solicits disadvantages. – ThatsJustCheesy Aug 31 '23 at 00:15
-
Also because the "duplicate" actually doesn't explain currying, but rather partial application, as it points out itself. – glennsl Aug 31 '23 at 08:56
-
I'm not convinced either is on-topic on Stack Overflow. Probably better suited to [languagedesign.se]. – pppery Aug 31 '23 at 20:58
1 Answers
The main advantage is that it makes partial function application more convenient, and thereby encourages function composition.
One disadvantage is that it doesn't fit very well with a few other language features you might want, such as labeled, optional and variadic arguments. It's certainly not impossible to get it to work, OCaml for example has both labeled and optional arguments, but it gets quirky. How do you know when a function is partially applied, or fully applied and just not applying the optional argument? OCaml's solution is to assume partial application, and require functions to be "terminated" with a non-optional argument to be able to be fully applied without specifying all the optional arguments.
Another disadvantage pops up if the language is impure and has some form of type inference. It is then possible to partially apply a side-effectful function, discard the value without noticing that the type is incorrect, and thereby never have the side-effect occur. How prone a language is to mistakes like this depends on its type inference, but it's a fairly common beginner's mistake in a language such as OCaml. It can however be avoided by being a bit disciplined with type annotations.

- 28,186
- 12
- 57
- 75