add Result.{to,of}_err

This commit is contained in:
Simon Cruanes 2016-04-11 20:56:39 +02:00
parent 85c4695138
commit 55a4c7ef7a
2 changed files with 18 additions and 0 deletions

View file

@ -245,6 +245,16 @@ let to_seq e k = match e with
| Ok x -> k x
| Error _ -> ()
type ('a, 'b) error = [`Ok of 'a | `Error of 'b]
let of_err = function
| `Ok x -> Ok x
| `Error y -> Error y
let to_err = function
| Ok x -> `Ok x
| Error y -> `Error y
(** {2 IO} *)
let pp pp_x buf e = match e with

View file

@ -181,6 +181,14 @@ val of_opt : 'a option -> ('a, string) t
val to_seq : ('a, _) t -> 'a sequence
type ('a, 'b) error = [`Ok of 'a | `Error of 'b]
val of_err : ('a, 'b) error -> ('a, 'b) t
(** @since NEXT_RELEASE *)
val to_err : ('a, 'b) t -> ('a, 'b) error
(** @since NEXT_RELEASE *)
(** {2 IO} *)
val pp : 'a printer -> ('a, string) t printer