When using mutable array’s for imperative code, it can be useful to operate on conceptual subslices of an underlying array. This provides an abstraction for operations akin to pointer arithmetic in C. For example, you can divide and conquer on sub-slices of an array using different starting pointers, but still be mutating the underlying array). The SML Basis library implements this in http://sml-family.org/Basis/array-slice.html. Does anyone know of a similar existing library in OCaml? (I searched opam and google and didn’t find anything that seemed relevant, but I’m I’ve found things can sometimes be hidden away.)
Try the Cf_slice module in Orsetto.
Your suggestion made me realize I had overlooked some other larger libraries like Orsetto (I did look in core, but didn’t see anything). I found Array_slice in containers as well.
Here is a link to Orsetto.
I ended up going with Containers because it is documented and is a general purpose standard lib as opposed to a (quite fully featured, but still specialized) library for ser/de.
Just for completeness, for slices defined on a multidimensional Bigarray, there is the
View module in Owl.
Just a brief aside to clarify some things here.
The Cf library in Orsetto is a combination of general container structures with accompanying logic for supporting generic parsing, formatting, emitting and scanning. It’s an OCamlFind subpackage all its own, and it can be used independent of any particular serialization technique.
The Cf_slice module is a bit more generic than the Array_slice module in Containers. It supports a common abstraction for string and bytes slices that it also supports 'a array slices.
Orsetto has documentation available with odig.