Module Descr


module Descr: sig .. end
Type description for safer unmarshalling.

This module provides a safer API than the library "unmarshal" for registering type description.



Type declaration


type 'a t 
Type of a type description. The type variable is for safety only.
type packed 
Type of an "embeded" type description (that is a type description enclosed into one other).

type structure =
| Sum of packed array array
| Array of packed (*Similar to Unmarshal.structure*)

Smart constructors


val pack : 'a t -> packed
Create an embeded type description from a standard type description.
val abstract : 'a Type.t -> 'a t
Similar to the Unmarshal.Abstract constructor.
val structure : 'a Type.t -> structure -> 'a t
Similar to the Unmarshal.Structure constructor.
val transform : 'a Type.t -> 'a t -> ('a -> 'a) -> 'a t
Similar to the Unmarshal.Transform constructor with sanity check.
val return : 'a Type.t -> 'a t -> (unit -> 'a) -> 'a t
Similar to the Unmarshal.Return constructor with sanity check.
val dynamic : 'a Type.t -> (unit -> 'a t) -> 'a t
Similar to the Unmarshal.Dynamic constructor.

Predefined type description values


val t_int : int t
val t_string : string t
val t_float : float t
val t_bool : bool t
val t_int32 : int32 t
val t_int64 : int64 t
val t_nativeint : nativeint t

Convenient functions for building type description


val t_record : 'a Type.t -> packed array -> 'a t
val t_tuple : 'a Type.t -> packed array -> 'a t
val t_couple : 'a t -> 'b t -> ('a * 'b) t
val t_list : 'a t -> 'a list t
val t_ref : 'a t -> 'a Pervasives.ref t
val t_option : 'a t -> 'a option t