diff options
| author | Arnaud Spiwack | 2014-10-17 17:58:11 +0200 |
|---|---|---|
| committer | Arnaud Spiwack | 2014-10-22 07:31:45 +0200 |
| commit | 8532caf90a0bca7ddf94d24f552b5faa98b0f66a (patch) | |
| tree | 453bb575fbe5421bce3ca1453a233edac0fd478b /lib/monad.mli | |
| parent | 000c1e636b033c57fc070d323140f9e26296b9c0 (diff) | |
Add a two-list monadic fold_left iterator.
Diffstat (limited to 'lib/monad.mli')
| -rw-r--r-- | lib/monad.mli | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/monad.mli b/lib/monad.mli index 768fb739d3..c72e584db1 100644 --- a/lib/monad.mli +++ b/lib/monad.mli @@ -54,6 +54,21 @@ module type ListS = sig operator calls its second argument in a tail position. *) val fold_left : ('a -> 'b -> 'a t) -> 'a -> 'b list -> 'a t + + (** {6 Two-list iterators} *) + + (** Raised when an combinator expects several lists of the same size + but finds that they are not. Exceptions must be raised inside + the monad, so two-list combinators take an extra argument to + raise the exception. *) + exception SizeMismatch + + (** [fold_left2 r f s l1 l2] behaves like {!fold_left} but acts + simultaneously on two lists. Returns [r SizeMismatch] if both lists + do not have the same length. *) + val fold_left2 : (exn->'a t) -> + ('a -> 'b -> 'c -> 'a t) -> 'a -> 'b list -> 'c list -> 'a t + end module type S = sig |
