Add option iter
authorSiraaj Khandkar <siraaj@khandkar.net>
Thu, 20 Sep 2018 20:35:00 +0000 (16:35 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Thu, 20 Sep 2018 20:35:00 +0000 (16:35 -0400)
compiler/src/lib/tiger/tiger_opt.ml
compiler/src/lib/tiger/tiger_opt.mli

index cdacd0e..8eee986 100644 (file)
@@ -5,6 +5,9 @@ let map t f =
   | None   -> None
   | Some x -> Some (f x)
 
   | None   -> None
   | Some x -> Some (f x)
 
+let iter t ~f =
+  ignore (map t f)
+
 let get t ~default =
   match t with
   | None   -> default
 let get t ~default =
   match t with
   | None   -> default
index 719e854..662ca4a 100644 (file)
@@ -2,4 +2,6 @@ type 'a t = 'a option
 
 val map : 'a t -> ('a -> 'b) -> 'b t
 
 
 val map : 'a t -> ('a -> 'b) -> 'b t
 
+val iter : 'a t -> f:('a -> unit) -> unit
+
 val get : 'a t -> default:'a -> 'a
 val get : 'a t -> default:'a -> 'a
This page took 0.028075 seconds and 4 git commands to generate.