diff --git a/AUTHORS.adoc b/AUTHORS.adoc index de89cd30..f2be0ad2 100644 --- a/AUTHORS.adoc +++ b/AUTHORS.adoc @@ -16,3 +16,4 @@ - Johannes Kloos - Geoff Gole (@gsg) - Roma Sokolov (@little-arhat) +- Malcolm Matalka (`orbitz`) diff --git a/src/core/CCResult.ml b/src/core/CCResult.ml index 581d2d06..42b5c12d 100644 --- a/src/core/CCResult.ml +++ b/src/core/CCResult.ml @@ -98,6 +98,14 @@ let fold ~ok ~error x = match x with | Ok x -> ok x | Error s -> error s +let is_ok = function + | Ok _ -> true + | Error _ -> false + +let is_error = function + | Ok _ -> false + | Error _ -> true + (** {2 Wrappers} *) let guard f = diff --git a/src/core/CCResult.mli b/src/core/CCResult.mli index 49674995..3f0d73a3 100644 --- a/src/core/CCResult.mli +++ b/src/core/CCResult.mli @@ -87,6 +87,16 @@ val fold : ok:('a -> 'b) -> error:('err -> 'b) -> ('a, 'err) t -> 'b (** [fold ~ok ~error e] opens [e] and, if [e = Ok x], returns [ok x], otherwise [e = Error s] and it returns [error s]. *) +val is_ok : ('a, 'err) t -> bool +(** Return true if Ok/ + + @since NEXT_RELEASE *) + +val is_error : ('a, 'err) t -> bool +(** Return true if Error + + @since NEXT_RELEASE *) + (** {2 Wrappers} *) val guard : (unit -> 'a) -> ('a, exn) t