import deriving 0.1.1a
[deriving.git] / tests / sigs.ml
bloba83eca5d01a492330cc4bf2d8ea1c98f509fafe2
1 (*pp deriving *)
3 (* Deriving a signature with types exposed *)
4 module T :
5 sig
6 type sum = S0 | S1 of int | S2 of int * float | S3 of int * float * bool | Sunit of unit | Stup of (int * float) | Stup1 of (int)
7 deriving (Dump, Eq, Show, Typeable, Pickle)
9 type nullsum = N0 | N1 | N2 | N3
10 deriving (Enum, Bounded, Eq, Typeable, Pickle)
12 type r1 = {
13 r1_l1 : int;
14 r1_l2 : int;
15 } deriving (Dump, Eq, Show, Typeable, Pickle, Functor)
17 type r2 = {
18 mutable r2_l1 : int;
19 mutable r2_l2 : int;
20 } deriving (Eq, Show, Typeable, Pickle)
22 type r3 = {
23 r3_l1 : int;
24 mutable r3_l2 : int;
25 } deriving (Eq, Show, Typeable, Pickle)
27 type r4 = {
28 r4_l1 : 'a . 'a list
30 type label = x:int -> int
32 type funct = int -> int
34 type intseq = INil | ICons of int * intseq
35 deriving (Dump, Eq, Show, Typeable, Pickle, Functor)
37 type 'a seq = Nil | Cons of 'a * 'a seq
38 deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
40 type uses_seqs = (intseq * float seq)
41 deriving (Dump, Eq, Show, Typeable, Pickle)
43 type obj = < x : int >
45 type poly0 = [`T0 | `T1 | `T2 | `T3]
46 deriving (Enum, Bounded, Show, Eq, Typeable, Pickle)
48 type poly1 = [`T0 | `T1 of int]
49 deriving (Dump, Eq, Show)
51 type poly2 = P of int * [`T0 | `T1 of int] * float
52 deriving (Dump, Eq, Show)
54 type poly3 = [`Nil | `Cons of int * 'c] as 'c
55 deriving (Dump, Eq, Show, Typeable, Pickle)
57 type poly3b = int * ([`Nil | `Cons of int * 'c] as 'c) * [`F]
58 deriving (Dump, Eq, Show, Typeable, Pickle)
60 type 'a poly7 = Foo of [`F of 'a]
61 and 'a poly8 = { x : [`G of [`H of [`I of 'a poly7]]] }
62 deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
64 type poly10 = [`F | poly3]
65 deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
67 type mutrec_a = mutrec_c
68 and mutrec_b = { l1 : mutrec_c ; l2 : mutrec_a }
69 and mutrec_c = S of int * mutrec_a | N
70 and mutrec_d = [`T of mutrec_b]
71 deriving (Dump, Eq, Show, Typeable, Pickle)
73 type ('a,'b) pmutrec_a = ('a,'b) pmutrec_c
74 and ('a,'b) pmutrec_b = { pl1 : ('a,'b) pmutrec_c ; pl2 : ('a,'b) pmutrec_a }
75 and ('a,'b) pmutrec_c = SS of 'a * ('a,'b) pmutrec_a * 'b
76 and ('a,'b) pmutrec_d = [`T of ('a,'b) pmutrec_b]
77 deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
79 type 'a ff1 = F of 'a * 'a | G of int deriving (Show, Eq, Dump, Functor, Typeable, Pickle)
80 type ('a,'b) ff2 = F1 of ('a,'b) ff2 | F2 of 'a seq * int * 'b option
81 deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
83 type tup0 = unit
84 deriving (Dump, Eq, Show, Typeable, Pickle)
85 type tup2 = int * float
86 deriving (Dump, Eq, Show, Typeable, Pickle)
87 type tup3 = int * float * bool
88 deriving (Dump, Eq, Show, Typeable, Pickle)
89 type tup4 = int * int * bool * unit
90 deriving (Dump, Eq, Show, Typeable, Pickle, Bounded)
92 type withref = WR of int * (int ref)
93 deriving (Eq, Show, Typeable, Pickle)
95 module M : sig
96 type t deriving (Show, Eq, Dump)
97 end
99 module P : sig
100 type 'a t (* deriving (Show) *)
103 type 'a constrained = [`F of 'a] constraint 'a = int
104 deriving (Functor)
106 type p1 = private P1
107 deriving (Show, Eq)
109 module Private : sig
110 type p2 = private Q deriving (Show, Eq, Dump)
113 type t = int
114 deriving (Eq, Enum, Bounded, Dump, Show, Typeable, Pickle, Functor)
116 = Defs
118 (* Deriving a signature with types made abstract *)
119 module T_opaque :
120 sig
121 type sum deriving (Dump, Eq, Show, Typeable, Pickle)
122 type nullsum deriving (Enum, Bounded, Eq, Typeable, Pickle)
123 type r1 deriving (Dump, Eq, Show, Typeable, Pickle, Functor)
124 type r2 deriving (Eq, Show, Typeable, Pickle)
125 type r3 deriving (Eq, Show, Typeable, Pickle)
126 type r4
127 type label
128 type funct
129 type intseq deriving (Dump, Eq, Show, Typeable, Pickle, Functor)
130 type 'a seq deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
131 type uses_seqs deriving (Dump, Eq, Show, Typeable, Pickle)
132 type obj
133 type poly0 deriving (Enum, Bounded, Show, Eq, Typeable, Pickle)
134 type poly1 deriving (Dump, Eq, Show)
135 type poly2 deriving (Dump, Eq, Show)
136 type poly3 deriving (Dump, Eq, Show, Typeable, Pickle)
137 type poly3b deriving (Dump, Eq, Show, Typeable, Pickle)
138 type 'a poly7
139 and 'a poly8 deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
140 type poly10 deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
141 type mutrec_a
142 and mutrec_b
143 and mutrec_c
144 and mutrec_d deriving (Dump, Eq, Show, Typeable, Pickle)
145 type ('a,'b) pmutrec_a
146 and ('a,'b) pmutrec_b
147 and ('a,'b) pmutrec_c
148 and ('a,'b) pmutrec_d deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
149 type 'a ff1 deriving (Show, Eq, Dump, Functor, Typeable, Pickle)
150 type ('a,'b) ff2 deriving (Dump, Eq, Show, Functor, Typeable, Pickle)
151 type tup0 deriving (Dump, Eq, Show, Typeable, Pickle)
152 type tup2 deriving (Dump, Eq, Show, Typeable, Pickle)
153 type tup3 deriving (Dump, Eq, Show, Typeable, Pickle)
154 type tup4 deriving (Dump, Eq, Show, Typeable, Pickle, Bounded)
155 type withref deriving (Eq, Show, Typeable, Pickle)
156 module M : sig type t deriving (Show, Eq, Dump) end
157 module P : sig type 'a t end
158 type 'a constrained constraint 'a = int deriving (Functor)
159 type p1 deriving (Show, Eq)
160 module Private : sig type p2 end
161 type t deriving (Eq, Enum, Bounded, Dump, Show, Typeable, Pickle, Functor)
163 = Defs
166 (* A signature with no deriving (to make sure that the types are still
167 compatible) *)
168 module T_no_deriving :
169 sig
170 type sum = S0 | S1 of int | S2 of int * float | S3 of int * float * bool | Sunit of unit | Stup of (int * float) | Stup1 of (int)
172 type nullsum = N0 | N1 | N2 | N3
174 type r1 = {
175 r1_l1 : int;
176 r1_l2 : int;
179 type r2 = {
180 mutable r2_l1 : int;
181 mutable r2_l2 : int;
184 type r3 = {
185 r3_l1 : int;
186 mutable r3_l2 : int;
189 type r4 = {
190 r4_l1 : 'a . 'a list
192 type label = x:int -> int
194 type funct = int -> int
196 type intseq = INil | ICons of int * intseq
198 type 'a seq = Nil | Cons of 'a * 'a seq
200 type uses_seqs = (intseq * float seq)
202 type obj = < x : int >
204 type poly0 = [`T0 | `T1 | `T2 | `T3]
206 type poly1 = [`T0 | `T1 of int]
208 type poly2 = P of int * [`T0 | `T1 of int] * float
210 type poly3 = [`Nil | `Cons of int * 'c] as 'c
212 type poly3b = int * ([`Nil | `Cons of int * 'c] as 'c) * [`F]
214 type 'a poly7 = Foo of [`F of 'a]
215 and 'a poly8 = { x : [`G of [`H of [`I of 'a poly7]]] }
217 type poly10 = [`F | poly3]
219 type mutrec_a = mutrec_c
220 and mutrec_b = { l1 : mutrec_c ; l2 : mutrec_a }
221 and mutrec_c = S of int * mutrec_a | N
222 and mutrec_d = [`T of mutrec_b]
224 type ('a,'b) pmutrec_a = ('a,'b) pmutrec_c
225 and ('a,'b) pmutrec_b = { pl1 : ('a,'b) pmutrec_c ; pl2 : ('a,'b) pmutrec_a }
226 and ('a,'b) pmutrec_c = SS of 'a * ('a,'b) pmutrec_a * 'b
227 and ('a,'b) pmutrec_d = [`T of ('a,'b) pmutrec_b]
229 type 'a ff1 = F of 'a * 'a | G of int
230 type ('a,'b) ff2 = F1 of ('a,'b) ff2 | F2 of 'a seq * int * 'b option
232 type tup0 = unit
233 type tup2 = int * float
234 type tup3 = int * float * bool
235 type tup4 = int * int * bool * unit
236 type withref = WR of int * (int ref)
238 module M : sig
239 type t
242 module P : sig
243 type 'a t
246 type 'a constrained = [`F of 'a] constraint 'a = int
248 type p1 = private P1
250 module Private : sig
251 type p2 = private Q
254 type t = int
256 = Defs