Created
October 14, 2019 05:39
-
-
Save KeenS/37faa4e3b9c6c387a3eaffd470bea010 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdjareport | |
@import: stage0 | |
let-inline \show-int n = embed-string (arabic n) | |
in | |
document (| | |
title = {サンプル文書}; | |
author = {組 版太郎}; | |
|) '< | |
+p {\show-int(~(gen (Let (Value (&1), fun x -> | |
(Let (Value (&2), fun y -> | |
x))))));} | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@stage: 0 | |
type 'a ast = | |
Value of 'a | |
| Let of 'a ast * ('a ast -> 'a ast) | |
let gen-value c = | |
&(let x = ~(c) in | |
x | |
) | |
let gen-let expr body = | |
&(let e = ~(expr) in | |
~(body &e) | |
) | |
let-rec gen ast = match ast with | |
| Value (v) -> gen-value v | |
| Let (expr, body) -> gen-let (gen expr) (fun x -> gen (body (Value x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment