This commit is contained in:
Swrup 2022-12-04 22:42:55 +01:00
commit 6fd066773f
37 changed files with 1537 additions and 0 deletions

12
src/syntax.ml Normal file
View file

@ -0,0 +1,12 @@
(* let bindings for early return when encountering an error *)
(* see https://ocaml.org/releases/4.13/htmlman/bindingops.html *)
let ( let* ) o f = Result.fold ~ok:f ~error:Result.error o
let unwrap_list f ids =
let l = List.map f ids in
let res = List.find_opt Result.is_error l in
match res with
| None -> Ok (List.map Result.get_ok l)
| Some (Ok _) -> assert false
| Some (Error _e as error) -> error