From ebdf201161046c334ab976d6fdc590076fae5476 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 9 Jun 2015 16:07:35 +0200 Subject: [PATCH] add `CCError.Infix` module --- src/core/CCError.ml | 8 ++++++++ src/core/CCError.mli | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/core/CCError.ml b/src/core/CCError.ml index 310dfe4f..3693361c 100644 --- a/src/core/CCError.ml +++ b/src/core/CCError.ml @@ -195,6 +195,14 @@ let retry n f = | `Error e -> retry (n-1) (e::acc) in retry n [] +(** {2 Infix} *) + +module Infix = struct + let (>>=) = (>>=) + let (>|=) = (>|=) + let (<*>) = (<*>) +end + (** {2 Monadic Operations} *) module type MONAD = sig diff --git a/src/core/CCError.mli b/src/core/CCError.mli index 57dc714a..63c966c0 100644 --- a/src/core/CCError.mli +++ b/src/core/CCError.mli @@ -120,6 +120,16 @@ val (<*>) : ('a -> 'b, 'err) t -> ('a, 'err) t -> ('b, 'err) t [`Ok (a b)]. Otherwise, it fails, and the error of [a] is chosen over the error of [b] if both fail *) +(** {2 Infix} + + @since NEXT_RELEASE *) + +module Infix : sig + val (>|=) : ('a, 'err) t -> ('a -> 'b) -> ('b, 'err) t + val (>>=) : ('a, 'err) t -> ('a -> ('b, 'err) t) -> ('b, 'err) t + val (<*>) : ('a -> 'b, 'err) t -> ('a, 'err) t -> ('b, 'err) t +end + (** {2 Collections} *) val map_l : ('a -> ('b, 'err) t) -> 'a list -> ('b list, 'err) t