This commit is contained in:
swrup 2025-11-04 19:28:34 +01:00
parent ece827c7ee
commit 84afc29675
4 changed files with 90 additions and 69 deletions

22
unikernel/syntax.ml Normal file
View file

@ -0,0 +1,22 @@
let ( let* ) = Lwt.bind
let ( let+ ) x f = Lwt.map f x
let ( let*? ) = Lwt_result.bind
let ( let+? ) x f = Lwt_result.map f x
let list_get_ok l =
let err = ref None in
try
Ok
(List.map
(function
| Error _e as e ->
err := Some e;
raise Exit
| Ok v -> v)
l)
with Exit -> ( match !err with None -> assert false | Some v -> v)
let lwt_list_get_ok l =
let open Lwt.Syntax in
let+ l = l in
list_get_ok l