+ wip content negotation
This commit is contained in:
parent
119d31a160
commit
cd85efffde
4 changed files with 166 additions and 33 deletions
37
src/syntax.ml
Normal file
37
src/syntax.ml
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue