unpythonic 0.15.3__tar.gz → 0.15.5__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.
- {unpythonic-0.15.3/unpythonic.egg-info → unpythonic-0.15.5}/PKG-INFO +23 -16
- {unpythonic-0.15.3 → unpythonic-0.15.5}/README.md +16 -6
- unpythonic-0.15.5/pyproject.toml +76 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/__init__.py +1 -1
- unpythonic-0.15.5/unpythonic/dialects/__init__.py +17 -0
- unpythonic-0.15.5/unpythonic/dialects/lispython.py +88 -0
- unpythonic-0.15.5/unpythonic/dialects/listhell.py +35 -0
- unpythonic-0.15.5/unpythonic/dialects/pytkell.py +51 -0
- unpythonic-0.15.5/unpythonic/syntax/00_stuff/letdo.py +980 -0
- unpythonic-0.15.3/AUTHORS.md +0 -22
- unpythonic-0.15.3/PKG-INFO +0 -887
- unpythonic-0.15.3/setup.cfg +0 -4
- unpythonic-0.15.3/setup.py +0 -104
- unpythonic-0.15.3/unpythonic.egg-info/SOURCES.txt +0 -71
- unpythonic-0.15.3/unpythonic.egg-info/dependency_links.txt +0 -1
- unpythonic-0.15.3/unpythonic.egg-info/not-zip-safe +0 -1
- unpythonic-0.15.3/unpythonic.egg-info/top_level.txt +0 -1
- {unpythonic-0.15.3 → unpythonic-0.15.5}/LICENSE.md +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/amb.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/arity.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/assignonce.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/collections.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/conditions.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/dispatch.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/dynassign.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/ec.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/env.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/excutil.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/fix.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/fold.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/fploop.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/fun.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/funutil.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/fup.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/gmemo.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/gtco.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/it.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/lazyutil.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/let.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/lispylet.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/llist.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/mathseq.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/misc.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/net/__init__.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/net/client.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/net/common.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/net/msg.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/net/ptyproxy.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/net/server.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/net/util.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/numutil.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/regutil.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/seq.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/singleton.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/slicing.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/symbol.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/__init__.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/autocurry.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/autoref.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/dbg.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/forall.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/ifexprs.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/lambdatools.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/lazify.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/letdo.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/letdoutil.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/letsyntax.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/nameutil.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/nb.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/prefix.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/scopeanalyzer.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/simplelet.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/tailtools.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/testingtools.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/syntax/util.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/tco.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/test/fixtures.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/timeutil.py +0 -0
- {unpythonic-0.15.3 → unpythonic-0.15.5}/unpythonic/typecheck.py +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unpythonic
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.5
|
|
4
4
|
Summary: Supercharge your Python with parts of Lisp and Haskell.
|
|
5
|
-
Home-page: https://github.com/Technologicat/unpythonic
|
|
6
|
-
Author: Juha Jeronen
|
|
7
|
-
Author-email: juha.m.jeronen@gmail.com
|
|
8
|
-
License: BSD
|
|
9
5
|
Keywords: functional-programming,language-extension,syntactic-macros,tail-call-optimization,tco,continuations,currying,lazy-evaluation,dynamic-variable,macros,lisp,scheme,racket,haskell
|
|
10
|
-
|
|
6
|
+
Author-Email: Juha Jeronen <juha.m.jeronen@gmail.com>
|
|
7
|
+
License: BSD
|
|
11
8
|
Classifier: Development Status :: 4 - Beta
|
|
12
9
|
Classifier: Environment :: Console
|
|
13
10
|
Classifier: Intended Audience :: Developers
|
|
@@ -24,11 +21,11 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
|
24
21
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
25
22
|
Classifier: Topic :: Software Development :: Libraries
|
|
26
23
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
-
|
|
28
|
-
Requires-Python:
|
|
24
|
+
Project-URL: Repository, https://github.com/Technologicat/unpythonic
|
|
25
|
+
Requires-Python: <3.13,>=3.8
|
|
26
|
+
Requires-Dist: mcpyrate>=3.6.4
|
|
27
|
+
Requires-Dist: sympy>=1.13
|
|
29
28
|
Description-Content-Type: text/markdown
|
|
30
|
-
License-File: LICENSE.md
|
|
31
|
-
License-File: AUTHORS.md
|
|
32
29
|
|
|
33
30
|
# Unpythonic: Python meets Lisp and Haskell
|
|
34
31
|
|
|
@@ -836,21 +833,31 @@ assert (my_map, double, (q, 1, 2, 3)) == (ll, 2, 4, 6)
|
|
|
836
833
|
```
|
|
837
834
|
</details>
|
|
838
835
|
|
|
839
|
-
##
|
|
836
|
+
## Install & uninstall
|
|
840
837
|
|
|
841
|
-
|
|
838
|
+
### From PyPI
|
|
842
839
|
|
|
843
|
-
|
|
840
|
+
```bash
|
|
841
|
+
pip install unpythonic
|
|
842
|
+
```
|
|
844
843
|
|
|
845
|
-
|
|
844
|
+
### From source
|
|
846
845
|
|
|
847
846
|
Clone the repo from GitHub. Then, navigate to it in a terminal, and:
|
|
848
847
|
|
|
849
848
|
```bash
|
|
850
|
-
pip install .
|
|
849
|
+
pip install . --no-compile
|
|
851
850
|
```
|
|
852
851
|
|
|
853
|
-
|
|
852
|
+
If you intend to use the macro layer of `unpythonic`, the `--no-compile` flag is important. It prevents an **incorrect** precompilation, without macro support, that `pip install` would otherwise do at its `bdist_wheel` step.
|
|
853
|
+
|
|
854
|
+
For most Python projects such precompilation is just fine - it's just macro-enabled projects that shouldn't be precompiled with standard tools.
|
|
855
|
+
|
|
856
|
+
If `--no-compile` is NOT used, the precompiled bytecode cache may cause errors such as `ImportError: cannot import name 'macros' from 'mcpyrate.quotes'`, when you try to e.g. `from unpythonic.syntax import macros, let`. In-tree, it might work, but against an installed copy, it will fail. It has happened that my CI setup did not detect this kind of failure.
|
|
857
|
+
|
|
858
|
+
This is a common issue when using macro expanders in Python.
|
|
859
|
+
|
|
860
|
+
### Uninstall
|
|
854
861
|
|
|
855
862
|
```bash
|
|
856
863
|
pip uninstall unpythonic
|
|
@@ -804,21 +804,31 @@ assert (my_map, double, (q, 1, 2, 3)) == (ll, 2, 4, 6)
|
|
|
804
804
|
```
|
|
805
805
|
</details>
|
|
806
806
|
|
|
807
|
-
##
|
|
807
|
+
## Install & uninstall
|
|
808
808
|
|
|
809
|
-
|
|
809
|
+
### From PyPI
|
|
810
810
|
|
|
811
|
-
|
|
811
|
+
```bash
|
|
812
|
+
pip install unpythonic
|
|
813
|
+
```
|
|
812
814
|
|
|
813
|
-
|
|
815
|
+
### From source
|
|
814
816
|
|
|
815
817
|
Clone the repo from GitHub. Then, navigate to it in a terminal, and:
|
|
816
818
|
|
|
817
819
|
```bash
|
|
818
|
-
pip install .
|
|
820
|
+
pip install . --no-compile
|
|
819
821
|
```
|
|
820
822
|
|
|
821
|
-
|
|
823
|
+
If you intend to use the macro layer of `unpythonic`, the `--no-compile` flag is important. It prevents an **incorrect** precompilation, without macro support, that `pip install` would otherwise do at its `bdist_wheel` step.
|
|
824
|
+
|
|
825
|
+
For most Python projects such precompilation is just fine - it's just macro-enabled projects that shouldn't be precompiled with standard tools.
|
|
826
|
+
|
|
827
|
+
If `--no-compile` is NOT used, the precompiled bytecode cache may cause errors such as `ImportError: cannot import name 'macros' from 'mcpyrate.quotes'`, when you try to e.g. `from unpythonic.syntax import macros, let`. In-tree, it might work, but against an installed copy, it will fail. It has happened that my CI setup did not detect this kind of failure.
|
|
828
|
+
|
|
829
|
+
This is a common issue when using macro expanders in Python.
|
|
830
|
+
|
|
831
|
+
### Uninstall
|
|
822
832
|
|
|
823
833
|
```bash
|
|
824
834
|
pip uninstall unpythonic
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "unpythonic"
|
|
3
|
+
description = "Supercharge your Python with parts of Lisp and Haskell."
|
|
4
|
+
authors = [
|
|
5
|
+
{ name = "Juha Jeronen", email = "juha.m.jeronen@gmail.com" },
|
|
6
|
+
]
|
|
7
|
+
requires-python = ">=3.8,<3.13"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
dynamic = []
|
|
10
|
+
dependencies = [
|
|
11
|
+
"mcpyrate>=3.6.4",
|
|
12
|
+
"sympy>=1.13",
|
|
13
|
+
]
|
|
14
|
+
keywords = [
|
|
15
|
+
"functional-programming",
|
|
16
|
+
"language-extension",
|
|
17
|
+
"syntactic-macros",
|
|
18
|
+
"tail-call-optimization",
|
|
19
|
+
"tco",
|
|
20
|
+
"continuations",
|
|
21
|
+
"currying",
|
|
22
|
+
"lazy-evaluation",
|
|
23
|
+
"dynamic-variable",
|
|
24
|
+
"macros",
|
|
25
|
+
"lisp",
|
|
26
|
+
"scheme",
|
|
27
|
+
"racket",
|
|
28
|
+
"haskell",
|
|
29
|
+
]
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Development Status :: 4 - Beta",
|
|
32
|
+
"Environment :: Console",
|
|
33
|
+
"Intended Audience :: Developers",
|
|
34
|
+
"License :: OSI Approved :: BSD License",
|
|
35
|
+
"Operating System :: POSIX :: Linux",
|
|
36
|
+
"Programming Language :: Python",
|
|
37
|
+
"Programming Language :: Python :: 3",
|
|
38
|
+
"Programming Language :: Python :: 3.8",
|
|
39
|
+
"Programming Language :: Python :: 3.9",
|
|
40
|
+
"Programming Language :: Python :: 3.10",
|
|
41
|
+
"Programming Language :: Python :: 3.11",
|
|
42
|
+
"Programming Language :: Python :: 3.12",
|
|
43
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
44
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
45
|
+
"Topic :: Software Development :: Libraries",
|
|
46
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
47
|
+
]
|
|
48
|
+
version = "0.15.5"
|
|
49
|
+
|
|
50
|
+
[project.license]
|
|
51
|
+
text = "BSD"
|
|
52
|
+
|
|
53
|
+
[project.urls]
|
|
54
|
+
Repository = "https://github.com/Technologicat/unpythonic"
|
|
55
|
+
|
|
56
|
+
[build-system]
|
|
57
|
+
requires = [
|
|
58
|
+
"pdm-backend",
|
|
59
|
+
]
|
|
60
|
+
build-backend = "pdm.backend"
|
|
61
|
+
|
|
62
|
+
[tool.pdm.version]
|
|
63
|
+
source = "file"
|
|
64
|
+
path = "unpythonic/__init__.py"
|
|
65
|
+
|
|
66
|
+
[tool.pdm.build]
|
|
67
|
+
includes = [
|
|
68
|
+
"unpythonic",
|
|
69
|
+
]
|
|
70
|
+
excludes = [
|
|
71
|
+
"**/tests",
|
|
72
|
+
"**/__pycache__",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
show_error_codes = true
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Dialects: Python the way you want it.
|
|
3
|
+
|
|
4
|
+
These dialects, i.e. whole-module syntax transformations, are powered by
|
|
5
|
+
`mcpyrate`'s dialect subsystem. The user manual is at:
|
|
6
|
+
https://github.com/Technologicat/mcpyrate/blob/master/doc/dialects.md
|
|
7
|
+
|
|
8
|
+
We provide these dialects mainly to demonstrate how to use that subsystem
|
|
9
|
+
to customize Python beyond what a local macro expander can do.
|
|
10
|
+
|
|
11
|
+
For examples of how to use these particular dialects, see the unit tests.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
# re-exports
|
|
15
|
+
from .lispython import * # noqa: F401, F403
|
|
16
|
+
from .listhell import * # noqa: F401, F403
|
|
17
|
+
from .pytkell import * # noqa: F401, F403
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Lispython: The love child of Python and Scheme.
|
|
3
|
+
|
|
4
|
+
Powered by `mcpyrate` and `unpythonic`.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__all__ = ["Lispython", "Lispy"]
|
|
8
|
+
|
|
9
|
+
__version__ = '2.0.0'
|
|
10
|
+
|
|
11
|
+
from mcpyrate.quotes import macros, q # noqa: F401
|
|
12
|
+
|
|
13
|
+
from mcpyrate.dialects import Dialect
|
|
14
|
+
from mcpyrate.splicing import splice_dialect
|
|
15
|
+
|
|
16
|
+
class Lispython(Dialect):
|
|
17
|
+
"""**Schemers rejoice!**
|
|
18
|
+
|
|
19
|
+
Multiple musings mix in a lambda,
|
|
20
|
+
Lament no longer the lack of let.
|
|
21
|
+
Languish no longer labelless, lambda,
|
|
22
|
+
Linked lists cons and fold.
|
|
23
|
+
Tail-call into recursion divine,
|
|
24
|
+
The final value always provide.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def transform_ast(self, tree): # tree is an ast.Module
|
|
28
|
+
with q as template:
|
|
29
|
+
__lang__ = "Lispython" # noqa: F841, just provide it to user code.
|
|
30
|
+
from unpythonic.syntax import (macros, tco, autoreturn, # noqa: F401, F811
|
|
31
|
+
multilambda, quicklambda, namedlambda, fn,
|
|
32
|
+
where,
|
|
33
|
+
let, letseq, letrec,
|
|
34
|
+
dlet, dletseq, dletrec,
|
|
35
|
+
blet, bletseq, bletrec,
|
|
36
|
+
local, delete, do, do0,
|
|
37
|
+
let_syntax, abbrev, block, expr,
|
|
38
|
+
cond)
|
|
39
|
+
from unpythonic import cons, car, cdr, ll, llist, nil, prod, dyn, Values # noqa: F401, F811
|
|
40
|
+
with autoreturn, quicklambda, multilambda, namedlambda, tco:
|
|
41
|
+
__paste_here__ # noqa: F821, just a splicing marker.
|
|
42
|
+
|
|
43
|
+
# Beginning with 3.6.0, `mcpyrate` makes available the source location info
|
|
44
|
+
# of the dialect-import that imported this dialect.
|
|
45
|
+
if hasattr(self, "lineno"): # mcpyrate 3.6.0+
|
|
46
|
+
tree.body = splice_dialect(tree.body, template, "__paste_here__",
|
|
47
|
+
lineno=self.lineno, col_offset=self.col_offset)
|
|
48
|
+
else:
|
|
49
|
+
tree.body = splice_dialect(tree.body, template, "__paste_here__")
|
|
50
|
+
|
|
51
|
+
return tree
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Lispy(Dialect):
|
|
55
|
+
"""**Pythonistas rejoice!**
|
|
56
|
+
|
|
57
|
+
O language like Lisp, like Python!
|
|
58
|
+
Semantic changes sensibly carry,
|
|
59
|
+
Python's primary virtue vindicate.
|
|
60
|
+
Ire me not with implicit imports,
|
|
61
|
+
Let my IDE label mistakes.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
def transform_ast(self, tree): # tree is an ast.Module
|
|
65
|
+
with q as template:
|
|
66
|
+
__lang__ = "Lispy" # noqa: F841, just provide it to user code.
|
|
67
|
+
from unpythonic.syntax import (macros, tco, autoreturn, # noqa: F401, F811
|
|
68
|
+
multilambda, quicklambda, namedlambda)
|
|
69
|
+
# The important point is none of these expect the user code to look like
|
|
70
|
+
# anything but regular Python, so IDEs won't yell about undefined names;
|
|
71
|
+
# just the semantics are slightly different.
|
|
72
|
+
#
|
|
73
|
+
# Even if the user code uses `fn[]` (to make `quicklambda` actually do anything),
|
|
74
|
+
# that macro must be explicitly imported. It works, because `splice_dialect`
|
|
75
|
+
# hoists macro-imports from the top level of the user code into the top level
|
|
76
|
+
# of the template.
|
|
77
|
+
with autoreturn, quicklambda, multilambda, namedlambda, tco:
|
|
78
|
+
__paste_here__ # noqa: F821, just a splicing marker.
|
|
79
|
+
|
|
80
|
+
# Beginning with 3.6.0, `mcpyrate` makes available the source location info
|
|
81
|
+
# of the dialect-import that imported this dialect.
|
|
82
|
+
if hasattr(self, "lineno"): # mcpyrate 3.6.0+
|
|
83
|
+
tree.body = splice_dialect(tree.body, template, "__paste_here__",
|
|
84
|
+
lineno=self.lineno, col_offset=self.col_offset)
|
|
85
|
+
else:
|
|
86
|
+
tree.body = splice_dialect(tree.body, template, "__paste_here__")
|
|
87
|
+
|
|
88
|
+
return tree
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Listhell: It's not Lisp, it's not Python, it's not Haskell.
|
|
3
|
+
|
|
4
|
+
Powered by `mcpyrate` and `unpythonic`.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__all__ = ["Listhell"]
|
|
8
|
+
|
|
9
|
+
__version__ = '2.0.0'
|
|
10
|
+
|
|
11
|
+
from mcpyrate.quotes import macros, q # noqa: F401
|
|
12
|
+
|
|
13
|
+
from mcpyrate.dialects import Dialect
|
|
14
|
+
from mcpyrate.splicing import splice_dialect
|
|
15
|
+
|
|
16
|
+
class Listhell(Dialect):
|
|
17
|
+
def transform_ast(self, tree): # tree is an ast.Module
|
|
18
|
+
with q as template:
|
|
19
|
+
__lang__ = "Listhell" # noqa: F841, just provide it to user code.
|
|
20
|
+
from unpythonic.syntax import macros, prefix, q, u, kw, autocurry # noqa: F401, F811
|
|
21
|
+
# Auxiliary syntax elements for the macros
|
|
22
|
+
from unpythonic import apply # noqa: F401
|
|
23
|
+
from unpythonic import composerc as compose # compose from Right, Currying # noqa: F401
|
|
24
|
+
with prefix, autocurry:
|
|
25
|
+
__paste_here__ # noqa: F821, just a splicing marker.
|
|
26
|
+
|
|
27
|
+
# Beginning with 3.6.0, `mcpyrate` makes available the source location info
|
|
28
|
+
# of the dialect-import that imported this dialect.
|
|
29
|
+
if hasattr(self, "lineno"): # mcpyrate 3.6.0+
|
|
30
|
+
tree.body = splice_dialect(tree.body, template, "__paste_here__",
|
|
31
|
+
lineno=self.lineno, col_offset=self.col_offset)
|
|
32
|
+
else:
|
|
33
|
+
tree.body = splice_dialect(tree.body, template, "__paste_here__")
|
|
34
|
+
|
|
35
|
+
return tree
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Pytkell: Because it's good to have a kell.
|
|
3
|
+
|
|
4
|
+
Powered by `mcpyrate` and `unpythonic`.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__all__ = ["Pytkell"]
|
|
8
|
+
|
|
9
|
+
__version__ = '2.0.0'
|
|
10
|
+
|
|
11
|
+
from mcpyrate.quotes import macros, q # noqa: F401
|
|
12
|
+
|
|
13
|
+
from mcpyrate.dialects import Dialect
|
|
14
|
+
from mcpyrate.splicing import splice_dialect
|
|
15
|
+
|
|
16
|
+
class Pytkell(Dialect):
|
|
17
|
+
def transform_ast(self, tree): # tree is an ast.Module
|
|
18
|
+
with q as template:
|
|
19
|
+
__lang__ = "Pytkell" # noqa: F841, just provide it to user code.
|
|
20
|
+
from unpythonic.syntax import (macros, lazy, lazyrec, lazify, autocurry, # noqa: F401, F811
|
|
21
|
+
where,
|
|
22
|
+
let, letseq, letrec,
|
|
23
|
+
dlet, dletseq, dletrec,
|
|
24
|
+
blet, bletseq, bletrec,
|
|
25
|
+
local, delete, do, do0,
|
|
26
|
+
cond, forall)
|
|
27
|
+
# Auxiliary syntax elements for the macros.
|
|
28
|
+
from unpythonic.syntax import insist, deny # noqa: F401
|
|
29
|
+
# Functions that have a haskelly feel to them.
|
|
30
|
+
from unpythonic import (foldl, foldr, scanl, scanr, # noqa: F401
|
|
31
|
+
s, imathify, gmathify, frozendict,
|
|
32
|
+
memoize, fupdate, fup,
|
|
33
|
+
gmemoize, imemoize, fimemoize,
|
|
34
|
+
islice, take, drop, split_at, first, second, nth, last,
|
|
35
|
+
flip, rotate)
|
|
36
|
+
from unpythonic import composerc as compose # compose from Right, Currying (Haskell's . operator) # noqa: F401
|
|
37
|
+
# This is a bit lispy, but we're not going out of our way to provide
|
|
38
|
+
# a haskelly surface syntax for these.
|
|
39
|
+
from unpythonic import cons, car, cdr, ll, llist, nil # noqa: F401
|
|
40
|
+
with lazify, autocurry:
|
|
41
|
+
__paste_here__ # noqa: F821, just a splicing marker.
|
|
42
|
+
|
|
43
|
+
# Beginning with 3.6.0, `mcpyrate` makes available the source location info
|
|
44
|
+
# of the dialect-import that imported this dialect.
|
|
45
|
+
if hasattr(self, "lineno"): # mcpyrate 3.6.0+
|
|
46
|
+
tree.body = splice_dialect(tree.body, template, "__paste_here__",
|
|
47
|
+
lineno=self.lineno, col_offset=self.col_offset)
|
|
48
|
+
else:
|
|
49
|
+
tree.body = splice_dialect(tree.body, template, "__paste_here__")
|
|
50
|
+
|
|
51
|
+
return tree
|