From 35d5add9d669f71e83e0768c5713d68f0607448e Mon Sep 17 00:00:00 2001 From: Matt Bray Date: Wed, 15 Jun 2022 11:52:37 +0100 Subject: [PATCH] chore: add My_opt.map to src-bs/decoders_util.ml --- src-bs/decoders_util.ml | 4 +++- src-bs/decoders_util.mli | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src-bs/decoders_util.ml b/src-bs/decoders_util.ml index 2e41740..6813caf 100644 --- a/src-bs/decoders_util.ml +++ b/src-bs/decoders_util.ml @@ -24,6 +24,8 @@ end module My_opt = struct let return x = Some x + let map f x = Belt.Option.map x f + let flat_map f x = Belt.Option.flatMap x f end @@ -37,7 +39,7 @@ module My_list = struct let find_map f xs = xs |. Belt.List.getBy (fun x -> - match f x with Some _ -> true | None -> false) + match f x with Some _ -> true | None -> false ) |. Belt.Option.flatMap f diff --git a/src-bs/decoders_util.mli b/src-bs/decoders_util.mli index a2a71b2..1e31194 100644 --- a/src-bs/decoders_util.mli +++ b/src-bs/decoders_util.mli @@ -19,6 +19,8 @@ end module My_opt : sig val return : 'a -> 'a option + val map : ('a -> 'b) -> 'a option -> 'b option + val flat_map : ('a -> 'b option) -> 'a option -> 'b option end