package seqes

  1. Overview
  2. Docs

Traversors

A traversor is a function that traverses a sequence, applying a caller-provided function on the sequence's elements. E.g., iter.

A traversor may traverse only a portion of the sequence. E.g., for_all.

The type of traversor mentions two distinct monad types:

  • 'a mon: the monad that the sequence is specialised to
  • 'a callermon: the monad that the caller-provided functions use

These two monad types can be different. The main use for these types being distinct is to provide both plain-traversors (e.g., the plain-iter has type ('a -> unit) -> 'a t -> unit mon) and mon-traversors (e.g., the mon-iter has type ('a -> unit mon) -> 'a t -> unit mon). Plain-traversors are obtained with type 'a callermon := 'a whereas mon-traversors are obtained with type 'a callermon := 'a mon.

There are more advanced use for tiers of monads. See examples/seqlist/seqlist.ml for an advanced example involving List and Option.

type 'a callermon

callermon is the type constructor for the monad used in caller-provided functions.

The type is meant to be substituted by the functor that produces modules following this signature.

type 'a mon

mon is the type constructor for the monad used in the sequence.

The type is meant to be substituted by the functor that produces modules of following this signature.

type 'a t

t is the type constructor for the sequence.

The type is meant to be substituted by the functor that produces modules of following this signature.

val iter : ('a -> unit callermon) -> 'a t -> unit mon

See Stdlib.Seq.iter

val fold_left : ('a -> 'b -> 'a callermon) -> 'a -> 'b t -> 'a mon

See Stdlib.Seq.fold_left

val iteri : (int -> 'a -> unit callermon) -> 'a t -> unit mon

See Stdlib.Seq.iteri

val fold_lefti : ('b -> int -> 'a -> 'b callermon) -> 'b -> 'a t -> 'b mon

See Stdlib.Seq.fold_lefti

val for_all : ('a -> bool callermon) -> 'a t -> bool mon

See Stdlib.Seq.for_all

val exists : ('a -> bool callermon) -> 'a t -> bool mon

See Stdlib.Seq.exists

val find : ('a -> bool callermon) -> 'a t -> 'a option mon

See Stdlib.Seq.find

val find_map : ('a -> 'b option callermon) -> 'a t -> 'b option mon

See Stdlib.Seq.find_map

val iter2 : ('a -> 'b -> unit callermon) -> 'a t -> 'b t -> unit mon

See Stdlib.Seq.iter2

val fold_left2 : ('a -> 'b -> 'c -> 'a callermon) -> 'a -> 'b t -> 'c t -> 'a mon

See Stdlib.Seq.fold_left2

val for_all2 : ('a -> 'b -> bool callermon) -> 'a t -> 'b t -> bool mon

See Stdlib.Seq.for_all2

val exists2 : ('a -> 'b -> bool callermon) -> 'a t -> 'b t -> bool mon

See Stdlib.Seq.exists2