[Libguestfs] [PATCH 0/4]: mllib: Add 'may' function, and refactoring.

Richard W.M. Jones rjones at redhat.com
Tue Nov 10 20:25:54 UTC 2015


The 'may' function is a higher-order function (HOF) that replaces:

  match x with
  | None -> ()
  | Some x -> f x

with:

  may f x

The idea comes from lablgtk (OCaml Gtk bindings) where it is widely
used.

If this change is clearer than previous code, then this could be used
in many more places.  However I previously steered clear from using
HOFs like this because they can be quite confusing for newcomers to
functional programming.

Rich.




More information about the Libguestfs mailing list