package seqes

  1. Overview
  2. Docs

The module type for the output of the Make2 module (below).

type ('a, 'e) mon

The type of the monad that the specialised Seq variation is built upon. This type is destructively substituted by the application of the functor; it is replaced by the actual monad type passed as parameter.

type ('a, 'e) t = unit -> (('a, 'e) node, 'e) mon

The Seq-like type: identical to Stdlib.Seq.t except for mon.

and ('a, 'e) node =
  1. | Nil
  2. | Cons of 'a * ('a, 'e) t

This include brings all the functions from the Stdlib.Seq module but specialised to the specialised Seq variation. E.g., given module SeqMon = Make2(Mon) then the function SeqMon.map has type ('a -> 'b) -> ('a, 'e) t -> ('b, 'e) t and SeqMon.iter has type ('a -> unit) -> ('a, 'e) t -> (unit, 'e) mon.

See the documentation of Sigs2.SEQMON2ALL for more details.

val iter : ('a -> unit) -> ('a, 'e) t -> (unit, 'e) mon
val fold_left : ('a -> 'b -> 'a) -> 'a -> ('b, 'e) t -> ('a, 'e) mon
val iteri : (int -> 'a -> unit) -> ('a, 'e) t -> (unit, 'e) mon
val fold_lefti : ('b -> int -> 'a -> 'b) -> 'b -> ('a, 'e) t -> ('b, 'e) mon
val for_all : ('a -> bool) -> ('a, 'e) t -> (bool, 'e) mon
val exists : ('a -> bool) -> ('a, 'e) t -> (bool, 'e) mon
val find : ('a -> bool) -> ('a, 'e) t -> ('a option, 'e) mon
val find_map : ('a -> 'b option) -> ('a, 'e) t -> ('b option, 'e) mon
val iter2 : ('a -> 'b -> unit) -> ('a, 'e) t -> ('b, 'e) t -> (unit, 'e) mon
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> ('b, 'e) t -> ('c, 'e) t -> ('a, 'e) mon
val for_all2 : ('a -> 'b -> bool) -> ('a, 'e) t -> ('b, 'e) t -> (bool, 'e) mon
val exists2 : ('a -> 'b -> bool) -> ('a, 'e) t -> ('b, 'e) t -> (bool, 'e) mon
val init : int -> (int -> 'a) -> ('a, 'e) t
val unfold : ('b -> ('a * 'b) option) -> 'b -> ('a, 'e) t
val forever : (unit -> 'a) -> ('a, 'e) t
val iterate : ('a -> 'a) -> 'a -> ('a, 'e) t
val map : ('a -> 'b) -> ('a, 'e) t -> ('b, 'e) t
val mapi : (int -> 'a -> 'b) -> ('a, 'e) t -> ('b, 'e) t
val filter : ('a -> bool) -> ('a, 'e) t -> ('a, 'e) t
val filter_map : ('a -> 'b option) -> ('a, 'e) t -> ('b, 'e) t
val scan : ('b -> 'a -> 'b) -> 'b -> ('a, 'e) t -> ('b, 'e) t
val take_while : ('a -> bool) -> ('a, 'e) t -> ('a, 'e) t
val drop_while : ('a -> bool) -> ('a, 'e) t -> ('a, 'e) t
val group : ('a -> 'a -> bool) -> ('a, 'e) t -> (('a, 'e) t, 'e) t
val map2 : ('a -> 'b -> 'c) -> ('a, 'e) t -> ('b, 'e) t -> ('c, 'e) t
val map_product : ('a -> 'b -> 'c) -> ('a, 'e) t -> ('b, 'e) t -> ('c, 'e) t
val partition_map : ('a -> ('b, 'c) Either.t) -> ('a, 'e) t -> ('b, 'e) t * ('c, 'e) t
val partition : ('a -> bool) -> ('a, 'e) t -> ('a, 'e) t * ('a, 'e) t
val is_empty : ('a, 'e) t -> (bool, 'e) mon
val uncons : ('a, 'e) t -> (('a * ('a, 'e) t) option, 'e) mon
val length : ('a, 'e) t -> (int, 'e) mon
val equal : ('a -> 'b -> bool) -> ('a, 'e) t -> ('b, 'e) t -> (bool, 'e) mon
val compare : ('a -> 'b -> int) -> ('a, 'e) t -> ('b, 'e) t -> (int, 'e) mon
val empty : ('a, 'e) t
val return : 'a -> ('a, 'e) t
val cons : 'a -> ('a, 'e) t -> ('a, 'e) t
val repeat : 'a -> ('a, 'e) t
val cycle : ('a, 'e) t -> ('a, 'e) t
val take : int -> ('a, 'e) t -> ('a, 'e) t
val drop : int -> ('a, 'e) t -> ('a, 'e) t
val memoize : ('a, 'e) t -> ('a, 'e) t
val once : ('a, 'e) t -> ('a, 'e) t
val transpose : (('a, 'e) t, 'e) t -> (('a, 'e) t, 'e) t
val append : ('a, 'e) t -> ('a, 'e) t -> ('a, 'e) t
val concat : (('a, 'e) t, 'e) t -> ('a, 'e) t
val flat_map : ('a -> ('b, 'e) t) -> ('a, 'e) t -> ('b, 'e) t
val concat_map : ('a -> ('b, 'e) t) -> ('a, 'e) t -> ('b, 'e) t
val zip : ('a, 'e) t -> ('b, 'e) t -> ('a * 'b, 'e) t
val interleave : ('a, 'e) t -> ('a, 'e) t -> ('a, 'e) t
val sorted_merge : ('a -> 'a -> int) -> ('a, 'e) t -> ('a, 'e) t -> ('a, 'e) t
val product : ('a, 'e) t -> ('b, 'e) t -> ('a * 'b, 'e) t
val unzip : ('a * 'b, 'e) t -> ('a, 'e) t * ('b, 'e) t
val split : ('a * 'b, 'e) t -> ('a, 'e) t * ('b, 'e) t
val of_dispenser : (unit -> ('a option, 'e) mon) -> ('a, 'e) t
val to_dispenser : ('a, 'e) t -> unit -> ('a option, 'e) mon
val ints : int -> (int, 'e) t
val of_seq : 'a Seq.t -> ('a, 'e) t
module M : sig ... end

M is a module which contains a specialised subset of the functions from the Stdlib.Seq module. Specifically, it contains those functions which take a function as parameter (e.g., map but not length). Moreover, those parameter functions' return type is specialised to be within the mon monad. E.g., given module SeqMon = Make2(Mon) then SeqMon.M.map has type ('a -> ('b, 'e) Mon.t) -> ('a, 'e) t -> ('b, 'e) t and SeqMon.M.iter has type ('a -> (unit, 'e) mon) -> ('a, 'e) t -> (unit, 'e) mon.

module Make (Alt : sig ... end) (Glue : sig ... end) : sig ... end

Make is a functor to produce further M-like modules, but with parameter functions returning into a different monad. E.g., given module SeqMon = Make(Mon) and module SeqMonMun = SeqMon.Make(Mun) then SeqMonMun.map has type ('a -> ('b, 'e) Mun.t) -> ('a, 'e) t -> ('b, 'e) t.

module MakeTraversors (Alt : sig ... end) (Ret : sig ... end) (GlueAlt : sig ... end) (GlueMon : sig ... end) : sig ... end

MakeTraversors is a functor similar to Make. It produces only a subset of the functions that Make does. Specifically, it produces the subset of functions that traverse a sequence (or part thereof) and return a value which is not a sequence (e.g., iter returning unit but not map returning a new sequence).

OCaml

Innovation. Community. Security.