Changes across many modules:
Caml with Stdlib. The Caml module predated Stdlib and has been redundant for some time.Added support for local allocations. This is a nonstandard OCaml extension available at https://github.com/ocaml-flambda/ocaml-jst.
Support includes:
[@local] arguments, especially closuresArray.create_local and Bytes.create_locallocal values, such as Applicative.S_local[@@deriving globalize] on some types, for converting local values to global valuesPolymorphic_compare submodules to Comparisons. The former was a misnomer. While the comparisons for a given type are meant to replace polymorphic compare operators, they are not polymorphic themselves.Container.S_with_creators and Indexed_container.S_with_creators. Used these in container modules such as Array, List, and String. These interfaces standardize functions like map and filter. Along the way, refactored module types in Container and Indexed_container.fold* functions, renamed accumulator type variables to 'acc for improved readability.of_string_opt to Int_intf.S.dequeue_and_ignore_exn to Queue_intf.S.Changes to individual modules:
Bool: added select, a primitive using CMOV on architectures that support it.Comparable:
'a reversed and compare_reversed, to support deriving inverted comparisons, e.g.: [%compare: My_type.t Comparable.reversed]Derived2_phantom, similar to Derived_phantom.Derived*.comparator_witness types injective.Float:
acosh, asinh, and atanh to Float.Float.of_string_opt.Hash_set: Made t injective.Hashtbl:
choose_randomly and choose_randomly_exn.Hashtbl.t injective.Lazy: Added peek, extracting an already-forced value if present.Map:
split_le_gt, split_lt_ge, and transpose_keys.Make_applicative_traversals, allowing some applicatives to improve performance when operating on maps.filter* functions.map_intf.ml. Among other changes, propagated ~comparator argument slightly differently to allow expressing type of transpose_keys properly.Monad: Documented performance characteristics of Ident.Option: Deprecated functions from Container but not particularly useful for options.Ppx_compare_lib: Removed primitive functions; ppx_compare now explicitly refers to these via Stdlib.Sequence: Changed Step.t variant type to use inlined records.Set:
of_tree, to_tree, split_le_gt, and split_lt_ge.'a Named.t type to set_intf.ml, rather than using a new type in every instance of Accessors.Set.t injective in both type arguments.set_intf.ml.Sexpable: Of_stringable now provides t_sexp_grammar.Sign and Sign_or_nan: Added to_string_hum.Stack: added filter, filter_inplace, and filter_map.String: added concat_lines, pad_left, pad_right, and unsafe_subSys: added opaque_identity_global, which forces its argument to be globally allocated.Type_equal: Id.Uid now implements Identifiable.SUniform_array: add sortResult.ok_fst to Result.to_either (old name remains as deprecated alias). Added analogous Result.of_either function.Array.truncate, {Obj_array, Uniform_array}.unsafe_truncate, Result.ok_unit, {Result, Or_error}.ignore.Hashtbl.equal to take the data equality function first, allowing it to be used with [%equal: t].List.dedup.String module.Monad.all_ignore in favor of Monad.all_unit.Or_error.ignore and Result.ignore in favor of Or_error.ignore_m and Result.ignore_m.Ordered_collection_common.get_pos_len now returns an Or_error.tBool.Non_short_circuiting.Float.square.Or_error.Ok.Ref doesn't implement Container.S1 anymore.Sequence.merge from cmp to compare.Info.of_lazy_tList.partition_result function, to partition a list of Result.t valuesequal from 'a t -> 'a t -> equal:('a -> 'a -> bool) -> bool to ('a -> 'a -> bool) -> 'a t -> 'a t -> bool.Lazy.compare to check physical equality before forcing the lazy values.Args in the Applicative interface in favor of using ppx_let.Array.replace arr i ~f in favor of using arr.(i) <- (f (arr.(i)))Ordered_collection_common functions from length to total_length, and add a unit argument to get_pos_len and get_pos_len_exn.Array and Set modules.Int.Hex.of_string and friends no longer silently ignore a suffix of non-hexadecimal garbage.?backtrace argument to Or_error.of_exn_result.List.zip now returns a List.Or_unequal_lengths.t instead of an option.Sequence module that were deprecated in 2015.Container.Make and Container.Make0 now require callers to either provide a custom length function or request that one be derived from fold. Container.to_array's signature is also changed to accept length and iter instead of fold.Int_math.Not_found, people who need it can use Caml.Not_found, but its use isn't recommended.Sexp.Not_found_s exception which will replace Caml.Not_found as the default exception in a future release.Array.find_exn, Array.find_map_exn, and Array.findi_exn may throw Caml.Not_found or Not_found_s.Hashtbl.find_exn may throw Caml.Not_found or Not_found_s.List.find_exn, and List.find_map_exn may throw Caml.Not_found or Not_found_s.List.find_exn may throw Caml.Not_found or Not_found_s.String.lsplit2_exn, and String.rsplit2_exn may throw Caml.Not_found or Not_found_s.Sys.backend_type.Hashtbl.create.Hashtbl.Hashable.t constructors from Hashtbl and Hash_set, instead favoring the first-class module constructors.Container operations from Either.First and Either.Second.fold_until in the Container interfaces. Rather than returning a Finished_or_stopped_early.t (which has also been removed), the function now takes a finish function that will be applied the result if f never returned a Stop _.String_dict module.Queue module that is backed by an Option_array for efficient and (non-allocating) implementations of most operations.Poly submodule to Map and Set that exposes constructors that use polymorphic compare.all_ignore in the Monad and Applicative interfaces in favor of all_unit.Array.replace_all in favor of Array.map_inplace, which is the standard name for that sort of operation within Base.List.find_exn, and List.find_map_exn may throw Caml.Not_found or Not_found_s.~compare a required argument to List.dedup_and_sort, List.dedup, List.find_a_dup, List.contains_dup, and List.find_all_dups.List.exn_if_dup. It is still available in core_kernel.List.slice. It is still available in core_kernel.Array, which incluced Array.normalize, Array.slice, Array.nget and Array.nset. These operations are still available in core_kernel.Uniform_array module that is just like an Array except guarantees that the representation array is not tagged with Double_array_tag, the tag for float arrays.Option_array module that allows for a compact representation of 'a optoin array, which avoids allocating heap objects representing Some a.String, which incluced String.normalize, String.slice, String.nget and String.nset. These operations are still available in core_kernel.Int63 and other integer types, specifically, the versions that return options._trunc. These allow fast conversions via bit arithmetic without any conditional failure; excess bits beyond the width of the output type are simply dropped.Sequence.group, similar to List.group.String.Caseless.compare so that it does not allocate.String.is_substring_at string ~pos ~substring. Used it as back-end for is_suffix and is_prefix.Replace_polymorphic_compare submodules from Base types and consolidated them in one place within Import0.(<=.) and its friends.Sys.argv.Formatter module to reexport the Format.formatter type and updated the deprecation message for Format.(Changes that can break existing programs are marked with a "*")
Printf.ifprintf to reflect OCaml's stdlib.Sequence.fold_m and iter_m respect Skip steps and explicitly bind when they occur.Float.is_negative and is_non_positive on NaN to return false rather than true.Validate.protect function, which was mistakenly raising exceptions.Map.add as set, and deprecated add. A later feature will add add and add_exn in the style of Hashtbl.Base.Int.hash. The old implementation was Int.abs but collision resistance is not enough, we want avalanching as well. The new function is an adaptation of one of the Thomas Wang hash functions to OCaml (63-bit integers), which results in reasonably good avalanching.open Base expose infix float operators (+., -., etc.).List.dedup to List.dedup_and_sort, to better reflect its existing behavior.Hashtbl.find_multi and Map.find_multi.Map.of_increasing_sequence for constructing a Map.t from an ordered Sequence.tList.chunks_of : 'a t -> length : int -> 'a t t, for breaking a list into chunks of equal length.Random numeric functions that take upper and lower inclusive bounds, e.g. Random.int_incl : int -> int -> int.Exn.Never_elide_backtrace with Backtrace.elide, a ref cell that determines whether Backtrace.to_string and Backtrace.sexp_of_t elide backtraces.Base.( @@ ).Base.Continue_or_stop and Finished_or_stopped_early, used with the Container.fold_until function.Sequence.Expert functions next_step and delayed_fold_step, for clients that want to explicitly handle Skip steps.Bytes module. This includes the submodules From_string and To_string with blit functions. N.B. the signature (and name) of unsafe_to_string and unsafe_of_string are different from the one in the standard library (and hopefully more explicit).Buffer. Also added Buffer.content_bytes, the analog of contents but that returns bytes rather than string.-safe-string.Int63.of_int32, which was missing.String mutating functions.Obj_array, moved in from Core_kernel.Hashtbl.Accessors, removed deprecated functions, moving them into a new module type, Deprecated.sexp_* types that are recognized by ppx_sexp_* converters: sexp_array, sexp_list, sexp_opaque, sexp_option.Or_error module's interface, moving the Container.S interface to an Ok submodule, and adding functions is_ok, is_error, and ok to more closely resemble the interface of the Result module.Int.O.of_int_exn.Base.force function.mod to recommend ( % ) rather than Caml.( mod ).List.compare, removing its closure allocation.String.mem to not allocate.Float.is_negative, is_non_negative, is_positive, and is_non_positive to avoid some boxing.Hashtbl.merge to relax its equality check on the input tables' Hashable.t records, checking physical equality componentwise if the records aren't physically equal.Result.combine_errors, similar to Or_error.combine_errors, with a slightly different type.Result.combine_errors_unit, similar to Or_error.combine_errors_unit.With_return.return type by adding the [@@unboxed] attribute.Initial release.