by baby · 3y ago · 0 comments
> Tacit programming (point-free programming) is a programming paradigm in which a function definition does not include information regarding its arguments, using combinators and function composition [...] instead of variables.
from https://stackoverflow.com/questions/944446/what-is-point-fre...
I guess it's the fact that in programming languages like OCaml you write functions like that:
let some_fn arg1 arg2 = ...
and so you can partially apply them:* using `some_fn` without any argument is manipulating a function with two arguments
* using `some_fn arg1` returns a new function that only takes one argument
* using `some_fn arg1 arg2` applies the entire function
let last xs = List.fold_left (fun x y -> Some y) None xs
This is of type last : 'a list -> 'a option = <fun>
Neat, `'a` is generic. Let's η-reduce out the `xs` and make the function point-free (ignoring the lambda): let last = List.fold_left (fun x y -> Some y) None
This doesn't work the way that we want: last : '_weak1 list -> '_weak1 option = <fun>
The moment that we call this weakly polymorphic function, its type is fixed and is no longer generic. In the toplevel: # last [1;2;3];;
- : int option = Some 3
# last['x';'y';'z'];;
Error: This expression has type char but an expression was expected of type
int
Haskell, of course, is totally happy to let you do point-free mania with Kleisli arrows and all of the rest of it.