Move the examples of labeled functions to StdLabels (#9976)
In the old days, the interfaces of the labeled modules (ArrayLabels, BytesLabels, ListLabels, StringLabels) started with short examples of labelings. Now, the interfaces of the non-labeled modules (Array, Bytes, List, String) are automatically generated from the interfaces of the labeled modules. As a side effect, the interfaces of Array, Bytes, List and String also start with short examples of labelings, which is somewhat strange. This commit reorganizes the documentation as follows: - The documentation of the StdLabels module is expanded, and includes the examples of labeled functions previously scattered in ArrayLabels, BytesLabels, ListLabels, StringLabels. - Array, Bytes, List, String and their labeled counterparts briefly mention the labeled modules and point to StdLabels, but no longer contain examples.master
parent
9fdc759ac0
commit
8b7ff3532c
|
@ -23,16 +23,9 @@
|
||||||
|
|
||||||
(** Array operations.
|
(** Array operations.
|
||||||
|
|
||||||
The labeled version of this module, {!ArrayLabels}, is intended to be used
|
The labeled version of this module can be used as described in the
|
||||||
via {!StdLabels} which replaces {!Array}, {!Bytes}, {!List} and {!String}
|
{!StdLabels} module.
|
||||||
with their labeled counterparts
|
*)
|
||||||
|
|
||||||
For example:
|
|
||||||
{[
|
|
||||||
open StdLabels
|
|
||||||
|
|
||||||
let everything = Array.create_matrix ~dimx:42 ~dimy:42 42
|
|
||||||
]} *)
|
|
||||||
|
|
||||||
type 'a t = 'a array
|
type 'a t = 'a array
|
||||||
(** An alias for the type of arrays. *)
|
(** An alias for the type of arrays. *)
|
||||||
|
|
|
@ -23,16 +23,9 @@
|
||||||
|
|
||||||
(** Array operations.
|
(** Array operations.
|
||||||
|
|
||||||
The labeled version of this module, {!ArrayLabels}, is intended to be used
|
The labeled version of this module can be used as described in the
|
||||||
via {!StdLabels} which replaces {!Array}, {!Bytes}, {!List} and {!String}
|
{!StdLabels} module.
|
||||||
with their labeled counterparts
|
*)
|
||||||
|
|
||||||
For example:
|
|
||||||
{[
|
|
||||||
open StdLabels
|
|
||||||
|
|
||||||
let everything = Array.create_matrix ~dimx:42 ~dimy:42 42
|
|
||||||
]} *)
|
|
||||||
|
|
||||||
type 'a t = 'a array
|
type 'a t = 'a array
|
||||||
(** An alias for the type of arrays. *)
|
(** An alias for the type of arrays. *)
|
||||||
|
|
|
@ -47,16 +47,8 @@
|
||||||
|
|
||||||
Bytes are represented by the OCaml type [char].
|
Bytes are represented by the OCaml type [char].
|
||||||
|
|
||||||
The labeled version of this module, {!BytesLabels}, is intended to be used
|
The labeled version of this module can be used as described in the
|
||||||
through {!StdLabels} which replaces {!Array}, {!Bytes}, {!List} and
|
{!StdLabels} module.
|
||||||
{!String} with their labeled counterparts.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
{[
|
|
||||||
open StdLabels
|
|
||||||
|
|
||||||
let first = Bytes.sub ~pos:0 ~len:1
|
|
||||||
]}
|
|
||||||
|
|
||||||
@since 4.02.0
|
@since 4.02.0
|
||||||
|
|
||||||
|
|
|
@ -47,16 +47,8 @@
|
||||||
|
|
||||||
Bytes are represented by the OCaml type [char].
|
Bytes are represented by the OCaml type [char].
|
||||||
|
|
||||||
The labeled version of this module, {!BytesLabels}, is intended to be used
|
The labeled version of this module can be used as described in the
|
||||||
through {!StdLabels} which replaces {!Array}, {!Bytes}, {!List} and
|
{!StdLabels} module.
|
||||||
{!String} with their labeled counterparts.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
{[
|
|
||||||
open StdLabels
|
|
||||||
|
|
||||||
let first = Bytes.sub ~pos:0 ~len:1
|
|
||||||
]}
|
|
||||||
|
|
||||||
@since 4.02.0
|
@since 4.02.0
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,8 @@
|
||||||
The above considerations can usually be ignored if your lists are not
|
The above considerations can usually be ignored if your lists are not
|
||||||
longer than about 10000 elements.
|
longer than about 10000 elements.
|
||||||
|
|
||||||
The labeled version of this module, {!ListLabels}, is intended to be used
|
The labeled version of this module can be used as described in the
|
||||||
through {!StdLabels} which replaces {!Array}, {!Bytes}, {!List} and
|
{!StdLabels} module.
|
||||||
{!String} with their labeled counterparts.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
{[
|
|
||||||
open StdLabels
|
|
||||||
|
|
||||||
let seq len = List.init ~f:(function i -> i) ~len
|
|
||||||
]}
|
|
||||||
*)
|
*)
|
||||||
|
|
||||||
type 'a t = 'a list = [] | (::) of 'a * 'a list (**)
|
type 'a t = 'a list = [] | (::) of 'a * 'a list (**)
|
||||||
|
|
|
@ -33,16 +33,8 @@
|
||||||
The above considerations can usually be ignored if your lists are not
|
The above considerations can usually be ignored if your lists are not
|
||||||
longer than about 10000 elements.
|
longer than about 10000 elements.
|
||||||
|
|
||||||
The labeled version of this module, {!ListLabels}, is intended to be used
|
The labeled version of this module can be used as described in the
|
||||||
through {!StdLabels} which replaces {!Array}, {!Bytes}, {!List} and
|
{!StdLabels} module.
|
||||||
{!String} with their labeled counterparts.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
{[
|
|
||||||
open StdLabels
|
|
||||||
|
|
||||||
let seq len = List.init ~f:(function i -> i) ~len
|
|
||||||
]}
|
|
||||||
*)
|
*)
|
||||||
|
|
||||||
type 'a t = 'a list = [] | (::) of 'a * 'a list (**)
|
type 'a t = 'a list = [] | (::) of 'a * 'a list (**)
|
||||||
|
|
|
@ -15,12 +15,21 @@
|
||||||
|
|
||||||
(** Standard labeled libraries.
|
(** Standard labeled libraries.
|
||||||
|
|
||||||
This meta-module provides labelized version of the {!Array},
|
This meta-module provides versions of the {!Array}, {!Bytes},
|
||||||
{!Bytes}, {!List} and {!String} modules.
|
{!List} and {!String} modules where function arguments are
|
||||||
|
systematically labeled. It is intended to be opened at the top of
|
||||||
|
source files, as shown below.
|
||||||
|
|
||||||
They only differ by their labels. Detailed interfaces can be found
|
{[
|
||||||
in [arrayLabels.mli], [bytesLabels.mli], [listLabels.mli]
|
open StdLabels
|
||||||
and [stringLabels.mli].
|
|
||||||
|
let to_upper = String.map ~f:Char.uppercase_ascii
|
||||||
|
let seq len = List.init ~f:(function i -> i) ~len
|
||||||
|
let everything = Array.create_matrix ~dimx:42 ~dimy:42 42
|
||||||
|
]}
|
||||||
|
|
||||||
|
Detailed interfaces documenting the function argument labels can be found
|
||||||
|
at {!ArrayLabels}, {!BytesLabels}, {!ListLabels} and {!StringLabels}.
|
||||||
*)
|
*)
|
||||||
|
|
||||||
module Array = ArrayLabels
|
module Array = ArrayLabels
|
||||||
|
|
|
@ -73,17 +73,9 @@ v}
|
||||||
default until OCaml 4.05. Starting with 4.06, the compatibility
|
default until OCaml 4.05. Starting with 4.06, the compatibility
|
||||||
mode is opt-in; we intend to remove the option in the future.
|
mode is opt-in; we intend to remove the option in the future.
|
||||||
|
|
||||||
|
The labeled version of this module can be used as described in the
|
||||||
The labeled version of this module, {!StringLabels}, is intended to be used
|
{!StdLabels} module.
|
||||||
through {!StdLabels} which replaces {!Array}, {!Bytes}, {!List} and
|
*)
|
||||||
{!String} with their labeled counterparts
|
|
||||||
|
|
||||||
For example:
|
|
||||||
{[
|
|
||||||
open StdLabels
|
|
||||||
|
|
||||||
let to_upper = String.map ~f:Char.uppercase_ascii
|
|
||||||
]} *)
|
|
||||||
|
|
||||||
(** {1:strings Strings} *)
|
(** {1:strings Strings} *)
|
||||||
|
|
||||||
|
|
|
@ -73,17 +73,9 @@ v}
|
||||||
default until OCaml 4.05. Starting with 4.06, the compatibility
|
default until OCaml 4.05. Starting with 4.06, the compatibility
|
||||||
mode is opt-in; we intend to remove the option in the future.
|
mode is opt-in; we intend to remove the option in the future.
|
||||||
|
|
||||||
|
The labeled version of this module can be used as described in the
|
||||||
The labeled version of this module, {!StringLabels}, is intended to be used
|
{!StdLabels} module.
|
||||||
through {!StdLabels} which replaces {!Array}, {!Bytes}, {!List} and
|
*)
|
||||||
{!String} with their labeled counterparts
|
|
||||||
|
|
||||||
For example:
|
|
||||||
{[
|
|
||||||
open StdLabels
|
|
||||||
|
|
||||||
let to_upper = String.map ~f:Char.uppercase_ascii
|
|
||||||
]} *)
|
|
||||||
|
|
||||||
(** {1:strings Strings} *)
|
(** {1:strings Strings} *)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue