This commit is contained in:
swrup 2025-11-04 20:08:07 +01:00
parent 95a78b5591
commit 76e26eb494
4 changed files with 58 additions and 53 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