package seqes

  1. Overview
  2. Docs

Module Monadic.Make2Source

Parameters

module Mon : sig ... end

Signature

Sourcetype ('a, 'e) t = unit -> (('a, 'e) node, 'e) Mon.t

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

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

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

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, 'e) Mun.t) -> ('a, 'e) t -> ('b, 'e) 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).

OCaml

Innovation. Community. Security.