aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2022-01-06 14:28:32 -0400
committerEduardo Julian2022-01-06 14:28:32 -0400
commitd37982f0af44714d95caf24d7f944e4e659b3e69 (patch)
tree1576fc83764d958f8b5f7963a4d9987cd73b641f
parent9afaa3a3236366d57cb1c3d771b25779ee76269b (diff)
Fixes for the pure-Lux JVM compiler machinery. [Part 2]
Diffstat (limited to '')
-rw-r--r--documentation/bookmark/back_end/wren.md4
-rw-r--r--documentation/bookmark/debugging.md107
-rw-r--r--documentation/bookmark/exception.md3
-rw-r--r--documentation/bookmark/game/accessibility.md5
-rw-r--r--documentation/bookmark/game/combat/damage.md4
-rw-r--r--documentation/bookmark/game/data.md4
-rw-r--r--documentation/bookmark/game/item.md4
-rw-r--r--documentation/bookmark/game/mechanic/crafting.md4
-rw-r--r--documentation/bookmark/game/progression.md5
-rw-r--r--documentation/bookmark/game/storytelling.md5
-rw-r--r--documentation/bookmark/game/storytelling/intrigue.md8
-rw-r--r--documentation/bookmark/game/storytelling/magic.md4
-rw-r--r--documentation/bookmark/game/storytelling/villain.md4
-rw-r--r--documentation/bookmark/math.md32
-rw-r--r--documentation/bookmark/math/linear_algebra.md33
-rw-r--r--documentation/bookmark/optimization/branchless_programming.md4
-rw-r--r--documentation/bookmark/paradigm/probabilistic_programming.md117
-rw-r--r--documentation/bookmark/parallelism.md4
-rw-r--r--lux-lua/source/program.lux42
-rw-r--r--stdlib/source/library/lux.lux2
-rw-r--r--stdlib/source/library/lux/target/jvm/bytecode.lux60
-rw-r--r--stdlib/source/library/lux/target/lua.lux107
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux12
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux28
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux334
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux91
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux145
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux182
-rw-r--r--stdlib/source/test/lux.lux20
-rw-r--r--stdlib/source/test/lux/extension.lux9
-rw-r--r--stdlib/source/test/lux/target/js.lux2
-rw-r--r--stdlib/source/test/lux/target/lua.lux709
-rw-r--r--stdlib/source/test/lux/target/python.lux17
-rw-r--r--stdlib/source/test/lux/target/ruby.lux2
39 files changed, 1483 insertions, 646 deletions
diff --git a/documentation/bookmark/back_end/wren.md b/documentation/bookmark/back_end/wren.md
new file mode 100644
index 000000000..8649c720b
--- /dev/null
+++ b/documentation/bookmark/back_end/wren.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Meta Class](https://wren.io/modules/meta/meta.html)
+
diff --git a/documentation/bookmark/debugging.md b/documentation/bookmark/debugging.md
index 60227f63c..64e9bdbc6 100644
--- a/documentation/bookmark/debugging.md
+++ b/documentation/bookmark/debugging.md
@@ -1,86 +1,87 @@
# Exemplar
-1. [Flow-storm debugger](https://github.com/jpmonettas/flow-storm-debugger)
+0. [Flow-storm debugger](https://github.com/jpmonettas/flow-storm-debugger)
# Service
-1. https://www.bugreplay.com/
+0. https://www.bugreplay.com/
# Input
-1. [Debugging Inputs](https://www.dropbox.com/s/ddn3fe55lws1rdr/icse2020-ddmax.pdf)
+0. [Debugging Inputs](https://www.dropbox.com/s/ddn3fe55lws1rdr/icse2020-ddmax.pdf)
# Omniscient debugging
-1. https://pernos.co/
+0. https://pernos.co/
# Tracing
-1. ["Understanding Microservices with Distributed Tracing" by Lita Cho](https://www.youtube.com/watch?v=URCLeycMrhU)
+0. ["Understanding Microservices with Distributed Tracing" by Lita Cho](https://www.youtube.com/watch?v=URCLeycMrhU)
# Reference
-1. [Debugging in Clojure](https://blog.davemartin.me/posts/debugging-in-clojure/)
-1. [The Debugging Book: Tools and Techniques for Automated Software Debugging](https://www.debuggingbook.org/)
-1. [The Power Of Collaborative Debugging](https://robert.ocallahan.org/2019/11/the-power-of-collaborative-debugging.html)
-1. [Multiverse Debugging: Non-Deterministic Debugging for Non-Deterministic Programs](https://stefan-marr.de/2019/07/what-if-we-could-see-all-concurrency-bugs-in-the-debugger/)
-1. [Writing a Debugger](http://system.joekain.com/debugger/)
-1. https://en.wikipedia.org/wiki/Jinx_Debugger
-1. http://www.mattzeunert.com/2017/12/07/better-types-of-debuggers.html
-1. https://www.youtube.com/watch?v=ipDhvd1NsmE
-1. http://georgejahad.com/clojure/cdt.html
-1. http://endlessparentheses.com/cider-debug-a-visual-interactive-debugger-for-clojure.html
-1. https://github.com/razum2um/clj-debugger
-1. https://stories.jotform.com/how-to-become-a-good-debugger-9324543fea33#.1ctzqfyly
-1. https://www.microsoft.com/en-us/research/publication/time-travel-debugging-javascriptnode-js/
-1. http://valgrind.org/
-1. http://fitzgeraldnick.com/2015/06/19/source-maps-are-insufficient.html
-1. http://stefan-marr.de/downloads/draft-marr-et-al-concurrency-agnostic-protocol-for-debugging.pdf
-1. https://tip.golang.org/doc/diagnostics.html
-1. https://github.com/solo-io/squash
-1. http://www.michaelburge.us/2017/09/27/delta-debugging-in-haskell.html
-1. https://undo.io/
-1. [Clojure Compilation, Backwards - Nicola Mometto](https://www.youtube.com/watch?v=2SGFeegEt9E)
-1. https://zorbash.com/post/debugging-elixir-applications/
-1. [Compose :: Melbourne 2017 - Ronen Narkis - Re-ops, a Functional Live-Infrastructure as Code](https://www.youtube.com/watch?v=iopuirQuK-s)
-1. [Compose :: Melbourne 2017 - Jurriaan Hage - Domain-Specific Type Error Diagnosis in GHC](https://www.youtube.com/watch?v=GbCfmnTmQDc)
-1. https://raygun.com/javascript-debugging-tips
-1. https://github.com/bpiel/sayid
-1. [Algorithmic Program Debugging](http://cpsc.yale.edu/sites/default/files/files/tr237.pdf)
-1. [Effect-Driven QuickChecking of Compilers](http://janmidtgaard.dk/papers/Midtgaard-al%3AICFP17-full.pdf)
-1. https://www.youtube.com/watch?v=_KrZzaShDew
-1. [NodeJS uses the Chome debugger protocol:](https://developer.chrome.com/devtools/docs/debugger-protocol)
-1. http://www.dwarfstd.org/
-1. https://docs.oracle.com/javase/7/docs/technotes/guides/jpda/jdwp-spec.html
-1. [Coarse Hierarchical Delta Debugging](http://www.inf.u-szeged.hu/~akiss/pub/pdf/hodovan2017coarsehdd.pdf)
-1. [Improving live debugging of concurrent threads through thread histories](http://scg.unibe.ch/scgbib?query=Lesk17a&display=abstract)
-1. [The JVM is Not Observable Enough (and What To Do About It)](https://www.cs.kent.ac.uk/people/staff/srk21//papers/kell12jvm-preprint.pdf)
-1. http://nikhilism.com/post/2019/retrieving-function-arguments-while-unwinding-the-stack/
-1. https://backtrace.io/blog/engineering/compile-once-debug-twice-picking-a-compiler-for-debuggability-1of3/
-1. https://singaporedatacompany.com/blog/more-developers-more-problems
-1. https://github.com/gruns/icecream
-1. https://lemire.me/blog/2016/06/21/i-do-not-use-a-debugger/
-1. https://the.agilesql.club/2019/05/how-to-load-test-a-sql-database/?u=h
+0. [Unobtrusive runtime warnings for libraries](https://www.pointfree.co/blog/posts/70-unobtrusive-runtime-warnings-for-libraries)
+0. [Debugging in Clojure](https://blog.davemartin.me/posts/debugging-in-clojure/)
+0. [The Debugging Book: Tools and Techniques for Automated Software Debugging](https://www.debuggingbook.org/)
+0. [The Power Of Collaborative Debugging](https://robert.ocallahan.org/2019/11/the-power-of-collaborative-debugging.html)
+0. [Multiverse Debugging: Non-Deterministic Debugging for Non-Deterministic Programs](https://stefan-marr.de/2019/07/what-if-we-could-see-all-concurrency-bugs-in-the-debugger/)
+0. [Writing a Debugger](http://system.joekain.com/debugger/)
+0. https://en.wikipedia.org/wiki/Jinx_Debugger
+0. http://www.mattzeunert.com/2017/12/07/better-types-of-debuggers.html
+0. https://www.youtube.com/watch?v=ipDhvd1NsmE
+0. http://georgejahad.com/clojure/cdt.html
+0. http://endlessparentheses.com/cider-debug-a-visual-interactive-debugger-for-clojure.html
+0. https://github.com/razum2um/clj-debugger
+0. https://stories.jotform.com/how-to-become-a-good-debugger-9324543fea33#.1ctzqfyly
+0. https://www.microsoft.com/en-us/research/publication/time-travel-debugging-javascriptnode-js/
+0. http://valgrind.org/
+0. http://fitzgeraldnick.com/2015/06/19/source-maps-are-insufficient.html
+0. http://stefan-marr.de/downloads/draft-marr-et-al-concurrency-agnostic-protocol-for-debugging.pdf
+0. https://tip.golang.org/doc/diagnostics.html
+0. https://github.com/solo-io/squash
+0. http://www.michaelburge.us/2017/09/27/delta-debugging-in-haskell.html
+0. https://undo.io/
+0. [Clojure Compilation, Backwards - Nicola Mometto](https://www.youtube.com/watch?v=2SGFeegEt9E)
+0. https://zorbash.com/post/debugging-elixir-applications/
+0. [Compose :: Melbourne 2017 - Ronen Narkis - Re-ops, a Functional Live-Infrastructure as Code](https://www.youtube.com/watch?v=iopuirQuK-s)
+0. [Compose :: Melbourne 2017 - Jurriaan Hage - Domain-Specific Type Error Diagnosis in GHC](https://www.youtube.com/watch?v=GbCfmnTmQDc)
+0. https://raygun.com/javascript-debugging-tips
+0. https://github.com/bpiel/sayid
+0. [Algorithmic Program Debugging](http://cpsc.yale.edu/sites/default/files/files/tr237.pdf)
+0. [Effect-Driven QuickChecking of Compilers](http://janmidtgaard.dk/papers/Midtgaard-al%3AICFP17-full.pdf)
+0. https://www.youtube.com/watch?v=_KrZzaShDew
+0. [NodeJS uses the Chome debugger protocol:](https://developer.chrome.com/devtools/docs/debugger-protocol)
+0. http://www.dwarfstd.org/
+0. https://docs.oracle.com/javase/7/docs/technotes/guides/jpda/jdwp-spec.html
+0. [Coarse Hierarchical Delta Debugging](http://www.inf.u-szeged.hu/~akiss/pub/pdf/hodovan2017coarsehdd.pdf)
+0. [Improving live debugging of concurrent threads through thread histories](http://scg.unibe.ch/scgbib?query=Lesk17a&display=abstract)
+0. [The JVM is Not Observable Enough (and What To Do About It)](https://www.cs.kent.ac.uk/people/staff/srk21//papers/kell12jvm-preprint.pdf)
+0. http://nikhilism.com/post/2019/retrieving-function-arguments-while-unwinding-the-stack/
+0. https://backtrace.io/blog/engineering/compile-once-debug-twice-picking-a-compiler-for-debuggability-1of3/
+0. https://singaporedatacompany.com/blog/more-developers-more-problems
+0. https://github.com/gruns/icecream
+0. https://lemire.me/blog/2016/06/21/i-do-not-use-a-debugger/
+0. https://the.agilesql.club/2019/05/how-to-load-test-a-sql-database/?u=h
# Benchmark
-1. https://github.com/smarr/ReBench
+0. https://github.com/smarr/ReBench
# Performance
-1. ["Software Performance: A Shape Not a Number" by Kay Ousterhout](https://www.youtube.com/watch?v=f7HCeE377-0)
-1. ["A Practical Look at Performance Theory" by Kavya Joshi](https://www.youtube.com/watch?v=bEYY3M0d-w8)
-1. https://nsirap.com/posts/001-web-porformance-api/
+0. ["Software Performance: A Shape Not a Number" by Kay Ousterhout](https://www.youtube.com/watch?v=f7HCeE377-0)
+0. ["A Practical Look at Performance Theory" by Kavya Joshi](https://www.youtube.com/watch?v=bEYY3M0d-w8)
+0. https://nsirap.com/posts/001-web-porformance-api/
# Profiling
-1. https://www.opsian.com/blog/what-is-continuous-profiling/
+0. https://www.opsian.com/blog/what-is-continuous-profiling/
# Time-travelling
-1. [Travelling through time with WinDbg at a system level](https://www.youtube.com/watch?v=mB9LIztjSKg)
+0. [Travelling through time with WinDbg at a system level](https://www.youtube.com/watch?v=mB9LIztjSKg)
# Monitoring
-1. https://www.erlang-solutions.com/blog/introducing-telemetry.html
+0. https://www.erlang-solutions.com/blog/introducing-telemetry.html
diff --git a/documentation/bookmark/exception.md b/documentation/bookmark/exception.md
index e47382a77..09b43b1eb 100644
--- a/documentation/bookmark/exception.md
+++ b/documentation/bookmark/exception.md
@@ -1,4 +1,5 @@
# Reference
-1. [You don't understand exceptions, but you should](https://matt.might.net/articles/implementing-exceptions/)
+0. [Using Coroutines to Implement C++ Exceptions for Freestanding Environments - Eyal Zedaka - CppCon 21](https://www.youtube.com/watch?v=TsXYqnUXrwM)
+0. [You don't understand exceptions, but you should](https://matt.might.net/articles/implementing-exceptions/)
diff --git a/documentation/bookmark/game/accessibility.md b/documentation/bookmark/game/accessibility.md
new file mode 100644
index 000000000..410627f7b
--- /dev/null
+++ b/documentation/bookmark/game/accessibility.md
@@ -0,0 +1,5 @@
+# Reference
+
+0. [Michael Langford - For the Squishies: Making Roguelikes Accessible to Children and their Parents](https://www.youtube.com/watch?v=wPN5bPxWXm8)
+0. [Accessibility Best Practices: Mobility Considerations](https://www.youtube.com/watch?v=-XBjj69-uK0)
+
diff --git a/documentation/bookmark/game/combat/damage.md b/documentation/bookmark/game/combat/damage.md
new file mode 100644
index 000000000..25a2b672b
--- /dev/null
+++ b/documentation/bookmark/game/combat/damage.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Hurting Your Players but Making it Fun || D&D w/ Dael Kingsmill](https://www.youtube.com/watch?v=thl54TR5Nb4)
+
diff --git a/documentation/bookmark/game/data.md b/documentation/bookmark/game/data.md
new file mode 100644
index 000000000..bfee78703
--- /dev/null
+++ b/documentation/bookmark/game/data.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Allie Signet & Joe Maliksi - SIBR - Sports, Splorts, and Statistics: Why Data Accessibility Matters](https://www.youtube.com/watch?v=WeRCGy3-uPY)
+
diff --git a/documentation/bookmark/game/item.md b/documentation/bookmark/game/item.md
new file mode 100644
index 000000000..e97e75e3b
--- /dev/null
+++ b/documentation/bookmark/game/item.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Cooler Magic Items for D&D! (Ep. #216)](https://www.youtube.com/watch?v=Qk3EJpMKGFw)
+
diff --git a/documentation/bookmark/game/mechanic/crafting.md b/documentation/bookmark/game/mechanic/crafting.md
new file mode 100644
index 000000000..b2c89efa8
--- /dev/null
+++ b/documentation/bookmark/game/mechanic/crafting.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Building Better Crafting Systems](https://www.youtube.com/watch?v=Nj7EaryBgak)
+
diff --git a/documentation/bookmark/game/progression.md b/documentation/bookmark/game/progression.md
new file mode 100644
index 000000000..9b3458e30
--- /dev/null
+++ b/documentation/bookmark/game/progression.md
@@ -0,0 +1,5 @@
+# Reference
+
+0. [Why D&D Shouldn't Use Character Levels || D&D w/ Dael Kingsmill](https://www.youtube.com/watch?v=SnPX8zfAAFQ)
+0. [The Problem with Leveling Up In Dungeons & Dragons (Ep. #228)](https://www.youtube.com/watch?v=2mcCBdXe1Vg)
+
diff --git a/documentation/bookmark/game/storytelling.md b/documentation/bookmark/game/storytelling.md
new file mode 100644
index 000000000..43e7ee536
--- /dev/null
+++ b/documentation/bookmark/game/storytelling.md
@@ -0,0 +1,5 @@
+# Reference
+
+0. [How James Bond Can Improve Your Dungeons & Dragons Game (Ep. 213)](https://www.youtube.com/watch?v=QRJXiRbXEek)
+0. [The ONE CLASSIC Book Every DM Needs to Read (Ep. 212)](https://www.youtube.com/watch?v=lfbnNxSFK6U)
+
diff --git a/documentation/bookmark/game/storytelling/intrigue.md b/documentation/bookmark/game/storytelling/intrigue.md
new file mode 100644
index 000000000..9896a1d4c
--- /dev/null
+++ b/documentation/bookmark/game/storytelling/intrigue.md
@@ -0,0 +1,8 @@
+# Reference
+
+0. []()
+
+# Exemplar
+
+0. [Review: Warhammer--Power Behind the Throne (Ep #223)](https://www.youtube.com/watch?v=K7IuyXt2wKg)
+
diff --git a/documentation/bookmark/game/storytelling/magic.md b/documentation/bookmark/game/storytelling/magic.md
new file mode 100644
index 000000000..571cc0093
--- /dev/null
+++ b/documentation/bookmark/game/storytelling/magic.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Wizards Good, Warlocks Bad || D&D w/ Dael Kingsmill](https://www.youtube.com/watch?v=sCXpucf16-k)
+
diff --git a/documentation/bookmark/game/storytelling/villain.md b/documentation/bookmark/game/storytelling/villain.md
new file mode 100644
index 000000000..89a742807
--- /dev/null
+++ b/documentation/bookmark/game/storytelling/villain.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Running Villains || D&D Baddies with Dael Kingsmill](https://www.youtube.com/watch?v=dRkbqK9SqJ0)
+
diff --git a/documentation/bookmark/math.md b/documentation/bookmark/math.md
index 3dbafd686..78de206a0 100644
--- a/documentation/bookmark/math.md
+++ b/documentation/bookmark/math.md
@@ -111,38 +111,6 @@
0. [Introduction to Probability at anadvanced leve](https://www.stat.berkeley.edu/~aditya/resources/AllLectures2018Fall201A.pdf)
-# Linear Algebra
-
-0. [Linear Algebra And Multi Dimensional Geometry](https://mirtitles.org/2020/02/13/4129/)
-0. [Interactive Linear Algebra](https://textbooks.math.gatech.edu/ila/)
-0. [Don’t invert that matrix](https://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/)
-0. [“Don’t invert that matrix” – why and how](https://civilstat.com/2015/07/dont-invert-that-matrix-why-and-how/)
-0. [Thirty-three Miniatures: Mathematical and Algorithmic Applications of Linear Algebra](https://kam.mff.cuni.cz/~matousek/stml-53-matousek-1.pdf)
-0. [Covectors are Different than Vectors, Usually](http://infohost.nmt.edu/~parendt/Phys509/notes/2diracnot/node4.html)
-0. [Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares](https://web.stanford.edu/~boyd/vmls/vmls.pdf)
-0. [Linear Algebra Done Wrong.](http://www.math.brown.edu/~treil/papers/LADW/LADW.html)
-0. [Linear Algebra Done Right](http://linear.axler.net/)
-0. [Down with Determinants!](http://www.axler.net/DwD.html)
-0. https://github.com/jacobbogers/blasjs
-0. https://graphicallinearalgebra.net/
-0. [Wild Linear Algebra](https://www.youtube.com/watch?v=yAb12PWrhV0&list=PLIljB45xT85BhzJ-oWNug1YtUjfWp1qAp &&& https://www.youtube.com/watch?v=nJdWFoliRnc&list=PLIljB45xT85DF5G-Hq0xPsVUnR5_wJRSw)
-0. https://github.com/ferreiradaselva/mathc
-0. http://www.fast.ai/2017/07/17/num-lin-alg/
-0. https://github.com/bluemathsoft/bm-linalg
-0. [The Matrix Cookbook](https://www.math.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf)
-0. https://dhruvp.netlify.com/2018/12/31/matrices/
-0. https://www.nalgebra.org/
-0. http://immersivemath.com/ila/index.html
-0. [Linear Logic and Linear Algebra](http://www.cs.bham.ac.uk/~drg/bll/steve.pdf)
-0. https://www.math3ma.com/blog/matrices-probability-graphs
-0. [Essence of linear algebra](https://www.youtube.com/watch?v=fNk_zzaMoSs&list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab)
-0. https://www.dhruvonmath.com/2018/12/31/matrices/
-0. http://blog.ezyang.com/2019/05/a-short-note-about-functional-linear-maps/
-0. https://www.math3ma.com/blog/matrices-as-tensor-network-diagrams
-0. [Convolution is outer product](https://arxiv.org/abs/1905.01289)
-0. [Graphical Calculus for products and convolutions](https://arxiv.org/abs/1903.01366)
-0. [3 Point Parameterization of Affine Transform](https://www.catid.io/affine3)
-
# Domain Theory
0. [A Brief Intro to Domain Theory](https://www.alignmentforum.org/posts/4C4jha5SdReWgg7dF/a-brief-intro-to-domain-theory)
diff --git a/documentation/bookmark/math/linear_algebra.md b/documentation/bookmark/math/linear_algebra.md
new file mode 100644
index 000000000..b2376d58f
--- /dev/null
+++ b/documentation/bookmark/math/linear_algebra.md
@@ -0,0 +1,33 @@
+# Reference
+
+0. [Basic Linear Algebra Subprograms](https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms)
+0. [Linear Algebra And Multi Dimensional Geometry](https://mirtitles.org/2020/02/13/4129/)
+0. [Interactive Linear Algebra](https://textbooks.math.gatech.edu/ila/)
+0. [Don’t invert that matrix](https://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/)
+0. [“Don’t invert that matrix” – why and how](https://civilstat.com/2015/07/dont-invert-that-matrix-why-and-how/)
+0. [Thirty-three Miniatures: Mathematical and Algorithmic Applications of Linear Algebra](https://kam.mff.cuni.cz/~matousek/stml-53-matousek-1.pdf)
+0. [Covectors are Different than Vectors, Usually](http://infohost.nmt.edu/~parendt/Phys509/notes/2diracnot/node4.html)
+0. [Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares](https://web.stanford.edu/~boyd/vmls/vmls.pdf)
+0. [Linear Algebra Done Wrong.](http://www.math.brown.edu/~treil/papers/LADW/LADW.html)
+0. [Linear Algebra Done Right](http://linear.axler.net/)
+0. [Down with Determinants!](http://www.axler.net/DwD.html)
+0. https://github.com/jacobbogers/blasjs
+0. https://graphicallinearalgebra.net/
+0. [Wild Linear Algebra](https://www.youtube.com/watch?v=yAb12PWrhV0&list=PLIljB45xT85BhzJ-oWNug1YtUjfWp1qAp &&& https://www.youtube.com/watch?v=nJdWFoliRnc&list=PLIljB45xT85DF5G-Hq0xPsVUnR5_wJRSw)
+0. https://github.com/ferreiradaselva/mathc
+0. http://www.fast.ai/2017/07/17/num-lin-alg/
+0. https://github.com/bluemathsoft/bm-linalg
+0. [The Matrix Cookbook](https://www.math.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf)
+0. https://dhruvp.netlify.com/2018/12/31/matrices/
+0. https://www.nalgebra.org/
+0. http://immersivemath.com/ila/index.html
+0. [Linear Logic and Linear Algebra](http://www.cs.bham.ac.uk/~drg/bll/steve.pdf)
+0. https://www.math3ma.com/blog/matrices-probability-graphs
+0. [Essence of linear algebra](https://www.youtube.com/watch?v=fNk_zzaMoSs&list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab)
+0. https://www.dhruvonmath.com/2018/12/31/matrices/
+0. http://blog.ezyang.com/2019/05/a-short-note-about-functional-linear-maps/
+0. https://www.math3ma.com/blog/matrices-as-tensor-network-diagrams
+0. [Convolution is outer product](https://arxiv.org/abs/1905.01289)
+0. [Graphical Calculus for products and convolutions](https://arxiv.org/abs/1903.01366)
+0. [3 Point Parameterization of Affine Transform](https://www.catid.io/affine3)
+
diff --git a/documentation/bookmark/optimization/branchless_programming.md b/documentation/bookmark/optimization/branchless_programming.md
new file mode 100644
index 000000000..069ead4a7
--- /dev/null
+++ b/documentation/bookmark/optimization/branchless_programming.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Branchless Programming in C++ - Fedor Pikus - CppCon 2021](https://www.youtube.com/watch?v=g-WPhYREFjk)
+
diff --git a/documentation/bookmark/paradigm/probabilistic_programming.md b/documentation/bookmark/paradigm/probabilistic_programming.md
index d89ed1de1..f1a46d27b 100644
--- a/documentation/bookmark/paradigm/probabilistic_programming.md
+++ b/documentation/bookmark/paradigm/probabilistic_programming.md
@@ -1,76 +1,77 @@
# Library
-1. [Soss](https://github.com/cscherrer/Soss.jl)
+0. [Soss](https://github.com/cscherrer/Soss.jl)
# Ranked Programming
-1. [Ranked Programming](https://github.com/tjitze/ranked-programming/blob/master/documentation/ranked_programming.pdf)
-1. https://github.com/tjitze/ranked-programming
+0. [Ranked Programming](https://github.com/tjitze/ranked-programming/blob/master/documentation/ranked_programming.pdf)
+0. https://github.com/tjitze/ranked-programming
# Inference
-1. [Gen: A general-purpose probabilistic programming system with programmable inference.](https://probcomp.github.io/Gen/)
-1. [Probabilistic Programming with Programmable Inference](https://people.csail.mit.edu/rinard/paper/pldi18.pdf)
-1. https://www.microsoft.com/en-us/research/blog/dowhy-a-library-for-causal-inference/
+0. [Gen: A general-purpose probabilistic programming system with programmable inference.](https://probcomp.github.io/Gen/)
+0. [Probabilistic Programming with Programmable Inference](https://people.csail.mit.edu/rinard/paper/pldi18.pdf)
+0. https://www.microsoft.com/en-us/research/blog/dowhy-a-library-for-causal-inference/
# Reference
-1. [Foundations of Probabilistic Programming](https://www.cambridge.org/core/books/foundations-of-probabilistic-programming/819623B1B5B33836476618AC0621F0EE)
-1. [An unorthodox path for implementing a probabilistic programming language](http://hyperparameter.space/blog/an-unorthodox-path-for-implementing-a-probabilistic-programming-language/)
-1. [The Distribution Monad](http://blog.russelldmatt.com/2018/10/15/the-distribution-monad.html)
-1. ["New programming constructs for probabilistic AI" by Marco Cusumano-Towner](https://www.youtube.com/watch?v=xNutxms6SH4)
-1. [A tour of probabilistic programming language APIs](https://colcarroll.github.io/ppl-api/)
-1. [Paradigms of Probabilistic Programming](https://www.youtube.com/watch?v=CmH1xxKRbiE)
-1. [Anatomy of a Probabilistic Programming Framework](https://eigenfoo.xyz/prob-prog-frameworks/)
-1. [Probabilistic Programming with monad‑bayes, Part 1: First Steps](https://www.tweag.io/posts/2019-09-20-monad-bayes-1.html)
-1. [Probabilistic Programming with monad‑bayes, Part 2: Linear Regression](https://www.tweag.io/posts/2019-11-08-monad-bayes-2.html)
-1. [FACTORIE](http://factorie.cs.umass.edu/)
-1. [End-User Probabilistic Programming (DRAFT)](https://www.cs.uoregon.edu/research/summerschool/summer19/lecture_notes/DRAFT___Probabilistic_Programming_for_End_Users.pdf)
-1. http://willcrichton.net/notes/probabilistic-programming-under-the-hood/
-1. [Ask HN: What companies are using probabilistic programming?](https://news.ycombinator.com/item?id=17220861)
-1. https://www-forbes-com.cdn.ampproject.org/v/s/www.forbes.com/sites/quora/2018/05/18/even-the-most-advanced-computer-programmers-have-probably-never-heard-of-this-concept/amp/?amp_js_v=a1&amp_gsa=1#amp_tf=From%20%251%24s&ampshare=https%3A%2F%2Fwww.forbes.com%2Fsites%2Fquora%2F2018%2F05%2F18%2Feven-the-most-advanced-computer-programmers-have-probably-never-heard-of-this-concept%2Famp%2F%23amp_tf%3DFrom%2520%25251%2524s&ampshare=https%3A%2F%2Fwww.forbes.com%2Fsites%2Fquora%2F2018%2F05%2F18%2Feven-the-most-advanced-computer-programmers-have-probably-never-heard-of-this-concept%2F&ampshare=https%3A%2F%2Fwww.forbes.com%2Fsites%2Fquora%2F2018%2F05%2F18%2Feven-the-most-advanced-computer-programmers-have-probably-never-heard-of-this-concept%2F
-1. [Deep Probabilistic Programming Languages: A Qualitative Study](https://arxiv.org/abs/1804.06458)
-1. [A Provably Correct Sampler for Probabilistic Programs](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/final.pdf)
-1. [Practical Probabilistic Programming with Monads](http://mlg.eng.cam.ac.uk/pub/pdf/SciGhaGor15.pdf)
-1. [Probabilistic Functional Programming in Haskell](https://web.engr.oregonstate.edu/~erwig/papers/PFP_JFP06.pdf)
-1. [The Probability Monad](https://www.youtube.com/watch?v=qZ4O-1VYv4c)
-1. https://www.chrisstucchio.com/blog/2016/probability_the_monad.html
-1. http://dippl.org/
-1. [Deep Probabilistic Programming](https://arxiv.org/abs/1701.03757v1)
-1. [Symbolic Conditioning of Arrays in Probabilistic Programs](http://homes.soic.indiana.edu/pravnar/disintegrate-arrays.pdf)
-1. http://probabilistic-programming.org/wiki/Home
-1. http://underscore.io/blog/posts/2016/04/21/probabilistic-programming.html
-1. https://moalquraishi.wordpress.com/2015/03/29/the-state-of-probabilistic-programming/
-1. https://en.wikipedia.org/wiki/Probabilistic_programming_language
-1. https://probmods.org/
-1. http://adriansampson.net/doc/ppl.html
-1. http://blog.fastforwardlabs.com/2017/10/02/pp-bibliography.html
-1. http://blog.fastforwardlabs.com/2017/01/30/the-algorithms-behind-probabilistic-programming.html
-1. https://arxiv.org/abs/1701.03757
-1. [Typed functional probabilistic programming: ready for practical use?](https://www.youtube.com/watch?v=DGZXoi6ehwA)
-1. [Generative probabilistic programming: applications and new ideas](https://www.youtube.com/watch?v=M_vG_6pq0XM)
-1. [Probabilistic Programming for Programming Languages People](https://github.com/sampsyo/ppl-intro)
-1. [Bayesian Methods for Hackers](https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers)
-1. [An Introduction to Probabilistic Programming](https://arxiv.org/abs/1809.10756)
-1. http://www.stormchecker.org/index.html
-1. https://betanalpha.github.io/assets/case_studies/conditional_probability_theory.html
-1. https://kaomorphism.com/2019/01/17/How-To-Predict-Any-Three-Events-More-Accurately.html
-1. [Probabilistic Programming with Densities in SlicStan: Efficient, Flexible and Deterministic](https://www.youtube.com/watch?v=CXiCJ7M72Wc)
+0. [Probabilistic programming with continuations](https://julesh.com/2020/08/15/probabilistic-programming-with-continuations/)
+0. [Foundations of Probabilistic Programming](https://www.cambridge.org/core/books/foundations-of-probabilistic-programming/819623B1B5B33836476618AC0621F0EE)
+0. [An unorthodox path for implementing a probabilistic programming language](http://hyperparameter.space/blog/an-unorthodox-path-for-implementing-a-probabilistic-programming-language/)
+0. [The Distribution Monad](http://blog.russelldmatt.com/2018/10/15/the-distribution-monad.html)
+0. ["New programming constructs for probabilistic AI" by Marco Cusumano-Towner](https://www.youtube.com/watch?v=xNutxms6SH4)
+0. [A tour of probabilistic programming language APIs](https://colcarroll.github.io/ppl-api/)
+0. [Paradigms of Probabilistic Programming](https://www.youtube.com/watch?v=CmH1xxKRbiE)
+0. [Anatomy of a Probabilistic Programming Framework](https://eigenfoo.xyz/prob-prog-frameworks/)
+0. [Probabilistic Programming with monad‑bayes, Part 1: First Steps](https://www.tweag.io/posts/2019-09-20-monad-bayes-1.html)
+0. [Probabilistic Programming with monad‑bayes, Part 2: Linear Regression](https://www.tweag.io/posts/2019-11-08-monad-bayes-2.html)
+0. [FACTORIE](http://factorie.cs.umass.edu/)
+0. [End-User Probabilistic Programming (DRAFT)](https://www.cs.uoregon.edu/research/summerschool/summer19/lecture_notes/DRAFT___Probabilistic_Programming_for_End_Users.pdf)
+0. http://willcrichton.net/notes/probabilistic-programming-under-the-hood/
+0. [Ask HN: What companies are using probabilistic programming?](https://news.ycombinator.com/item?id=17220861)
+0. https://www-forbes-com.cdn.ampproject.org/v/s/www.forbes.com/sites/quora/2018/05/18/even-the-most-advanced-computer-programmers-have-probably-never-heard-of-this-concept/amp/?amp_js_v=a1&amp_gsa=1#amp_tf=From%20%251%24s&ampshare=https%3A%2F%2Fwww.forbes.com%2Fsites%2Fquora%2F2018%2F05%2F18%2Feven-the-most-advanced-computer-programmers-have-probably-never-heard-of-this-concept%2Famp%2F%23amp_tf%3DFrom%2520%25251%2524s&ampshare=https%3A%2F%2Fwww.forbes.com%2Fsites%2Fquora%2F2018%2F05%2F18%2Feven-the-most-advanced-computer-programmers-have-probably-never-heard-of-this-concept%2F&ampshare=https%3A%2F%2Fwww.forbes.com%2Fsites%2Fquora%2F2018%2F05%2F18%2Feven-the-most-advanced-computer-programmers-have-probably-never-heard-of-this-concept%2F
+0. [Deep Probabilistic Programming Languages: A Qualitative Study](https://arxiv.org/abs/1804.06458)
+0. [A Provably Correct Sampler for Probabilistic Programs](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/final.pdf)
+0. [Practical Probabilistic Programming with Monads](http://mlg.eng.cam.ac.uk/pub/pdf/SciGhaGor15.pdf)
+0. [Probabilistic Functional Programming in Haskell](https://web.engr.oregonstate.edu/~erwig/papers/PFP_JFP06.pdf)
+0. [The Probability Monad](https://www.youtube.com/watch?v=qZ4O-1VYv4c)
+0. https://www.chrisstucchio.com/blog/2016/probability_the_monad.html
+0. http://dippl.org/
+0. [Deep Probabilistic Programming](https://arxiv.org/abs/1701.03757v1)
+0. [Symbolic Conditioning of Arrays in Probabilistic Programs](http://homes.soic.indiana.edu/pravnar/disintegrate-arrays.pdf)
+0. http://probabilistic-programming.org/wiki/Home
+0. http://underscore.io/blog/posts/2016/04/21/probabilistic-programming.html
+0. https://moalquraishi.wordpress.com/2015/03/29/the-state-of-probabilistic-programming/
+0. https://en.wikipedia.org/wiki/Probabilistic_programming_language
+0. https://probmods.org/
+0. http://adriansampson.net/doc/ppl.html
+0. http://blog.fastforwardlabs.com/2017/10/02/pp-bibliography.html
+0. http://blog.fastforwardlabs.com/2017/01/30/the-algorithms-behind-probabilistic-programming.html
+0. https://arxiv.org/abs/1701.03757
+0. [Typed functional probabilistic programming: ready for practical use?](https://www.youtube.com/watch?v=DGZXoi6ehwA)
+0. [Generative probabilistic programming: applications and new ideas](https://www.youtube.com/watch?v=M_vG_6pq0XM)
+0. [Probabilistic Programming for Programming Languages People](https://github.com/sampsyo/ppl-intro)
+0. [Bayesian Methods for Hackers](https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers)
+0. [An Introduction to Probabilistic Programming](https://arxiv.org/abs/1809.10756)
+0. http://www.stormchecker.org/index.html
+0. https://betanalpha.github.io/assets/case_studies/conditional_probability_theory.html
+0. https://kaomorphism.com/2019/01/17/How-To-Predict-Any-Three-Events-More-Accurately.html
+0. [Probabilistic Programming with Densities in SlicStan: Efficient, Flexible and Deterministic](https://www.youtube.com/watch?v=CXiCJ7M72Wc)
# DSL
-1. [Embedded probabilistic domain-specific language Hakaru10 (discrete and continuous distributions, MCMC (MH) sampling)](http://okmij.org/ftp/kakuritu/Hakaru10/index.html)
-1. https://github.com/p2t2/figaro
-1. http://www.robots.ox.ac.uk/~fwood/anglican/
-1. [Probabilistic programming and meta-programming in Clojure - Vikash Mansinghka](https://www.youtube.com/watch?v=KLGwLkmh8gI)
+0. [Embedded probabilistic domain-specific language Hakaru10 (discrete and continuous distributions, MCMC (MH) sampling)](http://okmij.org/ftp/kakuritu/Hakaru10/index.html)
+0. https://github.com/p2t2/figaro
+0. http://www.robots.ox.ac.uk/~fwood/anglican/
+0. [Probabilistic programming and meta-programming in Clojure - Vikash Mansinghka](https://www.youtube.com/watch?v=KLGwLkmh8gI)
# Language
-1. [Bean Machine: A Declarative Probabilistic Programming Language For Efficient Programmable Inference](https://pgm2020.cs.aau.dk/wp-content/uploads/2020/09/tehrani20.pdf)
-1. [Reactive Probabilistic Programming](https://arxiv.org/abs/1908.07563)
-1. https://hakaru-dev.github.io/
-1. http://probcomp.csail.mit.edu/venture/
-1. https://github.com/tjitze/RankPL/
-1. http://turing.guru/
-1. https://eng.uber.com/pyro/
+0. [Bean Machine: A Declarative Probabilistic Programming Language For Efficient Programmable Inference](https://pgm2020.cs.aau.dk/wp-content/uploads/2020/09/tehrani20.pdf)
+0. [Reactive Probabilistic Programming](https://arxiv.org/abs/1908.07563)
+0. https://hakaru-dev.github.io/
+0. http://probcomp.csail.mit.edu/venture/
+0. https://github.com/tjitze/RankPL/
+0. http://turing.guru/
+0. https://eng.uber.com/pyro/
diff --git a/documentation/bookmark/parallelism.md b/documentation/bookmark/parallelism.md
index a1829df9c..67c8f418d 100644
--- a/documentation/bookmark/parallelism.md
+++ b/documentation/bookmark/parallelism.md
@@ -1,5 +1,5 @@
# Reference
-1. [Arachne: Towards Core-Aware Scheduling](https://github.com/PlatformLab/Arachne)
-1. []()
+0. [C++ Standard Parallelism - Bryce Adelstein Lelbach - CppCon 2021](https://www.youtube.com/watch?v=LW_T2RGXego)
+0. [Arachne: Towards Core-Aware Scheduling](https://github.com/PlatformLab/Arachne)
diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux
index bedd9dbb8..66620007d 100644
--- a/lux-lua/source/program.lux
+++ b/lux-lua/source/program.lux
@@ -371,7 +371,7 @@
$b2 (_.var "b2")
$b3 (_.var "b3")
$b4 (_.var "b4")
- table/insert (_.apply/2 (_.var "table.insert"))]
+ table/insert (function (_ in/0 in/1) (_.apply (list in/0 in/1) (_.var "table.insert")))]
(_.function (_.var "utf8.char") (list $var_args)
($_ _.then
(_.local/1 $buffer (_.array (list)))
@@ -386,30 +386,30 @@
(<| (_.if (_.< (!int "80") $v)
... Single-byte sequence
(_.statement (|> (_.var "string.char")
- (_.apply/* (list $v))
+ (_.apply (list $v))
(table/insert $buffer))))
(_.if (_.< (!int "800") $v)
... Two-byte sequence
(_.statement (|> (_.var "string.char")
- (_.apply/* (list (!&|< "C0" "1F" +6 $v)
- (!&| "80" "3F" $v)))
+ (_.apply (list (!&|< "C0" "1F" +6 $v)
+ (!&| "80" "3F" $v)))
(table/insert $buffer))))
(_.if (_.< (!int "10000") $v)
... Three-byte sequence
(_.statement (|> (_.var "string.char")
- (_.apply/* (list (!&|< "E0" "0F" +12 $v)
- (!&|< "80" "3F" +6 $v)
- (!&| "80" "3F" $v)))
+ (_.apply (list (!&|< "E0" "0F" +12 $v)
+ (!&|< "80" "3F" +6 $v)
+ (!&| "80" "3F" $v)))
(table/insert $buffer))))
... Four-byte sequence
(_.statement (|> (_.var "string.char")
- (_.apply/* (list (!&|< "F0" "07" +18 $v)
- (!&|< "80" "3F" +12 $v)
- (!&|< "80" "3F" +6 $v)
- (!&| "80" "3F" $v)))
+ (_.apply (list (!&|< "F0" "07" +18 $v)
+ (!&|< "80" "3F" +12 $v)
+ (!&|< "80" "3F" +6 $v)
+ (!&| "80" "3F" $v)))
(table/insert $buffer))))
))
- (_.return (_.apply/2 (_.var "table.concat") $buffer (_.string "")))
+ (_.return (_.apply (list $buffer (_.string "")) (_.var "table.concat")))
))))
... (def: rembulan//str_rel_to_abs
@@ -429,7 +429,7 @@
... (_.> (_.length $string) $v))
... (_.statement (_.error/2 (_.string "bad index to string (out of range)") (_.int +3))))
... (_.set (list (_.nth $k $args)) $v)))
- ... (_.return (_.apply/1 (_.var "table.unpack") $args))
+ ... (_.return (_.apply (list $args) (_.var "table.unpack")))
... ))))
... (def: rembulan//decode
@@ -441,7 +441,7 @@
... $end (_.var "_end")]
... (<| (_.local_function $decode (list $string $start))
... ($_ _.then
- ... (_.set (list $start) (_.apply/2 $str_rel_to_abs $string (_.or (_.int +1) $start)))
+ ... (_.set (list $start) (_.apply (list $string (_.or (_.int +1) $start)) $str_rel_to_abs))
... (_.local/1 $b1 (_.do "byte" (list $start $start) $string))
... (<| (_.if (_.< (!int "80") $b1)
... ... Single-byte sequence
@@ -481,7 +481,7 @@
... (_.if (_.> (_.length $string) $i)
... (_.return _.nil)
... ($_ _.then
- ... (_.let (list $start $end) (_.apply/2 $decode $string $i))
+ ... (_.let (list $start $end) (_.apply (list $string $i) $decode))
... (_.if (_.not $start)
... (_.statement (_.error/2 (_.string "invalid UTF-8 code") (_.int +2)))
... ($_ _.then
@@ -500,14 +500,14 @@
... $size (_.var "size")]
... (_.function (_.var "utf8.len") (list $string $start $end)
... ($_ _.then
- ... (_.set (list $start $end) (_.apply/3 $str_rel_to_abs $string (_.or (_.int +1) $start) (_.or (_.int -1) $end)))
+ ... (_.set (list $start $end) (_.apply (list $string (_.or (_.int +1) $start) (_.or (_.int -1) $end)) $str_rel_to_abs))
... (_.local/1 $size (_.int +0))
... (_.repeat (_.>= $end $seq_end)
... ($_ _.then
- ... (_.let (list $seq_start $seq_end) (_.apply/2 $decode $string $start))
+ ... (_.let (list $seq_start $seq_end) (_.apply (list $string $start) $decode))
... (_.if (_.not $seq_start)
... ... Hit an invalid sequence!
- ... (_.return (_.multi (list (_.bool false) $start)))
+ ... (_.return (_.multi (list (_.boolean false) $start)))
... ($_ _.then
... (_.set (list $start) (_.+ (_.int +1) $seq_end))
... (_.set (list $size) (_.+ (_.int +1) $size))
@@ -799,9 +799,9 @@
(def: (program context program)
(Program _.Expression _.Statement)
(let [$program (_.var (reference.artifact context))]
- (_.statement (_.apply/* (list (runtime.lux//program_args (_.var "arg"))
- runtime.unit)
- program))))
+ (_.statement (_.apply (list (runtime.lux//program_args (_.var "arg"))
+ runtime.unit)
+ program))))
(def: (declare_success! _)
(-> Any (Async Any))
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 30f7bbc08..4aed1937b 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -679,7 +679,7 @@
{#Apply Text Either}}}}}
([_ val]
([_ state]
- {#Right state val})))
+ {#Right [state val]})))
#0)
("lux def" failure
diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux
index 4e450d7bc..97871977f 100644
--- a/stdlib/source/library/lux/target/jvm/bytecode.lux
+++ b/stdlib/source/library/lux/target/jvm/bytecode.lux
@@ -128,6 +128,40 @@
["Expected" (/stack.format expected)]
["Actual" (/stack.format actual)]))
+(def: .public (set? label)
+ (-> Label (Bytecode (Maybe [Stack Address])))
+ (function (_ state)
+ (let [[pool environment tracker] state]
+ {try.#Success [state
+ [..relative_identity
+ (case (dictionary.value label (value@ #known tracker))
+ {.#Some [expected {.#Some address}]}
+ {.#Some [expected address]}
+
+ _
+ {.#None})]]})))
+
+(def: .public (acknowledged? label)
+ (-> Label (Bytecode (Maybe Stack)))
+ (function (_ state)
+ (let [[pool environment tracker] state]
+ {try.#Success [state
+ [..relative_identity
+ (case (dictionary.value label (value@ #known tracker))
+ {.#Some [expected {.#None}]}
+ {.#Some expected}
+
+ _
+ {.#None})]]})))
+
+(def: .public stack
+ (Bytecode (Maybe Stack))
+ (function (_ state)
+ (let [[pool environment tracker] state]
+ {try.#Success [state
+ [..relative_identity
+ (value@ /environment.#stack environment)]]})))
+
(with_expansions [<success> (as_is (in [[pool
environment
(revised@ #known
@@ -165,6 +199,14 @@
(: (Monad Try))
try.monad))
+(def: .public (when_continuous it)
+ (-> (Bytecode Any) (Bytecode Any))
+ (do ..monad
+ [stack ..stack]
+ (.case stack
+ {.#None} (in [])
+ {.#Some _} it)))
+
(def: .public failure
(-> Text Bytecode)
(|>> {try.#Failure} function.constant))
@@ -186,7 +228,7 @@
(/address.move (estimator counter) counter))
(def: (bytecode consumption production registry [estimator bytecode] input)
- (All (_ a) (-> U2 U2 Registry [Estimator (-> [a] Instruction)] [a] (Bytecode Any)))
+ (All (_ a) (-> U2 U2 Registry [Estimator (-> [a] Instruction)] a (Bytecode Any)))
(function (_ [pool environment tracker])
(do [! try.monad]
[environment' (|> environment
@@ -301,14 +343,14 @@
[aload_2 $0 $1 @2 _.aload_2]
[aload_3 $0 $1 @3 _.aload_3]
- [iastore $3 $1 @_ _.iastore]
- [lastore $4 $1 @_ _.lastore]
- [fastore $3 $1 @_ _.fastore]
- [dastore $4 $1 @_ _.dastore]
- [aastore $3 $1 @_ _.aastore]
- [bastore $3 $1 @_ _.bastore]
- [castore $3 $1 @_ _.castore]
- [sastore $3 $1 @_ _.sastore]
+ [iastore $3 $0 @_ _.iastore]
+ [lastore $4 $0 @_ _.lastore]
+ [fastore $3 $0 @_ _.fastore]
+ [dastore $4 $0 @_ _.dastore]
+ [aastore $3 $0 @_ _.aastore]
+ [bastore $3 $0 @_ _.bastore]
+ [castore $3 $0 @_ _.castore]
+ [sastore $3 $0 @_ _.sastore]
[istore_0 $1 $0 @0 _.istore_0]
[istore_1 $1 $0 @1 _.istore_1]
diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux
index 72324192f..c99893692 100644
--- a/stdlib/source/library/lux/target/lua.lux
+++ b/stdlib/source/library/lux/target/lua.lux
@@ -1,31 +1,31 @@
(.using
- [library
- [lux {"-" Location Code Label int if cond function or and not let ^ local comment}
- ["@" target]
- [abstract
- [equivalence {"+" Equivalence}]
- [hash {"+" Hash}]
- ["[0]" enum]]
- [control
- [pipe {"+" case> cond> new>}]
- [parser
- ["<[0]>" code]]]
- [data
- ["[0]" text
- ["%" format {"+" format}]]
- [collection
- ["[0]" list ("[1]#[0]" functor mix)]]]
- [macro
- [syntax {"+" syntax:}]
- ["[0]" template]
- ["[0]" code]]
- [math
- [number
- ["n" nat]
- ["i" int]
- ["f" frac]]]
- [type
- abstract]]])
+ [library
+ [lux {"-" Location Code Label int if function or and not let ^ local comment}
+ ["@" target]
+ [abstract
+ [equivalence {"+" Equivalence}]
+ [hash {"+" Hash}]
+ ["[0]" enum]]
+ [control
+ [pipe {"+" case> cond> new>}]
+ [parser
+ ["<[0]>" code]]]
+ [data
+ ["[0]" text
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" list ("[1]#[0]" functor mix)]]]
+ [macro
+ [syntax {"+" syntax:}]
+ ["[0]" template]
+ ["[0]" code]]
+ [math
+ [number
+ ["n" nat]
+ ["i" int]
+ ["f" frac]]]
+ [type
+ abstract]]])
... Added the carriage return for better Windows compatibility.
(def: \n+
@@ -89,7 +89,7 @@
Literal
(:abstraction "nil"))
- (def: .public bool
+ (def: .public boolean
(-> Bit Literal)
(|>> (case> #0 "false"
#1 "true")
@@ -142,7 +142,7 @@
(|>> ..safe (text.enclosed' text.double_quote) :abstraction))
(def: .public multi
- (-> (List Expression) Literal)
+ (-> (List Expression) Expression)
(|>> (list#each ..code)
(text.interposed ..input_separator)
:abstraction))
@@ -159,15 +159,15 @@
(|>> (list#each (.function (_ [key value])
(format key " = " (:representation value))))
(text.interposed ..input_separator)
- (text.enclosed ["{" "}"])
+ (text.enclosed ["({" "})"])
:abstraction))
(def: .public (item idx array)
(-> Expression Expression Access)
- (:abstraction (format (:representation array) "[" (:representation idx) "]")))
+ (:abstraction (format "(" (:representation array) ")[" (:representation idx) "]")))
(def: .public (the field table)
- (-> Text Expression Computation)
+ (-> Text Expression Access)
(:abstraction (format (:representation table) "." field)))
(def: .public length
@@ -176,7 +176,7 @@
(text.enclosed ["#(" ")"])
:abstraction))
- (def: .public (apply/* args func)
+ (def: .public (apply args func)
(-> (List Expression) Expression Computation)
(|> args
(list#each ..code)
@@ -339,9 +339,9 @@
(text.enclosed ["(" ")"])
:abstraction))
- (template [<name> <code>]
+ (template [<name> <code> <binding>]
[(def: .public (<name> name args body!)
- (-> Var (List Var) Statement Statement)
+ (-> <binding> (List Var) Statement Statement)
(:abstraction
(format <code> " " (:representation name)
(|> args
@@ -350,8 +350,8 @@
(..nested (:representation body!))
\n+ "end")))]
- [function "function"]
- [local_function "local function"]
+ [function "function" Location]
+ [local_function "local function" Var]
)
(def: .public break
@@ -372,13 +372,6 @@
(:abstraction (format "-- " commentary \n+ (:representation on))))
)
-(def: .public (cond clauses else!)
- (-> (List [Expression Statement]) Statement Statement)
- (list#mix (.function (_ [test then!] next!)
- (..if test then! next!))
- else!
- (list.reversed clauses)))
-
(syntax: (arity_inputs [arity <code>.nat])
(in (case arity
0 (.list)
@@ -390,37 +383,23 @@
(in (list.repeated arity (` ..Expression))))
(template [<arity> <function>+]
- [(with_expansions [<apply> (template.symbol ["apply/" <arity>])
- <inputs> (arity_inputs <arity>)
+ [(with_expansions [<inputs> (arity_inputs <arity>)
<types> (arity_types <arity>)
<definitions> (template.spliced <function>+)]
- (def: .public (<apply> function <inputs>)
- (-> Expression <types> Computation)
- (..apply/* (.list <inputs>) function))
-
(template [<function>]
- [(`` (def: .public (~~ (template.symbol [<function> "/" <arity>]))
- (<apply> (..var <function>))))]
+ [(`` (def: .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>)
+ (-> <types> Computation)
+ (..apply (.list <inputs>) (..var <function>))))]
<definitions>))]
[1
[["error"]
+ ["pcall"]
["print"]
["require"]
["type"]
["ipairs"]]]
-
[2
- [["print"]
- ["error"]]]
-
- [3
- [["print"]]]
-
- [4
- []]
-
- [5
- []]
+ [["error"]]]
)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
index 988b31f55..bcaa03ee6 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
@@ -55,7 +55,7 @@
(/////.except extension.invalid_syntax [extension_name %synthesis input]))))
(template: (!unary function)
- [(|>> list _.apply/* (|> (_.var function)))])
+ [(|>> list _.apply (|> (_.var function)))])
(def: .public (statement expression archive synthesis)
Phase!
@@ -159,12 +159,12 @@
(/.install "/" (binary (product.uncurried //runtime.i64//division)))
(/.install "%" (binary (product.uncurried //runtime.i64//remainder)))
(/.install "f64" (unary (_./ (_.float +1.0))))
- (/.install "char" (unary (_.apply/1 (_.var "utf8.char"))))
+ (/.install "char" (unary (function (_ it) (_.apply (list it) (_.var "utf8.char")))))
)))
(def: f64//decode
(Unary Expression)
- (|>> list _.apply/* (|> (_.var "tonumber")) _.return (_.closure (list)) //runtime.lux//try))
+ (|>> list _.apply (|> (_.var "tonumber")) _.return (_.closure (list)) //runtime.lux//try))
(def: f64_procs
Bundle
@@ -174,11 +174,11 @@
(/.install "-" (binary (product.uncurried _.-)))
(/.install "*" (binary (product.uncurried _.*)))
(/.install "/" (binary (product.uncurried _./)))
- (/.install "%" (binary (product.uncurried (function.flipped (_.apply/2 (_.var "math.fmod"))))))
+ (/.install "%" (binary (product.uncurried (function (_ parameter subject) (_.apply (list subject parameter) (_.var "math.fmod"))))))
(/.install "=" (binary (product.uncurried _.=)))
(/.install "<" (binary (product.uncurried _.<)))
(/.install "i64" (unary (!unary "math.floor")))
- (/.install "encode" (unary (_.apply/2 (_.var "string.format") (_.string "%.17g"))))
+ (/.install "encode" (unary (function (_ it) (_.apply (list (_.string "%.17g") it) (_.var "string.format")))))
(/.install "decode" (unary ..f64//decode)))))
(def: (text//char [paramO subjectO])
@@ -211,7 +211,7 @@
(def: (io//log! messageO)
(Unary Expression)
- (|> (_.apply/* (list messageO) (_.var "print"))
+ (|> (_.apply (list messageO) (_.var "print"))
(_.or //runtime.unit)))
(def: io_procs
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux
index 4a9997ec7..23469d067 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux
@@ -109,11 +109,11 @@
(function (_ extension phase archive inputS)
(do [! ////////phase.monad]
[inputG (phase archive inputS)]
- (in (_.apply/1 (<| (_.closure (list $input))
- (_.return (|> (_.var "string.byte")
- (_.apply/* (list $input (_.int +1) (_.length $input)))
- (_.apply/1 (_.var "table.pack")))))
- inputG))))]))
+ (in (<| (_.apply (list inputG))
+ (_.closure (list $input))
+ (_.return (_.apply (list (_.apply (list $input (_.int +1) (_.length $input))
+ (_.var "string.byte")))
+ (_.var "table.pack")))))))]))
(def: utf8::decode
(custom
@@ -121,9 +121,9 @@
(function (_ extension phase archive inputS)
(do [! ////////phase.monad]
[inputG (phase archive inputS)]
- (in (|> inputG
- (_.apply/1 (_.var "table.unpack"))
- (_.apply/1 (_.var "string.char"))))))]))
+ (in (_.apply (list (_.apply (list inputG)
+ (_.var "table.unpack")))
+ (_.var "string.char")))))]))
(def: utf8
Bundle
@@ -146,7 +146,7 @@
(do [! ////////phase.monad]
[abstractionG (phase archive abstractionS)
inputsG (monad.each ! (phase archive) inputsS)]
- (in (_.apply/* inputsG abstractionG))))]))
+ (in (_.apply inputsG abstractionG))))]))
(def: lua::power
(custom
@@ -177,11 +177,11 @@
(variable "input"))
(list.repeated (.nat arity) []))]
(in (<| (_.closure g!inputs)
- _.statement
+ _.return
(case (.nat arity)
- 0 (_.apply/1 abstractionG //runtime.unit)
- 1 (_.apply/* g!inputs abstractionG)
- _ (_.apply/1 abstractionG (_.array g!inputs)))))))]))
+ 0 (_.apply (list //runtime.unit) abstractionG)
+ 1 (_.apply g!inputs abstractionG)
+ _ (_.apply (list (_.array g!inputs)) abstractionG))))))]))
(def: .public bundle
Bundle
@@ -196,5 +196,5 @@
(/.install "power" lua::power)
(/.install "import" lua::import)
(/.install "function" lua::function)
- (/.install "script universe" (nullary (function.constant (_.bool reference.universe))))
+ (/.install "script universe" (nullary (function.constant (_.boolean reference.universe))))
)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux
index d4f994a5d..b28f5b5a7 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux
@@ -23,19 +23,13 @@
["[1][0]" value]
["[1][0]" structure]
[////
- ["[0]" synthesis {"+" Path Synthesis}]
+ ["[0]" synthesis {"+" Path Fork Synthesis}]
["[0]" generation]
[///
["[0]" phase ("operation#[0]" monad)]
[reference
[variable {"+" Register}]]]]])
-(def: equals_name
- "equals")
-
-(def: equals_type
- (type.method [(list) (list //type.value) type.boolean (list)]))
-
(def: (pop_alt stack_depth)
(-> Nat (Bytecode Any))
(.case stack_depth
@@ -55,10 +49,6 @@
(-> (I64 Any) (Bytecode Any))
(|>> .int _.long))
-(def: double
- (-> Frac (Bytecode Any))
- (|>> _.double))
-
(def: peek
(Bytecode Any)
($_ _.composite
@@ -90,178 +80,240 @@
(..int lefts)
//runtime.right_projection))
-(def: (path' stack_depth @else @end phase archive path)
- (-> Nat Label Label (Generator Path))
- (.case path
- {synthesis.#Pop}
- (operation#in ..pop)
-
- {synthesis.#Bind register}
- (operation#in ($_ _.composite
- ..peek
- (_.astore register)))
+(def: equals@Object
+ (.let [class (type.class "java.lang.Object" (list))
+ method (type.method [(list) (list //type.value) type.boolean (list)])]
+ (_.invokevirtual class "equals" method)))
- {synthesis.#Then bodyS}
- (do phase.monad
- [bodyG (phase archive bodyS)]
- (in ($_ _.composite
- (..pop_alt stack_depth)
- bodyG
- (_.goto @end))))
-
- (^template [<pattern> <right?>]
- [(^ (<pattern> lefts))
- (operation#in
- (do _.monad
- [@success _.new_label
- @fail _.new_label]
+(def: (path|bind register)
+ (-> Register (Operation (Bytecode Any)))
+ (operation#in ($_ _.composite
+ ..peek
+ (_.astore register))))
+
+(def: (path|bit_fork again @else [when thenP elseP])
+ (-> (-> Path (Operation (Bytecode Any)))
+ Label [Bit Path (Maybe Path)]
+ (Operation (Bytecode Any)))
+ (do phase.monad
+ [then! (again thenP)
+ else! (.case elseP
+ {.#Some elseP}
+ (again elseP)
+
+ {.#None}
+ (in (_.goto @else)))
+ .let [if! (.if when _.ifeq _.ifne)]]
+ (in (do _.monad
+ [@else _.new_label]
($_ _.composite
..peek
- (_.checkcast //type.variant)
- (//structure.lefts lefts <right?>)
- (//structure.right? <right?>)
- //runtime.case
- _.dup
- (_.ifnull @fail)
- (_.goto @success)
- (_.set_label @fail)
- _.pop
- (_.goto @else)
- (_.set_label @success)
- //runtime.push)))])
- ([synthesis.side/left false]
- [synthesis.side/right true])
+ (//value.unwrap type.boolean)
+ (if! @else)
+ then!
+ (_.set_label @else)
+ else!)))))
- (^template [<pattern> <projection>]
- [(^ (<pattern> lefts))
- (operation#in ($_ _.composite
- ..peek
- (<projection> lefts)
- //runtime.push))])
- ([synthesis.member/left ..left_projection]
- [synthesis.member/right ..right_projection])
+(template [<name> <type> <unwrap> <dup> <pop> <test> <comparison> <if>]
+ [(def: (<name> again @else cons)
+ (-> (-> Path (Operation (Bytecode Any)))
+ Label (Fork <type> Path)
+ (Operation (Bytecode Any)))
+ (do [! phase.monad]
+ [fork! (monad.mix ! (function (_ [test thenP] else!)
+ (do !
+ [then! (again thenP)]
+ (in (do _.monad
+ [@else _.new_label]
+ ($_ _.composite
+ <dup>
+ (<test> test)
+ <comparison>
+ (<if> @else)
+ <pop>
+ then!
+ (_.set_label @else)
+ else!)))))
+ ($_ _.composite
+ <pop>
+ (_.goto @else))
+ {.#Item cons})]
+ (in ($_ _.composite
+ ..peek
+ <unwrap>
+ fork!))))]
- ... Extra optimization
- (^ (synthesis.path/seq
- (synthesis.member/left 0)
- (synthesis.!bind_top register thenP)))
- (do phase.monad
- [thenG (path' stack_depth @else @end phase archive thenP)]
- (in ($_ _.composite
- ..peek
- (_.checkcast //type.tuple)
- _.iconst_0
- _.aaload
- (_.astore register)
- thenG)))
+ [path|i64_fork (I64 Any) (//value.unwrap type.long) _.dup2 _.pop2 ..long _.lcmp _.ifne]
+ [path|f64_fork Frac (//value.unwrap type.double) _.dup2 _.pop2 _.double _.dcmpl _.ifne]
+ [path|text_fork Text (# _.monad in []) _.dup _.pop _.string ..equals@Object _.ifeq]
+ )
+
+(def: (path' stack_depth @else @end phase archive)
+ (-> Nat Label Label (Generator Path))
+ (function (again path)
+ (.case path
+ {synthesis.#Pop}
+ (operation#in ..pop)
+
+ {synthesis.#Bind register}
+ (..path|bind register)
+
+ (^template [<tag> <path>]
+ [{<tag> it}
+ (<path> again @else it)])
+ ([synthesis.#Bit_Fork ..path|bit_fork]
+ [synthesis.#I64_Fork ..path|i64_fork]
+ [synthesis.#F64_Fork ..path|f64_fork]
+ [synthesis.#Text_Fork ..path|text_fork])
- ... Extra optimization
- (^template [<pm> <projection>]
- [(^ (synthesis.path/seq
- (<pm> lefts)
- (synthesis.!bind_top register thenP)))
- (do phase.monad
- [then! (path' stack_depth @else @end phase archive thenP)]
- (in ($_ _.composite
- ..peek
- (_.checkcast //type.tuple)
- (..int lefts)
- <projection>
- (_.astore register)
- then!)))])
- ([synthesis.member/left //runtime.left_projection]
- [synthesis.member/right //runtime.right_projection])
+ {synthesis.#Then bodyS}
+ (do phase.monad
+ [body! (phase archive bodyS)]
+ (in ($_ _.composite
+ (..pop_alt stack_depth)
+ body!
+ (_.when_continuous (_.goto @end)))))
+
+ (^template [<right?> <pattern>]
+ [(^ (<pattern> lefts))
+ (operation#in
+ (do _.monad
+ [@success _.new_label]
+ ($_ _.composite
+ ..peek
+ (_.checkcast //type.variant)
+ (//structure.lefts lefts)
+ (//structure.right? <right?>)
+ //runtime.case
+ _.dup
+ (_.ifnonnull @success)
+ _.pop
+ (_.goto @else)
+ (_.set_label @success)
+ //runtime.push)))])
+ ([#0 synthesis.side/left]
+ [#1 synthesis.side/right])
- {synthesis.#Alt leftP rightP}
- (do phase.monad
- [@alt_else //runtime.forge_label
- left! (path' (++ stack_depth) @alt_else @end phase archive leftP)
- right! (path' stack_depth @else @end phase archive rightP)]
- (in ($_ _.composite
- _.dup
- left!
- (_.set_label @alt_else)
- _.pop
- right!)))
-
- {synthesis.#Seq leftP rightP}
- (do phase.monad
- [left! (path' stack_depth @else @end phase archive leftP)
- right! (path' stack_depth @else @end phase archive rightP)]
- (in ($_ _.composite
- left!
- right!)))
+ (^template [<pattern> <projection>]
+ [(^ (<pattern> lefts))
+ (operation#in ($_ _.composite
+ ..peek
+ (<projection> lefts)
+ //runtime.push))
- _
- (undefined)
- ))
+ ... Extra optimization
+ (^ (synthesis.path/seq
+ (<pattern> lefts)
+ (synthesis.!bind_top register thenP)))
+ (do phase.monad
+ [then! (path' stack_depth @else @end phase archive thenP)]
+ (in ($_ _.composite
+ ..peek
+ (<projection> lefts)
+ (_.astore register)
+ then!)))])
+ ([synthesis.member/left ..left_projection]
+ [synthesis.member/right ..right_projection])
+
+ {synthesis.#Seq leftP rightP}
+ (do phase.monad
+ [left! (path' stack_depth @else @end phase archive leftP)
+ right! (path' stack_depth @else @end phase archive rightP)]
+ (in ($_ _.composite
+ left!
+ right!)))
+
+ {synthesis.#Alt leftP rightP}
+ (do phase.monad
+ [@alt_else //runtime.forge_label
+ left! (path' (++ stack_depth) @alt_else @end phase archive leftP)
+ right! (path' stack_depth @else @end phase archive rightP)]
+ (in ($_ _.composite
+ _.dup
+ left!
+ (_.set_label @alt_else)
+ _.pop
+ right!)))
+ )))
(def: (path @end phase archive path)
(-> Label (Generator Path))
(do phase.monad
[@else //runtime.forge_label
- pathG (..path' 1 @else @end phase archive path)]
+ path! (..path' 1 @else @end phase archive path)]
(in ($_ _.composite
- pathG
- (_.set_label @else)
- _.pop
- //runtime.pm_failure
- _.aconst_null
- (_.goto @end)))))
+ path!
+ (do _.monad
+ [?@else (_.acknowledged? @else)]
+ (.case ?@else
+ {.#None}
+ (in [])
+
+ {.#Some _}
+ ($_ _.composite
+ (_.set_label @else)
+ _.pop ... TODO: Comment this line
+ //runtime.pm_failure
+ _.aconst_null ... TODO: Comment this line
+ (_.goto @end)
+ )))
+ ))))
-(def: .public (if phase archive [conditionS thenS elseS])
+(def: .public (if phase archive [testS thenS elseS])
(Generator [Synthesis Synthesis Synthesis])
(do phase.monad
- [conditionG (phase archive conditionS)
- thenG (phase archive thenS)
- elseG (phase archive elseS)]
+ [test! (phase archive testS)
+ then! (phase archive thenS)
+ else! (phase archive elseS)]
(in (do _.monad
[@else _.new_label
@end _.new_label]
($_ _.composite
- conditionG
+ test!
(//value.unwrap type.boolean)
(_.ifeq @else)
- thenG
- (_.goto @end)
+ then!
+ (_.when_continuous (_.goto @end))
(_.set_label @else)
- elseG
+ else!
(_.set_label @end))))))
(def: .public (let phase archive [inputS register bodyS])
(Generator [Synthesis Register Synthesis])
(do phase.monad
- [inputG (phase archive inputS)
- bodyG (phase archive bodyS)]
+ [input! (phase archive inputS)
+ body! (phase archive bodyS)]
(in ($_ _.composite
- inputG
+ input!
(_.astore register)
- bodyG))))
+ body!))))
(def: .public (get phase archive [path recordS])
(Generator [(List synthesis.Member) Synthesis])
(do phase.monad
- [recordG (phase archive recordS)]
- (in (list#mix (function (_ step so_far)
- (.let [next (.case step
- {.#Left lefts}
- (..left_projection lefts)
-
- {.#Right lefts}
- (..right_projection lefts))]
- (_.composite so_far next)))
- recordG
+ [record! (phase archive recordS)]
+ (in (list#mix (function (_ step so_far!)
+ (.let [next! (.case step
+ {.#Left lefts}
+ (..left_projection lefts)
+
+ {.#Right lefts}
+ (..right_projection lefts))]
+ ($_ _.composite
+ so_far!
+ next!)))
+ record!
(list.reversed path)))))
(def: .public (case phase archive [valueS path])
(Generator [Synthesis Path])
(do phase.monad
[@end //runtime.forge_label
- valueG (phase archive valueS)
- pathG (..path @end phase archive path)]
+ value! (phase archive valueS)
+ path! (..path @end phase archive path)]
(in ($_ _.composite
_.aconst_null
- valueG
+ value!
//runtime.push
- pathG
+ path!
(_.set_label @end)))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
index 050ca318a..a7f0d7ac6 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
@@ -149,7 +149,7 @@
current_partials
(..inputs ..this_offset apply_arity)
missing_partials
- (_.invokevirtual class //init.name (//init.type environment function_arity))
+ (_.invokespecial class //init.name (//init.type environment function_arity))
_.areturn)))))))
(monad.all _.monad))]]
($_ _.composite
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux
index 664e0fbc8..6c8a9ee75 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux
@@ -35,7 +35,7 @@
{.#Some ($_ _.composite
(_.set_label @begin)
body
- _.areturn
+ (_.when_continuous _.areturn)
)}))
(def: .public method
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux
index cf9f6b02e..5a1ec9ea6 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux
@@ -55,8 +55,8 @@
_ (_.anewarray $Object)]
(monad.all ! membersI))))))
-(def: .public (lefts lefts right?)
- (-> Nat Bit (Bytecode Any))
+(def: .public (lefts lefts)
+ (-> Nat (Bytecode Any))
(case lefts
0 _.iconst_0
1 _.iconst_1
@@ -87,7 +87,7 @@
(do phase.monad
[valueI (phase archive valueS)]
(in (do _.monad
- [_ (..lefts lefts right?)
+ [_ (..lefts lefts)
_ (..right? right?)
_ valueI]
(_.invokestatic //runtime.class "variant"
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux
index 3afa582f0..16c8d5c19 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux
@@ -1,34 +1,34 @@
(.using
- [library
- [lux {"-" case let if}
- [abstract
- ["[0]" monad {"+" do}]]
- [data
- ["[0]" text
- ["%" format {"+" format}]]
- [collection
- ["[0]" list ("[1]#[0]" functor mix)]
- ["[0]" set]]]
- [target
- ["_" lua {"+" Expression Var Statement}]]]]
- ["[0]" // "_"
- ["[1][0]" runtime {"+" Operation Phase Phase! Generator Generator!}]
+ [library
+ [lux {"-" case let if}
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [data
+ ["[0]" text
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" list ("[1]#[0]" functor mix)]
+ ["[0]" set]]]
+ [target
+ ["_" lua {"+" Expression Var Statement}]]]]
+ ["[0]" // "_"
+ ["[1][0]" runtime {"+" Operation Phase Phase! Generator Generator!}]
+ ["[1][0]" reference]
+ ["[1][0]" primitive]
+ ["/[1]" // "_"
["[1][0]" reference]
- ["[1][0]" primitive]
["/[1]" // "_"
- ["[1][0]" reference]
+ ["[1][0]" synthesis "_"
+ ["[1]/[0]" case]]
["/[1]" // "_"
- ["[1][0]" synthesis "_"
- ["[1]/[0]" case]]
- ["/[1]" // "_"
- ["[1][0]" synthesis {"+" Member Synthesis Path}]
- ["[1][0]" generation]
- ["//[1]" /// "_"
- [reference
- ["[1][0]" variable {"+" Register}]]
- ["[1][0]" phase ("[1]#[0]" monad)]
- [meta
- [archive {"+" Archive}]]]]]]])
+ ["[1][0]" synthesis {"+" Member Synthesis Path}]
+ ["[1][0]" generation]
+ ["//[1]" /// "_"
+ [reference
+ ["[1][0]" variable {"+" Register}]]
+ ["[1][0]" phase ("[1]#[0]" monad)]
+ [meta
+ [archive {"+" Archive}]]]]]]])
(def: .public register
(-> Register Var)
@@ -47,7 +47,7 @@
(in (|> bodyO
_.return
(_.closure (list (..register register)))
- (_.apply/* (list valueO))))))
+ (_.apply (list valueO))))))
(def: .public (let! statement expression archive [valueS register bodyS])
(Generator! [Synthesis Register Synthesis])
@@ -83,7 +83,7 @@
(_.return thenO)
(_.return elseO))
(_.closure (list))
- (_.apply/* (list))))))
+ (_.apply (list))))))
(def: .public (if! statement expression archive [testS thenS elseS])
(Generator! [Synthesis Synthesis Synthesis])
@@ -101,11 +101,11 @@
(def: (push! value)
(-> Expression Statement)
- (_.statement (|> (_.var "table.insert") (_.apply/* (list @cursor value)))))
+ (_.statement (|> (_.var "table.insert") (_.apply (list @cursor value)))))
(def: peek_and_pop
Expression
- (|> (_.var "table.remove") (_.apply/* (list @cursor))))
+ (|> (_.var "table.remove") (_.apply (list @cursor))))
(def: pop!
Statement
@@ -118,17 +118,17 @@
(def: save!
Statement
(_.statement (|> (_.var "table.insert")
- (_.apply/* (list @savepoint
- (_.apply/* (list @cursor
- (_.int +1)
- (_.length @cursor)
- (_.int +1)
- (_.table (list)))
- (_.var "table.move")))))))
+ (_.apply (list @savepoint
+ (_.apply (list @cursor
+ (_.int +1)
+ (_.length @cursor)
+ (_.int +1)
+ (_.table (list)))
+ (_.var "table.move")))))))
(def: restore!
Statement
- (_.set (list @cursor) (|> (_.var "table.remove") (_.apply/* (list @savepoint)))))
+ (_.set (list @cursor) (|> (_.var "table.remove") (_.apply (list @savepoint)))))
(def: fail! _.break)
@@ -152,7 +152,7 @@
(def: (alternation pre! post!)
(-> Statement Statement Statement)
($_ _.then
- (_.while (_.bool true)
+ (_.while (_.boolean true)
($_ _.then
..save!
pre!))
@@ -200,7 +200,10 @@
..peek)
then!])))
{.#Item item})]
- (in (_.cond clauses ..fail!)))])
+ (in (list#mix (function (_ [when then!] else!)
+ (_.if when then! else!))
+ ..fail!
+ clauses)))])
([/////synthesis.#I64_Fork (<| _.int .int)]
[/////synthesis.#F64_Fork _.float]
[/////synthesis.#Text_Fork _.string])
@@ -244,9 +247,9 @@
(do ///////phase.monad
[pattern_matching! (pattern_matching' statement expression archive pathP)]
(in ($_ _.then
- (_.while (_.bool true)
+ (_.while (_.boolean true)
pattern_matching!)
- (_.statement (|> (_.var "error") (_.apply/* (list (_.string ////synthesis/case.pattern_matching_error)))))))))
+ (_.statement (|> (_.var "error") (_.apply (list (_.string ////synthesis/case.pattern_matching_error)))))))))
(def: .public dependencies
(-> Path (List Var))
@@ -278,4 +281,4 @@
(..case! statement expression archive)
(# ///////phase.monad each
(|>> (_.closure (list))
- (_.apply/* (list))))))
+ (_.apply (list))))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
index 649692ccc..5ce1e0b7a 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
@@ -1,43 +1,43 @@
(.using
- [library
- [lux {"-" Tuple Variant Label function}
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- pipe]
- [data
- ["[0]" product]
- [text
- ["%" format {"+" format}]]
- [collection
- ["[0]" list ("[1]#[0]" functor mix)]]]
- [target
- ["_" lua {"+" Var Expression Label Statement}]]]]
- ["[0]" // "_"
- ["[1][0]" runtime {"+" Operation Phase Phase! Generator}]
+ [library
+ [lux {"-" Tuple Variant Label function}
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ pipe]
+ [data
+ ["[0]" product]
+ [text
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" list ("[1]#[0]" functor mix)]]]
+ [target
+ ["_" lua {"+" Var Expression Label Statement}]]]]
+ ["[0]" // "_"
+ ["[1][0]" runtime {"+" Operation Phase Phase! Generator}]
+ ["[1][0]" reference]
+ ["[1][0]" case]
+ ["/[1]" // "_"
["[1][0]" reference]
- ["[1][0]" case]
- ["/[1]" // "_"
- ["[1][0]" reference]
+ ["//[1]" /// "_"
+ [analysis {"+" Variant Tuple Abstraction Application Analysis}]
+ [synthesis {"+" Synthesis}]
+ ["[1][0]" generation {"+" Context}]
["//[1]" /// "_"
- [analysis {"+" Variant Tuple Abstraction Application Analysis}]
- [synthesis {"+" Synthesis}]
- ["[1][0]" generation {"+" Context}]
- ["//[1]" /// "_"
- [arity {"+" Arity}]
- ["[1][0]" phase ("[1]#[0]" monad)]
- [meta
- [archive
- ["[0]" dependency]]]
- [reference
- [variable {"+" Register Variable}]]]]]])
+ [arity {"+" Arity}]
+ ["[1][0]" phase ("[1]#[0]" monad)]
+ [meta
+ [archive
+ ["[0]" dependency]]]
+ [reference
+ [variable {"+" Register Variable}]]]]]])
(def: .public (apply expression archive [functionS argsS+])
(Generator (Application Synthesis))
(do [! ///////phase.monad]
[functionO (expression archive functionS)
argsO+ (monad.each ! (expression archive) argsS+)]
- (in (_.apply/* argsO+ functionO))))
+ (in (_.apply argsO+ functionO))))
(def: capture
(-> Register Var)
@@ -57,7 +57,7 @@
($_ _.then
(_.local_function @self @args body!)
(_.return @self)))
- (_.apply/* inits @self)])))
+ (_.apply inits @self)])))
(def: input
(|>> ++ //case.register))
@@ -90,51 +90,52 @@
initialize_self!
(list.indices arity))
pack (|>> (list) _.array)
- unpack (_.apply/1 (_.var "table.unpack"))
+ unpack (: (-> Expression Expression)
+ (.function (_ it)
+ (_.apply (list it) (_.var "table.unpack"))))
@var_args (_.var "...")]
.let [[definition instantiation] (with_closure closureO+ @self (list @var_args)
($_ _.then
(_.local/1 @curried (pack @var_args))
(_.local/1 @num_args (_.length @curried))
- (_.cond (list [(|> @num_args (_.= arityO))
- ($_ _.then
- initialize!
- (_.set_label @scope)
- body!)]
- [(|> @num_args (_.> arityO))
- (let [arity_inputs (_.apply/5 (_.var "table.move")
- @curried
- (_.int +1)
- arityO
- (_.int +1)
- (_.array (list)))
- extra_inputs (_.apply/5 (_.var "table.move")
- @curried
- (_.+ (_.int +1) arityO)
- @num_args
- (_.int +1)
- (_.array (list)))]
- (_.return (|> @self
- (_.apply/* (list (unpack arity_inputs)))
- (_.apply/* (list (unpack extra_inputs))))))])
- ... (|> @num_args (_.< arityO))
- (_.return (_.closure (list @var_args)
- (let [@extra_args (_.var "extra_args")]
- ($_ _.then
- (_.local/1 @extra_args (pack @var_args))
- (_.return (|> (_.array (list))
- (_.apply/5 (_.var "table.move")
- @curried
- (_.int +1)
- @num_args
- (_.int +1))
- (_.apply/5 (_.var "table.move")
- @extra_args
- (_.int +1)
- (_.length @extra_args)
- (_.+ (_.int +1) @num_args))
- unpack
- (_.apply/1 @self))))))))
+ (<| (_.if (|> @num_args (_.= arityO))
+ ($_ _.then
+ initialize!
+ (_.set_label @scope)
+ body!))
+ (_.if (|> @num_args (_.> arityO))
+ (let [arity_inputs (_.apply (list @curried
+ (_.int +1)
+ arityO
+ (_.int +1)
+ (_.array (list)))
+ (_.var "table.move"))
+ extra_inputs (_.apply (list @curried
+ (_.+ (_.int +1) arityO)
+ @num_args
+ (_.int +1)
+ (_.array (list)))
+ (_.var "table.move"))]
+ (_.return (|> @self
+ (_.apply (list (unpack arity_inputs)))
+ (_.apply (list (unpack extra_inputs)))))))
+ ... (|> @num_args (_.< arityO))
+ (_.return (_.closure (list @var_args)
+ (let [@extra_args (_.var "extra_args")]
+ ($_ _.then
+ (_.local/1 @extra_args (pack @var_args))
+ (_.return (_.apply (list (unpack (_.apply (list @extra_args
+ (_.int +1)
+ (_.length @extra_args)
+ (_.+ (_.int +1) @num_args)
+ (_.apply (list @curried
+ (_.int +1)
+ @num_args
+ (_.int +1)
+ (_.array (list)))
+ (_.var "table.move")))
+ (_.var "table.move"))))
+ @self)))))))
))]
_ (/////generation.execute! definition)
_ (/////generation.save! (product.right function_name) {.#None} definition)]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux
index c58a5d476..06135b240 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux
@@ -108,10 +108,10 @@
scope!)
(_.return @loop)
))
- (|> @context (_.apply/* foreigns))])))]
+ (_.apply foreigns @context)])))]
_ (/////generation.execute! directive)
_ (/////generation.save! artifact_id {.#None} directive)]
- (in (|> instantiation (_.apply/* initsO+))))))
+ (in (_.apply initsO+ instantiation)))))
(def: .public (again! statement expression archive argsS+)
(Generator! (List Synthesis))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux
index 3c879b684..556371e6a 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux
@@ -9,7 +9,7 @@
(-> <type> Literal)
<implementation>)]
- [bit Bit _.bool]
+ [bit Bit _.boolean]
[i64 (I64 Any) (|>> .int _.int)]
[f64 Frac _.float]
[text Text _.string]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux
index f20a6cb12..40525dd00 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux
@@ -1,42 +1,42 @@
(.using
- [library
- [lux {"-" Label Location}
- ["[0]" meta]
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" function]
- ["<>" parser
- ["<[0]>" code]]]
- [data
- ["[0]" product]
- ["[0]" text ("[1]#[0]" hash)
- ["%" format {"+" format}]
- [encoding
- ["[0]" utf8]]]
- [collection
- ["[0]" list ("[1]#[0]" functor)]
- ["[0]" sequence]]]
- ["[0]" macro
- [syntax {"+" syntax:}]
- ["[0]" code]]
- [math
- [number {"+" hex}
- ["[0]" i64]]]
- ["@" target
- ["_" lua {"+" Expression Location Var Computation Literal Label Statement}]]]]
- ["[0]" /// "_"
- ["[1][0]" reference]
- ["//[1]" /// "_"
- ["[1][0]" synthesis {"+" Synthesis}]
- ["[1][0]" generation]
- ["//[1]" ///
- ["[1][0]" phase]
- [reference
- [variable {"+" Register}]]
- [meta
- [archive {"+" Output Archive}
- ["[0]" artifact {"+" Registry}]]]]]])
+ [library
+ [lux {"-" Label Location}
+ ["[0]" meta]
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" function]
+ ["<>" parser
+ ["<[0]>" code]]]
+ [data
+ ["[0]" product]
+ ["[0]" text ("[1]#[0]" hash)
+ ["%" format {"+" format}]
+ [encoding
+ ["[0]" utf8]]]
+ [collection
+ ["[0]" list ("[1]#[0]" functor)]
+ ["[0]" sequence]]]
+ ["[0]" macro
+ [syntax {"+" syntax:}]
+ ["[0]" code]]
+ [math
+ [number {"+" hex}
+ ["[0]" i64]]]
+ ["@" target
+ ["_" lua {"+" Expression Location Var Computation Literal Label Statement}]]]]
+ ["[0]" /// "_"
+ ["[1][0]" reference]
+ ["//[1]" /// "_"
+ ["[1][0]" synthesis {"+" Synthesis}]
+ ["[1][0]" generation]
+ ["//[1]" ///
+ ["[1][0]" phase]
+ [reference
+ [variable {"+" Register}]]
+ [meta
+ [archive {"+" Output Archive}
+ ["[0]" artifact {"+" Registry}]]]]]])
(template [<name> <base>]
[(type: .public <name>
@@ -148,7 +148,7 @@
inputs)]
(in (list (` (def: .public ((~ g!name) (~+ inputsC))
(-> (~+ inputs_typesC) Computation)
- (_.apply/* (list (~+ inputsC)) (~ runtime_name))))
+ (_.apply (list (~+ inputsC)) (~ runtime_name))))
(` (def: (~ (code.local_symbol (format "@" name)))
Statement
@@ -170,7 +170,7 @@
(_.set (list tuple) (..item last_index_right tuple))))]
(runtime: (tuple//left lefts tuple)
(with_vars [last_index_right]
- (<| (_.while (_.bool true))
+ (<| (_.while (_.boolean true))
($_ _.then
(_.local/1 last_index_right (..last_index tuple))
(_.if (_.> lefts last_index_right)
@@ -181,21 +181,21 @@
(runtime: (tuple//right lefts tuple)
(with_vars [last_index_right right_index]
- (<| (_.while (_.bool true))
+ (<| (_.while (_.boolean true))
($_ _.then
(_.local/1 last_index_right (..last_index tuple))
(_.local/1 right_index (_.+ (_.int +1) lefts))
- (_.cond (list [(_.= last_index_right right_index)
- (_.return (..item right_index tuple))]
- [(_.> last_index_right right_index)
- ... Needs recursion.
- <recur>])
- (_.return (_.apply/* (list tuple
- (_.+ (_.int +1) right_index)
- (_.length tuple)
- (_.int +1)
- (_.array (list)))
- (_.var "table.move"))))
+ (<| (_.if (_.= last_index_right right_index)
+ (_.return (..item right_index tuple)))
+ (_.if (_.> last_index_right right_index)
+ ... Needs recursion.
+ <recur>)
+ (_.return (_.apply (list tuple
+ (_.+ (_.int +1) right_index)
+ (_.length tuple)
+ (_.int +1)
+ (_.array (list)))
+ (_.var "table.move"))))
)))))
(runtime: (sum//get sum expected##right? expected##lefts)
@@ -208,24 +208,22 @@
(_.- actual##lefts)
(_.- (_.int +1))))
(_.set (list sum) actual##value))]
- (<| (_.while (_.bool true))
- (_.cond (list [(_.= expected##lefts actual##lefts)
- (_.if (_.= expected##right? actual##right?)
- (_.return actual##value)
- mismatch!)]
-
- [(_.< expected##lefts actual##lefts)
- (_.if (_.= ..unit actual##right?)
- recur!
- mismatch!)]
-
- [(_.= ..unit expected##right?)
- (_.return (variant' (|> actual##lefts
- (_.- expected##lefts)
- (_.- (_.int +1)))
- actual##right?
- actual##value))])
- mismatch!))))
+ (<| (_.while (_.boolean true))
+ (_.if (_.= expected##lefts actual##lefts)
+ (_.if (_.= expected##right? actual##right?)
+ (_.return actual##value)
+ mismatch!))
+ (_.if (_.< expected##lefts actual##lefts)
+ (_.if (_.= ..unit actual##right?)
+ recur!
+ mismatch!))
+ (_.if (_.= ..unit expected##right?)
+ (_.return (variant' (|> actual##lefts
+ (_.- expected##lefts)
+ (_.- (_.int +1)))
+ actual##right?
+ actual##value)))
+ mismatch!)))
(def: runtime//adt
Statement
@@ -238,9 +236,9 @@
(runtime: (lux//try risky)
(with_vars [success value]
($_ _.then
- (_.let (list success value) (|> risky (_.apply/* (list ..unit))
+ (_.let (list success value) (|> risky (_.apply (list ..unit))
_.return (_.closure (list))
- list _.apply/* (|> (_.var "pcall"))))
+ list _.apply (|> (_.var "pcall"))))
(_.if success
(_.return (..right value))
(_.return (..left value))))))
@@ -306,18 +304,17 @@
(def: (find_byte_index subject param start)
(-> Expression Expression Expression Expression)
- (_.apply/4 (_.var "string.find") subject param start (_.bool #1)))
+ (_.apply (list subject param start (_.boolean #1))
+ (_.var "string.find")))
(def: (char_index subject byte_index)
(-> Expression Expression Expression)
- (|> byte_index
- (_.apply/3 (_.var "utf8.len") subject (_.int +1))))
+ (_.apply (list subject (_.int +1) byte_index)
+ (_.var "utf8.len")))
(def: (byte_index subject char_index)
(-> Expression Expression Expression)
- (|> char_index
- (_.+ (_.int +1))
- (_.apply/2 (_.var "utf8.offset") subject)))
+ (_.apply (list subject (_.+ (_.int +1) char_index)) (_.var "utf8.offset")))
(def: lux_index
(-> Expression Expression)
@@ -352,22 +349,23 @@
<normal>)))))
(runtime: (text//clip text offset length)
- (with_expansions [<rembulan> (_.return (_.apply/3 (_.var "string.sub") text (_.+ (_.int +1) offset) (_.+ offset length)))
- <normal> (_.return (_.apply/3 (_.var "string.sub")
- text
- (..byte_index text offset)
- (|> (_.+ offset length)
- ... (_.+ (_.int +1))
- (..byte_index text)
- (_.- (_.int +1)))))]
+ (with_expansions [<rembulan> (_.return (_.apply (list text (_.+ (_.int +1) offset) (_.+ offset length))
+ (_.var "string.sub")))
+ <normal> (_.return (_.apply (list text
+ (..byte_index text offset)
+ (|> (_.+ offset length)
+ ... (_.+ (_.int +1))
+ (..byte_index text)
+ (_.- (_.int +1))))
+ (_.var "string.sub")))]
(for [@.lua <normal>]
(_.if ..on_rembulan?
<rembulan>
<normal>))))
(runtime: (text//size subject)
- (with_expansions [<rembulan> (_.return (_.apply/1 (_.var "string.len") subject))
- <normal> (_.return (_.apply/1 (_.var "utf8.len") subject))]
+ (with_expansions [<rembulan> (_.return (_.apply (list subject) (_.var "string.len")))
+ <normal> (_.return (_.apply (list subject) (_.var "utf8.len")))]
(for [@.lua <normal>]
(_.if ..on_rembulan?
<rembulan>
@@ -376,17 +374,17 @@
(runtime: (text//char idx text)
(with_expansions [<rembulan> (with_vars [char]
($_ _.then
- (_.local/1 char (_.apply/* (list text idx)
- (_.var "string.byte")))
+ (_.local/1 char (_.apply (list text idx)
+ (_.var "string.byte")))
(_.if (_.= _.nil char)
(_.statement (_.error/1 (_.string "[Lux Error] Cannot get char from text.")))
(_.return char))))
<normal> (with_vars [offset char]
($_ _.then
- (_.local/1 offset (_.apply/2 (_.var "utf8.offset") text idx))
+ (_.local/1 offset (_.apply (list text idx) (_.var "utf8.offset")))
(_.if (_.= _.nil offset)
(_.statement (_.error/1 (_.string "[Lux Error] Cannot get char from text.")))
- (_.return (_.apply/2 (_.var "utf8.codepoint") text offset)))))]
+ (_.return (_.apply (list text offset) (_.var "utf8.codepoint"))))))]
(for [@.lua <normal>]
(_.if ..on_rembulan?
<rembulan>
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index 255d15c71..631f754e4 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -65,8 +65,9 @@
(~~ (.for ["{old}" (~~ (.as_is ["[1]/[0]" jvm]))
"JVM" (~~ (.as_is ["[1]/[0]" jvm]))
"JavaScript" (~~ (.as_is ["[1]/[0]" js]))
- "Ruby" (~~ (.as_is ["[1]/[0]" ruby]))
- "Python" (~~ (.as_is ["[1]/[0]" python]))]
+ "Lua" (~~ (.as_is ["[1]/[0]" lua]))
+ "Python" (~~ (.as_is ["[1]/[0]" python]))
+ "Ruby" (~~ (.as_is ["[1]/[0]" ruby]))]
(~~ (.as_is))))]
])))
@@ -101,8 +102,9 @@
(~~ (for [@.jvm (~~ (as_is /target/jvm.test))
@.old (~~ (as_is /target/jvm.test))
@.js (~~ (as_is /target/js.test))
- @.ruby (~~ (as_is /target/ruby.test))
- @.python (~~ (as_is /target/python.test))]
+ @.lua (~~ (as_is /target/lua.test))
+ @.python (~~ (as_is /target/python.test))
+ @.ruby (~~ (as_is /target/ruby.test))]
(~~ (as_is))))
(~~ (for [@.old (~~ (as_is))]
(~~ (as_is /extension.test))))
@@ -181,21 +183,21 @@
(case (/.try expected)
{.#Left _}
false
-
+
{.#Right actual}
(n.= expected actual)))
(_.cover [/.undefined]
(case (/.try (/.undefined))
{.#Left _}
true
-
+
{.#Right _}
false))
(_.cover [/.panic!]
(case (/.try (/.panic! expected_error))
{.#Left actual_error}
(text.contains? expected_error actual_error)
-
+
{.#Right _}
false))
)))
@@ -1116,7 +1118,7 @@
(value@ .#mappings)
(list#each product.left)
(set.of_list text.hash))
-
+
correct_locals!
(and (n.= 4 (value@ .#counter locals/2))
(set#= expected_locals/2
@@ -1149,7 +1151,7 @@
(binding? captured? let/0))]
(and correct_locals!
correct_closure!))
-
+
_
false)))))
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index 92b314dc7..a754e9bd2 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -150,6 +150,9 @@
@.js (generation.save! artifact_id {.#None}
(js.comment commentary
(js.statement (js.string commentary))))
+ @.python (generation.save! artifact_id {.#None}
+ (python.comment commentary
+ (python.statement (python.string commentary))))
@.lua (generation.save! artifact_id {.#None}
(lua.comment commentary
(lua.statement (lua.string commentary))))
@@ -159,8 +162,10 @@
(generation.log! commentary))))]
(in directive.no_requirements)))
- ... TODO: No longer skip testing Lua after Rembulan isn't being used anymore.
- (for [@.lua (as_is)]
+ (for [... TODO: No longer skip testing Lua after Rembulan isn't being used anymore.
+ @.lua (as_is)
+ ... TODO: No longer skip testing Python.
+ @.python (as_is)]
(`` ((~~ (static ..directive)) (n.* 2 3))))
))
diff --git a/stdlib/source/test/lux/target/js.lux b/stdlib/source/test/lux/target/js.lux
index cc60dd896..ae190fade 100644
--- a/stdlib/source/test/lux/target/js.lux
+++ b/stdlib/source/test/lux/target/js.lux
@@ -80,7 +80,7 @@
(try#each (function (_ it)
(case it
{.#None} true
- {.#Some _} true)))
+ {.#Some _} false)))
(try.else false)))
(_.cover [/.boolean]
(expression (|>> (:as Bit) (bit#= boolean))
diff --git a/stdlib/source/test/lux/target/lua.lux b/stdlib/source/test/lux/target/lua.lux
new file mode 100644
index 000000000..2558f41c8
--- /dev/null
+++ b/stdlib/source/test/lux/target/lua.lux
@@ -0,0 +1,709 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ ["[0]" ffi]
+ ["[0]" static]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]
+ ["$[0]" hash]]]
+ [control
+ [pipe {"+" case>}]
+ ["[0]" function]
+ ["[0]" maybe ("[1]#[0]" functor)]
+ ["[0]" try {"+" Try} ("[1]#[0]" functor)]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text {"+" \n} ("[1]#[0]" equivalence)
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" list ("[1]#[0]" functor)]]]
+ [macro
+ ["[0]" template]]
+ ["[0]" math
+ ["[0]" random {"+" Random} ("[1]#[0]" monad)]
+ [number
+ ["n" nat]
+ ["i" int]
+ ["f" frac]
+ ["[0]" i64]]]]]
+ [\\library
+ ["[0]" /]])
+
+... http://www.lua.org/manual/5.3/manual.html#pdf-load
+(ffi.import: (load [Text] "?" (-> Any Any)))
+
+(def: (expression ??? it)
+ (-> (-> Any Bit) /.Expression Bit)
+ (|> it
+ /.code
+ (format "return ")
+ ..load
+ (maybe#each (|>> (function.on []) ???))
+ (maybe.else false)))
+
+(def: test|literal
+ Test
+ (do [! random.monad]
+ [boolean random.bit
+ int random.int
+ float random.frac
+ string (random.ascii/upper 5)]
+ ($_ _.and
+ (_.cover [/.nil]
+ (|> /.nil
+ /.code
+ ..load
+ (case> {.#None} true
+ {.#Some _} false)))
+ (_.cover [/.boolean]
+ (expression (|>> (:as Bit) (bit#= boolean))
+ (/.boolean boolean)))
+ (_.cover [/.int]
+ (expression (|>> (:as Int) (i.= int))
+ (/.int int)))
+ (_.cover [/.float]
+ (expression (|>> (:as Frac) (f.= float))
+ (/.float float)))
+ (_.cover [/.string]
+ (expression (|>> (:as Text) (text#= string))
+ (/.string string)))
+ )))
+
+(def: test|boolean
+ Test
+ (do [! random.monad]
+ [left random.bit
+ right random.bit]
+ (`` ($_ _.and
+ (~~ (template [</> <lux>]
+ [(_.cover [</>]
+ (let [expected (<lux> left right)]
+ (expression (|>> (:as Bit) (bit#= expected))
+ (</> (/.boolean left) (/.boolean right)))))]
+
+ [/.or .or]
+ [/.and .and]
+ ))
+ (_.cover [/.not]
+ (expression (|>> (:as Bit) (bit#= (not left)))
+ (/.not (/.boolean left))))
+ ))))
+
+(template [<bits>]
+ [(`` (def: (~~ (template.symbol [int/ <bits>]))
+ (Random Int)
+ (let [mask (|> 1 (i64.left_shifted (-- <bits>)) --)]
+ (random#each (|>> (i64.and mask) .int) random.nat))))]
+
+ [16]
+ [32]
+ )
+
+(def: test|int
+ Test
+ (do [! random.monad]
+ [left random.int
+ right random.int
+ shift (# ! each (n.% 65) random.nat)
+
+ parameter (random.only (|>> (i.= +0) not)
+ random.int)
+ subject random.int]
+ (`` ($_ _.and
+ (~~ (template [</> <lux>]
+ [(_.cover [</>]
+ (let [expected (<lux> left right)]
+ (expression (|>> (:as Int) (i.= expected))
+ (</> (/.int left) (/.int right)))))]
+
+ [/.bit_or i64.or]
+ [/.bit_xor i64.xor]
+ [/.bit_and i64.and]
+ ))
+ (_.cover [/.opposite]
+ (expression (|>> (:as Int) (i.= (i.- left +0)))
+ (/.opposite (/.int left))))
+ (_.cover [/.bit_shl]
+ (let [expected (i64.left_shifted shift left)]
+ (expression (|>> (:as Int) (i.= expected))
+ (/.bit_shl (/.int (.int shift))
+ (/.int left)))))
+ (_.cover [/.bit_shr]
+ (let [expected (i64.right_shifted shift left)]
+ (expression (|>> (:as Int) (i.= expected))
+ (/.bit_shr (/.int (.int shift))
+ (/.int left)))))
+ (_.cover [/.//]
+ (let [expected (if (or (i.= (i.signum parameter) (i.signum subject))
+ (i.= +0 (i.% parameter subject)))
+ (i./ parameter subject)
+ (-- (i./ parameter subject)))]
+ (expression (|>> (:as Int) (i.= expected))
+ (/.// (/.int parameter) (/.int subject)))))
+ ))))
+
+(def: test|float
+ Test
+ (do [! random.monad]
+ [parameter (random.only (|>> (f.= +0.0) not)
+ random.safe_frac)
+ subject random.safe_frac]
+ (`` ($_ _.and
+ (~~ (template [</> <lux> <pre>]
+ [(_.cover [</>]
+ (let [expected (<lux> (<pre> parameter) (<pre> subject))]
+ (expression (|>> (:as Frac) (f.= expected))
+ (</> (/.float (<pre> parameter)) (/.float (<pre> subject))))))]
+
+ [/.+ f.+ |>]
+ [/.- f.- |>]
+ [/.* f.* |>]
+ [/./ f./ |>]
+ [/.% f.mod |>]
+ [/.^ math.pow f.abs]
+ ))
+ (~~ (template [</> <lux>]
+ [(_.cover [</>]
+ (let [expected (<lux> parameter subject)]
+ (expression (|>> (:as Bit) (bit#= expected))
+ (</> (/.float parameter) (/.float subject)))))]
+
+ [/.< f.<]
+ [/.<= f.<=]
+ [/.> f.>]
+ [/.>= f.>=]
+ [/.= f.=]
+ ))
+ ))))
+
+(def: test|string
+ Test
+ (do random.monad
+ [left (random.ascii/lower 8)
+ right (random.ascii/lower 8)
+ .let [expected (format left right)]]
+ ($_ _.and
+ (_.cover [/.concat]
+ (expression (|>> (:as Text) (text#= expected))
+ (|> (/.string left)
+ (/.concat (/.string right)))))
+ )))
+
+(def: test|array
+ Test
+ (do [! random.monad]
+ [size (# ! each (|>> (n.% 10) ++) random.nat)
+ index (# ! each (n.% size) random.nat)
+ items (random.list size random.safe_frac)
+ .let [expected (|> items
+ (list.item index)
+ maybe.trusted)]]
+ ($_ _.and
+ (_.cover [/.array /.item]
+ (and (expression (|>> (:as Frac) (f.= expected))
+ (/.item (/.int (.int (++ index)))
+ (/.array (list#each /.float items))))
+ (expression (|>> (:as Bit))
+ (|> (/.array (list#each /.float items))
+ (/.item (/.int (.int (++ size))))
+ (/.= /.nil)))))
+ (_.cover [/.length]
+ (expression (|>> (:as Int) (i.= (.int size)))
+ (/.length (/.array (list#each /.float items)))))
+ )))
+
+(def: test|table
+ Test
+ (do [! random.monad]
+ [expected random.safe_frac
+ dummy (random.only (|>> (f.= expected) not)
+ random.safe_frac)
+
+ size (# ! each (|>> (n.% 10) ++) random.nat)
+ index (# ! each (n.% size) random.nat)
+ items (random.list size random.safe_frac)
+
+ $self (# ! each /.var (random.ascii/lower 10))
+ $table (# ! each /.var (random.ascii/lower 11))
+ $arg (# ! each /.var (random.ascii/lower 12))
+ field (random.ascii/upper 5)
+ non_field (random.only (|>> (text#= field) not)
+ (random.ascii/upper 5))
+ method (random.ascii/upper 6)]
+ ($_ _.and
+ (_.cover [/.table /.the]
+ (and (expression (|>> (:as Frac) (f.= expected))
+ (/.the field (/.table (list [field (/.float expected)]))))
+ (expression (|>> (:as Bit))
+ (|> (/.table (list [field (/.float expected)]))
+ (/.the non_field)
+ (/.= /.nil)))))
+ (_.cover [/.do /.function]
+ (expression (|>> (:as Frac) (f.= expected))
+ (|> ($_ /.then
+ (/.local/1 $table (/.table (list [field (/.float expected)])))
+ (/.function (/.the method $table) (list $self $arg)
+ (/.if (/.= (/.float dummy) $arg)
+ (/.return (/.the field $self))
+ (/.return $arg)))
+ (/.return (/.do method (list (/.float dummy)) $table)))
+ (/.closure (list))
+ (/.apply (list)))))
+ )))
+
+(def: test|computation
+ Test
+ (do [! random.monad]
+ [test random.bit
+ then random.safe_frac
+ else random.safe_frac
+
+ boolean random.bit
+ int random.int
+ float random.frac
+ string (random.ascii/upper 5)
+
+ comment (random.ascii/upper 10)]
+ ($_ _.and
+ ..test|boolean
+ ..test|int
+ ..test|float
+ ..test|string
+ ..test|array
+ ..test|table
+ (_.cover [/.type/1]
+ (and (expression (|>> (:as Text) (text#= "boolean"))
+ (/.type/1 (/.boolean boolean)))
+ (expression (|>> (:as Text) (text#= "number"))
+ (/.type/1 (/.int int)))
+ (expression (|>> (:as Text) (text#= "number"))
+ (/.type/1 (/.float float)))
+ (expression (|>> (:as Text) (text#= "string"))
+ (/.type/1 (/.string string)))
+ (expression (|>> (:as Text) (text#= "nil"))
+ (/.type/1 /.nil))
+ (expression (|>> (:as Text) (text#= "table"))
+ (/.type/1 (/.table (list [string (/.float float)]))))
+ (expression (|>> (:as Text) (text#= "table"))
+ (/.type/1 (/.array (list (/.boolean boolean)
+ (/.float float)
+ (/.string string)))))
+ ))
+ (_.cover [/.require/1]
+ (expression (|>> (:as Int) (i.= (i.abs int)))
+ (|> (/.require/1 (/.string "math"))
+ (/.the "abs")
+ (/.apply (list (/.int int))))))
+ (_.cover [/.comment]
+ (expression (|>> (:as Frac) (f.= then))
+ (/.comment comment
+ (/.float then))))
+ )))
+
+(def: test|expression
+ Test
+ (`` ($_ _.and
+ (_.for [/.Literal]
+ ..test|literal)
+ (_.for [/.Computation]
+ ..test|computation)
+ )))
+
+(def: test/var
+ Test
+ (do [! random.monad]
+ [float/0 random.safe_frac
+ float/1 random.safe_frac
+ float/2 random.safe_frac
+ foreign (random.ascii/lower 10)
+ local (random.only (|>> (text#= foreign) not)
+ (random.ascii/lower 10))
+ .let [$foreign (/.var foreign)
+ $local (/.var local)]]
+ ($_ _.and
+ (_.cover [/.var]
+ (expression (|>> (:as Frac) (f.= float/0))
+ (|> (/.return $foreign)
+ (/.closure (list $foreign))
+ (/.apply (list (/.float float/0))))))
+ (_.cover [/.let]
+ (expression (|>> (:as Frac) (f.= float/1))
+ (|> ($_ /.then
+ (/.let (list $local) (/.float float/1))
+ (/.return $local))
+ (/.closure (list $foreign))
+ (/.apply (list (/.float float/0))))))
+ (_.cover [/.local/1]
+ (expression (|>> (:as Frac) (f.= float/1))
+ (|> ($_ /.then
+ (/.local/1 $local (/.float float/1))
+ (/.return $local))
+ (/.closure (list $foreign))
+ (/.apply (list (/.float float/0))))))
+ (_.cover [/.local]
+ (expression (|>> (:as Frac) (f.= float/1))
+ (|> ($_ /.then
+ (/.local (list $local))
+ (/.set (list $local) (/.float float/1))
+ (/.return $local))
+ (/.closure (list $foreign))
+ (/.apply (list (/.float float/0))))))
+ )))
+
+(def: test/location
+ Test
+ (do [! random.monad]
+ [float/0 random.safe_frac
+ float/1 random.safe_frac
+ int/0 ..int/16
+ $foreign (# ! each /.var (random.ascii/lower 10))
+ $arg/0 (# ! each /.var (random.ascii/lower 11))
+ $arg/1 (# ! each /.var (random.ascii/lower 12))
+ field (random.ascii/upper 10)]
+ ($_ _.and
+ (_.cover [/.set]
+ (expression (|>> (:as Frac) (f.= (f.+ float/0 float/0)))
+ (|> ($_ /.then
+ (/.set (list $foreign) (/.+ $foreign $foreign))
+ (/.return $foreign))
+ (/.closure (list $foreign))
+ (/.apply (list (/.float float/0))))))
+ (_.cover [/.multi]
+ (and (expression (|>> (:as Frac) (f.= float/0))
+ (|> ($_ /.then
+ (/.set (list $arg/0 $arg/1) (/.multi (list (/.float float/0) (/.float float/1))))
+ (/.return $arg/0))
+ (/.closure (list))
+ (/.apply (list))))
+ (expression (|>> (:as Frac) (f.= float/1))
+ (|> ($_ /.then
+ (/.set (list $arg/0 $arg/1) (/.multi (list (/.float float/0) (/.float float/1))))
+ (/.return $arg/1))
+ (/.closure (list))
+ (/.apply (list))))))
+ (_.cover [/.Access]
+ (and (expression (|>> (:as Frac) (f.= (f.+ float/0 float/0)))
+ (let [@ (/.item (/.int +1) $foreign)]
+ (|> ($_ /.then
+ (/.set (list $foreign) (/.array (list $foreign)))
+ (/.set (list @) (/.+ @ @))
+ (/.return @))
+ (/.closure (list $foreign))
+ (/.apply (list (/.float float/0))))))
+ (expression (|>> (:as Frac) (f.= (f.+ float/0 float/0)))
+ (let [@ (/.the field $foreign)]
+ (|> ($_ /.then
+ (/.set (list $foreign) (/.table (list [field $foreign])))
+ (/.set (list @) (/.+ @ @))
+ (/.return @))
+ (/.closure (list $foreign))
+ (/.apply (list (/.float float/0))))))))
+ (_.for [/.Var]
+ ..test/var)
+ )))
+
+(def: test|label
+ Test
+ (do [! random.monad]
+ [input ..int/16
+
+ full_iterations (# ! each (|>> (n.% 20) ++) random.nat)
+ expected_iterations (# ! each (|>> (n.% full_iterations) .int) random.nat)
+
+ $input (# ! each /.var (random.ascii/lower 10))
+ $output (# ! each /.var (random.ascii/lower 11))
+ $index (# ! each /.var (random.ascii/lower 12))
+
+ @loop (# ! each /.label (random.ascii/lower 13))
+
+ .let [expected (i.* expected_iterations input)
+ expected_iterations (/.int expected_iterations)]]
+ ($_ _.and
+ (_.cover [/.break]
+ (let [=for_in (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $output (/.int +0))
+ (/.for_in (list $index $input) (/.ipairs/1 (/.array (list.repeated full_iterations $input)))
+ ($_ /.then
+ (/.when (/.> expected_iterations $index)
+ /.break)
+ (/.set (list $output) (/.+ $input $output))))
+ (/.return $output))
+ (/.closure (list $input))
+ (/.apply (list (/.int input)))))
+
+ full_iterations (/.int (.int full_iterations))
+ =while (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $index (/.int +0))
+ (/.local/1 $output (/.int +0))
+ (/.while (/.< full_iterations $index)
+ ($_ /.then
+ (/.when (/.= expected_iterations $index)
+ /.break)
+ (/.set (list $output) (/.+ $input $output))
+ (/.set (list $index) (/.+ (/.int +1) $index))
+ ))
+ (/.return $output))
+ (/.closure (list $input))
+ (/.apply (list (/.int input)))))
+ =repeat (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $index (/.int +0))
+ (/.local/1 $output (/.int +0))
+ (/.repeat (/.= full_iterations $index)
+ ($_ /.then
+ (/.when (/.= expected_iterations $index)
+ /.break)
+ (/.set (list $output) (/.+ $input $output))
+ (/.set (list $index) (/.+ (/.int +1) $index))
+ ))
+ (/.return $output))
+ (/.closure (list $input))
+ (/.apply (list (/.int input)))))
+ =for_step (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $output (/.int +0))
+ (/.for_step $index (/.int +0) full_iterations (/.int +1)
+ ($_ /.then
+ (/.when (/.= expected_iterations $index)
+ /.break)
+ (/.set (list $output) (/.+ $input $output))))
+ (/.return $output))
+ (/.closure (list $input))
+ (/.apply (list (/.int input)))))]
+ (and =while
+ =repeat
+ =for_step
+ =for_in)))
+ (_.cover [/.label /.set_label /.go_to]
+ (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $index (/.int +0))
+ (/.local/1 $output (/.int +0))
+ (/.set_label @loop)
+ (/.if (/.< expected_iterations $index)
+ ($_ /.then
+ (/.set (list $output) (/.+ $input $output))
+ (/.set (list $index) (/.+ (/.int +1) $index))
+ (/.go_to @loop))
+ (/.return $output)))
+ (/.closure (list $input))
+ (/.apply (list (/.int input))))))
+ )))
+
+(def: test|loop
+ Test
+ (do [! random.monad]
+ [input ..int/16
+ iterations (# ! each (n.% 10) random.nat)
+ .let [$input (/.var "input")
+ $output (/.var "output")
+ $index (/.var "index")
+ expected (i.* (.int iterations) input)]]
+ ($_ _.and
+ (_.cover [/.while]
+ (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $index (/.int +0))
+ (/.local/1 $output (/.int +0))
+ (/.while (/.< (/.int (.int iterations)) $index)
+ ($_ /.then
+ (/.set (list $output) (/.+ $input $output))
+ (/.set (list $index) (/.+ (/.int +1) $index))
+ ))
+ (/.return $output))
+ (/.closure (list $input))
+ (/.apply (list (/.int input))))))
+ (_.cover [/.repeat]
+ (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $index (/.int +0))
+ (/.local/1 $output (/.int +0))
+ (/.repeat (/.= (/.int (.int iterations)) $index)
+ ($_ /.then
+ (/.set (list $output) (/.+ $input $output))
+ (/.set (list $index) (/.+ (/.int +1) $index))
+ ))
+ (/.return $output))
+ (/.closure (list $input))
+ (/.apply (list (/.int input))))))
+ (_.cover [/.for_step]
+ (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $output (/.int +0))
+ (/.for_step $index (/.int +0) (/.int (.int (-- iterations))) (/.int +1)
+ (/.set (list $output) (/.+ $input $output)))
+ (/.return $output))
+ (/.closure (list $input))
+ (/.apply (list (/.int input))))))
+ (_.cover [/.for_in /.ipairs/1]
+ (expression (|>> (:as Int) (i.= expected))
+ (|> ($_ /.then
+ (/.local/1 $output (/.int +0))
+ (/.for_in (list $index $input) (/.ipairs/1 (/.array (list.repeated iterations $input)))
+ (/.set (list $output) (/.+ $input $output)))
+ (/.return $output))
+ (/.closure (list $input))
+ (/.apply (list (/.int input))))))
+ (_.for [/.Label]
+ ..test|label)
+ )))
+
+(def: test|exception
+ Test
+ (do [! random.monad]
+ [expected random.safe_frac
+ dummy (random.only (|>> (f.= expected) not)
+ random.safe_frac)
+ $verdict (# ! each /.var (random.ascii/lower 10))
+ $outcome (# ! each /.var (random.ascii/lower 11))]
+ ($_ _.and
+ (_.cover [/.pcall/1]
+ (expression (|>> (:as Frac) (f.= expected))
+ (|> ($_ /.then
+ (/.let (list $verdict $outcome) (/.pcall/1 (/.closure (list)
+ (/.return (/.float expected)))))
+ (/.if $verdict
+ (/.return $outcome)
+ (/.return (/.float dummy))))
+ (/.closure (list))
+ (/.apply (list)))))
+ (_.cover [/.error/1]
+ (expression (|>> (:as Frac) (f.= expected))
+ (|> ($_ /.then
+ (/.let (list $verdict $outcome) (/.pcall/1 (/.closure (list)
+ ($_ /.then
+ (/.statement (/.error/1 (/.float expected)))
+ (/.return (/.float dummy))))))
+ (/.if $verdict
+ (/.return (/.float dummy))
+ (/.return $outcome)))
+ (/.closure (list))
+ (/.apply (list)))))
+ )))
+
+(def: test|function
+ Test
+ (do [! random.monad]
+ [float/0 random.safe_frac
+ iterations (# ! each (n.% 10) random.nat)
+ $self (# ! each /.var (random.ascii/lower 1))
+ $arg/0 (# ! each /.var (random.ascii/lower 2))
+ field (random.ascii/lower 3)
+ $class (# ! each /.var (random.ascii/upper 4))]
+ ($_ _.and
+ (_.cover [/.closure /.return]
+ (expression (|>> (:as Frac) (f.= float/0))
+ (/.apply (list)
+ (/.closure (list) (/.return (/.float float/0))))))
+ (_.cover [/.local_function]
+ (expression (|>> (:as Int) .nat (n.= iterations))
+ (|> ($_ /.then
+ (/.local_function $self (list $arg/0)
+ (/.if (/.< (/.int (.int iterations)) $arg/0)
+ (/.return (/.apply (list (/.+ (/.int +1) $arg/0)) $self))
+ (/.return $arg/0)))
+ (/.return (/.apply (list (/.int +0)) $self)))
+ (/.closure (list))
+ (/.apply (list)))))
+ (do [! random.monad]
+ [float/0 random.safe_frac
+ float/1 random.safe_frac
+ float/2 random.safe_frac
+ $arg/0 (# ! each /.var (random.ascii/lower 10))
+ $arg/1 (# ! each /.var (random.ascii/lower 11))
+ $arg/2 (# ! each /.var (random.ascii/lower 12))]
+ (`` ($_ _.and
+ (_.cover [/.apply]
+ (expression (|>> (:as Frac) (f.= ($_ f.+ float/0 float/1 float/2)))
+ (/.apply (list (/.float float/0)
+ (/.float float/1)
+ (/.float float/2))
+ (/.closure (list $arg/0 $arg/1 $arg/2) (/.return ($_ /.+ $arg/0 $arg/1 $arg/2))))))
+ )))
+ )))
+
+(def: test|branching
+ Test
+ (do [! random.monad]
+ [float/0 random.safe_frac
+ float/1 random.safe_frac
+ ??? random.bit]
+ ($_ _.and
+ (_.cover [/.if]
+ (expression (|>> (:as Frac) (f.= (if ??? float/0 float/1)))
+ (|> (/.if (/.boolean ???)
+ (/.return (/.float float/0))
+ (/.return (/.float float/1)))
+ (/.closure (list))
+ (/.apply (list)))))
+ (_.cover [/.when]
+ (expression (|>> (:as Frac) (f.= (if ??? float/0 float/1)))
+ (|> ($_ /.then
+ (/.when (/.boolean ???)
+ (/.return (/.float float/0)))
+ (/.return (/.float float/1)))
+ (/.closure (list))
+ (/.apply (list)))))
+ )))
+
+(def: test|binding
+ Test
+ ($_ _.and
+ ..test|function
+ (_.for [/.Location]
+ ..test/location)
+ ))
+
+(def: test|control
+ Test
+ ($_ _.and
+ ..test|branching
+ ..test|loop
+ ..test|exception
+ ))
+
+(def: test|statement
+ Test
+ (do [! random.monad]
+ [float/0 random.safe_frac
+ float/1 random.safe_frac
+ $arg/0 (# ! each /.var (random.ascii/lower 10))
+ $arg/1 (# ! each /.var (random.ascii/lower 11))]
+ (`` ($_ _.and
+ (_.cover [/.statement /.then /.print/1]
+ (expression (|>> (:as Frac) (f.= float/0))
+ (|> ($_ /.then
+ (/.statement (/.print/1 $arg/0))
+ (/.return $arg/0))
+ (/.closure (list $arg/0))
+ (/.apply (list (/.float float/0))))))
+ ..test|binding
+ ..test|control
+ ))))
+
+(def: .public test
+ Test
+ (do [! random.monad]
+ [.let [random (# ! each /.int random.int)]
+ expected random.int]
+ (<| (_.covering /._)
+ (_.for [/.Code /.code])
+ (`` ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence random))
+ (_.for [/.hash]
+ ($hash.spec /.hash random))
+
+ (_.cover [/.manual]
+ (expression (|>> (:as Int) (i.= expected))
+ (/.manual (/.code (/.int expected)))))
+ (_.for [/.Expression]
+ ..test|expression)
+ (_.for [/.Statement]
+ ..test|statement)
+ )))))
diff --git a/stdlib/source/test/lux/target/python.lux b/stdlib/source/test/lux/target/python.lux
index 49d74c1b3..e936ba850 100644
--- a/stdlib/source/test/lux/target/python.lux
+++ b/stdlib/source/test/lux/target/python.lux
@@ -29,25 +29,12 @@
(def: (expression ??? it)
(-> (-> Any Bit) (/.Expression Any) Bit)
- ... (case (|> it /.code ..eval)
- ... {try.#Success it}
- ... (|> it
- ... (maybe#each ???)
- ... (maybe.else false))
-
- ... {try.#Failure error}
- ... (exec
- ... ("lux io log" "try.#Failure")
- ... ("lux io log" error)
- ... ("lux io log" (|> it /.code))
- ... false))
(|> it
/.code
..eval
(try#each (|>> (maybe#each ???)
(maybe.else false)))
- (try.else false))
- )
+ (try.else false)))
(def: test|literal
Test
@@ -64,7 +51,7 @@
(try#each (function (_ it)
(case it
{.#None} true
- {.#Some _} true)))
+ {.#Some _} false)))
(try.else false)))
(_.cover [/.bool]
(expression (|>> (:as Bit) (bit#= bool))
diff --git a/stdlib/source/test/lux/target/ruby.lux b/stdlib/source/test/lux/target/ruby.lux
index 80d4a161f..87e781ebc 100644
--- a/stdlib/source/test/lux/target/ruby.lux
+++ b/stdlib/source/test/lux/target/ruby.lux
@@ -50,7 +50,7 @@
(try#each (function (_ it)
(case it
{.#None} true
- {.#Some _} true)))
+ {.#Some _} false)))
(try.else false)))
(_.cover [/.bool]
(expression (|>> (:as Bit) (bit#= bool))