diff options
Diffstat (limited to '')
| -rw-r--r-- | lib/Utilities.ml | 8 | ||||
| -rw-r--r-- | lib/Utilities.mli | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/Utilities.ml b/lib/Utilities.ml index bd604c9..9ae0119 100644 --- a/lib/Utilities.ml +++ b/lib/Utilities.ml @@ -1,4 +1,12 @@ module Result = struct let ( let* ) = Result.bind let fmap f m = Result.bind m f + + let sequence ms = List.fold_right + (fun m acc -> + let* acc = acc in + let* m = m in + Ok (m::acc)) + ms + (Ok []) end diff --git a/lib/Utilities.mli b/lib/Utilities.mli index c9852f0..cdb53df 100644 --- a/lib/Utilities.mli +++ b/lib/Utilities.mli @@ -1,4 +1,5 @@ module Result : sig val ( let* ) : ('a, 'e) result -> ('a -> ('b, 'e) result) -> ('b, 'e) result val fmap : ('a -> ('b, 'e) result) -> ('a, 'e) result -> ('b, 'e) result + val sequence : ('a, 'b) result list -> ('a list, 'b) result end |
