Source file or_error.ml

1
2
3
4
5
6
7
8
9
type ('a, 'e) result = ('a, 'e) Result.result = Ok of 'a | Error of 'e

type msg = [ `Msg of string ]

let ( >>= ) r f = match r with Ok v -> f v | Error _ as e -> e

let rec fold_list f acc = function
  | [] -> Ok acc
  | hd :: tl -> f acc hd >>= fun acc -> fold_list f acc tl