package seqes

  1. Overview
  2. Docs

Make a specialised Seq-like module based on a given Monad.

Parameters

module Mon : sig ... end

Signature

type 'a t = unit -> 'a node Mon.t

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

and 'a node =
  1. | Nil
  2. | Cons of 'a * 'a t

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

See the documentation of Sigs1.SEQMON1ALL for more details.

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

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

MakeTraversors2 is a functor similar to MakeTraversors but for a two-parameter monad.