Small improvements in the organization of the API doc.

This commit is contained in:
Drup 2019-03-08 19:35:11 +01:00 committed by Simon Cruanes
parent 19b7f6a443
commit cb052da2c8
2 changed files with 43 additions and 29 deletions

View file

@ -39,12 +39,14 @@ type +'a t = ('a -> unit) -> unit
type +'a iter = 'a t type +'a iter = 'a t
(** {b NOTE} Type [('a, 'b) t2 = ('a -> 'b -> unit) -> unit] (** {b NOTE} Type [('a, 'b) t2 = ('a -> 'b -> unit) -> unit]
has been removed and subsumed by [('a * 'b) t] @since 1.0 *) has been removed and subsumed by [('a * 'b) t]
@since 1.0
*)
type 'a equal = 'a -> 'a -> bool type 'a equal = 'a -> 'a -> bool
type 'a hash = 'a -> int type 'a hash = 'a -> int
(** {2 Build an iterator} *) (** {2 Creation} *)
val from_iter : (('a -> unit) -> unit) -> 'a t val from_iter : (('a -> unit) -> unit) -> 'a t
(** Build an iterator from a iter function *) (** Build an iterator from a iter function *)
@ -101,7 +103,15 @@ val cycle : 'a t -> 'a t
infinite iterator, you should use something like {!take} not to loop infinite iterator, you should use something like {!take} not to loop
forever. *) forever. *)
(** {2 Consume an iterator} *) val unfoldr : ('b -> ('a * 'b) option) -> 'b -> 'a t
(** [unfoldr f b] will apply [f] to [b]. If it
yields [Some (x,b')] then [x] is returned
and unfoldr recurses with [b']. *)
val scan : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b t
(** Iterator of intermediate results *)
(** {2 Consumption} *)
val iter : ('a -> unit) -> 'a t -> unit val iter : ('a -> unit) -> 'a t -> unit
(** Consume the iterator, passing all its arguments to the function. (** Consume the iterator, passing all its arguments to the function.
@ -181,7 +191,7 @@ val length : 'a t -> int
val is_empty : 'a t -> bool val is_empty : 'a t -> bool
(** Is the iterator empty? Forces the iterator. *) (** Is the iterator empty? Forces the iterator. *)
(** {2 Transform an iterator} *) (** {2 Transformation} *)
val filter : ('a -> bool) -> 'a t -> 'a t val filter : ('a -> bool) -> 'a t -> 'a t
(** Filter on elements of the iterator *) (** Filter on elements of the iterator *)
@ -373,6 +383,8 @@ val group_join_by : ?eq:'a equal -> ?hash:'a hash ->
precondition: for any [x] and [y], if [eq x y] then [hash x=hash y] must hold. precondition: for any [x] and [y], if [eq x y] then [hash x=hash y] must hold.
@since 0.10 *) @since 0.10 *)
(** {3 Set-like} *)
val inter : val inter :
?eq:'a equal -> ?hash:'a hash -> ?eq:'a equal -> ?hash:'a hash ->
'a t -> 'a t -> 'a t 'a t -> 'a t -> 'a t
@ -420,13 +432,7 @@ val subset :
not (subset (1 -- 4) (2 -- 10)) not (subset (1 -- 4) (2 -- 10))
*) *)
val unfoldr : ('b -> ('a * 'b) option) -> 'b -> 'a t (** {3 Arithmetic} *)
(** [unfoldr f b] will apply [f] to [b]. If it
yields [Some (x,b')] then [x] is returned
and unfoldr recurses with [b']. *)
val scan : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b t
(** Iterator of intermediate results *)
val max : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option val max : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
(** Max element of the iterator, using the given comparison function. (** Max element of the iterator, using the given comparison function.
@ -455,6 +461,8 @@ val sumf : float t -> float
(** Sum of elements, using Kahan summation (** Sum of elements, using Kahan summation
@since 0.11 *) @since 0.11 *)
(** {3 List-like} *)
val head : 'a t -> 'a option val head : 'a t -> 'a option
(** First element, if any, otherwise [None] (** First element, if any, otherwise [None]
@since 0.5.1 *) @since 0.5.1 *)
@ -491,7 +499,9 @@ val rev : 'a t -> 'a t
val zip_i : 'a t -> (int * 'a) t val zip_i : 'a t -> (int * 'a) t
(** Zip elements of the iterator with their index in the iterator. (** Zip elements of the iterator with their index in the iterator.
Changed type @since 1.0 to just give an iterator of pairs *) @since 1.0 Changed type to just give an iterator of pairs *)
(** {3 Pair iterators} *)
val fold2 : ('c -> 'a -> 'b -> 'c) -> 'c -> ('a * 'b) t -> 'c val fold2 : ('c -> 'a -> 'b -> 'c) -> 'c -> ('a * 'b) t -> 'c
@ -502,7 +512,7 @@ val map2 : ('a -> 'b -> 'c) -> ('a * 'b) t -> 'c t
val map2_2 : ('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a * 'b) t -> ('c * 'd) t val map2_2 : ('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a * 'b) t -> ('c * 'd) t
(** [map2_2 f g seq2] maps each [x, y] of seq2 into [f x y, g x y] *) (** [map2_2 f g seq2] maps each [x, y] of seq2 into [f x y, g x y] *)
(** {2 Basic data structures converters} *) (** {2 Data structures converters} *)
val to_list : 'a t -> 'a list val to_list : 'a t -> 'a list
(** Convert the iterator into a list. Preserves order of elements. (** Convert the iterator into a list. Preserves order of elements.
@ -639,7 +649,7 @@ val of_klist : 'a klist -> 'a t
val to_klist : 'a t -> 'a klist val to_klist : 'a t -> 'a klist
(** Make the iterator persistent and then iterate on it. Eager. *) (** Make the iterator persistent and then iterate on it. Eager. *)
(** {2 Functorial conversions between sets and iterators} *) (** {3 Sets} *)
module Set : sig module Set : sig
module type S = sig module type S = sig
@ -663,7 +673,7 @@ module Set : sig
module Make(X : Set.OrderedType) : S with type elt = X.t module Make(X : Set.OrderedType) : S with type elt = X.t
end end
(** {2 Conversion between maps and iterators.} *) (** {3 Maps} *)
module Map : sig module Map : sig
module type S = sig module type S = sig
@ -689,7 +699,7 @@ module Map : sig
module Make(V : Map.OrderedType) : S with type key = V.t module Make(V : Map.OrderedType) : S with type key = V.t
end end
(** {2 Infinite iterators of random values} *) (** {2 Random iterators} *)
val random_int : int -> int t val random_int : int -> int t
(** Infinite iterator of random integers between 0 and (** Infinite iterator of random integers between 0 and
@ -720,7 +730,7 @@ val shuffle_buffer : int -> 'a t -> 'a t
rest is consumed lazily. rest is consumed lazily.
@since 0.7 *) @since 0.7 *)
(** {2 Sampling} *) (** {3 Sampling} *)
val sample : int -> 'a t -> 'a array val sample : int -> 'a t -> 'a array
(** [sample n seq] returns k samples of [seq], with uniform probability. (** [sample n seq] returns k samples of [seq], with uniform probability.
@ -760,7 +770,7 @@ end
include module type of Infix include module type of Infix
(** {2 Pretty printing of iterators} *) (** {2 Pretty printing} *)
val pp_seq : ?sep:string -> (Format.formatter -> 'a -> unit) -> val pp_seq : ?sep:string -> (Format.formatter -> 'a -> unit) ->
Format.formatter -> 'a t -> unit Format.formatter -> 'a t -> unit

View file

@ -15,12 +15,14 @@ type +'a t = ('a -> unit) -> unit
type +'a iter = 'a t type +'a iter = 'a t
(** {b NOTE} Type [('a, 'b) t2 = ('a -> 'b -> unit) -> unit] (** {b NOTE} Type [('a, 'b) t2 = ('a -> 'b -> unit) -> unit]
has been removed and subsumed by [('a * 'b) t] @since 1.0 *) has been removed and subsumed by [('a * 'b) t]
@since 1.0
*)
type 'a equal = 'a -> 'a -> bool type 'a equal = 'a -> 'a -> bool
type 'a hash = 'a -> int type 'a hash = 'a -> int
(** {2 Build an iterator} *) (** {2 Creation} *)
val from_iter : (('a -> unit) -> unit) -> 'a t val from_iter : (('a -> unit) -> unit) -> 'a t
(** Build an iterator from a iter function *) (** Build an iterator from a iter function *)
@ -77,7 +79,7 @@ val cycle : 'a t -> 'a t
infinite iterator, you should use something like {!take} not to loop infinite iterator, you should use something like {!take} not to loop
forever. *) forever. *)
(** {2 Consume an iterator} *) (** {2 Consumption} *)
val iter : f:('a -> unit) -> 'a t -> unit val iter : f:('a -> unit) -> 'a t -> unit
(** Consume the iterator, passing all its arguments to the function. (** Consume the iterator, passing all its arguments to the function.
@ -157,7 +159,8 @@ val length : 'a t -> int
val is_empty : 'a t -> bool val is_empty : 'a t -> bool
(** Is the iterator empty? Forces the iterator. *) (** Is the iterator empty? Forces the iterator. *)
(** {2 Transform an iterator} *)
(** {2 Transformation} *)
val filter : f:('a -> bool) -> 'a t -> 'a t val filter : f:('a -> bool) -> 'a t -> 'a t
(** Filter on elements of the iterator *) (** Filter on elements of the iterator *)
@ -462,7 +465,7 @@ val rev : 'a t -> 'a t
val zip_i : 'a t -> (int * 'a) t val zip_i : 'a t -> (int * 'a) t
(** Zip elements of the iterator with their index in the iterator. (** Zip elements of the iterator with their index in the iterator.
Changed type @since 1.0 to just give an iterator of pairs *) @since 1.0 Changed type to just give an iterator of pairs *)
val fold2 : f:('c -> 'a -> 'b -> 'c) -> init:'c -> ('a * 'b) t -> 'c val fold2 : f:('c -> 'a -> 'b -> 'c) -> init:'c -> ('a * 'b) t -> 'c
@ -473,7 +476,8 @@ val map2 : f:('a -> 'b -> 'c) -> ('a * 'b) t -> 'c t
val map2_2 : f:('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a * 'b) t -> ('c * 'd) t val map2_2 : f:('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a * 'b) t -> ('c * 'd) t
(** [map2_2 f g seq2] maps each [x, y] of seq2 into [f x y, g x y] *) (** [map2_2 f g seq2] maps each [x, y] of seq2 into [f x y, g x y] *)
(** {2 Basic data structures converters} *)
(** {2 Data structures converters} *)
val to_list : 'a t -> 'a list val to_list : 'a t -> 'a list
(** Convert the iterator into a list. Preserves order of elements. (** Convert the iterator into a list. Preserves order of elements.
@ -611,7 +615,7 @@ val of_klist : 'a klist -> 'a t
val to_klist : 'a t -> 'a klist val to_klist : 'a t -> 'a klist
(** Make the iterator persistent and then iterate on it. Eager. *) (** Make the iterator persistent and then iterate on it. Eager. *)
(** {2 Functorial conversions between sets and iterators} *) (** {3 Sets} *)
module Set : sig module Set : sig
module type S = sig module type S = sig
@ -635,7 +639,7 @@ module Set : sig
module Make(X : Set.OrderedType) : S with type elt = X.t module Make(X : Set.OrderedType) : S with type elt = X.t
end end
(** {2 Conversion between maps and iterators.} *) (** {3 Maps} *)
module Map : sig module Map : sig
module type S = sig module type S = sig
@ -661,7 +665,7 @@ module Map : sig
module Make(V : Map.OrderedType) : S with type key = V.t module Make(V : Map.OrderedType) : S with type key = V.t
end end
(** {2 Infinite iterators of random values} *) (** {2 Random iterators} *)
val random_int : int -> int t val random_int : int -> int t
(** Infinite iterator of random integers between 0 and (** Infinite iterator of random integers between 0 and
@ -692,7 +696,7 @@ val shuffle_buffer : n:int -> 'a t -> 'a t
rest is consumed lazily. rest is consumed lazily.
@since 0.7 *) @since 0.7 *)
(** {2 Sampling} *) (** {3 Sampling} *)
val sample : n:int -> 'a t -> 'a array val sample : n:int -> 'a t -> 'a array
(** [sample n seq] returns k samples of [seq], with uniform probability. (** [sample n seq] returns k samples of [seq], with uniform probability.
@ -732,7 +736,7 @@ end
include module type of Infix include module type of Infix
(** {2 Pretty printing of iterators} *) (** {2 Pretty printing} *)
val pp_seq : ?sep:string -> (Format.formatter -> 'a -> unit) -> val pp_seq : ?sep:string -> (Format.formatter -> 'a -> unit) ->
Format.formatter -> 'a t -> unit Format.formatter -> 'a t -> unit