diff --git a/sig-builder-no-typ-dup/less-power/Ast_check/Feature/index.html b/sig-builder-no-typ-dup/less-power/Ast_check/Feature/index.html index 2d36511..aacd331 100644 --- a/sig-builder-no-typ-dup/less-power/Ast_check/Feature/index.html +++ b/sig-builder-no-typ-dup/less-power/Ast_check/Feature/index.html @@ -1,2 +1,2 @@ -
Ast_check.Feature
val to_identifier : t -> string
Unique identifier for this feature.
val of_identifier : string -> t
Provides the feature corresponding to a unique identifier returned by to_identifier
.
Primitive
and Internal_name
, required to prevent circumventing restrictions.
Everything but Tail_mod_cons
.
val to_message : t -> string
Provide a message explaining why a feature is prohibited.
Ast_check.Feature
val to_identifier : t -> string
Unique identifier for this feature.
val of_identifier : string -> t
Provides the feature corresponding to a unique identifier returned by to_identifier
.
Primitive
and Internal_name
, required to prevent circumventing restrictions.
Everything but Tail_mod_cons
.
val to_message : t -> string
Provide a message explaining why a feature is prohibited.
Ast_check
AST checker.
Tool to enforce restrictions on what syntax elements are allowed in OCaml code. Restricts use of the following class features and imperative elements:
while
loopsfor
loopsexternal
declarationsPackage__Module
)external
declarations and internal dune modules are forbidden, as they can be used to circumvent restrictions in the Stdlib
replacement. The sequence operator is not forbidden as there would be no point, a; b
can be trivially replaced by let _ = a in b
.
An executable is installed as lp-ast-check
. All files passed as arguments, and all .ml
files contained recursively in directories passed as arguments, are checked. Exits with code 0
if no violations are detected, 1
if violations are found, or 2
if an error occurs.
module Feature : sig ... end
type violation = {
location : Ppxlib.Location.t;
Location of the violation.
*)message : string option;
Error message.
*)feature : Feature.t;
Which prohibited feature was used.
*)}
A violation that occurred in the AST.
val ast_violations :
+Ast_check (less-power.Ast_check) Module Ast_check
AST checker.
Tool to enforce restrictions on what syntax elements are allowed in OCaml code. Restricts use of the following class features and imperative elements:
- class declarations
- class type declarations
- class method calls
- new class expressions
- setting class and record fields
- array literals
while
loopsfor
loops- declaring records with mutable entries
external
declarations- internal dune modules (
Package__Module
)
external
declarations and internal dune modules are forbidden, as they can be used to circumvent restrictions in the Stdlib
replacement. The sequence operator is not forbidden as there would be no point, a; b
can be trivially replaced by let _ = a in b
.
An executable is installed as lp-ast-check
. All files passed as arguments, and all .ml
files contained recursively in directories passed as arguments, are checked. Exits with code 0
if no violations are detected, 1
if violations are found, or 2
if an error occurs.
module Feature : sig ... end
type violation = {
location : Ppxlib.Location.t;
(*Location of the violation.
*)message : string option;
(*Error message.
*)feature : Feature.t;
(*Which prohibited feature was used.
*)
}
A violation that occurred in the AST.
val ast_violations :
?prohibited:Feature.Set.t ->
?limit:int ->
Ppxlib.structure ->
diff --git a/sig-builder-no-typ-dup/less-power/Ast_check_ppx/index.html b/sig-builder-no-typ-dup/less-power/Ast_check_ppx/index.html
index 6825878..fc85677 100644
--- a/sig-builder-no-typ-dup/less-power/Ast_check_ppx/index.html
+++ b/sig-builder-no-typ-dup/less-power/Ast_check_ppx/index.html
@@ -1,2 +1,2 @@
-Ast_check_ppx (less-power.Ast_check_ppx) Module Ast_check_ppx
Use the AST check as a PPX rewriter, with arguments. If further customization is needed, it's best to define a PPX directly in the given exercise's repository instead.
+Ast_check_ppx (less-power.Ast_check_ppx) Module Ast_check_ppx
Use the AST check as a PPX rewriter, with arguments. If further customization is needed, it's best to define a PPX directly in the given exercise's repository instead.
diff --git a/sig-builder-no-typ-dup/less-power/Common/Ctx_util/Syntax/index.html b/sig-builder-no-typ-dup/less-power/Common/Ctx_util/Syntax/index.html
index 0c0a3f7..1786754 100644
--- a/sig-builder-no-typ-dup/less-power/Common/Ctx_util/Syntax/index.html
+++ b/sig-builder-no-typ-dup/less-power/Common/Ctx_util/Syntax/index.html
@@ -1,2 +1,2 @@
-Syntax (less-power.Common.Ctx_util.Syntax) Module Ctx_util.Syntax
val let< : ('a, 'b, 'c) t -> ('a -> 'b) -> 'c
Let-syntax for with_context
+Syntax (less-power.Common.Ctx_util.Syntax) Module Ctx_util.Syntax
val let< : ('a, 'b, 'c) t -> ('a -> 'b) -> 'c
Let-syntax for with_context
diff --git a/sig-builder-no-typ-dup/less-power/Common/Ctx_util/index.html b/sig-builder-no-typ-dup/less-power/Common/Ctx_util/index.html
index a904361..e67799e 100644
--- a/sig-builder-no-typ-dup/less-power/Common/Ctx_util/index.html
+++ b/sig-builder-no-typ-dup/less-power/Common/Ctx_util/index.html
@@ -1,19 +1,19 @@
-Ctx_util (less-power.Common.Ctx_util) Module Common.Ctx_util
Context managers, loosely inspired by Python
type ('a, 'b, 'c) t =
+Ctx_util (less-power.Common.Ctx_util) Module Common.Ctx_util
Context managers, loosely inspired by Python
type ('a, 'b, 'c) t =
('a -> ('b, Util.exn_info) Stdlib.result) ->
- ('c, Util.exn_info) Stdlib.result
A context manager of type ('a, 'b, 'c) t
takes a continuation, and should feed the continuation a value of type 'a
. Once the continuation returns with either a 'b
(in Ok
) or an exn_info
(in Error
), the continuation should perform cleanup, and may suppress the exception by producing a suitable result (of type 'c
) instead. Often, 'b = 'c
.
This representation has the advantage that existing context managers of type ('a -> 'b) -> 'b
(where 'a
can be some concrete type like unit
) already conform to this type (e.g. In_channel.with_open_text
and Mutex.protect
).
val with_context : ('a, 'b, 'c) t -> ('d -> 'e) -> 'f
with_context cm f
runs f
in the context manager cm
module Syntax : sig ... end
val temp_file : ?temp_dir:string -> string -> string -> (string, 'a, 'b) t
As per Filename.temp_file
. Removes the temporary file upon completion.
val openfile :
+ ('c, Util.exn_info) Stdlib.result
A context manager of type ('a, 'b, 'c) t
takes a continuation, and should feed the continuation a value of type 'a
. Once the continuation returns with either a 'b
(in Ok
) or an exn_info
(in Error
), the continuation should perform cleanup, and may suppress the exception by producing a suitable result (of type 'c
) instead. Often, 'b = 'c
.
This representation has the advantage that existing context managers of type ('a -> 'b) -> 'b
(where 'a
can be some concrete type like unit
) already conform to this type (e.g. In_channel.with_open_text
and Mutex.protect
).
val with_context : ('a, 'b, 'c) t -> ('a -> 'b) -> 'c
with_context cm f
runs f
in the context manager cm
module Syntax : sig ... end
val temp_file : ?temp_dir:string -> string -> string -> (string, 'a, 'a) t
As per Filename.temp_file
. Removes the temporary file upon completion.
val openfile :
string ->
Unix.open_flag list ->
Unix.file_perm ->
- (Unix.file_descr, 'a, 'b) t
As per Unix.openfile
. Closes the file descriptor upon completion.
val set_signal : int -> Stdlib.Sys.signal_behavior -> (unit, 'a, 'b) t
As per Sys.set_signal
. Restores the previous signal behavior on completion.
val sigprocmask : Unix.sigprocmask_command -> int list -> (unit, 'a, 'b) t
As per Unix.sigprocmask
. Restores the previous mask on completion.
val timeout_unix :
+ (Unix.file_descr, 'a, 'a) t
As per Unix.openfile
. Closes the file descriptor upon completion.
val set_signal : int -> Stdlib.Sys.signal_behavior -> (unit, 'a, 'a) t
As per Sys.set_signal
. Restores the previous signal behavior on completion.
val sigprocmask : Unix.sigprocmask_command -> int list -> (unit, 'a, 'a) t
As per Unix.sigprocmask
. Restores the previous mask on completion.
val timeout_unix :
?timer:Unix.interval_timer ->
Mtime.span ->
- (unit, 'a, 'b option) t
val timed : (unit, 'a, 'b * Mtime.span) t
val capture_exceptions :
+ (unit, 'a, 'a option) t
val timed : (unit, 'a, 'a * Mtime.span) t
val capture_exceptions :
?filter:(exn -> bool) ->
unit ->
- (unit, 'a, ('b, Util.exn_info) Stdlib.result) t
val empty_context : 'a -> ('b -> 'c) -> ('d, 'e, 'f) t
val empty_context' : 'a -> ('b, 'c, 'd) t
val optional_context :
+ (unit, 'a, ('a, Util.exn_info) Stdlib.result) t
val empty_context : 'a -> ('b -> 'c) -> ('a, 'b, 'c) t
val empty_context' : 'a -> ('a, 'b, 'b) t
val optional_timeout_unix : ?timeout:Mtime.span -> (unit, 'a, 'b option) t
+ 'a option ->
+ ('b, 'c, 'd) t
val optional_timeout_unix : ?timeout:Mtime.span -> (unit, 'a, 'a option) t
diff --git a/sig-builder-no-typ-dup/less-power/Common/P_run/index.html b/sig-builder-no-typ-dup/less-power/Common/P_run/index.html
index 3fd7773..0aa569e 100644
--- a/sig-builder-no-typ-dup/less-power/Common/P_run/index.html
+++ b/sig-builder-no-typ-dup/less-power/Common/P_run/index.html
@@ -1,5 +1,5 @@
-P_run (less-power.Common.P_run) Module Common.P_run
Even higher-level wrapper around Unix.open_process
.
Waits for the given process or times out.
Timeout after duration
, sending signal
. If kill_after
is Some t
, then send SIGKILL
after waiting an additional t
.
val timeout :
+P_run (less-power.Common.P_run) Module Common.P_run
Even higher-level wrapper around Unix.open_process
.
Waits for the given process or times out.
Timeout after duration
, sending signal
. If kill_after
is Some t
, then send SIGKILL
after waiting an additional t
.
val timeout :
?signal:int ->
?kill_after:Mtime.span ->
Mtime.span ->
diff --git a/sig-builder-no-typ-dup/less-power/Common/Path_util/index.html b/sig-builder-no-typ-dup/less-power/Common/Path_util/index.html
index f6408f5..98f5cc2 100644
--- a/sig-builder-no-typ-dup/less-power/Common/Path_util/index.html
+++ b/sig-builder-no-typ-dup/less-power/Common/Path_util/index.html
@@ -1,5 +1,5 @@
-Path_util (less-power.Common.Path_util) Module Common.Path_util
Path and file-related utility functions.
like Sys.readdir
, but the returned entries are full paths
Checks that either p
is a regular file and condition
holds for it, or p
is a symlink to a regular file, and condition
holds for the symlink.
val mkdir :
+Path_util (less-power.Common.Path_util) Module Common.Path_util
Path and file-related utility functions.
like Sys.readdir
, but the returned entries are full paths
Checks that either p
is a regular file and condition
holds for it, or p
is a symlink to a regular file, and condition
holds for the symlink.
val mkdir :
?mode:Unix.file_perm ->
?parents:bool ->
?exist_ok:bool ->
diff --git a/sig-builder-no-typ-dup/less-power/Common/Pp_util/index.html b/sig-builder-no-typ-dup/less-power/Common/Pp_util/index.html
index 32fc71c..8b3340d 100644
--- a/sig-builder-no-typ-dup/less-power/Common/Pp_util/index.html
+++ b/sig-builder-no-typ-dup/less-power/Common/Pp_util/index.html
@@ -1,2 +1,2 @@
-Pp_util (less-power.Common.Pp_util) Module Common.Pp_util
More pretty-printing combinators.
+Pp_util (less-power.Common.Pp_util) Module Common.Pp_util
More pretty-printing combinators.
diff --git a/sig-builder-no-typ-dup/less-power/Common/Util/index.html b/sig-builder-no-typ-dup/less-power/Common/Util/index.html
index 80de3f5..e23694f 100644
--- a/sig-builder-no-typ-dup/less-power/Common/Util/index.html
+++ b/sig-builder-no-typ-dup/less-power/Common/Util/index.html
@@ -1,5 +1,5 @@
-Util (less-power.Common.Util) Module Common.Util
Various utility functions.
Same as List.equal
, but allows lists of different types
string_contains ~needle haystack
: does needle
exist as a substring of haystack
? Naive \mathcal{O}(nm)
implementation.
(~$ x) f
is f x
, e.g.: List.map (~$ 2) [List.nth ["a"; "b"; "c"]; String.sub "def" 1]
returns ["c"; "ef"]
Exception and its associated (raw) backtrace.
val raise_exn_info : exn_info -> 'a
val try_to_result : ('a -> 'b) -> 'c -> ('d, exn_info) Stdlib.result
val unresult_exn : ('a, exn_info) Stdlib.result -> 'b
Timeouts
val timeout_unix :
+Module Common.Util
Various utility functions.
Same as List.equal
, but allows lists of different types
string_contains ~needle haystack
: does needle
exist as a substring of haystack
? Naive \mathcal{O}(nm)
implementation.
(~$ x) f
is f x
, e.g.: List.map (~$ 2) [List.nth ["a"; "b"; "c"]; String.sub "def" 1]
returns ["c"; "ef"]
Exception and its associated (raw) backtrace.
val raise_exn_info : exn_info -> 'a
val try_to_result : ('a -> 'b) -> 'a -> ('b, exn_info) Stdlib.result
val unresult_exn : ('a, exn_info) Stdlib.result -> 'a
Timeouts
timeout_unix t f
is Some (f ())
if the call to f
terminates within t
, otherwise None
. The timeout is triggered by a Unix signal.
Notes:
-
Does not interrupt f
until an allocation occurs, which may be never.-
Any existing Unix timer is suspended for the duration of the call to f
.+
If f
is interrupted, it will not be left running in the background.
+ 'a ->
+ 'b option
timeout_unix t f
is Some (f ())
if the call to f
terminates within t
, otherwise None
. The timeout is triggered by a Unix signal.
Notes:
-
Does not interrupt f
until an allocation occurs, which may be never.-
Any existing Unix timer is suspended for the duration of the call to f
.+
If f
is interrupted, it will not be left running in the background.
diff --git a/sig-builder-no-typ-dup/less-power/Common/index.html b/sig-builder-no-typ-dup/less-power/Common/index.html
index b49d7c9..ae7321f 100644
--- a/sig-builder-no-typ-dup/less-power/Common/index.html
+++ b/sig-builder-no-typ-dup/less-power/Common/index.html
@@ -1,5 +1,5 @@
-Common (less-power.Common) Module Signature_builder.Ordered_set
val eval : ?eq:('a -> 'b -> bool) -> 'b list -> 'c t -> 'b list
+Ordered_set (less-power.Signature_builder.Ordered_set) Module Signature_builder.Ordered_set
val eval : ?eq:('a -> 'a -> bool) -> 'a list -> 'a t -> 'a list
diff --git a/sig-builder-no-typ-dup/less-power/Signature_builder/Parse/index.html b/sig-builder-no-typ-dup/less-power/Signature_builder/Parse/index.html
index 782aa47..8d172c9 100644
--- a/sig-builder-no-typ-dup/less-power/Signature_builder/Parse/index.html
+++ b/sig-builder-no-typ-dup/less-power/Signature_builder/Parse/index.html
@@ -1,5 +1,5 @@
-Parse (less-power.Signature_builder.Parse) Module Signature_builder.Parse
Parser for include specifications.
To use the signature builder, first enable the PPX rewriter. With dune, add the PPX rewriter to your component's dune
file:
(preprocess (pps less-power.signature-builder-ppx))
Then, within a signature, use an extension point to include signature items, for example:
module type Foo : sig
+Parse (less-power.Signature_builder.Parse) Module Signature_builder.Parse
Parser for include specifications.
To use the signature builder, first enable the PPX rewriter. With dune, add the PPX rewriter to your component's dune
file:
(preprocess (pps less-power.signature-builder-ppx))
Then, within a signature, use an extension point to include signature items, for example:
module type Foo : sig
[%%include stdlib.stdlib (fst, snd)]
end
Inclusion specifications can be more complex. The full grammar is as follows:
include-specs := include-spec | '()' | '(' include-spec {',' include-spec} ')'
include-spec :=
diff --git a/sig-builder-no-typ-dup/less-power/Signature_builder/index.html b/sig-builder-no-typ-dup/less-power/Signature_builder/index.html
index 990c7ad..123cea7 100644
--- a/sig-builder-no-typ-dup/less-power/Signature_builder/index.html
+++ b/sig-builder-no-typ-dup/less-power/Signature_builder/index.html
@@ -1,5 +1,5 @@
-Signature_builder (less-power.Signature_builder) Module Signature_builder
Library and PPX rewriter for building interfaces from existing interfaces by selectively adding and removing interface items.
See Parse
for the full grammar for inclusion specifications.
Loading saved signatures
type raw_signature_info = (string list * raw_signature) list
type signature_infos = (string * signature_info) list
val infos_add_signature :
+Signature_builder (less-power.Signature_builder) Module Signature_builder
Library and PPX rewriter for building interfaces from existing interfaces by selectively adding and removing interface items.
See Parse
for the full grammar for inclusion specifications.
Loading saved signatures
type raw_signature_info = (string list * raw_signature) list
type signature_infos = (string * signature_info) list
val infos_add_signature :
string ->
string list ->
Ppxlib.signature ->
diff --git a/sig-builder-no-typ-dup/less-power/Signature_builder_ppx/index.html b/sig-builder-no-typ-dup/less-power/Signature_builder_ppx/index.html
index 0269db2..cf00aa1 100644
--- a/sig-builder-no-typ-dup/less-power/Signature_builder_ppx/index.html
+++ b/sig-builder-no-typ-dup/less-power/Signature_builder_ppx/index.html
@@ -1,2 +1,2 @@
-Signature_builder_ppx (less-power.Signature_builder_ppx) Module Signature_builder_ppx
+Signature_builder_ppx (less-power.Signature_builder_ppx) Module Signature_builder_ppx
diff --git a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_alerts/index.html b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_alerts/index.html
index 929d143..6c9e43e 100644
--- a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_alerts/index.html
+++ b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_alerts/index.html
@@ -1,2 +1,2 @@
-Stdlib_alerts (less-power.Std_overrides.Hide_stdlib_variants.Stdlib_alerts) Module Hide_stdlib_variants.Stdlib_alerts
+Stdlib_alerts (less-power.Std_overrides.Hide_stdlib_variants.Stdlib_alerts) Module Hide_stdlib_variants.Stdlib_alerts
diff --git a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_components/index.html b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_components/index.html
index 3351e15..d3c24ee 100644
--- a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_components/index.html
+++ b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_components/index.html
@@ -1,2 +1,2 @@
-Stdlib_components (less-power.Std_overrides.Hide_stdlib_variants.Stdlib_components) Module Hide_stdlib_variants.Stdlib_components
+Stdlib_components (less-power.Std_overrides.Hide_stdlib_variants.Stdlib_components) Module Hide_stdlib_variants.Stdlib_components
diff --git a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_variants/index.html b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_variants/index.html
index cf542c6..a22b5e8 100644
--- a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_variants/index.html
+++ b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Stdlib_variants/index.html
@@ -1,2 +1,2 @@
-Stdlib_variants (less-power.Std_overrides.Hide_stdlib_variants.Stdlib_variants) Module Hide_stdlib_variants.Stdlib_variants
+Stdlib_variants (less-power.Std_overrides.Hide_stdlib_variants.Stdlib_variants) Module Hide_stdlib_variants.Stdlib_variants
diff --git a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Threads_alerts/index.html b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Threads_alerts/index.html
index ed80c84..6988699 100644
--- a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Threads_alerts/index.html
+++ b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/Threads_alerts/index.html
@@ -1,2 +1,2 @@
-Threads_alerts (less-power.Std_overrides.Hide_stdlib_variants.Threads_alerts) Module Hide_stdlib_variants.Threads_alerts
+Threads_alerts (less-power.Std_overrides.Hide_stdlib_variants.Threads_alerts) Module Hide_stdlib_variants.Threads_alerts
diff --git a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/index.html b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/index.html
index 4e99c3d..e20b8c7 100644
--- a/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/index.html
+++ b/sig-builder-no-typ-dup/less-power/Std_overrides/Hide_stdlib_variants/index.html
@@ -1,2 +1,2 @@
-Hide_stdlib_variants (less-power.Std_overrides.Hide_stdlib_variants) Module Std_overrides.Hide_stdlib_variants
Prevent access to the full variant library. Intended to be opened at the top level to hide the Stdlib_variants
module, and a couple others.
This is included in the other overrides modules, so you usually don't need to pass it to the -open
flag yourself. However, you should use it if you define your own override module based on less-power stdlib variants.
These modules are intentionally empty.
module Stdlib_variants : sig ... end
module Stdlib_components : sig ... end
module Stdlib_alerts : sig ... end
module Threads_alerts : sig ... end
+Hide_stdlib_variants (less-power.Std_overrides.Hide_stdlib_variants) Module Std_overrides.Hide_stdlib_variants
Prevent access to the full variant library. Intended to be opened at the top level to hide the Stdlib_variants
module, and a couple others.
This is included in the other overrides modules, so you usually don't need to pass it to the -open
flag yourself. However, you should use it if you define your own override module based on less-power stdlib variants.
These modules are intentionally empty.
module Stdlib_variants : sig ... end
module Stdlib_components : sig ... end
module Stdlib_alerts : sig ... end
module Threads_alerts : sig ... end
diff --git a/sig-builder-no-typ-dup/less-power/Std_overrides/Stdlib_alerting/index.html b/sig-builder-no-typ-dup/less-power/Std_overrides/Stdlib_alerting/index.html
index 744e23d..726a728 100644
--- a/sig-builder-no-typ-dup/less-power/Std_overrides/Stdlib_alerting/index.html
+++ b/sig-builder-no-typ-dup/less-power/Std_overrides/Stdlib_alerting/index.html
@@ -1,5 +1,5 @@
-Stdlib_alerting (less-power.Std_overrides.Stdlib_alerting) Module Std_overrides.Stdlib_alerting
Puts an alerting Stdlib
into scope, from Stdlib_alerts.Stdlib_alerting
.
module Stdlib = Stdlib_alerts.Stdlib_alerting
include module type of struct include Stdlib_alerts.Stdlib_alerting end
Stdlib
, but with the above module type.
raise
primitives and standard exceptions
include sig ... end
The Exit
exception is not raised by any library function. It is provided for use in your programs.
Exception raised when none of the cases of a pattern-matching apply. The arguments are the location of the match keyword in the source code (file name, line number, column number).
Exception raised when an assertion fails. The arguments are the location of the assert keyword in the source code (file name, line number, column number).
Exception raised by library functions to signal that the given arguments do not make sense. The string gives some information to the programmer. As a general rule, this exception should not be caught, it denotes a programming error and the code should be modified not to trigger it.
Exception raised by library functions to signal that they are undefined on the given arguments. The string is meant to give some information to the programmer; you must not pattern match on the string literal because it may change in future versions (use Failure _ instead).
Exception raised by the garbage collector when there is insufficient memory to complete the computation. (Not reliable for allocations on the minor heap.)
Exception raised by the bytecode interpreter when the evaluation stack reaches its maximal size. This often indicates infinite or excessively deep recursion in the user's program.
Before 4.10, it was not fully implemented by the native-code compiler.
Exception raised by the input/output functions to report an operating system error. The string is meant to give some information to the programmer; you must not pattern match on the string literal because it may change in future versions (use Sys_error _ instead).
Exception raised by input functions to signal that the end of file has been reached.
Exception raised by integer division and remainder operations when their second argument is zero.
A special case of Sys_error raised when no I/O is possible on a non-blocking I/O channel.
Polymorphic comparisons
Not including the impure (==)
and (!=)
.
include sig ... end
e1 = e2
tests for structural equality of e1
and e2
. Mutable structures (e.g. references and arrays) are equal if and only if their current contents are structurally equal, even if the two mutable objects are not the same physical object. Equality between functional values raises Invalid_argument
. Equality between cyclic data structures may not terminate. Left-associative operator, see Ocaml_operators
for more information.
Negation of Stdlib.(=)
. Left-associative operator, see Ocaml_operators
for more information.
See Stdlib.(>=)
. Left-associative operator, see Ocaml_operators
for more information.
See Stdlib.(>=)
. Left-associative operator, see Ocaml_operators
for more information.
See Stdlib.(>=)
. Left-associative operator, see Ocaml_operators
for more information.
Structural ordering functions. These functions coincide with the usual orderings over integers, characters, strings, byte sequences and floating-point numbers, and extend them to a total ordering over all types. The ordering is compatible with ( = )
. As in the case of ( = )
, mutable structures are compared by contents. Comparison between functional values raises Invalid_argument
. Comparison between cyclic structures may not terminate. Left-associative operator, see Ocaml_operators
for more information.
compare x y
returns 0
if x
is equal to y
, a negative integer if x
is less than y
, and a positive integer if x
is greater than y
. The ordering implemented by compare
is compatible with the comparison predicates =
, <
and >
defined above, with one difference on the treatment of the float value Stdlib.nan
. Namely, the comparison predicates treat nan
as different from any other float value, including itself; while compare
treats nan
as equal to itself and less than any other float value. This treatment of nan
ensures that compare
defines a total ordering relation.
compare
applied to functional values may raise Invalid_argument
. compare
applied to cyclic structures may not terminate.
The compare
function can be used as the comparison function required by the Set.Make
and Map.Make
functors, as well as the List.sort
and Array.sort
functions.
Return the smaller of the two arguments. The result is unspecified if one of the arguments contains the float value nan
.
Physical comparisons
The impure (==)
and (!=)
include sig ... end
e1 == e2
tests for physical equality of e1
and e2
. On mutable types such as references, arrays, byte sequences, records with mutable fields and objects with mutable instance variables, e1 == e2
is true if and only if physical modification of e1
also affects e2
. On non-mutable types, the behavior of ( == )
is implementation-dependent; however, it is guaranteed that e1 == e2
implies compare e1 e2 = 0
. Left-associative operator, see Ocaml_operators
for more information.
Negation of Stdlib.(==)
. Left-associative operator, see Ocaml_operators
for more information.
Boolean operations
include sig ... end
The boolean 'and'. Evaluation is sequential, left-to-right: in e1 && e2
, e1
is evaluated first, and if it returns false
, e2
is not evaluated at all. Right-associative operator, see Ocaml_operators
for more information.
Debugging macros
These are safe in the sense that referential transparency is preserved, if two uses of a macro at separate locations are considered separate occurrences.
include sig ... end
__LOC__
returns the location at which this expression appears in the file currently being parsed by the compiler, with the standard error format of OCaml: "File %S, line %d, characters %d-%d".
__LINE__
returns the line number at which this expression appears in the file currently being parsed by the compiler.
__POS__
returns a tuple (file,lnum,cnum,enum)
, corresponding to the location at which this expression appears in the file currently being parsed by the compiler. file
is the current filename, lnum
the line number, cnum
the character position in the line and enum
the last character position in the line.
__FUNCTION__
returns the name of the current function or method, including any enclosing modules or classes.
__LOC_OF__ expr
returns a pair (loc, expr)
where loc
is the location of expr
in the file currently being parsed by the compiler, with the standard error format of OCaml: "File %S, line %d, characters %d-%d".
__LINE_OF__ expr
returns a pair (line, expr)
, where line
is the line number at which the expression expr
appears in the file currently being parsed by the compiler.
__POS_OF__ expr
returns a pair (loc,expr)
, where loc
is a tuple (file,lnum,cnum,enum)
corresponding to the location at which the expression expr
appears in the file currently being parsed by the compiler. file
is the current filename, lnum
the line number, cnum
the character position in the line and enum
the last character position in the line.
Composition operators
include sig ... end
Reverse-application operator: x |> f |> g
is exactly equivalent to g (f (x))
. Left-associative operator, see Ocaml_operators
for more information.
Integer operations
include sig ... end
Unary negation. You can also write - e
instead of ~- e
. Unary operator, see Ocaml_operators
for more information.
Unary addition. You can also write + e
instead of ~+ e
. Unary operator, see Ocaml_operators
for more information.
Integer addition. Left-associative operator, see Ocaml_operators
for more information.
Integer subtraction. Left-associative operator, , see Ocaml_operators
for more information.
Integer multiplication. Left-associative operator, see Ocaml_operators
for more information.
Integer division. Integer division rounds the real quotient of its arguments towards zero. More precisely, if x >= 0
and y > 0
, x / y
is the greatest integer less than or equal to the real quotient of x
by y
. Moreover, (- x) / y = x / (- y) = - (x / y)
. Left-associative operator, see Ocaml_operators
for more information.
Integer remainder. If y
is not zero, the result of x mod y
satisfies the following properties: x = (x / y) * y + x mod y
and abs(x mod y) <= abs(y) - 1
. If y = 0
, x mod y
raises Division_by_zero
. Note that x mod y
is negative only if x < 0
. Left-associative operator, see Ocaml_operators
for more information.
abs x
is the absolute value of x
. On min_int
this is min_int
itself and thus remains negative.
Bitwise logical and. Left-associative operator, see Ocaml_operators
for more information.
Bitwise logical or. Left-associative operator, see Ocaml_operators
for more information.
Bitwise logical exclusive or. Left-associative operator, see Ocaml_operators
for more information.
n lsl m
shifts n
to the left by m
bits. The result is unspecified if m < 0
or m > Sys.int_size
. Right-associative operator, see Ocaml_operators
for more information.
n lsr m
shifts n
to the right by m
bits. This is a logical shift: zeroes are inserted regardless of the sign of n
. The result is unspecified if m < 0
or m > Sys.int_size
. Right-associative operator, see Ocaml_operators
for more information.
n asr m
shifts n
to the right by m
bits. This is an arithmetic shift: the sign bit of n
is replicated. The result is unspecified if m < 0
or m > Sys.int_size
. Right-associative operator, see Ocaml_operators
for more information.
Floating-point operations
include sig ... end
Unary negation. You can also write -. e
instead of ~-. e
. Unary operator, see Ocaml_operators
for more information.
Unary addition. You can also write +. e
instead of ~+. e
. Unary operator, see Ocaml_operators
for more information.
Floating-point addition. Left-associative operator, see Ocaml_operators
for more information.
Floating-point subtraction. Left-associative operator, see Ocaml_operators
for more information.
Floating-point multiplication. Left-associative operator, see Ocaml_operators
for more information.
Floating-point division. Left-associative operator, see Ocaml_operators
for more information.
Exponentiation. Right-associative operator, see Ocaml_operators
for more information.
expm1 x
computes exp x -. 1.0
, giving numerically-accurate results even if x
is close to 0.0
.
Arc cosine. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and is between 0.0
and pi
.
Arc sine. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and is between -pi/2
and pi/2
.
atan2 y x
returns the arc tangent of y /. x
. The signs of x
and y
are used to determine the quadrant of the result. Result is in radians and is between -pi
and pi
.
hypot x y
returns sqrt(x *. x + y *. y)
, that is, the length of the hypotenuse of a right-angled triangle with sides of length x
and y
, or, equivalently, the distance of the point (x,y)
to origin. If one of x
or y
is infinite, returns infinity
even if the other is nan
.
Hyperbolic arc cosine. The argument must fall within the range [1.0, inf]
. Result is in radians and is between 0.0
and inf
.
log1p x
computes log(1.0 +. x)
(natural logarithm), giving numerically-accurate results even if x
is close to 0.0
.
Hyperbolic arc sine. The argument and result range over the entire real line. Result is in radians.
Hyperbolic arc tangent. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and ranges over the entire real line.
Round above to an integer value. ceil f
returns the least integer value greater than or equal to f
. The result is returned as a float.
Round below to an integer value. floor f
returns the greatest integer value less than or equal to f
. The result is returned as a float.
copysign x y
returns a float whose absolute value is that of x
and whose sign is that of y
. If x
is nan
, returns nan
. If y
is nan
, returns either x
or -. x
, but it is not specified which.
mod_float a b
returns the remainder of a
with respect to b
. The returned value is a -. n *. b
, where n
is the quotient a /. b
rounded towards zero to an integer.
frexp f
returns the pair of the significant and the exponent of f
. When f
is zero, the significant x
and the exponent n
of f
are equal to zero. When f
is non-zero, they are defined by f = x *. 2 ** n
and 0.5 <= x < 1.0
.
Same as Stdlib.float_of_int
.
Same as Stdlib.int_of_float
.
Truncate the given floating-point number to an integer. The result is unspecified if the argument is nan
or falls outside the range of representable integers.
A special floating-point value denoting the result of an undefined operation such as 0.0 /. 0.0
. Stands for 'not a number'. Any floating-point operation with nan
as argument returns nan
as result, unless otherwise specified in IEEE 754 standard. As for floating-point comparisons, =
, <
, <=
, >
and >=
return false
and <>
returns true
if one or both of their arguments is nan
.
nan
is a quiet NaN since 5.1; it was a signaling NaN before.
The difference between 1.0
and the smallest exactly representable floating-point number greater than 1.0
.
String operations
More in Stdlib.String
Character operations
More in Stdlib.Char
Unit operations
include sig ... end
String conversion functions
include sig ... end
Return the string representation of a boolean. As the returned values may be shared, the user should not modify them directly.
Convert the given string to a boolean.
Return None
if the string is not "true"
or "false"
.
Same as Stdlib.bool_of_string_opt
, but raise Invalid_argument "bool_of_string"
instead of returning None
.
Convert the given string to an integer. The string is read in decimal (by default, or if the string begins with 0u
), in hexadecimal (if it begins with 0x
or 0X
), in octal (if it begins with 0o
or 0O
), or in binary (if it begins with 0b
or 0B
).
The 0u
prefix reads the input as an unsigned integer in the range [0, 2*max_int+1]
. If the input exceeds max_int
it is converted to the signed integer min_int + input - max_int - 1
.
The _
(underscore) character can appear anywhere in the string and is ignored.
Return None
if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type int
.
Same as Stdlib.int_of_string_opt
, but raise Failure "int_of_string"
instead of returning None
.
Return a string representation of a floating-point number.
This conversion can involve a loss of precision. For greater control over the manner in which the number is printed, see Printf
.
Convert the given string to a float. The string is read in decimal (by default) or in hexadecimal (marked by 0x
or 0X
).
The format of decimal floating-point numbers is [-] dd.ddd (e|E) [+|-] dd
, where d
stands for a decimal digit.
The format of hexadecimal floating-point numbers is [-] 0(x|X) hh.hhh (p|P) [+|-] dd
, where h
stands for an hexadecimal digit and d
for a decimal digit.
In both cases, at least one of the integer and fractional parts must be given; the exponent part is optional.
The _
(underscore) character can appear anywhere in the string and is ignored.
Depending on the execution platforms, other representations of floating-point numbers can be accepted, but should not be relied upon.
Return None
if the given string is not a valid representation of a float.
Same as Stdlib.float_of_string_opt
, but raise Failure "float_of_string"
instead of returning None
.
Pair operations
Character operations
More in Stdlib.List
include sig ... end
l0 @ l1
appends l1
to l0
. Same function as List.append
. Right-associative operator, see Ocaml_operators
for more information.
I/O operations
This is regular, unmocked, IO.
include sig ... end
val stdin : in_channel
The standard input for the process.
val stdout : out_channel
The standard output for the process.
val stderr : out_channel
The standard error output for the process.
Print a floating-point number, in decimal, on standard output.
The conversion of the number to a string uses string_of_float
and can involve a loss of precision.
Print a string, followed by a newline character, on standard output and flush standard output.
Print a newline character on standard output, and flush standard output. This can be used to simulate line buffering of standard output.
Print a floating-point number, in decimal, on standard error.
The conversion of the number to a string uses string_of_float
and can involve a loss of precision.
Print a string, followed by a newline character on standard error and flush standard error.
Print a newline character on standard error, and flush standard error.
Flush standard output, then read characters from standard input until a newline character is encountered.
Return the string of all characters read, without the newline character at the end.
Flush standard output, then read one line from standard input and convert it to an integer.
Return None
if the line read is not a valid representation of an integer.
Same as Stdlib.read_int_opt
, but raise Failure "int_of_string"
instead of returning None
.
Flush standard output, then read one line from standard input and convert it to a floating-point number.
Return None
if the line read is not a valid representation of a floating-point number.
Same as Stdlib.read_float_opt
, but raise Failure "float_of_string"
instead of returning None
.
val open_out : string -> out_channel
Open the named file for writing, and return a new output channel on that file, positioned at the beginning of the file. The file is truncated to zero length if it already exists. It is created if it does not already exists.
val open_out_bin : string -> out_channel
Same as Stdlib.open_out
, but the file is opened in binary mode, so that no translation takes place during writes. On operating systems that do not distinguish between text mode and binary mode, this function behaves like Stdlib.open_out
.
val open_out_gen : open_flag list -> int -> string -> out_channel
open_out_gen mode perm filename
opens the named file for writing, as described above. The extra argument mode
specifies the opening mode. The extra argument perm
specifies the file permissions, in case the file must be created. Stdlib.open_out
and Stdlib.open_out_bin
are special cases of this function.
val flush : out_channel -> unit
Flush the buffer associated with the given output channel, performing all pending writes on that channel. Interactive programs must be careful about flushing standard output and standard error at the right time.
val output_char : out_channel -> char -> unit
Write the character on the given output channel.
val output_string : out_channel -> string -> unit
Write the string on the given output channel.
val output_bytes : out_channel -> bytes -> unit
Write the byte sequence on the given output channel.
val output : out_channel -> bytes -> int -> int -> unit
output oc buf pos len
writes len
characters from byte sequence buf
, starting at offset pos
, to the given output channel oc
.
val output_substring : out_channel -> string -> int -> int -> unit
Same as output
but take a string as argument instead of a byte sequence.
val output_byte : out_channel -> int -> unit
Write one 8-bit integer (as the single character with that code) on the given output channel. The given integer is taken modulo 256.
val output_binary_int : out_channel -> int -> unit
Write one integer in binary format (4 bytes, big-endian) on the given output channel. The given integer is taken modulo 232. The only reliable way to read it back is through the Stdlib.input_binary_int
function. The format is compatible across all machines for a given version of OCaml.
val output_value : out_channel -> 'a -> unit
Write the representation of a structured value of any type to a channel. Circularities and sharing inside the value are detected and preserved. The object can be read back, by the function Stdlib.input_value
. See the description of module Marshal
for more information. Stdlib.output_value
is equivalent to Marshal.to_channel
with an empty list of flags.
val seek_out : out_channel -> int -> unit
seek_out chan pos
sets the current writing position to pos
for channel chan
. This works only for regular files. On files of other kinds (such as terminals, pipes and sockets), the behavior is unspecified.
val pos_out : out_channel -> int
Return the current writing position for the given channel. Does not work on channels opened with the Open_append
flag (returns unspecified results). For files opened in text mode under Windows, the returned position is approximate (owing to end-of-line conversion); in particular, saving the current position with pos_out
, then going back to this position using seek_out
will not work. For this programming idiom to work reliably and portably, the file must be opened in binary mode.
val out_channel_length : out_channel -> int
Return the size (number of characters) of the regular file on which the given channel is opened. If the channel is opened on a file that is not a regular file, the result is meaningless.
val close_out : out_channel -> unit
Close the given channel, flushing all buffered write operations. Output functions raise a Sys_error
exception when they are applied to a closed output channel, except close_out
and flush
, which do nothing when applied to an already closed channel. Note that close_out
may raise Sys_error
if the operating system signals an error when flushing or closing.
val close_out_noerr : out_channel -> unit
Same as close_out
, but ignore all errors.
val set_binary_mode_out : out_channel -> bool -> unit
set_binary_mode_out oc true
sets the channel oc
to binary mode: no translations take place during output. set_binary_mode_out oc false
sets the channel oc
to text mode: depending on the operating system, some translations may take place during output. For instance, under Windows, end-of-lines will be translated from \n
to \r\n
. This function has no effect under operating systems that do not distinguish between text mode and binary mode.
val open_in : string -> in_channel
Open the named file for reading, and return a new input channel on that file, positioned at the beginning of the file.
val open_in_bin : string -> in_channel
Same as Stdlib.open_in
, but the file is opened in binary mode, so that no translation takes place during reads. On operating systems that do not distinguish between text mode and binary mode, this function behaves like Stdlib.open_in
.
val open_in_gen : open_flag list -> int -> string -> in_channel
open_in_gen mode perm filename
opens the named file for reading, as described above. The extra arguments mode
and perm
specify the opening mode and file permissions. Stdlib.open_in
and Stdlib.open_in_bin
are special cases of this function.
val input_char : in_channel -> char
Read one character from the given input channel.
val input_line : in_channel -> string
Read characters from the given input channel, until a newline character is encountered. Return the string of all characters read, without the newline character at the end.
val input : in_channel -> bytes -> int -> int -> int
input ic buf pos len
reads up to len
characters from the given channel ic
, storing them in byte sequence buf
, starting at character number pos
. It returns the actual number of characters read, between 0 and len
(inclusive). A return value of 0 means that the end of file was reached. A return value between 0 and len
exclusive means that not all requested len
characters were read, either because no more characters were available at that time, or because the implementation found it convenient to do a partial read; input
must be called again to read the remaining characters, if desired. (See also Stdlib.really_input
for reading exactly len
characters.) Exception Invalid_argument "input"
is raised if pos
and len
do not designate a valid range of buf
.
val really_input : in_channel -> bytes -> int -> int -> unit
really_input ic buf pos len
reads len
characters from channel ic
, storing them in byte sequence buf
, starting at character number pos
.
val really_input_string : in_channel -> int -> string
really_input_string ic len
reads len
characters from channel ic
and returns them in a new string.
val input_byte : in_channel -> int
Same as Stdlib.input_char
, but return the 8-bit integer representing the character.
val input_binary_int : in_channel -> int
Read an integer encoded in binary format (4 bytes, big-endian) from the given input channel. See Stdlib.output_binary_int
.
val input_value : in_channel -> 'a
Read the representation of a structured value, as produced by Stdlib.output_value
, and return the corresponding value. This function is identical to Marshal.from_channel
; see the description of module Marshal
for more information, in particular concerning the lack of type safety.
val seek_in : in_channel -> int -> unit
seek_in chan pos
sets the current reading position to pos
for channel chan
. This works only for regular files. On files of other kinds, the behavior is unspecified.
val pos_in : in_channel -> int
Return the current reading position for the given channel. For files opened in text mode under Windows, the returned position is approximate (owing to end-of-line conversion); in particular, saving the current position with pos_in
, then going back to this position using seek_in
will not work. For this programming idiom to work reliably and portably, the file must be opened in binary mode.
val in_channel_length : in_channel -> int
Return the size (number of characters) of the regular file on which the given channel is opened. If the channel is opened on a file that is not a regular file, the result is meaningless. The returned size does not take into account the end-of-line translations that can be performed when reading from a channel opened in text mode.
val close_in : in_channel -> unit
Close the given channel. Input functions raise a Sys_error
exception when they are applied to a closed input channel, except close_in
, which does nothing when applied to an already closed channel.
val close_in_noerr : in_channel -> unit
Same as close_in
, but ignore all errors.
val set_binary_mode_in : in_channel -> bool -> unit
set_binary_mode_in ic true
sets the channel ic
to binary mode: no translations take place during input. set_binary_mode_out ic false
sets the channel ic
to text mode: depending on the operating system, some translations may take place during input. For instance, under Windows, end-of-lines will be translated from \r\n
to \n
. This function has no effect under operating systems that do not distinguish between text mode and binary mode.
module LargeFile = Stdlib_alerts.Stdlib_alerting.LargeFile
Operations on large files. This sub-module provides 64-bit variants of the channel functions that manipulate file positions and file sizes. By representing positions and sizes by 64-bit integers (type int64
) instead of regular integers (type int
), these alternate functions allow operating on files whose sizes are greater than max_int
.
References
include sig ... end
val ref : 'a -> 'a ref
Return a fresh reference containing the given value.
val (!) : 'a ref -> 'a
!r
returns the current contents of reference r
. Equivalent to fun r -> r.contents
. Unary operator, see Ocaml_operators
for more information.
val (:=) : 'a ref -> 'a -> unit
r := a
stores the value of a
in reference r
. Equivalent to fun r v -> r.contents <- v
. Right-associative operator, see Ocaml_operators
for more information.
val incr : int ref -> unit
Increment the integer contained in the given reference. Equivalent to fun r -> r := succ !r
.
val decr : int ref -> unit
Decrement the integer contained in the given reference. Equivalent to fun r -> r := pred !r
.
Result type
More in Stdlib.Result
Format strings
More in Stdlib.Scanf
, Stdlib.Printf
, and Stdlib.Format
include sig ... end
type ('a, 'b, 'c, 'd, 'e, 'f) format6 =
+Stdlib_alerting (less-power.Std_overrides.Stdlib_alerting) Module Std_overrides.Stdlib_alerting
Puts an alerting Stdlib
into scope, from Stdlib_alerts.Stdlib_alerting
.
module Stdlib = Stdlib_alerts.Stdlib_alerting
include module type of struct include Stdlib_alerts.Stdlib_alerting end
Stdlib
, but with the above module type.
raise
primitives and standard exceptions
include sig ... end
The Exit
exception is not raised by any library function. It is provided for use in your programs.
Exception raised when none of the cases of a pattern-matching apply. The arguments are the location of the match keyword in the source code (file name, line number, column number).
Exception raised when an assertion fails. The arguments are the location of the assert keyword in the source code (file name, line number, column number).
Exception raised by library functions to signal that the given arguments do not make sense. The string gives some information to the programmer. As a general rule, this exception should not be caught, it denotes a programming error and the code should be modified not to trigger it.
Exception raised by library functions to signal that they are undefined on the given arguments. The string is meant to give some information to the programmer; you must not pattern match on the string literal because it may change in future versions (use Failure _ instead).
Exception raised by the garbage collector when there is insufficient memory to complete the computation. (Not reliable for allocations on the minor heap.)
Exception raised by the bytecode interpreter when the evaluation stack reaches its maximal size. This often indicates infinite or excessively deep recursion in the user's program.
Before 4.10, it was not fully implemented by the native-code compiler.
Exception raised by the input/output functions to report an operating system error. The string is meant to give some information to the programmer; you must not pattern match on the string literal because it may change in future versions (use Sys_error _ instead).
Exception raised by input functions to signal that the end of file has been reached.
Exception raised by integer division and remainder operations when their second argument is zero.
A special case of Sys_error raised when no I/O is possible on a non-blocking I/O channel.
Polymorphic comparisons
Not including the impure (==)
and (!=)
.
include sig ... end
e1 = e2
tests for structural equality of e1
and e2
. Mutable structures (e.g. references and arrays) are equal if and only if their current contents are structurally equal, even if the two mutable objects are not the same physical object. Equality between functional values raises Invalid_argument
. Equality between cyclic data structures may not terminate. Left-associative operator, see Ocaml_operators
for more information.
Negation of Stdlib.(=)
. Left-associative operator, see Ocaml_operators
for more information.
See Stdlib.(>=)
. Left-associative operator, see Ocaml_operators
for more information.
See Stdlib.(>=)
. Left-associative operator, see Ocaml_operators
for more information.
See Stdlib.(>=)
. Left-associative operator, see Ocaml_operators
for more information.
Structural ordering functions. These functions coincide with the usual orderings over integers, characters, strings, byte sequences and floating-point numbers, and extend them to a total ordering over all types. The ordering is compatible with ( = )
. As in the case of ( = )
, mutable structures are compared by contents. Comparison between functional values raises Invalid_argument
. Comparison between cyclic structures may not terminate. Left-associative operator, see Ocaml_operators
for more information.
compare x y
returns 0
if x
is equal to y
, a negative integer if x
is less than y
, and a positive integer if x
is greater than y
. The ordering implemented by compare
is compatible with the comparison predicates =
, <
and >
defined above, with one difference on the treatment of the float value Stdlib.nan
. Namely, the comparison predicates treat nan
as different from any other float value, including itself; while compare
treats nan
as equal to itself and less than any other float value. This treatment of nan
ensures that compare
defines a total ordering relation.
compare
applied to functional values may raise Invalid_argument
. compare
applied to cyclic structures may not terminate.
The compare
function can be used as the comparison function required by the Set.Make
and Map.Make
functors, as well as the List.sort
and Array.sort
functions.
Return the smaller of the two arguments. The result is unspecified if one of the arguments contains the float value nan
.
Physical comparisons
The impure (==)
and (!=)
include sig ... end
e1 == e2
tests for physical equality of e1
and e2
. On mutable types such as references, arrays, byte sequences, records with mutable fields and objects with mutable instance variables, e1 == e2
is true if and only if physical modification of e1
also affects e2
. On non-mutable types, the behavior of ( == )
is implementation-dependent; however, it is guaranteed that e1 == e2
implies compare e1 e2 = 0
. Left-associative operator, see Ocaml_operators
for more information.
Negation of Stdlib.(==)
. Left-associative operator, see Ocaml_operators
for more information.
Boolean operations
include sig ... end
The boolean 'and'. Evaluation is sequential, left-to-right: in e1 && e2
, e1
is evaluated first, and if it returns false
, e2
is not evaluated at all. Right-associative operator, see Ocaml_operators
for more information.
Debugging macros
These are safe in the sense that referential transparency is preserved, if two uses of a macro at separate locations are considered separate occurrences.
include sig ... end
__LOC__
returns the location at which this expression appears in the file currently being parsed by the compiler, with the standard error format of OCaml: "File %S, line %d, characters %d-%d".
__LINE__
returns the line number at which this expression appears in the file currently being parsed by the compiler.
__POS__
returns a tuple (file,lnum,cnum,enum)
, corresponding to the location at which this expression appears in the file currently being parsed by the compiler. file
is the current filename, lnum
the line number, cnum
the character position in the line and enum
the last character position in the line.
__FUNCTION__
returns the name of the current function or method, including any enclosing modules or classes.
__LOC_OF__ expr
returns a pair (loc, expr)
where loc
is the location of expr
in the file currently being parsed by the compiler, with the standard error format of OCaml: "File %S, line %d, characters %d-%d".
__LINE_OF__ expr
returns a pair (line, expr)
, where line
is the line number at which the expression expr
appears in the file currently being parsed by the compiler.
__POS_OF__ expr
returns a pair (loc,expr)
, where loc
is a tuple (file,lnum,cnum,enum)
corresponding to the location at which the expression expr
appears in the file currently being parsed by the compiler. file
is the current filename, lnum
the line number, cnum
the character position in the line and enum
the last character position in the line.
Composition operators
include sig ... end
Reverse-application operator: x |> f |> g
is exactly equivalent to g (f (x))
. Left-associative operator, see Ocaml_operators
for more information.
Integer operations
include sig ... end
Unary negation. You can also write - e
instead of ~- e
. Unary operator, see Ocaml_operators
for more information.
Unary addition. You can also write + e
instead of ~+ e
. Unary operator, see Ocaml_operators
for more information.
Integer addition. Left-associative operator, see Ocaml_operators
for more information.
Integer subtraction. Left-associative operator, , see Ocaml_operators
for more information.
Integer multiplication. Left-associative operator, see Ocaml_operators
for more information.
Integer division. Integer division rounds the real quotient of its arguments towards zero. More precisely, if x >= 0
and y > 0
, x / y
is the greatest integer less than or equal to the real quotient of x
by y
. Moreover, (- x) / y = x / (- y) = - (x / y)
. Left-associative operator, see Ocaml_operators
for more information.
Integer remainder. If y
is not zero, the result of x mod y
satisfies the following properties: x = (x / y) * y + x mod y
and abs(x mod y) <= abs(y) - 1
. If y = 0
, x mod y
raises Division_by_zero
. Note that x mod y
is negative only if x < 0
. Left-associative operator, see Ocaml_operators
for more information.
abs x
is the absolute value of x
. On min_int
this is min_int
itself and thus remains negative.
Bitwise logical and. Left-associative operator, see Ocaml_operators
for more information.
Bitwise logical or. Left-associative operator, see Ocaml_operators
for more information.
Bitwise logical exclusive or. Left-associative operator, see Ocaml_operators
for more information.
n lsl m
shifts n
to the left by m
bits. The result is unspecified if m < 0
or m > Sys.int_size
. Right-associative operator, see Ocaml_operators
for more information.
n lsr m
shifts n
to the right by m
bits. This is a logical shift: zeroes are inserted regardless of the sign of n
. The result is unspecified if m < 0
or m > Sys.int_size
. Right-associative operator, see Ocaml_operators
for more information.
n asr m
shifts n
to the right by m
bits. This is an arithmetic shift: the sign bit of n
is replicated. The result is unspecified if m < 0
or m > Sys.int_size
. Right-associative operator, see Ocaml_operators
for more information.
Floating-point operations
include sig ... end
Unary negation. You can also write -. e
instead of ~-. e
. Unary operator, see Ocaml_operators
for more information.
Unary addition. You can also write +. e
instead of ~+. e
. Unary operator, see Ocaml_operators
for more information.
Floating-point addition. Left-associative operator, see Ocaml_operators
for more information.
Floating-point subtraction. Left-associative operator, see Ocaml_operators
for more information.
Floating-point multiplication. Left-associative operator, see Ocaml_operators
for more information.
Floating-point division. Left-associative operator, see Ocaml_operators
for more information.
Exponentiation. Right-associative operator, see Ocaml_operators
for more information.
expm1 x
computes exp x -. 1.0
, giving numerically-accurate results even if x
is close to 0.0
.
Arc cosine. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and is between 0.0
and pi
.
Arc sine. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and is between -pi/2
and pi/2
.
atan2 y x
returns the arc tangent of y /. x
. The signs of x
and y
are used to determine the quadrant of the result. Result is in radians and is between -pi
and pi
.
hypot x y
returns sqrt(x *. x + y *. y)
, that is, the length of the hypotenuse of a right-angled triangle with sides of length x
and y
, or, equivalently, the distance of the point (x,y)
to origin. If one of x
or y
is infinite, returns infinity
even if the other is nan
.
Hyperbolic arc cosine. The argument must fall within the range [1.0, inf]
. Result is in radians and is between 0.0
and inf
.
log1p x
computes log(1.0 +. x)
(natural logarithm), giving numerically-accurate results even if x
is close to 0.0
.
Hyperbolic arc sine. The argument and result range over the entire real line. Result is in radians.
Hyperbolic arc tangent. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and ranges over the entire real line.
Round above to an integer value. ceil f
returns the least integer value greater than or equal to f
. The result is returned as a float.
Round below to an integer value. floor f
returns the greatest integer value less than or equal to f
. The result is returned as a float.
copysign x y
returns a float whose absolute value is that of x
and whose sign is that of y
. If x
is nan
, returns nan
. If y
is nan
, returns either x
or -. x
, but it is not specified which.
mod_float a b
returns the remainder of a
with respect to b
. The returned value is a -. n *. b
, where n
is the quotient a /. b
rounded towards zero to an integer.
frexp f
returns the pair of the significant and the exponent of f
. When f
is zero, the significant x
and the exponent n
of f
are equal to zero. When f
is non-zero, they are defined by f = x *. 2 ** n
and 0.5 <= x < 1.0
.
Same as Stdlib.float_of_int
.
Same as Stdlib.int_of_float
.
Truncate the given floating-point number to an integer. The result is unspecified if the argument is nan
or falls outside the range of representable integers.
A special floating-point value denoting the result of an undefined operation such as 0.0 /. 0.0
. Stands for 'not a number'. Any floating-point operation with nan
as argument returns nan
as result, unless otherwise specified in IEEE 754 standard. As for floating-point comparisons, =
, <
, <=
, >
and >=
return false
and <>
returns true
if one or both of their arguments is nan
.
nan
is a quiet NaN since 5.1; it was a signaling NaN before.
The difference between 1.0
and the smallest exactly representable floating-point number greater than 1.0
.
String operations
More in Stdlib.String
Character operations
More in Stdlib.Char
Unit operations
include sig ... end
String conversion functions
include sig ... end
Return the string representation of a boolean. As the returned values may be shared, the user should not modify them directly.
Convert the given string to a boolean.
Return None
if the string is not "true"
or "false"
.
Same as Stdlib.bool_of_string_opt
, but raise Invalid_argument "bool_of_string"
instead of returning None
.
Convert the given string to an integer. The string is read in decimal (by default, or if the string begins with 0u
), in hexadecimal (if it begins with 0x
or 0X
), in octal (if it begins with 0o
or 0O
), or in binary (if it begins with 0b
or 0B
).
The 0u
prefix reads the input as an unsigned integer in the range [0, 2*max_int+1]
. If the input exceeds max_int
it is converted to the signed integer min_int + input - max_int - 1
.
The _
(underscore) character can appear anywhere in the string and is ignored.
Return None
if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type int
.
Same as Stdlib.int_of_string_opt
, but raise Failure "int_of_string"
instead of returning None
.
Return a string representation of a floating-point number.
This conversion can involve a loss of precision. For greater control over the manner in which the number is printed, see Printf
.
Convert the given string to a float. The string is read in decimal (by default) or in hexadecimal (marked by 0x
or 0X
).
The format of decimal floating-point numbers is [-] dd.ddd (e|E) [+|-] dd
, where d
stands for a decimal digit.
The format of hexadecimal floating-point numbers is [-] 0(x|X) hh.hhh (p|P) [+|-] dd
, where h
stands for an hexadecimal digit and d
for a decimal digit.
In both cases, at least one of the integer and fractional parts must be given; the exponent part is optional.
The _
(underscore) character can appear anywhere in the string and is ignored.
Depending on the execution platforms, other representations of floating-point numbers can be accepted, but should not be relied upon.
Return None
if the given string is not a valid representation of a float.
Same as Stdlib.float_of_string_opt
, but raise Failure "float_of_string"
instead of returning None
.
Pair operations
Character operations
More in Stdlib.List
include sig ... end
l0 @ l1
appends l1
to l0
. Same function as List.append
. Right-associative operator, see Ocaml_operators
for more information.
I/O operations
This is regular, unmocked, IO.
include sig ... end
val stdin : in_channel
The standard input for the process.
val stdout : out_channel
The standard output for the process.
val stderr : out_channel
The standard error output for the process.
Print a floating-point number, in decimal, on standard output.
The conversion of the number to a string uses string_of_float
and can involve a loss of precision.
Print a string, followed by a newline character, on standard output and flush standard output.
Print a newline character on standard output, and flush standard output. This can be used to simulate line buffering of standard output.
Print a floating-point number, in decimal, on standard error.
The conversion of the number to a string uses string_of_float
and can involve a loss of precision.
Print a string, followed by a newline character on standard error and flush standard error.
Print a newline character on standard error, and flush standard error.
Flush standard output, then read characters from standard input until a newline character is encountered.
Return the string of all characters read, without the newline character at the end.
Flush standard output, then read one line from standard input and convert it to an integer.
Return None
if the line read is not a valid representation of an integer.
Same as Stdlib.read_int_opt
, but raise Failure "int_of_string"
instead of returning None
.
Flush standard output, then read one line from standard input and convert it to a floating-point number.
Return None
if the line read is not a valid representation of a floating-point number.
Same as Stdlib.read_float_opt
, but raise Failure "float_of_string"
instead of returning None
.
val open_out : string -> out_channel
Open the named file for writing, and return a new output channel on that file, positioned at the beginning of the file. The file is truncated to zero length if it already exists. It is created if it does not already exists.
val open_out_bin : string -> out_channel
Same as Stdlib.open_out
, but the file is opened in binary mode, so that no translation takes place during writes. On operating systems that do not distinguish between text mode and binary mode, this function behaves like Stdlib.open_out
.
val open_out_gen : open_flag list -> int -> string -> out_channel
open_out_gen mode perm filename
opens the named file for writing, as described above. The extra argument mode
specifies the opening mode. The extra argument perm
specifies the file permissions, in case the file must be created. Stdlib.open_out
and Stdlib.open_out_bin
are special cases of this function.
val flush : out_channel -> unit
Flush the buffer associated with the given output channel, performing all pending writes on that channel. Interactive programs must be careful about flushing standard output and standard error at the right time.
val output_char : out_channel -> char -> unit
Write the character on the given output channel.
val output_string : out_channel -> string -> unit
Write the string on the given output channel.
val output_bytes : out_channel -> bytes -> unit
Write the byte sequence on the given output channel.
val output : out_channel -> bytes -> int -> int -> unit
output oc buf pos len
writes len
characters from byte sequence buf
, starting at offset pos
, to the given output channel oc
.
val output_substring : out_channel -> string -> int -> int -> unit
Same as output
but take a string as argument instead of a byte sequence.
val output_byte : out_channel -> int -> unit
Write one 8-bit integer (as the single character with that code) on the given output channel. The given integer is taken modulo 256.
val output_binary_int : out_channel -> int -> unit
Write one integer in binary format (4 bytes, big-endian) on the given output channel. The given integer is taken modulo 232. The only reliable way to read it back is through the Stdlib.input_binary_int
function. The format is compatible across all machines for a given version of OCaml.
val output_value : out_channel -> 'a -> unit
Write the representation of a structured value of any type to a channel. Circularities and sharing inside the value are detected and preserved. The object can be read back, by the function Stdlib.input_value
. See the description of module Marshal
for more information. Stdlib.output_value
is equivalent to Marshal.to_channel
with an empty list of flags.
val seek_out : out_channel -> int -> unit
seek_out chan pos
sets the current writing position to pos
for channel chan
. This works only for regular files. On files of other kinds (such as terminals, pipes and sockets), the behavior is unspecified.
val pos_out : out_channel -> int
Return the current writing position for the given channel. Does not work on channels opened with the Open_append
flag (returns unspecified results). For files opened in text mode under Windows, the returned position is approximate (owing to end-of-line conversion); in particular, saving the current position with pos_out
, then going back to this position using seek_out
will not work. For this programming idiom to work reliably and portably, the file must be opened in binary mode.
val out_channel_length : out_channel -> int
Return the size (number of characters) of the regular file on which the given channel is opened. If the channel is opened on a file that is not a regular file, the result is meaningless.
val close_out : out_channel -> unit
Close the given channel, flushing all buffered write operations. Output functions raise a Sys_error
exception when they are applied to a closed output channel, except close_out
and flush
, which do nothing when applied to an already closed channel. Note that close_out
may raise Sys_error
if the operating system signals an error when flushing or closing.
val close_out_noerr : out_channel -> unit
Same as close_out
, but ignore all errors.
val set_binary_mode_out : out_channel -> bool -> unit
set_binary_mode_out oc true
sets the channel oc
to binary mode: no translations take place during output. set_binary_mode_out oc false
sets the channel oc
to text mode: depending on the operating system, some translations may take place during output. For instance, under Windows, end-of-lines will be translated from \n
to \r\n
. This function has no effect under operating systems that do not distinguish between text mode and binary mode.
val open_in : string -> in_channel
Open the named file for reading, and return a new input channel on that file, positioned at the beginning of the file.
val open_in_bin : string -> in_channel
Same as Stdlib.open_in
, but the file is opened in binary mode, so that no translation takes place during reads. On operating systems that do not distinguish between text mode and binary mode, this function behaves like Stdlib.open_in
.
val open_in_gen : open_flag list -> int -> string -> in_channel
open_in_gen mode perm filename
opens the named file for reading, as described above. The extra arguments mode
and perm
specify the opening mode and file permissions. Stdlib.open_in
and Stdlib.open_in_bin
are special cases of this function.
val input_char : in_channel -> char
Read one character from the given input channel.
val input_line : in_channel -> string
Read characters from the given input channel, until a newline character is encountered. Return the string of all characters read, without the newline character at the end.
val input : in_channel -> bytes -> int -> int -> int
input ic buf pos len
reads up to len
characters from the given channel ic
, storing them in byte sequence buf
, starting at character number pos
. It returns the actual number of characters read, between 0 and len
(inclusive). A return value of 0 means that the end of file was reached. A return value between 0 and len
exclusive means that not all requested len
characters were read, either because no more characters were available at that time, or because the implementation found it convenient to do a partial read; input
must be called again to read the remaining characters, if desired. (See also Stdlib.really_input
for reading exactly len
characters.) Exception Invalid_argument "input"
is raised if pos
and len
do not designate a valid range of buf
.
val really_input : in_channel -> bytes -> int -> int -> unit
really_input ic buf pos len
reads len
characters from channel ic
, storing them in byte sequence buf
, starting at character number pos
.
val really_input_string : in_channel -> int -> string
really_input_string ic len
reads len
characters from channel ic
and returns them in a new string.
val input_byte : in_channel -> int
Same as Stdlib.input_char
, but return the 8-bit integer representing the character.
val input_binary_int : in_channel -> int
Read an integer encoded in binary format (4 bytes, big-endian) from the given input channel. See Stdlib.output_binary_int
.
val input_value : in_channel -> 'a
Read the representation of a structured value, as produced by Stdlib.output_value
, and return the corresponding value. This function is identical to Marshal.from_channel
; see the description of module Marshal
for more information, in particular concerning the lack of type safety.
val seek_in : in_channel -> int -> unit
seek_in chan pos
sets the current reading position to pos
for channel chan
. This works only for regular files. On files of other kinds, the behavior is unspecified.
val pos_in : in_channel -> int
Return the current reading position for the given channel. For files opened in text mode under Windows, the returned position is approximate (owing to end-of-line conversion); in particular, saving the current position with pos_in
, then going back to this position using seek_in
will not work. For this programming idiom to work reliably and portably, the file must be opened in binary mode.
val in_channel_length : in_channel -> int
Return the size (number of characters) of the regular file on which the given channel is opened. If the channel is opened on a file that is not a regular file, the result is meaningless. The returned size does not take into account the end-of-line translations that can be performed when reading from a channel opened in text mode.
val close_in : in_channel -> unit
Close the given channel. Input functions raise a Sys_error
exception when they are applied to a closed input channel, except close_in
, which does nothing when applied to an already closed channel.
val close_in_noerr : in_channel -> unit
Same as close_in
, but ignore all errors.
val set_binary_mode_in : in_channel -> bool -> unit
set_binary_mode_in ic true
sets the channel ic
to binary mode: no translations take place during input. set_binary_mode_out ic false
sets the channel ic
to text mode: depending on the operating system, some translations may take place during input. For instance, under Windows, end-of-lines will be translated from \r\n
to \n
. This function has no effect under operating systems that do not distinguish between text mode and binary mode.
module LargeFile = Stdlib_alerts.Stdlib_alerting.LargeFile
Operations on large files. This sub-module provides 64-bit variants of the channel functions that manipulate file positions and file sizes. By representing positions and sizes by 64-bit integers (type int64
) instead of regular integers (type int
), these alternate functions allow operating on files whose sizes are greater than max_int
.
References
include sig ... end
val ref : 'a -> 'a ref
Return a fresh reference containing the given value.
val (!) : 'a ref -> 'a
!r
returns the current contents of reference r
. Equivalent to fun r -> r.contents
. Unary operator, see Ocaml_operators
for more information.
val (:=) : 'a ref -> 'a -> unit
r := a
stores the value of a
in reference r
. Equivalent to fun r v -> r.contents <- v
. Right-associative operator, see Ocaml_operators
for more information.
val incr : int ref -> unit
Increment the integer contained in the given reference. Equivalent to fun r -> r := succ !r
.
val decr : int ref -> unit
Decrement the integer contained in the given reference. Equivalent to fun r -> r := pred !r
.
Result type
More in Stdlib.Result
Format strings
More in Stdlib.Scanf
, Stdlib.Printf
, and Stdlib.Format
include sig ... end
type ('a, 'b, 'c, 'd) format4 = ('a, 'b, 'c, 'c, 'c, 'd) format6
type ('a, 'b, 'c) format = ('a, 'b, 'c, 'c) format4
format_of_string s
returns a format string read from the string literal s
. Note: format_of_string
can not convert a string argument that is not a literal. If you need this functionality, use the more general Scanf.format_from_string
function.
val (^^) :
diff --git a/sig-builder-no-typ-dup/less-power/Std_overrides/Stdlib_safe/index.html b/sig-builder-no-typ-dup/less-power/Std_overrides/Stdlib_safe/index.html
index 704b447..0888984 100644
--- a/sig-builder-no-typ-dup/less-power/Std_overrides/Stdlib_safe/index.html
+++ b/sig-builder-no-typ-dup/less-power/Std_overrides/Stdlib_safe/index.html
@@ -1,5 +1,5 @@
-Stdlib_safe (less-power.Std_overrides.Stdlib_safe) Module Std_overrides.Stdlib_safe
Puts the safe parts of Stdlib
into scope, from Stdlib_components.Stdlib_safe
module Stdlib = Stdlib_components.Stdlib_safe
include module type of struct include Stdlib_components.Stdlib_safe end
include module type of struct include Stdlib_components.Exceptions end
include module type of struct include Stdlib_components.Composition end
include module type of struct include Stdlib_components.Debugging end
include module type of struct include Stdlib_components.Comparisons end
include module type of struct include Stdlib_components.BooleanOperations end
include module type of struct include Stdlib_components.IntegerOperations end
include module type of struct include Stdlib_components.FloatingPointOperations end
val classify_float : float -> fpclass
include module type of struct include Stdlib_components.StringOperations end
include module type of struct include Stdlib_components.CharOperations end
include module type of struct include Stdlib_components.UnitOperations end
include module type of struct include Stdlib_components.PairOperations end
include module type of struct include Stdlib_components.Result end
include module type of struct include Stdlib_components.StringConversion end
include module type of struct include Stdlib_components.ListOperations end
include module type of struct include Stdlib_components.Formats end
val format_of_string :
+Stdlib_safe (less-power.Std_overrides.Stdlib_safe) Module Std_overrides.Stdlib_safe
Puts the safe parts of Stdlib
into scope, from Stdlib_components.Stdlib_safe
module Stdlib = Stdlib_components.Stdlib_safe
include module type of struct include Stdlib_components.Stdlib_safe end
include module type of struct include Stdlib_components.Exceptions end
include module type of struct include Stdlib_components.Composition end
include module type of struct include Stdlib_components.Debugging end
include module type of struct include Stdlib_components.Comparisons end
include module type of struct include Stdlib_components.BooleanOperations end
include module type of struct include Stdlib_components.IntegerOperations end
include module type of struct include Stdlib_components.FloatingPointOperations end
val classify_float : float -> fpclass
include module type of struct include Stdlib_components.StringOperations end
include module type of struct include Stdlib_components.CharOperations end
include module type of struct include Stdlib_components.UnitOperations end
include module type of struct include Stdlib_components.PairOperations end
include module type of struct include Stdlib_components.Result end
include module type of struct include Stdlib_components.StringConversion end
include module type of struct include Stdlib_components.ListOperations end
include module type of struct include Stdlib_components.Formats end
val (^^) :
('a, 'b, 'c, 'd, 'e, 'f) Stdlib.format6 ->
diff --git a/sig-builder-no-typ-dup/less-power/Std_overrides/index.html b/sig-builder-no-typ-dup/less-power/Std_overrides/index.html
index c300905..6da03a7 100644
--- a/sig-builder-no-typ-dup/less-power/Std_overrides/index.html
+++ b/sig-builder-no-typ-dup/less-power/Std_overrides/index.html
@@ -1,2 +1,2 @@
-Std_overrides (less-power.Std_overrides) Module Std_overrides
Ready-to-use modules for replacing the default pervasives, using -open
.
module Hide_stdlib_variants : sig ... end
Prevent access to the full variant library. Intended to be opened at the top level to hide the Stdlib_variants
module, and a couple others.
module Stdlib_safe : sig ... end
Puts the safe parts of Stdlib
into scope, from Stdlib_components.Stdlib_safe
module Stdlib_alerting : sig ... end
Puts an alerting Stdlib
into scope, from Stdlib_alerts.Stdlib_alerting
.
+Std_overrides (less-power.Std_overrides) Module Std_overrides
Ready-to-use modules for replacing the default pervasives, using -open
.
module Hide_stdlib_variants : sig ... end
Prevent access to the full variant library. Intended to be opened at the top level to hide the Stdlib_variants
module, and a couple others.
module Stdlib_safe : sig ... end
Puts the safe parts of Stdlib
into scope, from Stdlib_components.Stdlib_safe
module Stdlib_alerting : sig ... end
Puts an alerting Stdlib
into scope, from Stdlib_alerts.Stdlib_alerting
.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Char/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Char/index.html
index d65012c..7b31657 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Char/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Char/index.html
@@ -1,2 +1,2 @@
-Char (less-power.Stdlib_alerts.Stdlib_alerting.Char) Module Stdlib_alerting.Char
include sig ... end
Return a string representing the given character, with special characters escaped following the lexical conventions of OCaml. All characters outside the ASCII printable range (32..126) are escaped, as well as backslash, double-quote, and single-quote.
Convert the given character to its equivalent lowercase character, using the US-ASCII character set.
Convert the given character to its equivalent uppercase character, using the US-ASCII character set.
The comparison function for characters, with the same specification as Stdlib.compare
. Along with the type t
, this function compare
allows the module Char
to be passed as argument to the functors Set.Make
and Map.Make
.
val seeded_hash : int -> t -> int
A seeded hash function for characters, with the same output value as Hashtbl.seeded_hash
. This function allows this module to be passed as argument to the functor Hashtbl.MakeSeeded
.
val hash : t -> int
An unseeded hash function for characters, with the same output value as Hashtbl.hash
. This function allows this module to be passed as argument to the functor Hashtbl.Make
.
+Char (less-power.Stdlib_alerts.Stdlib_alerting.Char) Module Stdlib_alerting.Char
include sig ... end
Return a string representing the given character, with special characters escaped following the lexical conventions of OCaml. All characters outside the ASCII printable range (32..126) are escaped, as well as backslash, double-quote, and single-quote.
Convert the given character to its equivalent lowercase character, using the US-ASCII character set.
Convert the given character to its equivalent uppercase character, using the US-ASCII character set.
The comparison function for characters, with the same specification as Stdlib.compare
. Along with the type t
, this function compare
allows the module Char
to be passed as argument to the functors Set.Make
and Map.Make
.
val seeded_hash : int -> t -> int
A seeded hash function for characters, with the same output value as Hashtbl.seeded_hash
. This function allows this module to be passed as argument to the functor Hashtbl.MakeSeeded
.
val hash : t -> int
An unseeded hash function for characters, with the same output value as Hashtbl.hash
. This function allows this module to be passed as argument to the functor Hashtbl.Make
.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Digest/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Digest/index.html
index e273db7..3148c93 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Digest/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Digest/index.html
@@ -1,2 +1,2 @@
-Digest (less-power.Stdlib_alerts.Stdlib_alerting.Digest) Module Stdlib_alerting.Digest
include sig ... end
The comparison function for 16-character digest, with the same specification as Stdlib.compare
and the implementation shared with String.compare
. Along with the type t
, this function compare
allows the module Digest
to be passed as argument to the functors Set.Make
and Map.Make
.
val string : string -> t
Return the digest of the given string.
val substring : string -> int -> int -> t
Digest.substring s ofs len
returns the digest of the substring of s
starting at index ofs
and containing len
characters.
val to_hex : t -> string
Return the printable hexadecimal representation of the given digest.
val from_hex : string -> t
Convert a hexadecimal representation back into the corresponding digest.
val bytes : bytes -> t
Return the digest of the given byte sequence.
val subbytes : bytes -> int -> int -> t
Digest.subbytes s ofs len
returns the digest of the subsequence of s
starting at index ofs
and containing len
bytes.
val channel : Stdlib.in_channel -> int -> t
If len
is nonnegative, Digest.channel ic len
reads len
characters from channel ic
and returns their digest, or raises End_of_file
if end-of-file is reached before len
characters are read. If len
is negative, Digest.channel ic len
reads all characters from ic
until end-of-file is reached and return their digest.
val file : string -> t
Return the digest of the file whose name is given.
val output : Stdlib.out_channel -> t -> unit
Write a digest on the given output channel.
val input : Stdlib.in_channel -> t
Read a digest from the given input channel.
+Digest (less-power.Stdlib_alerts.Stdlib_alerting.Digest) Module Stdlib_alerting.Digest
include sig ... end
The comparison function for 16-character digest, with the same specification as Stdlib.compare
and the implementation shared with String.compare
. Along with the type t
, this function compare
allows the module Digest
to be passed as argument to the functors Set.Make
and Map.Make
.
val string : string -> t
Return the digest of the given string.
val substring : string -> int -> int -> t
Digest.substring s ofs len
returns the digest of the substring of s
starting at index ofs
and containing len
characters.
val to_hex : t -> string
Return the printable hexadecimal representation of the given digest.
val from_hex : string -> t
Convert a hexadecimal representation back into the corresponding digest.
val bytes : bytes -> t
Return the digest of the given byte sequence.
val subbytes : bytes -> int -> int -> t
Digest.subbytes s ofs len
returns the digest of the subsequence of s
starting at index ofs
and containing len
bytes.
val channel : Stdlib.in_channel -> int -> t
If len
is nonnegative, Digest.channel ic len
reads len
characters from channel ic
and returns their digest, or raises End_of_file
if end-of-file is reached before len
characters are read. If len
is negative, Digest.channel ic len
reads all characters from ic
until end-of-file is reached and return their digest.
val file : string -> t
Return the digest of the file whose name is given.
val output : Stdlib.out_channel -> t -> unit
Write a digest on the given output channel.
val input : Stdlib.in_channel -> t
Read a digest from the given input channel.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Filename/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Filename/index.html
index 1df8855..8fbdb46 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Filename/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Filename/index.html
@@ -1,5 +1,5 @@
-Filename (less-power.Stdlib_alerts.Stdlib_alerting.Filename) Module Stdlib_alerting.Filename
include sig ... end
The conventional name for the parent of the current directory (e.g. ..
in Unix).
concat dir file
returns a file name that designates file file
in directory dir
.
Return true
if the file name is relative to the current directory, false
if it is absolute (i.e. in Unix, starts with /
).
Return true
if the file name is relative and does not start with an explicit reference to the current directory (./
or ../
in Unix), false
if it starts with an explicit reference to the root directory or the current directory.
check_suffix name suff
returns true
if the filename name
ends with the suffix suff
.
Under Windows ports (including Cygwin), comparison is case-insensitive, relying on String.lowercase_ascii
. Note that this does not match exactly the interpretation of case-insensitive filename equivalence from Windows.
chop_suffix name suff
removes the suffix suff
from the filename name
.
chop_suffix_opt ~suffix filename
removes the suffix from the filename
if possible, or returns None
if the filename does not end with the suffix.
Under Windows ports (including Cygwin), comparison is case-insensitive, relying on String.lowercase_ascii
. Note that this does not match exactly the interpretation of case-insensitive filename equivalence from Windows.
extension name
is the shortest suffix ext
of name0
where:
name0
is the longest suffix of name
that does not contain a directory separator;ext
starts with a period;ext
is preceded by at least one non-period character in name0
.
If such a suffix does not exist, extension name
is the empty string.
Return the given file name without its extension, as defined in Filename.extension
. If the extension is empty, the function returns the given file name.
The following invariant holds for any file name s
:
remove_extension s ^ extension s = s
Same as Filename.remove_extension
, but raise Invalid_argument
if the given name has an empty extension.
Split a file name into directory name / base file name. If name
is a valid file name, then concat (dirname name) (basename name)
returns a file name which is equivalent to name
. Moreover, after setting the current directory to dirname name
(with Sys.chdir
), references to basename name
(which is a relative file name) designate the same file as name
before the call to Sys.chdir
.
This function conforms to the specification of POSIX.1-2008 for the basename
utility.
See Filename.basename
. This function conforms to the specification of POSIX.1-2008 for the dirname
utility.
null
is "/dev/null"
on POSIX and "NUL"
on Windows. It represents a file on the OS that discards all writes and returns end of file on reads.
Return a quoted version of a file name, suitable for use as one argument in a command line, escaping all meta-characters. Warning: under Windows, the output is only suitable for use with programs that follow the standard Windows quoting conventions.
val quote_command :
+Filename (less-power.Stdlib_alerts.Stdlib_alerting.Filename) Module Stdlib_alerting.Filename
include sig ... end
The conventional name for the parent of the current directory (e.g. ..
in Unix).
concat dir file
returns a file name that designates file file
in directory dir
.
Return true
if the file name is relative to the current directory, false
if it is absolute (i.e. in Unix, starts with /
).
Return true
if the file name is relative and does not start with an explicit reference to the current directory (./
or ../
in Unix), false
if it starts with an explicit reference to the root directory or the current directory.
check_suffix name suff
returns true
if the filename name
ends with the suffix suff
.
Under Windows ports (including Cygwin), comparison is case-insensitive, relying on String.lowercase_ascii
. Note that this does not match exactly the interpretation of case-insensitive filename equivalence from Windows.
chop_suffix name suff
removes the suffix suff
from the filename name
.
chop_suffix_opt ~suffix filename
removes the suffix from the filename
if possible, or returns None
if the filename does not end with the suffix.
Under Windows ports (including Cygwin), comparison is case-insensitive, relying on String.lowercase_ascii
. Note that this does not match exactly the interpretation of case-insensitive filename equivalence from Windows.
extension name
is the shortest suffix ext
of name0
where:
name0
is the longest suffix of name
that does not contain a directory separator;ext
starts with a period;ext
is preceded by at least one non-period character in name0
.
If such a suffix does not exist, extension name
is the empty string.
Return the given file name without its extension, as defined in Filename.extension
. If the extension is empty, the function returns the given file name.
The following invariant holds for any file name s
:
remove_extension s ^ extension s = s
Same as Filename.remove_extension
, but raise Invalid_argument
if the given name has an empty extension.
Split a file name into directory name / base file name. If name
is a valid file name, then concat (dirname name) (basename name)
returns a file name which is equivalent to name
. Moreover, after setting the current directory to dirname name
(with Sys.chdir
), references to basename name
(which is a relative file name) designate the same file as name
before the call to Sys.chdir
.
This function conforms to the specification of POSIX.1-2008 for the basename
utility.
See Filename.basename
. This function conforms to the specification of POSIX.1-2008 for the dirname
utility.
null
is "/dev/null"
on POSIX and "NUL"
on Windows. It represents a file on the OS that discards all writes and returns end of file on reads.
Return a quoted version of a file name, suitable for use as one argument in a command line, escaping all meta-characters. Warning: under Windows, the output is only suitable for use with programs that follow the standard Windows quoting conventions.
val quote_command :
string ->
?stdin:string ->
?stdout:string ->
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/Array/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/Array/index.html
index a0bba10..17e58ca 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/Array/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/Array/index.html
@@ -1,5 +1,5 @@
-Array (less-power.Stdlib_alerts.Stdlib_alerting.Float.Array) Module Float.Array
Float arrays with packed representation.
val length : t -> int
Return the length (number of elements) of the given floatarray.
val get : t -> int -> float
get a n
returns the element number n
of floatarray a
.
val set : t -> int -> float -> unit
set a n x
modifies floatarray a
in place, replacing element number n
with x
.
val make : int -> float -> t
make n x
returns a fresh floatarray of length n
, initialized with x
.
val create : int -> t
create n
returns a fresh floatarray of length n
, with uninitialized data.
val init : int -> (int -> float) -> t
init n f
returns a fresh floatarray of length n
, with element number i
initialized to the result of f i
. In other terms, init n f
tabulates the results of f
applied to the integers 0
to n-1
.
append v1 v2
returns a fresh floatarray containing the concatenation of the floatarrays v1
and v2
.
sub a pos len
returns a fresh floatarray of length len
, containing the elements number pos
to pos + len - 1
of floatarray a
.
copy a
returns a copy of a
, that is, a fresh floatarray containing the same elements as a
.
val fill : t -> int -> int -> float -> unit
fill a pos len x
modifies the floatarray a
in place, storing x
in elements number pos
to pos + len - 1
.
blit src src_pos dst dst_pos len
copies len
elements from floatarray src
, starting at element number src_pos
, to floatarray dst
, starting at element number dst_pos
. It works correctly even if src
and dst
are the same floatarray, and the source and destination chunks overlap.
val to_list : t -> float list
to_list a
returns the list of all the elements of a
.
val of_list : float list -> t
of_list l
returns a fresh floatarray containing the elements of l
.
Iterators
val iter : (float -> unit) -> t -> unit
iter f a
applies function f
in turn to all the elements of a
. It is equivalent to f a.(0); f a.(1); ...; f a.(length a - 1); ()
.
val iteri : (int -> float -> unit) -> t -> unit
Same as iter
, but the function is applied with the index of the element as first argument, and the element itself as second argument.
map f a
applies function f
to all the elements of a
, and builds a floatarray with the results returned by f
.
val map_inplace : (float -> float) -> t -> unit
map_inplace f a
applies function f
to all elements of a
, and updates their values in place.
Same as map
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
val mapi_inplace : (int -> float -> float) -> t -> unit
Same as map_inplace
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
val fold_left : ('acc -> float -> 'acc) -> 'acc -> t -> 'acc
fold_left f x init
computes f (... (f (f x init.(0)) init.(1)) ...) init.(n-1)
, where n
is the length of the floatarray init
.
val fold_right : (float -> 'acc -> 'acc) -> t -> 'acc -> 'acc
fold_right f a init
computes f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...))
, where n
is the length of the floatarray a
.
Iterators on two arrays
Array.iter2 f a b
applies function f
to all the elements of a
and b
.
map2 f a b
applies function f
to all the elements of a
and b
, and builds a floatarray with the results returned by f
: [| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]
.
Array scanning
val for_all : (float -> bool) -> t -> bool
for_all f [|a1; ...; an|]
checks if all elements of the floatarray satisfy the predicate f
. That is, it returns (f a1) && (f a2) && ... && (f an)
.
val exists : (float -> bool) -> t -> bool
exists f [|a1; ...; an|]
checks if at least one element of the floatarray satisfies the predicate f
. That is, it returns (f a1) || (f a2) || ... || (f an)
.
val mem : float -> t -> bool
mem a set
is true if and only if there is an element of set
that is structurally equal to a
, i.e. there is an x
in set
such that compare a x = 0
.
val mem_ieee : float -> t -> bool
Same as mem
, but uses IEEE equality instead of structural equality.
Array searching
val find_opt : (float -> bool) -> t -> float option
val find_index : (float -> bool) -> t -> int option
find_index f a
returns Some i
, where i
is the index of the first element of the array a
that satisfies f x
, if there is such an element.
It returns None
if there is no such element.
val find_map : (float -> 'a option) -> t -> 'a option
val find_mapi : (int -> float -> 'a option) -> t -> 'a option
Same as find_map
, but the predicate is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
Sorting
val sort : (float -> float -> int) -> t -> unit
Sort a floatarray in increasing order according to a comparison function. The comparison function must return 0 if its arguments compare as equal, a positive integer if the first is greater, and a negative integer if the first is smaller (see below for a complete specification). For example, Stdlib.compare
is a suitable comparison function. After calling sort
, the array is sorted in place in increasing order. sort
is guaranteed to run in constant heap space and (at most) logarithmic stack space.
The current implementation uses Heap Sort. It runs in constant stack space.
Specification of the comparison function: Let a
be the floatarray and cmp
the comparison function. The following must be true for all x
, y
, z
in a
:
cmp x y
> 0 if and only if cmp y x
< 0- if
cmp x y
>= 0 and cmp y z
>= 0 then cmp x z
>= 0
When sort
returns, a
contains the same elements as before, reordered in such a way that for all i and j valid indices of a
:
cmp a.(i) a.(j)
>= 0 if and only if i >= j
val stable_sort : (float -> float -> int) -> t -> unit
Same as sort
, but the sorting algorithm is stable (i.e. elements that compare equal are kept in their original order) and not guaranteed to run in constant heap space.
The current implementation uses Merge Sort. It uses a temporary floatarray of length n/2
, where n
is the length of the floatarray. It is usually faster than the current implementation of sort
.
val fast_sort : (float -> float -> int) -> t -> unit
Same as sort
or stable_sort
, whichever is faster on typical input.
Float arrays and Sequences
val to_seq : t -> float Stdlib.Seq.t
Iterate on the floatarray, in increasing order. Modifications of the floatarray during iteration will be reflected in the sequence.
val to_seqi : t -> (int * float) Stdlib.Seq.t
Iterate on the floatarray, in increasing order, yielding indices along elements. Modifications of the floatarray during iteration will be reflected in the sequence.
val of_seq : float Stdlib.Seq.t -> t
Create an array from the generator.
val map_to_array : (float -> 'a) -> t -> 'a array
map_to_array f a
applies function f
to all the elements of a
, and builds an array with the results returned by f
: [| f a.(0); f a.(1); ...; f a.(length a - 1) |]
.
val map_from_array : ('a -> float) -> 'a array -> t
map_from_array f a
applies function f
to all the elements of a
, and builds a floatarray with the results returned by f
.
Arrays and concurrency safety
Care must be taken when concurrently accessing float arrays from multiple domains: accessing an array will never crash a program, but unsynchronized accesses might yield surprising (non-sequentially-consistent) results.
Atomicity
Every float array operation that accesses more than one array element is not atomic. This includes iteration, scanning, sorting, splitting and combining arrays.
For example, consider the following program:
let size = 100_000_000
+Array (less-power.Stdlib_alerts.Stdlib_alerting.Float.Array) Module Float.Array
Float arrays with packed representation.
val length : t -> int
Return the length (number of elements) of the given floatarray.
val get : t -> int -> float
get a n
returns the element number n
of floatarray a
.
val set : t -> int -> float -> unit
set a n x
modifies floatarray a
in place, replacing element number n
with x
.
val make : int -> float -> t
make n x
returns a fresh floatarray of length n
, initialized with x
.
val create : int -> t
create n
returns a fresh floatarray of length n
, with uninitialized data.
val init : int -> (int -> float) -> t
init n f
returns a fresh floatarray of length n
, with element number i
initialized to the result of f i
. In other terms, init n f
tabulates the results of f
applied to the integers 0
to n-1
.
append v1 v2
returns a fresh floatarray containing the concatenation of the floatarrays v1
and v2
.
sub a pos len
returns a fresh floatarray of length len
, containing the elements number pos
to pos + len - 1
of floatarray a
.
copy a
returns a copy of a
, that is, a fresh floatarray containing the same elements as a
.
val fill : t -> int -> int -> float -> unit
fill a pos len x
modifies the floatarray a
in place, storing x
in elements number pos
to pos + len - 1
.
blit src src_pos dst dst_pos len
copies len
elements from floatarray src
, starting at element number src_pos
, to floatarray dst
, starting at element number dst_pos
. It works correctly even if src
and dst
are the same floatarray, and the source and destination chunks overlap.
val to_list : t -> float list
to_list a
returns the list of all the elements of a
.
val of_list : float list -> t
of_list l
returns a fresh floatarray containing the elements of l
.
Iterators
val iter : (float -> unit) -> t -> unit
iter f a
applies function f
in turn to all the elements of a
. It is equivalent to f a.(0); f a.(1); ...; f a.(length a - 1); ()
.
val iteri : (int -> float -> unit) -> t -> unit
Same as iter
, but the function is applied with the index of the element as first argument, and the element itself as second argument.
map f a
applies function f
to all the elements of a
, and builds a floatarray with the results returned by f
.
val map_inplace : (float -> float) -> t -> unit
map_inplace f a
applies function f
to all elements of a
, and updates their values in place.
Same as map
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
val mapi_inplace : (int -> float -> float) -> t -> unit
Same as map_inplace
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
val fold_left : ('acc -> float -> 'acc) -> 'acc -> t -> 'acc
fold_left f x init
computes f (... (f (f x init.(0)) init.(1)) ...) init.(n-1)
, where n
is the length of the floatarray init
.
val fold_right : (float -> 'acc -> 'acc) -> t -> 'acc -> 'acc
fold_right f a init
computes f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...))
, where n
is the length of the floatarray a
.
Iterators on two arrays
Array.iter2 f a b
applies function f
to all the elements of a
and b
.
map2 f a b
applies function f
to all the elements of a
and b
, and builds a floatarray with the results returned by f
: [| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]
.
Array scanning
val for_all : (float -> bool) -> t -> bool
for_all f [|a1; ...; an|]
checks if all elements of the floatarray satisfy the predicate f
. That is, it returns (f a1) && (f a2) && ... && (f an)
.
val exists : (float -> bool) -> t -> bool
exists f [|a1; ...; an|]
checks if at least one element of the floatarray satisfies the predicate f
. That is, it returns (f a1) || (f a2) || ... || (f an)
.
val mem : float -> t -> bool
mem a set
is true if and only if there is an element of set
that is structurally equal to a
, i.e. there is an x
in set
such that compare a x = 0
.
val mem_ieee : float -> t -> bool
Same as mem
, but uses IEEE equality instead of structural equality.
Array searching
val find_opt : (float -> bool) -> t -> float option
val find_index : (float -> bool) -> t -> int option
find_index f a
returns Some i
, where i
is the index of the first element of the array a
that satisfies f x
, if there is such an element.
It returns None
if there is no such element.
val find_map : (float -> 'a option) -> t -> 'a option
val find_mapi : (int -> float -> 'a option) -> t -> 'a option
Same as find_map
, but the predicate is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
Sorting
val sort : (float -> float -> int) -> t -> unit
Sort a floatarray in increasing order according to a comparison function. The comparison function must return 0 if its arguments compare as equal, a positive integer if the first is greater, and a negative integer if the first is smaller (see below for a complete specification). For example, Stdlib.compare
is a suitable comparison function. After calling sort
, the array is sorted in place in increasing order. sort
is guaranteed to run in constant heap space and (at most) logarithmic stack space.
The current implementation uses Heap Sort. It runs in constant stack space.
Specification of the comparison function: Let a
be the floatarray and cmp
the comparison function. The following must be true for all x
, y
, z
in a
:
cmp x y
> 0 if and only if cmp y x
< 0- if
cmp x y
>= 0 and cmp y z
>= 0 then cmp x z
>= 0
When sort
returns, a
contains the same elements as before, reordered in such a way that for all i and j valid indices of a
:
cmp a.(i) a.(j)
>= 0 if and only if i >= j
val stable_sort : (float -> float -> int) -> t -> unit
Same as sort
, but the sorting algorithm is stable (i.e. elements that compare equal are kept in their original order) and not guaranteed to run in constant heap space.
The current implementation uses Merge Sort. It uses a temporary floatarray of length n/2
, where n
is the length of the floatarray. It is usually faster than the current implementation of sort
.
val fast_sort : (float -> float -> int) -> t -> unit
Same as sort
or stable_sort
, whichever is faster on typical input.
Float arrays and Sequences
val to_seq : t -> float Stdlib.Seq.t
Iterate on the floatarray, in increasing order. Modifications of the floatarray during iteration will be reflected in the sequence.
val to_seqi : t -> (int * float) Stdlib.Seq.t
Iterate on the floatarray, in increasing order, yielding indices along elements. Modifications of the floatarray during iteration will be reflected in the sequence.
val of_seq : float Stdlib.Seq.t -> t
Create an array from the generator.
val map_to_array : (float -> 'a) -> t -> 'a array
map_to_array f a
applies function f
to all the elements of a
, and builds an array with the results returned by f
: [| f a.(0); f a.(1); ...; f a.(length a - 1) |]
.
val map_from_array : ('a -> float) -> 'a array -> t
map_from_array f a
applies function f
to all the elements of a
, and builds a floatarray with the results returned by f
.
Arrays and concurrency safety
Care must be taken when concurrently accessing float arrays from multiple domains: accessing an array will never crash a program, but unsynchronized accesses might yield surprising (non-sequentially-consistent) results.
Atomicity
Every float array operation that accesses more than one array element is not atomic. This includes iteration, scanning, sorting, splitting and combining arrays.
For example, consider the following program:
let size = 100_000_000
let a = Float.Array.make size 1.
let update a f () =
Float.Array.iteri (fun i x -> Float.Array.set a i (f x)) a
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/ArrayLabels/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/ArrayLabels/index.html
index efa24bd..a088adb 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/ArrayLabels/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/ArrayLabels/index.html
@@ -1,5 +1,5 @@
-ArrayLabels (less-power.Stdlib_alerts.Stdlib_alerting.Float.ArrayLabels) Module Float.ArrayLabels
Float arrays with packed representation (labeled functions).
val length : t -> int
Return the length (number of elements) of the given floatarray.
val get : t -> int -> float
get a n
returns the element number n
of floatarray a
.
val set : t -> int -> float -> unit
set a n x
modifies floatarray a
in place, replacing element number n
with x
.
val make : int -> float -> t
make n x
returns a fresh floatarray of length n
, initialized with x
.
val create : int -> t
create n
returns a fresh floatarray of length n
, with uninitialized data.
val init : int -> f:(int -> float) -> t
init n ~f
returns a fresh floatarray of length n
, with element number i
initialized to the result of f i
. In other terms, init n ~f
tabulates the results of f
applied to the integers 0
to n-1
.
append v1 v2
returns a fresh floatarray containing the concatenation of the floatarrays v1
and v2
.
sub a ~pos ~len
returns a fresh floatarray of length len
, containing the elements number pos
to pos + len - 1
of floatarray a
.
copy a
returns a copy of a
, that is, a fresh floatarray containing the same elements as a
.
val fill : t -> pos:int -> len:int -> float -> unit
fill a ~pos ~len x
modifies the floatarray a
in place, storing x
in elements number pos
to pos + len - 1
.
blit ~src ~src_pos ~dst ~dst_pos ~len
copies len
elements from floatarray src
, starting at element number src_pos
, to floatarray dst
, starting at element number dst_pos
. It works correctly even if src
and dst
are the same floatarray, and the source and destination chunks overlap.
val to_list : t -> float list
to_list a
returns the list of all the elements of a
.
val of_list : float list -> t
of_list l
returns a fresh floatarray containing the elements of l
.
Iterators
val iter : f:(float -> unit) -> t -> unit
iter ~f a
applies function f
in turn to all the elements of a
. It is equivalent to f a.(0); f a.(1); ...; f a.(length a - 1); ()
.
val iteri : f:(int -> float -> unit) -> t -> unit
Same as iter
, but the function is applied with the index of the element as first argument, and the element itself as second argument.
map ~f a
applies function f
to all the elements of a
, and builds a floatarray with the results returned by f
.
val map_inplace : f:(float -> float) -> t -> unit
map_inplace f a
applies function f
to all elements of a
, and updates their values in place.
Same as map
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
val mapi_inplace : f:(int -> float -> float) -> t -> unit
Same as map_inplace
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
val fold_left : f:('acc -> float -> 'acc) -> init:'acc -> t -> 'acc
fold_left ~f x ~init
computes f (... (f (f x init.(0)) init.(1)) ...) init.(n-1)
, where n
is the length of the floatarray init
.
val fold_right : f:(float -> 'acc -> 'acc) -> t -> init:'acc -> 'acc
fold_right f a init
computes f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...))
, where n
is the length of the floatarray a
.
Iterators on two arrays
Array.iter2 ~f a b
applies function f
to all the elements of a
and b
.
map2 ~f a b
applies function f
to all the elements of a
and b
, and builds a floatarray with the results returned by f
: [| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]
.
Array scanning
val for_all : f:(float -> bool) -> t -> bool
for_all ~f [|a1; ...; an|]
checks if all elements of the floatarray satisfy the predicate f
. That is, it returns (f a1) && (f a2) && ... && (f an)
.
val exists : f:(float -> bool) -> t -> bool
exists f [|a1; ...; an|]
checks if at least one element of the floatarray satisfies the predicate f
. That is, it returns (f a1) || (f a2) || ... || (f an)
.
val mem : float -> set:t -> bool
mem a ~set
is true if and only if there is an element of set
that is structurally equal to a
, i.e. there is an x
in set
such that compare a x = 0
.
val mem_ieee : float -> set:t -> bool
Same as mem
, but uses IEEE equality instead of structural equality.
Array searching
val find_opt : f:(float -> bool) -> t -> float option
val find_index : f:(float -> bool) -> t -> int option
find_index ~f a
returns Some i
, where i
is the index of the first element of the array a
that satisfies f x
, if there is such an element.
It returns None
if there is no such element.
val find_map : f:(float -> 'a option) -> t -> 'a option
val find_mapi : f:(int -> float -> 'a option) -> t -> 'a option
Same as find_map
, but the predicate is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
Sorting
val sort : cmp:(float -> float -> int) -> t -> unit
Sort a floatarray in increasing order according to a comparison function. The comparison function must return 0 if its arguments compare as equal, a positive integer if the first is greater, and a negative integer if the first is smaller (see below for a complete specification). For example, Stdlib.compare
is a suitable comparison function. After calling sort
, the array is sorted in place in increasing order. sort
is guaranteed to run in constant heap space and (at most) logarithmic stack space.
The current implementation uses Heap Sort. It runs in constant stack space.
Specification of the comparison function: Let a
be the floatarray and cmp
the comparison function. The following must be true for all x
, y
, z
in a
:
cmp x y
> 0 if and only if cmp y x
< 0- if
cmp x y
>= 0 and cmp y z
>= 0 then cmp x z
>= 0
When sort
returns, a
contains the same elements as before, reordered in such a way that for all i and j valid indices of a
:
cmp a.(i) a.(j)
>= 0 if and only if i >= j
val stable_sort : cmp:(float -> float -> int) -> t -> unit
Same as sort
, but the sorting algorithm is stable (i.e. elements that compare equal are kept in their original order) and not guaranteed to run in constant heap space.
The current implementation uses Merge Sort. It uses a temporary floatarray of length n/2
, where n
is the length of the floatarray. It is usually faster than the current implementation of sort
.
val fast_sort : cmp:(float -> float -> int) -> t -> unit
Same as sort
or stable_sort
, whichever is faster on typical input.
Float arrays and Sequences
val to_seq : t -> float Stdlib.Seq.t
Iterate on the floatarray, in increasing order. Modifications of the floatarray during iteration will be reflected in the sequence.
val to_seqi : t -> (int * float) Stdlib.Seq.t
Iterate on the floatarray, in increasing order, yielding indices along elements. Modifications of the floatarray during iteration will be reflected in the sequence.
val of_seq : float Stdlib.Seq.t -> t
Create an array from the generator.
val map_to_array : f:(float -> 'a) -> t -> 'a array
map_to_array ~f a
applies function f
to all the elements of a
, and builds an array with the results returned by f
: [| f a.(0); f a.(1); ...; f a.(length a - 1) |]
.
val map_from_array : f:('a -> float) -> 'a array -> t
map_from_array ~f a
applies function f
to all the elements of a
, and builds a floatarray with the results returned by f
.
Arrays and concurrency safety
Care must be taken when concurrently accessing float arrays from multiple domains: accessing an array will never crash a program, but unsynchronized accesses might yield surprising (non-sequentially-consistent) results.
Atomicity
Every float array operation that accesses more than one array element is not atomic. This includes iteration, scanning, sorting, splitting and combining arrays.
For example, consider the following program:
let size = 100_000_000
+ArrayLabels (less-power.Stdlib_alerts.Stdlib_alerting.Float.ArrayLabels) Module Float.ArrayLabels
Float arrays with packed representation (labeled functions).
val length : t -> int
Return the length (number of elements) of the given floatarray.
val get : t -> int -> float
get a n
returns the element number n
of floatarray a
.
val set : t -> int -> float -> unit
set a n x
modifies floatarray a
in place, replacing element number n
with x
.
val make : int -> float -> t
make n x
returns a fresh floatarray of length n
, initialized with x
.
val create : int -> t
create n
returns a fresh floatarray of length n
, with uninitialized data.
val init : int -> f:(int -> float) -> t
init n ~f
returns a fresh floatarray of length n
, with element number i
initialized to the result of f i
. In other terms, init n ~f
tabulates the results of f
applied to the integers 0
to n-1
.
append v1 v2
returns a fresh floatarray containing the concatenation of the floatarrays v1
and v2
.
sub a ~pos ~len
returns a fresh floatarray of length len
, containing the elements number pos
to pos + len - 1
of floatarray a
.
copy a
returns a copy of a
, that is, a fresh floatarray containing the same elements as a
.
val fill : t -> pos:int -> len:int -> float -> unit
fill a ~pos ~len x
modifies the floatarray a
in place, storing x
in elements number pos
to pos + len - 1
.
blit ~src ~src_pos ~dst ~dst_pos ~len
copies len
elements from floatarray src
, starting at element number src_pos
, to floatarray dst
, starting at element number dst_pos
. It works correctly even if src
and dst
are the same floatarray, and the source and destination chunks overlap.
val to_list : t -> float list
to_list a
returns the list of all the elements of a
.
val of_list : float list -> t
of_list l
returns a fresh floatarray containing the elements of l
.
Iterators
val iter : f:(float -> unit) -> t -> unit
iter ~f a
applies function f
in turn to all the elements of a
. It is equivalent to f a.(0); f a.(1); ...; f a.(length a - 1); ()
.
val iteri : f:(int -> float -> unit) -> t -> unit
Same as iter
, but the function is applied with the index of the element as first argument, and the element itself as second argument.
map ~f a
applies function f
to all the elements of a
, and builds a floatarray with the results returned by f
.
val map_inplace : f:(float -> float) -> t -> unit
map_inplace f a
applies function f
to all elements of a
, and updates their values in place.
Same as map
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
val mapi_inplace : f:(int -> float -> float) -> t -> unit
Same as map_inplace
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
val fold_left : f:('acc -> float -> 'acc) -> init:'acc -> t -> 'acc
fold_left ~f x ~init
computes f (... (f (f x init.(0)) init.(1)) ...) init.(n-1)
, where n
is the length of the floatarray init
.
val fold_right : f:(float -> 'acc -> 'acc) -> t -> init:'acc -> 'acc
fold_right f a init
computes f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...))
, where n
is the length of the floatarray a
.
Iterators on two arrays
Array.iter2 ~f a b
applies function f
to all the elements of a
and b
.
map2 ~f a b
applies function f
to all the elements of a
and b
, and builds a floatarray with the results returned by f
: [| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]
.
Array scanning
val for_all : f:(float -> bool) -> t -> bool
for_all ~f [|a1; ...; an|]
checks if all elements of the floatarray satisfy the predicate f
. That is, it returns (f a1) && (f a2) && ... && (f an)
.
val exists : f:(float -> bool) -> t -> bool
exists f [|a1; ...; an|]
checks if at least one element of the floatarray satisfies the predicate f
. That is, it returns (f a1) || (f a2) || ... || (f an)
.
val mem : float -> set:t -> bool
mem a ~set
is true if and only if there is an element of set
that is structurally equal to a
, i.e. there is an x
in set
such that compare a x = 0
.
val mem_ieee : float -> set:t -> bool
Same as mem
, but uses IEEE equality instead of structural equality.
Array searching
val find_opt : f:(float -> bool) -> t -> float option
val find_index : f:(float -> bool) -> t -> int option
find_index ~f a
returns Some i
, where i
is the index of the first element of the array a
that satisfies f x
, if there is such an element.
It returns None
if there is no such element.
val find_map : f:(float -> 'a option) -> t -> 'a option
val find_mapi : f:(int -> float -> 'a option) -> t -> 'a option
Same as find_map
, but the predicate is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
Sorting
val sort : cmp:(float -> float -> int) -> t -> unit
Sort a floatarray in increasing order according to a comparison function. The comparison function must return 0 if its arguments compare as equal, a positive integer if the first is greater, and a negative integer if the first is smaller (see below for a complete specification). For example, Stdlib.compare
is a suitable comparison function. After calling sort
, the array is sorted in place in increasing order. sort
is guaranteed to run in constant heap space and (at most) logarithmic stack space.
The current implementation uses Heap Sort. It runs in constant stack space.
Specification of the comparison function: Let a
be the floatarray and cmp
the comparison function. The following must be true for all x
, y
, z
in a
:
cmp x y
> 0 if and only if cmp y x
< 0- if
cmp x y
>= 0 and cmp y z
>= 0 then cmp x z
>= 0
When sort
returns, a
contains the same elements as before, reordered in such a way that for all i and j valid indices of a
:
cmp a.(i) a.(j)
>= 0 if and only if i >= j
val stable_sort : cmp:(float -> float -> int) -> t -> unit
Same as sort
, but the sorting algorithm is stable (i.e. elements that compare equal are kept in their original order) and not guaranteed to run in constant heap space.
The current implementation uses Merge Sort. It uses a temporary floatarray of length n/2
, where n
is the length of the floatarray. It is usually faster than the current implementation of sort
.
val fast_sort : cmp:(float -> float -> int) -> t -> unit
Same as sort
or stable_sort
, whichever is faster on typical input.
Float arrays and Sequences
val to_seq : t -> float Stdlib.Seq.t
Iterate on the floatarray, in increasing order. Modifications of the floatarray during iteration will be reflected in the sequence.
val to_seqi : t -> (int * float) Stdlib.Seq.t
Iterate on the floatarray, in increasing order, yielding indices along elements. Modifications of the floatarray during iteration will be reflected in the sequence.
val of_seq : float Stdlib.Seq.t -> t
Create an array from the generator.
val map_to_array : f:(float -> 'a) -> t -> 'a array
map_to_array ~f a
applies function f
to all the elements of a
, and builds an array with the results returned by f
: [| f a.(0); f a.(1); ...; f a.(length a - 1) |]
.
val map_from_array : f:('a -> float) -> 'a array -> t
map_from_array ~f a
applies function f
to all the elements of a
, and builds a floatarray with the results returned by f
.
Arrays and concurrency safety
Care must be taken when concurrently accessing float arrays from multiple domains: accessing an array will never crash a program, but unsynchronized accesses might yield surprising (non-sequentially-consistent) results.
Atomicity
Every float array operation that accesses more than one array element is not atomic. This includes iteration, scanning, sorting, splitting and combining arrays.
For example, consider the following program:
let size = 100_000_000
let a = Float.ArrayLabels.make size 1.
let update a f () =
Float.ArrayLabels.iteri ~f:(fun i x -> Float.Array.set a i (f x)) a
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/index.html
index e8c0320..dcd19d7 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Float/index.html
@@ -1,2 +1,2 @@
-Float (less-power.Stdlib_alerts.Stdlib_alerting.Float) Module Stdlib_alerting.Float
include sig ... end
fma x y z
returns x * y + z
, with a best effort for computing this expression with a single rounding, using either hardware instructions (providing full IEEE compliance) or a software emulation.
On 64-bit Cygwin, 64-bit mingw-w64 and MSVC 2017 and earlier, this function may be emulated owing to known bugs on limitations on these platforms. Note: since software emulation of the fma is costly, make sure that you are using hardware fma support if performance matters.
rem a b
returns the remainder of a
with respect to b
. The returned value is a -. n *. b
, where n
is the quotient a /. b
rounded towards zero to an integer.
succ x
returns the floating point number right after x
i.e., the smallest floating-point number greater than x
. See also next_after
.
pred x
returns the floating-point number right before x
i.e., the greatest floating-point number smaller than x
. See also next_after
.
A special floating-point value denoting the result of an undefined operation such as 0.0 /. 0.0
. Stands for 'not a number'. Any floating-point operation with nan
as argument returns nan
as result, unless otherwise specified in IEEE 754 standard. As for floating-point comparisons, =
, <
, <=
, >
and >=
return false
and <>
returns true
if one or both of their arguments is nan
.
nan
is quiet_nan
since 5.1; it was a signaling NaN before.
Signaling NaN. The corresponding signals do not raise OCaml exception, but the value can be useful for interoperability with C libraries.
The difference between 1.0
and the smallest exactly representable floating-point number greater than 1.0
.
is_finite x
is true
if and only if x
is finite i.e., not infinite and not nan
.
is_infinite x
is true
if and only if x
is infinity
or neg_infinity
.
is_nan x
is true
if and only if x
is not a number (see nan
).
Truncate the given floating-point number to an integer. The result is unspecified if the argument is nan
or falls outside the range of representable integers.
Convert the given string to a float. The string is read in decimal (by default) or in hexadecimal (marked by 0x
or 0X
). The format of decimal floating-point numbers is [-] dd.ddd (e|E) [+|-] dd
, where d
stands for a decimal digit. The format of hexadecimal floating-point numbers is [-] 0(x|X) hh.hhh (p|P) [+|-] dd
, where h
stands for an hexadecimal digit and d
for a decimal digit. In both cases, at least one of the integer and fractional parts must be given; the exponent part is optional. The _
(underscore) character can appear anywhere in the string and is ignored. Depending on the execution platforms, other representations of floating-point numbers can be accepted, but should not be relied upon.
Return a string representation of a floating-point number.
This conversion can involve a loss of precision. For greater control over the manner in which the number is printed, see Printf
.
This function is an alias for Stdlib.string_of_float
.
The five classes of floating-point numbers, as determined by the classify_float
function.
val classify_float : float -> fpclass
Return the class of the given floating-point number: normal, subnormal, zero, infinite, or not a number.
expm1 x
computes exp x -. 1.0
, giving numerically-accurate results even if x
is close to 0.0
.
log1p x
computes log(1.0 +. x)
(natural logarithm), giving numerically-accurate results even if x
is close to 0.0
.
Arc cosine. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and is between 0.0
and pi
.
Arc sine. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and is between -pi/2
and pi/2
.
atan2 y x
returns the arc tangent of y /. x
. The signs of x
and y
are used to determine the quadrant of the result. Result is in radians and is between -pi
and pi
.
hypot x y
returns sqrt(x *. x +. y *. y)
, that is, the length of the hypotenuse of a right-angled triangle with sides of length x
and y
, or, equivalently, the distance of the point (x,y)
to origin. If one of x
or y
is infinite, returns infinity
even if the other is nan
.
Hyperbolic arc cosine. The argument must fall within the range [1.0, inf]
. Result is in radians and is between 0.0
and inf
.
Hyperbolic arc sine. The argument and result range over the entire real line. Result is in radians.
Hyperbolic arc tangent. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and ranges over the entire real line.
Error function. The argument ranges over the entire real line. The result is always within [-1.0, 1.0]
.
Complementary error function (erfc x = 1 - erf x
). The argument ranges over the entire real line. The result is always within [-1.0, 1.0]
.
trunc x
rounds x
to the nearest integer whose absolute value is less than or equal to x
.
round x
rounds x
to the nearest integer with ties (fractional values of 0.5) rounded away from zero, regardless of the current rounding direction. If x
is an integer, +0.
, -0.
, nan
, or infinite, x
itself is returned.
On 64-bit mingw-w64, this function may be emulated owing to a bug in the C runtime library (CRT) on this platform.
Round above to an integer value. ceil f
returns the least integer value greater than or equal to f
. The result is returned as a float.
Round below to an integer value. floor f
returns the greatest integer value less than or equal to f
. The result is returned as a float.
next_after x y
returns the next representable floating-point value following x
in the direction of y
. More precisely, if y
is greater (resp. less) than x
, it returns the smallest (resp. largest) representable number greater (resp. less) than x
. If x
equals y
, the function returns y
. If x
or y
is nan
, a nan
is returned. Note that next_after max_float infinity = infinity
and that next_after 0. infinity
is the smallest denormalized positive number. If x
is the smallest denormalized positive number, next_after x 0. = 0.
copy_sign x y
returns a float whose absolute value is that of x
and whose sign is that of y
. If x
is nan
, returns nan
. If y
is nan
, returns either x
or -. x
, but it is not specified which.
sign_bit x
is true
if and only if the sign bit of x
is set. For example sign_bit 1.
and signbit 0.
are false
while sign_bit (-1.)
and sign_bit (-0.)
are true
.
frexp f
returns the pair of the significant and the exponent of f
. When f
is zero, the significant x
and the exponent n
of f
are equal to zero. When f
is non-zero, they are defined by f = x *. 2 ** n
and 0.5 <= x < 1.0
.
compare x y
returns 0
if x
is equal to y
, a negative integer if x
is less than y
, and a positive integer if x
is greater than y
. compare
treats nan
as equal to itself and less than any other float value. This treatment of nan
ensures that compare
defines a total ordering relation.
min x y
returns the minimum of x
and y
. It returns nan
when x
or y
is nan
. Moreover min (-0.) (+0.) = -0.
max x y
returns the maximum of x
and y
. It returns nan
when x
or y
is nan
. Moreover max (-0.) (+0.) = +0.
min_max x y
is (min x y, max x y)
, just more efficient.
min_num x y
returns the minimum of x
and y
treating nan
as missing values. If both x
and y
are nan
, nan
is returned. Moreover min_num (-0.) (+0.) = -0.
max_num x y
returns the maximum of x
and y
treating nan
as missing values. If both x
and y
are nan
nan
is returned. Moreover max_num (-0.) (+0.) = +0.
min_max_num x y
is (min_num x y, max_num x y)
, just more efficient. Note that in particular min_max_num x nan = (x, x)
and min_max_num nan y = (y, y)
.
val seeded_hash : int -> t -> int
A seeded hash function for floats, with the same output value as Hashtbl.seeded_hash
. This function allows this module to be passed as argument to the functor Hashtbl.MakeSeeded
.
val hash : t -> int
An unseeded hash function for floats, with the same output value as Hashtbl.hash
. This function allows this module to be passed as argument to the functor Hashtbl.Make
.
module Array : sig ... end
Float arrays with packed representation.
module ArrayLabels : sig ... end
Float arrays with packed representation (labeled functions).
+Float (less-power.Stdlib_alerts.Stdlib_alerting.Float) Module Stdlib_alerting.Float
include sig ... end
fma x y z
returns x * y + z
, with a best effort for computing this expression with a single rounding, using either hardware instructions (providing full IEEE compliance) or a software emulation.
On 64-bit Cygwin, 64-bit mingw-w64 and MSVC 2017 and earlier, this function may be emulated owing to known bugs on limitations on these platforms. Note: since software emulation of the fma is costly, make sure that you are using hardware fma support if performance matters.
rem a b
returns the remainder of a
with respect to b
. The returned value is a -. n *. b
, where n
is the quotient a /. b
rounded towards zero to an integer.
succ x
returns the floating point number right after x
i.e., the smallest floating-point number greater than x
. See also next_after
.
pred x
returns the floating-point number right before x
i.e., the greatest floating-point number smaller than x
. See also next_after
.
A special floating-point value denoting the result of an undefined operation such as 0.0 /. 0.0
. Stands for 'not a number'. Any floating-point operation with nan
as argument returns nan
as result, unless otherwise specified in IEEE 754 standard. As for floating-point comparisons, =
, <
, <=
, >
and >=
return false
and <>
returns true
if one or both of their arguments is nan
.
nan
is quiet_nan
since 5.1; it was a signaling NaN before.
Signaling NaN. The corresponding signals do not raise OCaml exception, but the value can be useful for interoperability with C libraries.
The difference between 1.0
and the smallest exactly representable floating-point number greater than 1.0
.
is_finite x
is true
if and only if x
is finite i.e., not infinite and not nan
.
is_infinite x
is true
if and only if x
is infinity
or neg_infinity
.
is_nan x
is true
if and only if x
is not a number (see nan
).
Truncate the given floating-point number to an integer. The result is unspecified if the argument is nan
or falls outside the range of representable integers.
Convert the given string to a float. The string is read in decimal (by default) or in hexadecimal (marked by 0x
or 0X
). The format of decimal floating-point numbers is [-] dd.ddd (e|E) [+|-] dd
, where d
stands for a decimal digit. The format of hexadecimal floating-point numbers is [-] 0(x|X) hh.hhh (p|P) [+|-] dd
, where h
stands for an hexadecimal digit and d
for a decimal digit. In both cases, at least one of the integer and fractional parts must be given; the exponent part is optional. The _
(underscore) character can appear anywhere in the string and is ignored. Depending on the execution platforms, other representations of floating-point numbers can be accepted, but should not be relied upon.
Return a string representation of a floating-point number.
This conversion can involve a loss of precision. For greater control over the manner in which the number is printed, see Printf
.
This function is an alias for Stdlib.string_of_float
.
The five classes of floating-point numbers, as determined by the classify_float
function.
val classify_float : float -> fpclass
Return the class of the given floating-point number: normal, subnormal, zero, infinite, or not a number.
expm1 x
computes exp x -. 1.0
, giving numerically-accurate results even if x
is close to 0.0
.
log1p x
computes log(1.0 +. x)
(natural logarithm), giving numerically-accurate results even if x
is close to 0.0
.
Arc cosine. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and is between 0.0
and pi
.
Arc sine. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and is between -pi/2
and pi/2
.
atan2 y x
returns the arc tangent of y /. x
. The signs of x
and y
are used to determine the quadrant of the result. Result is in radians and is between -pi
and pi
.
hypot x y
returns sqrt(x *. x +. y *. y)
, that is, the length of the hypotenuse of a right-angled triangle with sides of length x
and y
, or, equivalently, the distance of the point (x,y)
to origin. If one of x
or y
is infinite, returns infinity
even if the other is nan
.
Hyperbolic arc cosine. The argument must fall within the range [1.0, inf]
. Result is in radians and is between 0.0
and inf
.
Hyperbolic arc sine. The argument and result range over the entire real line. Result is in radians.
Hyperbolic arc tangent. The argument must fall within the range [-1.0, 1.0]
. Result is in radians and ranges over the entire real line.
Error function. The argument ranges over the entire real line. The result is always within [-1.0, 1.0]
.
Complementary error function (erfc x = 1 - erf x
). The argument ranges over the entire real line. The result is always within [-1.0, 1.0]
.
trunc x
rounds x
to the nearest integer whose absolute value is less than or equal to x
.
round x
rounds x
to the nearest integer with ties (fractional values of 0.5) rounded away from zero, regardless of the current rounding direction. If x
is an integer, +0.
, -0.
, nan
, or infinite, x
itself is returned.
On 64-bit mingw-w64, this function may be emulated owing to a bug in the C runtime library (CRT) on this platform.
Round above to an integer value. ceil f
returns the least integer value greater than or equal to f
. The result is returned as a float.
Round below to an integer value. floor f
returns the greatest integer value less than or equal to f
. The result is returned as a float.
next_after x y
returns the next representable floating-point value following x
in the direction of y
. More precisely, if y
is greater (resp. less) than x
, it returns the smallest (resp. largest) representable number greater (resp. less) than x
. If x
equals y
, the function returns y
. If x
or y
is nan
, a nan
is returned. Note that next_after max_float infinity = infinity
and that next_after 0. infinity
is the smallest denormalized positive number. If x
is the smallest denormalized positive number, next_after x 0. = 0.
copy_sign x y
returns a float whose absolute value is that of x
and whose sign is that of y
. If x
is nan
, returns nan
. If y
is nan
, returns either x
or -. x
, but it is not specified which.
sign_bit x
is true
if and only if the sign bit of x
is set. For example sign_bit 1.
and signbit 0.
are false
while sign_bit (-1.)
and sign_bit (-0.)
are true
.
frexp f
returns the pair of the significant and the exponent of f
. When f
is zero, the significant x
and the exponent n
of f
are equal to zero. When f
is non-zero, they are defined by f = x *. 2 ** n
and 0.5 <= x < 1.0
.
compare x y
returns 0
if x
is equal to y
, a negative integer if x
is less than y
, and a positive integer if x
is greater than y
. compare
treats nan
as equal to itself and less than any other float value. This treatment of nan
ensures that compare
defines a total ordering relation.
min x y
returns the minimum of x
and y
. It returns nan
when x
or y
is nan
. Moreover min (-0.) (+0.) = -0.
max x y
returns the maximum of x
and y
. It returns nan
when x
or y
is nan
. Moreover max (-0.) (+0.) = +0.
min_max x y
is (min x y, max x y)
, just more efficient.
min_num x y
returns the minimum of x
and y
treating nan
as missing values. If both x
and y
are nan
, nan
is returned. Moreover min_num (-0.) (+0.) = -0.
max_num x y
returns the maximum of x
and y
treating nan
as missing values. If both x
and y
are nan
nan
is returned. Moreover max_num (-0.) (+0.) = +0.
min_max_num x y
is (min_num x y, max_num x y)
, just more efficient. Note that in particular min_max_num x nan = (x, x)
and min_max_num nan y = (y, y)
.
val seeded_hash : int -> t -> int
A seeded hash function for floats, with the same output value as Hashtbl.seeded_hash
. This function allows this module to be passed as argument to the functor Hashtbl.MakeSeeded
.
val hash : t -> int
An unseeded hash function for floats, with the same output value as Hashtbl.hash
. This function allows this module to be passed as argument to the functor Hashtbl.Make
.
module Array : sig ... end
Float arrays with packed representation.
module ArrayLabels : sig ... end
Float arrays with packed representation (labeled functions).
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/Make/argument-1-H/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/Make/argument-1-H/index.html
index 0da9603..21ac5fd 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/Make/argument-1-H/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/Make/argument-1-H/index.html
@@ -1,2 +1,2 @@
-H (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.Make.H) Parameter Make.H
val hash : t -> int
A hashing function on keys. It must be such that if two keys are equal according to equal
, then they have identical hash values as computed by hash
. Examples: suitable (equal
, hash
) pairs for arbitrary key types include
+H (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.Make.H) Parameter Make.H
val hash : t -> int
A hashing function on keys. It must be such that if two keys are equal according to equal
, then they have identical hash values as computed by hash
. Examples: suitable (equal
, hash
) pairs for arbitrary key types include
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/Make/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/Make/index.html
index 4f4b930..6552d7e 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/Make/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/Make/index.html
@@ -1,2 +1,2 @@
-Make (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.Make) Module Hashtbl.Make
Functor building an implementation of the hashtable structure. The functor Hashtbl.Make
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. Since the hash function is not seeded, the create
operation of the result structure always returns non-randomized hash tables.
Parameters
module H : HashedType
Signature
type key = H.t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
+Make (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.Make) Module Hashtbl.Make
Functor building an implementation of the hashtable structure. The functor Hashtbl.Make
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. Since the hash function is not seeded, the create
operation of the result structure always returns non-randomized hash tables.
Parameters
module H : HashedType
Signature
type key = H.t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/MakeSeeded/argument-1-H/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/MakeSeeded/argument-1-H/index.html
index 87da65f..82fc2f9 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/MakeSeeded/argument-1-H/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/MakeSeeded/argument-1-H/index.html
@@ -1,2 +1,2 @@
-H (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.MakeSeeded.H) Parameter MakeSeeded.H
val seeded_hash : int -> t -> int
A seeded hashing function on keys. The first argument is the seed. It must be the case that if equal x y
is true, then seeded_hash seed x = seeded_hash seed y
for any value of seed
. A suitable choice for seeded_hash
is the function Hashtbl.seeded_hash
below.
+H (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.MakeSeeded.H) Parameter MakeSeeded.H
val seeded_hash : int -> t -> int
A seeded hashing function on keys. The first argument is the seed. It must be the case that if equal x y
is true, then seeded_hash seed x = seeded_hash seed y
for any value of seed
. A suitable choice for seeded_hash
is the function Hashtbl.seeded_hash
below.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/MakeSeeded/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/MakeSeeded/index.html
index 7a8b720..6cda401 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/MakeSeeded/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/MakeSeeded/index.html
@@ -1,2 +1,2 @@
-MakeSeeded (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.MakeSeeded) Module Hashtbl.MakeSeeded
Functor building an implementation of the hashtable structure. The functor Hashtbl.MakeSeeded
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the seeded hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. The create
operation of the result structure supports the ~random
optional parameter and returns randomized hash tables if ~random:true
is passed or if randomization is globally on (see Hashtbl.randomize
).
Parameters
module H : SeededHashedType
Signature
type key = H.t
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
+MakeSeeded (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.MakeSeeded) Module Hashtbl.MakeSeeded
Functor building an implementation of the hashtable structure. The functor Hashtbl.MakeSeeded
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the seeded hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. The create
operation of the result structure supports the ~random
optional parameter and returns randomized hash tables if ~random:true
is passed or if randomization is globally on (see Hashtbl.randomize
).
Parameters
module H : SeededHashedType
Signature
type key = H.t
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/index.html
index 1412b7d..8d78537 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/index.html
@@ -1,2 +1,2 @@
-Hashtbl (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl) Module Stdlib_alerting.Hashtbl
include sig ... end
Hashtbl.hash x
associates a nonnegative integer to any value of any type. It is guaranteed that if x = y
or Stdlib.compare x y = 0
, then hash x = hash y
. Moreover, hash
always terminates, even on cyclic structures.
A variant of hash
that is further parameterized by an integer seed.
Hashtbl.hash_param meaningful total x
computes a hash value for x
, with the same properties as for hash
. The two extra integer parameters meaningful
and total
give more precise control over hashing. Hashing performs a breadth-first, left-to-right traversal of the structure x
, stopping after meaningful
meaningful nodes were encountered, or total
nodes (meaningful or not) were encountered. If total
as specified by the user exceeds a certain value, currently 256, then it is capped to that value. Meaningful nodes are: integers; floating-point numbers; strings; characters; booleans; and constant constructors. Larger values of meaningful
and total
means that more nodes are taken into account to compute the final hash value, and therefore collisions are less likely to happen. However, hashing takes longer. The parameters meaningful
and total
govern the tradeoff between accuracy and speed. As default choices, hash
and seeded_hash
take meaningful = 10
and total = 100
.
A variant of hash_param
that is further parameterized by an integer seed. Usage: Hashtbl.seeded_hash_param meaningful total seed x
.
val create : ?random:bool -> int -> ('a, 'b) t
Hashtbl.create n
creates a new, empty hash table, with initial size n
. For best results, n
should be on the order of the expected number of elements that will be in the table. The table grows as needed, so n
is just an initial guess.
The optional ~random
parameter (a boolean) controls whether the internal organization of the hash table is randomized at each execution of Hashtbl.create
or deterministic over all executions.
A hash table that is created with ~random
set to false
uses a fixed hash function (hash
) to distribute keys among buckets. As a consequence, collisions between keys happen deterministically. In Web-facing applications or other security-sensitive applications, the deterministic collision patterns can be exploited by a malicious user to create a denial-of-service attack: the attacker sends input crafted to create many collisions in the table, slowing the application down.
A hash table that is created with ~random
set to true
uses the seeded hash function seeded_hash
with a seed that is randomly chosen at hash table creation time. In effect, the hash function used is randomly selected among 2^{30}
different hash functions. All these hash functions have different collision patterns, rendering ineffective the denial-of-service attack described above. However, because of randomization, enumerating all elements of the hash table using fold
or iter
is no longer deterministic: elements are enumerated in different orders at different runs of the program.
If no ~random
parameter is given, hash tables are created in non-random mode by default. This default can be changed either programmatically by calling randomize
or by setting the R
flag in the OCAMLRUNPARAM
environment variable.
val clear : ('a, 'b) t -> unit
Empty a hash table. Use reset
instead of clear
to shrink the size of the bucket table to its initial size.
val reset : ('a, 'b) t -> unit
Empty a hash table and shrink the size of the bucket table to its initial size.
val add : ('a, 'b) t -> 'a -> 'b -> unit
Hashtbl.add tbl key data
adds a binding of key
to data
in table tbl
.
Warning: Previous bindings for key
are not removed, but simply hidden. That is, after performing remove
tbl key
, the previous binding for key
, if any, is restored. (Same behavior as with association lists.)
If you desire the classic behavior of replacing elements, see replace
.
val find : ('a, 'b) t -> 'a -> 'b
Hashtbl.find tbl x
returns the current binding of x
in tbl
, or raises Not_found
if no such binding exists.
val find_opt : ('a, 'b) t -> 'a -> 'b option
Hashtbl.find_opt tbl x
returns the current binding of x
in tbl
, or None
if no such binding exists.
val find_all : ('a, 'b) t -> 'a -> 'b list
Hashtbl.find_all tbl x
returns the list of all data associated with x
in tbl
. The current binding is returned first, then the previous bindings, in reverse order of introduction in the table.
val mem : ('a, 'b) t -> 'a -> bool
Hashtbl.mem tbl x
checks if x
is bound in tbl
.
val remove : ('a, 'b) t -> 'a -> unit
Hashtbl.remove tbl x
removes the current binding of x
in tbl
, restoring the previous binding if it exists. It does nothing if x
is not bound in tbl
.
val replace : ('a, 'b) t -> 'a -> 'b -> unit
val iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit
Hashtbl.iter f tbl
applies f
to all bindings in table tbl
. f
receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to f
.
The order in which the bindings are passed to f
is unspecified. However, if the table contains several bindings for the same key, they are passed to f
in reverse order of introduction, that is, the most recent binding is passed first.
If the hash table was created in non-randomized mode, the order in which the bindings are enumerated is reproducible between successive runs of the program, and even between minor versions of OCaml. For randomized hash tables, the order of enumeration is entirely random.
The behavior is not specified if the hash table is modified by f
during the iteration.
val filter_map_inplace : ('a -> 'b -> 'b option) -> ('a, 'b) t -> unit
Hashtbl.filter_map_inplace f tbl
applies f
to all bindings in table tbl
and update each binding depending on the result of f
. If f
returns None
, the binding is discarded. If it returns Some new_val
, the binding is update to associate the key to new_val
.
Other comments for iter
apply as well.
val fold : ('a -> 'b -> 'acc -> 'acc) -> ('a, 'b) t -> 'acc -> 'acc
Hashtbl.fold f tbl init
computes (f kN dN ... (f k1 d1 init)...)
, where k1 ... kN
are the keys of all bindings in tbl
, and d1 ... dN
are the associated values. Each binding is presented exactly once to f
.
The order in which the bindings are passed to f
is unspecified. However, if the table contains several bindings for the same key, they are passed to f
in reverse order of introduction, that is, the most recent binding is passed first.
If the hash table was created in non-randomized mode, the order in which the bindings are enumerated is reproducible between successive runs of the program, and even between minor versions of OCaml. For randomized hash tables, the order of enumeration is entirely random.
The behavior is not specified if the hash table is modified by f
during the iteration.
val length : ('a, 'b) t -> int
Hashtbl.length tbl
returns the number of bindings in tbl
. It takes constant time. Multiple bindings are counted once each, so Hashtbl.length
gives the number of times Hashtbl.iter
calls its first argument.
After a call to Hashtbl.randomize()
, hash tables are created in randomized mode by default: create
returns randomized hash tables, unless the ~random:false
optional parameter is given. The same effect can be achieved by setting the R
parameter in the OCAMLRUNPARAM
environment variable.
It is recommended that applications or Web frameworks that need to protect themselves against the denial-of-service attack described in create
call Hashtbl.randomize()
at initialization time before any domains are created.
Note that once Hashtbl.randomize()
was called, there is no way to revert to the non-randomized default behavior of create
. This is intentional. Non-randomized hash tables can still be created using Hashtbl.create ~random:false
.
Return true
if the tables are currently created in randomized mode by default, false
otherwise.
Return a copy of the given hashtable. Unlike copy
, rebuild
h
re-hashes all the (key, value) entries of the original table h
. The returned hash table is randomized if h
was randomized, or the optional random
parameter is true, or if the default is to create randomized hash tables; see create
for more information.
rebuild
can safely be used to import a hash table built by an old version of the Hashtbl
module, then marshaled to persistent storage. After unmarshaling, apply rebuild
to produce a hash table for the current version of the Hashtbl
module.
val stats : ('a, 'b) t -> statistics
Hashtbl.stats tbl
returns statistics about the table tbl
: number of buckets, size of the biggest bucket, distribution of buckets by size.
val to_seq : ('a, 'b) t -> ('a * 'b) Stdlib.Seq.t
Iterate on the whole table. The order in which the bindings appear in the sequence is unspecified. However, if the table contains several bindings for the same key, they appear in reversed order of introduction, that is, the most recent binding appears first.
The behavior is not specified if the hash table is modified during the iteration.
val to_seq_keys : ('a, _) t -> 'a Stdlib.Seq.t
Same as Seq.map fst (to_seq m)
val to_seq_values : (_, 'b) t -> 'b Stdlib.Seq.t
Same as Seq.map snd (to_seq m)
val add_seq : ('a, 'b) t -> ('a * 'b) Stdlib.Seq.t -> unit
Add the given bindings to the table, using add
val replace_seq : ('a, 'b) t -> ('a * 'b) Stdlib.Seq.t -> unit
Add the given bindings to the table, using replace
val of_seq : ('a * 'b) Stdlib.Seq.t -> ('a, 'b) t
Build a table from the given bindings. The bindings are added in the same order they appear in the sequence, using replace_seq
, which means that if two pairs have the same key, only the latest one will appear in the table.
module type HashedType = sig ... end
The input signature of the functor Make
.
Functor building an implementation of the hashtable structure. The functor Hashtbl.Make
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. Since the hash function is not seeded, the create
operation of the result structure always returns non-randomized hash tables.
module type SeededHashedType = sig ... end
The input signature of the functor MakeSeeded
.
module type SeededS = sig ... end
The output signature of the functor MakeSeeded
.
module MakeSeeded (H : SeededHashedType) : SeededS with type key = H.t
Functor building an implementation of the hashtable structure. The functor Hashtbl.MakeSeeded
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the seeded hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. The create
operation of the result structure supports the ~random
optional parameter and returns randomized hash tables if ~random:true
is passed or if randomization is globally on (see Hashtbl.randomize
).
+Hashtbl (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl) Module Stdlib_alerting.Hashtbl
include sig ... end
Hashtbl.hash x
associates a nonnegative integer to any value of any type. It is guaranteed that if x = y
or Stdlib.compare x y = 0
, then hash x = hash y
. Moreover, hash
always terminates, even on cyclic structures.
A variant of hash
that is further parameterized by an integer seed.
Hashtbl.hash_param meaningful total x
computes a hash value for x
, with the same properties as for hash
. The two extra integer parameters meaningful
and total
give more precise control over hashing. Hashing performs a breadth-first, left-to-right traversal of the structure x
, stopping after meaningful
meaningful nodes were encountered, or total
nodes (meaningful or not) were encountered. If total
as specified by the user exceeds a certain value, currently 256, then it is capped to that value. Meaningful nodes are: integers; floating-point numbers; strings; characters; booleans; and constant constructors. Larger values of meaningful
and total
means that more nodes are taken into account to compute the final hash value, and therefore collisions are less likely to happen. However, hashing takes longer. The parameters meaningful
and total
govern the tradeoff between accuracy and speed. As default choices, hash
and seeded_hash
take meaningful = 10
and total = 100
.
A variant of hash_param
that is further parameterized by an integer seed. Usage: Hashtbl.seeded_hash_param meaningful total seed x
.
val create : ?random:bool -> int -> ('a, 'b) t
Hashtbl.create n
creates a new, empty hash table, with initial size n
. For best results, n
should be on the order of the expected number of elements that will be in the table. The table grows as needed, so n
is just an initial guess.
The optional ~random
parameter (a boolean) controls whether the internal organization of the hash table is randomized at each execution of Hashtbl.create
or deterministic over all executions.
A hash table that is created with ~random
set to false
uses a fixed hash function (hash
) to distribute keys among buckets. As a consequence, collisions between keys happen deterministically. In Web-facing applications or other security-sensitive applications, the deterministic collision patterns can be exploited by a malicious user to create a denial-of-service attack: the attacker sends input crafted to create many collisions in the table, slowing the application down.
A hash table that is created with ~random
set to true
uses the seeded hash function seeded_hash
with a seed that is randomly chosen at hash table creation time. In effect, the hash function used is randomly selected among 2^{30}
different hash functions. All these hash functions have different collision patterns, rendering ineffective the denial-of-service attack described above. However, because of randomization, enumerating all elements of the hash table using fold
or iter
is no longer deterministic: elements are enumerated in different orders at different runs of the program.
If no ~random
parameter is given, hash tables are created in non-random mode by default. This default can be changed either programmatically by calling randomize
or by setting the R
flag in the OCAMLRUNPARAM
environment variable.
val clear : ('a, 'b) t -> unit
Empty a hash table. Use reset
instead of clear
to shrink the size of the bucket table to its initial size.
val reset : ('a, 'b) t -> unit
Empty a hash table and shrink the size of the bucket table to its initial size.
val add : ('a, 'b) t -> 'a -> 'b -> unit
Hashtbl.add tbl key data
adds a binding of key
to data
in table tbl
.
Warning: Previous bindings for key
are not removed, but simply hidden. That is, after performing remove
tbl key
, the previous binding for key
, if any, is restored. (Same behavior as with association lists.)
If you desire the classic behavior of replacing elements, see replace
.
val find : ('a, 'b) t -> 'a -> 'b
Hashtbl.find tbl x
returns the current binding of x
in tbl
, or raises Not_found
if no such binding exists.
val find_opt : ('a, 'b) t -> 'a -> 'b option
Hashtbl.find_opt tbl x
returns the current binding of x
in tbl
, or None
if no such binding exists.
val find_all : ('a, 'b) t -> 'a -> 'b list
Hashtbl.find_all tbl x
returns the list of all data associated with x
in tbl
. The current binding is returned first, then the previous bindings, in reverse order of introduction in the table.
val mem : ('a, 'b) t -> 'a -> bool
Hashtbl.mem tbl x
checks if x
is bound in tbl
.
val remove : ('a, 'b) t -> 'a -> unit
Hashtbl.remove tbl x
removes the current binding of x
in tbl
, restoring the previous binding if it exists. It does nothing if x
is not bound in tbl
.
val replace : ('a, 'b) t -> 'a -> 'b -> unit
val iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit
Hashtbl.iter f tbl
applies f
to all bindings in table tbl
. f
receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to f
.
The order in which the bindings are passed to f
is unspecified. However, if the table contains several bindings for the same key, they are passed to f
in reverse order of introduction, that is, the most recent binding is passed first.
If the hash table was created in non-randomized mode, the order in which the bindings are enumerated is reproducible between successive runs of the program, and even between minor versions of OCaml. For randomized hash tables, the order of enumeration is entirely random.
The behavior is not specified if the hash table is modified by f
during the iteration.
val filter_map_inplace : ('a -> 'b -> 'b option) -> ('a, 'b) t -> unit
Hashtbl.filter_map_inplace f tbl
applies f
to all bindings in table tbl
and update each binding depending on the result of f
. If f
returns None
, the binding is discarded. If it returns Some new_val
, the binding is update to associate the key to new_val
.
Other comments for iter
apply as well.
val fold : ('a -> 'b -> 'acc -> 'acc) -> ('a, 'b) t -> 'acc -> 'acc
Hashtbl.fold f tbl init
computes (f kN dN ... (f k1 d1 init)...)
, where k1 ... kN
are the keys of all bindings in tbl
, and d1 ... dN
are the associated values. Each binding is presented exactly once to f
.
The order in which the bindings are passed to f
is unspecified. However, if the table contains several bindings for the same key, they are passed to f
in reverse order of introduction, that is, the most recent binding is passed first.
If the hash table was created in non-randomized mode, the order in which the bindings are enumerated is reproducible between successive runs of the program, and even between minor versions of OCaml. For randomized hash tables, the order of enumeration is entirely random.
The behavior is not specified if the hash table is modified by f
during the iteration.
val length : ('a, 'b) t -> int
Hashtbl.length tbl
returns the number of bindings in tbl
. It takes constant time. Multiple bindings are counted once each, so Hashtbl.length
gives the number of times Hashtbl.iter
calls its first argument.
After a call to Hashtbl.randomize()
, hash tables are created in randomized mode by default: create
returns randomized hash tables, unless the ~random:false
optional parameter is given. The same effect can be achieved by setting the R
parameter in the OCAMLRUNPARAM
environment variable.
It is recommended that applications or Web frameworks that need to protect themselves against the denial-of-service attack described in create
call Hashtbl.randomize()
at initialization time before any domains are created.
Note that once Hashtbl.randomize()
was called, there is no way to revert to the non-randomized default behavior of create
. This is intentional. Non-randomized hash tables can still be created using Hashtbl.create ~random:false
.
Return true
if the tables are currently created in randomized mode by default, false
otherwise.
Return a copy of the given hashtable. Unlike copy
, rebuild
h
re-hashes all the (key, value) entries of the original table h
. The returned hash table is randomized if h
was randomized, or the optional random
parameter is true, or if the default is to create randomized hash tables; see create
for more information.
rebuild
can safely be used to import a hash table built by an old version of the Hashtbl
module, then marshaled to persistent storage. After unmarshaling, apply rebuild
to produce a hash table for the current version of the Hashtbl
module.
val stats : ('a, 'b) t -> statistics
Hashtbl.stats tbl
returns statistics about the table tbl
: number of buckets, size of the biggest bucket, distribution of buckets by size.
val to_seq : ('a, 'b) t -> ('a * 'b) Stdlib.Seq.t
Iterate on the whole table. The order in which the bindings appear in the sequence is unspecified. However, if the table contains several bindings for the same key, they appear in reversed order of introduction, that is, the most recent binding appears first.
The behavior is not specified if the hash table is modified during the iteration.
val to_seq_keys : ('a, _) t -> 'a Stdlib.Seq.t
Same as Seq.map fst (to_seq m)
val to_seq_values : (_, 'b) t -> 'b Stdlib.Seq.t
Same as Seq.map snd (to_seq m)
val add_seq : ('a, 'b) t -> ('a * 'b) Stdlib.Seq.t -> unit
Add the given bindings to the table, using add
val replace_seq : ('a, 'b) t -> ('a * 'b) Stdlib.Seq.t -> unit
Add the given bindings to the table, using replace
val of_seq : ('a * 'b) Stdlib.Seq.t -> ('a, 'b) t
Build a table from the given bindings. The bindings are added in the same order they appear in the sequence, using replace_seq
, which means that if two pairs have the same key, only the latest one will appear in the table.
module type HashedType = sig ... end
The input signature of the functor Make
.
Functor building an implementation of the hashtable structure. The functor Hashtbl.Make
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. Since the hash function is not seeded, the create
operation of the result structure always returns non-randomized hash tables.
module type SeededHashedType = sig ... end
The input signature of the functor MakeSeeded
.
module type SeededS = sig ... end
The output signature of the functor MakeSeeded
.
module MakeSeeded (H : SeededHashedType) : SeededS with type key = H.t
Functor building an implementation of the hashtable structure. The functor Hashtbl.MakeSeeded
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the seeded hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. The create
operation of the result structure supports the ~random
optional parameter and returns randomized hash tables if ~random:true
is passed or if randomization is globally on (see Hashtbl.randomize
).
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-HashedType/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-HashedType/index.html
index b153795..bdec07a 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-HashedType/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-HashedType/index.html
@@ -1,2 +1,2 @@
-HashedType (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.HashedType) Module type Hashtbl.HashedType
The input signature of the functor Make
.
val hash : t -> int
A hashing function on keys. It must be such that if two keys are equal according to equal
, then they have identical hash values as computed by hash
. Examples: suitable (equal
, hash
) pairs for arbitrary key types include
+HashedType (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.HashedType) Module type Hashtbl.HashedType
The input signature of the functor Make
.
val hash : t -> int
A hashing function on keys. It must be such that if two keys are equal according to equal
, then they have identical hash values as computed by hash
. Examples: suitable (equal
, hash
) pairs for arbitrary key types include
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-S/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-S/index.html
index 401d57b..622032d 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-S/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-S/index.html
@@ -1,2 +1,2 @@
-S (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.S) Module type Hashtbl.S
The output signature of the functor Make
.
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
+S (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.S) Module type Hashtbl.S
The output signature of the functor Make
.
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-SeededHashedType/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-SeededHashedType/index.html
index f18a2d5..58be2ab 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-SeededHashedType/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-SeededHashedType/index.html
@@ -1,2 +1,2 @@
-SeededHashedType (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.SeededHashedType) Module type Hashtbl.SeededHashedType
The input signature of the functor MakeSeeded
.
val seeded_hash : int -> t -> int
A seeded hashing function on keys. The first argument is the seed. It must be the case that if equal x y
is true, then seeded_hash seed x = seeded_hash seed y
for any value of seed
. A suitable choice for seeded_hash
is the function Hashtbl.seeded_hash
below.
+SeededHashedType (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.SeededHashedType) Module type Hashtbl.SeededHashedType
The input signature of the functor MakeSeeded
.
val seeded_hash : int -> t -> int
A seeded hashing function on keys. The first argument is the seed. It must be the case that if equal x y
is true, then seeded_hash seed x = seeded_hash seed y
for any value of seed
. A suitable choice for seeded_hash
is the function Hashtbl.seeded_hash
below.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-SeededS/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-SeededS/index.html
index 1c3216d..5ddb088 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-SeededS/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Hashtbl/module-type-SeededS/index.html
@@ -1,2 +1,2 @@
-SeededS (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.SeededS) Module type Hashtbl.SeededS
The output signature of the functor MakeSeeded
.
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
+SeededS (less-power.Stdlib_alerts.Stdlib_alerting.Hashtbl.SeededS) Module type Hashtbl.SeededS
The output signature of the functor MakeSeeded
.
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/LargeFile/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/LargeFile/index.html
index 3b539c1..150d3db 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/LargeFile/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/LargeFile/index.html
@@ -1,2 +1,2 @@
-LargeFile (less-power.Stdlib_alerts.Stdlib_alerting.LargeFile) Module Stdlib_alerting.LargeFile
Operations on large files. This sub-module provides 64-bit variants of the channel functions that manipulate file positions and file sizes. By representing positions and sizes by 64-bit integers (type int64
) instead of regular integers (type int
), these alternate functions allow operating on files whose sizes are greater than max_int
.
val seek_out : out_channel -> int64 -> unit
val pos_out : out_channel -> int64
val out_channel_length : out_channel -> int64
val seek_in : in_channel -> int64 -> unit
val pos_in : in_channel -> int64
val in_channel_length : in_channel -> int64
+LargeFile (less-power.Stdlib_alerts.Stdlib_alerting.LargeFile) Module Stdlib_alerting.LargeFile
Operations on large files. This sub-module provides 64-bit variants of the channel functions that manipulate file positions and file sizes. By representing positions and sizes by 64-bit integers (type int64
) instead of regular integers (type int
), these alternate functions allow operating on files whose sizes are greater than max_int
.
val seek_out : out_channel -> int64 -> unit
val pos_out : out_channel -> int64
val out_channel_length : out_channel -> int64
val seek_in : in_channel -> int64 -> unit
val pos_in : in_channel -> int64
val in_channel_length : in_channel -> int64
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/List/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/List/index.html
index 4b92a83..4f790f7 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/List/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/List/index.html
@@ -1,5 +1,5 @@
-List (less-power.Stdlib_alerts.Stdlib_alerting.List) Module Stdlib_alerting.List
include sig ... end
Compare the lengths of two lists. compare_lengths l1 l2
is equivalent to compare (length l1) (length l2)
, except that the computation stops after reaching the end of the shortest list.
Compare the length of a list to an integer. compare_length_with l len
is equivalent to compare (length l) len
, except that the computation stops after at most len
iterations on the list.
is_empty l
is true if and only if l
has no elements. It is equivalent to compare_length_with l 0 = 0
.
Return the n
-th element of the given list. The first element (head of the list) is at position 0.
Return the n
-th element of the given list. The first element (head of the list) is at position 0. Return None
if the list is too short.
init len f
is [f 0; f 1; ...; f (len-1)]
, evaluated left to right.
append l0 l1
appends l1
to l0
. Same function as the infix operator @
.
rev_append l1 l2
reverses l1
and concatenates it with l2
. This is equivalent to (
rev
l1) @ l2
.
Concatenate a list of lists. The elements of the argument are all concatenated together (in the same order) to give the result. Not tail-recursive (length of the argument + length of the longest sub-list).
Same as concat
. Not tail-recursive (length of the argument + length of the longest sub-list).
equal eq [a1; ...; an] [b1; ..; bm]
holds when the two input lists have the same length, and for each pair of elements ai
, bi
at the same position we have eq ai bi
.
Note: the eq
function may be called even if the lists have different length. If you know your equality function is costly, you may want to check compare_lengths
first.
compare cmp [a1; ...; an] [b1; ...; bm]
performs a lexicographic comparison of the two input lists, using the same 'a -> 'a -> int
interface as Stdlib.compare
:
a1 :: l1
is smaller than a2 :: l2
(negative result) if a1
is smaller than a2
, or if they are equal (0 result) and l1
is smaller than l2
- the empty list
[]
is strictly smaller than non-empty lists
Note: the cmp
function will be called even if the lists have different lengths.
iter f [a1; ...; an]
applies function f
in turn to [a1; ...; an]
. It is equivalent to f a1; f a2; ...; f an
.
Same as iter
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
map f [a1; ...; an]
applies function f
to a1, ..., an
, and builds the list [f a1; ...; f an]
with the results returned by f
.
Same as map
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
filter_map f l
applies f
to every element of l
, filters out the None
elements and returns the list of the arguments of the Some
elements.
val fold_left_map :
+List (less-power.Stdlib_alerts.Stdlib_alerting.List) Module Stdlib_alerting.List
include sig ... end
Compare the lengths of two lists. compare_lengths l1 l2
is equivalent to compare (length l1) (length l2)
, except that the computation stops after reaching the end of the shortest list.
Compare the length of a list to an integer. compare_length_with l len
is equivalent to compare (length l) len
, except that the computation stops after at most len
iterations on the list.
is_empty l
is true if and only if l
has no elements. It is equivalent to compare_length_with l 0 = 0
.
Return the n
-th element of the given list. The first element (head of the list) is at position 0.
Return the n
-th element of the given list. The first element (head of the list) is at position 0. Return None
if the list is too short.
init len f
is [f 0; f 1; ...; f (len-1)]
, evaluated left to right.
append l0 l1
appends l1
to l0
. Same function as the infix operator @
.
rev_append l1 l2
reverses l1
and concatenates it with l2
. This is equivalent to (
rev
l1) @ l2
.
Concatenate a list of lists. The elements of the argument are all concatenated together (in the same order) to give the result. Not tail-recursive (length of the argument + length of the longest sub-list).
Same as concat
. Not tail-recursive (length of the argument + length of the longest sub-list).
equal eq [a1; ...; an] [b1; ..; bm]
holds when the two input lists have the same length, and for each pair of elements ai
, bi
at the same position we have eq ai bi
.
Note: the eq
function may be called even if the lists have different length. If you know your equality function is costly, you may want to check compare_lengths
first.
compare cmp [a1; ...; an] [b1; ...; bm]
performs a lexicographic comparison of the two input lists, using the same 'a -> 'a -> int
interface as Stdlib.compare
:
a1 :: l1
is smaller than a2 :: l2
(negative result) if a1
is smaller than a2
, or if they are equal (0 result) and l1
is smaller than l2
- the empty list
[]
is strictly smaller than non-empty lists
Note: the cmp
function will be called even if the lists have different lengths.
iter f [a1; ...; an]
applies function f
in turn to [a1; ...; an]
. It is equivalent to f a1; f a2; ...; f an
.
Same as iter
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
map f [a1; ...; an]
applies function f
to a1, ..., an
, and builds the list [f a1; ...; f an]
with the results returned by f
.
Same as map
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
filter_map f l
applies f
to every element of l
, filters out the None
elements and returns the list of the arguments of the Some
elements.
val fold_left_map :
('acc -> 'a -> 'acc * 'b) ->
'acc ->
'a list ->
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/ListLabels/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/ListLabels/index.html
index 0ea1217..0c6f0fd 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/ListLabels/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/ListLabels/index.html
@@ -1,5 +1,5 @@
-ListLabels (less-power.Stdlib_alerts.Stdlib_alerting.ListLabels) Module Stdlib_alerting.ListLabels
include sig ... end
Compare the lengths of two lists. compare_lengths l1 l2
is equivalent to compare (length l1) (length l2)
, except that the computation stops after reaching the end of the shortest list.
Compare the length of a list to an integer. compare_length_with l len
is equivalent to compare (length l) len
, except that the computation stops after at most len
iterations on the list.
is_empty l
is true if and only if l
has no elements. It is equivalent to compare_length_with l 0 = 0
.
Return the n
-th element of the given list. The first element (head of the list) is at position 0.
Return the n
-th element of the given list. The first element (head of the list) is at position 0. Return None
if the list is too short.
init ~len ~f
is [f 0; f 1; ...; f (len-1)]
, evaluated left to right.
append l0 l1
appends l1
to l0
. Same function as the infix operator @
.
rev_append l1 l2
reverses l1
and concatenates it with l2
. This is equivalent to (
rev
l1) @ l2
.
Concatenate a list of lists. The elements of the argument are all concatenated together (in the same order) to give the result. Not tail-recursive (length of the argument + length of the longest sub-list).
Same as concat
. Not tail-recursive (length of the argument + length of the longest sub-list).
equal eq [a1; ...; an] [b1; ..; bm]
holds when the two input lists have the same length, and for each pair of elements ai
, bi
at the same position we have eq ai bi
.
Note: the eq
function may be called even if the lists have different length. If you know your equality function is costly, you may want to check compare_lengths
first.
compare cmp [a1; ...; an] [b1; ...; bm]
performs a lexicographic comparison of the two input lists, using the same 'a -> 'a -> int
interface as Stdlib.compare
:
a1 :: l1
is smaller than a2 :: l2
(negative result) if a1
is smaller than a2
, or if they are equal (0 result) and l1
is smaller than l2
- the empty list
[]
is strictly smaller than non-empty lists
Note: the cmp
function will be called even if the lists have different lengths.
iter ~f [a1; ...; an]
applies function f
in turn to [a1; ...; an]
. It is equivalent to f a1; f a2; ...; f an
.
Same as iter
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
map ~f [a1; ...; an]
applies function f
to a1, ..., an
, and builds the list [f a1; ...; f an]
with the results returned by f
.
Same as map
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
filter_map ~f l
applies f
to every element of l
, filters out the None
elements and returns the list of the arguments of the Some
elements.
val fold_left_map :
+ListLabels (less-power.Stdlib_alerts.Stdlib_alerting.ListLabels) Module Stdlib_alerting.ListLabels
include sig ... end
Compare the lengths of two lists. compare_lengths l1 l2
is equivalent to compare (length l1) (length l2)
, except that the computation stops after reaching the end of the shortest list.
Compare the length of a list to an integer. compare_length_with l len
is equivalent to compare (length l) len
, except that the computation stops after at most len
iterations on the list.
is_empty l
is true if and only if l
has no elements. It is equivalent to compare_length_with l 0 = 0
.
Return the n
-th element of the given list. The first element (head of the list) is at position 0.
Return the n
-th element of the given list. The first element (head of the list) is at position 0. Return None
if the list is too short.
init ~len ~f
is [f 0; f 1; ...; f (len-1)]
, evaluated left to right.
append l0 l1
appends l1
to l0
. Same function as the infix operator @
.
rev_append l1 l2
reverses l1
and concatenates it with l2
. This is equivalent to (
rev
l1) @ l2
.
Concatenate a list of lists. The elements of the argument are all concatenated together (in the same order) to give the result. Not tail-recursive (length of the argument + length of the longest sub-list).
Same as concat
. Not tail-recursive (length of the argument + length of the longest sub-list).
equal eq [a1; ...; an] [b1; ..; bm]
holds when the two input lists have the same length, and for each pair of elements ai
, bi
at the same position we have eq ai bi
.
Note: the eq
function may be called even if the lists have different length. If you know your equality function is costly, you may want to check compare_lengths
first.
compare cmp [a1; ...; an] [b1; ...; bm]
performs a lexicographic comparison of the two input lists, using the same 'a -> 'a -> int
interface as Stdlib.compare
:
a1 :: l1
is smaller than a2 :: l2
(negative result) if a1
is smaller than a2
, or if they are equal (0 result) and l1
is smaller than l2
- the empty list
[]
is strictly smaller than non-empty lists
Note: the cmp
function will be called even if the lists have different lengths.
iter ~f [a1; ...; an]
applies function f
in turn to [a1; ...; an]
. It is equivalent to f a1; f a2; ...; f an
.
Same as iter
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
map ~f [a1; ...; an]
applies function f
to a1, ..., an
, and builds the list [f a1; ...; f an]
with the results returned by f
.
Same as map
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
filter_map ~f l
applies f
to every element of l
, filters out the None
elements and returns the list of the arguments of the Some
elements.
val fold_left_map :
f:('acc -> 'a -> 'acc * 'b) ->
init:'acc ->
'a list ->
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/Make/argument-1-H/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/Make/argument-1-H/index.html
index e7c83d9..82d5da3 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/Make/argument-1-H/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/Make/argument-1-H/index.html
@@ -1,2 +1,2 @@
-H (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.Make.H) Parameter Make.H
val hash : t -> int
A hashing function on keys. It must be such that if two keys are equal according to equal
, then they have identical hash values as computed by hash
. Examples: suitable (equal
, hash
) pairs for arbitrary key types include
+H (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.Make.H) Parameter Make.H
val hash : t -> int
A hashing function on keys. It must be such that if two keys are equal according to equal
, then they have identical hash values as computed by hash
. Examples: suitable (equal
, hash
) pairs for arbitrary key types include
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/Make/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/Make/index.html
index 21ed009..d6ddd45 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/Make/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/Make/index.html
@@ -1,2 +1,2 @@
-Make (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.Make) Module Hashtbl.Make
Functor building an implementation of the hashtable structure. The functor Hashtbl.Make
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. Since the hash function is not seeded, the create
operation of the result structure always returns non-randomized hash tables.
Parameters
module H : HashedType
Signature
type key = H.t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
+Make (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.Make) Module Hashtbl.Make
Functor building an implementation of the hashtable structure. The functor Hashtbl.Make
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. Since the hash function is not seeded, the create
operation of the result structure always returns non-randomized hash tables.
Parameters
module H : HashedType
Signature
type key = H.t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/MakeSeeded/argument-1-H/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/MakeSeeded/argument-1-H/index.html
index 879cafe..1545802 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/MakeSeeded/argument-1-H/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/MakeSeeded/argument-1-H/index.html
@@ -1,2 +1,2 @@
-H (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.MakeSeeded.H) Parameter MakeSeeded.H
val seeded_hash : int -> t -> int
A seeded hashing function on keys. The first argument is the seed. It must be the case that if equal x y
is true, then seeded_hash seed x = seeded_hash seed y
for any value of seed
. A suitable choice for seeded_hash
is the function Hashtbl.seeded_hash
below.
+H (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.MakeSeeded.H) Parameter MakeSeeded.H
val seeded_hash : int -> t -> int
A seeded hashing function on keys. The first argument is the seed. It must be the case that if equal x y
is true, then seeded_hash seed x = seeded_hash seed y
for any value of seed
. A suitable choice for seeded_hash
is the function Hashtbl.seeded_hash
below.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/MakeSeeded/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/MakeSeeded/index.html
index 26c16ff..10dc303 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/MakeSeeded/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/MakeSeeded/index.html
@@ -1,2 +1,2 @@
-MakeSeeded (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.MakeSeeded) Module Hashtbl.MakeSeeded
Functor building an implementation of the hashtable structure. The functor Hashtbl.MakeSeeded
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the seeded hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. The create
operation of the result structure supports the ~random
optional parameter and returns randomized hash tables if ~random:true
is passed or if randomization is globally on (see Hashtbl.randomize
).
Parameters
module H : SeededHashedType
Signature
type key = H.t
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
+MakeSeeded (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.MakeSeeded) Module Hashtbl.MakeSeeded
Functor building an implementation of the hashtable structure. The functor Hashtbl.MakeSeeded
returns a structure containing a type key
of keys and a type 'a t
of hash tables associating data of type 'a
to keys of type key
. The operations perform similarly to those of the generic interface, but use the seeded hashing and equality functions specified in the functor argument H
instead of generic equality and hashing. The create
operation of the result structure supports the ~random
optional parameter and returns randomized hash tables if ~random:true
is passed or if randomization is globally on (see Hashtbl.randomize
).
Parameters
module H : SeededHashedType
Signature
type key = H.t
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/index.html
index 6c56589..bbc22b0 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/index.html
@@ -1,5 +1,5 @@
-Hashtbl (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl) Module MoreLabels.Hashtbl
Hash tables and hash functions.
Hash tables are hashed association tables, with in-place modification. Because most operations on a hash table modify their input, they're more commonly used in imperative code. The lookup of the value associated with a key (see find
, find_opt
) is normally very fast, often faster than the equivalent lookup in Map
.
The functors Make
and MakeSeeded
can be used when performance or flexibility are key. The user provides custom equality and hash functions for the key type, and obtains a custom hash table type for this particular type of key.
Warning a hash table is only as good as the hash function. A bad hash function will turn the table into a degenerate association list, with linear time lookup instead of constant time lookup.
The polymorphic t
hash table is useful in simpler cases or in interactive environments. It uses the polymorphic hash
function defined in the OCaml runtime (at the time of writing, it's SipHash), as well as the polymorphic equality (=)
.
See the examples section.
Unsynchronized accesses
Unsynchronized accesses to a hash table may lead to an invalid hash table state. Thus, concurrent accesses to a hash tables must be synchronized (for instance with a Mutex.t
).
Generic interface
val create : ?random:bool -> int -> ('a, 'b) t
Hashtbl.create n
creates a new, empty hash table, with initial size n
. For best results, n
should be on the order of the expected number of elements that will be in the table. The table grows as needed, so n
is just an initial guess.
The optional ~random
parameter (a boolean) controls whether the internal organization of the hash table is randomized at each execution of Hashtbl.create
or deterministic over all executions.
A hash table that is created with ~random
set to false
uses a fixed hash function (hash
) to distribute keys among buckets. As a consequence, collisions between keys happen deterministically. In Web-facing applications or other security-sensitive applications, the deterministic collision patterns can be exploited by a malicious user to create a denial-of-service attack: the attacker sends input crafted to create many collisions in the table, slowing the application down.
A hash table that is created with ~random
set to true
uses the seeded hash function seeded_hash
with a seed that is randomly chosen at hash table creation time. In effect, the hash function used is randomly selected among 2^{30}
different hash functions. All these hash functions have different collision patterns, rendering ineffective the denial-of-service attack described above. However, because of randomization, enumerating all elements of the hash table using fold
or iter
is no longer deterministic: elements are enumerated in different orders at different runs of the program.
If no ~random
parameter is given, hash tables are created in non-random mode by default. This default can be changed either programmatically by calling randomize
or by setting the R
flag in the OCAMLRUNPARAM
environment variable.
val clear : ('a, 'b) t -> unit
Empty a hash table. Use reset
instead of clear
to shrink the size of the bucket table to its initial size.
val reset : ('a, 'b) t -> unit
Empty a hash table and shrink the size of the bucket table to its initial size.
val add : ('a, 'b) t -> key:'a -> data:'b -> unit
Hashtbl.add tbl ~key ~data
adds a binding of key
to data
in table tbl
.
Warning: Previous bindings for key
are not removed, but simply hidden. That is, after performing remove
tbl key
, the previous binding for key
, if any, is restored. (Same behavior as with association lists.)
If you desire the classic behavior of replacing elements, see replace
.
val find : ('a, 'b) t -> 'a -> 'b
Hashtbl.find tbl x
returns the current binding of x
in tbl
, or raises Not_found
if no such binding exists.
val find_opt : ('a, 'b) t -> 'a -> 'b option
Hashtbl.find_opt tbl x
returns the current binding of x
in tbl
, or None
if no such binding exists.
val find_all : ('a, 'b) t -> 'a -> 'b list
Hashtbl.find_all tbl x
returns the list of all data associated with x
in tbl
. The current binding is returned first, then the previous bindings, in reverse order of introduction in the table.
val mem : ('a, 'b) t -> 'a -> bool
Hashtbl.mem tbl x
checks if x
is bound in tbl
.
val remove : ('a, 'b) t -> 'a -> unit
Hashtbl.remove tbl x
removes the current binding of x
in tbl
, restoring the previous binding if it exists. It does nothing if x
is not bound in tbl
.
val replace : ('a, 'b) t -> key:'a -> data:'b -> unit
val iter : f:(key:'a -> data:'b -> unit) -> ('a, 'b) t -> unit
Hashtbl.iter ~f tbl
applies f
to all bindings in table tbl
. f
receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to f
.
The order in which the bindings are passed to f
is unspecified. However, if the table contains several bindings for the same key, they are passed to f
in reverse order of introduction, that is, the most recent binding is passed first.
If the hash table was created in non-randomized mode, the order in which the bindings are enumerated is reproducible between successive runs of the program, and even between minor versions of OCaml. For randomized hash tables, the order of enumeration is entirely random.
The behavior is not specified if the hash table is modified by f
during the iteration.
val filter_map_inplace :
+Hashtbl (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl) Module MoreLabels.Hashtbl
Hash tables and hash functions.
Hash tables are hashed association tables, with in-place modification. Because most operations on a hash table modify their input, they're more commonly used in imperative code. The lookup of the value associated with a key (see find
, find_opt
) is normally very fast, often faster than the equivalent lookup in Map
.
The functors Make
and MakeSeeded
can be used when performance or flexibility are key. The user provides custom equality and hash functions for the key type, and obtains a custom hash table type for this particular type of key.
Warning a hash table is only as good as the hash function. A bad hash function will turn the table into a degenerate association list, with linear time lookup instead of constant time lookup.
The polymorphic t
hash table is useful in simpler cases or in interactive environments. It uses the polymorphic hash
function defined in the OCaml runtime (at the time of writing, it's SipHash), as well as the polymorphic equality (=)
.
See the examples section.
Unsynchronized accesses
Unsynchronized accesses to a hash table may lead to an invalid hash table state. Thus, concurrent accesses to a hash tables must be synchronized (for instance with a Mutex.t
).
Generic interface
val create : ?random:bool -> int -> ('a, 'b) t
Hashtbl.create n
creates a new, empty hash table, with initial size n
. For best results, n
should be on the order of the expected number of elements that will be in the table. The table grows as needed, so n
is just an initial guess.
The optional ~random
parameter (a boolean) controls whether the internal organization of the hash table is randomized at each execution of Hashtbl.create
or deterministic over all executions.
A hash table that is created with ~random
set to false
uses a fixed hash function (hash
) to distribute keys among buckets. As a consequence, collisions between keys happen deterministically. In Web-facing applications or other security-sensitive applications, the deterministic collision patterns can be exploited by a malicious user to create a denial-of-service attack: the attacker sends input crafted to create many collisions in the table, slowing the application down.
A hash table that is created with ~random
set to true
uses the seeded hash function seeded_hash
with a seed that is randomly chosen at hash table creation time. In effect, the hash function used is randomly selected among 2^{30}
different hash functions. All these hash functions have different collision patterns, rendering ineffective the denial-of-service attack described above. However, because of randomization, enumerating all elements of the hash table using fold
or iter
is no longer deterministic: elements are enumerated in different orders at different runs of the program.
If no ~random
parameter is given, hash tables are created in non-random mode by default. This default can be changed either programmatically by calling randomize
or by setting the R
flag in the OCAMLRUNPARAM
environment variable.
val clear : ('a, 'b) t -> unit
Empty a hash table. Use reset
instead of clear
to shrink the size of the bucket table to its initial size.
val reset : ('a, 'b) t -> unit
Empty a hash table and shrink the size of the bucket table to its initial size.
val add : ('a, 'b) t -> key:'a -> data:'b -> unit
Hashtbl.add tbl ~key ~data
adds a binding of key
to data
in table tbl
.
Warning: Previous bindings for key
are not removed, but simply hidden. That is, after performing remove
tbl key
, the previous binding for key
, if any, is restored. (Same behavior as with association lists.)
If you desire the classic behavior of replacing elements, see replace
.
val find : ('a, 'b) t -> 'a -> 'b
Hashtbl.find tbl x
returns the current binding of x
in tbl
, or raises Not_found
if no such binding exists.
val find_opt : ('a, 'b) t -> 'a -> 'b option
Hashtbl.find_opt tbl x
returns the current binding of x
in tbl
, or None
if no such binding exists.
val find_all : ('a, 'b) t -> 'a -> 'b list
Hashtbl.find_all tbl x
returns the list of all data associated with x
in tbl
. The current binding is returned first, then the previous bindings, in reverse order of introduction in the table.
val mem : ('a, 'b) t -> 'a -> bool
Hashtbl.mem tbl x
checks if x
is bound in tbl
.
val remove : ('a, 'b) t -> 'a -> unit
Hashtbl.remove tbl x
removes the current binding of x
in tbl
, restoring the previous binding if it exists. It does nothing if x
is not bound in tbl
.
val replace : ('a, 'b) t -> key:'a -> data:'b -> unit
val iter : f:(key:'a -> data:'b -> unit) -> ('a, 'b) t -> unit
Hashtbl.iter ~f tbl
applies f
to all bindings in table tbl
. f
receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to f
.
The order in which the bindings are passed to f
is unspecified. However, if the table contains several bindings for the same key, they are passed to f
in reverse order of introduction, that is, the most recent binding is passed first.
If the hash table was created in non-randomized mode, the order in which the bindings are enumerated is reproducible between successive runs of the program, and even between minor versions of OCaml. For randomized hash tables, the order of enumeration is entirely random.
The behavior is not specified if the hash table is modified by f
during the iteration.
val filter_map_inplace :
f:(key:'a -> data:'b -> 'b option) ->
('a, 'b) t ->
unit
Hashtbl.filter_map_inplace ~f tbl
applies f
to all bindings in table tbl
and update each binding depending on the result of f
. If f
returns None
, the binding is discarded. If it returns Some new_val
, the binding is update to associate the key to new_val
.
Other comments for iter
apply as well.
val fold :
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-HashedType/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-HashedType/index.html
index ff24538..95e9c64 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-HashedType/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-HashedType/index.html
@@ -1,2 +1,2 @@
-HashedType (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.HashedType) Module type Hashtbl.HashedType
The input signature of the functor Make
.
val hash : t -> int
A hashing function on keys. It must be such that if two keys are equal according to equal
, then they have identical hash values as computed by hash
. Examples: suitable (equal
, hash
) pairs for arbitrary key types include
+HashedType (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.HashedType) Module type Hashtbl.HashedType
The input signature of the functor Make
.
val hash : t -> int
A hashing function on keys. It must be such that if two keys are equal according to equal
, then they have identical hash values as computed by hash
. Examples: suitable (equal
, hash
) pairs for arbitrary key types include
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-S/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-S/index.html
index d3fdb53..04bd6e0 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-S/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-S/index.html
@@ -1,2 +1,2 @@
-S (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.S) Module type Hashtbl.S
The output signature of the functor Make
.
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
+S (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.S) Module type Hashtbl.S
The output signature of the functor Make
.
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-SeededHashedType/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-SeededHashedType/index.html
index 7f19e3a..bc9b832 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-SeededHashedType/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-SeededHashedType/index.html
@@ -1,2 +1,2 @@
-SeededHashedType (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.SeededHashedType) Module type Hashtbl.SeededHashedType
The input signature of the functor MakeSeeded
.
val seeded_hash : int -> t -> int
A seeded hashing function on keys. The first argument is the seed. It must be the case that if equal x y
is true, then seeded_hash seed x = seeded_hash seed y
for any value of seed
. A suitable choice for seeded_hash
is the function Hashtbl.seeded_hash
below.
+SeededHashedType (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.SeededHashedType) Module type Hashtbl.SeededHashedType
The input signature of the functor MakeSeeded
.
val seeded_hash : int -> t -> int
A seeded hashing function on keys. The first argument is the seed. It must be the case that if equal x y
is true, then seeded_hash seed x = seeded_hash seed y
for any value of seed
. A suitable choice for seeded_hash
is the function Hashtbl.seeded_hash
below.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-SeededS/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-SeededS/index.html
index bef92e9..1f0c973 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-SeededS/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Hashtbl/module-type-SeededS/index.html
@@ -1,2 +1,2 @@
-SeededS (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.SeededS) Module type Hashtbl.SeededS
The output signature of the functor MakeSeeded
.
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
+SeededS (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Hashtbl.SeededS) Module type Hashtbl.SeededS
The output signature of the functor MakeSeeded
.
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/Make/argument-1-Ord/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/Make/argument-1-Ord/index.html
index dbf500b..2c0a73e 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/Make/argument-1-Ord/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/Make/argument-1-Ord/index.html
@@ -1,2 +1,2 @@
-Ord (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map.Make.Ord) Parameter Make.Ord
A total ordering function over the keys. This is a two-argument function f
such that f e1 e2
is zero if the keys e1
and e2
are equal, f e1 e2
is strictly negative if e1
is smaller than e2
, and f e1 e2
is strictly positive if e1
is greater than e2
. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare
.
+Ord (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map.Make.Ord) Parameter Make.Ord
A total ordering function over the keys. This is a two-argument function f
such that f e1 e2
is zero if the keys e1
and e2
are equal, f e1 e2
is strictly negative if e1
is smaller than e2
, and f e1 e2
is strictly positive if e1
is greater than e2
. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare
.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/Make/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/Make/index.html
index a183b72..4aa699d 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/Make/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/Make/index.html
@@ -1,5 +1,5 @@
-Make (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map.Make) Module Map.Make
Functor building an implementation of the map structure given a totally ordered type.
Parameters
module Ord : OrderedType
Signature
Maps
type key = Ord.t
The type of the map keys.
val empty : 'a t
The empty map.
add ~key ~data m
returns a map containing the same bindings as m
, plus a binding of key
to data
. If key
was already bound in m
to a value that is physically equal to data
, m
is returned unchanged (the result of the function is then physically equal to m
). Otherwise, the previous binding of key
in m
disappears.
add_to_list ~key ~data m
is m
with key
mapped to l
such that l
is data :: Map.find key m
if key
was bound in m
and [v]
otherwise.
update ~key ~f m
returns a map containing the same bindings as m
, except for the binding of key
. Depending on the value of y
where y
is f (find_opt key m)
, the binding of key
is added, removed or updated. If y
is None
, the binding is removed if it exists; otherwise, if y
is Some z
then key
is associated to z
in the resulting map. If key
was already bound in m
to a value that is physically equal to z
, m
is returned unchanged (the result of the function is then physically equal to m
).
singleton x y
returns the one-element map that contains a binding y
for x
.
remove x m
returns a map containing the same bindings as m
, except for x
which is unbound in the returned map. If x
was not in m
, m
is returned unchanged (the result of the function is then physically equal to m
).
val merge :
+Make (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map.Make) Module Map.Make
Functor building an implementation of the map structure given a totally ordered type.
Parameters
module Ord : OrderedType
Signature
Maps
type key = Ord.t
The type of the map keys.
val empty : 'a t
The empty map.
add ~key ~data m
returns a map containing the same bindings as m
, plus a binding of key
to data
. If key
was already bound in m
to a value that is physically equal to data
, m
is returned unchanged (the result of the function is then physically equal to m
). Otherwise, the previous binding of key
in m
disappears.
add_to_list ~key ~data m
is m
with key
mapped to l
such that l
is data :: Map.find key m
if key
was bound in m
and [v]
otherwise.
update ~key ~f m
returns a map containing the same bindings as m
, except for the binding of key
. Depending on the value of y
where y
is f (find_opt key m)
, the binding of key
is added, removed or updated. If y
is None
, the binding is removed if it exists; otherwise, if y
is Some z
then key
is associated to z
in the resulting map. If key
was already bound in m
to a value that is physically equal to z
, m
is returned unchanged (the result of the function is then physically equal to m
).
singleton x y
returns the one-element map that contains a binding y
for x
.
remove x m
returns a map containing the same bindings as m
, except for x
which is unbound in the returned map. If x
was not in m
, m
is returned unchanged (the result of the function is then physically equal to m
).
val merge :
f:(key -> 'a option -> 'b option -> 'c option) ->
'a t ->
'b t ->
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/index.html
index 3c38d0b..ba9136a 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/index.html
@@ -1,5 +1,5 @@
-Map (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map) Module MoreLabels.Map
Association tables over ordered types.
This module implements applicative association tables, also known as finite maps or dictionaries, given a total ordering function over the keys. All operations over maps are purely applicative (no side-effects). The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map.
For instance:
module IntPairs =
+Map (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map) Module MoreLabels.Map
Association tables over ordered types.
This module implements applicative association tables, also known as finite maps or dictionaries, given a total ordering function over the keys. All operations over maps are purely applicative (no side-effects). The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map.
For instance:
module IntPairs =
struct
type t = int * int
let compare (x0,y0) (x1,y1) =
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/module-type-OrderedType/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/module-type-OrderedType/index.html
index a7531ba..0a96497 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/module-type-OrderedType/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/module-type-OrderedType/index.html
@@ -1,2 +1,2 @@
-OrderedType (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map.OrderedType) Module type Map.OrderedType
Input signature of the functor Make
.
A total ordering function over the keys. This is a two-argument function f
such that f e1 e2
is zero if the keys e1
and e2
are equal, f e1 e2
is strictly negative if e1
is smaller than e2
, and f e1 e2
is strictly positive if e1
is greater than e2
. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare
.
+OrderedType (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map.OrderedType) Module type Map.OrderedType
Input signature of the functor Make
.
A total ordering function over the keys. This is a two-argument function f
such that f e1 e2
is zero if the keys e1
and e2
are equal, f e1 e2
is strictly negative if e1
is smaller than e2
, and f e1 e2
is strictly positive if e1
is greater than e2
. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare
.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/module-type-S/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/module-type-S/index.html
index a850367..ead58e5 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/module-type-S/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Map/module-type-S/index.html
@@ -1,5 +1,5 @@
-S (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map.S) Module type Map.S
Output signature of the functor Make
.
Maps
val empty : 'a t
The empty map.
add ~key ~data m
returns a map containing the same bindings as m
, plus a binding of key
to data
. If key
was already bound in m
to a value that is physically equal to data
, m
is returned unchanged (the result of the function is then physically equal to m
). Otherwise, the previous binding of key
in m
disappears.
add_to_list ~key ~data m
is m
with key
mapped to l
such that l
is data :: Map.find key m
if key
was bound in m
and [v]
otherwise.
update ~key ~f m
returns a map containing the same bindings as m
, except for the binding of key
. Depending on the value of y
where y
is f (find_opt key m)
, the binding of key
is added, removed or updated. If y
is None
, the binding is removed if it exists; otherwise, if y
is Some z
then key
is associated to z
in the resulting map. If key
was already bound in m
to a value that is physically equal to z
, m
is returned unchanged (the result of the function is then physically equal to m
).
singleton x y
returns the one-element map that contains a binding y
for x
.
remove x m
returns a map containing the same bindings as m
, except for x
which is unbound in the returned map. If x
was not in m
, m
is returned unchanged (the result of the function is then physically equal to m
).
val merge :
+S (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Map.S) Module type Map.S
Output signature of the functor Make
.
Maps
val empty : 'a t
The empty map.
add ~key ~data m
returns a map containing the same bindings as m
, plus a binding of key
to data
. If key
was already bound in m
to a value that is physically equal to data
, m
is returned unchanged (the result of the function is then physically equal to m
). Otherwise, the previous binding of key
in m
disappears.
add_to_list ~key ~data m
is m
with key
mapped to l
such that l
is data :: Map.find key m
if key
was bound in m
and [v]
otherwise.
update ~key ~f m
returns a map containing the same bindings as m
, except for the binding of key
. Depending on the value of y
where y
is f (find_opt key m)
, the binding of key
is added, removed or updated. If y
is None
, the binding is removed if it exists; otherwise, if y
is Some z
then key
is associated to z
in the resulting map. If key
was already bound in m
to a value that is physically equal to z
, m
is returned unchanged (the result of the function is then physically equal to m
).
singleton x y
returns the one-element map that contains a binding y
for x
.
remove x m
returns a map containing the same bindings as m
, except for x
which is unbound in the returned map. If x
was not in m
, m
is returned unchanged (the result of the function is then physically equal to m
).
val merge :
f:(key -> 'a option -> 'b option -> 'c option) ->
'a t ->
'b t ->
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/Make/argument-1-Ord/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/Make/argument-1-Ord/index.html
index efd86b4..4df4937 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/Make/argument-1-Ord/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/Make/argument-1-Ord/index.html
@@ -1,2 +1,2 @@
-Ord (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set.Make.Ord) Parameter Make.Ord
A total ordering function over the set elements. This is a two-argument function f
such that f e1 e2
is zero if the elements e1
and e2
are equal, f e1 e2
is strictly negative if e1
is smaller than e2
, and f e1 e2
is strictly positive if e1
is greater than e2
. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare
.
+Ord (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set.Make.Ord) Parameter Make.Ord
A total ordering function over the set elements. This is a two-argument function f
such that f e1 e2
is zero if the elements e1
and e2
are equal, f e1 e2
is strictly negative if e1
is smaller than e2
, and f e1 e2
is strictly positive if e1
is greater than e2
. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare
.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/Make/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/Make/index.html
index d4a8285..03f21dc 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/Make/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/Make/index.html
@@ -1,3 +1,3 @@
-Make (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set.Make) Module Set.Make
Functor building an implementation of the set structure given a totally ordered type.
Parameters
module Ord : OrderedType
Signature
Sets
type elt = Ord.t
The type of the set elements.
val empty : t
The empty set.
add x s
returns a set containing all elements of s
, plus x
. If x
was already in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
remove x s
returns a set containing all elements of s
, except x
. If x
was not in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
val cardinal : t -> int
Return the number of elements of a set.
Elements
Return the list of all elements of the given set. The returned list is sorted in increasing order with respect to the ordering Ord.compare
, where Ord
is the argument given to Set.Make
.
Return the smallest element of the given set (with respect to the Ord.compare
ordering), or raise Not_found
if the set is empty.
Return the smallest element of the given set (with respect to the Ord.compare
ordering), or None
if the set is empty.
Same as min_elt_opt
, but returns the largest element of the given set.
Return one element of the given set, or raise Not_found
if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.
Return one element of the given set, or None
if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.
Searching
find x s
returns the element of s
equal to x
(according to Ord.compare
), or raise Not_found
if no such element exists.
find_opt x s
returns the element of s
equal to x
(according to Ord.compare
), or None
if no such element exists.
find_first ~f s
, where f
is a monotonically increasing function, returns the lowest element e
of s
such that f e
, or raises Not_found
if no such element exists.
For example, find_first (fun e -> Ord.compare e x >= 0) s
will return the first element e
of s
where Ord.compare e x >= 0
(intuitively: e >= x
), or raise Not_found
if x
is greater than any element of s
.
find_first_opt ~f s
, where f
is a monotonically increasing function, returns an option containing the lowest element e
of s
such that f e
, or None
if no such element exists.
find_last ~f s
, where f
is a monotonically decreasing function, returns the highest element e
of s
such that f e
, or raises Not_found
if no such element exists.
find_last_opt ~f s
, where f
is a monotonically decreasing function, returns an option containing the highest element e
of s
such that f e
, or None
if no such element exists.
Traversing
iter ~f s
applies f
in turn to all elements of s
. The elements of s
are presented to f
in increasing order with respect to the ordering over the type of the elements.
fold ~f s init
computes (f xN ... (f x2 (f x1 init))...)
, where x1 ... xN
are the elements of s
, in increasing order.
Transforming
map ~f s
is the set whose elements are f a0
,f a1
... f
+Make (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set.Make) Module Set.Make
Functor building an implementation of the set structure given a totally ordered type.
Parameters
module Ord : OrderedType
Signature
Sets
type elt = Ord.t
The type of the set elements.
val empty : t
The empty set.
add x s
returns a set containing all elements of s
, plus x
. If x
was already in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
remove x s
returns a set containing all elements of s
, except x
. If x
was not in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
val cardinal : t -> int
Return the number of elements of a set.
Elements
Return the list of all elements of the given set. The returned list is sorted in increasing order with respect to the ordering Ord.compare
, where Ord
is the argument given to Set.Make
.
Return the smallest element of the given set (with respect to the Ord.compare
ordering), or raise Not_found
if the set is empty.
Return the smallest element of the given set (with respect to the Ord.compare
ordering), or None
if the set is empty.
Same as min_elt_opt
, but returns the largest element of the given set.
Return one element of the given set, or raise Not_found
if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.
Return one element of the given set, or None
if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.
Searching
find x s
returns the element of s
equal to x
(according to Ord.compare
), or raise Not_found
if no such element exists.
find_opt x s
returns the element of s
equal to x
(according to Ord.compare
), or None
if no such element exists.
find_first ~f s
, where f
is a monotonically increasing function, returns the lowest element e
of s
such that f e
, or raises Not_found
if no such element exists.
For example, find_first (fun e -> Ord.compare e x >= 0) s
will return the first element e
of s
where Ord.compare e x >= 0
(intuitively: e >= x
), or raise Not_found
if x
is greater than any element of s
.
find_first_opt ~f s
, where f
is a monotonically increasing function, returns an option containing the lowest element e
of s
such that f e
, or None
if no such element exists.
find_last ~f s
, where f
is a monotonically decreasing function, returns the highest element e
of s
such that f e
, or raises Not_found
if no such element exists.
find_last_opt ~f s
, where f
is a monotonically decreasing function, returns an option containing the highest element e
of s
such that f e
, or None
if no such element exists.
Traversing
iter ~f s
applies f
in turn to all elements of s
. The elements of s
are presented to f
in increasing order with respect to the ordering over the type of the elements.
fold ~f s init
computes (f xN ... (f x2 (f x1 init))...)
, where x1 ... xN
are the elements of s
, in increasing order.
Transforming
map ~f s
is the set whose elements are f a0
,f a1
... f
aN
, where a0
,a1
...aN
are the elements of s
.
The elements are passed to f
in increasing order with respect to the ordering over the type of the elements.
If no element of s
is changed by f
, s
is returned unchanged. (If each output of f
is physically equal to its input, the returned set is physically equal to s
.)
filter ~f s
returns the set of all elements in s
that satisfy predicate f
. If f
satisfies every element in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
filter_map ~f s
returns the set of all v
such that f x = Some v
for some element x
of s
.
For example,
filter_map (fun n -> if n mod 2 = 0 then Some (n / 2) else None) s
is the set of halves of the even elements of s
.
If no element of s
is changed or dropped by f
(if f x = Some x
for each element x
), then s
is returned unchanged: the result of the function is then physically equal to s
.
partition ~f s
returns a pair of sets (s1, s2)
, where s1
is the set of all the elements of s
that satisfy the predicate f
, and s2
is the set of all the elements of s
that do not satisfy f
.
split x s
returns a triple (l, present, r)
, where l
is the set of elements of s
that are strictly less than x
; r
is the set of elements of s
that are strictly greater than x
; present
is false
if s
contains no element equal to x
, or true
if s
contains an element equal to x
.
Predicates and comparisons
val is_empty : t -> bool
Test whether a set is empty or not.
equal s1 s2
tests whether the sets s1
and s2
are equal, that is, contain equal elements.
Total ordering between sets. Can be used as the ordering function for doing sets of sets.
for_all ~f s
checks if all elements of the set satisfy the predicate f
.
exists ~f s
checks if at least one element of the set satisfies the predicate f
.
Converting
of_list l
creates a set from a list of elements. This is usually more efficient than folding add
over the list, except perhaps for lists with many duplicated elements.
to_seq_from x s
iterates on a subset of the elements of s
in ascending order, from x
or above.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/index.html
index d8ede0a..21e1593 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/index.html
@@ -1,5 +1,5 @@
-Set (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set) Module MoreLabels.Set
Sets over ordered types.
This module implements the set data structure, given a total ordering function over the set elements. All operations over sets are purely applicative (no side-effects). The implementation uses balanced binary trees, and is therefore reasonably efficient: insertion and membership take time logarithmic in the size of the set, for instance.
The Make
functor constructs implementations for any type, given a compare
function. For instance:
module IntPairs =
+Set (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set) Module MoreLabels.Set
Sets over ordered types.
This module implements the set data structure, given a total ordering function over the set elements. All operations over sets are purely applicative (no side-effects). The implementation uses balanced binary trees, and is therefore reasonably efficient: insertion and membership take time logarithmic in the size of the set, for instance.
The Make
functor constructs implementations for any type, given a compare
function. For instance:
module IntPairs =
struct
type t = int * int
let compare (x0,y0) (x1,y1) =
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/module-type-OrderedType/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/module-type-OrderedType/index.html
index ba9b815..76c2df7 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/module-type-OrderedType/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/module-type-OrderedType/index.html
@@ -1,2 +1,2 @@
-OrderedType (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set.OrderedType) Module type Set.OrderedType
Input signature of the functor Make
.
A total ordering function over the set elements. This is a two-argument function f
such that f e1 e2
is zero if the elements e1
and e2
are equal, f e1 e2
is strictly negative if e1
is smaller than e2
, and f e1 e2
is strictly positive if e1
is greater than e2
. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare
.
+OrderedType (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set.OrderedType) Module type Set.OrderedType
Input signature of the functor Make
.
A total ordering function over the set elements. This is a two-argument function f
such that f e1 e2
is zero if the elements e1
and e2
are equal, f e1 e2
is strictly negative if e1
is smaller than e2
, and f e1 e2
is strictly positive if e1
is greater than e2
. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare
.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/module-type-S/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/module-type-S/index.html
index f7f23f0..181d33a 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/module-type-S/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/Set/module-type-S/index.html
@@ -1,3 +1,3 @@
-S (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set.S) Module type Set.S
Output signature of the functor Make
.
Sets
val empty : t
The empty set.
add x s
returns a set containing all elements of s
, plus x
. If x
was already in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
remove x s
returns a set containing all elements of s
, except x
. If x
was not in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
val cardinal : t -> int
Return the number of elements of a set.
Elements
Return the list of all elements of the given set. The returned list is sorted in increasing order with respect to the ordering Ord.compare
, where Ord
is the argument given to Set.Make
.
Return the smallest element of the given set (with respect to the Ord.compare
ordering), or raise Not_found
if the set is empty.
Return the smallest element of the given set (with respect to the Ord.compare
ordering), or None
if the set is empty.
Same as min_elt_opt
, but returns the largest element of the given set.
Return one element of the given set, or raise Not_found
if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.
Return one element of the given set, or None
if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.
Searching
find x s
returns the element of s
equal to x
(according to Ord.compare
), or raise Not_found
if no such element exists.
find_opt x s
returns the element of s
equal to x
(according to Ord.compare
), or None
if no such element exists.
find_first ~f s
, where f
is a monotonically increasing function, returns the lowest element e
of s
such that f e
, or raises Not_found
if no such element exists.
For example, find_first (fun e -> Ord.compare e x >= 0) s
will return the first element e
of s
where Ord.compare e x >= 0
(intuitively: e >= x
), or raise Not_found
if x
is greater than any element of s
.
find_first_opt ~f s
, where f
is a monotonically increasing function, returns an option containing the lowest element e
of s
such that f e
, or None
if no such element exists.
find_last ~f s
, where f
is a monotonically decreasing function, returns the highest element e
of s
such that f e
, or raises Not_found
if no such element exists.
find_last_opt ~f s
, where f
is a monotonically decreasing function, returns an option containing the highest element e
of s
such that f e
, or None
if no such element exists.
Traversing
iter ~f s
applies f
in turn to all elements of s
. The elements of s
are presented to f
in increasing order with respect to the ordering over the type of the elements.
fold ~f s init
computes (f xN ... (f x2 (f x1 init))...)
, where x1 ... xN
are the elements of s
, in increasing order.
Transforming
map ~f s
is the set whose elements are f a0
,f a1
... f
+S (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels.Set.S) Module type Set.S
Output signature of the functor Make
.
Sets
val empty : t
The empty set.
add x s
returns a set containing all elements of s
, plus x
. If x
was already in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
remove x s
returns a set containing all elements of s
, except x
. If x
was not in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
val cardinal : t -> int
Return the number of elements of a set.
Elements
Return the list of all elements of the given set. The returned list is sorted in increasing order with respect to the ordering Ord.compare
, where Ord
is the argument given to Set.Make
.
Return the smallest element of the given set (with respect to the Ord.compare
ordering), or raise Not_found
if the set is empty.
Return the smallest element of the given set (with respect to the Ord.compare
ordering), or None
if the set is empty.
Same as min_elt_opt
, but returns the largest element of the given set.
Return one element of the given set, or raise Not_found
if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.
Return one element of the given set, or None
if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets.
Searching
find x s
returns the element of s
equal to x
(according to Ord.compare
), or raise Not_found
if no such element exists.
find_opt x s
returns the element of s
equal to x
(according to Ord.compare
), or None
if no such element exists.
find_first ~f s
, where f
is a monotonically increasing function, returns the lowest element e
of s
such that f e
, or raises Not_found
if no such element exists.
For example, find_first (fun e -> Ord.compare e x >= 0) s
will return the first element e
of s
where Ord.compare e x >= 0
(intuitively: e >= x
), or raise Not_found
if x
is greater than any element of s
.
find_first_opt ~f s
, where f
is a monotonically increasing function, returns an option containing the lowest element e
of s
such that f e
, or None
if no such element exists.
find_last ~f s
, where f
is a monotonically decreasing function, returns the highest element e
of s
such that f e
, or raises Not_found
if no such element exists.
find_last_opt ~f s
, where f
is a monotonically decreasing function, returns an option containing the highest element e
of s
such that f e
, or None
if no such element exists.
Traversing
iter ~f s
applies f
in turn to all elements of s
. The elements of s
are presented to f
in increasing order with respect to the ordering over the type of the elements.
fold ~f s init
computes (f xN ... (f x2 (f x1 init))...)
, where x1 ... xN
are the elements of s
, in increasing order.
Transforming
map ~f s
is the set whose elements are f a0
,f a1
... f
aN
, where a0
,a1
...aN
are the elements of s
.
The elements are passed to f
in increasing order with respect to the ordering over the type of the elements.
If no element of s
is changed by f
, s
is returned unchanged. (If each output of f
is physically equal to its input, the returned set is physically equal to s
.)
filter ~f s
returns the set of all elements in s
that satisfy predicate f
. If f
satisfies every element in s
, s
is returned unchanged (the result of the function is then physically equal to s
).
filter_map ~f s
returns the set of all v
such that f x = Some v
for some element x
of s
.
For example,
filter_map (fun n -> if n mod 2 = 0 then Some (n / 2) else None) s
is the set of halves of the even elements of s
.
If no element of s
is changed or dropped by f
(if f x = Some x
for each element x
), then s
is returned unchanged: the result of the function is then physically equal to s
.
partition ~f s
returns a pair of sets (s1, s2)
, where s1
is the set of all the elements of s
that satisfy the predicate f
, and s2
is the set of all the elements of s
that do not satisfy f
.
split x s
returns a triple (l, present, r)
, where l
is the set of elements of s
that are strictly less than x
; r
is the set of elements of s
that are strictly greater than x
; present
is false
if s
contains no element equal to x
, or true
if s
contains an element equal to x
.
Predicates and comparisons
val is_empty : t -> bool
Test whether a set is empty or not.
equal s1 s2
tests whether the sets s1
and s2
are equal, that is, contain equal elements.
Total ordering between sets. Can be used as the ordering function for doing sets of sets.
for_all ~f s
checks if all elements of the set satisfy the predicate f
.
exists ~f s
checks if at least one element of the set satisfies the predicate f
.
Converting
of_list l
creates a set from a list of elements. This is usually more efficient than folding add
over the list, except perhaps for lists with many duplicated elements.
to_seq_from x s
iterates on a subset of the elements of s
in ascending order, from x
or above.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/index.html
index 4e8c41b..3b49550 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/MoreLabels/index.html
@@ -1,2 +1,2 @@
-MoreLabels (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels) Module Stdlib_alerting.MoreLabels
+MoreLabels (less-power.Stdlib_alerts.Stdlib_alerting.MoreLabels) Module Stdlib_alerting.MoreLabels
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printexc/Slot/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printexc/Slot/index.html
index 0106dc6..655b8e8 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printexc/Slot/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printexc/Slot/index.html
@@ -1,2 +1,2 @@
-Slot (less-power.Stdlib_alerts.Stdlib_alerting.Printexc.Slot) Module Printexc.Slot
type t = backtrace_slot
val is_raise : t -> bool
is_raise slot
is true
when slot
refers to a raising point in the code, and false
when it comes from a simple function call.
val is_inline : t -> bool
is_inline slot
is true
when slot
refers to a call that got inlined by the compiler, and false
when it comes from any other context.
location slot
returns the location information of the slot, if available, and None
otherwise.
Some possible reasons for failing to return a location are as follow:
- the slot corresponds to a compiler-inserted raise
- the slot corresponds to a part of the program that has not been compiled with debug information (
-g
)
val name : t -> string option
name slot
returns the name of the function or definition enclosing the location referred to by the slot.
name slot
returns None if the name is unavailable, which may happen for the same reasons as location
returning None.
val format : int -> t -> string option
format pos slot
returns the string representation of slot
as raw_backtrace_to_string
would format it, assuming it is the pos
-th element of the backtrace: the 0
-th element is pretty-printed differently than the others.
Whole-backtrace printing functions also skip some uninformative slots; in that case, format pos slot
returns None
.
+Slot (less-power.Stdlib_alerts.Stdlib_alerting.Printexc.Slot) Module Printexc.Slot
type t = backtrace_slot
val is_raise : t -> bool
is_raise slot
is true
when slot
refers to a raising point in the code, and false
when it comes from a simple function call.
val is_inline : t -> bool
is_inline slot
is true
when slot
refers to a call that got inlined by the compiler, and false
when it comes from any other context.
location slot
returns the location information of the slot, if available, and None
otherwise.
Some possible reasons for failing to return a location are as follow:
- the slot corresponds to a compiler-inserted raise
- the slot corresponds to a part of the program that has not been compiled with debug information (
-g
)
val name : t -> string option
name slot
returns the name of the function or definition enclosing the location referred to by the slot.
name slot
returns None if the name is unavailable, which may happen for the same reasons as location
returning None.
val format : int -> t -> string option
format pos slot
returns the string representation of slot
as raw_backtrace_to_string
would format it, assuming it is the pos
-th element of the backtrace: the 0
-th element is pretty-printed differently than the others.
Whole-backtrace printing functions also skip some uninformative slots; in that case, format pos slot
returns None
.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printexc/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printexc/index.html
index d035cd2..dc169f9 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printexc/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printexc/index.html
@@ -1,5 +1,5 @@
-Printexc (less-power.Stdlib_alerts.Stdlib_alerting.Printexc) Module Stdlib_alerting.Printexc
include sig ... end
Printexc.to_string_default e
returns a string representation of the exception e
, ignoring all registered exception printers.
Printexc.to_string e
returns a string representation of the exception e
.
Printexc.print fn x
applies fn
to x
and returns the result. If the evaluation of fn x
raises any exception, the name of the exception is printed on standard error output, and the exception is raised again. The typical use is to catch and report exceptions that escape a function application.
Printexc.catch fn x
is similar to Printexc.print
, but aborts the program with exit code 2 after printing the uncaught exception. This function is deprecated: the runtime system is now able to print uncaught exceptions as precisely as Printexc.catch
does. Moreover, calling Printexc.catch
makes it harder to track the location of the exception using the debugger or the stack backtrace facility. So, do not use Printexc.catch
in new code.
Printexc.print_backtrace oc
prints an exception backtrace on the output channel oc
. The backtrace lists the program locations where the most-recently raised exception was raised and where it was propagated through function calls.
If the call is not inside an exception handler, the returned backtrace is unspecified. If the call is after some exception-catching code (before in the handler, or in a when-guard during the matching of the exception handler), the backtrace may correspond to a later exception than the handled one.
Printexc.get_backtrace ()
returns a string containing the same exception backtrace that Printexc.print_backtrace
would print. Same restriction usage than print_backtrace
.
Printexc.record_backtrace b
turns recording of exception backtraces on (if b = true
) or off (if b = false
). Initially, backtraces are not recorded, unless the b
flag is given to the program through the OCAMLRUNPARAM
variable.
Printexc.backtrace_status()
returns true
if exception backtraces are currently recorded, false
if not.
Printexc.register_printer fn
registers fn
as an exception printer. The printer should return None
or raise an exception if it does not know how to convert the passed exception, and Some
+Printexc (less-power.Stdlib_alerts.Stdlib_alerting.Printexc) Module Stdlib_alerting.Printexc
include sig ... end
Printexc.to_string_default e
returns a string representation of the exception e
, ignoring all registered exception printers.
Printexc.to_string e
returns a string representation of the exception e
.
Printexc.print fn x
applies fn
to x
and returns the result. If the evaluation of fn x
raises any exception, the name of the exception is printed on standard error output, and the exception is raised again. The typical use is to catch and report exceptions that escape a function application.
Printexc.catch fn x
is similar to Printexc.print
, but aborts the program with exit code 2 after printing the uncaught exception. This function is deprecated: the runtime system is now able to print uncaught exceptions as precisely as Printexc.catch
does. Moreover, calling Printexc.catch
makes it harder to track the location of the exception using the debugger or the stack backtrace facility. So, do not use Printexc.catch
in new code.
Printexc.print_backtrace oc
prints an exception backtrace on the output channel oc
. The backtrace lists the program locations where the most-recently raised exception was raised and where it was propagated through function calls.
If the call is not inside an exception handler, the returned backtrace is unspecified. If the call is after some exception-catching code (before in the handler, or in a when-guard during the matching of the exception handler), the backtrace may correspond to a later exception than the handled one.
Printexc.get_backtrace ()
returns a string containing the same exception backtrace that Printexc.print_backtrace
would print. Same restriction usage than print_backtrace
.
Printexc.record_backtrace b
turns recording of exception backtraces on (if b = true
) or off (if b = false
). Initially, backtraces are not recorded, unless the b
flag is given to the program through the OCAMLRUNPARAM
variable.
Printexc.backtrace_status()
returns true
if exception backtraces are currently recorded, false
if not.
Printexc.register_printer fn
registers fn
as an exception printer. The printer should return None
or raise an exception if it does not know how to convert the passed exception, and Some
s
with s
the resulting string if it can convert the passed exception. Exceptions raised by the printer are ignored.
When converting an exception into a string, the printers will be invoked in the reverse order of their registrations, until a printer returns a Some s
value (if no such printer exists, the runtime will use a generic printer).
When using this mechanism, one should be aware that an exception backtrace is attached to the thread that saw it raised, rather than to the exception itself. Practically, it means that the code related to fn
should not use the backtrace if it has itself raised an exception before.
Printexc.use_printers e
returns None
if there are no registered printers and Some s
with else as the resulting string otherwise.
A raw_backtrace_entry
is an element of a raw_backtrace
.
Each raw_backtrace_entry
is an opaque integer, whose value is not stable between different programs, or even between different runs of the same binary.
A raw_backtrace_entry
can be converted to a usable form using backtrace_slots_of_raw_entry
below. Note that, due to inlining, a single raw_backtrace_entry
may convert to several backtrace_slot
s. Since the values of a raw_backtrace_entry
are not stable, they cannot be marshalled. If they are to be converted, the conversion must be done by the process that generated them.
Again due to inlining, there may be multiple distinct raw_backtrace_entry values that convert to equal backtrace_slot
s. However, if two raw_backtrace_entry
s are equal as integers, then they represent the same backtrace_slot
s.
val raw_backtrace_entries : raw_backtrace -> raw_backtrace_entry array
val get_raw_backtrace : unit -> raw_backtrace
Printexc.get_raw_backtrace ()
returns the same exception backtrace that Printexc.print_backtrace
would print, but in a raw format. Same restriction usage than print_backtrace
.
val print_raw_backtrace : Stdlib.out_channel -> raw_backtrace -> unit
Print a raw backtrace in the same format Printexc.print_backtrace
uses.
val raw_backtrace_to_string : raw_backtrace -> string
Return a string from a raw backtrace, in the same format Printexc.get_backtrace
uses.
val raise_with_backtrace : exn -> raw_backtrace -> 'a
Reraise the exception using the given raw_backtrace for the origin of the exception
val get_callstack : int -> raw_backtrace
Printexc.get_callstack n
returns a description of the top of the call stack on the current program point (for the current thread), with at most n
entries. (Note: this function is not related to exceptions at all, despite being part of the Printexc
module.)
val default_uncaught_exception_handler : exn -> raw_backtrace -> unit
Printexc.default_uncaught_exception_handler
prints the exception and backtrace on standard error output.
val set_uncaught_exception_handler : (exn -> raw_backtrace -> unit) -> unit
Printexc.set_uncaught_exception_handler fn
registers fn
as the handler for uncaught exceptions. The default handler is Printexc.default_uncaught_exception_handler
.
Note that when fn
is called all the functions registered with Stdlib.at_exit
have already been called. Because of this you must make sure any output channel fn
writes on is flushed.
Also note that exceptions raised by user code in the interactive toplevel are not passed to this function as they are caught by the toplevel itself.
If fn
raises an exception, both the exceptions passed to fn
and raised by fn
will be printed with their respective backtrace.
val backtrace_slots : raw_backtrace -> backtrace_slot array option
Returns the slots of a raw backtrace, or None
if none of them contain useful information.
In the return array, the slot at index 0
corresponds to the most recent function call, raise, or primitive get_backtrace
call in the trace.
Some possible reasons for returning None
are as follow:
- none of the slots in the trace come from modules compiled with debug information (
-g
) - the program is a bytecode program that has not been linked with debug information enabled (
ocamlc -g
)
val backtrace_slots_of_raw_entry :
raw_backtrace_entry ->
backtrace_slot array option
Returns the slots of a single raw backtrace entry, or None
if this entry lacks debug information.
Slots are returned in the same order as backtrace_slots
: the slot at index 0
is the most recent call, raise, or primitive, and subsequent slots represent callers.
module Slot : sig ... end
val raw_backtrace_length : raw_backtrace -> int
raw_backtrace_length bckt
returns the number of slots in the backtrace bckt
.
val get_raw_backtrace_slot : raw_backtrace -> int -> raw_backtrace_slot
get_raw_backtrace_slot bckt pos
returns the slot in position pos
in the backtrace bckt
.
val convert_raw_backtrace_slot : raw_backtrace_slot -> backtrace_slot
Extracts the user-friendly backtrace_slot
from a low-level raw_backtrace_slot
.
val get_raw_backtrace_next_slot :
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printf/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printf/index.html
index 8b49f54..9f92a97 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printf/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Printf/index.html
@@ -1,5 +1,5 @@
-Printf (less-power.Stdlib_alerts.Stdlib_alerting.Printf) Module Stdlib_alerting.Printf
include sig ... end
Same as Printf.fprintf
, but instead of printing on an output channel, return a string containing the result of formatting the arguments.
Same as sprintf
above, but instead of returning the string, passes it to the first argument.
val fprintf :
+Printf (less-power.Stdlib_alerts.Stdlib_alerting.Printf) Module Stdlib_alerting.Printf
include sig ... end
Same as Printf.fprintf
, but instead of printing on an output channel, return a string containing the result of formatting the arguments.
Same as sprintf
above, but instead of returning the string, passes it to the first argument.
fprintf outchan format arg1 ... argN
formats the arguments arg1
to argN
according to the format string format
, and outputs the resulting string on the channel outchan
.
The format string is a character string which contains two types of objects: plain characters, which are simply copied to the output channel, and conversion specifications, each of which causes conversion and printing of arguments.
Conversion specifications have the following form:
% [flags] [width] [.precision] type
In short, a conversion specification consists in the %
character, followed by optional modifiers and a type which is made of one or two characters.
The types and their meanings are:
d
, i
: convert an integer argument to signed decimal. The flag #
adds underscores to large values for readability.u
, n
, l
, L
, or N
: convert an integer argument to unsigned decimal. Warning: n
, l
, L
, and N
are used for scanf
, and should not be used for printf
. The flag #
adds underscores to large values for readability.x
: convert an integer argument to unsigned hexadecimal, using lowercase letters. The flag #
adds a 0x
prefix to non zero values.X
: convert an integer argument to unsigned hexadecimal, using uppercase letters. The flag #
adds a 0X
prefix to non zero values.o
: convert an integer argument to unsigned octal. The flag #
adds a 0
prefix to non zero values.s
: insert a string argument.S
: convert a string argument to OCaml syntax (double quotes, escapes).c
: insert a character argument.C
: convert a character argument to OCaml syntax (single quotes, escapes).f
: convert a floating-point argument to decimal notation, in the style dddd.ddd
.F
: convert a floating-point argument to OCaml syntax (dddd.
or dddd.ddd
or d.ddd e+-dd
). Converts to hexadecimal with the #
flag (see h
).e
or E
: convert a floating-point argument to decimal notation, in the style d.ddd e+-dd
(mantissa and exponent).g
or G
: convert a floating-point argument to decimal notation, in style f
or e
, E
(whichever is more compact). Moreover, any trailing zeros are removed from the fractional part of the result and the decimal-point character is removed if there is no fractional part remaining.h
or H
: convert a floating-point argument to hexadecimal notation, in the style 0xh.hhhh p+-dd
(hexadecimal mantissa, exponent in decimal and denotes a power of 2).B
: convert a boolean argument to the string true
or false
b
: convert a boolean argument (deprecated; do not use in new programs).ld
, li
, lu
, lx
, lX
, lo
: convert an int32
argument to the format specified by the second letter (decimal, hexadecimal, etc).nd
, ni
, nu
, nx
, nX
, no
: convert a nativeint
argument to the format specified by the second letter.Ld
, Li
, Lu
, Lx
, LX
, Lo
: convert an int64
argument to the format specified by the second letter.a
: user-defined printer. Take two arguments and apply the first one to outchan
(the current output channel) and to the second argument. The first argument must therefore have type out_channel -> 'b -> unit
and the second 'b
. The output produced by the function is inserted in the output of fprintf
at the current point.t
: same as %a
, but take only one argument (with type out_channel -> unit
) and apply it to outchan
.\{ fmt %\}
: convert a format string argument to its type digest. The argument must have the same type as the internal format string fmt
.( fmt %)
: format string substitution. Take a format string argument and substitute it to the internal format string fmt
to print following arguments. The argument must have the same type as the internal format string fmt
.!
: take no argument and flush the output.%
: take no argument and output one %
character.\@
: take no argument and output one \@
character.,
: take no argument and output nothing: a no-op delimiter for conversion specifications.
The optional flags
are:
-
: left-justify the output (default is right justification).0
: for numerical conversions, pad with zeroes instead of spaces.+
: for signed numerical conversions, prefix number with a +
sign if positive.- space: for signed numerical conversions, prefix number with a space if positive.
#
: request an alternate formatting style for the integer types and the floating-point type F
.
The optional width
is an integer indicating the minimal width of the result. For instance, %6d
prints an integer, prefixing it with spaces to fill at least 6 characters.
The optional precision
is a dot .
followed by an integer indicating how many digits follow the decimal point in the %f
, %e
, %E
, %h
, and %H
conversions or the maximum number of significant digits to appear for the %F
, %g
and %G
conversions. For instance, %.4f
prints a float
with 4 fractional digits.
The integer in a width
or precision
can also be specified as *
, in which case an extra integer argument is taken to specify the corresponding width
or precision
. This integer argument precedes immediately the argument to print. For instance, %.*f
prints a float
with as many fractional digits as the value of the argument given before the float.
Same as Printf.fprintf
, but output on stdout
.
Same as Printf.fprintf
, but output on stderr
.
Same as Printf.fprintf
, but does not print anything. Useful to ignore some material when conditionally printing.
val kfprintf :
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Scanf/Scanning/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Scanf/Scanning/index.html
index 22dc23e..8c0606f 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Scanf/Scanning/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Scanf/Scanning/index.html
@@ -1,2 +1,2 @@
-Scanning (less-power.Stdlib_alerts.Stdlib_alerting.Scanf.Scanning) Module Scanf.Scanning
+Scanning (less-power.Stdlib_alerts.Stdlib_alerting.Scanf.Scanning) Module Scanf.Scanning
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Scanf/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Scanf/index.html
index 96c8dec..58ab3f0 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Scanf/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Scanf/index.html
@@ -1,5 +1,5 @@
-Scanf (less-power.Stdlib_alerts.Stdlib_alerting.Scanf) Module Stdlib_alerting.Scanf
module Scanning : sig ... end
include sig ... end
type ('a, 'b, 'c, 'd) scanner =
+Scanf (less-power.Stdlib_alerts.Stdlib_alerting.Scanf) Module Stdlib_alerting.Scanf
module Scanning : sig ... end
include sig ... end
type ('a, 'b, 'c, 'd) scanner =
('a, Scanning.in_channel, 'b, 'c, 'a -> 'd, 'd) Stdlib.format6 ->
'c
The type of formatted input scanners: ('a, 'b, 'c, 'd) scanner
is the type of a formatted input function that reads from some formatted input channel according to some format string; more precisely, if scan
is some formatted input function, then scan
ic fmt f
applies f
to all the arguments specified by format string fmt
, when scan
has read those arguments from the Scanning.in_channel
formatted input channel ic
.
For instance, the Scanf.scanf
function below has type ('a, 'b, 'c, 'd) scanner
, since it is a formatted input function that reads from Scanning.stdin
: scanf fmt f
applies f
to the arguments specified by fmt
, reading those arguments from Stdlib.stdin
as expected.
If the format fmt
has some %r
indications, the corresponding formatted input functions must be provided before receiver function f
. For instance, if read_elem
is an input function for values of type t
, then bscanf ic "%r;" read_elem f
reads a value v
of type t
followed by a ';'
character, and returns f v
.
type ('a, 'b, 'c, 'd) scanner_opt =
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Seq/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Seq/index.html
index fb43ceb..6f77da0 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Seq/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/Seq/index.html
@@ -1,2 +1,2 @@
-Seq (less-power.Stdlib_alerts.Stdlib_alerting.Seq) Module Stdlib_alerting.Seq
type 'a t = unit -> 'a node
include sig ... end
val is_empty : 'a t -> bool
is_empty xs
determines whether the sequence xs
is empty.
It is recommended that the sequence xs
be persistent. Indeed, is_empty xs
demands the head of the sequence xs
, so, if xs
is ephemeral, it may be the case that xs
cannot be used any more after this call has taken place.
If xs
is empty, then uncons xs
is None
.
If xs
is nonempty, then uncons xs
is Some (x, ys)
where x
is the head of the sequence and ys
its tail.
val length : 'a t -> int
length xs
is the length of the sequence xs
.
The sequence xs
must be finite.
val iter : ('a -> unit) -> 'a t -> unit
iter f xs
invokes f x
successively for every element x
of the sequence xs
, from left to right.
It terminates only if the sequence xs
is finite.
val fold_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc
fold_left f _ xs
invokes f _ x
successively for every element x
of the sequence xs
, from left to right.
An accumulator of type 'a
is threaded through the calls to f
.
It terminates only if the sequence xs
is finite.
val iteri : (int -> 'a -> unit) -> 'a t -> unit
iteri f xs
invokes f i x
successively for every element x
located at index i
in the sequence xs
.
It terminates only if the sequence xs
is finite.
iteri f xs
is equivalent to iter (fun (i, x) -> f i x) (zip (ints 0) xs)
.
val fold_lefti : ('acc -> int -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc
fold_lefti f _ xs
invokes f _ i x
successively for every element x
located at index i
of the sequence xs
.
An accumulator of type 'b
is threaded through the calls to f
.
It terminates only if the sequence xs
is finite.
fold_lefti f accu xs
is equivalent to fold_left (fun accu (i, x) -> f accu i x) accu (zip (ints 0) xs)
.
val for_all : ('a -> bool) -> 'a t -> bool
for_all p xs
determines whether all elements x
of the sequence xs
satisfy p x
.
The sequence xs
must be finite.
val exists : ('a -> bool) -> 'a t -> bool
exists xs p
determines whether at least one element x
of the sequence xs
satisfies p x
.
The sequence xs
must be finite.
val find : ('a -> bool) -> 'a t -> 'a option
find p xs
returns Some x
, where x
is the first element of the sequence xs
that satisfies p x
, if there is such an element.
It returns None
if there is no such element.
The sequence xs
must be finite.
val find_index : ('a -> bool) -> 'a t -> int option
find_index p xs
returns Some i
, where i
is the index of the first element of the sequence xs
that satisfies p x
, if there is such an element.
It returns None
if there is no such element.
The sequence xs
must be finite.
val find_map : ('a -> 'b option) -> 'a t -> 'b option
find_map f xs
returns Some y
, where x
is the first element of the sequence xs
such that f x = Some _
, if there is such an element, and where y
is defined by f x = Some y
.
It returns None
if there is no such element.
The sequence xs
must be finite.
val find_mapi : (int -> 'a -> 'b option) -> 'a t -> 'b option
Same as find_map
, but the predicate is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
The sequence xs
must be finite.
iter2 f xs ys
invokes f x y
successively for every pair (x, y)
of elements drawn synchronously from the sequences xs
and ys
.
If the sequences xs
and ys
have different lengths, then iteration stops as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
Iteration terminates only if at least one of the sequences xs
and ys
is finite.
iter2 f xs ys
is equivalent to iter (fun (x, y) -> f x y) (zip xs ys)
.
fold_left2 f _ xs ys
invokes f _ x y
successively for every pair (x, y)
of elements drawn synchronously from the sequences xs
and ys
.
An accumulator of type 'a
is threaded through the calls to f
.
If the sequences xs
and ys
have different lengths, then iteration stops as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
Iteration terminates only if at least one of the sequences xs
and ys
is finite.
fold_left2 f accu xs ys
is equivalent to fold_left (fun accu (x, y) -> f accu x y) (zip xs ys)
.
for_all2 p xs ys
determines whether all pairs (x, y)
of elements drawn synchronously from the sequences xs
and ys
satisfy p x y
.
If the sequences xs
and ys
have different lengths, then iteration stops as soon as one sequence is exhausted; the excess elements in the other sequence are ignored. In particular, if xs
or ys
is empty, then for_all2 p xs ys
is true. This is where for_all2
and equal
differ: equal eq xs ys
can be true only if xs
and ys
have the same length.
At least one of the sequences xs
and ys
must be finite.
for_all2 p xs ys
is equivalent to for_all (fun b -> b) (map2 p xs ys)
.
exists2 p xs ys
determines whether some pair (x, y)
of elements drawn synchronously from the sequences xs
and ys
satisfies p x y
.
If the sequences xs
and ys
have different lengths, then iteration must stop as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
At least one of the sequences xs
and ys
must be finite.
exists2 p xs ys
is equivalent to exists (fun b -> b) (map2 p xs ys)
.
Provided the function eq
defines an equality on elements, equal eq xs ys
determines whether the sequences xs
and ys
are pointwise equal.
At least one of the sequences xs
and ys
must be finite.
Provided the function cmp
defines a preorder on elements, compare cmp xs ys
compares the sequences xs
and ys
according to the lexicographic preorder.
For more details on comparison functions, see Array.sort
.
At least one of the sequences xs
and ys
must be finite.
val empty : 'a t
empty
is the empty sequence. It has no elements. Its length is 0.
val return : 'a -> 'a t
return x
is the sequence whose sole element is x
. Its length is 1.
cons x xs
is the sequence that begins with the element x
, followed with the sequence xs
.
Writing cons (f()) xs
causes the function call f()
to take place immediately. For this call to be delayed until the sequence is queried, one must instead write (fun () -> Cons(f(), xs))
.
val init : int -> (int -> 'a) -> 'a t
init n f
is the sequence f 0; f 1; ...; f (n-1)
.
n
must be nonnegative.
If desired, the infinite sequence f 0; f 1; ...
can be defined as map f (ints 0)
.
val unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t
unfold
constructs a sequence out of a step function and an initial state.
If f u
is None
then unfold f u
is the empty sequence. If f u
is Some (x, u')
then unfold f u
is the nonempty sequence cons x (unfold f u')
.
For example, unfold (function [] -> None | h :: t -> Some (h, t)) l
is equivalent to List.to_seq l
.
val repeat : 'a -> 'a t
repeat x
is the infinite sequence where the element x
is repeated indefinitely.
repeat x
is equivalent to cycle (return x)
.
val forever : (unit -> 'a) -> 'a t
forever f
is an infinite sequence where every element is produced (on demand) by the function call f()
.
For instance, forever Random.bool
is an infinite sequence of random bits.
forever f
is equivalent to map f (repeat ())
.
cycle xs
is the infinite sequence that consists of an infinite number of repetitions of the sequence xs
.
If xs
is an empty sequence, then cycle xs
is empty as well.
Consuming (a prefix of) the sequence cycle xs
once can cause the sequence xs
to be consumed more than once. Therefore, xs
must be persistent.
val iterate : ('a -> 'a) -> 'a -> 'a t
iterate f x
is the infinite sequence whose elements are x
, f x
, f (f x)
, and so on.
In other words, it is the orbit of the function f
, starting at x
.
map f xs
is the image of the sequence xs
through the transformation f
.
If xs
is the sequence x0; x1; ...
then map f xs
is the sequence f x0; f x1; ...
.
mapi
is analogous to map
, but applies the function f
to an index and an element.
mapi f xs
is equivalent to map2 f (ints 0) xs
.
filter p xs
is the sequence of the elements x
of xs
that satisfy p x
.
In other words, filter p xs
is the sequence xs
, deprived of the elements x
such that p x
is false.
filter_map f xs
is the sequence of the elements y
such that f x = Some y
, where x
ranges over xs
.
filter_map f xs
is equivalent to map Option.get (filter Option.is_some (map f xs))
.
If xs
is a sequence [x0; x1; x2; ...]
, then scan f a0 xs
is a sequence of accumulators [a0; a1; a2; ...]
where a1
is f a0 x0
, a2
is f a1 x1
, and so on.
Thus, scan f a0 xs
is conceptually related to fold_left f a0 xs
. However, instead of performing an eager iteration and immediately returning the final accumulator, it returns a sequence of accumulators.
For instance, scan (+) 0
transforms a sequence of integers into the sequence of its partial sums.
If xs
has length n
then scan f a0 xs
has length n+1
.
take n xs
is the sequence of the first n
elements of xs
.
If xs
has fewer than n
elements, then take n xs
is equivalent to xs
.
n
must be nonnegative.
drop n xs
is the sequence xs
, deprived of its first n
elements.
If xs
has fewer than n
elements, then drop n xs
is empty.
n
must be nonnegative.
drop
is lazy: the first n+1
elements of the sequence xs
are demanded only when the first element of drop n xs
is demanded. For this reason, drop 1 xs
is not equivalent to tail xs
, which queries xs
immediately.
take_while p xs
is the longest prefix of the sequence xs
where every element x
satisfies p x
.
drop_while p xs
is the sequence xs
, deprived of the prefix take_while p xs
.
Provided the function eq
defines an equality on elements, group eq xs
is the sequence of the maximal runs of adjacent duplicate elements of the sequence xs
.
Every element of group eq xs
is a nonempty sequence of equal elements.
The concatenation concat (group eq xs)
is equal to xs
.
Consuming group eq xs
, and consuming the sequences that it contains, can cause xs
to be consumed more than once. Therefore, xs
must be persistent.
The sequence memoize xs
has the same elements as the sequence xs
.
Regardless of whether xs
is ephemeral or persistent, memoize xs
is persistent: even if it is queried several times, xs
is queried at most once.
The construction of the sequence memoize xs
internally relies on suspensions provided by the module Lazy
. These suspensions are not thread-safe. Therefore, the sequence memoize xs
must not be queried by multiple threads concurrently.
If xss
is a matrix (a sequence of rows), then transpose xss
is the sequence of the columns of the matrix xss
.
The rows of the matrix xss
are not required to have the same length.
The matrix xss
is not required to be finite (in either direction).
The matrix xss
must be persistent.
append xs ys
is the concatenation of the sequences xs
and ys
.
Its elements are the elements of xs
, followed by the elements of ys
.
If xss
is a sequence of sequences, then concat xss
is its concatenation.
If xss
is the sequence xs0; xs1; ...
then concat xss
is the sequence xs0 @ xs1 @ ...
.
concat_map f xs
is equivalent to concat (map f xs)
.
concat_map
is an alias for flat_map
.
zip xs ys
is the sequence of pairs (x, y)
drawn synchronously from the sequences xs
and ys
.
If the sequences xs
and ys
have different lengths, then the sequence ends as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
zip xs ys
is equivalent to map2 (fun a b -> (a, b)) xs ys
.
map2 f xs ys
is the sequence of the elements f x y
, where the pairs (x, y)
are drawn synchronously from the sequences xs
and ys
.
If the sequences xs
and ys
have different lengths, then the sequence ends as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
map2 f xs ys
is equivalent to map (fun (x, y) -> f x y) (zip xs ys)
.
interleave xs ys
is the sequence that begins with the first element of xs
, continues with the first element of ys
, and so on.
When one of the sequences xs
and ys
is exhausted, interleave xs ys
continues with the rest of the other sequence.
If the sequences xs
and ys
are sorted according to the total preorder cmp
, then sorted_merge cmp xs ys
is the sorted sequence obtained by merging the sequences xs
and ys
.
For more details on comparison functions, see Array.sort
.
product xs ys
is the Cartesian product of the sequences xs
and ys
.
For every element x
of xs
and for every element y
of ys
, the pair (x, y)
appears once as an element of product xs ys
.
The order in which the pairs appear is unspecified.
The sequences xs
and ys
are not required to be finite.
The sequences xs
and ys
must be persistent.
The sequence map_product f xs ys
is the image through f
of the Cartesian product of the sequences xs
and ys
.
For every element x
of xs
and for every element y
of ys
, the element f x y
appears once as an element of map_product f xs ys
.
The order in which these elements appear is unspecified.
The sequences xs
and ys
are not required to be finite.
The sequences xs
and ys
must be persistent.
map_product f xs ys
is equivalent to map (fun (x, y) -> f x y) (product xs ys)
.
unzip
transforms a sequence of pairs into a pair of sequences.
unzip xs
is equivalent to (map fst xs, map snd xs)
.
Querying either of the sequences returned by unzip xs
causes xs
to be queried. Therefore, querying both of them causes xs
to be queried twice. Thus, xs
must be persistent and cheap. If that is not the case, use unzip (memoize xs)
.
partition_map f xs
returns a pair of sequences (ys, zs)
, where:
ys
is the sequence of the elements y
such that f x = Left y
, where x
ranges over xs
;
zs
is the sequence of the elements z
such that f x = Right z
, where x
ranges over xs
.
partition_map f xs
is equivalent to a pair of filter_map Either.find_left (map f xs)
and filter_map Either.find_right (map f xs)
.
Querying either of the sequences returned by partition_map f xs
causes xs
to be queried. Therefore, querying both of them causes xs
to be queried twice. Thus, xs
must be persistent and cheap. If that is not the case, use partition_map f (memoize xs)
.
partition p xs
returns a pair of the subsequence of the elements of xs
that satisfy p
and the subsequence of the elements of xs
that do not satisfy p
.
partition p xs
is equivalent to filter p xs, filter (fun x -> not (p x)) xs
.
Consuming both of the sequences returned by partition p xs
causes xs
to be consumed twice and causes the function f
to be applied twice to each element of the list. Therefore, f
should be pure and cheap. Furthermore, xs
should be persistent and cheap. If that is not the case, use partition p (memoize xs)
.
val of_dispenser : (unit -> 'a option) -> 'a t
of_dispenser it
is the sequence of the elements produced by the dispenser it
. It is an ephemeral sequence: it can be consumed at most once. If a persistent sequence is needed, use memoize (of_dispenser it)
.
val ints : int -> int t
ints i
is the infinite sequence of the integers beginning at i
and counting up.
The sequence once xs
has the same elements as the sequence xs
.
Regardless of whether xs
is ephemeral or persistent, once xs
is an ephemeral sequence: it can be queried at most once. If it (or a suffix of it) is queried more than once, then the exception Forced_twice
is raised. This can be useful, while debugging or testing, to ensure that a sequence is consumed at most once.
This exception is raised when a sequence returned by once
(or a suffix of it) is queried more than once.
val to_dispenser : 'a t -> unit -> 'a option
to_dispenser xs
is a fresh dispenser on the sequence xs
.
This dispenser has mutable internal state, which is not protected by a lock; so, it must not be used by several threads concurrently.
+Seq (less-power.Stdlib_alerts.Stdlib_alerting.Seq) Module Stdlib_alerting.Seq
type 'a t = unit -> 'a node
include sig ... end
val is_empty : 'a t -> bool
is_empty xs
determines whether the sequence xs
is empty.
It is recommended that the sequence xs
be persistent. Indeed, is_empty xs
demands the head of the sequence xs
, so, if xs
is ephemeral, it may be the case that xs
cannot be used any more after this call has taken place.
If xs
is empty, then uncons xs
is None
.
If xs
is nonempty, then uncons xs
is Some (x, ys)
where x
is the head of the sequence and ys
its tail.
val length : 'a t -> int
length xs
is the length of the sequence xs
.
The sequence xs
must be finite.
val iter : ('a -> unit) -> 'a t -> unit
iter f xs
invokes f x
successively for every element x
of the sequence xs
, from left to right.
It terminates only if the sequence xs
is finite.
val fold_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc
fold_left f _ xs
invokes f _ x
successively for every element x
of the sequence xs
, from left to right.
An accumulator of type 'a
is threaded through the calls to f
.
It terminates only if the sequence xs
is finite.
val iteri : (int -> 'a -> unit) -> 'a t -> unit
iteri f xs
invokes f i x
successively for every element x
located at index i
in the sequence xs
.
It terminates only if the sequence xs
is finite.
iteri f xs
is equivalent to iter (fun (i, x) -> f i x) (zip (ints 0) xs)
.
val fold_lefti : ('acc -> int -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc
fold_lefti f _ xs
invokes f _ i x
successively for every element x
located at index i
of the sequence xs
.
An accumulator of type 'b
is threaded through the calls to f
.
It terminates only if the sequence xs
is finite.
fold_lefti f accu xs
is equivalent to fold_left (fun accu (i, x) -> f accu i x) accu (zip (ints 0) xs)
.
val for_all : ('a -> bool) -> 'a t -> bool
for_all p xs
determines whether all elements x
of the sequence xs
satisfy p x
.
The sequence xs
must be finite.
val exists : ('a -> bool) -> 'a t -> bool
exists xs p
determines whether at least one element x
of the sequence xs
satisfies p x
.
The sequence xs
must be finite.
val find : ('a -> bool) -> 'a t -> 'a option
find p xs
returns Some x
, where x
is the first element of the sequence xs
that satisfies p x
, if there is such an element.
It returns None
if there is no such element.
The sequence xs
must be finite.
val find_index : ('a -> bool) -> 'a t -> int option
find_index p xs
returns Some i
, where i
is the index of the first element of the sequence xs
that satisfies p x
, if there is such an element.
It returns None
if there is no such element.
The sequence xs
must be finite.
val find_map : ('a -> 'b option) -> 'a t -> 'b option
find_map f xs
returns Some y
, where x
is the first element of the sequence xs
such that f x = Some _
, if there is such an element, and where y
is defined by f x = Some y
.
It returns None
if there is no such element.
The sequence xs
must be finite.
val find_mapi : (int -> 'a -> 'b option) -> 'a t -> 'b option
Same as find_map
, but the predicate is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
The sequence xs
must be finite.
iter2 f xs ys
invokes f x y
successively for every pair (x, y)
of elements drawn synchronously from the sequences xs
and ys
.
If the sequences xs
and ys
have different lengths, then iteration stops as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
Iteration terminates only if at least one of the sequences xs
and ys
is finite.
iter2 f xs ys
is equivalent to iter (fun (x, y) -> f x y) (zip xs ys)
.
fold_left2 f _ xs ys
invokes f _ x y
successively for every pair (x, y)
of elements drawn synchronously from the sequences xs
and ys
.
An accumulator of type 'a
is threaded through the calls to f
.
If the sequences xs
and ys
have different lengths, then iteration stops as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
Iteration terminates only if at least one of the sequences xs
and ys
is finite.
fold_left2 f accu xs ys
is equivalent to fold_left (fun accu (x, y) -> f accu x y) (zip xs ys)
.
for_all2 p xs ys
determines whether all pairs (x, y)
of elements drawn synchronously from the sequences xs
and ys
satisfy p x y
.
If the sequences xs
and ys
have different lengths, then iteration stops as soon as one sequence is exhausted; the excess elements in the other sequence are ignored. In particular, if xs
or ys
is empty, then for_all2 p xs ys
is true. This is where for_all2
and equal
differ: equal eq xs ys
can be true only if xs
and ys
have the same length.
At least one of the sequences xs
and ys
must be finite.
for_all2 p xs ys
is equivalent to for_all (fun b -> b) (map2 p xs ys)
.
exists2 p xs ys
determines whether some pair (x, y)
of elements drawn synchronously from the sequences xs
and ys
satisfies p x y
.
If the sequences xs
and ys
have different lengths, then iteration must stop as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
At least one of the sequences xs
and ys
must be finite.
exists2 p xs ys
is equivalent to exists (fun b -> b) (map2 p xs ys)
.
Provided the function eq
defines an equality on elements, equal eq xs ys
determines whether the sequences xs
and ys
are pointwise equal.
At least one of the sequences xs
and ys
must be finite.
Provided the function cmp
defines a preorder on elements, compare cmp xs ys
compares the sequences xs
and ys
according to the lexicographic preorder.
For more details on comparison functions, see Array.sort
.
At least one of the sequences xs
and ys
must be finite.
val empty : 'a t
empty
is the empty sequence. It has no elements. Its length is 0.
val return : 'a -> 'a t
return x
is the sequence whose sole element is x
. Its length is 1.
cons x xs
is the sequence that begins with the element x
, followed with the sequence xs
.
Writing cons (f()) xs
causes the function call f()
to take place immediately. For this call to be delayed until the sequence is queried, one must instead write (fun () -> Cons(f(), xs))
.
val init : int -> (int -> 'a) -> 'a t
init n f
is the sequence f 0; f 1; ...; f (n-1)
.
n
must be nonnegative.
If desired, the infinite sequence f 0; f 1; ...
can be defined as map f (ints 0)
.
val unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t
unfold
constructs a sequence out of a step function and an initial state.
If f u
is None
then unfold f u
is the empty sequence. If f u
is Some (x, u')
then unfold f u
is the nonempty sequence cons x (unfold f u')
.
For example, unfold (function [] -> None | h :: t -> Some (h, t)) l
is equivalent to List.to_seq l
.
val repeat : 'a -> 'a t
repeat x
is the infinite sequence where the element x
is repeated indefinitely.
repeat x
is equivalent to cycle (return x)
.
val forever : (unit -> 'a) -> 'a t
forever f
is an infinite sequence where every element is produced (on demand) by the function call f()
.
For instance, forever Random.bool
is an infinite sequence of random bits.
forever f
is equivalent to map f (repeat ())
.
cycle xs
is the infinite sequence that consists of an infinite number of repetitions of the sequence xs
.
If xs
is an empty sequence, then cycle xs
is empty as well.
Consuming (a prefix of) the sequence cycle xs
once can cause the sequence xs
to be consumed more than once. Therefore, xs
must be persistent.
val iterate : ('a -> 'a) -> 'a -> 'a t
iterate f x
is the infinite sequence whose elements are x
, f x
, f (f x)
, and so on.
In other words, it is the orbit of the function f
, starting at x
.
map f xs
is the image of the sequence xs
through the transformation f
.
If xs
is the sequence x0; x1; ...
then map f xs
is the sequence f x0; f x1; ...
.
mapi
is analogous to map
, but applies the function f
to an index and an element.
mapi f xs
is equivalent to map2 f (ints 0) xs
.
filter p xs
is the sequence of the elements x
of xs
that satisfy p x
.
In other words, filter p xs
is the sequence xs
, deprived of the elements x
such that p x
is false.
filter_map f xs
is the sequence of the elements y
such that f x = Some y
, where x
ranges over xs
.
filter_map f xs
is equivalent to map Option.get (filter Option.is_some (map f xs))
.
If xs
is a sequence [x0; x1; x2; ...]
, then scan f a0 xs
is a sequence of accumulators [a0; a1; a2; ...]
where a1
is f a0 x0
, a2
is f a1 x1
, and so on.
Thus, scan f a0 xs
is conceptually related to fold_left f a0 xs
. However, instead of performing an eager iteration and immediately returning the final accumulator, it returns a sequence of accumulators.
For instance, scan (+) 0
transforms a sequence of integers into the sequence of its partial sums.
If xs
has length n
then scan f a0 xs
has length n+1
.
take n xs
is the sequence of the first n
elements of xs
.
If xs
has fewer than n
elements, then take n xs
is equivalent to xs
.
n
must be nonnegative.
drop n xs
is the sequence xs
, deprived of its first n
elements.
If xs
has fewer than n
elements, then drop n xs
is empty.
n
must be nonnegative.
drop
is lazy: the first n+1
elements of the sequence xs
are demanded only when the first element of drop n xs
is demanded. For this reason, drop 1 xs
is not equivalent to tail xs
, which queries xs
immediately.
take_while p xs
is the longest prefix of the sequence xs
where every element x
satisfies p x
.
drop_while p xs
is the sequence xs
, deprived of the prefix take_while p xs
.
Provided the function eq
defines an equality on elements, group eq xs
is the sequence of the maximal runs of adjacent duplicate elements of the sequence xs
.
Every element of group eq xs
is a nonempty sequence of equal elements.
The concatenation concat (group eq xs)
is equal to xs
.
Consuming group eq xs
, and consuming the sequences that it contains, can cause xs
to be consumed more than once. Therefore, xs
must be persistent.
The sequence memoize xs
has the same elements as the sequence xs
.
Regardless of whether xs
is ephemeral or persistent, memoize xs
is persistent: even if it is queried several times, xs
is queried at most once.
The construction of the sequence memoize xs
internally relies on suspensions provided by the module Lazy
. These suspensions are not thread-safe. Therefore, the sequence memoize xs
must not be queried by multiple threads concurrently.
If xss
is a matrix (a sequence of rows), then transpose xss
is the sequence of the columns of the matrix xss
.
The rows of the matrix xss
are not required to have the same length.
The matrix xss
is not required to be finite (in either direction).
The matrix xss
must be persistent.
append xs ys
is the concatenation of the sequences xs
and ys
.
Its elements are the elements of xs
, followed by the elements of ys
.
If xss
is a sequence of sequences, then concat xss
is its concatenation.
If xss
is the sequence xs0; xs1; ...
then concat xss
is the sequence xs0 @ xs1 @ ...
.
concat_map f xs
is equivalent to concat (map f xs)
.
concat_map
is an alias for flat_map
.
zip xs ys
is the sequence of pairs (x, y)
drawn synchronously from the sequences xs
and ys
.
If the sequences xs
and ys
have different lengths, then the sequence ends as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
zip xs ys
is equivalent to map2 (fun a b -> (a, b)) xs ys
.
map2 f xs ys
is the sequence of the elements f x y
, where the pairs (x, y)
are drawn synchronously from the sequences xs
and ys
.
If the sequences xs
and ys
have different lengths, then the sequence ends as soon as one sequence is exhausted; the excess elements in the other sequence are ignored.
map2 f xs ys
is equivalent to map (fun (x, y) -> f x y) (zip xs ys)
.
interleave xs ys
is the sequence that begins with the first element of xs
, continues with the first element of ys
, and so on.
When one of the sequences xs
and ys
is exhausted, interleave xs ys
continues with the rest of the other sequence.
If the sequences xs
and ys
are sorted according to the total preorder cmp
, then sorted_merge cmp xs ys
is the sorted sequence obtained by merging the sequences xs
and ys
.
For more details on comparison functions, see Array.sort
.
product xs ys
is the Cartesian product of the sequences xs
and ys
.
For every element x
of xs
and for every element y
of ys
, the pair (x, y)
appears once as an element of product xs ys
.
The order in which the pairs appear is unspecified.
The sequences xs
and ys
are not required to be finite.
The sequences xs
and ys
must be persistent.
The sequence map_product f xs ys
is the image through f
of the Cartesian product of the sequences xs
and ys
.
For every element x
of xs
and for every element y
of ys
, the element f x y
appears once as an element of map_product f xs ys
.
The order in which these elements appear is unspecified.
The sequences xs
and ys
are not required to be finite.
The sequences xs
and ys
must be persistent.
map_product f xs ys
is equivalent to map (fun (x, y) -> f x y) (product xs ys)
.
unzip
transforms a sequence of pairs into a pair of sequences.
unzip xs
is equivalent to (map fst xs, map snd xs)
.
Querying either of the sequences returned by unzip xs
causes xs
to be queried. Therefore, querying both of them causes xs
to be queried twice. Thus, xs
must be persistent and cheap. If that is not the case, use unzip (memoize xs)
.
partition_map f xs
returns a pair of sequences (ys, zs)
, where:
ys
is the sequence of the elements y
such that f x = Left y
, where x
ranges over xs
;
zs
is the sequence of the elements z
such that f x = Right z
, where x
ranges over xs
.
partition_map f xs
is equivalent to a pair of filter_map Either.find_left (map f xs)
and filter_map Either.find_right (map f xs)
.
Querying either of the sequences returned by partition_map f xs
causes xs
to be queried. Therefore, querying both of them causes xs
to be queried twice. Thus, xs
must be persistent and cheap. If that is not the case, use partition_map f (memoize xs)
.
partition p xs
returns a pair of the subsequence of the elements of xs
that satisfy p
and the subsequence of the elements of xs
that do not satisfy p
.
partition p xs
is equivalent to filter p xs, filter (fun x -> not (p x)) xs
.
Consuming both of the sequences returned by partition p xs
causes xs
to be consumed twice and causes the function f
to be applied twice to each element of the list. Therefore, f
should be pure and cheap. Furthermore, xs
should be persistent and cheap. If that is not the case, use partition p (memoize xs)
.
val of_dispenser : (unit -> 'a option) -> 'a t
of_dispenser it
is the sequence of the elements produced by the dispenser it
. It is an ephemeral sequence: it can be consumed at most once. If a persistent sequence is needed, use memoize (of_dispenser it)
.
val ints : int -> int t
ints i
is the infinite sequence of the integers beginning at i
and counting up.
The sequence once xs
has the same elements as the sequence xs
.
Regardless of whether xs
is ephemeral or persistent, once xs
is an ephemeral sequence: it can be queried at most once. If it (or a suffix of it) is queried more than once, then the exception Forced_twice
is raised. This can be useful, while debugging or testing, to ensure that a sequence is consumed at most once.
This exception is raised when a sequence returned by once
(or a suffix of it) is queried more than once.
val to_dispenser : 'a t -> unit -> 'a option
to_dispenser xs
is a fresh dispenser on the sequence xs
.
This dispenser has mutable internal state, which is not protected by a lock; so, it must not be used by several threads concurrently.
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/StdLabels/List/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/StdLabels/List/index.html
index 31b142d..0675566 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/StdLabels/List/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/StdLabels/List/index.html
@@ -1,5 +1,5 @@
-List (less-power.Stdlib_alerts.Stdlib_alerting.StdLabels.List) Module StdLabels.List
include sig ... end
Compare the lengths of two lists. compare_lengths l1 l2
is equivalent to compare (length l1) (length l2)
, except that the computation stops after reaching the end of the shortest list.
Compare the length of a list to an integer. compare_length_with l len
is equivalent to compare (length l) len
, except that the computation stops after at most len
iterations on the list.
is_empty l
is true if and only if l
has no elements. It is equivalent to compare_length_with l 0 = 0
.
Return the n
-th element of the given list. The first element (head of the list) is at position 0.
Return the n
-th element of the given list. The first element (head of the list) is at position 0. Return None
if the list is too short.
init ~len ~f
is [f 0; f 1; ...; f (len-1)]
, evaluated left to right.
append l0 l1
appends l1
to l0
. Same function as the infix operator @
.
rev_append l1 l2
reverses l1
and concatenates it with l2
. This is equivalent to (
rev
l1) @ l2
.
Concatenate a list of lists. The elements of the argument are all concatenated together (in the same order) to give the result. Not tail-recursive (length of the argument + length of the longest sub-list).
Same as concat
. Not tail-recursive (length of the argument + length of the longest sub-list).
equal eq [a1; ...; an] [b1; ..; bm]
holds when the two input lists have the same length, and for each pair of elements ai
, bi
at the same position we have eq ai bi
.
Note: the eq
function may be called even if the lists have different length. If you know your equality function is costly, you may want to check compare_lengths
first.
compare cmp [a1; ...; an] [b1; ...; bm]
performs a lexicographic comparison of the two input lists, using the same 'a -> 'a -> int
interface as Stdlib.compare
:
a1 :: l1
is smaller than a2 :: l2
(negative result) if a1
is smaller than a2
, or if they are equal (0 result) and l1
is smaller than l2
- the empty list
[]
is strictly smaller than non-empty lists
Note: the cmp
function will be called even if the lists have different lengths.
iter ~f [a1; ...; an]
applies function f
in turn to [a1; ...; an]
. It is equivalent to f a1; f a2; ...; f an
.
Same as iter
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
map ~f [a1; ...; an]
applies function f
to a1, ..., an
, and builds the list [f a1; ...; f an]
with the results returned by f
.
Same as map
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
filter_map ~f l
applies f
to every element of l
, filters out the None
elements and returns the list of the arguments of the Some
elements.
val fold_left_map :
+List (less-power.Stdlib_alerts.Stdlib_alerting.StdLabels.List) Module StdLabels.List
include sig ... end
Compare the lengths of two lists. compare_lengths l1 l2
is equivalent to compare (length l1) (length l2)
, except that the computation stops after reaching the end of the shortest list.
Compare the length of a list to an integer. compare_length_with l len
is equivalent to compare (length l) len
, except that the computation stops after at most len
iterations on the list.
is_empty l
is true if and only if l
has no elements. It is equivalent to compare_length_with l 0 = 0
.
Return the n
-th element of the given list. The first element (head of the list) is at position 0.
Return the n
-th element of the given list. The first element (head of the list) is at position 0. Return None
if the list is too short.
init ~len ~f
is [f 0; f 1; ...; f (len-1)]
, evaluated left to right.
append l0 l1
appends l1
to l0
. Same function as the infix operator @
.
rev_append l1 l2
reverses l1
and concatenates it with l2
. This is equivalent to (
rev
l1) @ l2
.
Concatenate a list of lists. The elements of the argument are all concatenated together (in the same order) to give the result. Not tail-recursive (length of the argument + length of the longest sub-list).
Same as concat
. Not tail-recursive (length of the argument + length of the longest sub-list).
equal eq [a1; ...; an] [b1; ..; bm]
holds when the two input lists have the same length, and for each pair of elements ai
, bi
at the same position we have eq ai bi
.
Note: the eq
function may be called even if the lists have different length. If you know your equality function is costly, you may want to check compare_lengths
first.
compare cmp [a1; ...; an] [b1; ...; bm]
performs a lexicographic comparison of the two input lists, using the same 'a -> 'a -> int
interface as Stdlib.compare
:
a1 :: l1
is smaller than a2 :: l2
(negative result) if a1
is smaller than a2
, or if they are equal (0 result) and l1
is smaller than l2
- the empty list
[]
is strictly smaller than non-empty lists
Note: the cmp
function will be called even if the lists have different lengths.
iter ~f [a1; ...; an]
applies function f
in turn to [a1; ...; an]
. It is equivalent to f a1; f a2; ...; f an
.
Same as iter
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
map ~f [a1; ...; an]
applies function f
to a1, ..., an
, and builds the list [f a1; ...; f an]
with the results returned by f
.
Same as map
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
filter_map ~f l
applies f
to every element of l
, filters out the None
elements and returns the list of the arguments of the Some
elements.
val fold_left_map :
f:('acc -> 'a -> 'acc * 'b) ->
init:'acc ->
'a list ->
diff --git a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/StdLabels/String/index.html b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/StdLabels/String/index.html
index d201730..8d3c493 100644
--- a/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/StdLabels/String/index.html
+++ b/sig-builder-no-typ-dup/less-power/Stdlib_alerts/Stdlib_alerting/StdLabels/String/index.html
@@ -1,5 +1,5 @@
-String (less-power.Stdlib_alerts.Stdlib_alerting.StdLabels.String) Module StdLabels.String
include sig ... end
make n c
is a string of length n
with each index holding the character c
.
init n ~f
is a string of length n
with index i
holding the character f i
(called in increasing index order).
get s i
is the character at index i
in s
. This is the same as writing s.[i]
.
concat ~sep ss
concatenates the list of strings ss
, inserting the separator string sep
between each.
compare s0 s1
sorts s0
and s1
in lexicographical order. compare
behaves like Stdlib.compare
on strings but may be more efficient.
starts_with
~prefix s
is true
if and only if s
starts with prefix
.
ends_with
~suffix s
is true
if and only if s
ends with suffix
.
contains_from s start c
is true
if and only if c
appears in s
after position start
.
rcontains_from s stop c
is true
if and only if c
appears in s
before position stop+1
.
contains s c
is String.contains_from
s 0 c
.
sub s ~pos ~len
is a string of length len
, containing the substring of s
that starts at position pos
and has length len
.
split_on_char ~sep s
is the list of all (possibly empty) substrings of s
that are delimited by the character sep
.
The function's result is specified by the following invariants:
- The list is not empty.
- Concatenating its elements using
sep
as a separator returns a string equal to the input (concat (make 1 sep)
+String (less-power.Stdlib_alerts.Stdlib_alerting.StdLabels.String) Module