+ include Monad.MakeT2(struct
+ module Wrapped = Wrapped
+ type ('x,'a) m = ('x,'a error) Wrapped.m
+ type ('x,'a) result = ('x,'a) Wrapped.result
+ type ('x,'a) result_exn = ('x,'a) Wrapped.result_exn
+ let elevate w = Wrapped.bind w (fun a -> Wrapped.unit (Success a))
+ let bind u f = Wrapped.bind u (fun t -> match t with
+ | Success a -> f a
+ | Error e -> Wrapped.unit (Error e))
+ let run u =
+ let w = Wrapped.bind u (fun t -> match t with
+ | Success a -> Wrapped.unit a
+ | Error e -> Wrapped.zero ())
+ in Wrapped.run w
+ let run_exn u =
+ let w = Wrapped.bind u (fun t -> match t with
+ | Success a -> Wrapped.unit a
+ | Error e -> raise (Err.Exc e))
+ in Wrapped.run_exn w
+ end)
+ let throw e = Wrapped.unit (Error e)
+ let catch u handler = Wrapped.bind u (fun t -> match t with
+ | Success _ -> Wrapped.unit t
+ | Error e -> handler e)