deriving (Enum) now uses Deriving_Enum module [#1]
[deriving.git] / lib / pickle.mli
blob742905f3f438cc90eb1516e01bc63d9cf48088ad
1 type id
3 (* representation of values of user-defined types *)
4 module Repr : sig
5 type t
6 val make : ?constructor:int -> id list -> t
7 end
9 (* Utilities for serialization *)
10 module Write : sig
11 type s
12 include Monad.Monad_state_type with type state = s
13 module Utils (T : Typeable.Typeable) (E : Eq.Eq with type a = T.a) : sig
14 val allocate : T.a -> (id -> unit m) -> id m
15 val store_repr : id -> Repr.t -> unit m
16 end
17 end
19 (* Utilities for deserialization *)
20 module Read : sig
21 type s
22 include Monad.Monad_state_type with type state = s
23 module Utils (T : Typeable.Typeable) : sig
24 val sum : (int * id list -> T.a m) -> (id -> T.a m)
25 val tuple : (id list -> T.a m) -> (id -> T.a m)
26 val record : (T.a -> id list -> T.a m) -> int -> (id -> T.a m)
27 end
28 end
30 exception UnpicklingError of string
31 exception UnknownTag of int * string
33 module type Pickle =
34 sig
35 type a
36 module T : Typeable.Typeable with type a = a
37 module E : Eq.Eq with type a = a
38 val pickle : a -> id Write.m
39 val unpickle : id -> a Read.m
40 val to_buffer : Buffer.t -> a -> unit
41 val to_string : a -> string
42 val to_channel : out_channel -> a -> unit
43 val from_stream : char Stream.t -> a
44 val from_string : string -> a
45 val from_channel : in_channel -> a
46 end
48 module Defaults
49 (S : sig
50 type a
51 module T : Typeable.Typeable with type a = a
52 module E : Eq.Eq with type a = a
53 val pickle : a -> id Write.m
54 val unpickle : id -> a Read.m
55 end) : Pickle with type a = S.a
57 module Pickle_unit : Pickle with type a = unit
58 module Pickle_bool : Pickle with type a = bool
59 module Pickle_int : Pickle with type a = int
60 module Pickle_char : Pickle with type a = char
61 module Pickle_float : Pickle with type a = float
62 module Pickle_num : Pickle with type a = Num.num
63 module Pickle_string : Pickle with type a = string
64 module Pickle_option (V0 : Pickle) : Pickle with type a = V0.a option
65 module Pickle_list (V0 : Pickle) : Pickle with type a = V0.a list
66 module Pickle_ref (S : Pickle) : Pickle with type a = S.a ref
68 module Pickle_from_dump
69 (P : Dump.Dump)
70 (E : Eq.Eq with type a = P.a)
71 (T : Typeable.Typeable with type a = P.a)
72 : Pickle with type a = P.a