JJ: Description from the destination commit:

~ syntax stuff

JJ: Description from source commit:
~~
This commit is contained in:
swrup 2025-11-04 18:36:32 +01:00
parent 774d55ebb1
commit 1a65fa9b8c
4 changed files with 131 additions and 102 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