@@ -41,23 +41,23 @@ val test_lambda : Int.t -> Int.t = <fun>
41
41
let alpha_equiv (f : {A : Add} -> A.t -> A.t ) : {T : Add} -> T.t -> T.t = f
42
42
43
43
[%% expect{|
44
- val alpha_equiv : ({A : Add } -> A .t -> A .t ) -> {T : Add } -> T .t -> T .t =
44
+ val alpha_equiv : ({A : Add } -> A .t -> A .t ) -> ( {T : Add } -> T .t -> T .t ) =
45
45
< fun>
46
46
|}]
47
47
48
48
let apply_weird {M : Typ} (f : {M : Typ} -> _ ) (x : M.t ) : M.t = f {M } x
49
49
50
50
[%% expect{|
51
- val apply_weird : { M : Typ } -> ({ M : Typ } -> M / 2. t -> M / 2. t) -> M .t -> M .t =
52
- < fun>
51
+ val apply_weird :
52
+ { M / 1 : Typ } -> ({ M / 2 : Typ } -> M / 1. t -> M / 1. t) -> M / 1. t -> M / 1. t = < fun>
53
53
|}]
54
54
55
55
(* Invalid arguments *)
56
56
57
57
let f x {M : Typ} (y : M.t ) = (x, y)
58
58
59
59
[%% expect{|
60
- val f : 'a -> {M : Typ } -> M .t -> 'a * M .t = < fun>
60
+ val f : 'a -> ( {M : Typ } -> M .t -> 'a * M .t ) = < fun>
61
61
|}]
62
62
63
63
let invalid_arg1 = f {Int }
@@ -66,7 +66,7 @@ let invalid_arg1 = f {Int}
66
66
Line 1 , characters 19-20 :
67
67
1 | let invalid_arg1 = f {Int }
68
68
^
69
- Error : This expression has type " 'a -> {M : Typ} -> M.t -> 'a * M.t"
69
+ Error : This expression has type 'a -> ( {M : Typ } -> M. t -> 'a * M. t)
70
70
But was applied to a module .
71
71
| }]
72
72
@@ -76,7 +76,7 @@ let invalid_arg2 = f 3 4 {Int}
76
76
Line 1 , characters 19-20 :
77
77
1 | let invalid_arg2 = f 3 4 {Int }
78
78
^
79
- Error : This expression has type " 'a -> {M : Typ} -> M.t -> 'a * M.t"
79
+ Error : This expression has type 'a -> ( {M : Typ } -> M. t -> 'a * M. t)
80
80
But was applied to an expression.
81
81
| }]
82
82
@@ -95,14 +95,14 @@ let apply_labelled_fail = labelled ~y:3
95
95
Line 1 , characters 26-34 :
96
96
1 | let apply_labelled_fail = labelled ~y: 3
97
97
^^^^^^^^
98
- Error : This expression has type " y:M.t -> M.t"
98
+ Error : This expression has type { M : Typ } -> y :M .t -> M .t
99
99
Received an expression argument . However , module arguments cannot be omitted .
100
100
|}]
101
101
102
102
let apply_opt (f : ?opt:int -> {M : Typ} -> M.t ) = f {Int }
103
103
104
104
[%% expect{|
105
- val apply_opt : (?opt:int -> {M : Typ } -> M .t ) -> Int .t = < fun>
105
+ val apply_opt : (?opt:int -> ( {M : Typ } -> M .t ) ) -> Int .t = < fun>
106
106
|}]
107
107
108
108
(* let f_labelled_marg ~{M : Typ} ~{N : Typ} (x : M.t) (y : N.t) = (y, x)
@@ -143,7 +143,7 @@ val map : {M : Map} -> ('a -> 'b) -> 'a M.t -> 'b M.t = <fun>
143
143
let s_list = map {List } string_of_int [3 ; 1 ; 4 ]
144
144
145
145
[%% expect{|
146
- val s_list : string List .t = [ "3" ; "1" ; "4" ]
146
+ val s_list : string List .t = List. (::) ( "3" , [ "1" ; "4" ])
147
147
|}]
148
148
149
149
let s_list : string list = s_list
@@ -167,7 +167,7 @@ module MapCombin :
167
167
val map : ('a -> 'b ) -> 'a M1 .t M2 .t -> 'b M1 .t M2 .t
168
168
end
169
169
val s_list_array : string MapCombin (List )(Array ).t =
170
- [|[ "3" ; "2" ]; [ "2" ]; []|]
170
+ [|List. (::) ( "3" , [ "2" ]); List. (::) ( "2" , []); List. []|]
171
171
|}]
172
172
173
173
@@ -240,10 +240,10 @@ let try_coerce (f : {A : Add} -> A.t -> A.t) : {T : Typ} -> T.t -> T.t = f
240
240
Line 1 , characters 73-74 :
241
241
1 | let try_coerce (f : {A : Add} -> A.t -> A.t ) : {T : Typ} -> T. t -> T. t = f
242
242
^
243
- Error : This expression has type " {A : Add} -> A.t -> A.t"
244
- but an expression was expected of type " {T : Typ} -> T.t -> T.t"
245
- The two module argument types differ by their runtime size.
243
+ Error : This expression has type {A : Add } -> A. t -> A. t
244
+ but an expression was expected of type {T : Typ } -> T. t -> T. t
246
245
| }]
246
+ (* The two module argument types differ by their runtime size. *)
247
247
248
248
249
249
(* Here the coercion requires computation and should? be forbidden *)
@@ -253,13 +253,13 @@ let try_coerce2 (f : {A : AddSub} -> A.t -> A.t) = (f :> ({T : SubAdd} -> T.t ->
253
253
Line 1 , characters 51-86 :
254
254
1 | let try_coerce2 (f : {A : AddSub} -> A.t -> A.t ) = (f :> ({T : SubAdd} -> T.t -> T.t) )
255
255
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
256
- Error : Type "{A : AddSub} -> A.t -> A.t" is not a subtype of
257
- "{T : SubAdd} -> T.t -> T.t"
258
- The two module argument types do not share
259
- the same positions for runtime components .
260
- For example , the value "add" occurs at the expected position of
261
- the value "sub" .
256
+ Error : Type {A : AddSub} -> A. t -> A. t is not a subtype of
257
+ {T : SubAdd } -> T. t -> T. t
262
258
| }]
259
+ (* The two module argument types do not share
260
+ the same positions for runtime components.
261
+ For example, the value add occurs at the expected position of
262
+ the value sub. *)
263
263
264
264
265
265
(* Here the coercion does not require any computation and thus could be allowed *)
@@ -269,10 +269,10 @@ let try_coerce3 (f : {A : Add} -> A.t -> A.t) = (f :> {T : Typ} -> T.t -> T.t)
269
269
Line 1 , characters 48-78 :
270
270
1 | let try_coerce3 (f : {A : Add} -> A.t -> A.t ) = (f :> {T : Typ} -> T.t -> T.t )
271
271
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
272
- Error : Type "{A : Add} -> A.t -> A.t" is not a subtype of
273
- "{T : Typ} -> T.t -> T.t"
274
- The two module argument types differ by their runtime size .
272
+ Error : Type {A : Add} -> A. t -> A. t is not a subtype of
273
+ {T : Typ } -> T. t -> T. t
275
274
| }]
275
+ (* The two module argument types differ by their runtime size. *)
276
276
277
277
module type Add2 = sig
278
278
type a
@@ -304,22 +304,27 @@ let try_coerce4 (f : {A : Add2} -> A.t -> A.t) : {A : Add} -> A.t -> A.t = f
304
304
Line 1 , characters 75-76 :
305
305
1 | let try_coerce4 (f : {A : Add2} -> A.t -> A.t ) : {A : Add} -> A. t -> A. t = f
306
306
^
307
- Error : This expression has type " {A : Add2} -> A.t -> A.t "
308
- but an expression was expected of type " {A : Add} -> A.t -> A.t "
309
- Modules do not match : Add is not included in Add2
310
- The type "a" is required but not provided
307
+ Error : This expression has type { A / 1 : Add2 } -> A / 1 . t -> A / 1. t
308
+ but an expression was expected of type { A / 2 : Add } -> A / 2 . t -> A / 2. t
309
+ File " _none_ " , line 1 :
310
+ Definition of module A / 2
311
311
| }]
312
+ (* Modules do not match: Add is not included in Add2
313
+ The type a is required but not provided *)
312
314
313
315
let coerce5 (f : {A : Add2} -> A.t -> A.t ) = (f :> {A : Add} -> A.t -> A.t )
314
316
315
317
let try_coerce6 (f : {A : Add2} -> A.t -> A.t ) : {A : Add3} -> A.t -> A.t = f
316
318
let try_coerce7 (f : {A : Add2} -> A.t -> A.t ) : {A : Add4} -> A.t -> A.t = f
317
319
318
320
[%% expect{|
319
- val coerce5 : ({A : Add2 } -> A .t -> A .t ) -> {A : Add } -> A .t -> A .t = < fun>
320
- val try_coerce6 : ({A : Add2 } -> A .t -> A .t ) -> {A : Add3 } -> A .t -> A .t =
321
+ val coerce5 :
322
+ ({A / 1 : Add2 } -> A / 1. t -> A / 1. t) -> ({A / 2 : Add } -> A / 2. t -> A / 2. t) = < fun>
323
+ val try_coerce6 :
324
+ ({A / 1 : Add2 } -> A / 1. t -> A / 1. t) -> ({A / 2 : Add3 } -> A / 2. t -> A / 2. t) =
321
325
< fun>
322
- val try_coerce7 : ({A : Add2 } -> A .t -> A .t ) -> {A : Add4 } -> A .t -> A .t =
326
+ val try_coerce7 :
327
+ ({A / 1 : Add2 } -> A / 1. t -> A / 1. t) -> ({A / 2 : Add4 } -> A / 2. t -> A / 2. t) =
323
328
< fun>
324
329
|}]
325
330
@@ -343,8 +348,8 @@ let apply_with_annot f {T : Typ} (x : T.t) : T.t =
343
348
let merge_no_mod (type a ) (x : a ) (y : a ) = x
344
349
345
350
[%% expect{|
346
- val apply_with_annot : ({ T : Typ } -> T .t -> T .t ) -> { T : Typ } -> T .t -> T .t =
347
- < fun>
351
+ val apply_with_annot :
352
+ ({ T / 1 : Typ } -> T / 1. t -> T / 1. t) -> ({ T / 2 : Typ } -> T / 2. t -> T / 2. t) = < fun>
348
353
val merge_no_mod : 'a -> 'a -> 'a = < fun>
349
354
|}]
350
355
@@ -368,8 +373,8 @@ let apply_small_annot2 (f : {T : Typ} -> T.t -> T.t) g {T : Typ} x =
368
373
369
374
[%% expect{|
370
375
val apply_small_annot2 :
371
- ({T : Typ } -> T .t -> T .t ) ->
372
- ({T : Typ } -> T .t -> T .t ) -> { T : Typ } -> T .t -> T .t = < fun>
376
+ ({T / 1 : Typ } -> T / 1 . t -> T / 1 . t) ->
377
+ ({T / 1 : Typ } -> T / 1 . t -> T / 1 . t) -> ({ T / 2 : Typ } -> T / 2 . t -> T / 2. t) = < fun>
373
378
|}]
374
379
375
380
@@ -410,9 +415,9 @@ val r : '_weak1 option ref = {contents = None}
410
415
Line 6 , characters 12-13 :
411
416
6 | r := Some x
412
417
^
413
- Error : This expression has type " T.t" but an expression was expected of type
414
- " 'weak1"
415
- The type constructor " T.t" would escape its scope
418
+ Error : This expression has type T. t but an expression was expected of type
419
+ 'weak1
420
+ The type constructor T. t would escape its scope
416
421
| }]
417
422
418
423
@@ -422,8 +427,8 @@ let f x {A : Add} (y : A.t) = A.add x y
422
427
Line 1 , characters 36-37 :
423
428
1 | let f x {A : Add} (y : A.t ) = A. add x y
424
429
^
425
- Error : This expression has type " 'a " but an expression was expected of type " A.t"
426
- The type constructor " A.t" would escape its scope
430
+ Error : This expression has type 'a but an expression was expected of type A. t
431
+ The type constructor A. t would escape its scope
427
432
| }]
428
433
429
434
let f (x : {T : Typ} -> _ ) : {T : Typ} -> T.t = x
@@ -432,9 +437,11 @@ let f (x : {T : Typ} -> _) : {T : Typ} -> T.t = x
432
437
Line 1 , characters 48-49 :
433
438
1 | let f (x : {T : Typ} -> _ ) : {T : Typ} -> T. t = x
434
439
^
435
- Error : This expression has type " {T : Typ} -> 'a"
436
- but an expression was expected of type " {T : Typ} -> T.t"
437
- The module " T" would escape its scope
440
+ Error : This expression has type {T / 1 : Typ } -> 'a
441
+ but an expression was expected of type {T / 2 : Typ } -> T / 2. t
442
+ The module T would escape its scope
443
+ File " _none_" , line 1 :
444
+ Definition of module T / 2
438
445
| }]
439
446
440
447
@@ -568,8 +575,8 @@ let rec m = map {List} (fun x -> x) [3]
568
575
and g = 3 :: m
569
576
570
577
[%% expect{|
571
- val m : int List .t = [ 3 ]
572
- val m : int List .t = [ 3 ]
578
+ val m : int List .t = List. (::) ( 3 , [])
579
+ val m : int List .t = List. (::) ( 3 , [])
573
580
val g : int list = [3 ; 3 ]
574
581
|}]
575
582
0 commit comments