Skip to content

Instantly share code, notes, and snippets.

@KeenS
Created October 14, 2019 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KeenS/37faa4e3b9c6c387a3eaffd470bea010 to your computer and use it in GitHub Desktop.
Save KeenS/37faa4e3b9c6c387a3eaffd470bea010 to your computer and use it in GitHub Desktop.
@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))))));}
>
@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