package typerep

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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

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.

Place holder for common Variants and Fields interface

module type Named = sig ... end
module type Computation = sig ... end
module Make_named_for_closure (X : sig ... end) : Named with type 'a computation := 'a X.t

Not all computations are arrow types. For example:

module Ident : sig ... end
module type S = sig ... end
module Make (X : sig ... end) : S with type 'a t = 'a X.t

The 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