-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpytkell.py
More file actions
43 lines (37 loc) · 2.05 KB
/
pytkell.py
File metadata and controls
43 lines (37 loc) · 2.05 KB
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
# -*- coding: utf-8 -*-
"""Pytkell: Because it's good to have a kell.
Powered by `mcpyrate` and `unpythonic`.
"""
__all__ = ["Pytkell"]
__version__ = '2.0.0'
from mcpyrate.quotes import macros, q # noqa: F401
from mcpyrate.dialects import Dialect
from mcpyrate.splicing import splice_dialect
class Pytkell(Dialect):
def transform_ast(self, tree): # tree is an ast.Module
with q as template:
__lang__ = "Pytkell" # noqa: F841, just provide it to user code.
from unpythonic.syntax import (macros, lazy, lazyrec, lazify, autocurry, # noqa: F401, F811
where,
let, letseq, letrec,
dlet, dletseq, dletrec,
blet, bletseq, bletrec,
local, delete, do, do0,
cond, forall)
# Auxiliary syntax elements for the macros.
from unpythonic.syntax import insist, deny # noqa: F401
# Functions that have a haskelly feel to them.
from unpythonic import (foldl, foldr, scanl, scanr, # noqa: F401
s, imathify, gmathify, frozendict,
memoize, fupdate, fup,
gmemoize, imemoize, fimemoize,
islice, take, drop, split_at, first, second, nth, last,
flip, rotate)
from unpythonic import composerc as compose # compose from Right, Currying (Haskell's . operator) # noqa: F401
# This is a bit lispy, but we're not going out of our way to provide
# a haskelly surface syntax for these.
from unpythonic import cons, car, cdr, ll, llist, nil # noqa: F401
with lazify, autocurry:
__paste_here__ # noqa: F821, just a splicing marker.
tree.body = splice_dialect(tree.body, template, "__paste_here__")
return tree