Module type Std.Memory_iterators

Iterators lifted into monad

type t
type 'a m
val fold : ?word_size:size -> t -> init:'b -> f:(word -> 'b -> 'b m) -> 'b m

fold ~word_size ~init ~f t folds over elements of t, so a result is f (... (f (f a elt_1) elt_2) ...) elt_n

val iter : ?word_size:size -> t -> f:(word -> unit m) -> unit m

iter ~word_size ~f t applies f to elements of t

val foldi : ?word_size:size -> t -> init:'b -> f:(addr -> word -> 'b -> 'b m) -> 'b m

foldi ~word_size ~init ~f t is like fold, but also passes an address to the f

val iteri : ?word_size:size -> t -> f:(addr -> word -> unit m) -> unit m

iteri ~word_size ~f t is like iter, but also passes an address to the f

val exists : ?word_size:size -> t -> f:(addr -> word -> bool m) -> bool m

exists ~word_size ~f t checks if at least one element of t satisfies the predicate f

val for_all : ?word_size:size -> t -> f:(addr -> word -> bool m) -> bool m

for_all ~word_size ~f t checks if all elements of t satisfies the predicate f

val count : ?word_size:size -> t -> f:(addr -> word -> bool m) -> int m

count ~word_size ~f t is the number of elements in t that satisfies the predicate f.

val find_if : ?word_size:size -> t -> f:(addr -> word -> bool m) -> word option m

find_if ~word_size ~f t returns the first element of t that satisfies the predicate p or None if no elements satisfied

val find_map : ?word_size:size -> t -> f:(addr -> word -> 'a option m) -> 'a option m

find_map ~word_size ~f t returns the first evaluation of f that returns Some or None if f always returns None