mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
add Result.{to,of}_err
This commit is contained in:
parent
85c4695138
commit
55a4c7ef7a
2 changed files with 18 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue