I am pleased to announce the first release of spvec. This small OCaml library implements semi-persistent vectors. In other words, it offers vectors that support just two operations, namely push and get, and that appear to be persistent (immutable), but must be used according to a restricted discipline. Thanks to this restriction, an efficient implementation, based on a mutable vector, is possible. One might say that this library offers mutable vectors disguised as persistent vectors, with a simple and safe API.
Two submodules are offered, Spvec.Safe and Spvec.Unsafe. The safe variant detects misuses of the library at runtime. The unsafe variant is faster, but does not detect misuses; it should be used only if and when the user’s code is believed to be correct.
For more details, see the documentation.
opam update
opam install spvec
Happy hacking,
FP.