Allowing let-binding for functions whose last argument is a closure
- OCaml 80.2%
- Dune 13.2%
- Makefile 6.6%
| .github/workflows | ||
| .vscode | ||
| src | ||
| test | ||
| .gitattributes | ||
| .gitignore | ||
| .ocamlformat | ||
| CHANGES.md | ||
| dune | ||
| dune-project | ||
| LICENSE | ||
| Makefile | ||
| ppx-let-fun.opam | ||
| README.md | ||
ppx-let-fun
ppx-let-fun is an experimental ppx rewriter which allows you to use a
let-syntax style to handle functions applications that expects their last
argument to be a closure. It defines and rewrite the let%fun extension:
For example:
let print_hello_world file =
Out_channel.with_open_text file (fun oc ->
Out_channel.output_string oc "Hello, ";
Out_channel.output_string oc "World\n")
Can be rewritten as:
let print_hello_world file =
let%fun oc = Out_channel.with_open_text file in
Out_channel.output_string oc "Hello, ";
Out_channel.output_string oc "World\n"
Possibly related
Archived
I'm now considering using a let& operator instead:
let print_hello_world file =
let& oc = Out_channel.with_open_text file in
Out_channel.output_string oc "Hello, ";
Out_channel.output_string oc "World\n"
which I have released as an alternative library named letfun.
As a result, ppx-let-fun is now archived and I will not continue supporting it.