pellest/src/syntax.ml

13 lines
418 B
OCaml
Raw Normal View History

2022-12-04 22:42:55 +01:00
(* 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