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.

Any monad that we can use to produce transformers, we can also use to produce traversors. Thus, SEQMON1TRANSFORMERS includes SEQMON1TRAVERSORS and all the functors producing transformer also produce traversors.

val iter : ('a -> unit) -> 'a t -> unit Mon.t

See Stdlib.Seq.iter

val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a Mon.t

See Stdlib.Seq.fold_left

val iteri : (int -> 'a -> unit) -> 'a t -> unit Mon.t

See Stdlib.Seq.iteri

val fold_lefti : ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b Mon.t

See Stdlib.Seq.fold_lefti

val for_all : ('a -> bool) -> 'a t -> bool Mon.t

See Stdlib.Seq.for_all

val exists : ('a -> bool) -> 'a t -> bool Mon.t

See Stdlib.Seq.exists

val find : ('a -> bool) -> 'a t -> 'a option Mon.t

See Stdlib.Seq.find

val find_map : ('a -> 'b option) -> 'a t -> 'b option Mon.t

See Stdlib.Seq.find_map

val iter2 : ('a -> 'b -> unit) -> 'a t -> 'b t -> unit Mon.t

See Stdlib.Seq.iter2

val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b t -> 'c t -> 'a Mon.t

See Stdlib.Seq.fold_left2

val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool Mon.t

See Stdlib.Seq.for_all2

val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool Mon.t

See Stdlib.Seq.exists2

val init : int -> (int -> 'a) -> 'a t

See Stdlib.Seq.init

val unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t

See Stdlib.Seq.unfold

val forever : (unit -> 'a) -> 'a t

See Stdlib.Seq.forever

val iterate : ('a -> 'a) -> 'a -> 'a t

See Stdlib.Seq.iterate

val map : ('a -> 'b) -> 'a t -> 'b t

See Stdlib.Seq.map

val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t

See Stdlib.Seq.mapi

val filter : ('a -> bool) -> 'a t -> 'a t

See Stdlib.Seq.filter

val filter_map : ('a -> 'b option) -> 'a t -> 'b t

See Stdlib.Seq.filter_map

val scan : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b t

See Stdlib.Seq.scan

val take_while : ('a -> bool) -> 'a t -> 'a t

See Stdlib.Seq.take_while

val drop_while : ('a -> bool) -> 'a t -> 'a t

See Stdlib.Seq.drop_while

val group : ('a -> 'a -> bool) -> 'a t -> 'a t t

See Stdlib.Seq.group

val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

See Stdlib.Seq.map2

val map_product : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

See Stdlib.Seq.map_product

val partition_map : ('a -> ('b, 'c) Stdlib.Either.t) -> 'a t -> 'b t * 'c t

See Stdlib.Seq.partition_map

val partition : ('a -> bool) -> 'a t -> 'a t * 'a t

See Stdlib.Seq.partition

val is_empty : 'a t -> bool Mon.t

See Stdlib.Seq.is_empty

val uncons : 'a t -> ('a * 'a t) option Mon.t

See Stdlib.Seq.uncons

val length : 'a t -> int Mon.t

See Stdlib.Seq.length

val equal : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool Mon.t

See Stdlib.Seq.equal

val compare : ('a -> 'b -> int) -> 'a t -> 'b t -> int Mon.t

See Stdlib.Seq.compare

val empty : 'a t

See Stdlib.Seq.empty

val return : 'a -> 'a t

See Stdlib.Seq.return

val cons : 'a -> 'a t -> 'a t

See Stdlib.Seq.cons

val repeat : 'a -> 'a t

See Stdlib.Seq.repeat

val cycle : 'a t -> 'a t

See Stdlib.Seq.cycle

val take : int -> 'a t -> 'a t

See Stdlib.Seq.take

val drop : int -> 'a t -> 'a t

See Stdlib.Seq.drop

val memoize : 'a t -> 'a t

See Stdlib.Seq.memoize

val once : 'a t -> 'a t

See Stdlib.Seq.once

val transpose : 'a t t -> 'a t t

See Stdlib.Seq.transpose

val append : 'a t -> 'a t -> 'a t

See Stdlib.Seq.append

val concat : 'a t t -> 'a t

See Stdlib.Seq.concat

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

See Stdlib.Seq.flat_map

val concat_map : ('a -> 'b t) -> 'a t -> 'b t

See Stdlib.Seq.concat_map

val zip : 'a t -> 'b t -> ('a * 'b) t

See Stdlib.Seq.zip

val interleave : 'a t -> 'a t -> 'a t

See Stdlib.Seq.interleave

val sorted_merge : ('a -> 'a -> int) -> 'a t -> 'a t -> 'a t

See Stdlib.Seq.sorted_merge

val product : 'a t -> 'b t -> ('a * 'b) t

See Stdlib.Seq.product

val unzip : ('a * 'b) t -> 'a t * 'b t

See Stdlib.Seq.unzip

val split : ('a * 'b) t -> 'a t * 'b t

See Stdlib.Seq.split

val of_dispenser : (unit -> 'a option Mon.t) -> 'a t

See Stdlib.Seq.of_dispenser

val to_dispenser : 'a t -> unit -> 'a option Mon.t

See Stdlib.Seq.to_dispenser

val ints : int -> int t

See Stdlib.Seq.ints

val of_seq : 'a Stdlib.Seq.t -> 'a t

See Stdlib.Seq.of_seq

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).