Skip to content

Commit 77caef7

Browse files
committed
add an example of variadic functor
1 parent fce6ed2 commit 77caef7

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

testsuite/tests/typing-modules/functors.ml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,3 +1121,69 @@ Error: Signature mismatch:
11211121
...(R) = sig type upon type the type heath end
11221122
The type `heart' is required but not provided
11231123
|}]
1124+
1125+
1126+
(** Abstract module type woes *)
1127+
1128+
(** Future works: module types must be extended after accepting arguments *)
1129+
1130+
module F(X:sig module type t module M:t end) = X.M
1131+
1132+
module PF = struct
1133+
module type t = module type of F
1134+
module M = F
1135+
end
1136+
1137+
module U = F(PF)(PF)(PF)
1138+
[%%expect {|
1139+
module F : functor (X : sig module type t module M : t end) -> X.t
1140+
module PF :
1141+
sig
1142+
module type t = functor (X : sig module type t module M : t end) -> X.t
1143+
module M = F
1144+
end
1145+
module U : PF.t
1146+
|}]
1147+
1148+
module W = F(PF)(PF)(PF)(PF)(PF)(F)
1149+
[%%expect {|
1150+
Line 1, characters 11-35:
1151+
1 | module W = F(PF)(PF)(PF)(PF)(PF)(F)
1152+
^^^^^^^^^^^^^^^^^^^^^^^^
1153+
Error: The functor application is ill-typed.
1154+
These arguments:
1155+
PF PF PF PF PF F
1156+
do not match these parameters:
1157+
functor (X : ...) -> ...
1158+
1. Module PF matches the expected module type
1159+
2. The following extra argument is provided
1160+
PF :
1161+
sig
1162+
module type t =
1163+
functor (X : sig module type t module M : t end) -> X.t
1164+
module M = F
1165+
end
1166+
3. The following extra argument is provided
1167+
PF :
1168+
sig
1169+
module type t =
1170+
functor (X : sig module type t module M : t end) -> X.t
1171+
module M = F
1172+
end
1173+
4. The following extra argument is provided
1174+
PF :
1175+
sig
1176+
module type t =
1177+
functor (X : sig module type t module M : t end) -> X.t
1178+
module M = F
1179+
end
1180+
5. The following extra argument is provided
1181+
PF :
1182+
sig
1183+
module type t =
1184+
functor (X : sig module type t module M : t end) -> X.t
1185+
module M = F
1186+
end
1187+
6. The following extra argument is provided
1188+
F : functor (X : sig module type t module M : t end) -> X.t
1189+
|}]

0 commit comments

Comments
 (0)