package ocaml-base-compiler
val fatal_errorf : ('a, Format.formatter, unit, 'b) Pervasives.format4 -> 'a
val protect_refs : ref_and_value list -> (unit -> 'a) -> 'a
protect_refs l f
temporarily sets r
to v
for each R (r, v)
in l
while executing f
. The previous contents of the references is restored even if f
raises an exception.
module Stdlib : sig ... end
val create_hashtable : int -> ('a * 'b) list -> ('a, 'b) Hashtbl.t
val copy_file : Pervasives.in_channel -> Pervasives.out_channel -> unit
val copy_file_chunk :
Pervasives.in_channel ->
Pervasives.out_channel ->
int ->
unit
val string_of_file : Pervasives.in_channel -> string
val output_to_file_via_temporary :
?mode:Pervasives.open_flag list ->
string ->
(string -> Pervasives.out_channel -> 'a) ->
'a
module Int_literal_converter : sig ... end
val get_ref : 'a list Pervasives.ref -> 'a list
module LongString : sig ... end
edit_distance a b cutoff
computes the edit distance between strings a
and b
. To help efficiency, it uses a cutoff: if the distance d
is smaller than cutoff
, it returns Some d
, else None
.
The distance algorithm currently used is Damerau-Levenshtein: it computes the number of insertion, deletion, substitution of letters, or swapping of adjacent letters to go from one word to the other. The particular algorithm may change in the future.
spellcheck env name
takes a list of names env
that exist in the current environment and an erroneous name
, and returns a list of suggestions taken from env
, that are close enough to name
that it may be a typo for one of them.
val did_you_mean : Format.formatter -> (unit -> string list) -> unit
did_you_mean ppf get_choices
hints that the user may have meant one of the option returned by calling get_choices
. It does nothing if the returned list is empty.
The unit -> ...
thunking is meant to delay any potentially-slow computation (typically computing edit-distance with many things from the current environment) to when the hint message is to be printed. You should print an understandable error message before calling did_you_mean
, so that users get a clear notification of the failure even if producing the hint is slow.
String.cut_at s c
returns a pair containing the sub-string before the first occurrence of c
in s
, and the sub-string after the first occurrence of c
in s
. let (before, after) = String.cut_at s c in
before ^ String.make 1 c ^ after
is the identity if s
contains c
.
Raise Not_found
if the character does not appear in the string
module Color : sig ... end
normalise_eol s
returns a fresh copy of s
with any '\r' characters removed. Intended for pre-processing text which will subsequently be printed on a channel which performs EOL transformations (i.e. Windows)
delete_eol_spaces s
returns a fresh copy of s
with any end of line spaces removed. Intended to normalize the output of the toplevel for tests.
Hook machinery
Hooks machinery: add_hook name f
will register a function that will be called on the argument of a later call to apply_hooks
. Hooks are applied in the lexicographical order of their names.
An exception raised by a hook will be wrapped into a HookExnWrapper
constructor by the hook machinery.
A hook can use raise_unwrapped_hook_exn
to raise an exception that will not be wrapped into a HookExnWrapper
.
module type HookSig = sig ... end