A computation is the type of an operation that can be applied to various different kind of types. It is expressed as a type with one parameter:
type 'a computation
Examples of computation:
type sexp_of_t = ('a -> Sexp.t) computation type type_struct = Type_struct.t computation
The term generic is used to refer to a specific implementation of a computation
whose concrete implementation is programmed using the type representation of values.
For example, when one uses with sexp as a way to implement the sexp_of_t
computation, the technique used is code generation at compile time. Another approach
is to define a generic function sexp_of_t that inspects the representation of the
type at runtime.
This module offers an abstraction over type rep in order to implement generics in a efficient way.
Provided from a user enough pieces of implementation regarding a particular computation, this module returns essentially the following function:
(** main function : get the computation from the typerep *)
val of_typerep : 'a Typerep.t -> `generic of 'a computation
that allows one to get the generic computation operating on a given type 'a.
name is used for debug information only in case of Broken_dependency.
The required is to handle dependencies between generics at runtime.
Example:
if X is the module given to build a generic computation G that depends on three
other computation A,B,C then X.required shall be A.ident ; B.ident ; C.ident