From 722a72579a075e6d5a2ce5a0b34351521770e84d Mon Sep 17 00:00:00 2001 From: Nathan Braswell Date: Tue, 12 May 2020 21:30:37 -0400 Subject: [PATCH] Spelling --- bf.kp | 20 ++-- fungll.krak | 74 ++++++------- index.html | 303 ++++++++++++++------------------------------------- k_prime.krak | 112 +++++++++---------- method.kp | 2 +- 5 files changed, 183 insertions(+), 328 deletions(-) diff --git a/bf.kp b/bf.kp index 6a0b9bc..f6bc828 100644 --- a/bf.kp +++ b/bf.kp @@ -5,25 +5,25 @@ (def! make-atom (fn* (x) [x])) (def! set-atom! (fn* (x y) (set-nth! x 0 y))) (def! get-atom (fn* (x) (nth x 0))) -(add_grammer_rule 'form ["@" 'form] (fn* (_ x) `(get-atom ~x))) +(add_grammar_rule 'form ["@" 'form] (fn* (_ x) `(get-atom ~x))) ; Now begin by defining our BF syntax & semantics ; Define our tokens as BF atoms -(add_grammer_rule 'bfs_atom ["<"] (fn* (_) '(set-atom! cursor (- @cursor 1)))) -(add_grammer_rule 'bfs_atom [">"] (fn* (_) '(set-atom! cursor (+ @cursor 1)))) -(add_grammer_rule 'bfs_atom ["\\+"] (fn* (_) '(set-nth! tape @cursor (+ (nth tape @cursor) 1)))) -(add_grammer_rule 'bfs_atom ["-"] (fn* (_) '(set-nth! tape @cursor (- (nth tape @cursor) 1)))) -(add_grammer_rule 'bfs_atom [","] (fn* (_) '(let* (value (nth input @inptr)) +(add_grammar_rule 'bfs_atom ["<"] (fn* (_) '(set-atom! cursor (- @cursor 1)))) +(add_grammar_rule 'bfs_atom [">"] (fn* (_) '(set-atom! cursor (+ @cursor 1)))) +(add_grammar_rule 'bfs_atom ["\\+"] (fn* (_) '(set-nth! tape @cursor (+ (nth tape @cursor) 1)))) +(add_grammar_rule 'bfs_atom ["-"] (fn* (_) '(set-nth! tape @cursor (- (nth tape @cursor) 1)))) +(add_grammar_rule 'bfs_atom [","] (fn* (_) '(let* (value (nth input @inptr)) (do (set-atom! inptr (+ 1 @inptr)) (set-nth! tape @cursor value))))) -(add_grammer_rule 'bfs_atom ["."] (fn* (_) '(set-atom! output (cons (nth tape @cursor) @output)))) +(add_grammar_rule 'bfs_atom ["."] (fn* (_) '(set-atom! output (cons (nth tape @cursor) @output)))) ; Define strings of BF atoms -(add_grammer_rule 'bfs ['bfs_atom *] (fn* (x) x)) +(add_grammar_rule 'bfs ['bfs_atom *] (fn* (x) x)) ; Add loop as an atom ; (note that closure cannot yet close over itself by value, so we pass it in) -(add_grammer_rule 'bfs_atom ["\\[" 'bfs "]"] (fn* (_ x _) +(add_grammar_rule 'bfs_atom ["\\[" 'bfs "]"] (fn* (_ x _) `(let* (f (fn* (f) (if (= 0 (nth tape @cursor)) nil @@ -32,7 +32,7 @@ ; For now, stick BFS rule inside an unambigious BFS block ; Also add setup code -(add_grammer_rule 'form ["bf" 'optional_WS "{" 'optional_WS 'bfs 'optional_WS "}"] +(add_grammar_rule 'form ["bf" 'optional_WS "{" 'optional_WS 'bfs 'optional_WS "}"] (fn* (_ _ _ _ x _ _) `(fn* (input) (let* ( diff --git a/fungll.krak b/fungll.krak index a0654b6..1860306 100644 --- a/fungll.krak +++ b/fungll.krak @@ -283,21 +283,21 @@ fun bs(nonterminal: int, rule_idx: int, idx_into_rule: int, left: int, pivot: in var to_ret.construct(nonterminal, rule_idx, idx_into_rule, left, pivot, right): BS return to_ret } -/*fun fungll(grammer: ref Grammer, start_symbol: *char, input: ref str): set {*/ - /*return fungll(grammer, str(start_symbol), input)*/ +/*fun fungll(grammar: ref Grammer, start_symbol: *char, input: ref str): set {*/ + /*return fungll(grammar, str(start_symbol), input)*/ /*}*/ -/*fun fungll(grammer: ref Grammer, start_symbol: str, input: ref str): set {*/ - /*return fungll(grammer, -1*(grammer.nonterminal_funs.find(start_symbol)+1), input)*/ +/*fun fungll(grammar: ref Grammer, start_symbol: str, input: ref str): set {*/ + /*return fungll(grammar, -1*(grammar.nonterminal_funs.find(start_symbol)+1), input)*/ /*}*/ -fun fungll(grammer: ref Grammer, start_symbol: int, input: ref str): set { - var R = descend(grammer, start_symbol, 0) +fun fungll(grammar: ref Grammer, start_symbol: int, input: ref str): set { + var R = descend(grammar, start_symbol, 0) var U = set() var G = map, set>() var P = map, set>() var Y = set() while R.size() != 0 { var d = R.pop() - var it = process(grammer, input, d, G, P) + var it = process(grammar, input, d, G, P) var Rp = it.first.first var Yp = it.first.second var Gp = it.second @@ -325,21 +325,21 @@ fun fungll(grammer: ref Grammer, start_symbol: int, input: ref str): s } return Y } -fun descend(grammer: ref Grammer, symbol: int, l: int): set { +fun descend(grammar: ref Grammer, symbol: int, l: int): set { var to_ret = set() - for (var rhs = 0; rhs < grammer.get_nonterminal_rules(symbol).size; rhs++;) + for (var rhs = 0; rhs < grammar.get_nonterminal_rules(symbol).size; rhs++;) to_ret.add(descriptor(symbol, rhs, 0, l, l)) return to_ret } -fun process(grammer: ref Grammer, input: ref str, descript: Descriptor, G: ref map, set>, P: ref map, set>): triple, set>, map, set>, map, set>> { +fun process(grammar: ref Grammer, input: ref str, descript: Descriptor, G: ref map, set>, P: ref map, set>): triple, set>, map, set>, map, set>> { // if at end / end is emptystr - if descript.idx_into_rule == grammer.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx].size { - return process_e(grammer, descript, G, P) + if descript.idx_into_rule == grammar.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx].size { + return process_e(grammar, descript, G, P) } else { - return process_symbol(grammer, input, descript, G, P) + return process_symbol(grammar, input, descript, G, P) } } -fun process_e(grammer: ref Grammer, descript: Descriptor, G: ref map, set>, P: ref map, set>): triple, set>, map, set>, map, set>> { +fun process_e(grammar: ref Grammer, descript: Descriptor, G: ref map, set>, P: ref map, set>): triple, set>, map, set>, map, set>> { var nonterminal: int var rule_idx: int var left: int @@ -351,29 +351,29 @@ fun process_e(grammer: ref Grammer, descript: Descriptor, G: ref map

, set>(), map(make_pair(X,l), set(k))) } -fun process_symbol(grammer: ref Grammer, input: ref str, descript: Descriptor, G: ref map, set>, P: ref map, set>): triple, set>, map, set>, map, set>> { - var s = grammer.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx][descript.idx_into_rule] +fun process_symbol(grammar: ref Grammer, input: ref str, descript: Descriptor, G: ref map, set>, P: ref map, set>): triple, set>, map, set>, map, set>> { + var s = grammar.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx][descript.idx_into_rule] var k = descript.pivot var R = P.get_with_default(make_pair(s,k), set()) var Gp = map(make_pair(s,k), set(pending(descript.nonterminal, descript.rule_idx, descript.idx_into_rule+1, descript.left))) - if grammer.is_terminal(s) { - return make_triple(matc(grammer,input,descript), map, set>(), map, set>()) + if grammar.is_terminal(s) { + return make_triple(matc(grammar,input,descript), map, set>(), map, set>()) } else if R.size() == 0 { // s in N - return make_triple(make_pair(descend(grammer,s,k), set()), Gp, map, set>()) + return make_triple(make_pair(descend(grammar,s,k), set()), Gp, map, set>()) } else { // s in N and R != set() return make_triple(skip(k,pending(descript.nonterminal, descript.rule_idx, descript.idx_into_rule+1, descript.left), R), Gp, map, set>()) } } -fun matc(grammer: ref Grammer, input: ref str, descript: Descriptor): pair, set> { - /*println("trying to match " + grammer.to_string(grammer.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx][descript.idx_into_rule]))*/ - var match_length = grammer.match_terminal(grammer.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx][descript.idx_into_rule], input, descript.pivot) +fun matc(grammar: ref Grammer, input: ref str, descript: Descriptor): pair, set> { + /*println("trying to match " + grammar.to_string(grammar.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx][descript.idx_into_rule]))*/ + var match_length = grammar.match_terminal(grammar.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx][descript.idx_into_rule], input, descript.pivot) if match_length > 0 { - /*println("matched " + grammer.to_string(grammer.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx][descript.idx_into_rule]))*/ + /*println("matched " + grammar.to_string(grammar.get_nonterminal_rules(descript.nonterminal)[descript.rule_idx][descript.idx_into_rule]))*/ return make_pair(set(descriptor(descript.nonterminal, descript.rule_idx, descript.idx_into_rule+1, descript.left, descript.pivot+match_length)), set(bs(descript.nonterminal, descript.rule_idx, descript.idx_into_rule+1, descript.left, descript.pivot, descript.pivot+match_length))) } else { return make_pair(set(), set()) @@ -395,31 +395,31 @@ fun nmatch(k:int, K: ref set, R: ref set): pair, s return make_pair(Rp,Y) } /*fun main(argc: int, argv: **char): int {*/ - /*var grammer.construct(): Grammer*/ - /*var Number = grammer.add_new_nonterminal("Number", vec(grammer.add_terminal("[0-9]+", fun(input: ref str, l: int, r: int): int { return string_to_num(input.slice(l,r)); })), fun(i: ref vec): int { return i[0]; })*/ + /*var grammar.construct(): Grammer*/ + /*var Number = grammar.add_new_nonterminal("Number", vec(grammar.add_terminal("[0-9]+", fun(input: ref str, l: int, r: int): int { return string_to_num(input.slice(l,r)); })), fun(i: ref vec): int { return i[0]; })*/ - /*var mult = grammer.add_terminal("\\*", fun(input: ref str, l: int, r: int): int { return 1; })*/ - /*var Factor = grammer.add_new_nonterminal("Factor", vec(Number), fun(i: ref vec): int { return i[0]; })*/ - /*grammer.add_to_nonterminal(Factor, vec(Factor, mult, Number), fun(i: ref vec): int { return i[0]*i[2]; })*/ + /*var mult = grammar.add_terminal("\\*", fun(input: ref str, l: int, r: int): int { return 1; })*/ + /*var Factor = grammar.add_new_nonterminal("Factor", vec(Number), fun(i: ref vec): int { return i[0]; })*/ + /*grammar.add_to_nonterminal(Factor, vec(Factor, mult, Number), fun(i: ref vec): int { return i[0]*i[2]; })*/ - /*var add = grammer.add_terminal("\\+", fun(input: ref str, l: int, r: int): int { return 1; })*/ - /*var Term = grammer.add_new_nonterminal("Term", vec(Factor), fun(i: ref vec): int { return i[0]; })*/ - /*grammer.add_to_nonterminal(Term, vec(Term, add, Factor), fun(i: ref vec): int { return i[0]+i[2]; })*/ + /*var add = grammar.add_terminal("\\+", fun(input: ref str, l: int, r: int): int { return 1; })*/ + /*var Term = grammar.add_new_nonterminal("Term", vec(Factor), fun(i: ref vec): int { return i[0]; })*/ + /*grammar.add_to_nonterminal(Term, vec(Term, add, Factor), fun(i: ref vec): int { return i[0]+i[2]; })*/ - /*grammer.set_start_symbol(Term)*/ + /*grammar.set_start_symbol(Term)*/ /*var input = str("1+23*44")*/ - /*var BSR = fungll(grammer, input)*/ + /*var BSR = fungll(grammar, input)*/ /*println(str("length of BSR is: ") + BSR.size())*/ /*for (var i = 0; i < BSR.data.size; i++;) {*/ /*var BS = BSR.data[i]*/ - /*println(str() + i + ": " + grammer.to_string(BSR.data[i]))*/ + /*println(str() + i + ": " + grammar.to_string(BSR.data[i]))*/ /*}*/ - /*var res = grammer.eval_BSR(input, BSR)*/ - /*println(str("result of grammer.eval_BSR(fungll(grammer, ") + input + ")) = " + res)*/ + /*var res = grammar.eval_BSR(input, BSR)*/ + /*println(str("result of grammar.eval_BSR(fungll(grammar, ") + input + ")) = " + res)*/ /*return 0*/ /*}*/ diff --git a/index.html b/index.html index a76d4fa..872935a 100644 --- a/index.html +++ b/index.html @@ -2,267 +2,122 @@ - -

Nathan Braswell's Current Programming Language / Compiler Research

- Repository: https://github.com/limvot/kraken -

- Table of Contents: If you're impatient, jump to the code examples! - - -

Concept:

+

Nathan Braswell's Current Programming Language / Compiler Research

+

Current idea:

- -

About:

+

Status:

Currently, I am bootstrapping this new core Lisp out of my prior compiler for my programming language, Kraken. I have implemented the first version of the FUN-GLL algorithm and have working context-free reader macros. I'll have enough to self-host this core soon, and will then use the more efficent core Lisp implementation to implement the Type Systems as Macros paper and add a type system to the new language. -

The general flow is that the input file is executed with the core Lisp interpreter, and if there is a "main" symbol defined the compiler emits C for that function & all other functions & data that it references. In this way the language supports very powerful meta-programming at compile time, including adding syntax to the language, arbitrary computation, and importing other files, and then compiles into a static executable. The current compiling backend emits C. -

Below are a few examples of using the live grammer modification / context-free reader macros to implement basic methods as well as embed the BF language into the core Lisp. The core Lisp implementation has been compiled to WebAssembly and should be able to run in your browser. Feel free to make edits and play around below. +

Below is an example of using the live grammer modification / context-free reader macros to embed the BF language into the core Lisp. The core Lisp implementation has been compiled to WebAssembly and should be able to run in your browser. Feel free to make edits and play around below.
-Note that the current implementation is inefficent, and sometimes has problems running in phone web browsers. -
-

Runnable Example Code:

-
-
; Of course +

Code:

+ -
-

Method Example:

- Let's use our meta system (attaching objects to other objects) to implement basic objects/methods. - We will attach a vector of alternating symbols / functions (to make this example simple, since maps aren't built in) to our data as the meta, then look up methods on it when we perform a call. The add_grammer_rule function modifies the grammer/parser currently being used to parse the file and operates as a super-powerful reader macro. We use it in this code to add a rule that transforms
a.b(c, d)
into
(method-call a 'b c d)
where method-call is the function that looks up the symbol 'b on the meta object attached to a and calls it with the rest of the parameters. -
- -
-
; First quick lookup function, since maps are not built in -(def! get-value-helper (fn* (dict key idx) (if (>= idx (count dict)) - nil - (if (= key (nth dict idx)) - (nth dict (+ idx 1)) - (get-value-helper dict key (+ idx 2)))))) -(def! get-value (fn* (dict key) (get-value-helper dict key 0))) -; Our actual method call function -(def! method-call (fn* (object method & arguments) (let* (method_fn (get-value (meta object) method)) - (if (= method_fn nil) - (println "no method " method) - (apply method_fn object arguments))))) -; Some nice syntatic sugar for method calls -(add_grammer_rule 'form ['form "\\." 'atom 'optional_WS "\\(" 'optional_WS 'space_forms 'optional_WS "\\)"] - (fn* (o _ m _ _ _ p _ _) `(method-call ~o '~m ,p))) +; Use the power of GLL reader macros to implement +; BF support -; Ok, let's create our object by hand for this example -(def! actual_obj (with-meta [0] [ - 'inc (fn* (o) (set-nth! o 0 (+ (nth o 0) 1))) - 'dec (fn* (o) (set-nth! o 0 (- (nth o 0) 1))) - 'set (fn* (o n) (set-nth! o 0 n)) - 'get (fn* (o) (nth o 0)) - ])) -(do - ; Use our new sugar - actual_obj.set(1337) - actual_obj.inc() - (println "get: " actual_obj.get()) - actual_obj.dec() - (println "get: " actual_obj.get()) +; Utility until we get stdlib & datastructures figured out +(def! with_update (fn* [arr idx val] + (if (= idx 0) + (cons val (rest arr)) + (cons (first arr) (with_update (rest arr) (- idx 1) val))))) - ; Use methods directly - (method-call actual_obj 'set 654) - (method-call actual_obj 'inc) - (println "get: " (method-call actual_obj 'get)) - (method-call actual_obj 'dec) - (method-call actual_obj 'dec) - (println "get: " (method-call actual_obj 'get)) - - nil) -
-

Output:

- -
-

More Complicated Example: BF as an embedded language

-
-
; We don't have atoms built in, mutable vectors -; are our base building block. In order to make the -; following BF implementation nice, let's add atoms! -; They will be implmented as length 1 vectors with nice syntax for deref -(def! make-atom (fn* (x) [x])) -(def! set-atom! (fn* (x y) (set-nth! x 0 y))) -(def! get-atom (fn* (x) (nth x 0))) -(add_grammer_rule 'form ["@" 'form] (fn* (_ x) `(get-atom ~x))) - -; Now begin by defining our BF syntax & semantics ; Define our tokens as BF atoms -(add_grammer_rule 'bfs_atom ["<"] (fn* (_) '(set-atom! cursor (- @cursor 1)))) -(add_grammer_rule 'bfs_atom [">"] (fn* (_) '(set-atom! cursor (+ @cursor 1)))) -(add_grammer_rule 'bfs_atom ["\\+"] (fn* (_) '(set-nth! tape @cursor (+ (nth tape @cursor) 1)))) -(add_grammer_rule 'bfs_atom ["-"] (fn* (_) '(set-nth! tape @cursor (- (nth tape @cursor) 1)))) -(add_grammer_rule 'bfs_atom [","] (fn* (_) '(let* (value (nth input @inptr)) - (do (set-atom! inptr (+ 1 @inptr)) - (set-nth! tape @cursor value))))) -(add_grammer_rule 'bfs_atom ["."] (fn* (_) '(set-atom! output (cons (nth tape @cursor) @output)))) +(add_grammer_rule 'bfs_atom ["<"] (fn* [xs] (list 'left))) +(add_grammer_rule 'bfs_atom [">"] (fn* [xs] (list 'right))) +(add_grammer_rule 'bfs_atom ["\\+"] (fn* [xs] (list 'plus))) +(add_grammer_rule 'bfs_atom ["-"] (fn* [xs] (list 'minus))) +(add_grammer_rule 'bfs_atom [","] (fn* [xs] (list 'in))) +(add_grammer_rule 'bfs_atom ["."] (fn* [xs] (list 'out))) ; Define strings of BF atoms -(add_grammer_rule 'bfs ['bfs_atom *] (fn* (x) x)) +(add_grammer_rule 'non_empty_bfs_list ['bfs_atom] (fn* [xs] (list (nth xs 0)))) +(add_grammer_rule 'non_empty_bfs_list ['bfs_atom 'optional_WS 'non_empty_bfs_list] (fn* [xs] (cons (nth xs 0) (nth xs 2)))) +(add_grammer_rule 'bfs_list [] (fn* [xs] xs)) +(add_grammer_rule 'bfs_list ['non_empty_bfs_list] (fn* [xs] (nth xs 0))) ; Add loop as an atom -; (note that closure cannot yet close over itself by value, so we pass it in) -(add_grammer_rule 'bfs_atom ["\\[" 'bfs "]"] (fn* (_ x _) - `(let* (f (fn* (f) - (if (= 0 (nth tape @cursor)) +(add_grammer_rule 'bfs_atom ["\\[" 'bfs_list "]"] (fn* [xs] + `(let* (f (fn* [] + (if (= 0 (nth (deref arr) (deref ptr))) nil - (do ,x (f f))))) - (f f)))) + (do ,(nth xs 1) (f))))) + (f)))) + +; Top level BFS rule +(add_grammer_rule 'bfs ['bfs_list] (fn* [xs] (nth xs 0))) ; For now, stick BFS rule inside an unambigious BFS block -; Also add setup code +; and add compilation/implementation +; Note that this compilation into the underlying Lisp +; happens at macro evaluation time. If this code were +; to be compiled to C, it would be compiled all the way +; to C code with no trace of the original BF code. (add_grammer_rule 'form ["bf" 'optional_WS "{" 'optional_WS 'bfs 'optional_WS "}"] - (fn* (_ _ _ _ x _ _) - `(fn* (input) + (fn* [xs] + `(fn* [input] (let* ( - tape (vector 0 0 0 0 0) - cursor (make-atom 0) - inptr (make-atom 0) - output (make-atom (vector)) - ) - (do (println "beginning bfs") ,x (nth output 0)))))) + arr (atom (vector 0 0 0 0 0)) + output (atom []) + ptr (atom 0) + inptr (atom 0) + left (fn* [] (swap! ptr (fn* [old] (- old 1)))) + right (fn* [] (swap! ptr (fn* [old] (+ old 1)))) + plus (fn* [] (swap! arr (fn* [old] (with_update old (deref ptr) (+ (nth (deref arr) (deref ptr)) 1))))) + minus (fn* [] (swap! arr (fn* [old] (with_update old (deref ptr) (- (nth (deref arr) (deref ptr)) 1))))) + in (fn* [] (let* ( h (nth input (deref inptr)) + _ (swap! inptr (fn* [old] (+ old 1)))) + (swap! arr (fn* [old] (with_update old (deref ptr) h))))) + out (fn* [] (swap! output (fn* [old] (cons (nth (deref arr) (deref ptr)) old))))) + (do ,(nth xs 4) (deref output)))))) ; Let's try it out! This BF program prints the input 3 times (println (bf { ,>+++[<.>-] } [1337])) -; we can also have it compile into our main program (if this wasn't the web version) -(def! main (fn* () (do (println "BF: " (bf { ,>+++[<.>-] } [1337])) 0))) -
-

Output:

- -
-

Performance Benchmarks

-

Performance is quite poor (for the interpreter mainly, the C compiler seems to be smart enough to make even the very inefficent generated C code fast), as almost no work has gone into it as of yet. - We are currently focusing on the FUN-GLL macros and creating a more fully-featured language on top of the core Lisp using them. We will focus more on performance with the implemenation of the functional persistant datastructures and the self-hosting rewrite, and performance will be the main focus of the RVSDG IR part of the project. -

Even so, it is worth keeping a rough estimate of performance in mind. For this, we have compiled a very basic benchmark below, with more benchmark programs (sorting, etc) to be included as the language gets developed: -
- - - - - - - - - - - - - - - - - -
Core Lisp InterpreterCore Lisp Compiled to CHand-written C
Fibonacci(27)51.505s0.007s0.002s
-
- Here is the core Lisp code run / compiled by the two above tests, which you can run in your web browser. The hand-written C code is an exact translation of this into ideomatic C. -
Note: N is lowered in the web demo so WebAssembly doesn't run out of memory. -
-

Fibonacci:

-
-
(def! fib (fn* (n) (cond (= 0 n) 0 - (= 1 n) 1 - true (+ (fib (- n 1)) (fib (- n 2)))))) -(let* (n 16) - (println "Fib(" n "): " (fib n))) -
-

Output:

- -
-

Next Steps

-
    -
  • Implement simple garbage collector for compiled code (currently C) -
  • Implement persistant functional data structures -
      -
    • Hash Array-Mapped Trie (HAMT) / Relaxed Radix Balance Tree (RRB-Tree) -
    • Hash Map based on the above -
    • Hash Set based on the above -
    -
  • Prototype Type Systems as Macros, may require macro system rewrite/upgrade -
  • Sketch out Kraken language on top of core Lisp, includes basic Hindley-Milner type system implemented with Macros and above data structures -
  • Re-self-host using functional approach in above Kraken language -
  • Use Type System Macros to implement automatic transiant creation on HAMT/RBB-Tree as an optimization -
  • Implement RVSDG IR and develop best bang-for-buck optimizations using it -
- - - + +
+

Output:

+