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

[Libguestfs] [PATCH 1/4] generator: Add |> (revapply) operator for compat with OCaml < 4.01.



---
 generator/utils.ml  | 2 ++
 generator/utils.mli | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/generator/utils.ml b/generator/utils.ml
index bb96eb6..3e81433 100644
--- a/generator/utils.ml
+++ b/generator/utils.ml
@@ -205,6 +205,8 @@ let files_equal n1 n2 =
   | 1 -> false
   | i -> failwithf "%s: failed with error code %d" cmd i
 
+let (|>) x f = f x
+
 let rec filter_map f = function
   | [] -> []
   | x :: xs ->
diff --git a/generator/utils.mli b/generator/utils.mli
index a69328f..c7d3f2c 100644
--- a/generator/utils.mli
+++ b/generator/utils.mli
@@ -76,6 +76,10 @@ val files_equal : string -> string -> bool
 (** [files_equal filename1 filename2] returns true if the files contain
     the same content. *)
 
+val (|>) : 'a -> ('a -> 'b) -> 'b
+(** Added in OCaml 4.01, we can remove our definition when we
+    can assume this minimum version of OCaml. *)
+
 val filter_map : ('a -> 'b option) -> 'a list -> 'b list
 
 val find_map : ('a -> 'b option) -> 'a list -> 'b
-- 
2.9.3


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