Navigation
- README
- Pure-Python feature set
- Syntactic macro feature set
- Examples of creating dialects using
mcpyrate
- REPL server
- Troubleshooting
- Design notes
- Essays
- Additional reading
- Contribution guidelines
Table of Contents
Python with prefix syntax for function calls, and automatic currying.
Powered by mcpyrate
and unpythonic
.
from unpythonic.dialects import dialects, Listhell # noqa: F401
from unpythonic import foldr, cons, nil, ll
(print, "hello from Listhell")
double = lambda x: 2 * x
my_map = lambda f: (foldr, (compose, cons, f), nil)
assert (my_map, double, (q, 1, 2, 3)) == (ll, 2, 4, 6)
In terms of unpythonic.syntax
, we implicitly enable prefix
and autocurry
for the whole module.
The following are dialect builtins:
apply
, aliased tounpythonic.fun.apply
compose
, aliased to unpythonic's currying right-composecomposerc
q
,u
,kw
for the prefix syntax (note these are notmcpyrate
'sq
andu
, but those fromunpythonic.syntax
, specifically forprefix
)
For detailed documentation of the language features, see unpythonic.syntax
.
If you need more stuff, unpythonic
is effectively the standard library of Listhell, on top of what Python itself already provides.
Listhell is a dialect of Python implemented via macros and a thin whole-module AST transformation. The dialect definition lives in unpythonic.dialects.listhell
. Usage examples can be found in the unit tests.
Listhell is essentially a demonstration of how Python could look, if it had Lisp's prefix syntax for function calls and Haskell's automatic currying.
It's also a minimal example of how to make an AST-transforming dialect.
Only outside-in macros that should expand after autocurry
(currently, unpythonic
provides no such macros) and inside-out macros that should expand before autocurry
(there are two, namely tco
and continuations
) can be used in programs written in the Listhell dialect.
If you like the idea and want autocurry for a Lisp, try spicy for Racket.
Not intended for serious use.
Prefix syntax of Lisp, speed of Python, and readability of Haskell, all in one.