@@ -3,8 +3,10 @@ module List = List0
33include Applicative_intf. Definitions
44
55[%% template
6- module % template.portable Make3 (X : Basic3 ) :
7- S3 with type ('a, 'p, 'q) t := ('a, 'p, 'q) X. t = struct
6+ [@@@ kind.default k = (value, value_or_null mod maybe_null)]
7+
8+ module % template.portable Make3 (X : Basic3 [@kind k] ) :
9+ S3 [@ kind k] with type ('a : k, 'p, 'q ) t := ('a, 'p, 'q) X. t = struct
810 include X
911
1012 let ( < *> ) = apply
@@ -33,24 +35,25 @@ module%template.portable Make3 (X : Basic3) :
3335 end
3436end
3537
36- module % template.portable [@ modality p] Make2 (X : Basic2 ) :
37- S2 with type ('a, 'p) t := ('a, 'p) X. t = Make3 [@ modality p] (struct
38+ module % template.portable [@ modality p] Make2 (X : Basic2 [@kind k] ) :
39+ S2 [@ kind k] with type ('a : k, 'p ) t := ('a, 'p) X. t =
40+ Make3 [@ kind k] [@ modality p] (struct
3841 include X
3942
40- type ('a, 'p, _) t = ('a , 'p ) X .t
43+ type ('a : k , 'p, _) t = ('a , 'p ) X .t
4144 end )
4245
43- module % template.portable [@ modality p] Make (X : Basic ) : S with type 'a t := 'a X. t =
44- Make3 [@ modality p] (struct
46+ module % template.portable [@ modality p] Make (X : Basic [@kind k] ) :
47+ S [ @ kind k] with type ('a : k ) t := 'a X. t = Make3 [ @ kind k] [@ modality p] (struct
4548 include X
4649
47- type ('a, _, _) t = 'a X .t
50+ type ('a : k , _, _) t = 'a X .t
4851 end )
4952
5053[@@@ mode.default m = (global, local)]
5154
52- module % template.portable Make3_using_map2 (X : Basic3_using_map2 [@mode m] ) :
53- S3 [@ mode m] with type ('a, 'p, 'q) t := ('a, 'p, 'q) X. t = struct
55+ module % template.portable Make3_using_map2 (X : Basic3_using_map2 [@kind k] [@ mode m] ) :
56+ S3 [@ kind k] [ @ mode m] with type ('a : k , 'p, 'q ) t := ('a, 'p, 'q) X. t = struct
5457 include X
5558
5659 let apply tf ta = map2 tf ta ~f: (fun f a -> f a)
8790module % template.portable
8891 [@ modality p] Make2_using_map2
8992 (X : Basic2_using_map2
90- [@ mode m]) : S2 [@mode m] with type ('a, 'p ) t := ('a, 'p) X. t =
91- Make3_using_map2 [@ mode m] [@ modality p] (struct
93+ [@ kind k] [ @ mode m]) : S2 [@kind k] [@ mode m] with type ('a : k , 'p ) t := ('a, 'p) X. t =
94+ Make3_using_map2 [@ kind k] [ @ mode m] [@ modality p] (struct
9295 include X
9396
94- type ('a, 'p, _) t = ('a , 'p ) X .t
97+ type ('a : k , 'p, _) t = ('a , 'p ) X .t
9598 end )
9699
97- module % template.portable [@ modality p] Make_using_map2 (X : Basic_using_map2 [@mode m] ) :
98- S [@ mode m] with type 'a t := 'a X. t = Make3_using_map2 [@ mode m] [@ modality p] (struct
100+ module % template.portable
101+ [@ modality p] Make_using_map2
102+ (X : Basic_using_map2
103+ [@ kind k] [@ mode m]) : S [@kind k] [@mode m] with type ('a : k ) t := 'a X. t =
104+ Make3_using_map2 [@ kind k] [@ mode m] [@ modality p] (struct
99105 include X
100106
101- type ('a, _, _) t = 'a X .t
107+ type ('a : k , _, _) t = 'a X .t
102108 end )
103109
104- module % template.portable [@ modality p] Of_monad3 (M : Monad.S3 [@mode m] ) :
105- S3 [@ mode m] with type ('a, 'p, 'q) t := ('a, 'p, 'q) M. t =
106- Make3_using_map2 [@ mode m] [@ modality p] (struct
107- type ('a, 'p, 'q) t = ('a , 'p , 'q ) M .t
110+ module % template.portable [@ modality p] Of_monad3 (M : Monad.S3 [@kind k] [@ mode m] ) :
111+ S3 [@ kind k] [ @ mode m] with type ('a : k , 'p, 'q ) t := ('a, 'p, 'q) M. t =
112+ Make3_using_map2 [@ kind k] [ @ mode m] [@ modality p] (struct
113+ type ('a : k , 'p, 'q) t = ('a , 'p , 'q ) M .t
108114
109115 let return = M. return
110116
@@ -115,27 +121,32 @@ Make3_using_map2 [@mode m] [@modality p] (struct
115121 let map = `Custom M. map
116122 end )
117123
118- module % template.portable [@ modality p] Of_monad2 (M : Monad.S2 [@mode m] ) :
119- S2 [@ mode m] with type ('a, 'p) t := ('a, 'p) M. t =
120- Of_monad3 [@ mode m] [@ modality p] (struct
124+ module % template.portable [@ modality p] Of_monad2 (M : Monad.S2 [@kind k] [@ mode m] ) :
125+ S2 [@ kind k] [ @ mode m] with type ('a : k , 'p ) t := ('a, 'p) M. t =
126+ Of_monad3 [@ kind k] [ @ mode m] [@ modality p] (struct
121127 include M
122128
123- type ('a, 'p, _) t = ('a , 'p ) M .t
129+ type ('a : k , 'p, _) t = ('a , 'p ) M .t
124130 end )
125131
126- module % template.portable [@ modality p] Of_monad (M : Monad.S [@mode m] ) :
127- S [@ mode m] with type 'a t := 'a M. t = Of_monad3 [@ mode m] [@ modality p] (struct
132+ module % template.portable [@ modality p] Of_monad (M : Monad.S [@kind k] [@mode m] ) :
133+ S [@ kind k] [@ mode m] with type ('a : k ) t := 'a M. t =
134+ Of_monad3 [@ kind k] [@ mode m] [@ modality p] (struct
128135 include M
129136
130- type ('a, _, _) t = 'a M .t
137+ type ('a : k , _, _) t = 'a M .t
131138 end )
132139
133- module % template.portable [@ modality p] Compose (F : S [@mode m] ) (G : S [@mode m] ) :
134- S [@ mode m] with type 'a t = 'a F. t G. t = struct
135- type 'a t = 'a F .t G .t
140+ module % template.portable
141+ [@ modality p] Compose
142+ (F : S
143+ [@ kind k] [@ mode m])
144+ (G : S
145+ [@ kind k] [@ mode m]) : S [@kind k] [@mode m] with type ('a : k ) t = 'a F. t G. t = struct
146+ type ('a : k) t = 'a F .t G .t
136147
137- include Make_using_map2 [@ mode m] [@ modality p] (struct
138- type nonrec 'a t = 'a t
148+ include Make_using_map2 [@ kind k] [ @ mode m] [@ modality p] (struct
149+ type nonrec ('a : k) t = 'a t
139150
140151 let return a = G. return (F. return a)
141152 let map2 tx ty ~f = G. map2 tx ty ~f: (F. map2 ~f ) [@ nontail]
@@ -144,12 +155,17 @@ module%template.portable [@modality p] Compose (F : S [@mode m]) (G : S [@mode m
144155 end )
145156end
146157
147- module % template.portable [@ modality p] Pair (F : S [@mode m] ) (G : S [@mode m] ) :
148- S [@ mode m] with type 'a t = 'a F. t * 'a G. t = struct
149- type 'a t = 'a F .t * 'a G .t
158+ module % template.portable
159+ [@ modality p] Pair
160+ (F : S
161+ [@ kind k] [@ mode m])
162+ (G : S
163+ [@ kind k] [@ mode m]) : S [@kind k] [@mode m] with type ('a : k ) t = 'a F. t * 'a G. t =
164+ struct
165+ type ('a : k) t = 'a F .t * 'a G .t
150166
151- include Make_using_map2 [@ mode m] [@ modality p] (struct
152- type nonrec 'a t = 'a t
167+ include Make_using_map2 [@ kind k] [ @ mode m] [@ modality p] (struct
168+ type nonrec ('a : k) t = 'a t
153169
154170 let return a = F. return a, G. return a
155171 let map2 tx ty ~f = F. map2 ~f (fst tx) (fst ty), G. map2 ~f (snd tx) (snd ty)
@@ -163,15 +179,15 @@ end
163179module Make_let_syntax3
164180 (X : sig
165181 @@ p
166- include For_let_syntax3 [@ mode m]
182+ include For_let_syntax3 [@ kind k] [ @ mode m]
167183 end )
168184 (Intf : sig
169185 module type S
170186 end )
171187 (Impl : Intf.S ) : sig @@ p
172- include Let_syntax3 [@ mode m]
188+ include Let_syntax3 [@ kind k] [ @ mode m]
173189 end
174- with type ('a, 'p, 'q) t := ('a, 'p, 'q) X. t
190+ with type ('a : k , 'p, 'q ) t := ('a, 'p, 'q) X. t
175191 with module Open_on_rhs_intf := Intf = struct
176192 module Let_syntax = struct
177193 include X
@@ -186,57 +202,57 @@ end
186202module Make_let_syntax2
187203 (X : sig
188204 @@ p
189- include For_let_syntax2 [@ mode m]
205+ include For_let_syntax2 [@ kind k] [ @ mode m]
190206 end )
191207 (Intf : sig
192208 module type S
193209 end )
194210 (Impl : Intf.S ) : sig @@ p
195- include Let_syntax2 [@ mode m]
211+ include Let_syntax2 [@ kind k] [ @ mode m]
196212 end
197- with type ('a, 'p) t := ('a, 'p) X. t
213+ with type ('a : k , 'p ) t := ('a, 'p) X. t
198214 with module Open_on_rhs_intf := Intf =
199- Make_let_syntax3 [@ mode m] [@ modality p]
215+ Make_let_syntax3 [@ kind k] [ @ mode m] [@ modality p]
200216 (struct
201217 include X
202218
203- type ('a, 'p, _) t = ('a , 'p ) X .t
219+ type ('a : k , 'p, _) t = ('a , 'p ) X .t
204220 end )
205221 (Intf )
206222 (Impl )
207223
208224module Make_let_syntax
209225 (X : sig
210226 @@ p
211- include For_let_syntax [@ mode m]
227+ include For_let_syntax [@ kind k] [ @ mode m]
212228 end )
213229 (Intf : sig
214230 module type S
215231 end )
216232 (Impl : Intf.S ) : sig @@ p
217- include Let_syntax [@ mode m]
233+ include Let_syntax [@ kind k] [ @ mode m]
218234 end
219- with type 'a t := 'a X. t
235+ with type ('a : k ) t := 'a X. t
220236 with module Open_on_rhs_intf := Intf =
221- Make_let_syntax3 [@ mode m] [@ modality p]
237+ Make_let_syntax3 [@ kind k] [ @ mode m] [@ modality p]
222238 (struct
223239 include X
224240
225- type ('a, _, _) t = 'a X .t
241+ type ('a : k , _, _) t = 'a X .t
226242 end )
227243 (Intf )
228244 (Impl )]
229245
230- module Ident = struct
231- type 'a t = 'a
246+ module % template [ @ mode p = (portable, nonportable)] Ident = struct
247+ type ('a : value_or_null) t = 'a
232248
233- let return = Fn. id
249+ let return x = x
234250 let apply f a = f a
235251 let both a b = a, b
236252 let map3 a b c ~f = f a b c
237253 let map2 a b ~f = f a b
238254 let map a ~f = f a
239- let all = Fn. id
255+ let all x = x
240256 let all_unit = ignore
241257
242258 module Applicative_infix = struct
0 commit comments