~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to testsuite/tests/typing-poly/poly.ml.reference

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-04-21 21:35:08 UTC
  • mfrom: (1.1.11 upstream) (12.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110421213508-kg34453aqmb0moha
* Fixes related to -output-obj with g++ (in debian/patches):
  - add Declare-primitive-name-table-as-const-char
  - add Avoid-multiple-declarations-in-generated-.c-files-in
  - fix Embed-bytecode-in-C-object-when-using-custom: the closing
    brace for extern "C" { ... } was missing in some cases

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#   * * *       #   type 'a t = { t : 'a; }
 
3
# type 'a fold = { fold : 'b. f:('b -> 'a -> 'b) -> init:'b -> 'b; }
 
4
# val f : 'a list -> 'a fold = <fun>
 
5
# - : int = 6
 
6
#               class ['a] ilist :
 
7
  'a list ->
 
8
  object ('b)
 
9
    val l : 'a list
 
10
    method add : 'a -> 'b
 
11
    method fold : f:('c -> 'a -> 'c) -> init:'c -> 'c
 
12
  end
 
13
#         class virtual ['a] vlist :
 
14
  object ('b)
 
15
    method virtual add : 'a -> 'b
 
16
    method virtual fold : f:('c -> 'a -> 'c) -> init:'c -> 'c
 
17
  end
 
18
#             class ilist2 :
 
19
  int list ->
 
20
  object ('a)
 
21
    val l : int list
 
22
    method add : int -> 'a
 
23
    method fold : f:('b -> int -> 'b) -> init:'b -> 'b
 
24
  end
 
25
#             val ilist2 : 'a list -> 'a vlist = <fun>
 
26
#             class ['a] ilist3 :
 
27
  'a list ->
 
28
  object ('b)
 
29
    val l : 'a list
 
30
    method add : 'a -> 'b
 
31
    method fold : f:('c -> 'a -> 'c) -> init:'c -> 'c
 
32
  end
 
33
#               class ['a] ilist4 :
 
34
  'a list ->
 
35
  object ('b)
 
36
    val l : 'a list
 
37
    method add : 'a -> 'b
 
38
    method fold : f:('c -> 'a -> 'c) -> init:'c -> 'c
 
39
  end
 
40
#                 class ['a] ilist5 :
 
41
  'a list ->
 
42
  object ('b)
 
43
    val l : 'a list
 
44
    method add : 'a -> 'b
 
45
    method fold : f:('c -> 'a -> 'c) -> init:'c -> 'c
 
46
    method fold2 : f:('d -> 'a -> 'd) -> init:'d -> 'd
 
47
  end
 
48
#                 class ['a] ilist6 :
 
49
  'a list ->
 
50
  object ('b)
 
51
    val l : 'a list
 
52
    method add : 'a -> 'b
 
53
    method fold : f:('c -> 'a -> 'c) -> init:'c -> 'c
 
54
    method fold2 : f:('d -> 'a -> 'd) -> init:'d -> 'd
 
55
  end
 
56
#       class virtual ['a] olist :
 
57
  object method virtual fold : f:('a -> 'b -> 'b) -> init:'b -> 'b end
 
58
#         class ['a] onil :
 
59
  object method fold : f:('a -> 'b -> 'b) -> init:'b -> 'b end
 
60
#             class ['a] ocons :
 
61
  hd:'a ->
 
62
  tl:'a olist ->
 
63
  object
 
64
    val hd : 'a
 
65
    val tl : 'a olist
 
66
    method fold : f:('a -> 'b -> 'b) -> init:'b -> 'b
 
67
  end
 
68
#               class ['a] ostream :
 
69
  hd:'a ->
 
70
  tl:'a ostream ->
 
71
  object
 
72
    val hd : 'a
 
73
    val tl : 'a ostream
 
74
    method empty : bool
 
75
    method fold : f:('a -> 'b -> 'b) -> init:'b -> 'b
 
76
  end
 
77
#                   class ['a] ostream1 :
 
78
  hd:'a ->
 
79
  tl:'b ->
 
80
  object ('b)
 
81
    val hd : 'a
 
82
    val tl : 'b
 
83
    method fold : f:('a -> 'c -> 'c) -> init:'c -> 'c
 
84
    method hd : 'a
 
85
    method tl : 'b
 
86
  end
 
87
#           class vari : object method m : [< `A | `B | `C ] -> int end
 
88
#       class vari : object method m : [< `A | `B | `C ] -> int end
 
89
#           module V : sig type v = [ `A | `B | `C ] val m : [< v ] -> int end
 
90
#         class varj : object method m : [< V.v ] -> int end
 
91
#         module type T =
 
92
  sig class vari : object method m : [< `A | `B | `C ] -> int end end
 
93
#             module M0 :
 
94
  sig class vari : object method m : [< `A | `B | `C ] -> int end end
 
95
#   module M : T
 
96
# val v : M.vari = <obj>
 
97
# - : int = 1
 
98
#               class point :
 
99
  x:int ->
 
100
  y:int -> object val x : int val y : int method x : int method y : int end
 
101
#           class color_point :
 
102
  x:int ->
 
103
  y:int ->
 
104
  color:string ->
 
105
  object
 
106
    val color : string
 
107
    val x : int
 
108
    val y : int
 
109
    method color : string
 
110
    method x : int
 
111
    method y : int
 
112
  end
 
113
#                   class circle :
 
114
  #point ->
 
115
  r:int ->
 
116
  object val p : point val r : int method distance : #point -> float end
 
117
#           val p0 : point = <obj>
 
118
val p1 : point = <obj>
 
119
val cp : color_point = <obj>
 
120
val c : circle = <obj>
 
121
val d : float = 11.4536240470737098
 
122
#   val f : < m : 'a. 'a -> 'a > -> < m : 'a. 'a -> 'a > = <fun>
 
123
#   Characters 41-42:
 
124
  let f (x : < m : 'a. 'a -> 'a list >) = (x : < m : 'b. 'b -> 'c >)
 
125
                                           ^
 
126
Error: This expression has type < m : 'a. 'a -> 'a list >
 
127
       but an expression was expected of type < m : 'a. 'a -> 'b >
 
128
       The universal variable 'a would escape its scope
 
129
#           class id : object method id : 'a -> 'a end
 
130
#         class type id_spec = object method id : 'a -> 'a end
 
131
#       class id_impl : object method id : 'a -> 'a end
 
132
#               class a : object method m : bool end
 
133
and b : object method id : 'a -> 'a end
 
134
#           Characters 72-77:
 
135
    method id x = x
 
136
              ^^^^^
 
137
Error: This method has type 'a -> 'a which is less general than 'b. 'b -> 'a
 
138
#         Characters 75-80:
 
139
    method id x = x
 
140
              ^^^^^
 
141
Error: This method has type 'a -> 'a which is less general than 'b. 'b -> 'a
 
142
#           Characters 80-85:
 
143
    method id _ = x
 
144
              ^^^^^
 
145
Error: This method has type 'a -> 'a which is less general than 'b. 'b -> 'b
 
146
#                 Characters 92-159:
 
147
  ............x =
 
148
      match r with
 
149
        None -> r <- Some x; x
 
150
      | Some y -> y
 
151
Error: This method has type 'a -> 'a which is less general than 'b. 'b -> 'b
 
152
#         class c : object method m : 'a -> 'b -> 'a end
 
153
#     val f1 : id -> int * bool = <fun>
 
154
#   val f2 : id -> int * bool = <fun>
 
155
#   Characters 24-28:
 
156
  let f3 f = f#id 1, f#id true
 
157
                          ^^^^
 
158
Error: This expression has type bool but an expression was expected of type
 
159
         int
 
160
#   val f4 : id -> int * bool = <fun>
 
161
#           class c : object method m : #id -> int * bool end
 
162
#             class id2 : object method id : 'a -> 'a method mono : int -> int end
 
163
#   val app : int * bool = (1, true)
 
164
#   Characters 4-25:
 
165
  type 'a foo = 'a foo list
 
166
      ^^^^^^^^^^^^^^^^^^^^^
 
167
Error: The type abbreviation foo is cyclic
 
168
#     class ['a] bar : 'a -> object  end
 
169
#   type 'a foo = 'a foo bar
 
170
#   - : (< m : 'b. 'b * 'a > as 'a) -> 'c * 'a = <fun>
 
171
# - : (< m : 'b. 'a * 'b list > as 'a) -> 'a * 'c list = <fun>
 
172
# val f :
 
173
  (< m : 'b. 'a * (< n : 'b; .. > as 'b) > as 'a) ->
 
174
  'a * (< n : 'c; .. > as 'c) = <fun>
 
175
# - : (< p : 'b. < m : 'b; n : 'a; .. > as 'b > as 'a) ->
 
176
    (< m : 'c; n : 'a; .. > as 'c)
 
177
= <fun>
 
178
# - : (< m : 'b. 'b * < p : 'd. 'd * 'c * 'a > as 'c > as 'a) ->
 
179
    ('f * < p : 'g. 'g * 'e * 'a > as 'e)
 
180
= <fun>
 
181
#   - : < m : 'a. < p : 'a; .. > as 'b > -> 'b = <fun>
 
182
#   type sum = T of < id : 'a. 'a -> 'a >
 
183
# - : sum -> 'a -> 'a = <fun>
 
184
#   type record = { r : < id : 'a. 'a -> 'a >; }
 
185
# - : record -> 'a -> 'a = <fun>
 
186
# - : record -> 'a -> 'a = <fun>
 
187
#       class myself : object ('a) method self : 'b -> 'a end
 
188
#                       class number :
 
189
  object ('a)
 
190
    val num : int
 
191
    method num : int
 
192
    method prev : 'a
 
193
    method succ : 'a
 
194
    method switch : zero:(unit -> 'b) -> prev:('a -> 'b) -> 'b
 
195
  end
 
196
#     val id : 'a -> 'a = <fun>
 
197
#       class c : object method id : 'a -> 'a end
 
198
#         class c' : object method id : 'a -> 'a end
 
199
#               class d :
 
200
  object
 
201
    val mutable count : int
 
202
    method count : int
 
203
    method id : 'a -> 'a
 
204
    method old : 'b -> 'b
 
205
  end
 
206
#             class ['a] olist :
 
207
  'a list ->
 
208
  object ('b)
 
209
    val l : 'a list
 
210
    method cons : 'a -> 'b
 
211
    method fold : f:('a -> 'c -> 'c) -> init:'c -> 'c
 
212
  end
 
213
#   val sum : int #olist -> int = <fun>
 
214
#   val count : 'a #olist -> int = <fun>
 
215
#     val append : 'a #olist -> ('a #olist as 'b) -> 'b = <fun>
 
216
#     type 'a t = unit
 
217
#   class o : object method x : [> `A ] t -> unit end
 
218
#   class c : object method m : d end
 
219
and d : ?x:int -> unit -> object  end
 
220
# class d : ?x:int -> unit -> object  end
 
221
and c : object method m : d end
 
222
#           class type numeral = object method fold : ('a -> 'a) -> 'a -> 'a end
 
223
class zero : object method fold : ('a -> 'a) -> 'a -> 'a end
 
224
class next : #numeral -> object method fold : ('a -> 'a) -> 'a -> 'a end
 
225
#       class type node_type = object method as_variant : [> `Node of node_type ] end
 
226
#       class node : node_type
 
227
#     class node : object method as_variant : [> `Node of node_type ] end
 
228
#   type bad = { bad : 'a. 'a option ref; }
 
229
# Characters 17-25:
 
230
  let bad = {bad = ref None};;
 
231
                   ^^^^^^^^
 
232
Error: This field value has type 'a option ref which is less general than
 
233
         'b. 'b option ref
 
234
# type bad2 = { mutable bad2 : 'a. 'a option ref option; }
 
235
# val bad2 : bad2 = {bad2 = None}
 
236
# Characters 13-28:
 
237
  bad2.bad2 <- Some (ref None);;
 
238
               ^^^^^^^^^^^^^^^
 
239
Error: This field value has type 'a option ref option
 
240
       which is less general than 'b. 'b option ref option
 
241
#       val f : < m : 'a. < p : 'a * 'b > as 'b > -> 'c -> unit = <fun>
 
242
# val f : < m : 'a. 'a * (< p : int * 'b > as 'b) > -> 'b -> unit = <fun>
 
243
#       type 'a t = [ `A of 'a ]
 
244
#       class c : object method m : ([> 'a t ] as 'a) -> unit end
 
245
#         class c : object method m : ([> 'a t ] as 'a) -> unit end
 
246
#     class c : object method m : ([> 'a t ] as 'a) -> 'a end
 
247
#     class c : object method m : ([> `A ] as 'a) option -> 'a end
 
248
#           Characters 145-166:
 
249
  object method virtual visit : 'a.('a visitor -> 'a) end;;
 
250
                                ^^^^^^^^^^^^^^^^^^^^^
 
251
Error: This type scheme cannot quantify 'a :
 
252
it escapes this scope.
 
253
#                 type ('a, 'b) list_visitor = < caseCons : 'b -> 'b list -> 'a; caseNil : 'a >
 
254
type 'a alist = < visit : 'b. ('b, 'a) list_visitor -> 'b >
 
255
class type ct = object ('a) method fold : ('b -> 'a -> 'b) -> 'b -> 'b end
 
256
type t = { f : 'a 'b. ('b -> (#ct as 'a) -> 'b) -> 'b; }
 
257
#     Characters 20-25:
 
258
  type t = u and u = t;;
 
259
       ^^^^^
 
260
Error: The type abbreviation t is cyclic
 
261
#       class ['a] a : object constraint 'a = [> `A of 'a a ] end
 
262
type t = [ `A of t a ]
 
263
#     Characters 71-80:
 
264
  type ('a,'b) t constraint 'a = 'b and ('a,'b) u = ('a,'b) t;;
 
265
                                                    ^^^^^^^^^
 
266
Error: Constraints are not satisfied in this type.
 
267
Type ('a, 'b) t should be an instance of ('c, 'c) t
 
268
#     type 'a t = 'a
 
269
and u = int t
 
270
#     type 'a t constraint 'a = int
 
271
# Characters 26-32:
 
272
  type 'a u = 'a and 'a v = 'a u t;;
 
273
                            ^^^^^^
 
274
Error: Constraints are not satisfied in this type.
 
275
Type 'a u t should be an instance of int t
 
276
# type 'a u = 'a constraint 'a = int
 
277
and 'a v = 'a u t constraint 'a = int
 
278
#     type g = int
 
279
# type 'a t = unit constraint 'a = g
 
280
# Characters 26-32:
 
281
  type 'a u = 'a and 'a v = 'a u t;;
 
282
                            ^^^^^^
 
283
Error: Constraints are not satisfied in this type.
 
284
Type 'a u t should be an instance of g t
 
285
# type 'a u = 'a constraint 'a = g
 
286
and 'a v = 'a u t constraint 'a = int
 
287
#     Characters 38-58:
 
288
  type 'a u = < m : 'a v > and 'a v = 'a list u;;
 
289
      ^^^^^^^^^^^^^^^^^^^^
 
290
Error: In the definition of v, type 'a list u should be 'a u
 
291
#       type 'a t = 'a
 
292
type 'a u = A of 'a t
 
293
#     type 'a t = < a : 'a >
 
294
# - : ('a t as 'a) -> 'a t = <fun>
 
295
# type u = 'a t as 'a
 
296
#       type t = A | B
 
297
# - : [> `A ] * t -> int = <fun>
 
298
# - : [> `A ] * t -> int = <fun>
 
299
# - : [> `A ] option * t -> int = <fun>
 
300
#   - : [> `A ] option * t -> int = <fun>
 
301
# - : t * [< `A | `B ] -> int = <fun>
 
302
# - : [< `A | `B ] * t -> int = <fun>
 
303
# Characters 0-41:
 
304
  function (`A|`B), _ -> 0 | _,(`A|`B) -> 1;;
 
305
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
306
Warning 8: this pattern-matching is not exhaustive.
 
307
Here is an example of a value that is not matched:
 
308
(`AnyExtraTag, `AnyExtraTag)
 
309
- : [> `A | `B ] * [> `A | `B ] -> int = <fun>
 
310
# Characters 0-29:
 
311
  function `B,1 -> 1 | _,1 -> 2;;
 
312
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
313
Warning 8: this pattern-matching is not exhaustive.
 
314
Here is an example of a value that is not matched:
 
315
(_, 0)
 
316
Characters 21-24:
 
317
  function `B,1 -> 1 | _,1 -> 2;;
 
318
                       ^^^
 
319
Warning 11: this match case is unused.
 
320
- : [< `B ] * int -> int = <fun>
 
321
# Characters 0-29:
 
322
  function 1,`B -> 1 | 1,_ -> 2;;
 
323
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
324
Warning 8: this pattern-matching is not exhaustive.
 
325
Here is an example of a value that is not matched:
 
326
(0, _)
 
327
Characters 21-24:
 
328
  function 1,`B -> 1 | 1,_ -> 2;;
 
329
                       ^^^
 
330
Warning 11: this match case is unused.
 
331
- : int * [< `B ] -> int = <fun>
 
332
#       Characters 69-135:
 
333
  type ('a, 'b) a = 'a -> unit constraint 'a = [> `B of ('a, 'b) b as 'b] 
 
334
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
335
Error: Constraints are not satisfied in this type.
 
336
Type
 
337
([> `B of 'a ], 'a) b as 'a
 
338
should be an instance of
 
339
(('b, [> `A of 'b ] as 'c) a as 'b, 'c) b
 
340
#     *                           class type ['a, 'b] a =
 
341
  object
 
342
    constraint 'a = < as_a : ('a, 'b) a as 'c; b : 'b; .. >
 
343
    constraint 'b = < a : 'a; as_b : ('a, 'b) b; .. >
 
344
    method as_a : 'c
 
345
    method b : 'b
 
346
  end
 
347
and ['a, 'b] b =
 
348
  object
 
349
    constraint 'a = < as_a : ('a, 'b) a; b : 'b; .. >
 
350
    constraint 'b = < a : 'a; as_b : ('a, 'b) b; .. >
 
351
    method a : 'a
 
352
    method as_b : ('a, 'b) b
 
353
  end
 
354
class type ['a] ca =
 
355
  object ('b)
 
356
    constraint 'a = < a : 'b; as_b : ('b, 'a) b; .. >
 
357
    method as_a : ('b, 'a) a
 
358
    method b : 'a
 
359
  end
 
360
class type ['a] cb =
 
361
  object ('b)
 
362
    constraint 'a = < as_a : ('a, 'b) a; b : 'b; .. >
 
363
    method a : 'a
 
364
    method as_b : ('a, 'b) b
 
365
  end
 
366
type bt = 'a ca cb as 'a
 
367
#     class c : object method m : int end
 
368
# val f : unit -> c = <fun>
 
369
# val f : unit -> c = <fun>
 
370
# Characters 11-60:
 
371
  let f () = object method private n = 1 method m = {<>}#n end;;
 
372
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
373
Warning 15: the following private methods were made public implicitly:
 
374
 n.
 
375
val f : unit -> < m : int; n : int > = <fun>
 
376
# Characters 11-56:
 
377
  let f () = object (self:c) method n = 1 method m = 2 end;;
 
378
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
379
Error: This object is expected to have type c but actually has type
 
380
         < m : int; n : 'a >
 
381
       The first object type has no method n
 
382
# Characters 11-69:
 
383
  let f () = object (_:'s) constraint 's = < n : int > method m = 1 end;;
 
384
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
385
Error: This object is expected to have type < n : int > but actually has type
 
386
         < m : 'a >
 
387
       The second object type has no method n
 
388
#         Characters 66-124:
 
389
      object (self: 's) method x = 3 method private m = self end
 
390
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
391
Error: This object is expected to have type < x : int; .. >
 
392
       but actually has type < x : int >
 
393
       Self type cannot be unified with a closed object type
 
394
#         val o : < x : int > = <obj>
 
395
#         Characters 76-77:
 
396
    (x : <m : 'a. 'a * (<m:'b. 'a * <m:'c. 'c * 'bar> > as 'bar) >);;
 
397
     ^
 
398
Error: This expression has type < m : 'b. 'b * < m : 'b * 'a > > as 'a
 
399
       but an expression was expected of type
 
400
         < m : 'b. 'b * (< m : 'b * < m : 'd. 'd * 'c > > as 'c) >
 
401
       Types for method m are incompatible
 
402
#         Characters 176-177:
 
403
  let f (x : foo') = (x : bar');;
 
404
                      ^
 
405
Error: This expression has type foo' = < m : 'a. 'a * 'a foo >
 
406
       but an expression was expected of type bar' = < m : 'a. 'a * 'a bar >
 
407
       Type 'a foo = < m : 'a * 'a foo > is not compatible with type
 
408
         'a bar = < m : 'a * < m : 'b. 'b * 'a bar > > 
 
409
       Type 'a foo = < m : 'a * 'a foo > is not compatible with type
 
410
         < m : 'b. 'b * 'a bar > 
 
411
       Types for method m are incompatible
 
412
#     Characters 67-68:
 
413
    (x : <m : 'b. 'b * ('b * <m : 'c. 'c * ('c * 'bar)>)> as 'bar);;
 
414
     ^
 
415
Error: This expression has type
 
416
         < m : 'a. 'a * ('a * < m : 'c. 'c * 'b > as 'b) >
 
417
       but an expression was expected of type
 
418
         < m : 'a. 'a * ('a * < m : 'c. 'c * ('c * 'd) >) > as 'd
 
419
       Types for method m are incompatible
 
420
#   Characters 66-67:
 
421
    (x : <m : 'b. 'b * ('b * <m : 'c. 'c * ('b * 'bar)>)> as 'bar);;
 
422
     ^
 
423
Error: This expression has type
 
424
         < m : 'a. 'a * ('a * < m : 'c. 'c * 'b > as 'b) >
 
425
       but an expression was expected of type
 
426
         < m : 'a. 'a * ('a * < m : 'c. 'c * ('a * 'd) >) > as 'd
 
427
       Types for method m are incompatible
 
428
#   Characters 51-52:
 
429
    (x : <m : 'b. 'b * ('b * <m:'c. 'c * 'bar> as 'bar)>);;
 
430
     ^
 
431
Error: This expression has type < m : 'b. 'b * ('b * 'a) > as 'a
 
432
       but an expression was expected of type
 
433
         < m : 'b. 'b * ('b * < m : 'd. 'd * 'c > as 'c) >
 
434
       Types for method m are incompatible
 
435
#     Characters 14-115:
 
436
  ....(x : <m : 'a. 'a -> ('a * <m:'c. 'c -> 'bar> as 'bar)>
 
437
         :> <m : 'a. 'a -> ('a * 'foo)> as 'foo)..
 
438
Error: Type < m : 'a. 'a -> ('a * (< m : 'd. 'd -> 'b as 'e > as 'c) as 'b) >
 
439
       is not a subtype of < m : 'a. 'a -> ('a * 'f as 'h) as 'g > as 'f 
 
440
#       Characters 88-150:
 
441
  = struct let f (x : <m : 'a. 'a * ('a * 'foo)> as 'foo) = () end;;
 
442
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
443
Error: Signature mismatch:
 
444
       Modules do not match:
 
445
         sig val f : (< m : 'b. 'b * ('b * 'a) > as 'a) -> unit end
 
446
       is not included in
 
447
         sig
 
448
           val f : < m : 'a. 'a * ('a * < m : 'c. 'c * 'b > as 'b) > -> unit
 
449
         end
 
450
       Values do not match:
 
451
         val f : (< m : 'b. 'b * ('b * 'a) > as 'a) -> unit
 
452
       is not included in
 
453
         val f : < m : 'a. 'a * ('a * < m : 'c. 'c * 'b > as 'b) > -> unit
 
454
#     Characters 78-132:
 
455
  = struct type t = <m : 'a. 'a * ('a * 'foo)> as 'foo end;;
 
456
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
457
Error: Signature mismatch:
 
458
       Modules do not match:
 
459
         sig type t = < m : 'b. 'b * ('b * 'a) > as 'a end
 
460
       is not included in
 
461
         sig type t = < m : 'a. 'a * ('a * < m : 'c. 'c * 'b > as 'b) > end
 
462
       Type declarations do not match:
 
463
         type t = < m : 'b. 'b * ('b * 'a) > as 'a
 
464
       is not included in
 
465
         type t = < m : 'a. 'a * ('a * < m : 'c. 'c * 'b > as 'b) >
 
466
#     module M : sig type 'a t type u = < m : 'a. 'a t > end
 
467
#   module M : sig type 'a t val f : < m : 'a. 'a t > -> int end
 
468
#     module M : sig type 'a t val f : < m : 'a. 'a t > -> int end
 
469
#         val f :
 
470
  (< m : 'b. 'b -> (< m : 'b. 'b -> 'c * <  > > as 'c) * < .. >; .. > as 'a) ->
 
471
  'a -> bool = <fun>
 
472
#         type t = [ `A | `B ]
 
473
# type v = private [> t ]
 
474
# - : t -> v = <fun>
 
475
# type u = private [< t ]
 
476
# - : u -> v = <fun>
 
477
# Characters 9-21:
 
478
  fun x -> (x : v :> u);;
 
479
           ^^^^^^^^^^^^
 
480
Error: Type v = [> `A | `B ] is not a subtype of u = [< `A | `B ] 
 
481
# type v = private [< t ]
 
482
# Characters 9-21:
 
483
  fun x -> (x : u :> v);;
 
484
           ^^^^^^^^^^^^
 
485
Error: Type u = [< `A | `B ] is not a subtype of v = [< `A | `B ] 
 
486
# type p = < x : p >
 
487
# type q = private < x : p; .. >
 
488
# - : q -> p = <fun>
 
489
# Characters 9-21:
 
490
  fun x -> (x : p :> q);;
 
491
           ^^^^^^^^^^^^
 
492
Error: Type p = < x : p > is not a subtype of q = < x : p; .. > 
 
493
#       Characters 14-100:
 
494
  ..(x : <m:'a. (<p:int;..> as 'a) -> int>
 
495
      :> <m:'b. (<p:int;q:int;..> as 'b) -> int>)..
 
496
Error: Type < m : 'a. (< p : int; .. > as 'a) -> int > is not a subtype of
 
497
         < m : 'b. (< p : int; q : int; .. > as 'b) -> int > 
 
498
#     val f2 :
 
499
  < m : 'a. (< p : < a : int >; .. > as 'a) -> int > ->
 
500
  < m : 'a. (< p : < a : int; b : int >; .. > as 'a) -> int > = <fun>
 
501
#     Characters 13-107:
 
502
  ..(x : <m:'a. (<p:<a:int;b:int>;..> as 'a) -> int>
 
503
      :> <m:'b. (<p:<a:int>;..> as 'b) -> int>)..
 
504
Error: Type < m : 'a. (< p : < a : int; b : int >; .. > as 'a) -> int >
 
505
       is not a subtype of < m : 'a. (< p : < a : int >; .. > as 'a) -> int > 
 
506
# Characters 11-55:
 
507
  let f4 x = (x : <p:<a:int;b:int>;..> :> <p:<a:int>;..>);;
 
508
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
509
Error: Type < p : < a : int; b : int >; .. > is not a subtype of
 
510
         < p : < a : int >; .. > 
 
511
The second object type has no method b
 
512
#   val f5 :
 
513
  < m : 'a. [< `A of < p : int > ] as 'a > ->
 
514
  < m : 'a. [< `A of <  > ] as 'a > = <fun>
 
515
#   Characters 13-83:
 
516
    (x : <m:'a. [< `A of < > ] as 'a> :> <m:'a. [< `A of <p:int> ] as 'a>);;
 
517
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
518
Error: Type < m : 'a. [< `A of <  > ] as 'a > is not a subtype of
 
519
         < m : 'a. [< `A of < p : int > ] as 'a > 
 
520
#     class c : object method id : 'a -> 'a end
 
521
# type u = c option
 
522
# val just : 'a option -> 'a = <fun>
 
523
# val f : c -> 'a -> 'a = <fun>
 
524
#     val g : c -> 'a -> 'a = <fun>
 
525
#     val h : < id : 'a; .. > -> 'a = <fun>
 
526
#       val f : 'a -> int = <fun>
 
527
val g : 'a -> int = <fun>
 
528
# type 'a t = Leaf of 'a | Node of ('a * 'a) t
 
529
#   val depth : 'a t -> int = <fun>
 
530
#     Characters 34-74:
 
531
    function Leaf _ -> 1 | Node x -> 1 + d x
 
532
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
533
Error: This definition has type 'a t -> int which is less general than
 
534
         'b. 'b t -> int
 
535
#   Characters 34-78:
 
536
    function Leaf x -> x | Node x -> 1 + depth x;; (* fails *)
 
537
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
538
Error: This definition has type int t -> int which is less general than
 
539
         'a. 'a t -> int
 
540
#   Characters 34-74:
 
541
    function Leaf x -> x | Node x -> depth x;; (* fails *)
 
542
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
543
Error: This definition has type 'a t -> 'a which is less general than
 
544
         'b. 'b t -> 'a
 
545
#   Characters 38-78:
 
546
    function Leaf x -> x | Node x -> depth x;; (* fails *)
 
547
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
548
Error: This definition has type 'a. 'a t -> 'a which is less general than
 
549
         'b 'c. 'c t -> 'b
 
550
#   val r : 'a list * '_b list ref = ([], {contents = []})
 
551
val q : unit -> 'a list * '_b list ref = <fun>
 
552
# val f : 'a -> 'a = <fun>
 
553
# val zero : [> `B of 'a | `Int of int ] as 'a = `Int 0
 
554
# Characters 39-45:
 
555
  let zero : 'a. [< `Int of int] as 'a = `Int 0;; (* fails *)
 
556
                                         ^^^^^^
 
557
Error: This expression has type [> `Int of int ]
 
558
       but an expression was expected of type [< `Int of int ]
 
559
       Types for tag `Int are incompatible
 
560
#       type t = { f : 'a. [> `B of 'a | `Int of int ] as 'a; }
 
561
val zero : t = {f = `Int 0}
 
562
#   Characters 56-62:
 
563
  let zero = {f = `Int 0} ;; (* fails *)
 
564
                  ^^^^^^
 
565
Error: This expression has type [> `Int of int ]
 
566
       but an expression was expected of type [< `Int of int ]
 
567
       Types for tag `Int are incompatible
 
568
#       val id : 'a -> 'a = <fun>
 
569
val neg : int -> bool -> int * bool = <fun>
 
570
#                         type t = A of int | B of (int * t) list | C of (string * t) list
 
571
val transf : (int -> t) -> t -> t = <fun>
 
572
val transf_alist : (int -> t) -> ('a * t) list -> ('a * t) list = <fun>
 
573
#         type t = { f : 'a. ('a list -> int) Lazy.t; }
 
574
val l : t = {f = <lazy>}
 
575
#     type t = { f : 'a. 'a -> unit; }
 
576
# - : t = {f = <fun>}
 
577
# Characters 3-16:
 
578
  {f=fun ?x y -> y};; (* fail *)
 
579
     ^^^^^^^^^^^^^
 
580
Error: This field value has type unit -> unit which is less general than
 
581
         'a. 'a -> unit
 
582