# Stdcompat, a compatibility module for OCaml standard library

**URL:** <https://discuss.ocaml.org/t/stdcompat-a-compatibility-module-for-ocaml-standard-library/1130>\
**Category:** Community\
**Tags:** announce\
**Created:** [November 16, 2017, 11:24am UTC](https://discuss.ocaml.org/t/stdcompat-a-compatibility-module-for-ocaml-standard-library/1130 "2017-11-16T11:24:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thierry\_Martinez](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/thierry_martinez/32/2864_2.png) [@Thierry\_Martinez](https://discuss.ocaml.org/u/Thierry_Martinez)\
**Post date:** [November 16, 2017, 11:24am UTC](https://discuss.ocaml.org/t/stdcompat-a-compatibility-module-for-ocaml-standard-library/1130/1 "2017-11-16T11:24:37Z")

</div>

I am pleased to announce Stdcompat: a compatibility module for OCaml standard library.

`Stdcompat.*` redefines (most of the) symbols available in the standard library of OCaml 4.06.0, such as `List.find_opt`, `floatarray`, `bytes`, `Uchar.t`, etc., and compiles on all versions of OCaml since 3.12.0.

If the version of OCaml is recent enough, these types and values are just aliases to the corresponding symbols of the standard library. Otherwise, they are redefined. For instance, `Stdcompat.floatarray` is an alias for `floatarray` with OCaml 4.06.0 and for `float array` with OCaml 4.05.0 and older.

Sub-modules signatures include the signatures of the standard library modules, in order to allow `Stdcompat` to be opened globally if preferred. For instance, `Stdcompat.List` reexports all the symbols of `List`. See the`.mlip` file or the preprocessed `.mli` and the generated documentation for the complete list of available symbols.

The provided redefinitions do not make anything magic with the internal data structures: some of them are not as efficient as the ones of the standard library (for instance, `Hashtbl.filter_map_inplace` may rebuild the hash-table), and can be even insecure (for instance, seeds are ignored for hash tables prior OCaml 4.00). This is a design choice that can possibly change in the future. Of course, these lesser redefinitions are used only if the OCaml version is not recent enough.

The module is intended to follow future changes of the standard library, and the API can change, for instance if some symbols become deprecated. However, I will try to keep the ability to be compiled on old versions of OCaml (at least 3.12.0).

GitHub repository: [https://github.com/thierry-martinez/stdcompat](https://github.com/thierry-martinez/stdcompat)  
Available in OPAM: `opam install stdcompat`

Happy hacking!

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [December 31, 2017, 7:40am UTC](https://discuss.ocaml.org/t/stdcompat-a-compatibility-module-for-ocaml-standard-library/1130/2 "2017-12-31T07:40:04Z")

</div>

Hi Thierry, based on your intentions of keeping backwards-compatibility, I have a feeling you’ve been in some discussions about possible changes to the standard library. I would be very interested to have a look at those–could you give me a pointer? Thanks
