module Common:sig..end
exception Bug of string
exception Finally of exn * exn
val unimplemented : string -> 'a Or_error.ttypedecimal =float
decimal type alias provides more readable serializations to s-expressions, at
the cost of lower precision. For example:
# sexp_of_decimal 3.000000000001;;
- : Sexp.t = 3
# sexp_of_float 3.000000000001;;
- : Sexp.t = 3.0000000000010000889
Also, the decimal sexp-converter will fail when provided with nan or infinity.
# float_of_sexp (Sexp.Atom "nan");;
- : float = nan
# decimal_of_sexp (Sexp.Atom "nan");;
Exception:
(Sexplib.Conv.Of_sexp_error (Failure common.ml.Decimal_nan_or_inf) nan).
type passfail =
| |
Pass |
| |
Fail of |
type read_only
typeimmutable = privateread_only
typeread_write = privateread_only
typenever_returns =Never_returns.never_returns
never_returns should be used as the return type of functions that don't return and
might block forever, rather than 'a or _. This forces callers of such functions
to have a call to never_returns at the call site, which makes it clear to readers
what's going on. We do not intend to use this type for functions such as failwithf
that always raise an exception.val never_returns : never_returns -> 'aval protect : f:(unit -> 'a) -> finally:(unit -> unit) -> 'aval protectx : f:('b -> 'a) -> 'b -> finally:('b -> unit) -> 'aval fst3 : 'a * 'b * 'c -> 'aval snd3 : 'b * 'a * 'c -> 'aval trd3 : 'b * 'c * 'a -> 'aval uw : 'a option -> 'aval is_none : 'a option -> boolval is_some : 'a option -> boolval (|!) : 'a -> ('a -> 'b) -> 'bval (|>) : 'a -> ('a -> 'b) -> 'bval ident : 'a -> 'aval const : 'a -> 'b -> 'aval (==>) : bool -> bool -> boolval (^/) : string -> string -> stringFilename.concatval failwiths : string -> 'a -> ('a -> Sexplib.Sexp.t) -> 'bval failwithf : ('r, unit, string, unit -> 'a) Pervasives.format4 -> 'rval invalid_argf : ('r, unit, string, unit -> 'a) Pervasives.format4 -> 'rval ok_exn : 'a Or_error.t -> 'aOr_error.ok_exnval error : string -> 'a -> ('a -> Sexplib.Sexp.t) -> 'b Or_error.tOr_error.errortype 'a return = private {
|
return : |
with_return f allows for something like the return statement in C within f. There
are three ways f can terminate:
1. If f calls r.return x, then x is returned by with_return.
2. If f evaluates to a value x, then x is returned by with_return.
3. If f raises an exception, it escapes with_return.
Here is a typical example:
let find l ~f =
with_return (fun r ->
List.iter l ~f:(fun x -> if f x then r.return (Some x));
None
)
It is only because of a deficiency of ML types that with_return doesn't have type:
val with_return : 'a. (('a -> ('b. 'b)) -> 'a) -> 'a
but we can slightly increase the scope of 'b, without changing the meaning of the type and then we get
type 'a return = { return : 'b . 'a -> b }
val with_return : ('a return -> 'a) -> 'a
But the actual reason we chose to use a record type with polymorphic field is that
otherwise we would have to clobber the namespace of functions with return and that is
undesirable because return would get hidden as soon as we open any monad. We
considered names different than return but everything seemed worse than just having
return as a record field. We are clobbering the namespace of record fields but that
is much more acceptable.
val with_return : ('a return -> 'a) -> 'aval phys_equal : 'a -> 'a -> bool== and != and replace them with the longer and more mnemonic
phys_equal because they too easily lead to mistakes (for example they don't even
work right on Int64 or Float). One can usually use the equal function for a
specific type, or use (=) or (<>) for built in types like char, int, float,val (==) : [ `Consider_using_phys_equal ] ->
[ `Consider_using_phys_equal ] -> [ `Consider_using_phys_equal ]val (!=) : [ `Consider_using_phys_equal ] ->
[ `Consider_using_phys_equal ] -> [ `Consider_using_phys_equal ]val force : 'a Lazy.t -> 'aval stage : 'a -> 'a Staged.tmodule : Staged for documentationval unstage : 'a Staged.t -> 'aexception C_malloc_exn of int * int
The following section contains definitions that hide operations from the standard
library that are considered problematic or confusing, or simply redundant.
val seek_out : [ `Deprecated_use_out_channel ] ->
[ `Deprecated_use_out_channel ] -> [ `Deprecated_use_out_channel ]val pos_out : [ `Deprecated_use_out_channel ] -> [ `Deprecated_use_out_channel ]val out_channel_length : [ `Deprecated_use_out_channel ] -> [ `Deprecated_use_out_channel ]val seek_in : [ `Deprecated_use_in_channel ] ->
[ `Deprecated_use_in_channel ] -> [ `Deprecated_use_in_channel ]val pos_in : [ `Deprecated_use_in_channel ] -> [ `Deprecated_use_in_channel ]val in_channel_length : [ `Deprecated_use_in_channel ] -> [ `Deprecated_use_in_channel ]val modf : [ `Deprecated_use_float_modf ] -> [ `Deprecated_use_float_modf ]val truncate : [ `Deprecated_use_float_iround_towards_zero ] ->
[ `Deprecated_use_float_iround_towards_zero ]val close_in : [ `Deprecated_use_in_channel ] -> [ `Deprecated_use_in_channel ]val close_out : [ `Deprecated_use_out_channel ] -> [ `Deprecated_use_out_channel ]val (&) : [ `Deprecated_use_two_ampersands ] ->
[ `Deprecated_use_two_ampersands ] -> [ `Deprecated_use_two_ampersands ]val max_int : [ `Deprecated_use_int_module ]val min_int : [ `Deprecated_use_int_module ]val ceil : [ `Deprecated_use__Float__round_up ] -> [ `Deprecated_use__Float__round_up ]val floor : [ `Deprecated_use__Float__round_down ] ->
[ `Deprecated_use__Float__round_down ]val abs_float : [ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]val mod_float : [ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]val frexp : [ `Deprecated_use_float_module ] ->
[ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]val ldexp : [ `Deprecated_use_float_module ] ->
[ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]val float_of_int : [ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]val max_float : [ `Deprecated_use_float_module ]val min_float : [ `Deprecated_use_float_module ]val epsilon_float : [ `Deprecated_use_float_module ]val classify_float : [ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]val string_of_float : [ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]val float_of_string : [ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]val infinity : [ `Deprecated_use_float_module ]val neg_infinity : [ `Deprecated_use_float_module ]val nan : [ `Deprecated_use_float_module ]val int_of_float : [ `Deprecated_use_float_module ] -> [ `Deprecated_use_float_module ]typefpclass =[ `Deprecated_use_float_module ]
val compare_decimal : decimal -> decimal -> intval decimal_of_sexp : Sexplib.Sexp.t -> decimalval sexp_of_decimal : decimal -> Sexplib.Sexp.tval bin_decimal : decimal Bin_prot.Type_class.tval bin_read_decimal : decimal Bin_prot.Read_ml.readerval bin_read_decimal_ : decimal Bin_prot.Unsafe_read_c.readerval bin_read_decimal__ : (int -> decimal) Bin_prot.Unsafe_read_c.readerval bin_reader_decimal : decimal Bin_prot.Type_class.readerval bin_size_decimal : decimal Bin_prot.Size.sizerval bin_write_decimal : decimal Bin_prot.Write_ml.writerval bin_write_decimal_ : decimal Bin_prot.Unsafe_write_c.writerval bin_writer_decimal : decimal Bin_prot.Type_class.writerval compare_read_only : read_only -> read_only -> intval bin_read_only : read_only Bin_prot.Type_class.tval bin_read_read_only : read_only Bin_prot.Read_ml.readerval bin_read_read_only_ : read_only Bin_prot.Unsafe_read_c.readerval bin_read_read_only__ : (int -> read_only) Bin_prot.Unsafe_read_c.readerval bin_reader_read_only : read_only Bin_prot.Type_class.readerval bin_size_read_only : read_only Bin_prot.Size.sizerval bin_write_read_only : read_only Bin_prot.Write_ml.writerval bin_write_read_only_ : read_only Bin_prot.Unsafe_write_c.writerval bin_writer_read_only : read_only Bin_prot.Type_class.writerval read_only_of_sexp : Sexplib.Sexp.t -> read_onlyval sexp_of_read_only : read_only -> Sexplib.Sexp.tval compare_immutable : immutable -> immutable -> intval bin_immutable : immutable Bin_prot.Type_class.tval bin_read_immutable : immutable Bin_prot.Read_ml.readerval bin_read_immutable_ : immutable Bin_prot.Unsafe_read_c.readerval bin_read_immutable__ : (int -> immutable) Bin_prot.Unsafe_read_c.readerval bin_reader_immutable : immutable Bin_prot.Type_class.readerval bin_size_immutable : immutable Bin_prot.Size.sizerval bin_write_immutable : immutable Bin_prot.Write_ml.writerval bin_write_immutable_ : immutable Bin_prot.Unsafe_write_c.writerval bin_writer_immutable : immutable Bin_prot.Type_class.writerval immutable_of_sexp : Sexplib.Sexp.t -> immutableval sexp_of_immutable : immutable -> Sexplib.Sexp.tval compare_read_write : read_write -> read_write -> intval bin_read_write : read_write Bin_prot.Type_class.tval bin_read_read_write : read_write Bin_prot.Read_ml.readerval bin_read_read_write_ : read_write Bin_prot.Unsafe_read_c.readerval bin_read_read_write__ : (int -> read_write) Bin_prot.Unsafe_read_c.readerval bin_reader_read_write : read_write Bin_prot.Type_class.readerval bin_size_read_write : read_write Bin_prot.Size.sizerval bin_write_read_write : read_write Bin_prot.Write_ml.writerval bin_write_read_write_ : read_write Bin_prot.Unsafe_write_c.writerval bin_writer_read_write : read_write Bin_prot.Type_class.writerval read_write_of_sexp : Sexplib.Sexp.t -> read_writeval sexp_of_read_write : read_write -> Sexplib.Sexp.tval sexp_of_never_returns : never_returns -> Sexplib.Sexp.tnever_returns should be used as the return type of functions that don't return and
might block forever, rather than 'a or _. This forces callers of such functions
to have a call to never_returns at the call site, which makes it clear to readers
what's going on. We do not intend to use this type for functions such as failwithf
that always raise an exception.Filename.concatOr_error.ok_exnOr_error.errorwith_return f allows for something like the return statement in C within f. There
are three ways f can terminate:
1. If f calls r.return x, then x is returned by with_return.
2. If f evaluates to a value x, then x is returned by with_return.
3. If f raises an exception, it escapes with_return.
Here is a typical example:
let find l ~f =
with_return (fun r ->
List.iter l ~f:(fun x -> if f x then r.return (Some x));
None
)
It is only because of a deficiency of ML types that with_return doesn't have type:
val with_return : 'a. (('a -> ('b. 'b)) -> 'a) -> 'a
but we can slightly increase the scope of 'b, without changing the meaning of the type and then we get
type 'a return = { return : 'b . 'a -> b }
val with_return : ('a return -> 'a) -> 'a
But the actual reason we chose to use a record type with polymorphic field is that
otherwise we would have to clobber the namespace of functions with return and that is
undesirable because return would get hidden as soon as we open any monad. We
considered names different than return but everything seemed worse than just having
return as a record field. We are clobbering the namespace of record fields but that
is much more acceptable.
We disable == and != and replace them with the longer and more mnemonic
phys_equal because they too easily lead to mistakes (for example they don't even
work right on Int64 or Float). One can usually use the equal function for a
specific type, or use (=) or (<>) for built in types like char, int, float,
See module : Staged for documentation
Raised if malloc in C bindings fail (errno * size).
The following section contains definitions that hide operations from the standard
library that are considered problematic or confusing, or simply redundant.
we have our own version of these two, the INRIA version doesn't release the runtime
lock.