From 442d1557b879a8a4bd76f441f72a17bfb71cf05f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 17 Jul 2021 22:48:54 -0400 Subject: Now allowing compilers to generate custom-named outputs. --- documentation/bookmark/abstraction.md | 4 ++ documentation/bookmark/arithmetic.md | 11 ++++ documentation/bookmark/browser.md | 1 + documentation/bookmark/combinatory_logic.md | 5 ++ documentation/bookmark/compiler.md | 1 + documentation/bookmark/computational_effect.md | 4 ++ documentation/bookmark/computer_science.md | 7 +++ documentation/bookmark/concurrency.md | 4 ++ documentation/bookmark/concurrency/actor.md | 4 ++ documentation/bookmark/concurrency/security.md | 4 ++ documentation/bookmark/data_science.md | 1 + documentation/bookmark/database.md | 1 + documentation/bookmark/game_programming.md | 1 + .../bookmark/infrastructure/containers.md | 4 ++ documentation/bookmark/integer.md | 4 ++ documentation/bookmark/lazy_evaluation.md | 4 ++ documentation/bookmark/macro.md | 4 ++ documentation/bookmark/optimization.md | 5 ++ .../bookmark/paradigm/logic_programming.md | 8 +++ .../bookmark/paradigm/subjective_programming.md | 4 ++ documentation/bookmark/platform/jvm.md | 1 + documentation/bookmark/public_resource.md | 4 ++ documentation/bookmark/quantum_computing.md | 4 ++ documentation/bookmark/rendering.md | 5 ++ documentation/bookmark/resource_management.md | 5 ++ documentation/bookmark/sorting.md | 5 ++ documentation/bookmark/system.md | 4 ++ .../bookmark/type_theory/dependent_types.md | 1 + documentation/bookmark/type_theory/inference.md | 4 ++ documentation/bookmark/type_theory/unit.md | 1 + documentation/bookmark/unsafe_programming.md | 5 ++ .../bookmark/user_interface/accessibility.md | 1 + lux-js/source/program.lux | 22 +++---- lux-jvm/source/luxc/lang/translation/jvm.lux | 32 ++++++---- .../luxc/lang/translation/jvm/extension/host.lux | 2 +- .../source/luxc/lang/translation/jvm/function.lux | 2 +- .../source/luxc/lang/translation/jvm/runtime.lux | 12 ++-- lux-lua/source/program.lux | 18 +++--- lux-python/source/program.lux | 9 +-- lux-ruby/source/program.lux | 9 +-- .../library/lux/tool/compiler/default/init.lux | 4 +- .../library/lux/tool/compiler/default/platform.lux | 4 +- .../lux/tool/compiler/language/lux/generation.lux | 20 +++---- .../language/lux/phase/extension/directive/lux.lux | 10 ++-- .../language/lux/phase/generation/js/function.lux | 2 +- .../language/lux/phase/generation/js/runtime.lux | 3 +- .../language/lux/phase/generation/jvm/function.lux | 18 +++--- .../language/lux/phase/generation/jvm/runtime.lux | 4 +- .../language/lux/phase/generation/lua/function.lux | 2 +- .../language/lux/phase/generation/lua/loop.lux | 2 +- .../language/lux/phase/generation/lua/runtime.lux | 3 +- .../language/lux/phase/generation/python/case.lux | 2 +- .../lux/phase/generation/python/function.lux | 4 +- .../language/lux/phase/generation/python/loop.lux | 2 +- .../lux/phase/generation/python/runtime.lux | 3 +- .../lux/phase/generation/ruby/function.lux | 2 +- .../language/lux/phase/generation/ruby/runtime.lux | 3 +- .../library/lux/tool/compiler/meta/archive.lux | 2 +- .../lux/tool/compiler/meta/archive/artifact.lux | 34 ++++++----- .../library/lux/tool/compiler/meta/io/archive.lux | 52 +++++++++++------ .../lux/tool/compiler/meta/packager/jvm.lux | 15 +++-- .../lux/tool/compiler/meta/packager/script.lux | 21 +++---- stdlib/source/library/lux/world/shell.lux | 12 ++-- .../program/aedifex/dependency/resolution.lux | 14 +++-- stdlib/source/program/aedifex/pom.lux | 2 +- stdlib/source/test/aedifex/command/build.lux | 68 ++++++++++++++++++++++ stdlib/source/test/aedifex/dependency.lux | 8 ++- stdlib/source/test/aedifex/dependency/status.lux | 14 +++++ stdlib/source/test/aedifex/profile.lux | 25 +++++--- stdlib/source/test/aedifex/repository/identity.lux | 2 +- stdlib/source/test/aedifex/runtime.lux | 7 ++- stdlib/source/test/lux.lux | 37 +++++++++++- 72 files changed, 466 insertions(+), 162 deletions(-) create mode 100644 documentation/bookmark/abstraction.md create mode 100644 documentation/bookmark/arithmetic.md create mode 100644 documentation/bookmark/combinatory_logic.md create mode 100644 documentation/bookmark/computational_effect.md create mode 100644 documentation/bookmark/computer_science.md create mode 100644 documentation/bookmark/concurrency.md create mode 100644 documentation/bookmark/concurrency/actor.md create mode 100644 documentation/bookmark/concurrency/security.md create mode 100644 documentation/bookmark/infrastructure/containers.md create mode 100644 documentation/bookmark/integer.md create mode 100644 documentation/bookmark/lazy_evaluation.md create mode 100644 documentation/bookmark/macro.md create mode 100644 documentation/bookmark/paradigm/subjective_programming.md create mode 100644 documentation/bookmark/public_resource.md create mode 100644 documentation/bookmark/quantum_computing.md create mode 100644 documentation/bookmark/resource_management.md create mode 100644 documentation/bookmark/sorting.md create mode 100644 documentation/bookmark/system.md create mode 100644 documentation/bookmark/type_theory/inference.md create mode 100644 documentation/bookmark/unsafe_programming.md diff --git a/documentation/bookmark/abstraction.md b/documentation/bookmark/abstraction.md new file mode 100644 index 000000000..b66a147b0 --- /dev/null +++ b/documentation/bookmark/abstraction.md @@ -0,0 +1,4 @@ +# Reference + +1. [YOW! Lambda Jam 2017 Conal Elliott - Teaching New Tricks to Old Programs #YOWLambdaJam](https://www.youtube.com/watch?v=vzLK_xE9Zy8) + diff --git a/documentation/bookmark/arithmetic.md b/documentation/bookmark/arithmetic.md new file mode 100644 index 000000000..c58dd4923 --- /dev/null +++ b/documentation/bookmark/arithmetic.md @@ -0,0 +1,11 @@ +# Saturation + +1. [Saturation arithmetic](https://en.wikipedia.org/wiki/Saturation_arithmetic) + +# Interval + +1. [Growing a Language, by Guy Steele](https://www.youtube.com/watch?v=_ahvzDzKdB0&t=2214s) +1. [Yet another alternative to floating-point numbers](https://wordsandbuttons.online/yet_another_alternative_to_floating_point_numbers.html) +1. [Interval arithmetic](https://en.wikipedia.org/wiki/Interval_arithmetic) +1. [How do you compute the midpoint of an interval?](https://hal.archives-ouvertes.fr/file/index/docid/576641/filename/computing-midpoint.pdf) + diff --git a/documentation/bookmark/browser.md b/documentation/bookmark/browser.md index 018b3b7b7..5fc699317 100644 --- a/documentation/bookmark/browser.md +++ b/documentation/bookmark/browser.md @@ -37,6 +37,7 @@ # Reference 1. [Public Suffix List](https://publicsuffix.org/) +1. [Public Suffix List Problems](https://github.com/sleevi/psl-problems) 1. https://www.opera.com/gx 1. https://evertpot.com/tabs-are-the-wrong-abstraction/ 1. http://news.mit.edu/2018/system-patches-private-browsing-0223 diff --git a/documentation/bookmark/combinatory_logic.md b/documentation/bookmark/combinatory_logic.md new file mode 100644 index 000000000..1ded7e08e --- /dev/null +++ b/documentation/bookmark/combinatory_logic.md @@ -0,0 +1,5 @@ +# Reference + +1. [YOW! Lambda Jam 2018 - Edward Kmett - Combinators Revisited](https://www.youtube.com/watch?v=zhj_tUMwTe0) +1. [Combinatory Logic in Programming](https://doc.lagout.org/science/0_Computer%20Science/2_Algorithms/Combinatory%20Logic%20in%20Programming.pdf) + diff --git a/documentation/bookmark/compiler.md b/documentation/bookmark/compiler.md index 390c22c5e..6cb381190 100644 --- a/documentation/bookmark/compiler.md +++ b/documentation/bookmark/compiler.md @@ -1,5 +1,6 @@ # Methodology +1. [Scope herding with delimited continuations](https://blog.moertel.com/posts/2005-09-13-scope-herding-with-delimited-continuations.html) 1. [Compiling with Continuations by Andrew W. Appel](https://www.amazon.com/dp/0521416957) 1. [Collapsing Towers of Interpreters](https://www.cs.purdue.edu/homes/rompf/papers/amin-popl18.pdf) 1. [Miniphases: Compilation using Modular and Efficient Tree Transformations](https://infoscience.epfl.ch/record/228518/files/paper.pdf) diff --git a/documentation/bookmark/computational_effect.md b/documentation/bookmark/computational_effect.md new file mode 100644 index 000000000..d3d75ac09 --- /dev/null +++ b/documentation/bookmark/computational_effect.md @@ -0,0 +1,4 @@ +# Reference + +1. [A Categorical View of Computational Effects](https://www.youtube.com/watch?v=6t6bsWVOIzs) + diff --git a/documentation/bookmark/computer_science.md b/documentation/bookmark/computer_science.md new file mode 100644 index 000000000..273d2300a --- /dev/null +++ b/documentation/bookmark/computer_science.md @@ -0,0 +1,7 @@ +# Reference + +1. [PROGRAM DESIGN BY CALCULATION](http://www4.di.uminho.pt/~jno/ps/pdbc.pdf) +1. [A Short Skinny on Relations & the Algebra of Programming](http://www.philipzucker.com/a-short-skinny-on-relations-towards-the-algebra-of-programming/) +1. [Tensorial logic: A primitive logic of tensor and negation](https://www.irif.fr/~mellies/tensorial-logic.html) +1. [Introduction to Theoretical Computer Science](https://introtcs.org/public/index.html) + diff --git a/documentation/bookmark/concurrency.md b/documentation/bookmark/concurrency.md new file mode 100644 index 000000000..4d82d1c69 --- /dev/null +++ b/documentation/bookmark/concurrency.md @@ -0,0 +1,4 @@ +# Reference + +1. [OneFile - The world's first wait-free Software Transactional Memory](http://concurrencyfreaks.blogspot.com/2019/04/onefile-worlds-first-wait-free-software.html) + diff --git a/documentation/bookmark/concurrency/actor.md b/documentation/bookmark/concurrency/actor.md new file mode 100644 index 000000000..bf6a3b621 --- /dev/null +++ b/documentation/bookmark/concurrency/actor.md @@ -0,0 +1,4 @@ +# Reference + +1. [otplike – Erlang/OTP processes and behaviours for Clojure - Alexey Aristov](https://www.youtube.com/watch?v=nHvRbZZhUDQ) + diff --git a/documentation/bookmark/concurrency/security.md b/documentation/bookmark/concurrency/security.md new file mode 100644 index 000000000..1d48a21d8 --- /dev/null +++ b/documentation/bookmark/concurrency/security.md @@ -0,0 +1,4 @@ +# Reference + +1. [Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control](http://erights.org/talks/thesis/markm-thesis.pdf) + diff --git a/documentation/bookmark/data_science.md b/documentation/bookmark/data_science.md index d505d3178..aecf4e81f 100644 --- a/documentation/bookmark/data_science.md +++ b/documentation/bookmark/data_science.md @@ -1,4 +1,5 @@ # Reference +1. [Exponential smoothing](https://en.wikipedia.org/wiki/Exponential_smoothing) 1. [High Performance Data With Clojure Chris Nuernberger](https://www.youtube.com/watch?v=5mUGu4RlwKE) diff --git a/documentation/bookmark/database.md b/documentation/bookmark/database.md index 5dc141142..2506f07c4 100644 --- a/documentation/bookmark/database.md +++ b/documentation/bookmark/database.md @@ -24,6 +24,7 @@ # Query +1. [Comprehending Ringads](http://lambda-the-ultimate.org/node/5525) 1. [Reasons why SELECT * is bad for SQL performance](https://tanelpoder.com/posts/reasons-why-select-star-is-bad-for-sql-performance/) 1. [A Short Story About SQL’s Biggest Rival](https://www.holistics.io/blog/quel-vs-sql/) 1. https://calcite.apache.org/ diff --git a/documentation/bookmark/game_programming.md b/documentation/bookmark/game_programming.md index 483c9b356..3191e7087 100644 --- a/documentation/bookmark/game_programming.md +++ b/documentation/bookmark/game_programming.md @@ -178,6 +178,7 @@ # Entity Component System (ECS) +1. [Component Graph System](https://github.com/kvark/froggy/wiki/Component-Graph-System) 1. [Why Vanilla ECS Is Not Enough](https://ajmmertens.medium.com/why-vanilla-ecs-is-not-enough-d7ed4e3bebe5) 1. [On DOTS: Entity Component System](https://blogs.unity3d.com/2019/03/08/on-dots-entity-component-system/) 1. http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ diff --git a/documentation/bookmark/infrastructure/containers.md b/documentation/bookmark/infrastructure/containers.md new file mode 100644 index 000000000..46f02845c --- /dev/null +++ b/documentation/bookmark/infrastructure/containers.md @@ -0,0 +1,4 @@ +# Reference + +1. [The Ideal Versus the Real: Revisiting the History of Virtual Machines and Containers](https://arxiv.org/abs/1904.12226) + diff --git a/documentation/bookmark/integer.md b/documentation/bookmark/integer.md new file mode 100644 index 000000000..e6630ed20 --- /dev/null +++ b/documentation/bookmark/integer.md @@ -0,0 +1,4 @@ +# Parsing + +1. [Faster Integer Parsing](https://rust-malaysia.github.io/code/2020/07/11/faster-integer-parsing.html) + diff --git a/documentation/bookmark/lazy_evaluation.md b/documentation/bookmark/lazy_evaluation.md new file mode 100644 index 000000000..e20487b81 --- /dev/null +++ b/documentation/bookmark/lazy_evaluation.md @@ -0,0 +1,4 @@ +# Reference + +1. [Call-by-Need Is Clairvoyant Call-by-Value](http://www.cs.nott.ac.uk/~pszgmh/clairvoyant.pdf) + diff --git a/documentation/bookmark/macro.md b/documentation/bookmark/macro.md new file mode 100644 index 000000000..7a5f6255a --- /dev/null +++ b/documentation/bookmark/macro.md @@ -0,0 +1,4 @@ +# Reference + +1. [Fortifying Macros](https://www2.ccs.neu.edu/racket/pubs/icfp10-cf.pdf) + diff --git a/documentation/bookmark/optimization.md b/documentation/bookmark/optimization.md index fe23c3e2a..e9e6f2109 100644 --- a/documentation/bookmark/optimization.md +++ b/documentation/bookmark/optimization.md @@ -1,3 +1,7 @@ +# Hashing + +1. [Fibonacci Hashing: The Optimization that the World Forgot (or: a Better Alternative to Integer Modulo)](https://probablydance.com/2018/06/16/fibonacci-hashing-the-optimization-that-the-world-forgot-or-a-better-alternative-to-integer-modulo/) + # Arithmetic 1. [Labor of Division (Episode I)](https://ridiculousfish.com/blog/posts/labor-of-division-episode-i.html) @@ -20,6 +24,7 @@ # Reference +1. [Do Low-level Optimizations Matter?](https://cantrip.org/sortfast.html) 1. [Inline caching](https://bernsteinbear.com/blog/inline-caching/) 1. [Weird and Wonderful Division Tricks](https://saml98.github.io/jekyll/update/2020/02/21/weird-division.htmls) 1. [Towards a Domain-Extensible Compiler: Optimizingan Image Processing Pipeline on Mobile CPUs](https://thok.eu/publications/2021/cgo.pdf) diff --git a/documentation/bookmark/paradigm/logic_programming.md b/documentation/bookmark/paradigm/logic_programming.md index d48cd9e27..caf03f67d 100644 --- a/documentation/bookmark/paradigm/logic_programming.md +++ b/documentation/bookmark/paradigm/logic_programming.md @@ -1,3 +1,11 @@ +# Unification + +1. [Functors of the World, Unite!](https://www.youtube.com/watch?v=8k7YH9st_8U) + +# Inspiration + +1. [Next-Paradigm Programming Languages: What Will They Look Like and What Changes Will They Bring?](https://arxiv.org/abs/1905.00402) + # Reference 1. https://book.simply-logical.space/ diff --git a/documentation/bookmark/paradigm/subjective_programming.md b/documentation/bookmark/paradigm/subjective_programming.md new file mode 100644 index 000000000..964571c7e --- /dev/null +++ b/documentation/bookmark/paradigm/subjective_programming.md @@ -0,0 +1,4 @@ +# Reference + +1. [Dancing with Symmetry to Harness the Power of Complexity: Subjective Programming in Context](https://www.infoq.com/presentations/oop-language-context/) + diff --git a/documentation/bookmark/platform/jvm.md b/documentation/bookmark/platform/jvm.md index 7e8969b91..f804b80e2 100644 --- a/documentation/bookmark/platform/jvm.md +++ b/documentation/bookmark/platform/jvm.md @@ -1,5 +1,6 @@ # Reference +1. [String concatenation, redux](https://cl4es.github.io/2019/05/14/String-Concat-Redux.html) 1. [Beware of computation in static initializer](https://pangin.pro/posts/computation-in-static-initializer) 1. [JVM Internals](https://blog.jamesdbloom.com/JVMInternals.html) 1. [JVM Anatomy Quarks](https://shipilev.net/jvm/anatomy-quarks/) diff --git a/documentation/bookmark/public_resource.md b/documentation/bookmark/public_resource.md new file mode 100644 index 000000000..147744b5c --- /dev/null +++ b/documentation/bookmark/public_resource.md @@ -0,0 +1,4 @@ +# Reference + +1. [Public API Lists](https://github.com/public-api-lists/public-api-lists) + diff --git a/documentation/bookmark/quantum_computing.md b/documentation/bookmark/quantum_computing.md new file mode 100644 index 000000000..229c39289 --- /dev/null +++ b/documentation/bookmark/quantum_computing.md @@ -0,0 +1,4 @@ +# Programming Language + +1. [Silq](https://silq.ethz.ch/) + diff --git a/documentation/bookmark/rendering.md b/documentation/bookmark/rendering.md index 7ee38f83d..4222fea4b 100644 --- a/documentation/bookmark/rendering.md +++ b/documentation/bookmark/rendering.md @@ -1,3 +1,8 @@ +# Physically Based Rendering + +1. [Physically Based Rendering](https://www.pbr-book.org/3ed-2018/contents) +1. [Physically Based Rendering in Filament](https://google.github.io/filament/Filament.html) + # Reference 1. [Geometry Types for Graphics Programming](https://www.cs.cornell.edu/~asampson/media/papers/gator-oopsla2020-preprint.pdf) diff --git a/documentation/bookmark/resource_management.md b/documentation/bookmark/resource_management.md new file mode 100644 index 000000000..3b353ccab --- /dev/null +++ b/documentation/bookmark/resource_management.md @@ -0,0 +1,5 @@ +# Reference + +1. [Understanding ResourceT](https://www.fpcomplete.com/blog/2017/06/understanding-resourcet/) +1. [Composable resource management in Scala](https://bszwej.medium.com/composable-resource-management-in-scala-ce902bda48b2) + diff --git a/documentation/bookmark/sorting.md b/documentation/bookmark/sorting.md new file mode 100644 index 000000000..3906a4d3f --- /dev/null +++ b/documentation/bookmark/sorting.md @@ -0,0 +1,5 @@ +# Reference + +1. [discrimination: Fast generic linear-time sorting, joins and container construction.](https://hackage.haskell.org/package/discrimination-0.1) +1. [Radix Sort, Trie Trees, and Maps from Representable Functors](https://chrispenner.ca/posts/representable-discrimination) + diff --git a/documentation/bookmark/system.md b/documentation/bookmark/system.md new file mode 100644 index 000000000..01cd20ef8 --- /dev/null +++ b/documentation/bookmark/system.md @@ -0,0 +1,4 @@ +# Reference + +1. [On system rollback and totalised fields: An algebraic approach to system change](http://markburgess.org/papers/totalfield.pdf) + diff --git a/documentation/bookmark/type_theory/dependent_types.md b/documentation/bookmark/type_theory/dependent_types.md index c46522210..6feb91d99 100644 --- a/documentation/bookmark/type_theory/dependent_types.md +++ b/documentation/bookmark/type_theory/dependent_types.md @@ -5,6 +5,7 @@ # Reference +1. [The Gentle Art of Levitation](http://lambda-the-ultimate.org/node/5526) 1. [Programming up to Congruence](http://www.cs.yale.edu/homes/vilhelm/papers/popl15congruence.pdf) 1. [From Scheme to Dependent Types in 100 lines by Gershom Bazerman (Part 1)](https://vimeo.com/134561872) 1. [From Scheme to Dependent Types in 100 Lines by Gershom Bazerman (Part 2)](https://vimeo.com/135746080) diff --git a/documentation/bookmark/type_theory/inference.md b/documentation/bookmark/type_theory/inference.md new file mode 100644 index 000000000..f5ee9cb07 --- /dev/null +++ b/documentation/bookmark/type_theory/inference.md @@ -0,0 +1,4 @@ +# Reference + +1. [Functors of the World, Unite!](https://www.youtube.com/watch?v=8k7YH9st_8U) + diff --git a/documentation/bookmark/type_theory/unit.md b/documentation/bookmark/type_theory/unit.md index 5f5306117..cf23e396c 100644 --- a/documentation/bookmark/type_theory/unit.md +++ b/documentation/bookmark/type_theory/unit.md @@ -1,4 +1,5 @@ # Reference +1. https://en.wikipedia.org/wiki/Metric_prefix#Metric_units 1. [unittyped: An extendable library for type-safe computations including units.](https://hackage.haskell.org/package/unittyped) diff --git a/documentation/bookmark/unsafe_programming.md b/documentation/bookmark/unsafe_programming.md new file mode 100644 index 000000000..82a6f0e6d --- /dev/null +++ b/documentation/bookmark/unsafe_programming.md @@ -0,0 +1,5 @@ +# Reference + +1. [Pure destination-passing style in Linear Haskell](https://www.tweag.io/blog/2020-11-11-linear-dps/) +1. [Episode 27: I Promise; Trust Me](https://newrustacean.com/show_notes/e027/struct.script) + diff --git a/documentation/bookmark/user_interface/accessibility.md b/documentation/bookmark/user_interface/accessibility.md index 5a0645773..6519470b3 100644 --- a/documentation/bookmark/user_interface/accessibility.md +++ b/documentation/bookmark/user_interface/accessibility.md @@ -1,4 +1,5 @@ # Reference +1. [Detecting Hover-Capable Devices](https://css-irl.info/detecting-hover-capable-devices/) 1. [Nobody talks about the real reason to use Tabs over Spaces](https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/?st=jxuy98ok&sh=8487bdfa) diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index 6163c2dfa..295aba2ce 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -465,9 +465,10 @@ [?output (javax/script/ScriptEngine::eval (_.code input) interpreter)] (wrap []))) - (def: (define! interpreter context input) - (-> javax/script/ScriptEngine Context _.Expression (Try [Text Any _.Statement])) - (let [global (reference.artifact context) + (def: (define! interpreter context custom input) + (-> javax/script/ScriptEngine Context (Maybe Text) _.Expression (Try [Text Any _.Statement])) + (let [global (maybe.default (reference.artifact context) + custom) @global (_.var global)] (do try.monad [#let [definition (_.define @global input)] @@ -488,10 +489,10 @@ (def: (ingest context content) (|> content (\ utf8.codec decode) try.assume (:as _.Statement))) - (def: (re_learn context content) + (def: (re_learn context custom content) (..execute! interpreter content)) - (def: (re_load context content) + (def: (re_load context custom content) (do try.monad [_ (..execute! interpreter content)] (..evaluate! interpreter context (_.var (reference.artifact context)))))))))) @@ -525,9 +526,10 @@ [?output (..eval (_.code input))] (wrap []))) - (def: (define! context input) - (-> Context _.Expression (Try [Text Any _.Statement])) - (let [global (reference.artifact context) + (def: (define! context custom input) + (-> Context (Maybe Text) _.Expression (Try [Text Any _.Statement])) + (let [global (maybe.default (reference.artifact context) + custom) @global (_.var global)] (do try.monad [#let [definition (_.define @global input)] @@ -546,10 +548,10 @@ (def: (ingest context content) (|> content (\ utf8.codec decode) try.assume (:as _.Statement))) - (def: (re_learn context content) + (def: (re_learn context custom content) (..execute! content)) - (def: (re_load context content) + (def: (re_load context custom content) (do try.monad [_ (..execute! content)] (..evaluate! context (_.var (reference.artifact context))))))))) diff --git a/lux-jvm/source/luxc/lang/translation/jvm.lux b/lux-jvm/source/luxc/lang/translation/jvm.lux index 4cd521f9f..0f6ba6744 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm.lux @@ -14,6 +14,7 @@ [data [binary (#+ Binary)] ["." product] + ["." maybe] ["." text ("#@." hash) ["%" format (#+ format)]] [collection @@ -145,11 +146,13 @@ (loader.store class_name class_bytecode library))] (loader.load class_name loader)))) -(def: (define! library loader context valueI) - (-> Library java/lang/ClassLoader generation.Context Inst (Try [Text Any Definition])) +(def: (define! library loader context custom valueI) + (-> Library java/lang/ClassLoader generation.Context (Maybe Text) Inst (Try [Text Any Definition])) (do try.monad [[value definition] (evaluate! library loader context valueI)] - (wrap [(..class_name context) value definition]))) + (wrap [(maybe.default (..class_name context) + custom) + value definition]))) (def: #export host (IO Host) @@ -170,19 +173,26 @@ (def: (ingest context bytecode) [(..class_name context) bytecode]) - (def: (re_learn context [_ bytecode]) + (def: (re_learn context custom [_ bytecode]) (io.run - (loader.store (..class_name context) bytecode library))) + (loader.store (maybe.default (..class_name context) custom) bytecode library))) - (def: (re_load context [_ bytecode]) + (def: (re_load context custom [_ bytecode]) (io.run (do (try.with io.monad) - [#let [class_name (..class_name context)] + [#let [class_name (maybe.default (..class_name context) custom)] _ (loader.store class_name bytecode library) class (loader.load class_name loader)] (\ io.monad wrap (..class_value class_name class)))))))))) -(def: #export $Variant (type.array ..$Value)) -(def: #export $Tuple (type.array ..$Value)) -(def: #export $Runtime (type.class (..class_name [0 0]) (list))) -(def: #export $Function (type.class (..class_name [0 1]) (list))) +(def: #export $Variant + (type.array ..$Value)) + +(def: #export $Tuple + (type.array ..$Value)) + +(def: #export $Runtime + (type.class (..class_name [0 0]) (list))) + +(def: #export $Function + (type.class (..class_name [0 1]) (list))) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux index 69e63ab71..441a415ee 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -1053,7 +1053,7 @@ (..with_anonymous_init class total_environment super_class inputsTI) method_definitions))]] _ (generation.execute! directive) - _ (generation.save! artifact_id directive)] + _ (generation.save! artifact_id #.None directive)] (..anonymous_instance generate archive class total_environment)))])) (def: bundle::class diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux index f524dc097..394b0b7b5 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux @@ -328,7 +328,7 @@ _ (generation.execute! directive) _ (case forced_context #.None - (generation.save! (product.right function_context) directive) + (generation.save! (product.right function_context) #.None directive) (#.Some function_context) (wrap []))] diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux index 20bd9bd9e..e0426f363 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux @@ -339,7 +339,7 @@ 0) (def: translate_runtime - (Operation [artifact.ID Binary]) + (Operation [artifact.ID (Maybe Text) Binary]) (let [runtime_class (..reflection //.$Runtime) bytecode ($d.class #$.V1_6 #$.Public $.finalC runtime_class (list) (type.class "java.lang.Object" (list)) (list) (|>> adt_methods @@ -349,14 +349,14 @@ directive [runtime_class bytecode]] (do phase.monad [_ (generation.execute! directive) - _ (generation.save! ..runtime_id directive)] - (wrap [..runtime_id bytecode])))) + _ (generation.save! ..runtime_id #.None directive)] + (wrap [..runtime_id #.None bytecode])))) (def: function_id 1) (def: translate_function - (Operation [artifact.ID Binary]) + (Operation [artifact.ID (Maybe Text) Binary]) (let [applyI (|> (enum.range n.enum 2 num_apply_variants) (list@map (function (_ arity) ($d.method #$.Public $.noneM apply_method (apply_signature arity) @@ -386,8 +386,8 @@ directive [function_class bytecode]] (do phase.monad [_ (generation.execute! directive) - _ (generation.save! ..function_id directive)] - (wrap [..function_id bytecode])))) + _ (generation.save! ..function_id #.None directive)] + (wrap [..function_id #.None bytecode])))) (def: #export translate (Operation [Registry Output]) diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 6c7719220..0bb73d348 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -561,8 +561,9 @@ (def: execute! run!) - (def: (define! context input) - (let [global (reference.artifact context) + (def: (define! context custom input) + (let [global (maybe.default (reference.artifact context) + custom) @global (_.var global)] (do try.monad [#let [definition (_.set (list @global) input)] @@ -573,10 +574,10 @@ (def: (ingest context content) (|> content (\ utf8.codec decode) try.assume (:as _.Statement))) - (def: (re_learn context content) + (def: (re_learn context custom content) (run! content)) - (def: (re_load context content) + (def: (re_load context custom content) (do try.monad [_ (run! content)] (run! (_.return (_.var (reference.artifact context))))))))])))) @@ -598,8 +599,9 @@ (def: execute! run!) - (def: (define! context input) - (let [global (reference.artifact context) + (def: (define! context custom input) + (let [global (maybe.default (reference.artifact context) + custom) @global (_.var global)] (do try.monad [#let [definition (_.set (list @global) input)] @@ -610,10 +612,10 @@ (def: (ingest context content) (|> content (\ utf8.codec decode) try.assume (:as _.Statement))) - (def: (re_learn context content) + (def: (re_learn context custom content) (run! content)) - (def: (re_load context content) + (def: (re_load context custom content) (do try.monad [_ (run! content)] (run! (_.return (_.var (reference.artifact context))))))))))))}) diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index f00594c99..f7c167368 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -276,8 +276,9 @@ (implementation (def: evaluate! evaluate!) (def: execute! execute!) - (def: (define! context input) - (let [global (reference.artifact context) + (def: (define! context custom input) + (let [global (maybe.default (reference.artifact context) + custom) @global (_.var global)] (do try.monad [#let [definition (_.set (list @global) input)] @@ -291,10 +292,10 @@ try.assume (:as (_.Statement Any)))) - (def: (re_learn context content) + (def: (re_learn context custom content) (execute! content)) - (def: (re_load context content) + (def: (re_load context custom content) (do try.monad [_ (execute! content)] (evaluate! context (_.var (reference.artifact context)))))))))) diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index a221e6529..2e77c85f4 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -623,8 +623,9 @@ (def: execute! run!) - (def: (define! context input) - (let [global (reference.artifact context) + (def: (define! context custom input) + (let [global (maybe.default (reference.artifact context) + custom) @global (_.global global)] (do try.monad [#let [definition (_.set (list @global) input)] @@ -637,10 +638,10 @@ try.assume (:as _.Statement))) - (def: (re_learn context content) + (def: (re_learn context custom content) (run! content)) - (def: (re_load context content) + (def: (re_load context custom content) (do try.monad [_ (run! content)] (run! (_.global (reference.artifact context)))))))))) diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index 172de25e7..3d49eb706 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -258,8 +258,8 @@ (wrap [state (#.Right [descriptor (document.write key analysis_module) - (row\map (function (_ [artifact_id directive]) - [artifact_id (write_directive directive)]) + (row\map (function (_ [artifact_id custom directive]) + [artifact_id custom (write_directive directive)]) final_buffer)])])) (#.Some [source requirements temporary_payload]) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index 9ebf79b7b..bc0e9b3cc 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -98,8 +98,8 @@ (-> Static archive.ID [Descriptor (Document Any) Output] (Promise (Try Any)))) (let [system (get@ #&file_system platform) - write_artifact! (: (-> [artifact.ID Binary] (Action Any)) - (function (_ [artifact_id content]) + write_artifact! (: (-> [artifact.ID (Maybe Text) Binary] (Action Any)) + (function (_ [artifact_id custom content]) (ioW.write system static module_id artifact_id content)))] (do {! ..monad} [_ (ioW.prepare system static module_id) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index 13d36021f..02adbd2bd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -34,7 +34,7 @@ [archive.ID artifact.ID]) (type: #export (Buffer directive) - (Row [artifact.ID directive])) + (Row [artifact.ID (Maybe Text) directive])) (exception: #export (cannot_interpret {error Text}) (exception.report @@ -54,14 +54,14 @@ evaluate!) (: (-> directive (Try Any)) execute!) - (: (-> Context expression (Try [Text Any directive])) + (: (-> Context (Maybe Text) expression (Try [Text Any directive])) define!) (: (-> Context Binary directive) ingest) - (: (-> Context directive (Try Any)) + (: (-> Context (Maybe Text) directive (Try Any)) re_learn) - (: (-> Context directive (Try Any)) + (: (-> Context (Maybe Text) directive (Try Any)) re_load)) (type: #export (State anchor expression directive) @@ -210,20 +210,20 @@ (#try.Failure error) (exception.throw ..cannot_interpret error)))) -(def: #export (define! context code) +(def: #export (define! context custom code) (All [anchor expression directive] - (-> Context expression (Operation anchor expression directive [Text Any directive]))) + (-> Context (Maybe Text) expression (Operation anchor expression directive [Text Any directive]))) (function (_ (^@ stateE [bundle state])) - (case (\ (get@ #host state) define! context code) + (case (\ (get@ #host state) define! context custom code) (#try.Success output) (#try.Success [stateE output]) (#try.Failure error) (exception.throw ..cannot_interpret error)))) -(def: #export (save! artifact_id code) +(def: #export (save! artifact_id custom code) (All [anchor expression directive] - (-> artifact.ID directive (Operation anchor expression directive Any))) + (-> artifact.ID (Maybe Text) directive (Operation anchor expression directive Any))) (do {! phase.monad} [?buffer (extension.read (get@ #buffer))] (case ?buffer @@ -231,7 +231,7 @@ ## TODO: Optimize by no longer checking for overwrites... (if (row.any? (|>> product.left (n.= artifact_id)) buffer) (phase.throw ..cannot_overwrite_output [artifact_id]) - (extension.update (set@ #buffer (#.Some (row.add [artifact_id code] buffer))))) + (extension.update (set@ #buffer (#.Some (row.add [artifact_id custom code] buffer))))) #.None (phase.throw ..no_buffer_for_saving_code [artifact_id])))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index dc8272030..8fd5d2416 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -114,8 +114,8 @@ [codeG (generate archive codeS) id (/////generation.learn name) module_id (phase.lift (archive.id module archive)) - [target_name value directive] (/////generation.define! [module_id id] codeG) - _ (/////generation.save! id directive)] + [target_name value directive] (/////generation.define! [module_id id] #.None codeG) + _ (/////generation.save! id #.None directive)] (wrap [code//type codeG value])))) (def: (definition archive name expected codeC) @@ -166,8 +166,8 @@ [codeG (generate archive codeS) module_id (phase.lift (archive.id current_module archive)) id ( extension) - [target_name value directive] (/////generation.define! [module_id id] codeG) - _ (/////generation.save! id directive)] + [target_name value directive] (/////generation.define! [module_id id] #.None codeG) + _ (/////generation.save! id #.None directive)] (wrap [codeG value]))))) (def: #export ( archive extension codeT codeC) @@ -393,7 +393,7 @@ (do phase.monad [programG (generate archive programS) artifact_id (/////generation.learn /////program.name)] - (/////generation.save! artifact_id (program [module_id artifact_id] programG)))) + (/////generation.save! artifact_id #.None (program [module_id artifact_id] programG)))) (def: (def::program program) (All [anchor expression directive] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux index df13919b0..0f2d9adf6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux @@ -119,5 +119,5 @@ @self)))))))) ))] _ (/////generation.execute! definition) - _ (/////generation.save! (product.right function_name) definition)] + _ (/////generation.save! (product.right function_name) #.None definition)] (wrap instantiation))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 2f6370418..65783662a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -775,11 +775,12 @@ (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id ..runtime)] + _ (/////generation.save! ..module_id #.None ..runtime)] (wrap [(|> artifact.empty artifact.resource product.right) (row.row [..module_id + #.None (|> ..runtime _.code (\ utf8.codec encode))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux index 37cda09e1..42d9cf2a4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux @@ -87,7 +87,7 @@ class.public class.final)) -(def: this-offset 1) +(def: this_offset 1) (def: internal (All [category] @@ -98,22 +98,22 @@ (def: #export (abstraction generate archive [environment arity bodyS]) (Generator Abstraction) (do phase.monad - [@begin //runtime.forge-label - [function-context bodyG] (generation.with-new-context archive - (generation.with-anchor [@begin ..this-offset] + [@begin //runtime.forge_label + [function_context bodyG] (generation.with_new_context archive + (generation.with_anchor [@begin ..this_offset] (generate archive bodyS))) - #let [function-class (//runtime.class-name function-context)] - [fields methods instance] (..with generate archive @begin function-class environment arity bodyG) + #let [function_class (//runtime.class_name function_context)] + [fields methods instance] (..with generate archive @begin function_class environment arity bodyG) class (phase.lift (class.class version.v6_0 ..modifier - (name.internal function-class) + (name.internal function_class) (..internal /abstract.class) (list) fields methods (row.row))) #let [bytecode (format.run class.writer class)] - _ (generation.execute! [function-class bytecode]) - _ (generation.save! function-class [function-class bytecode])] + _ (generation.execute! [function_class bytecode]) + _ (generation.save! function_class #.None [function_class bytecode])] (wrap instance))) (def: #export (apply generate archive [abstractionS inputsS]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index e445ec2d4..edfa6d78d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -537,7 +537,7 @@ (row.row)))] (do ////.monad [_ (generation.execute! [class bytecode])] - (generation.save! ..artifact_id [class bytecode])))) + (generation.save! ..artifact_id #.None [class bytecode])))) (def: generate_function (Operation Any) @@ -594,7 +594,7 @@ (row.row)))] (do ////.monad [_ (generation.execute! [class bytecode])] - (generation.save! //function.artifact_id [class bytecode])))) + (generation.save! //function.artifact_id #.None [class bytecode])))) (def: #export generate (Operation Any) 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 97a5b1691..789d30fcc 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 @@ -133,5 +133,5 @@ (_.apply/1 @self)))))))) ))] _ (/////generation.execute! definition) - _ (/////generation.save! (product.right function_name) definition)] + _ (/////generation.save! (product.right function_name) #.None definition)] (wrap instantiation))) 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 a6719856c..18b65c352 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,7 +108,7 @@ )) (|> @context (_.apply/* foreigns))])))] _ (/////generation.execute! directive) - _ (/////generation.save! artifact_id directive)] + _ (/////generation.save! artifact_id #.None directive)] (wrap (|> instantiation (_.apply/* initsO+)))))) (def: #export (recur! statement expression archive argsS+) 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 a0266db38..8f1e5b117 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 @@ -422,11 +422,12 @@ (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id ..runtime)] + _ (/////generation.save! ..module_id #.None ..runtime)] (wrap [(|> artifact.empty artifact.resource product.right) (row.row [..module_id + #.None (|> ..runtime _.code (\ utf8.codec encode))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index a4e5e81fc..3a776a2a7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -330,5 +330,5 @@ directive (_.def @case @dependencies+ pattern_matching!)] _ (/////generation.execute! directive) - _ (/////generation.save! case_artifact directive)] + _ (/////generation.save! case_artifact #.None directive)] (wrap (_.apply/* @case @dependencies+)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux index ca18fb0ef..d2e70def2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux @@ -48,7 +48,7 @@ #.Nil (do ///////phase.monad [_ (/////generation.execute! function_definition) - _ (/////generation.save! function_id function_definition)] + _ (/////generation.save! function_id #.None function_definition)] (wrap @function)) _ @@ -60,7 +60,7 @@ function_definition (_.return @function)))] _ (/////generation.execute! directive) - _ (/////generation.save! function_id directive)] + _ (/////generation.save! function_id #.None directive)] (wrap (_.apply/* @function inits))))) (def: input diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux index 353c890f9..4ec21d754 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux @@ -103,7 +103,7 @@ )) (_.apply/* @loop foreigns)]))] _ (/////generation.execute! directive) - _ (/////generation.save! loop_artifact directive)] + _ (/////generation.save! loop_artifact #.None directive)] (wrap (_.apply/* instantiation initsO+))))) (def: #export (recur! statement expression archive argsS+) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index 7a19539df..34009976f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -450,11 +450,12 @@ (/////generation.with_buffer (do ///////phase.monad [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id ..runtime)] + _ (/////generation.save! ..module_id #.None ..runtime)] (wrap [(|> artifact.empty artifact.resource product.right) (row.row [..module_id + #.None (|> ..runtime _.code (\ utf8.codec encode))])])))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux index af7906c9c..c24efad81 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux @@ -108,5 +108,5 @@ (_.do "concat" (list @missing)))))))))))) )))] _ (/////generation.execute! declaration) - _ (/////generation.save! function_artifact declaration)] + _ (/////generation.save! function_artifact #.None declaration)] (wrap instatiation))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index 2ce60a9a1..3e8e09d8c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -393,11 +393,12 @@ (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id ..runtime)] + _ (/////generation.save! ..module_id #.None ..runtime)] (wrap [(|> artifact.empty artifact.resource product.right) (row.row [..module_id + #.None (|> ..runtime _.code (\ utf8.codec encode))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index 735e315c5..39beec921 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -39,7 +39,7 @@ [version (#+ Version)]]]) (type: #export Output - (Row [artifact.ID Binary])) + (Row [artifact.ID (Maybe Text) Binary])) (exception: #export (unknown_document {module Module} {known_modules (List Module)}) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index 33e09e51a..2c6deeb27 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -7,7 +7,7 @@ [pipe (#+ case>)] ["." exception (#+ exception:)] ["<>" parser - ["" binary (#+ Parser)]]] + ["<.>" binary (#+ Parser)]]] [data ["." product] ["." text @@ -30,7 +30,8 @@ (#Analyser Text) (#Synthesizer Text) (#Generator Text) - (#Directive Text)) + (#Directive Text) + (#Custom Text)) (type: #export Artifact {#id ID @@ -90,6 +91,7 @@ [#Synthesizer synthesizer synthesizers] [#Generator generator generators] [#Directive directive directives] + [#Custom custom customs] ) (def: #export (remember name registry) @@ -109,8 +111,9 @@ [1 #Definition binary.text] [2 #Analyser binary.text] [3 #Synthesizer binary.text] - [4 #Generator binary.text] - [5 #Directive binary.text])))) + [4 #Generator binary.text] + [5 #Directive binary.text] + [6 #Custom binary.text])))) artifacts (: (Writer (Row Category)) (binary.row/64 category))] (|>> :representation @@ -126,16 +129,20 @@ (Parser Registry) (let [category (: (Parser Category) (do {! <>.monad} - [tag .nat] + [tag .nat] (case tag - 0 (\ ! map (|>> #Anonymous) .any) - 1 (\ ! map (|>> #Definition) .text) - 2 (\ ! map (|>> #Analyser) .text) - 3 (\ ! map (|>> #Synthesizer) .text) - 4 (\ ! map (|>> #Generator) .text) - 5 (\ ! map (|>> #Directive) .text) + (^template [ ] + [ (\ ! map (|>> ) )]) + ([0 #Anonymous .any] + [1 #Definition .text] + [2 #Analyser .text] + [3 #Synthesizer .text] + [4 #Generator .text] + [5 #Directive .text] + [6 #Custom .text]) + _ (<>.fail (exception.construct ..invalid_category [tag])))))] - (|> (.row/64 category) + (|> (.row/64 category) (\ <>.monad map (row\fold (function (_ artifact registry) (product.right (case artifact @@ -149,7 +156,8 @@ [#Analyser ..analyser] [#Synthesizer ..synthesizer] [#Generator ..generator] - [#Directive ..directive]) + [#Directive ..directive] + [#Custom ..custom]) ))) ..empty))))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index 0b7a54a34..cd7b7169a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -227,12 +227,12 @@ (case (do ! [data (try.from_maybe (dictionary.get (format (%.nat artifact_id) extension) actual)) #let [context [module_id artifact_id] - directive (\ host ingest context data) - output (row.add [artifact_id data] output)]] + directive (\ host ingest context data)]] (case artifact_category #artifact.Anonymous (do ! - [_ (\ host re_learn context directive)] + [#let [output (row.add [artifact_id #.None data] output)] + _ (\ host re_learn context #.None directive)] (wrap [definitions [analysers synthesizers @@ -241,25 +241,27 @@ output])) (#artifact.Definition name) - (if (text\= $/program.name name) - (wrap [definitions - [analysers - synthesizers - generators - directives] - output]) - (do ! - [value (\ host re_load context directive)] - (wrap [(dictionary.put name value definitions) + (let [output (row.add [artifact_id #.None data] output)] + (if (text\= $/program.name name) + (wrap [definitions [analysers synthesizers generators directives] - output]))) + output]) + (do ! + [value (\ host re_load context #.None directive)] + (wrap [(dictionary.put name value definitions) + [analysers + synthesizers + generators + directives] + output])))) (#artifact.Analyser extension) (do ! - [value (\ host re_load context directive)] + [#let [output (row.add [artifact_id #.None data] output)] + value (\ host re_load context #.None directive)] (wrap [definitions [(dictionary.put extension (:as analysis.Handler value) analysers) synthesizers @@ -269,7 +271,8 @@ (#artifact.Synthesizer extension) (do ! - [value (\ host re_load context directive)] + [#let [output (row.add [artifact_id #.None data] output)] + value (\ host re_load context #.None directive)] (wrap [definitions [analysers (dictionary.put extension (:as synthesis.Handler value) synthesizers) @@ -279,7 +282,8 @@ (#artifact.Generator extension) (do ! - [value (\ host re_load context directive)] + [#let [output (row.add [artifact_id #.None data] output)] + value (\ host re_load context #.None directive)] (wrap [definitions [analysers synthesizers @@ -289,12 +293,24 @@ (#artifact.Directive extension) (do ! - [value (\ host re_load context directive)] + [#let [output (row.add [artifact_id #.None data] output)] + value (\ host re_load context #.None directive)] (wrap [definitions [analysers synthesizers generators (dictionary.put extension (:as directive.Handler value) directives)] + output])) + + (#artifact.Custom name) + (do ! + [#let [output (row.add [artifact_id (#.Some name) data] output)] + value (\ host re_load context (#.Some name) directive)] + (wrap [definitions + [analysers + synthesizers + generators + directives] output])))) (#try.Success [definitions' bundles' output']) (recur input' definitions' bundles' output') diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index f5366ab8e..7e79903d5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -11,6 +11,7 @@ ["." promise (#+ Promise)]]] [data ["." binary (#+ Binary)] + ["." maybe ("#\." functor)] ["." text ["%" format (#+ format)]] [collection @@ -109,11 +110,13 @@ (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version)) manifest))) -(def: (write_class static module artifact content sink) - (-> Static archive.ID artifact.ID Binary java/util/jar/JarOutputStream +(def: (write_class static module artifact custom content sink) + (-> Static archive.ID artifact.ID (Maybe Text) Binary java/util/jar/JarOutputStream java/util/jar/JarOutputStream) - (let [class_path (format (runtime.class_name [module artifact]) - (get@ #static.artifact_extension static))] + (let [class_path (|> custom + (maybe\map (|>> name.internal name.read)) + (maybe.default (runtime.class_name [module artifact])) + (text.suffix (get@ #static.artifact_extension static)))] (do_to sink (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path)) (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content))) @@ -123,8 +126,8 @@ (def: (write_module static [module output] sink) (-> Static [archive.ID Output] java/util/jar/JarOutputStream java/util/jar/JarOutputStream) - (row\fold (function (_ [artifact content] sink) - (..write_class static module artifact content sink)) + (row\fold (function (_ [artifact custom content] sink) + (..write_class static module artifact custom content sink)) sink output)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux index ac2b5758c..36b1db690 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux @@ -33,30 +33,25 @@ ["$" lux [generation (#+ Context)]]]]]]) -## TODO: Delete ASAP -(type: (Action ! a) - (! (Try a))) - (def: (write_module sequence [module output] so_far) (All [directive] (-> (-> directive directive directive) [archive.ID Output] directive (Try directive))) (|> output row.to_list - (list\map product.right) + (list\map (|>> product.right product.right)) (monad.fold try.monad (function (_ content so_far) (|> content (\ utf8.codec decode) (\ try.monad map - (function (_ content) - (sequence so_far - (:share [directive] - directive - so_far - - directive - (:assume content))))))) + (|>> :assume + (:share [directive] + directive + so_far + + directive) + (sequence so_far))))) so_far))) (def: #export (package header to_code sequence scope) diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index 52cd3efd4..ddfacbc5e 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -318,8 +318,8 @@ (: (-> s (Try [s Exit])) on_await)) -(`` (implementation: (mock_process mock state) - (All [s] (-> (Mock s) (Atom s) (Process IO))) +(`` (implementation: (mock_process state mock) + (All [s] (-> (Atom s) (Mock s) (Process IO))) (~~ (template [ ] [(def: ( _) @@ -368,7 +368,7 @@ s (Shell IO))) - (def: (execute input) - (io.io (do try.monad - [mock (mock input)] - (wrap (..mock_process mock (atom.atom init))))))) + (def: execute + (|>> mock + (\ try.monad map (..mock_process (atom.atom init))) + io.io))) diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index 15a32959b..1e0c522b9 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -234,12 +234,14 @@ ///package.dependencies (try\map set.to_list) (try.default (list))) - sub_repositories (|> package - ///package.repositories - (try\map set.to_list) - (try.default (list)) - (list\map new_repository) - (list\compose repositories))] + ## For security reasons, it's not a good idea to allow dependencies to introduce repositories. + ## package_repositories (|> package + ## ///package.repositories + ## (try\map set.to_list) + ## (try.default (list)) + ## (list\map new_repository)) + ## sub_repositories (list\compose repositories package_repositories) + sub_repositories repositories] [successes failures resolution] (recur sub_repositories (#.Cons head successes) failures diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index 8f1dae1ea..c5756ee97 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -8,7 +8,7 @@ ["." try (#+ Try)] ["." exception] ["<>" parser - ["" xml (#+ Parser)]]] + ["<.>" xml (#+ Parser)]]] [data ["." name] ["." maybe ("#\." functor)] diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 1292c232f..4b0960d32 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -5,6 +5,7 @@ [abstract [monad (#+ do)]] [control + [pipe (#+ case>)] [io (#+ IO)] ["." try] ["." exception] @@ -72,6 +73,38 @@ (def: (on_await state) (#try.Success [state shell.error])))))))) +(def: #export (reader_shell error?) + (-> Bit (-> (List Text) (Shell IO))) + (shell.mock + (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) + (#try.Success + (: (shell.Mock (List Text)) + (implementation + (def: (on_read state) + (if error? + (exception.throw shell.no_more_output []) + (case state + (#.Cons head tail) + (#try.Success [tail head]) + + #.Nil + (exception.throw shell.no_more_output [])))) + (def: (on_error state) + (if error? + (case state + (#.Cons head tail) + (#try.Success [tail head]) + + #.Nil + (exception.throw shell.no_more_output [])) + (exception.throw shell.no_more_output []))) + (def: (on_write input state) + (#try.Failure "on_write")) + (def: (on_destroy state) + (#try.Failure "on_destroy")) + (def: (on_await state) + (#try.Success [state shell.error])))))))) + (def: compiler (Random Dependency) (do random.monad @@ -181,4 +214,39 @@ (text\= /.failure end))))] (_.cover' [/.failure] (try.default false verdict))))) + (do ! + [expected/0 (random.ascii/alpha 5) + expected/1 (random.ascii/alpha 5) + expected/2 (random.ascii/alpha 5)] + (`` ($_ _.and + (~~ (template [ ] + [(let [console (@version.echo "") + shell (|> (list expected/0 expected/1 expected/2) + (..reader_shell ) + shell.async)] + (wrap (do {! promise.monad} + [verdict (do ///action.monad + [process (shell [environment.empty working_directory "" (list "")]) + _ ( console process) + actual/0 (\ console read_line []) + actual/1 (\ console read_line []) + actual/2 (\ console read_line []) + end! (|> (\ console read_line []) + (\ ! map (|>> (case> (#try.Failure error) + true + + (#try.Success _) + false) + #try.Success)))] + (wrap (and (text\= expected/0 actual/0) + (text\= expected/1 actual/1) + (text\= expected/2 actual/2) + end!)))] + (_.cover' [] + (try.default false verdict)))))] + + [#0 /.log_output!] + [#1 /.log_error!] + )) + ))) )))) diff --git a/stdlib/source/test/aedifex/dependency.lux b/stdlib/source/test/aedifex/dependency.lux index 7ce95f716..733e15710 100644 --- a/stdlib/source/test/aedifex/dependency.lux +++ b/stdlib/source/test/aedifex/dependency.lux @@ -5,7 +5,9 @@ [abstract [monad (#+ do)] [\\specification - ["$." equivalence]]] + ["$." equivalence] + ["$." order] + ["$." hash]]] [math ["." random (#+ Random)]]]] [// @@ -26,4 +28,8 @@ ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) + (_.for [/.order] + ($order.spec /.order ..random)) + (_.for [/.hash] + ($hash.spec /.hash ..random)) )))) diff --git a/stdlib/source/test/aedifex/dependency/status.lux b/stdlib/source/test/aedifex/dependency/status.lux index f886c031f..64bb2f642 100644 --- a/stdlib/source/test/aedifex/dependency/status.lux +++ b/stdlib/source/test/aedifex/dependency/status.lux @@ -3,8 +3,12 @@ [lux #* ["_" test (#+ Test)] [abstract + [monad (#+ do)] [\\specification ["$." equivalence]]] + [data + ["." binary #_ + ["#T" \\test]]] [math ["." random (#+ Random) ("#\." monad)]]]] ["$." /// #_ @@ -31,4 +35,14 @@ ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) + + (do random.monad + [payload (binaryT.random 1)] + (_.cover [/.verified] + (case (/.verified payload) + (#/.Verified sha1 md5) + true + + _ + false))) )))) diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index c593f1706..7163ac780 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -14,7 +14,7 @@ [parser ["." cli]]] [data - ["." text] + ["." text ("#\." equivalence)] [collection ["." set (#+ Set)] ["." dictionary (#+ Dictionary)]]] @@ -144,9 +144,20 @@ (_.for [/.Distribution /.License /.SCM /.Organization /.Email /.Developer /.Contributor /.Info /.Source /.Target /.Name /.Profile] - ($_ _.and - (_.for [/.equivalence] - ($equivalence.spec /.equivalence ..random)) - (_.for [/.monoid] - ($monoid.spec /.equivalence /.monoid ..random)) - )))) + (`` ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.monoid] + ($monoid.spec /.equivalence /.monoid ..random)) + + (_.cover [/.default] + (text\= "" /.default)) + (_.cover [/.default_compiler] + (|> (\ /.monoid identity) + (get@ #/.compiler) + (is? /.default_compiler))) + (_.cover [/.default_target] + (|> (\ /.monoid identity) + (get@ #/.target) + (is? /.default_target))) + ))))) diff --git a/stdlib/source/test/aedifex/repository/identity.lux b/stdlib/source/test/aedifex/repository/identity.lux index 74daecb4d..e19acde36 100644 --- a/stdlib/source/test/aedifex/repository/identity.lux +++ b/stdlib/source/test/aedifex/repository/identity.lux @@ -20,7 +20,7 @@ (def: #export test Test (<| (_.covering /._) - (_.for [/.Identity] + (_.for [/.User /.Password /.Identity] ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index 24745da4a..7d6d3f98b 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -3,7 +3,9 @@ [lux #* ["_" test (#+ Test)] [abstract - [monad (#+ do)]] + [monad (#+ do)] + [\\specification + ["$." equivalence]]] [data ["." maybe ("#\." functor)] ["." text ("#\." equivalence)] @@ -35,6 +37,9 @@ [path (random.ascii/alpha 5) runtime ..random] (`` ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (~~ (template [] [(_.cover [/.default_java /.default_js /.default_python /.default_lua /.default_ruby] (let [listing (|> (list /.default_java /.default_js /.default_python /.default_lua /.default_ruby) diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 26924ef8e..1e9976f4e 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -19,7 +19,9 @@ [data ["." bit ("#\." equivalence)] ["." text ("#\." equivalence) - ["%" format (#+ format)]]] + ["%" format (#+ format)]] + [collection + ["." list]]] [macro ["." code ("#\." equivalence)]] ["." math @@ -553,6 +555,38 @@ (n.= (n.* (inc expected_left) (dec expected_right)) (actual expected_left expected_right)))))) +(/.template: (!n/+ ) + (n.+ )) + +(def: for_template + Test + (`` ($_ _.and + (_.cover [/.template] + (let [bits (list (~~ (/.template [_] + [true] + + [0] [1] [2] + )))] + (and (n.= 3 (list.size bits)) + (list.every? (bit\= true) bits)))) + (do random.monad + [left random.nat + right random.nat] + (_.cover [/.template:] + (n.= (n.+ left right) + (!n/+ left right)))) + (do {! random.monad} + [sample (\ ! map (n.% 5) random.nat)] + (_.cover [/.^template] + (case sample + (/.^template [] + [ true]) + ([0] [1] [2] [3] [4]) + + _ + false))) + ))) + (def: test Test (<| (_.covering /._) @@ -577,6 +611,7 @@ ..for_type ..for_i64 ..for_function + ..for_template ..sub_tests ))) -- cgit v1.2.3