b
This commit is contained in:
commit
6fd066773f
37 changed files with 1537 additions and 0 deletions
12
src/syntax.ml
Normal file
12
src/syntax.ml
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue