Skip to content

Instantly share code, notes, and snippets.

View ashpool37's full-sized avatar
🌠
You're gonna carry that weight.

Artem Zhurikhin ashpool37

🌠
You're gonna carry that weight.
View GitHub Profile
from typing import Any, Dict, List, Mapping, Union
# Values for JSON that aren't nested
JSON_v = Union[str, int, float, bool, None]
# If MyPy ever permits recursive definitions, just uncomment this:
# JSON = Union[List['JSON'], Mapping[str, 'JSON'], JSON_v]
# Until then, here's a multi-layer way to represent any (reasonable) JSON we
# might send or receive. It terminates at JSON_4, so the maximum depth of
@kurinoku
kurinoku / eval.rkt
Last active December 10, 2023 21:28
[Racket] Dynamically evaluate your language using `make-module-evaluator`
#lang racket/base
(require racket/sandbox
racket/runtime-path
"parser.rkt"
"tokenizer.rkt"
"expander.rkt"
syntax/strip-context)
;; To pass to the module datum
('uncursed magic marker', 3987)
('2 blessed scrolls of charging', 3889)
('magic marker', 3571)
('blessed magic marker', 2540)
('blessed greased +2 silver dragon scale mail', 1167)
('blessed +2 silver dragon scale mail', 1105)
('3 blessed scrolls of charging', 1096)
('blessed +2 gray dragon scale mail', 1033)
('blessed spellbook of identify', 886)
('2 blessed scrolls of genocide', 850)