diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-07-30 19:55:42 +0000 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-07-30 16:56:06 -0300 |
| commit | 2a3ffd895f5c2061d7941134bb15df6047141916 (patch) | |
| tree | ac564d40b1d24794d4d9c77055b0486eae0128dd /lib/Utilities.ml | |
| parent | 357a0c4ec609ccfd86764ac41480bcb7b1194986 (diff) | |
| download | RNT-2a3ffd895f5c2061d7941134bb15df6047141916.tar.gz RNT-2a3ffd895f5c2061d7941134bb15df6047141916.zip | |
B-trees & serialization with bencode
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 |
