mbarbin / letfun

Use let-binding with functions whose last argument is a closure

Home Page:https://mbarbin.github.io/letfun/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

letfun

CI Status Coverage Status

letfun is a tiny library which allows you to use a let-binding style to handle functions applications that expects their last argument to be a closure. It uses for this the let& operator.

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 open Letfun in
  let& oc = Out_channel.with_open_text file in
  Out_channel.output_string oc "Hello, ";
  Out_channel.output_string oc "World\n"

Code documentation

The code documentation of the latest release is built with odoc and published to GitHub pages here.

About

Use let-binding with functions whose last argument is a closure

https://mbarbin.github.io/letfun/

License:MIT License


Languages

Language:OCaml 60.7%Language:Makefile 39.3%