master
branchmaster
branchThis library is a set of APIs defined with module types, and a set of modules and functors implementing one or more of those interfaces.
The APIs define what a character and a string of characters should be.
This is the development branch of the library, the latest released version is 0.0.1.
See the INSTALL file for build instructions.
We have:
BASIC_CHARACTER
: characters of any length.NATIVE_CONVERSIONS
: functions to transform from/to native OCaml
strings.BASIC_STRING
: immutable strings of (potentially abstract)
characters:NATIVE_CONVERSIONS
,output
function:
Make_output
: OUTPUT_MODEL
→ sig val output: ... end
.UNSAFELY_MUTABLE
: mutability of some string implementations
(“unsafe” meaning that they break immutability
invariants/assumptions).MINIMALISTIC_MUTABLE_STRING
: abstract mutable string used as
argument of the Of_mutable
functor.The Native_character
module implements BASIC_CHARACTER
with
OCaml's char
type.
The Native_string
module implements BASIC_STRING
and
UNSAFELY_MUTABLE
with OCaml's string
type (and hence
Native_character
).
List_of
is a functor: BASIC_CHARACTER
→ BASIC_STRING
, i.e., it creates a
string datastructure made of a list of characters.
The functor Of_mutable
uses an implementation of
MINIMALISTIC_MUTABLE_STRING
to build a BASIC_STRING
.
The Int_utf8_character
module implements BASIC_CHARACTER
with
OCaml integers (int
) representing Utf8 characters (we force the
handling of not more than 31 bits, even if RFC 3629
restricts them to end at U+10FFFF, c.f. also
wikipedia). Note that the function is_whitespace
considers
only ASCII whitespace (useful while writing parsers for example).
See the file sosa_test.ml
for usage examples, the
library is tested with:
List_of(Native_character)
),List_of(utf8-int array)
),Of_mutable(utf8-int array)
),Of_mutable(int8 Bigarray1.t)
).The tests are a self-compiling “Shell-then-OCaml-script” which
depends on the Nonstd, and the OCaml
Bigarray
libraries:
./test/sosa_test.ml
and you may add the basic benchmarks to the process with:
./test/sosa_test.ml bench