forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 1
/
functors.ml
1747 lines (1638 loc) · 52.7 KB
/
functors.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* TEST
* expect
*)
module type a
module type b
module type c
module type x = sig type x end
module type y = sig type y end
module type z = sig type z end
module type empty = sig end
module Empty = struct end
module X: x = struct type x end
module Y: y = struct type y end
module Z: z = struct type z end
module F(X:x)(Y:y)(Z:z) = struct end
[%%expect {|
module type a
module type b
module type c
module type x = sig type x end
module type y = sig type y end
module type z = sig type z end
module type empty = sig end
module Empty : sig end
module X : x
module Y : y
module Z : z
module F : functor (X : x) (Y : y) (Z : z) -> sig end
|}]
module M = F(X)(Z)
[%%expect {|
Line 1, characters 11-18:
1 | module M = F(X)(Z)
^^^^^^^
Error: The functor application is ill-typed.
These arguments:
X Z
do not match these parameters:
functor (X : x) (Y : y) (Z : z) -> ...
1. Module X matches the expected module type x
2. An argument appears to be missing with module type y
3. Module Z matches the expected module type z
|}]
module type f = functor (X:empty)(Y:empty) -> empty
module F: f =
functor(X:empty)(Y:empty)(Z:empty) -> Empty
[%%expect {|
module type f = functor (X : empty) (Y : empty) -> empty
Line 3, characters 9-45:
3 | functor(X:empty)(Y:empty)(Z:empty) -> Empty
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
Modules do not match:
functor (X : empty) (Y : empty) (Z : empty) -> ...
is not included in
functor (X : empty) (Y : empty) -> ...
1. Module types empty and empty match
2. Module types empty and empty match
3. An extra argument is provided of module type empty
|}]
module type f = functor (X:a)(Y:b) -> c
module F:f = functor (X:a)(Y:b)(Z:c) -> Empty
[%%expect {|
module type f = functor (X : a) (Y : b) -> c
Line 2, characters 21-45:
2 | module F:f = functor (X:a)(Y:b)(Z:c) -> Empty
^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
Modules do not match:
functor (X : a) (Y : b) (Z : c) -> ...
is not included in
functor (X : a) (Y : b) -> ...
1. Module types a and a match
2. Module types b and b match
3. An extra argument is provided of module type c
|}]
module M : sig module F: functor (X:sig end) -> sig end end =
struct
module F(X:sig type t end) = struct end
end
[%%expect {|
Lines 2-4, characters 2-5:
2 | ..struct
3 | module F(X:sig type t end) = struct end
4 | end
Error: Signature mismatch:
Modules do not match:
sig module F : functor (X : sig type t end) -> sig end end
is not included in
sig module F : functor (X : sig end) -> sig end end
In module F:
Modules do not match:
functor (X : $S1) -> ...
is not included in
functor (X : sig end) -> ...
Module types do not match:
$S1 = sig type t end
does not include
sig end
The type `t' is required but not provided
|}]
module F(X:sig type t end) = struct end
module M = F(struct type x end)
[%%expect {|
module F : functor (X : sig type t end) -> sig end
Line 2, characters 11-31:
2 | module M = F(struct type x end)
^^^^^^^^^^^^^^^^^^^^
Error: Modules do not match: sig type x end is not included in sig type t end
The type `t' is required but not provided
|}]
module F(X:sig type x end)(Y:sig type y end)(Z:sig type z end) = struct
type t = X of X.x | Y of Y.y | Z of Z.z
end
type u = F(X)(Z).t
[%%expect {|
module F :
functor (X : sig type x end) (Y : sig type y end) (Z : sig type z end) ->
sig type t = X of X.x | Y of Y.y | Z of Z.z end
Line 4, characters 9-18:
4 | type u = F(X)(Z).t
^^^^^^^^^
Error: The functor application F(X)(Z) is ill-typed.
These arguments:
X Z
do not match these parameters:
functor (X : ...) (Y : $T2) (Z : ...) -> ...
1. Module X matches the expected module type
2. An argument appears to be missing with module type
$T2 = sig type y end
3. Module Z matches the expected module type
|}]
module F()(X:sig type t end) = struct end
module M = F()()
[%%expect {|
module F : functor () (X : sig type t end) -> sig end
Line 2, characters 11-16:
2 | module M = F()()
^^^^^
Error: The functor application is ill-typed.
These arguments:
() ()
do not match these parameters:
functor () (X : $T2) -> ...
1. Module () matches the expected module type
2. The functor was expected to be applicative at this position
|}]
module M: sig
module F: functor(X:sig type x end)(X:sig type y end) -> sig end
end = struct
module F(X:sig type y end) = struct end
end
[%%expect {|
Lines 3-5, characters 6-3:
3 | ......struct
4 | module F(X:sig type y end) = struct end
5 | end
Error: Signature mismatch:
Modules do not match:
sig module F : functor (X : sig type y end) -> sig end end
is not included in
sig
module F :
functor (X : sig type x end) (X : sig type y end) -> sig end
end
In module F:
Modules do not match:
functor (X : $S2) -> ...
is not included in
functor (X : $T1) (X : $T2) -> ...
1. An argument appears to be missing with module type
$T1 = sig type x end
2. Module types $S2 and $T2 match
|}]
module F(Ctx: sig
module type t
module type u
module X:t
module Y:u
end) = struct
open Ctx
module F(A:t)(B:u) = struct end
module M = F(Y)(X)
end
[%%expect {|
Line 9, characters 13-20:
9 | module M = F(Y)(X)
^^^^^^^
Error: The functor application is ill-typed.
These arguments:
Ctx.Y Ctx.X
do not match these parameters:
functor (A : Ctx.t) (B : Ctx.u) -> ...
1. Modules do not match: Ctx.Y : Ctx.u is not included in Ctx.t
2. Modules do not match: Ctx.X : Ctx.t is not included in Ctx.u
|}]
(** Too many arguments *)
module Ord = struct type t = unit let compare _ _ = 0 end
module M = Map.Make(Ord)(Ord)
[%%expect {|
module Ord : sig type t = unit val compare : 'a -> 'b -> int end
Line 2, characters 11-29:
2 | module M = Map.Make(Ord)(Ord)
^^^^^^^^^^^^^^^^^^
Error: The functor application is ill-typed.
These arguments:
Ord Ord
do not match these parameters:
functor (Ord : Map.OrderedType) -> ...
1. The following extra argument is provided
Ord : sig type t = unit val compare : 'a -> 'b -> int end
2. Module Ord matches the expected module type Map.OrderedType
|}]
(** Dependent types *)
(** Application side *)
module F
(A:sig type x type y end)
(B:sig type x = A.x end)
(C:sig type y = A.y end)
= struct end
module K = struct include X include Y end
module M = F(K)(struct type x = K.x end)( (* struct type z = K.y end *) )
[%%expect {|
module F :
functor (A : sig type x type y end) (B : sig type x = A.x end)
(C : sig type y = A.y end) -> sig end
module K : sig type x = X.x type y = Y.y end
Line 10, characters 11-73:
10 | module M = F(K)(struct type x = K.x end)( (* struct type z = K.y end *) )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The functor application is ill-typed.
These arguments:
K $S2 ()
do not match these parameters:
functor (A : ...) (B : ...) (C : $T3) -> ...
1. Module K matches the expected module type
2. Module $S2 matches the expected module type
3. The functor was expected to be applicative at this position
|}]
module M = F(K)(struct type y = K.y end)
[%%expect {|
Line 1, characters 11-40:
1 | module M = F(K)(struct type y = K.y end)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The functor application is ill-typed.
These arguments:
K $S3
do not match these parameters:
functor (A : ...) (B : $T2) (C : ...) -> ...
1. Module K matches the expected module type
2. An argument appears to be missing with module type
$T2 = sig type x = A.x end
3. Module $S3 matches the expected module type
|}]
module M =
F
(struct include X include Y end)
(struct type x = K.x end)
(struct type yy = K.y end)
[%%expect {|
Lines 2-5, characters 2-30:
2 | ..F
3 | (struct include X include Y end)
4 | (struct type x = K.x end)
5 | (struct type yy = K.y end)
Error: The functor application is ill-typed.
These arguments:
$S1 $S2 $S3
do not match these parameters:
functor (A : ...) (B : ...) (C : $T3) -> ...
1. Module $S1 matches the expected module type
2. Module $S2 matches the expected module type
3. Modules do not match:
$S3 : sig type yy = K.y end
is not included in
$T3 = sig type y = A.y end
The type `y' is required but not provided
|}]
module M = struct
module N = struct
type x
type y
end
end
module Defs = struct
module X = struct type x = M.N.x end
module Y = struct type y = M.N.y end
end
module Missing_X = F(M.N)(Defs.Y)
[%%expect {|
module M : sig module N : sig type x type y end end
module Defs :
sig module X : sig type x = M.N.x end module Y : sig type y = M.N.y end end
Line 13, characters 19-33:
13 | module Missing_X = F(M.N)(Defs.Y)
^^^^^^^^^^^^^^
Error: The functor application is ill-typed.
These arguments:
M.N Defs.Y
do not match these parameters:
functor (A : ...) (B : $T2) (C : ...) -> ...
1. Module M.N matches the expected module type
2. An argument appears to be missing with module type
$T2 = sig type x = A.x end
3. Module Defs.Y matches the expected module type
|}]
module Too_many_Xs = F(M.N)(Defs.X)(Defs.X)(Defs.Y)
[%%expect {|
Line 1, characters 21-51:
1 | module Too_many_Xs = F(M.N)(Defs.X)(Defs.X)(Defs.Y)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The functor application is ill-typed.
These arguments:
M.N Defs.X Defs.X Defs.Y
do not match these parameters:
functor (A : ...) (B : ...) (C : ...) -> ...
1. Module M.N matches the expected module type
2. The following extra argument is provided
Defs.X : sig type x = M.N.x end
3. Module Defs.X matches the expected module type
4. Module Defs.Y matches the expected module type
|}]
module X = struct type x = int end
module Y = struct type y = float end
module Missing_X_bis = F(struct type x = int type y = float end)(Y)
[%%expect {|
module X : sig type x = int end
module Y : sig type y = float end
Line 3, characters 23-67:
3 | module Missing_X_bis = F(struct type x = int type y = float end)(Y)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The functor application is ill-typed.
These arguments:
$S1 Y
do not match these parameters:
functor (A : ...) (B : $T2) (C : ...) -> ...
1. Module $S1 matches the expected module type
2. An argument appears to be missing with module type
$T2 = sig type x = A.x end
3. Module Y matches the expected module type
|}]
module Too_many_Xs_bis = F(struct type x = int type y = float end)(X)(X)(Y)
[%%expect {|
Line 1, characters 25-75:
1 | module Too_many_Xs_bis = F(struct type x = int type y = float end)(X)(X)(Y)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The functor application is ill-typed.
These arguments:
$S1 X X Y
do not match these parameters:
functor (A : ...) (B : ...) (C : ...) -> ...
1. Module $S1 matches the expected module type
2. The following extra argument is provided X : sig type x = int end
3. Module X matches the expected module type
4. Module Y matches the expected module type
|}]
(** Inclusion side *)
module type f =
functor(A:sig type x type y end)(B:sig type x = A.x end)(C:sig type y = A.y end)
-> sig end
module F: f = functor (A:sig include x include y end)(Z:sig type y = A.y end) -> struct end
[%%expect {|
module type f =
functor (A : sig type x type y end) (B : sig type x = A.x end)
(C : sig type y = A.y end) -> sig end
Line 4, characters 22-91:
4 | module F: f = functor (A:sig include x include y end)(Z:sig type y = A.y end) -> struct end
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
Modules do not match:
functor (A : $S1) (Z : $S3) -> ...
is not included in
functor (A : $T1) (B : $T2) (C : $T3) -> ...
1. Module types $S1 and $T1 match
2. An argument appears to be missing with module type
$T2 = sig type x = A.x end
3. Module types $S3 and $T3 match
|}]
module type f =
functor(B:sig type x type y type u=x type v=y end)(Y:sig type yu = Y of B.u end)(Z:sig type zv = Z of B.v end)
-> sig end
module F: f = functor (X:sig include x include y end)(Z:sig type zv = Z of X.y end) -> struct end
[%%expect {|
module type f =
functor (B : sig type x type y type u = x type v = y end)
(Y : sig type yu = Y of B.u end) (Z : sig type zv = Z of B.v end) ->
sig end
Line 4, characters 22-97:
4 | module F: f = functor (X:sig include x include y end)(Z:sig type zv = Z of X.y end) -> struct end
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
Modules do not match:
functor (X : $S1) (Z : $S3) -> ...
is not included in
functor (B : $T1) (Y : $T2) (Z : $T3) -> ...
1. Module types $S1 and $T1 match
2. An argument appears to be missing with module type
$T2 = sig type yu = Y of B.u end
3. Module types $S3 and $T3 match
|}]
(** Module type equalities *)
module M: sig
module type S = sig type t end
end = struct
module type S = sig type s type t end
end;;
[%%expect {|
Lines 5-7, characters 6-3:
5 | ......struct
6 | module type S = sig type s type t end
7 | end..
Error: Signature mismatch:
Modules do not match:
sig module type S = sig type s type t end end
is not included in
sig module type S = sig type t end end
Module type declarations do not match:
module type S = sig type s type t end
does not match
module type S = sig type t end
The second module type is not included in the first
At position module type S = <here>
Module types do not match:
sig type t end
is not equal to
sig type s type t end
At position module type S = <here>
The type `s' is required but not provided
|}]
module M: sig
module type S = sig type t type u end
end = struct
module type S = sig type t end
end;;
[%%expect {|
Lines 3-5, characters 6-3:
3 | ......struct
4 | module type S = sig type t end
5 | end..
Error: Signature mismatch:
Modules do not match:
sig module type S = sig type t end end
is not included in
sig module type S = sig type t type u end end
Module type declarations do not match:
module type S = sig type t end
does not match
module type S = sig type t type u end
The first module type is not included in the second
At position module type S = <here>
Module types do not match:
sig type t end
is not equal to
sig type t type u end
At position module type S = <here>
The type `u' is required but not provided
|}]
(** Name collision test *)
module F(X:x)(B:b)(Y:y) = struct type t end
module M = struct
module type b
module G(P: sig module B:b end) = struct
open P
module U = F(struct type x end)(B)(struct type w end)
end
end
[%%expect {|
module F : functor (X : x) (B : b) (Y : y) -> sig type t end
Line 8, characters 15-57:
8 | module U = F(struct type x end)(B)(struct type w end)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The functor application is ill-typed.
These arguments:
$S1 P.B $S3
do not match these parameters:
functor (X : x) (B : b/2) (Y : y) -> ...
1. Module $S1 matches the expected module type x
2. Modules do not match:
P.B : b/1
is not included in
b/2
Line 5, characters 2-15:
Definition of module type b/1
Line 2, characters 0-13:
Definition of module type b/2
3. Modules do not match: $S3 : sig type w end is not included in y
|}]
module F(X:a) = struct type t end
module M = struct
module type a
module G(P: sig module X:a end) = struct
open P
type t = F(X).t
end
end
[%%expect {|
module F : functor (X : a) -> sig type t end
Line 6, characters 13-19:
6 | type t = F(X).t
^^^^^^
Error: Modules do not match: a/1 is not included in a/2
Line 3, characters 2-15:
Definition of module type a/1
Line 1, characters 0-13:
Definition of module type a/2
|}]
module M: sig module F: functor(X:a)(Y:a) -> sig end end =
struct
module type aa = a
module type a
module F(X:aa)(Y:a) = struct end
end
[%%expect {|
Lines 2-6, characters 1-3:
2 | .struct
3 | module type aa = a
4 | module type a
5 | module F(X:aa)(Y:a) = struct end
6 | end
Error: Signature mismatch:
Modules do not match:
sig
module type aa = a
module type a
module F : functor (X : aa) (Y : a) -> sig end
end
is not included in
sig module F : functor (X : a) (Y : a) -> sig end end
In module F:
Modules do not match:
functor (X : aa) (Y : a/1) -> ...
is not included in
functor (X : a/2) (Y : a/2) -> ...
1. Module types aa and a/2 match
2. Module types do not match:
a/1
does not include
a/2
Line 4, characters 2-15:
Definition of module type a/1
Line 1, characters 0-13:
Definition of module type a/2
|}]
module X: functor ( X: sig end) -> sig end = functor(X: Set.OrderedType) -> struct end
[%%expect {|
Line 1, characters 52-86:
1 | module X: functor ( X: sig end) -> sig end = functor(X: Set.OrderedType) -> struct end
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
Modules do not match:
functor (X : Set.OrderedType) -> ...
is not included in
functor (X : sig end) -> ...
Module types do not match:
Set.OrderedType
does not include
sig end
The type `t' is required but not provided
File "set.mli", line 52, characters 4-10: Expected declaration
The value `compare' is required but not provided
File "set.mli", line 55, characters 4-31: Expected declaration
|}]
(** Deeply nested errors *)
module M: sig
module F: functor
(X:
functor(A: sig type xa end)(B:sig type xz end) -> sig end
)
(Y:
functor(A: sig type ya end)(B:sig type yb end) -> sig end
)
(Z:
functor(A: sig type za end)(B:sig type zb end) -> sig end
) -> sig end
end = struct
module F
(X:
functor (A: sig type xa end)(B:sig type xz end) -> sig end
)
(Y:
functor (A: sig type ya end)(B:sig type ybb end) -> sig end
)
(Z:
functor (A: sig type za end)(B:sig type zbb end) -> sig end
)
= struct end
end
[%%expect {|
Lines 15-27, characters 6-3:
15 | ......struct
16 | module F
17 | (X:
18 | functor (A: sig type xa end)(B:sig type xz end) -> sig end
19 | )
...
24 | functor (A: sig type za end)(B:sig type zbb end) -> sig end
25 | )
26 | = struct end
27 | end
Error: Signature mismatch:
Modules do not match:
sig
module F :
functor
(X : functor (A : sig type xa end) (B : sig type xz end) ->
sig end)
(Y : functor (A : sig type ya end) (B : sig type ybb end) ->
sig end)
(Z : functor (A : sig type za end) (B : sig type zbb end) ->
sig end)
-> sig end
end
is not included in
sig
module F :
functor
(X : functor (A : sig type xa end) (B : sig type xz end) ->
sig end)
(Y : functor (A : sig type ya end) (B : sig type yb end) ->
sig end)
(Z : functor (A : sig type za end) (B : sig type zb end) ->
sig end)
-> sig end
end
In module F:
Modules do not match:
functor (X : $S1) (Y : $S2) (Z : $S3) -> ...
is not included in
functor (X : $T1) (Y : $T2) (Z : $T3) -> ...
1. Module types $S1 and $T1 match
2. Module types do not match:
$S2 =
functor (A : sig type ya end) (B : sig type ybb end) -> sig end
does not include
$T2 =
functor (A : sig type ya end) (B : sig type yb end) -> sig end
Modules do not match:
functor (A : $S1) (B : $S2) -> ...
is not included in
functor (A : $T1) (B : $T2) -> ...
1. Module types $S1 and $T1 match
2. Module types do not match:
$S2 = sig type yb end
does not include
$T2 = sig type ybb end
The type `yb' is required but not provided
3. Module types do not match:
$S3 =
functor (A : sig type za end) (B : sig type zbb end) -> sig end
does not include
$T3 =
functor (A : sig type za end) (B : sig type zb end) -> sig end
Modules do not match:
functor (A : $S1) (B : $S2) -> ...
is not included in
functor (A : $T1) (B : $T2) -> ...
|}]
module M: sig
module F: functor
(X:
functor(A: sig type xa end)(B:sig type xz end) -> sig end
)
(Y:
functor(A: sig type ya end)(B:sig type yb end) -> sig end
)
(Z:
functor(A: sig type za end)(B:sig type zb end) -> sig end
) -> sig end
end = struct
module F
(X:
functor (A: sig type xa end)(B:sig type xz end) -> sig end
)
(Y:
functor (A: sig type ya end)(B:sig type yb end) -> sig end
)
= struct end
end
[%%expect {|
Lines 12-21, characters 6-3:
12 | ......struct
13 | module F
14 | (X:
15 | functor (A: sig type xa end)(B:sig type xz end) -> sig end
16 | )
17 | (Y:
18 | functor (A: sig type ya end)(B:sig type yb end) -> sig end
19 | )
20 | = struct end
21 | end
Error: Signature mismatch:
Modules do not match:
sig
module F :
functor
(X : functor (A : sig type xa end) (B : sig type xz end) ->
sig end)
(Y : functor (A : sig type ya end) (B : sig type yb end) ->
sig end)
-> sig end
end
is not included in
sig
module F :
functor
(X : functor (A : sig type xa end) (B : sig type xz end) ->
sig end)
(Y : functor (A : sig type ya end) (B : sig type yb end) ->
sig end)
(Z : functor (A : sig type za end) (B : sig type zb end) ->
sig end)
-> sig end
end
In module F:
Modules do not match:
functor (X : $S1) (Y : $S2) -> ...
is not included in
functor (X : $T1) (Y : $T2) (Z : $T3) -> ...
1. Module types $S1 and $T1 match
2. Module types $S2 and $T2 match
3. An argument appears to be missing with module type
$T3 =
functor (A : sig type za end) (B : sig type zb end) -> sig end
|}]
module M: sig
module F: functor
(X:
functor(A: sig type xa end)(B:sig type xz end) -> sig end
)
(Y:
functor(A: sig type ya end)(B:sig type yb end) -> sig end
)
(Z:
functor(A: sig type za end)(B:sig type zb end) -> sig end
) -> sig end
end = struct
module F
(X:
functor (A: sig type xaa end)(B:sig type xz end) -> sig end
)
(Y:
functor (A: sig type ya end)(B:sig type ybb end) -> sig end
)
(Z:
functor (A: sig type za end)(B:sig type zbb end) -> sig end
)
= struct end
end
[%%expect {|
Lines 12-24, characters 6-3:
12 | ......struct
13 | module F
14 | (X:
15 | functor (A: sig type xaa end)(B:sig type xz end) -> sig end
16 | )
...
21 | functor (A: sig type za end)(B:sig type zbb end) -> sig end
22 | )
23 | = struct end
24 | end
Error: Signature mismatch:
Modules do not match:
sig
module F :
functor
(X : functor (A : sig type xaa end) (B : sig type xz end) ->
sig end)
(Y : functor (A : sig type ya end) (B : sig type ybb end) ->
sig end)
(Z : functor (A : sig type za end) (B : sig type zbb end) ->
sig end)
-> sig end
end
is not included in
sig
module F :
functor
(X : functor (A : sig type xa end) (B : sig type xz end) ->
sig end)
(Y : functor (A : sig type ya end) (B : sig type yb end) ->
sig end)
(Z : functor (A : sig type za end) (B : sig type zb end) ->
sig end)
-> sig end
end
In module F:
Modules do not match:
functor (X : $S1) (Y : $S2) (Z : $S3) -> ...
is not included in
functor (X : $T1) (Y : $T2) (Z : $T3) -> ...
1. Module types do not match:
$S1 =
functor (A : sig type xaa end) (B : sig type xz end) -> sig end
does not include
$T1 =
functor (A : sig type xa end) (B : sig type xz end) -> sig end
Modules do not match:
functor (A : $S1) (B : $S2) -> ...
is not included in
functor (A : $T1) (B : $T2) -> ...
1. Module types do not match:
$S1 = sig type xa end
does not include
$T1 = sig type xaa end
The type `xa' is required but not provided
2. Module types $S2 and $T2 match
2. Module types do not match:
$S2 =
functor (A : sig type ya end) (B : sig type ybb end) -> sig end
does not include
$T2 =
functor (A : sig type ya end) (B : sig type yb end) -> sig end
Modules do not match:
functor (A : $S1) (B : $S2) -> ...
is not included in
functor (A : $T1) (B : $T2) -> ...
3. Module types do not match:
$S3 =
functor (A : sig type za end) (B : sig type zbb end) -> sig end
does not include
$T3 =
functor (A : sig type za end) (B : sig type zb end) -> sig end
Modules do not match:
functor (A : $S1) (B : $S2) -> ...
is not included in
functor (A : $T1) (B : $T2) -> ...
|}]
module A: sig
module B: sig
module C: sig
module D: sig
module E: sig
module F: sig type x end -> sig type y end
-> sig type z end -> sig type w end -> sig end
end
end
end
end
end = struct
module B = struct
module C = struct
module D = struct
module E = struct
module F(X:sig type x end)(Y:sig type y' end)
(W:sig type w end) = struct end
end
end
end
end
end
[%%expect {|
Lines 12-23, characters 6-3:
12 | ......struct
13 | module B = struct
14 | module C = struct
15 | module D = struct
16 | module E = struct
...
20 | end
21 | end
22 | end
23 | end
Error: Signature mismatch:
Modules do not match:
sig
module B :
sig
module C :
sig
module D :
sig
module E :
sig
module F :
functor (X : sig type x end)
(Y : sig type y' end) (W : sig type w end) ->
sig end
end
end
end
end
end
is not included in
sig
module B :
sig
module C :
sig
module D :
sig
module E :
sig
module F :
sig type x end -> sig type y end ->
sig type z end -> sig type w end -> sig end
end
end
end
end
end
In module B:
Modules do not match:
sig module C = B.C end
is not included in
sig
module C :
sig
module D :
sig
module E :
sig
module F :
sig type x end -> sig type y end ->
sig type z end -> sig type w end -> sig end
end
end
end
end
In module B.C:
Modules do not match:
sig module D = B.C.D end
is not included in
sig
module D :
sig
module E :
sig
module F :
sig type x end -> sig type y end -> sig type z end ->
sig type w end -> sig end
end
end
end
In module B.C.D:
Modules do not match:
sig module E = B.C.D.E end
is not included in
sig
module E :
sig
module F :
sig type x end -> sig type y end -> sig type z end ->
sig type w end -> sig end
end