+ wip content negotation

This commit is contained in:
Swrup 2025-09-15 23:41:36 +02:00
parent 119d31a160
commit cd85efffde
4 changed files with 166 additions and 33 deletions

37
src/syntax.ml Normal file
View file

@ -0,0 +1,37 @@
let ( let* ) o f = match o with Ok v -> f v | Error _ as e -> e
let ( let+ ) o f = match o with Ok v -> Ok (f v) | Error _ as e -> e
let list_iter f l =
let err = ref None in
try
List.iter
(fun v ->
match f v with
| Error _e as e ->
err := Some e;
raise Exit
| Ok () -> ())
l;
Ok ()
with Exit -> ( match !err with None -> assert false | Some v -> v)
let list_map f l =
let err = ref None in
try
Ok
(List.map
(fun v ->
match f v with
| 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 list_fold_left f acc l =
List.fold_left
(fun acc v ->
let* acc = acc in
f acc v)
(Ok acc) l