@@ -19,10 +19,14 @@ open! Import
19
19
20
20
module Definitions = struct
21
21
[%% template
22
- [@@@ mode.default m = (global, local)]
22
+ [@@@ mode.default m = (global, local), p = (nonportable, portable) ]
23
23
24
24
(* * Module types below provide both global and local versions. In OxCaml, the latter
25
- accept local [~f] closures. *)
25
+ accept local [~f] closures.
26
+
27
+ Both [local] and [portable] versions are designed with a strict data structure in
28
+ mind. The types won't make sense for Applicatives whose evaluation is delayed (e.g.
29
+ most monads, Command.Param, or anything like a database query applicative). *)
26
30
27
31
(* * Applicative operations. An applicative abstracts the notion of computations whose
28
32
results can be combined. An ['a t] represents a computation returning ['a].
@@ -78,14 +82,14 @@ module Definitions = struct
78
82
module type S2_kernel = sig
79
83
type ('a, 'p) t
80
84
81
- include S3_kernel [@ mode m] with type ('a, 'p, _) t := ('a, 'p) t
85
+ include S3_kernel [@ mode m p ] with type ('a, 'p, _) t := ('a, 'p) t
82
86
end
83
87
84
88
(* * Applicative operations for applicatives with one type parameter. *)
85
89
module type S_kernel = sig
86
90
type 'a t
87
91
88
- include S3_kernel [@ mode m] with type ('a, _, _) t := 'a t
92
+ include S3_kernel [@ mode m p ] with type ('a, _, _) t := 'a t
89
93
end
90
94
91
95
(* * Infix operators. This module type subsumes the other [Index*] types below. *)
@@ -102,14 +106,14 @@ module Definitions = struct
102
106
module type Applicative_infix2 = sig
103
107
type ('a, 'p) t
104
108
105
- include Applicative_infix3 [@ mode m] with type ('a, 'p, _) t := ('a, 'p) t
109
+ include Applicative_infix3 [@ mode m p ] with type ('a, 'p, _) t := ('a, 'p) t
106
110
end
107
111
108
112
(* * Infix operators for applicatives with one type parameter. *)
109
113
module type Applicative_infix = sig
110
114
type 'a t
111
115
112
- include Applicative_infix3 [@ mode m] with type ('a, _, _) t := 'a t
116
+ include Applicative_infix3 [@ mode m p ] with type ('a, _, _) t := 'a t
113
117
end
114
118
115
119
(* * Complete applicative interface. Extends [_kernel] with infix operators.
@@ -118,25 +122,25 @@ module Definitions = struct
118
122
module type S3 = sig
119
123
type ('a, 'p, 'q) t
120
124
121
- include S3_kernel [@ mode m] with type ('a, 'p, 'q) t := ('a, 'p, 'q) t
122
- include Applicative_infix3 [@ mode m] with type ('a, 'p, 'q) t := ('a, 'p, 'q) t
125
+ include S3_kernel [@ mode m p ] with type ('a, 'p, 'q) t := ('a, 'p, 'q) t
126
+ include Applicative_infix3 [@ mode m p ] with type ('a, 'p, 'q) t := ('a, 'p, 'q) t
123
127
124
128
module Applicative_infix :
125
- Applicative_infix3 [@ mode m] with type ('a, 'p, 'q) t := ('a, 'p, 'q) t
129
+ Applicative_infix3 [@ mode m p ] with type ('a, 'p, 'q) t := ('a, 'p, 'q) t
126
130
end
127
131
128
132
(* * Complete applicative interface with two type parameters. *)
129
133
module type S2 = sig
130
134
type ('a, 'p) t
131
135
132
- include S3 [@ mode m] with type ('a, 'p, _) t := ('a, 'p) t
136
+ include S3 [@ mode m p ] with type ('a, 'p, _) t := ('a, 'p) t
133
137
end
134
138
135
139
(* * Complete applicative interface with one type parameter. *)
136
140
module type S = sig
137
141
type 'a t
138
142
139
- include S3 [@ mode m] with type ('a, _, _) t := 'a t
143
+ include S3 [@ mode m p ] with type ('a, _, _) t := 'a t
140
144
end
141
145
142
146
(* * Supports [let%map] syntax. See [ppx_let] documentation.
@@ -287,8 +291,9 @@ module type Applicative = sig
287
291
[%% template:
288
292
(* * The identity applicative. Useful as an argument to functors that require a monad, to
289
293
produce a non-applicative result. *)
290
- module Ident : sig
291
- include S [@ mode local]
294
+ module % template
295
+ [@ mode p = (portable, nonportable)] Ident : sig
296
+ include S [@ mode local p]
292
297
end
293
298
with type 'a t = 'a
294
299
0 commit comments