[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]