@shd101wyy/yo 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/skills/yo-async-effects/SKILL.md +4 -4
- package/.github/skills/yo-async-effects/async-effects-recipes.md +34 -34
- package/.github/skills/yo-core-patterns/SKILL.md +1 -1
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +26 -26
- package/.github/skills/yo-project-workflow/SKILL.md +6 -3
- package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
- package/.github/skills/yo-syntax/SKILL.md +7 -6
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +73 -60
- package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
- package/README.md +10 -8
- package/out/cjs/index.cjs +456 -438
- package/out/cjs/yo-cli.cjs +576 -543
- package/out/cjs/yo-lsp.cjs +559 -532
- package/out/esm/index.mjs +281 -263
- package/out/types/src/formatter.d.ts +11 -0
- package/out/types/src/lsp/formatting.d.ts +2 -0
- package/out/types/src/tests/formatter.test.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/alg/hash.yo +13 -21
- package/std/allocator.yo +25 -40
- package/std/async.yo +3 -7
- package/std/build.yo +105 -151
- package/std/cli/arg_parser.yo +184 -169
- package/std/collections/array_list.yo +350 -314
- package/std/collections/btree_map.yo +142 -131
- package/std/collections/deque.yo +132 -128
- package/std/collections/hash_map.yo +542 -566
- package/std/collections/hash_set.yo +623 -687
- package/std/collections/linked_list.yo +275 -293
- package/std/collections/ordered_map.yo +113 -85
- package/std/collections/priority_queue.yo +73 -73
- package/std/crypto/md5.yo +191 -95
- package/std/crypto/random.yo +56 -64
- package/std/crypto/sha256.yo +151 -107
- package/std/encoding/base64.yo +87 -81
- package/std/encoding/hex.yo +43 -50
- package/std/encoding/html.yo +56 -81
- package/std/encoding/html_char_utils.yo +7 -13
- package/std/encoding/html_entities.yo +2248 -2253
- package/std/encoding/json.yo +316 -224
- package/std/encoding/punycode.yo +86 -116
- package/std/encoding/toml.yo +67 -66
- package/std/encoding/utf16.yo +37 -44
- package/std/env.yo +62 -91
- package/std/error.yo +7 -15
- package/std/fmt/display.yo +5 -9
- package/std/fmt/index.yo +8 -14
- package/std/fmt/to_string.yo +330 -315
- package/std/fmt/writer.yo +58 -87
- package/std/fs/dir.yo +83 -102
- package/std/fs/file.yo +147 -180
- package/std/fs/metadata.yo +45 -78
- package/std/fs/temp.yo +55 -65
- package/std/fs/types.yo +27 -40
- package/std/fs/walker.yo +53 -68
- package/std/gc.yo +5 -8
- package/std/glob.yo +30 -43
- package/std/http/client.yo +107 -120
- package/std/http/http.yo +106 -96
- package/std/http/index.yo +4 -6
- package/std/imm/list.yo +88 -93
- package/std/imm/map.yo +528 -464
- package/std/imm/set.yo +52 -57
- package/std/imm/sorted_map.yo +340 -286
- package/std/imm/sorted_set.yo +57 -63
- package/std/imm/string.yo +404 -345
- package/std/imm/vec.yo +173 -181
- package/std/io/reader.yo +3 -6
- package/std/io/writer.yo +4 -8
- package/std/libc/assert.yo +5 -9
- package/std/libc/ctype.yo +32 -22
- package/std/libc/dirent.yo +26 -25
- package/std/libc/errno.yo +164 -90
- package/std/libc/fcntl.yo +52 -45
- package/std/libc/float.yo +66 -44
- package/std/libc/limits.yo +42 -33
- package/std/libc/math.yo +53 -82
- package/std/libc/signal.yo +72 -47
- package/std/libc/stdatomic.yo +217 -188
- package/std/libc/stdint.yo +5 -29
- package/std/libc/stdio.yo +5 -29
- package/std/libc/stdlib.yo +32 -39
- package/std/libc/string.yo +5 -23
- package/std/libc/sys/stat.yo +58 -56
- package/std/libc/time.yo +5 -19
- package/std/libc/unistd.yo +5 -20
- package/std/libc/wctype.yo +6 -9
- package/std/libc/windows.yo +26 -30
- package/std/log.yo +41 -55
- package/std/net/addr.yo +102 -97
- package/std/net/dns.yo +27 -28
- package/std/net/errors.yo +50 -49
- package/std/net/tcp.yo +113 -124
- package/std/net/udp.yo +55 -66
- package/std/os/env.yo +35 -33
- package/std/os/signal.yo +15 -25
- package/std/path.yo +276 -311
- package/std/prelude.yo +6304 -4315
- package/std/process/command.yo +87 -103
- package/std/process/index.yo +12 -31
- package/std/regex/compiler.yo +196 -95
- package/std/regex/flags.yo +58 -39
- package/std/regex/index.yo +157 -173
- package/std/regex/match.yo +20 -31
- package/std/regex/node.yo +134 -152
- package/std/regex/parser.yo +283 -259
- package/std/regex/unicode.yo +172 -202
- package/std/regex/vm.yo +155 -171
- package/std/string/index.yo +5 -7
- package/std/string/rune.yo +45 -55
- package/std/string/string.yo +937 -964
- package/std/string/string_builder.yo +94 -104
- package/std/string/unicode.yo +46 -64
- package/std/sync/channel.yo +72 -73
- package/std/sync/cond.yo +31 -36
- package/std/sync/mutex.yo +30 -32
- package/std/sync/once.yo +13 -16
- package/std/sync/rwlock.yo +26 -31
- package/std/sync/waitgroup.yo +20 -25
- package/std/sys/advise.yo +16 -24
- package/std/sys/bufio/buf_reader.yo +77 -93
- package/std/sys/bufio/buf_writer.yo +52 -65
- package/std/sys/clock.yo +4 -9
- package/std/sys/constants.yo +77 -61
- package/std/sys/copy.yo +4 -10
- package/std/sys/dir.yo +26 -43
- package/std/sys/dns.yo +41 -61
- package/std/sys/errors.yo +95 -103
- package/std/sys/events.yo +45 -57
- package/std/sys/externs.yo +319 -267
- package/std/sys/fallocate.yo +7 -11
- package/std/sys/fcntl.yo +14 -22
- package/std/sys/file.yo +26 -40
- package/std/sys/future.yo +5 -8
- package/std/sys/iov.yo +12 -25
- package/std/sys/lock.yo +12 -13
- package/std/sys/mmap.yo +38 -43
- package/std/sys/path.yo +3 -8
- package/std/sys/perm.yo +7 -21
- package/std/sys/pipe.yo +5 -12
- package/std/sys/process.yo +23 -29
- package/std/sys/seek.yo +10 -12
- package/std/sys/signal.yo +7 -13
- package/std/sys/signals.yo +52 -35
- package/std/sys/socket.yo +63 -58
- package/std/sys/socketpair.yo +3 -6
- package/std/sys/sockinfo.yo +11 -20
- package/std/sys/statfs.yo +11 -34
- package/std/sys/statx.yo +25 -52
- package/std/sys/sysinfo.yo +15 -20
- package/std/sys/tcp.yo +62 -92
- package/std/sys/temp.yo +5 -9
- package/std/sys/time.yo +5 -15
- package/std/sys/timer.yo +6 -11
- package/std/sys/tty.yo +10 -18
- package/std/sys/udp.yo +22 -39
- package/std/sys/umask.yo +3 -6
- package/std/sys/unix.yo +33 -52
- package/std/testing/bench.yo +49 -52
- package/std/thread.yo +10 -15
- package/std/time/datetime.yo +105 -89
- package/std/time/duration.yo +43 -56
- package/std/time/instant.yo +13 -18
- package/std/time/sleep.yo +5 -9
- package/std/url/index.yo +184 -209
- package/std/worker.yo +6 -10
package/std/imm/set.yo
CHANGED
|
@@ -17,57 +17,51 @@
|
|
|
17
17
|
//! assert(s.contains(i32(1)), "set contains 1");
|
|
18
18
|
//! assert((s.len() == usize(2)), "two elements");
|
|
19
19
|
//! ```
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
{ List } :: import "./list.yo";
|
|
23
|
-
|
|
20
|
+
{ Map } :: import("./map.yo");
|
|
21
|
+
{ List } :: import("./list.yo");
|
|
24
22
|
/// Persistent immutable hash set backed by a HAMT.
|
|
25
23
|
///
|
|
26
24
|
/// Wraps `Map(T, bool)` internally. The bool values are always `true`.
|
|
27
25
|
Set :: (fn(comptime(T) : Type, where(T <: (Eq(T), Hash, Send))) -> comptime(Type))(
|
|
28
26
|
struct(_inner : Map(T, bool))
|
|
29
27
|
);
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
impl(
|
|
29
|
+
forall(T : Type),
|
|
30
|
+
where(T <: (Eq(T), Hash, Send)),
|
|
31
|
+
Set(T),
|
|
32
32
|
/// Create an empty set.
|
|
33
33
|
new : (fn() -> Self)(
|
|
34
|
-
Self(_inner: Map(T, bool).new())
|
|
34
|
+
Self(_inner : Map(T, bool).new())
|
|
35
35
|
),
|
|
36
|
-
|
|
37
36
|
/// Number of elements.
|
|
38
|
-
len : (fn(self: Self) -> usize)(self._inner.len()),
|
|
39
|
-
|
|
37
|
+
len : (fn(self : Self) -> usize)(self._inner.len()),
|
|
40
38
|
/// Check if the set is empty.
|
|
41
|
-
is_empty : (fn(self: Self) -> bool)(self._inner.is_empty()),
|
|
42
|
-
|
|
39
|
+
is_empty : (fn(self : Self) -> bool)(self._inner.is_empty()),
|
|
43
40
|
/// Check if the set contains `elem`.
|
|
44
|
-
contains : (fn(self: Self, elem: T) -> bool)(
|
|
41
|
+
contains : (fn(self : Self, elem : T) -> bool)(
|
|
45
42
|
self._inner.contains_key(elem)
|
|
46
43
|
),
|
|
47
|
-
|
|
48
44
|
/// Return a new set with `elem` added.
|
|
49
|
-
insert : (fn(self: Self, elem: T) -> Self)(
|
|
50
|
-
Self(_inner: self._inner.insert(elem, true))
|
|
45
|
+
insert : (fn(self : Self, elem : T) -> Self)(
|
|
46
|
+
Self(_inner : self._inner.insert(elem, true))
|
|
51
47
|
),
|
|
52
|
-
|
|
53
48
|
/// Return a new set with `elem` removed.
|
|
54
|
-
remove : (fn(self: Self, elem: T) -> Self)(
|
|
55
|
-
Self(_inner: self._inner.remove(elem))
|
|
49
|
+
remove : (fn(self : Self, elem : T) -> Self)(
|
|
50
|
+
Self(_inner : self._inner.remove(elem))
|
|
56
51
|
),
|
|
57
|
-
|
|
58
52
|
/// Return the union of two sets (`self ∪ other`).
|
|
59
|
-
union : (fn(self: Self, other: Self) -> Self)(
|
|
60
|
-
Self(_inner: self._inner.merge(other._inner))
|
|
53
|
+
union : (fn(self : Self, other : Self) -> Self)(
|
|
54
|
+
Self(_inner : self._inner.merge(other._inner))
|
|
61
55
|
),
|
|
62
|
-
|
|
63
56
|
/// Return the intersection of two sets (`self ∩ other`).
|
|
64
|
-
intersection : (fn(self: Self, other: Self) -> Self)({
|
|
57
|
+
intersection : (fn(self : Self, other : Self) -> Self)({
|
|
65
58
|
elems := self.to_list();
|
|
66
59
|
(result : Self) = Self.new();
|
|
67
60
|
(cur : List(T)) = elems;
|
|
68
61
|
(done : bool) = false;
|
|
69
|
-
while
|
|
70
|
-
match(
|
|
62
|
+
while(runtime(!(done)), {
|
|
63
|
+
match(
|
|
64
|
+
cur.head(),
|
|
71
65
|
.Some(elem) => {
|
|
72
66
|
if(other.contains(elem), {
|
|
73
67
|
result = result.insert(elem);
|
|
@@ -78,18 +72,18 @@ impl(forall(T : Type), where(T <: (Eq(T), Hash, Send)), Set(T),
|
|
|
78
72
|
done = true;
|
|
79
73
|
}
|
|
80
74
|
);
|
|
81
|
-
};
|
|
75
|
+
});
|
|
82
76
|
result
|
|
83
77
|
}),
|
|
84
|
-
|
|
85
78
|
/// Return the difference (`self \ other`).
|
|
86
|
-
difference : (fn(self: Self, other: Self) -> Self)({
|
|
79
|
+
difference : (fn(self : Self, other : Self) -> Self)({
|
|
87
80
|
elems := self.to_list();
|
|
88
81
|
(result : Self) = Self.new();
|
|
89
82
|
(cur : List(T)) = elems;
|
|
90
83
|
(done : bool) = false;
|
|
91
|
-
while
|
|
92
|
-
match(
|
|
84
|
+
while(runtime(!(done)), {
|
|
85
|
+
match(
|
|
86
|
+
cur.head(),
|
|
93
87
|
.Some(elem) => {
|
|
94
88
|
if(!(other.contains(elem)), {
|
|
95
89
|
result = result.insert(elem);
|
|
@@ -100,20 +94,20 @@ impl(forall(T : Type), where(T <: (Eq(T), Hash, Send)), Set(T),
|
|
|
100
94
|
done = true;
|
|
101
95
|
}
|
|
102
96
|
);
|
|
103
|
-
};
|
|
97
|
+
});
|
|
104
98
|
result
|
|
105
99
|
}),
|
|
106
|
-
|
|
107
100
|
/// Check if `self` is a subset of `other`.
|
|
108
|
-
is_subset : (fn(self: Self, other: Self) -> bool)({
|
|
109
|
-
if(
|
|
110
|
-
return
|
|
101
|
+
is_subset : (fn(self : Self, other : Self) -> bool)({
|
|
102
|
+
if(self.len() > other.len(), {
|
|
103
|
+
return(false);
|
|
111
104
|
});
|
|
112
105
|
elems := self.to_list();
|
|
113
106
|
(cur : List(T)) = elems;
|
|
114
107
|
(result : bool) = true;
|
|
115
|
-
while
|
|
116
|
-
match(
|
|
108
|
+
while(runtime(result && !(cur.is_empty())), {
|
|
109
|
+
match(
|
|
110
|
+
cur.head(),
|
|
117
111
|
.Some(elem) => {
|
|
118
112
|
if(!(other.contains(elem)), {
|
|
119
113
|
result = false;
|
|
@@ -122,12 +116,11 @@ impl(forall(T : Type), where(T <: (Eq(T), Hash, Send)), Set(T),
|
|
|
122
116
|
},
|
|
123
117
|
.None => ()
|
|
124
118
|
);
|
|
125
|
-
};
|
|
119
|
+
});
|
|
126
120
|
result
|
|
127
121
|
}),
|
|
128
|
-
|
|
129
122
|
/// Check if two sets are disjoint.
|
|
130
|
-
is_disjoint : (fn(self: Self, other: Self) -> bool)({
|
|
123
|
+
is_disjoint : (fn(self : Self, other : Self) -> bool)({
|
|
131
124
|
(smaller : Self) = cond(
|
|
132
125
|
(self.len() <= other.len()) => self,
|
|
133
126
|
true => other
|
|
@@ -139,8 +132,9 @@ impl(forall(T : Type), where(T <: (Eq(T), Hash, Send)), Set(T),
|
|
|
139
132
|
elems := smaller.to_list();
|
|
140
133
|
(cur : List(T)) = elems;
|
|
141
134
|
(result : bool) = true;
|
|
142
|
-
while
|
|
143
|
-
match(
|
|
135
|
+
while(runtime(result && !(cur.is_empty())), {
|
|
136
|
+
match(
|
|
137
|
+
cur.head(),
|
|
144
138
|
.Some(elem) => {
|
|
145
139
|
if(larger.contains(elem), {
|
|
146
140
|
result = false;
|
|
@@ -149,31 +143,32 @@ impl(forall(T : Type), where(T <: (Eq(T), Hash, Send)), Set(T),
|
|
|
149
143
|
},
|
|
150
144
|
.None => ()
|
|
151
145
|
);
|
|
152
|
-
};
|
|
146
|
+
});
|
|
153
147
|
result
|
|
154
148
|
}),
|
|
155
|
-
|
|
156
149
|
/// Collect all elements into a List.
|
|
157
|
-
to_list : (fn(self: Self) -> List(T))(
|
|
150
|
+
to_list : (fn(self : Self) -> List(T))(
|
|
158
151
|
self._inner.keys()
|
|
159
152
|
),
|
|
160
|
-
|
|
161
153
|
/// Create a set from a slice of elements.
|
|
162
|
-
from_slice : (fn(s: Slice(T)) -> Self)({
|
|
154
|
+
from_slice : (fn(s : Slice(T)) -> Self)({
|
|
163
155
|
(result : Self) = Self.new();
|
|
164
156
|
i := usize(0);
|
|
165
157
|
slen := s.len();
|
|
166
|
-
while
|
|
158
|
+
while(i < slen, i = (i + usize(1)), {
|
|
167
159
|
result = result.insert((s.ptr() &+ i).*);
|
|
168
|
-
};
|
|
160
|
+
});
|
|
169
161
|
result
|
|
170
162
|
})
|
|
171
163
|
);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
(
|
|
175
|
-
|
|
164
|
+
impl(
|
|
165
|
+
forall(T : Type),
|
|
166
|
+
where(T <: (Eq(T), Hash, Send)),
|
|
167
|
+
Set(T),
|
|
168
|
+
Eq(Set(T))(
|
|
169
|
+
(==) : (fn(lhs : Self, rhs : Self) -> bool)(
|
|
170
|
+
lhs._inner == rhs._inner
|
|
171
|
+
)
|
|
176
172
|
)
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
export Set;
|
|
173
|
+
);
|
|
174
|
+
export(Set);
|