koatl 0.1.36__tar.gz → 0.1.38__tar.gz
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.
- {koatl-0.1.36 → koatl-0.1.38}/Cargo.lock +1 -1
- {koatl-0.1.36 → koatl-0.1.38}/PKG-INFO +1 -1
- {koatl-0.1.36 → koatl-0.1.38}/koatl/Cargo.toml +1 -1
- koatl-0.1.38/koatl/python/koatl/prelude/__init__.tl +61 -0
- {koatl-0.1.36 → koatl-0.1.38/koatl}/python/koatl/runtime/__init__.py +0 -3
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/runtime/virtual.py +4 -4
- koatl-0.1.38/koatl/python/koatl/std/alg/__init__.tl +5 -0
- {koatl-0.1.36/koatl/python/koatl/prelude/functional → koatl-0.1.38/koatl/python/koatl/std/alg}/async.tl +1 -1
- koatl-0.1.36/koatl/python/koatl/prelude/functional/algebra.tl → koatl-0.1.38/koatl/python/koatl/std/alg/base.tl +2 -0
- {koatl-0.1.36/python/koatl/prelude/functional → koatl-0.1.38/koatl/python/koatl/std/alg}/env.tl +1 -1
- {koatl-0.1.36/python/koatl/prelude/functional → koatl-0.1.38/koatl/python/koatl/std/alg}/memo.tl +2 -5
- {koatl-0.1.36/koatl/python/koatl/prelude/functional → koatl-0.1.38/koatl/python/koatl/std/alg}/result.tl +2 -24
- koatl-0.1.38/koatl/python/koatl/std/data/__init__.tl +1 -0
- {koatl-0.1.36/python/koatl/prelude/functional → koatl-0.1.38/koatl/python/koatl/std/data}/list.tl +2 -5
- koatl-0.1.38/koatl/python/koatl/std/io.tl +3 -0
- koatl-0.1.36/python/koatl/prelude/iterable.tl → koatl-0.1.38/koatl/python/koatl/std/iter.tl +4 -4
- koatl-0.1.38/koatl/python/koatl/std/lazy_module.tl +33 -0
- koatl-0.1.36/koatl/python/koatl/prelude/regex.tl → koatl-0.1.38/koatl/python/koatl/std/re.tl +3 -15
- koatl-0.1.36/koatl/python/koatl/runtime/classes.py → koatl-0.1.38/koatl/python/koatl/std/trait.py +1 -1
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/parser/src/ast.rs +7 -8
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/parser/src/lexer.rs +176 -94
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/parser/src/parser.rs +99 -60
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/parser/src/util.rs +5 -33
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/lib.rs +12 -1
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/py/emit.rs +3 -3
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/resolve_scopes.rs +72 -22
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/transform.rs +101 -36
- koatl-0.1.38/python/koatl/prelude/__init__.tl +61 -0
- {koatl-0.1.36/koatl → koatl-0.1.38}/python/koatl/runtime/__init__.py +0 -3
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/runtime/virtual.py +4 -4
- koatl-0.1.38/python/koatl/std/alg/__init__.tl +5 -0
- {koatl-0.1.36/python/koatl/prelude/functional → koatl-0.1.38/python/koatl/std/alg}/async.tl +1 -1
- koatl-0.1.36/python/koatl/prelude/functional/algebra.tl → koatl-0.1.38/python/koatl/std/alg/base.tl +2 -0
- {koatl-0.1.36/koatl/python/koatl/prelude/functional → koatl-0.1.38/python/koatl/std/alg}/env.tl +1 -1
- {koatl-0.1.36/koatl/python/koatl/prelude/functional → koatl-0.1.38/python/koatl/std/alg}/memo.tl +2 -5
- {koatl-0.1.36/python/koatl/prelude/functional → koatl-0.1.38/python/koatl/std/alg}/result.tl +2 -24
- koatl-0.1.38/python/koatl/std/data/__init__.tl +1 -0
- {koatl-0.1.36/koatl/python/koatl/prelude/functional → koatl-0.1.38/python/koatl/std/data}/list.tl +2 -5
- koatl-0.1.38/python/koatl/std/io.tl +3 -0
- koatl-0.1.36/koatl/python/koatl/prelude/iterable.tl → koatl-0.1.38/python/koatl/std/iter.tl +4 -4
- koatl-0.1.38/python/koatl/std/lazy_module.tl +33 -0
- koatl-0.1.36/python/koatl/prelude/regex.tl → koatl-0.1.38/python/koatl/std/re.tl +3 -15
- koatl-0.1.36/python/koatl/runtime/classes.py → koatl-0.1.38/python/koatl/std/trait.py +1 -1
- koatl-0.1.36/koatl/python/koatl/prelude/__init__.tl +0 -6
- koatl-0.1.36/koatl/python/koatl/prelude/functional/__init__.tl +0 -26
- koatl-0.1.36/koatl/python/koatl/prelude/io.tl +0 -5
- koatl-0.1.36/python/koatl/prelude/__init__.tl +0 -6
- koatl-0.1.36/python/koatl/prelude/functional/__init__.tl +0 -26
- koatl-0.1.36/python/koatl/prelude/io.tl +0 -5
- {koatl-0.1.36 → koatl-0.1.38}/Cargo.toml +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/README.md +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/.github/workflows/CI.yml +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/.gitignore +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/LICENSE +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/README.md +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/__init__.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/__main__.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/cli.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/notebook/magic.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/runtime/helpers.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/runtime/meta_finder.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/python/koatl/runtime/record.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/requirements.txt +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/src/emit_py.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/src/lib.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/containers.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/data.txt +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/decorators.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/destructure-for-and-fn.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/destructure.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/escape_ident.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/fstr.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/functions.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/generator.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/if_expr.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/loops.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/match.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/nary-list.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/placeholder.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/precedence.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/record.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/scopes.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/semantic_whitespace.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/short_circuit.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/base/with.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/async.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/aug_assign.tl +0 -0
- {koatl-0.1.36/koatl/tests/e2e/base → koatl-0.1.38/koatl/tests/e2e/prelude}/coal.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/env.tl +0 -0
- {koatl-0.1.36/koatl/tests/e2e/base → koatl-0.1.38/koatl/tests/e2e/prelude}/imports.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/iterables.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/list.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/memo.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/result.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/slice.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/try.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/prelude/virtual.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/util/__init__.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/util/module0.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/util/module1.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/e2e/util/module2.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/parse/arith.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/parse/assign.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/parse/block-comments.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/parse/deco.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/parse/func.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/parse/matches.tl +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/test_e2e.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl/tests/test_parse.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/Cargo.toml +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/parser/Cargo.toml +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/parser/src/lib.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/inference.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/main.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/parse_timer.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/parser.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/py/ast.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/py/mod.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/py/util.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/types.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/koatl-core/src/util.rs +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/pyproject.toml +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/__init__.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/__main__.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/cli.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/notebook/magic.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/runtime/helpers.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/runtime/meta_finder.py +0 -0
- {koatl-0.1.36 → koatl-0.1.38}/python/koatl/runtime/record.py +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import koatl.std.iter.Iterable
|
|
2
|
+
|
|
3
|
+
Extension.trait(Iterable)
|
|
4
|
+
|
|
5
|
+
import koatl.std.data.List
|
|
6
|
+
|
|
7
|
+
Extension.property(list, "len")& List.len.fget
|
|
8
|
+
|
|
9
|
+
import koatl.std.alg.*
|
|
10
|
+
|
|
11
|
+
Extension.property(object, "result")& self => Result(self)
|
|
12
|
+
|
|
13
|
+
__tl__.Ok = Ok
|
|
14
|
+
__tl__.Err = Err
|
|
15
|
+
__tl__.Result = Result
|
|
16
|
+
|
|
17
|
+
__tl__.op_coal = (x, f) =>
|
|
18
|
+
if x matches Result():
|
|
19
|
+
return x.coalesce(f)
|
|
20
|
+
|
|
21
|
+
if not koatl.std.alg.result.infer_ok(x):
|
|
22
|
+
return f()
|
|
23
|
+
return x
|
|
24
|
+
|
|
25
|
+
__tl__.op_map = (x, f) =>
|
|
26
|
+
if x matches Result():
|
|
27
|
+
return x.map(f)
|
|
28
|
+
|
|
29
|
+
if koatl.std.alg.result.infer_ok(x):
|
|
30
|
+
return f(x)
|
|
31
|
+
return x
|
|
32
|
+
|
|
33
|
+
__tl__.memo_value = Memo.value
|
|
34
|
+
__tl__.async_memo_value = AsyncMemo.value
|
|
35
|
+
|
|
36
|
+
import koatl.std.re.Pattern
|
|
37
|
+
|
|
38
|
+
Extension.method(str, "match")& (regex, str) => Pattern(regex).match(str)
|
|
39
|
+
|
|
40
|
+
# Note: the below methods have arguments in reverse order to Python's re module.
|
|
41
|
+
Extension.method(str, "matches")& (str, regex) => Pattern(regex).match(str)
|
|
42
|
+
Extension.method(str, "search")& (str, regex) => Pattern(regex).search(str)
|
|
43
|
+
|
|
44
|
+
import koatl.std.lazy_module.LazyModule
|
|
45
|
+
|
|
46
|
+
export import koatl.std.trait.*
|
|
47
|
+
export Result, Ok, Err, Env, Memo, Async, AsyncMemo
|
|
48
|
+
export std = LazyModule("koatl.std")
|
|
49
|
+
|
|
50
|
+
ModuleProxy = class:
|
|
51
|
+
__init__ = (self) =>
|
|
52
|
+
self._modules = {}
|
|
53
|
+
|
|
54
|
+
__getattr__ = (self, attr) =>
|
|
55
|
+
if attr not in self._modules:
|
|
56
|
+
self._modules[attr] = LazyModule(attr)
|
|
57
|
+
return self._modules[attr]
|
|
58
|
+
|
|
59
|
+
__repr__ = self => f"ModuleProxy({self._modules})"
|
|
60
|
+
|
|
61
|
+
export mod = ModuleProxy()
|
|
@@ -19,7 +19,6 @@ meta_finder.install_hook()
|
|
|
19
19
|
from .virtual import *
|
|
20
20
|
from .record import *
|
|
21
21
|
from .helpers import *
|
|
22
|
-
from .classes import *
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
def dummy(name):
|
|
@@ -52,7 +51,6 @@ __tl__ = SimpleNamespace(
|
|
|
52
51
|
**{name: helpers.__dict__[name] for name in helpers.__all__},
|
|
53
52
|
**{name: record.__dict__[name] for name in record.__all__},
|
|
54
53
|
**{name: virtual.__dict__[name] for name in virtual.__all__},
|
|
55
|
-
**{name: classes.__dict__[name] for name in classes.__all__},
|
|
56
54
|
)
|
|
57
55
|
|
|
58
56
|
|
|
@@ -61,5 +59,4 @@ __all__ = [
|
|
|
61
59
|
*helpers.__all__,
|
|
62
60
|
*record.__all__,
|
|
63
61
|
*virtual.__all__,
|
|
64
|
-
*classes.__all__,
|
|
65
62
|
]
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
from functools import partial
|
|
2
2
|
from itertools import count
|
|
3
3
|
from types import SimpleNamespace
|
|
4
|
-
from
|
|
4
|
+
from koatl._rs import fast_vget, fast_vset, fast_vset_trait
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def vget(obj, name, ignore_traits=False):
|
|
8
8
|
try:
|
|
9
9
|
return getattr(obj, name)
|
|
10
|
-
except AttributeError:
|
|
11
|
-
|
|
10
|
+
except AttributeError as e:
|
|
11
|
+
orig_err = e
|
|
12
12
|
|
|
13
13
|
# special case for iter - this could be implemented using types and trait vtbls
|
|
14
14
|
# but this is simpler and probably faster
|
|
@@ -38,7 +38,7 @@ def vget(obj, name, ignore_traits=False):
|
|
|
38
38
|
|
|
39
39
|
return partial(v, obj)
|
|
40
40
|
|
|
41
|
-
raise
|
|
41
|
+
raise orig_err
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
def vhas(obj, name, ignore_traits=False):
|
{koatl-0.1.36/python/koatl/prelude/functional → koatl-0.1.38/koatl/python/koatl/std/alg}/memo.tl
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import collections.defaultdict
|
|
2
2
|
import functools.wraps
|
|
3
3
|
|
|
4
|
-
import .
|
|
4
|
+
import .base.(MonadOnce, Identity)
|
|
5
5
|
import .result.(Result, Ok, Err)
|
|
6
6
|
import .async.(Async)
|
|
7
7
|
|
|
@@ -181,7 +181,4 @@ export AsyncMemo = class(MonadOnce):
|
|
|
181
181
|
|
|
182
182
|
except StopIteration(value=value):
|
|
183
183
|
return value
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
__tl__.memo_value = Memo.value
|
|
187
|
-
__tl__.async_memo_value = AsyncMemo.value
|
|
184
|
+
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import functools.wraps
|
|
2
|
-
import .
|
|
2
|
+
import .base.(Identity, MonadOnce)
|
|
3
3
|
|
|
4
4
|
infer_ok = x =>
|
|
5
5
|
x match:
|
|
@@ -158,26 +158,4 @@ export Err = class(Result):
|
|
|
158
158
|
if self.value matches BaseException():
|
|
159
159
|
raise self.value
|
|
160
160
|
raise ValueError(f"Expected Ok, got {repr(self)}")
|
|
161
|
-
coalesce = (self, f) => f()
|
|
162
|
-
|
|
163
|
-
Extension.property(object, "result")& self => Result
|
|
164
|
-
|
|
165
|
-
__tl__.Ok = Ok
|
|
166
|
-
__tl__.Err = Err
|
|
167
|
-
__tl__.Result = Result
|
|
168
|
-
|
|
169
|
-
__tl__.op_coal = (x, f) =>
|
|
170
|
-
if x matches Result():
|
|
171
|
-
return x.coalesce(f)
|
|
172
|
-
|
|
173
|
-
if not infer_ok(x):
|
|
174
|
-
return f()
|
|
175
|
-
return x
|
|
176
|
-
|
|
177
|
-
__tl__.op_map = (x, f) =>
|
|
178
|
-
if x matches Result():
|
|
179
|
-
return x.map(f)
|
|
180
|
-
|
|
181
|
-
if infer_ok(x):
|
|
182
|
-
return f(x)
|
|
183
|
-
return x
|
|
161
|
+
coalesce = (self, f) => f()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export import .list.List
|
{koatl-0.1.36/python/koatl/prelude/functional → koatl-0.1.38/koatl/python/koatl/std/data}/list.tl
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
import .Monad
|
|
3
|
+
import koatl.std.alg.Monad
|
|
4
4
|
|
|
5
5
|
export List = class(Monad):
|
|
6
6
|
__new__ = (cls, *args, **kwargs) => raise ValueError(
|
|
@@ -19,7 +19,4 @@ export List = class(Monad):
|
|
|
19
19
|
|
|
20
20
|
pure = staticmethod& x => [x]
|
|
21
21
|
|
|
22
|
-
len = property& self => len(self)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Extension.property(list, "len")& List.len.fget
|
|
22
|
+
len = property& self => len(self)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
import builtins
|
|
3
|
-
import .functional.(Traversable, Ok, Err, Memo, Async, AsyncMemo, Result)
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import koatl.std.trait.Trait
|
|
5
|
+
import .alg.(Traversable, Ok, Err, Memo, Async, AsyncMemo, Result)
|
|
6
|
+
|
|
7
|
+
export Iterable = class(Traversable, Trait):
|
|
6
8
|
iter = Trait.abstract& self => None
|
|
7
9
|
|
|
8
10
|
skip = (self, n) =>
|
|
@@ -259,8 +261,6 @@ export Iterable = Extension.trait& class(Traversable, Trait):
|
|
|
259
261
|
Record(self.iter)
|
|
260
262
|
|
|
261
263
|
traverse = (self, f=None) =>
|
|
262
|
-
import .functional.(Async, Result)
|
|
263
|
-
|
|
264
264
|
if f === None:
|
|
265
265
|
f = x => x
|
|
266
266
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
import collections
|
|
3
|
+
|
|
4
|
+
export LazyModule = class:
|
|
5
|
+
__init__ = (self, name) =>
|
|
6
|
+
self._name = name
|
|
7
|
+
self._module = None
|
|
8
|
+
self._submodules = {}
|
|
9
|
+
|
|
10
|
+
__getattr__ = (self, attr) =>
|
|
11
|
+
try:
|
|
12
|
+
if self._module === None:
|
|
13
|
+
self._module = importlib.import_module(self._name)
|
|
14
|
+
|
|
15
|
+
if hasattr(self._module, "__path__"):
|
|
16
|
+
if attr not in self._submodules:
|
|
17
|
+
self._submodules[attr] =
|
|
18
|
+
if importlib.util.find_spec(f"{self._name}.{attr}", self._module.__path__):
|
|
19
|
+
LazyModule(f"{self._name}.{attr}")
|
|
20
|
+
else:
|
|
21
|
+
None
|
|
22
|
+
|
|
23
|
+
if self._submodules[attr] <=> None:
|
|
24
|
+
return self._submodules[attr]
|
|
25
|
+
|
|
26
|
+
if hasattr(self._module, attr):
|
|
27
|
+
return getattr(self._module, attr)
|
|
28
|
+
except e:
|
|
29
|
+
raise ValueError(str(e))
|
|
30
|
+
|
|
31
|
+
raise AttributeError(f"Module '{self._name}' has no attribute '{attr}'")
|
|
32
|
+
|
|
33
|
+
__repr__ = self => f"LazyModule({self._name})"
|
koatl-0.1.36/koatl/python/koatl/prelude/regex.tl → koatl-0.1.38/koatl/python/koatl/std/re.tl
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import collections
|
|
3
|
-
import .
|
|
3
|
+
import .alg.Result
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export Pattern = class:
|
|
6
6
|
__slots__ = ("pattern",)
|
|
7
7
|
|
|
8
8
|
__init__ = (self, pattern) =>
|
|
@@ -45,16 +45,4 @@ export Regex = class:
|
|
|
45
45
|
|
|
46
46
|
match = property& self => self._match.group(0)
|
|
47
47
|
|
|
48
|
-
__repr__ = self => f"Match({self._match})"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Extension.method(str, "match")& (regex, str) => Regex(regex).match(str)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# Note: the below methods have arguments in reverse order to Python's re module.
|
|
55
|
-
|
|
56
|
-
Extension.method(str, "matches")& (str, regex) =>
|
|
57
|
-
Regex(regex).match(str)
|
|
58
|
-
|
|
59
|
-
Extension.method(str, "search")& (str, regex) =>
|
|
60
|
-
Regex(regex).search(str)
|
|
48
|
+
__repr__ = self => f"Match({self._match})"
|
koatl-0.1.36/koatl/python/koatl/runtime/classes.py → koatl-0.1.38/koatl/python/koatl/std/trait.py
RENAMED
|
@@ -40,7 +40,7 @@ class MappingMeta(type):
|
|
|
40
40
|
return [(k, v) for k, v in inspect.getmembers(self) if not k.startswith("_")]
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
# A utility base class to inherit from
|
|
43
|
+
# A utility base class to inherit from that implements Mapping on the type and thus destructuring.
|
|
44
44
|
class Class(metaclass=MappingMeta):
|
|
45
45
|
pass
|
|
46
46
|
|
|
@@ -97,21 +97,20 @@ pub enum Literal<'a> {
|
|
|
97
97
|
pub type SLiteral<'a> = Spanned<Literal<'a>>;
|
|
98
98
|
|
|
99
99
|
#[derive(Debug, Clone)]
|
|
100
|
-
pub enum
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
pub enum ImportLeaf<'a> {
|
|
101
|
+
Multi(Vec<ImportTree<'a>>),
|
|
102
|
+
Single(SIdent<'a>, Option<SIdent<'a>>),
|
|
103
|
+
This(Option<SIdent<'a>>),
|
|
103
104
|
Star,
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
#[derive(Debug, Clone)]
|
|
107
|
-
pub struct
|
|
108
|
+
pub struct ImportTree<'a> {
|
|
108
109
|
pub trunk: Vec<SIdent<'a>>,
|
|
109
|
-
pub
|
|
110
|
+
pub leaf: Spanned<ImportLeaf<'a>>,
|
|
110
111
|
|
|
111
112
|
// number of dots prepending the trunk
|
|
112
113
|
pub level: usize,
|
|
113
|
-
|
|
114
|
-
pub reexport: bool,
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
@@ -133,7 +132,7 @@ pub enum Stmt<'a, TTree: Tree> {
|
|
|
133
132
|
Return(TTree::Expr),
|
|
134
133
|
While(TTree::Expr, TTree::Expr),
|
|
135
134
|
For(TTree::Pattern, TTree::Expr, TTree::Expr),
|
|
136
|
-
Import(
|
|
135
|
+
Import(ImportTree<'a>, bool),
|
|
137
136
|
Try(TTree::Expr, Vec<MatchCase<TTree>>, Option<TTree::Expr>),
|
|
138
137
|
Raise(Option<TTree::Expr>),
|
|
139
138
|
|