Interface that should support any regular data type.
Overview
A regular type is catch all term for all data types that are regular, like numbers, characters, strings and their algebraic closure. A proper term for such types would be inductive types. A regular type always has a concrete representation, it is printable, comparable (with total order), hashable, etc.
To contrast, functions, closures, proxies, descriptors, and any co-inductive types are non-regular. The main difference, is that regular type is self contained, where non-regular types, usually represent something that can be only observed, but not really represented with the data type.
On the border line we have Opaque
data types. These are types, that pretend to be Regular
, but we can't actually inspect their representation.
Features
So what the library actually provides. First of all it defines the Regular
interface, that each regular data type is expected to implement. This includes a full set of Io
functions, that allows one to read, write and serialize values of the type (see Data
interface). It also provides an inteface for creating different collections from the values of that type, including trees, hashtables, maps, sets, etc. Also, it describes the whole algebra of comparison functions. For the opaque data types an interface called Opaque
is provided, that is a proper subset of the Regular
. It doesn't provide printing and serialization, but has everything that can be derived for a type with a total order (e.g., containers, comparison function, etc).
A functor is provided for each interface, that requires the minimal implementation, and derives the rest.
Finally, a Bytes
module is provided that facilitates the transfer from mutable to immutable Strings
. It is the extension of OCaml standard Bytes module, enhanced with the expected set of functions.
Type definitions
bytes is a mutable sequence of bytes that has a fixed length.
Reader and Writer type classes
Each type class is an abstraction of a tuple of function.
an interface for reading a value from the input.
an interface for writing a value to the output.
a string that digests data
'a printer
constructs a printer type for arbitrary type 'a
.
A value of type 'a printer
is a function that is expected by the %a
specifier of the Format.printf
family of functions.
Printable data structures.
Abbreviation for 'a Sequence.t
val compare_seq : ('a -> 'a -> int) -> 'a seq -> 'a seq -> int
val (^::) : 'a -> 'a seq -> 'a seq
x ^:: xs
is a consing operator for sequences
module Data : sig ... end
Data types support module.
Regular types models a general concept of value, i.e., something that can be used in way similar to regular int
, string
, char
and other built in types. So that it can be compared, used in maps, sets, hashtables, printer, etc.
Opaque type is like regular type, except that we can print or examine it in any way. So it can't be serialized or pretty-printed. An Opaque.Make
can create an instances of such type.
module Bytes : sig ... end
Extension of the standard bytes module.