Module Std.Type_generic

module Type_generic: Type_generic


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.

module Variant_and_record_intf: module type of Variant_and_record_intf
module Helper: 
functor (A : Variant_and_record_intf.S) ->
functor (B : Variant_and_record_intf.S) -> sig .. end
module type Named = sig .. end
module type Computation = sig .. end
module Make_named_for_closure: 
functor (X : sig
type 'a input 
type 'a output 
type 'a t = 'a input ->
'a output
end) -> Named  with type 'a computation := 'a X.t
Not all computations are arrow types.
module Ident: sig .. end
module type S = sig .. end
module Make: 
functor (X : sig
type 'a t 
val name : string
val required : Type_generic.Ident.t list
include Type_generic.Computation
end) -> S  with type 'a t = 'a X.t
The name is used for debug information only in case of Broken_dependency.