ligo/proto-alpha-utils/x_error_monad.ml
2019-05-12 20:50:18 +00:00

26 lines
618 B
OCaml

include Tezos_error_monad.Error_monad
include Tezos_utils.Error_monad
open Memory_proto_alpha
let (>>??) = Alpha_environment.Error_monad.(>>?)
let alpha_wrap a = Alpha_environment.wrap_error a
let force_ok_alpha ~msg a = force_ok ~msg @@ alpha_wrap a
let force_lwt ~msg a = force_ok ~msg @@ Lwt_main.run a
let force_lwt_alpha ~msg a = force_ok ~msg @@ alpha_wrap @@ Lwt_main.run a
let assert_error () = function
| Ok _ -> fail @@ failure "assert_error"
| Error _ -> return ()
let (>>=??) a f =
a >>= fun a ->
match alpha_wrap a with
| Ok result -> f result
| Error errs -> Lwt.return (Error errs)