-1

I just know that it's it easy partial application and it's that it can (and does, for Haskell) simplify the syntax?

glennsl
  • 28,186
  • 12
  • 57
  • 75
joshua
  • 947
  • 2
  • 8
  • 14

1 Answers1

2

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.

glennsl
  • 28,186
  • 12
  • 57
  • 75