File: modules.sml

package info (click to toggle)
mlton 20130715-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 60,900 kB
  • ctags: 69,386
  • sloc: xml: 34,418; ansic: 17,399; lisp: 2,879; makefile: 1,605; sh: 1,254; pascal: 256; python: 143; asm: 97
file content (300 lines) | stat: -rw-r--r-- 4,540 bytes parent folder | download | duplicates (7)
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
signature S =
   sig
      type t
      structure S:
         sig
            type 'a t
            val x: 'a t
         end
   end

structure S:
   sig
      datatype ('a, 'b) t = T of 'a
   end =
   struct
      datatype ('b, 'a) t = T of 'b
   end

functor F (eqtype t
           datatype u = U of t
           eqtype v
           sharing type t = v) =
   struct
      fun f (u: u) = u = u
   end

functor F (type t
           eqtype u
           sharing type t = u) =
   struct
      fun f (x: t) = x = x
   end

signature S1 =
   sig
      datatype t = T
   end

signature S2 =
   sig
      eqtype u
      structure S: S1 where type t = u
   end;

signature S1 =
   sig
      datatype t = T
   end

signature S2 =
   sig
      datatype u = U 
      structure S: S1 where type t = u
   end;

signature S =
   sig
      datatype t = T
   end where type t = int

signature S =
   sig
      type t
      type u
      type v = t
      sharing type u = v
   end

signature S =
   sig
      type 'a t
      type 'a u
      type 'a v = 'a t
      sharing type u = v
   end

signature S =
   sig
      type t
      datatype u = U
      sharing type u = t
   end

signature S =
   sig
      type t
      structure Z:
         sig
            datatype u = U
         end
      sharing type Z.u = t
   end

signature S =
   sig
      eqtype t
      structure Z:
         sig
            datatype u = U
         end where type u = t
   end

structure S:
   sig
      eqtype t
      structure Z:
         sig
            datatype u = U
         end where type u = t
   end =
   struct
      structure Z =
         struct
            datatype u = U
         end
      type t = Z.u
   end

functor F () = struct end

functor F (type t) = struct type u = t end

functor F (val x: int) = struct val y = x end

functor F (structure S: sig end) = struct open S end

functor F (type t
           type u
           sharing type t = u) =
   struct
      val id: t -> u = fn x => x
   end

functor F (eqtype t) = struct fun f (x: t) = x = x end

functor F (structure S:
              sig
                 type t
              end
           structure T:
              sig
                 type t
              end
           sharing S = T) =
   struct
      val id: S.t -> T.t = fn x => x
   end

functor F (datatype 'a t = T of 'a * 'a) =
   struct
      val _ = T (13, 14)
   end

functor F (type ('a, 'b) t
           type 'a u = ('a, int) t
           val f: (bool, 'b) t -> real
           val u: bool u) =
   struct
      val _ = f u
   end
              
functor F (datatype t = T
           datatype u = U of t) =
   struct
      fun f (x: u) = x = x
   end

structure S:
   sig
      val x: unit list
   end =
   struct
      val x = []
   end

structure S:
   sig
      val x: 'a list
   end =
   struct
      val x = []
   end

structure S:
   sig
      val x: ''a list
   end =
   struct
      val x = []
   end

structure S:
   sig
      val f: ''a -> ''a list
   end =
   struct
      fun f x = [x]
   end

structure S:
   sig
      type 'a t

      val T: int t
   end =
   struct
      datatype 'a t = T
   end

structure S:
   sig
      val f: 'a list -> 'a list
   end =
   struct
      fun f _ = []
   end
val z = S.f [1, 2, 3]

structure S = struct datatype t = T end
functor F () = S
structure S1 = F ()
structure S2 = F ()
val _ = S1.T = S2.T

datatype t = T
functor F () =
   struct
      datatype t = datatype t
   end
structure S1 = F ()
structure S2 = F ()
val _ = S1.T = S2.T

signature SIG = sig type t end
functor F (S: sig type t end): SIG = S
structure S:>
   sig
      structure T: sig type t end
      structure U: SIG
      sharing type T.t = U.t
   end =
   struct
      structure T = struct type t = unit end
      structure U = F (type t = unit)
   end
val f = fn z: S.T.t => z: S.U.t

structure S:>
   sig
      eqtype t
      val x: t
   end =
   struct
      type t = unit
      val x = ()
   end
val _ = S.x = S.x

val _ = fn x: LargeInt.int => x: IntInf.int

signature S =
   sig
      type t
   end
structure S:> S =
   struct
      datatype t = T
   end
signature T =
   sig
      type u
      include S where type t = S.t
   end
structure T:> T =
   struct
      datatype u = U
      type t = S.t
   end
val _: T.t -> S.t = fn x => x

signature SIG =
   sig
      type u
      type v = u
   end where type v = int
structure S: SIG =
   struct
      type u = int
      type v = int
   end

functor F () =
   struct
      val A = 0
   end
structure S =
   struct
      datatype z = A
      structure F = F ()
   end