mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-09 12:45:34 -05:00
CCError.map2
This commit is contained in:
parent
c340ad3358
commit
e6dd5db678
2 changed files with 8 additions and 0 deletions
|
|
@ -49,6 +49,10 @@ let map f e = match e with
|
|||
| `Ok x -> `Ok (f x)
|
||||
| `Error s -> `Error s
|
||||
|
||||
let map2 f g e = match e with
|
||||
| `Ok x -> `Ok (f x)
|
||||
| `Error s -> `Error (g s)
|
||||
|
||||
let flat_map f e = match e with
|
||||
| `Ok x -> f x
|
||||
| `Error s -> `Error s
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ val of_exn : exn -> 'a t
|
|||
|
||||
val map : ('a -> 'b) -> 'a t -> 'b t
|
||||
|
||||
val map2 : ('a -> 'b) -> (string -> string) -> 'a t -> 'b t
|
||||
(** Same as {!map}, but also with a function that can transform
|
||||
the error message in case of failure *)
|
||||
|
||||
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
|
||||
|
||||
val guard : (unit -> 'a) -> 'a t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue