Skip to content

Commit

Permalink
chore: add My_opt.map to src-bs/decoders_util.ml
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjbray committed Jun 15, 2022
1 parent 221f37b commit 35d5add
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src-bs/decoders_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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


Expand Down
2 changes: 2 additions & 0 deletions src-bs/decoders_util.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 35d5add

Please sign in to comment.