package seqes

  1. Overview
  2. Docs

Module Monadic.Make1Source

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

Parameters

module Mon : sig ... end

Signature

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

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

Sourceand '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.

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

See Stdlib.Seq.of_seq

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

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

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