File: funmap.dats

package info (click to toggle)
ats2-lang 0.4.2-5
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 40,524 kB
  • sloc: ansic: 389,898; makefile: 7,138; javascript: 1,852; lisp: 811; sh: 657; php: 573; python: 387; perl: 365
file content (243 lines) | stat: -rw-r--r-- 3,608 bytes parent folder | download | duplicates (5)
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
(* ****** ****** *)
//
// HX-2017-10-28:
// For supporting
// "unityped" programming
//
(* ****** ****** *)
//
(*
#define
ATS_DYNLOADFLAG 1
*)
#define
ATS_PACKNAME
"ATSLIB.libats.ML.COMPILE"
//
(* ****** ****** *)
//
#include
"share/atspre_staload.hats"
//
(* ****** ****** *)
//
#staload
"libats/ML/SATS/basis.sats"
#staload
"libats/ML/SATS/list0.sats"
//
(* ****** ****** *)
//
#staload FM =
"libats/ML/SATS/funmap.sats"
//
#staload _(*FM*) =
"libats/ML/DATS/funmap.dats"
#staload _(*FM*) =
"libats/DATS/funmap_avltree.dats"
//
(* ****** ****** *)
//
// HX: Interface
//
(* ****** ****** *)
//
// HX: covariant
//
abstype
map_type(itm:t@ype+)
//
typedef
map(a:t@ype) = map_type(a)
//
(* ****** ****** *)
//
extern
fun
funmap_nil
{itm:type}((*void*)):<> map(itm)
and
funmap_make_nil
{itm:type}((*void*)):<> map(itm)
//
(* ****** ****** *)
//
extern
fun
funmap_size
{itm:type}(map(itm)):<> intGte(0)
//
overload size with funmap_size
//
extern
fun
funmap_is_nil
{itm:type}(kxs: map(itm)):<> bool
and
funmap_isnot_nil
{itm:type}(kxs: map(itm)):<> bool
//
overload iseqz with funmap_is_nil
overload isneqz with funmap_isnot_nil
//
(* ****** ****** *)
//
extern
fun
funmap_search
{itm:type}
(
  kxs: map(INV(itm)), k0: string
) : Option_vt(itm) // end of [funmap_search]
//
overload .search with funmap_search
//
(* ****** ****** *)
//
extern
fun
funmap_insert
{itm:type}
(
  &map(INV(itm)) >> _, k0: string, x0: itm
) : Option_vt(itm) // end of [funmap_insert]
//
overload .insert with funmap_insert
//
(* ****** ****** *)
//
extern
fun
funmap_remove
{itm:type}
(kxs: &map(INV(itm)) >> _, k0: string): bool
and
funmap_takeout
{itm:type}
(kxs: &map(INV(itm)) >> _, k0: string): Option_vt(itm)
//
overload .remove with funmap_remove
overload .takeout with funmap_takeout
//
(* ****** ****** *)
//
extern
fun
funmap_foreach_cloref
{itm:type}
( kxs: map(INV(itm))
, fwork: (string, itm) -<cloref1> void
) : void // end of [funmap_foreach_cloref]
//
extern
fun
funmap_foreach_method
{itm:type}
(
  kxs: map(INV(itm))
)
(
  fwork: (string, itm) -<cloref1> void
) : void // end of [funmap_foreach_method]
//
overload .foreach with funmap_foreach_method
//
(* ****** ****** *)
//
// HX: Implementation
//
(* ****** ****** *)
//
assume
map_type
(itm:t@ype) = $FM.map(string, itm)
//
(* ****** ****** *)
//
implement
funmap_nil
{itm}((*void*)) =
$FM.funmap_nil<>{string,itm}()
//
implement
funmap_make_nil
{itm}((*void*)) =
$FM.funmap_make_nil<>{string,itm}()
//
(* ****** ****** *)
//
implement
funmap_size
{itm}(kxs) =
sz2i(g1ofg0(msz)) where
{
  val msz =
    $FM.funmap_size<string,itm>(kxs)
  // end of [val]
} (* funmap_size *)
//
(* ****** ****** *)
//
implement
funmap_is_nil
{itm}(kxs) =
$FM.funmap_is_nil<>{string,itm}(kxs)
implement
funmap_isnot_nil
{itm}(kxs) =
$FM.funmap_isnot_nil<>{string,itm}(kxs)
//
(* ****** ****** *)
//
implement
funmap_search
{itm:type}
(kxs, k0) =
$FM.funmap_search<string,itm>(kxs, k0)
//
(* ****** ****** *)
//
implement
funmap_insert
{itm:type}
(kxs, k0, x0) =
$FM.funmap_insert<string,itm>(kxs, k0, x0)
//
(* ****** ****** *)
//
implement
funmap_remove
{itm:type}
(kxs, k0) =
(
  $FM.funmap_remove<string,itm>(kxs, k0)
)
implement
funmap_takeout
{itm:type}
(kxs, k0) =
(
  $FM.funmap_takeout<string,itm>(kxs, k0)
)
//
(* ****** ****** *)
//
implement
funmap_foreach_method
{itm}(kxs) =
(
lam(fwork) =>
  funmap_foreach_cloref(kxs, fwork)
) (* end of [funmap_foreach_method] *)
//
implement
funmap_foreach_cloref
{itm}(kxs, fwork) =
(
$FM.funmap_foreach_cloref<string,itm>
  (kxs, fwork)
) (* end of [funmap_foreach_cloref] *)
//
(* ****** ****** *)

(* end of [funmap.dats] *)