package base
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=11de9f28abbd131d778b5665126ec7e8
sha512=202bec57f9bf846cae1e6a9a51fb82128ff9744959550e1c6645fa02baf8f24225f2a409e820d325d89eb4422eba6f6b4304f9b78b94660283c477749d63ca8f
doc/CHANGES.html
Release v0.17.0
Added functionality:
- Add
String.to_sequence - Derive
equalonSet.Merge_with_duplicates_element.t - Add
Queue.drain - Add
Or_error.of_option - Extend
Hashtbl_intf.Hashtblwithcapacity, intended for testing resizing behavior - Add
Nothing.must_be_*functions discarding (parts of) inputs withNothing.tas a type parameter - Add
Float.log2 - Add
Random.bits64, re-exported fromStdlib.Random - Add
String.edit_distanceto compute Levenshtein distance between strings - Add
Comparator.to_moduleandComparator.of_module, converting betweenComparator.tandComparator.Module.t - Add
Map.sum,unzip,of_list_with_key_fold, andof_list_with_key_reduce - Add
Applicative.Ident, similar toMonad.Ident - Extend
Uniform_arraywith more operations akin toArray - Added
List.singleton - Add
Map.merge_disjoint_exnfor merging two disjoint maps of the same key/value types Raises an exception if there are conflicting keys - Added
Sequence.Expert.Viewto consume sequences more flexibly and efficiently - Add a
Binarysubmodule toInt,Int32, etc, which provideto_stringandsexp_of_twith syntax matching the ocaml binary int literal syntax - Add
List.stable_dedupand deprecateSet.stable_dedup_list - Add
Queue.enqueue_frontandQueue.dequeue_back - Add
Type_equal.Id.Create*functors for polymorphic types
Added unicode support:
- Added
Utf*submodules toBytes,Uchar, andString - Types for
UcharandStringencoding UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF32-BE - Added conversions, read/write functions, etc
Changed behavior:
Infohas improved parsing of DOS newlines and trailing newlines in backtraces
Removed definitions that were previously deprecated:
Type_equal.equaltype alias now that destructive update is availableMap.comparatorandSet.comparatortype aliasesBase.Popcount, as it is exported via the variousInt*modulesOptionfunctions fromContainerthat are not usefulResult.ok_fst, an alias forto_eitherSequence.merge, an alias formerge_deduped_and_sortedInfo.to_string_hum_deprecated?trunc_afterflag toInfo.of_list, no longer used
Deprecated:
Type_equal.Injective, now that injectivity annotations exist
Removed without deprecating:
Type_equal.Id.Uid.to_string,of_string, andt_of_sexp. These were not compatible with the representation changes needed for the newId.Create*functors
Interface changes:
Container.Genericnow supports two "extra" (non-element) type parameters- Abstracted some of
MapintoDictionary_immutableinterfaces - Abstracted some of
HashtblintoDictionary_mutableinterfaces - Export
Set.Poly.settype rather than using destructive update
Bug fixes:
- Indexing was wrong in
Sequence.findi, now fixed and with a regression test
Performance improvements:
- Split up and refactored tests in
Baseto reduce build times - Stop using exceptions for control, primarily to speed up
js_of_ocamlversions. AffectsSequence.compare,String.index,String.rindex,String.index_from,String.rindex_from,Map.change, andMap.remove - Unboxed
Int64.pow - Branchless implementation of
Float.clamp_unchecked,Int.clamp_unchecked - Branchless loop body in
Array.countandArray.counti - Remove allocation in
List.Assoc.find_exn - Reduce allocation of
With_returnunder some compiler configurations - Restore
Array.equalto zero allocation - Avoid boxing in
Int64.to_int_exn,Int64.hash_fold_t,Float.hash_fold_t - Inlining annotation on
Float.sign_exnto avoid boxing - Add
[@cold]annotation toError.raise - Tighten up conditional logic in
Hashtbl.setandHashtbl.remove - Reducing redundant computation in various
Mapfunctions - Rewrite
Array.min_eltandArray.max_eltto reduce branching and allocation - Improve
ppx_hashderived code for enumeration-like variants. - Moved queue mutation check to a function marked
[@cold]. - Rewrite
List.dedup_and_sortwithout a final remove-duplicates pass. - Fix
Infoto avoid blowing up the stack onforceof the internallazy. - Make
List.take,List.drop, andList.splitreturn the original list when possible. (issue 153, thanks@mroch) - Adapted
Listfunctions to take advantage of[@tail_mod_cons]where beneficial. - Use
[@tail_mod_cons]inSequence.to_list
Refactoring:
- Update whitespace styling, primarily by no longer using ocp-indent on code
- Use
Stdlib.Sys.Immediate64inInt63instead of hand-written copy - Properly use loop variable in
List.chunks_ofhelper - Rename internal variable in
Hashtbl.removefor clarity - Lift some of
Int_conversionstoInt_string_conversionsto share elsewhere - Remove unused
[@tailcall]attribute inList.group - Use inlined records in
MapandSetinternal variant representations - Reimplement
Map.Build_increasingto something simpler - Remove unnecessary helper in
Map.remove - Remove unused functions from
String0 - Use inlining instead of duplication for helpers in
Setimplementation - Split out
Ocaml_intrinsics_kernel, used it for some intrinsics inBase
Documentation:
- Fix typo where
Set.union_listdocumented itself asunion - Various grammar and capitalization fixes (PR 145, thanks
@goodship1)
Tests and benchmarks, largely to gain confidence in the changes above:
- Updated allocation expect tests to actually use
let%expect_test(oops) - Updated benchmarks for
Float.clamp*. - Add benchmarks for
Hashtbl.map_inplace,create,remove,set,change, andfind_and_remove - Add benchmarks for
Map.set,remove, andchange - Add
js_of_ocaml-only benchmarks forMap.removeandMap.change - Benchmark
Sequence.compareandString.index - Benchmark
Set.add,find, andfind_map - Tests and benchmarks for
min_elt,max_elt,count, andcountiinArrayandList
Windows:
- Fixed the windows build. (PR 152, thanks
@hhugo)
Work toward compatibility with OCaml 5.1:
- Update
Randomto use new splittable PRNG - Other various changes
Improved support for compiler extensions found at https://github.com/ocaml-flambda/flambda-backend:
- Various updated signatures, definitions, and new functionality to support
local_mode and stack allocation - Added annotations for
[@zero_alloc]compiler checks
Release v0.16.0
Changes across many modules:
- Replaced
CamlwithStdlib. TheCamlmodule predatedStdliband 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:
- updating functions to accept
[@local]arguments, especially closures - local constructors, like
Array.create_localandBytes.create_local - new versions of interfaces supporting
localvalues, such asApplicative.S_local [@@deriving globalize]on some types, for converting local values to global values
- updating functions to accept
- Rename
Polymorphic_comparesubmodules toComparisons. The former was a misnomer. While the comparisons for a given type are meant to replace polymorphic compare operators, they are not polymorphic themselves. - Added
Container.S_with_creatorsandIndexed_container.S_with_creators. Used these in container modules such asArray,List, andString. These interfaces standardize functions likemapandfilter. Along the way, refactored module types inContainerandIndexed_container. - In signatures for
fold*functions, renamed accumulator type variables to'accfor improved readability. - Added
of_string_opttoInt_intf.S. - Added
dequeue_and_ignore_exntoQueue_intf.S.
Changes to individual modules:
Bool: addedselect, a primitive usingCMOVon architectures that support it.Comparable:- Added
'a reversedandcompare_reversed, to support deriving inverted comparisons, e.g.:[%compare: My_type.t Comparable.reversed] - Added
Derived2_phantom, similar toDerived_phantom. - Made
Derived*.comparator_witnesstypes injective.
- Added
Float:- Added hyperbolic trig functions
acosh,asinh, andatanhtoFloat. - Added
Float.of_string_opt.
- Added hyperbolic trig functions
Hash_set: Madetinjective.Hashtbl:- Added
choose_randomlyandchoose_randomly_exn. - Made
Hashtbl.tinjective.
- Added
Lazy: Addedpeek, extracting an already-forced value if present.Map:- Added
split_le_gt,split_lt_ge, andtranspose_keys. - Added
Make_applicative_traversals, allowing some applicatives to improve performance when operating on maps. - Corrected documentation of performance for
filter*functions. - Refactored module types in
map_intf.ml. Among other changes, propagated~comparatorargument slightly differently to allow expressing type oftranspose_keysproperly.
- Added
Monad: Documented performance characteristics ofIdent.Option: Deprecated functions fromContainerbut not particularly useful for options.Ppx_compare_lib: Removed primitive functions;ppx_comparenow explicitly refers to these viaStdlib.Sequence: ChangedStep.tvariant type to use inlined records.Set:- Added
of_tree,to_tree,split_le_gt, andsplit_lt_ge. - Created a single shared
'a Named.ttype toset_intf.ml, rather than using a new type in every instance ofAccessors. - Made
Set.tinjective in both type arguments. - Refactored module types in
set_intf.ml.
- Added
Sexpable:Of_stringablenow providest_sexp_grammar.SignandSign_or_nan: Addedto_string_hum.Stack: addedfilter,filter_inplace, andfilter_map.String: addedconcat_lines,pad_left,pad_right, andunsafe_subSys: addedopaque_identity_global, which forces its argument to be globally allocated.Type_equal:Id.Uidnow implementsIdentifiable.SUniform_array: addsort
Old pre-v0.15 changelogs (very likely stale and incomplete)
git version
- Renamed
Result.ok_fsttoResult.to_either(old name remains as deprecated alias). Added analogousResult.of_eitherfunction. - Removed deprecated values
Array.truncate,{Obj_array, Uniform_array}.unsafe_truncate,Result.ok_unit,{Result, Or_error}.ignore. - Changed the signature of
Hashtbl.equalto take the data equality function first, allowing it to be used with[%equal: t]. - Remove deprecated function
List.dedup. - Remove deprecated string mutation functions from the
Stringmodule. - Removed deprecated function
Monad.all_ignorein favor ofMonad.all_unit. - Deprecated
Or_error.ignoreandResult.ignorein favor ofOr_error.ignore_mandResult.ignore_m. Ordered_collection_common.get_pos_lennow returns anOr_error.t- Added
Bool.Non_short_circuiting. - Added
Float.square. - Remove module
Or_error.Ok. - module
Refdoesn't implementContainer.S1anymore. - Rename parameter of
Sequence.mergefromcmptocompare. - Added
Info.of_lazy_t - Added
List.partition_resultfunction, to partition a list ofResult.tvalues - Changed the signature of
equalfrom'a t -> 'a t -> equal:('a -> 'a -> bool) -> boolto('a -> 'a -> bool) -> 'a t -> 'a t -> bool. - Optimized
Lazy.compareto check physical equality before forcing the lazy values. - Deprecated
Argsin theApplicativeinterface in favor of usingppx_let. - Deprecated
Array.replace arr i ~fin favor of usingarr.(i) <- (f (arr.(i))) - Rename collection length parameter of
Ordered_collection_commonfunctions fromlengthtototal_length, and add a unit argument toget_pos_lenandget_pos_len_exn. - Removed functions that were deprecated in 2016 from the
ArrayandSetmodules. Int.Hex.of_stringand friends no longer silently ignore a suffix of non-hexadecimal garbage.- Added
?backtraceargument toOr_error.of_exn_result. List.zipnow returns aList.Or_unequal_lengths.tinstead of anoption.- Remove functions from the
Sequencemodule that were deprecated in 2015. Container.MakeandContainer.Make0now require callers to either provide a customlengthfunction or request that one be derived fromfold.Container.to_array's signature is also changed to acceptlengthanditerinstead offold.- Exposed module
Int_math.
v0.11
- Deprecated
Not_found, people who need it can useCaml.Not_found, but its use isn't recommended. - Added the
Sexp.Not_found_sexception which will replaceCaml.Not_foundas the default exception in a future release. - Document that
Array.find_exn,Array.find_map_exn, andArray.findi_exnmay throwCaml.Not_foundorNot_found_s. - Document that
Hashtbl.find_exnmay throwCaml.Not_foundorNot_found_s. - Document that
List.find_exn, andList.find_map_exnmay throwCaml.Not_foundorNot_found_s. - Document that
List.find_exnmay throwCaml.Not_foundorNot_found_s. - Document that
String.lsplit2_exn, andString.rsplit2_exnmay throwCaml.Not_foundorNot_found_s. - Added
Sys.backend_type. - Removed unnecessary unit argument from
Hashtbl.create. - Removed deprecated operations from
Hashtbl. - Removed
Hashable.tconstructors fromHashtblandHash_set, instead favoring the first-class module constructors. - Removed
Containeroperations fromEither.FirstandEither.Second. - Changed the type of
fold_untilin theContainerinterfaces. Rather than returning aFinished_or_stopped_early.t(which has also been removed), the function now takes afinishfunction that will be applied the result iffnever returned aStop _. - Removed the
String_dictmodule. - Added a
Queuemodule that is backed by anOption_arrayfor efficient and (non-allocating) implementations of most operations. - Added a
Polysubmodule toMapandSetthat exposes constructors that use polymorphic compare. - Deprecated
all_ignorein theMonadandApplicativeinterfaces in favor ofall_unit. - Deprecated
Array.replace_allin favor ofArray.map_inplace, which is the standard name for that sort of operation within Base. - Document that
List.find_exn, andList.find_map_exnmay throwCaml.Not_foundorNot_found_s. - Make
~comparea required argument toList.dedup_and_sort,List.dedup,List.find_a_dup,List.contains_dup, andList.find_all_dups. - Removed
List.exn_if_dup. It is still available in core_kernel. - Removed "normalized" index operation
List.slice. It is still available in core_kernel. - Remove "normalized" index operations from
Array, which inclucedArray.normalize,Array.slice,Array.ngetandArray.nset. These operations are still available in core_kernel. - Added
Uniform_arraymodule that is just like anArrayexcept guarantees that the representation array is not tagged withDouble_array_tag, the tag for float arrays. - Added
Option_arraymodule that allows for a compact representation of'a optoin array, which avoids allocating heap objects representingSome a. - Remove "normalized" index operations from
String, which inclucedString.normalize,String.slice,String.ngetandString.nset. These operations are still available in core_kernel. - Added missing conversions between
Int63and other integer types, specifically, the versions that return options. - Added truncating versions of integer conversions, with a suffix of
_trunc. These allow fast conversions via bit arithmetic without any conditional failure; excess bits beyond the width of the output type are simply dropped. - Added
Sequence.group, similar toList.group. - Reimplemented
String.Caseless.compareso that it does not allocate. - Added
String.is_substring_at string ~pos ~substring. Used it as back-end foris_suffixandis_prefix. - Moved all remaining
Replace_polymorphic_comparesubmodules from Base types and consolidated them in one place withinImport0. - Removed
(<=.)and its friends. - Added
Sys.argv. - Added a infix exponentation operator for int.
- Added a
Formattermodule to reexport theFormat.formattertype and updated the deprecation message forFormat.
v0.10
(Changes that can break existing programs are marked with a "*")
Bugfixes
- Generalized the type of
Printf.ifprintfto reflect OCaml's stdlib. - Made
Sequence.fold_manditer_mrespectSkipsteps and explicitly bind when they occur. - Changed
Float.is_negativeandis_non_positiveonNaNto returnfalserather thantrue. - Fixed the
Validate.protectfunction, which was mistakenly raising exceptions.
API changes
- Renamed
Map.addasset, and deprecatedadd. A later feature will addaddandadd_exnin the style ofHashtbl. - A different hash function is used to implement
Base.Int.hash. The old implementation wasInt.absbut 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. - Made
open Baseexpose infix float operators (+., -., etc.).
- Renamed
List.deduptoList.dedup_and_sort, to better reflect its existing behavior.
- Added
Hashtbl.find_multiandMap.find_multi. - Added function
Map.of_increasing_sequencefor constructing aMap.tfrom an orderedSequence.t - Added function
List.chunks_of : 'a t -> length : int -> 'a t t, for breaking a list into chunks of equal length. - Add to module
Randomnumeric functions that take upper and lower inclusive bounds, e.g.Random.int_incl : int -> int -> int.
- Replaced
Exn.Never_elide_backtracewithBacktrace.elide, arefcell that determines whetherBacktrace.to_stringandBacktrace.sexp_of_telide backtraces.
- Exposed infix operator
Base.( @@ ). - Exposed modules
Base.Continue_or_stopandFinished_or_stopped_early, used with theContainer.fold_untilfunction. - Exposed module types Base.T, T1, T2, and T3.
- Added
Sequence.Expertfunctionsnext_stepanddelayed_fold_step, for clients that want to explicitly handleSkipsteps. - Added
Bytesmodule. This includes the submodulesFrom_stringandTo_stringwith blit functions. N.B. the signature (and name) ofunsafe_to_stringandunsafe_of_stringare different from the one in the standard library (and hopefully more explicit). - Add bytes functions to
Buffer. Also addedBuffer.content_bytes, the analog ofcontentsbut that returnsbytesrather thanstring.
- Enabled
-safe-string.
- Added function
Int63.of_int32, which was missing.
- Deprecated a number of
Stringmutating functions.
- Added module
Obj_array, moved in fromCore_kernel.
- In module type
Hashtbl.Accessors, removed deprecated functions, moving them into a new module type,Deprecated.
- Exported
sexp_*types that are recognized byppx_sexp_*converters:sexp_array,sexp_list,sexp_opaque,sexp_option.
- Reworked the
Or_errormodule's interface, moving theContainer.Sinterface to anOksubmodule, and adding functionsis_ok,is_error, andokto more closely resemble the interface of theResultmodule.
- Removed
Int.O.of_int_exn. - Exposed
Base.forcefunction. - Changed the deprecation warning for
modto recommend( % )rather thanCaml.( mod ).
Performance related changes
- Optimized
List.compare, removing its closure allocation. - Optimized
String.memto not allocate. - Optimized
Float.is_negative,is_non_negative,is_positive, andis_non_positiveto avoid some boxing. - Changed
Hashtbl.mergeto relax its equality check on the input tables'Hashable.trecords, checking physical equality componentwise if the records aren't physically equal. - Added
Result.combine_errors, similar toOr_error.combine_errors, with a slightly different type. - Added
Result.combine_errors_unit, similar toOr_error.combine_errors_unit. - Optimized the
With_return.returntype by adding the[@@unboxed]attribute. - Improved a number of deprecation warnings.
v0.9
Initial release.