/ppx-let-fun

Allowing let-binding for functions whose last argument is a closure

Primary LanguageOCamlMIT LicenseMIT

ppx-let-fun

CI Status

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.