Kind/book/Kind.Term.show.go.kind2
Victor Taelin 85ad65b026 use-notation
Now, there are two local binders:

let x = ...
use x = ...

The 'let' binder will create a local definition, type-check it, and
assign a name to it. When compiled, it will create 'dup' nodes.

The 'use' binder is just an alias. It will not bind a new variable, and,
when compiled, will create inline copies. Also, for type-checking, it
allows creating aliases that are definitionaly equal for the checker.
2024-03-08 17:39:37 -03:00

192 lines
4.0 KiB
Plaintext

Kind.Term.show.go
: ∀(term: Kind.Term) ∀(dep: Nat) String.Concatenator
= λterm λdep
use P = λX String.Concatenator
use all = λnam λinp λbod λnil
(Kind.Text.show.go
"∀("
(Kind.Text.show.go
nam
(Kind.Text.show.go
": "
(Kind.Term.show.go
inp
dep
(Kind.Text.show.go
") "
(Kind.Term.show.go
(bod (Kind.var nam dep))
(Nat.succ dep)
nil
)
)
)
)
)
)
use lam = λnam λbod λnil
(Kind.Text.show.go
"λ"
(Kind.Text.show.go
nam
(Kind.Text.show.go
" "
(Kind.Term.show.go
(bod (Kind.var nam dep))
(Nat.succ dep)
nil
)
)
)
)
use app = λfun λarg λnil
(Kind.Text.show.go
"("
(Kind.Term.show.go
fun
dep
(Kind.Text.show.go
" "
(Kind.Term.show.go arg dep (Kind.Text.show.go ")" nil))
)
)
)
use ann = λval λtyp λnil
(Kind.Text.show.go
"{"
(Kind.Term.show.go
val
dep
(Kind.Text.show.go
" : "
(Kind.Term.show.go typ dep (Kind.Text.show.go "}" nil))
)
)
)
use slf = λnam λbod λnil
(Kind.Text.show.go
"$"
(Kind.Text.show.go
nam
(Kind.Text.show.go
" "
(Kind.Term.show.go
(bod (Kind.var nam dep))
(Nat.succ dep)
nil
)
)
)
)
use ins = λval λnil
(Kind.Text.show.go "~" (Kind.Term.show.go val dep nil))
use ref = λnam λval λnil (Kind.Text.show.go nam nil)
use def = λnam λval λbod λnil
(Kind.Text.show.go
"use "
(Kind.Text.show.go
nam
(Kind.Text.show.go
" = "
(Kind.Term.show.go
val
dep
(Kind.Text.show.go
"; "
(Kind.Term.show.go
(bod (Kind.var nam dep))
(Nat.succ dep)
nil
)
)
)
)
)
)
use set = λnil (Kind.Text.show.go "*" nil)
use u60 = λnil (Kind.Text.show.go "#U60" nil)
use num = λval λnil (Kind.Text.show.go "#" (U60.show.go val nil))
use op2 = λopr λfst λsnd λnil
(Kind.Text.show.go
"#("
(Kind.Oper.show.go
opr
(Kind.Text.show.go
" "
(Kind.Term.show.go
fst
dep
(Kind.Text.show.go
" "
(Kind.Term.show.go snd dep (Kind.Text.show.go ")" nil))
)
)
)
)
)
use mat = λnam λx λz λs λp λnil
(Kind.Text.show.go
"#match "
(Kind.Text.show.go
nam
(Kind.Text.show.go
" = "
(Kind.Term.show.go
x
dep
(Kind.Text.show.go
" { #0: "
(Kind.Term.show.go
z
dep
(Kind.Text.show.go
"; #+: "
(Kind.Term.show.go
(s (Kind.var (String.concat nam "-1") dep))
(Nat.succ dep)
(Kind.Text.show.go
" }: "
(Kind.Term.show.go
(p (Kind.var nam dep))
(Nat.succ dep)
nil
)
)
)
)
)
)
)
)
)
)
use txt = λtext λnil
(Kind.Text.show.go
String.quote
(Kind.Text.show.go
text
(Kind.Text.show.go String.quote nil)
)
)
use hol = λnam λctx λnil
(Kind.Text.show.go "?" (Kind.Text.show.go nam nil))
use var = λnam λidx λnil (Kind.Text.show.go nam nil)
(~term
P
all
lam
app
ann
slf
ins
ref
def
set
u60
num
op2
mat
txt
hol
var
)