aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2022-11-18 20:56:49 -0400
committerEduardo Julian2022-11-18 20:56:49 -0400
commit6aa4fac0c97264a2b1186063c062ae0873582f54 (patch)
treeb34540d9688ccef495a2c29eec3c7ff30d5e7f16
parent4ea7563c46a07dbe1cb84547a60e9398144917ae (diff)
Updated the Python compiler to work with the new format for extensions.
Diffstat (limited to '')
-rw-r--r--documentation/bookmark/architecture/message_queue.md4
-rw-r--r--documentation/bookmark/business/decision_making.md2
-rw-r--r--documentation/bookmark/business/growth/activation_rate.md4
-rw-r--r--documentation/bookmark/business/onboarding.md4
-rw-r--r--documentation/bookmark/ecology.md2
-rw-r--r--documentation/bookmark/learning.md4
-rw-r--r--documentation/bookmark/logging.md1
-rw-r--r--documentation/bookmark/math/geometry/differential.md1
-rw-r--r--documentation/bookmark/procedural_generation/art.md1
-rw-r--r--documentation/bookmark/research/zettelkasten.md4
-rw-r--r--documentation/bookmark/security.md2
-rw-r--r--documentation/bookmark/security/one_time_program.md4
-rw-r--r--documentation/bookmark/testing/web.md4
-rw-r--r--documentation/bookmark/user_interface/a11y__accessibility.md2
-rw-r--r--documentation/bookmark/user_interface/color.md7
-rw-r--r--documentation/bookmark/user_interface/color/lch.md4
-rw-r--r--lux-python/source/program.lux32
-rw-r--r--stdlib/source/library/lux/data/text.lux6
-rw-r--r--stdlib/source/library/lux/data/text/encoding/utf8.lux4
-rw-r--r--stdlib/source/library/lux/debug.lux12
-rw-r--r--stdlib/source/library/lux/ffi.lux82
-rw-r--r--stdlib/source/library/lux/math/number/frac.lux4
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux12
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux166
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux3
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux233
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux117
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux75
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux2
-rw-r--r--stdlib/source/library/lux/world/time/instant.lux4
-rw-r--r--stdlib/source/test/lux/meta/target/python.lux2
-rw-r--r--stdlib/source/unsafe/lux/data/binary.lux8
-rw-r--r--stdlib/source/unsafe/lux/data/collection/array.lux12
36 files changed, 454 insertions, 376 deletions
diff --git a/documentation/bookmark/architecture/message_queue.md b/documentation/bookmark/architecture/message_queue.md
new file mode 100644
index 000000000..a5073266a
--- /dev/null
+++ b/documentation/bookmark/architecture/message_queue.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Delivering billions of messages exactly once](https://segment.com/blog/exactly-once-delivery/)
+
diff --git a/documentation/bookmark/business/decision_making.md b/documentation/bookmark/business/decision_making.md
index 7cf45b579..a76d77044 100644
--- a/documentation/bookmark/business/decision_making.md
+++ b/documentation/bookmark/business/decision_making.md
@@ -1,6 +1,6 @@
# Reference
-0. []()
+0. [Why Developing Negative Capability is Critical in Leadership](https://www.leadingsapiens.com/developing-negative-capability-leadership/)
0. [We are not Adults Just Because We Say So](http://misc-stuff.terraaeon.com/articles/adults.html)
0. [Tools for better thinking](https://untools.co/)
0. [Multi-Factor Decision Making Math](https://criticalfallibilism.com/multi-factor-decision-making-math/)
diff --git a/documentation/bookmark/business/growth/activation_rate.md b/documentation/bookmark/business/growth/activation_rate.md
new file mode 100644
index 000000000..1e6ce6acf
--- /dev/null
+++ b/documentation/bookmark/business/growth/activation_rate.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [What is a good activation rate](https://www.lennysnewsletter.com/p/what-is-a-good-activation-rate)
+
diff --git a/documentation/bookmark/business/onboarding.md b/documentation/bookmark/business/onboarding.md
new file mode 100644
index 000000000..7c30031ec
--- /dev/null
+++ b/documentation/bookmark/business/onboarding.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Effective onboarding at a new job](https://sherlock.codes/blog/effective-onboarding-at-a-new-job/)
+
diff --git a/documentation/bookmark/ecology.md b/documentation/bookmark/ecology.md
index cefb4d1ce..c817322a9 100644
--- a/documentation/bookmark/ecology.md
+++ b/documentation/bookmark/ecology.md
@@ -1,5 +1,5 @@
# Reference
-0. []()
+0. [Sonali Bag](https://en.wikipedia.org/wiki/Sonali_Bag)
0. [CO2.js: An Open Library for Digital Carbon Reporting](https://branch.climateaction.tech/issues/issue-4/co2js/)
diff --git a/documentation/bookmark/learning.md b/documentation/bookmark/learning.md
new file mode 100644
index 000000000..db109b731
--- /dev/null
+++ b/documentation/bookmark/learning.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Variability, Not Repetition, is the Key to Mastery](https://www.scotthyoung.com/blog/2022/10/26/variable-mastery/)
+
diff --git a/documentation/bookmark/logging.md b/documentation/bookmark/logging.md
index f065e5540..667c99c2d 100644
--- a/documentation/bookmark/logging.md
+++ b/documentation/bookmark/logging.md
@@ -1,5 +1,6 @@
# Reference
+0. [High-Level Event Mining: A Framework](https://arxiv.org/abs/2211.00006)
0. [Better Java logging, inspired by Clojure and Rust](https://mccue.dev/pages/9-25-22-better-java-logging)
0. [Spans - a key concept of distributed tracing](https://signoz.io/blog/distributed-tracing-span/)
0. [Structured Logging for Python](https://www.structlog.org/en/latest/)
diff --git a/documentation/bookmark/math/geometry/differential.md b/documentation/bookmark/math/geometry/differential.md
index 73c9f465f..a05b1ff69 100644
--- a/documentation/bookmark/math/geometry/differential.md
+++ b/documentation/bookmark/math/geometry/differential.md
@@ -1,4 +1,5 @@
# Reference
+0. [Discrete Differential Geometry - CMU 15-458/858](https://www.youtube.com/playlist?list=PL9_jI1bdZmz0hIrNCMQW1YmZysAiIYSSS)
0. [Visual Differential Geometry and Forms: A Mathematical Drama in Five Acts](https://press.princeton.edu/books/hardcover/9780691203690/visual-differential-geometry-and-forms)
diff --git a/documentation/bookmark/procedural_generation/art.md b/documentation/bookmark/procedural_generation/art.md
index 990770381..d32b38423 100644
--- a/documentation/bookmark/procedural_generation/art.md
+++ b/documentation/bookmark/procedural_generation/art.md
@@ -1,4 +1,5 @@
# Reference
+0. [Digital Marbling](https://blog.amandaghassaei.com/2022/10/25/digital-marbling/)
0. [Flow Fields](https://tylerxhobbs.com/essays/2020/flow-fields)
diff --git a/documentation/bookmark/research/zettelkasten.md b/documentation/bookmark/research/zettelkasten.md
new file mode 100644
index 000000000..df8898005
--- /dev/null
+++ b/documentation/bookmark/research/zettelkasten.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Stop Taking Regular Notes; Use a Zettelkasten Instead](https://eugeneyan.com/writing/note-taking-zettelkasten/)
+
diff --git a/documentation/bookmark/security.md b/documentation/bookmark/security.md
index 8cbde16c8..9271d0b10 100644
--- a/documentation/bookmark/security.md
+++ b/documentation/bookmark/security.md
@@ -115,7 +115,7 @@
# Reference
-0. []()
+0. [The immutable laws of security](https://learn.microsoft.com/en-us/security/compass/ten-laws-of-security)
0. [Suricata: the leading independent open source threat detection engine](https://suricata.io/)
0. [CS 253 Web Security](https://web.stanford.edu/class/cs253/)
0. [Secure By Design](https://www.amazon.com/Secure-Design-Daniel-Deogun/dp/1617294357)
diff --git a/documentation/bookmark/security/one_time_program.md b/documentation/bookmark/security/one_time_program.md
new file mode 100644
index 000000000..e388efef0
--- /dev/null
+++ b/documentation/bookmark/security/one_time_program.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [One-Time Programs](https://blog.cryptographyengineering.com/2022/10/27/one-time-programs/)
+
diff --git a/documentation/bookmark/testing/web.md b/documentation/bookmark/testing/web.md
new file mode 100644
index 000000000..18a8a6957
--- /dev/null
+++ b/documentation/bookmark/testing/web.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Web Automation: Don't Use Selenium, Use Playwright](https://new.pythonforengineers.com/blog/web-automation-dont-use-selenium-use-playwright/)
+
diff --git a/documentation/bookmark/user_interface/a11y__accessibility.md b/documentation/bookmark/user_interface/a11y__accessibility.md
index 34eba799d..d830babc5 100644
--- a/documentation/bookmark/user_interface/a11y__accessibility.md
+++ b/documentation/bookmark/user_interface/a11y__accessibility.md
@@ -1,6 +1,6 @@
# Reference
-0. []()
+0. [Accessibility Design: Color Blindness](https://www.alanzucconi.com/2015/12/16/color-blindness/)
0. [a11yphant: Learning web accessibility made easy](https://a11yphant.com/)
0. [Inclusive Design Principles](https://inclusivedesignprinciples.org/)
0. [Making Accessibility More Accessible](https://austingil.com/making-accessibility-more-accessible/)
diff --git a/documentation/bookmark/user_interface/color.md b/documentation/bookmark/user_interface/color.md
index 922539d01..200067ae1 100644
--- a/documentation/bookmark/user_interface/color.md
+++ b/documentation/bookmark/user_interface/color.md
@@ -1,6 +1,11 @@
# Reference
-0. []()
+0. [The Müller Formula (or: Predictable Color Preferences)](https://www.colourlovers.com/blog/2007/09/02/the-muller-formula-or-predictable-color-preferences)
+0. [Mastering Multi-hued Color Scales with Chroma.js](https://www.vis4.net/blog/2013/09/mastering-multi-hued-color-scales/)
+0. [How To Avoid Equidistant HSV Colors ](https://www.vis4.net/blog/2011/12/avoid-equidistant-hsv-colors/)
+0. [The incredibly challenging task of sorting colours](https://www.alanzucconi.com/2015/09/30/colour-sorting/)
+0. [How to find the main colours in an image](https://www.alanzucconi.com/2015/05/24/how-to-find-the-main-colours-in-an-image/)
+0. [The Secrets of Colour Interpolation](https://www.alanzucconi.com/2016/01/06/colour-interpolation/)
0. [Color Design Hub](https://github.com/delaklo/color-design-hub)
0. [Color.js: Let's get serious about color](https://colorjs.io/)
0. [Leonardo](https://leonardocolor.io/#)
diff --git a/documentation/bookmark/user_interface/color/lch.md b/documentation/bookmark/user_interface/color/lch.md
new file mode 100644
index 000000000..c4cf71bbc
--- /dev/null
+++ b/documentation/bookmark/user_interface/color/lch.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [OKLCH in CSS: why we moved from RGB and HSL](https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl)
+
diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux
index aac58040c..82f82733b 100644
--- a/lux-python/source/program.lux
+++ b/lux-python/source/program.lux
@@ -48,7 +48,6 @@
[macro (.only Expander)]]
[phase
["[0]" extension (.only Extender Handler)
- ["[1]/[0]" bundle]
["[0]" analysis
["[1]" python]]
["[0]" translation
@@ -466,7 +465,7 @@
(..eval [(_.code input) globals])))
execute! (is (-> (_.Statement Any) (Try Any))
(function (execute! input)
- (ffi.try ("python exec" (_.code input) globals))))
+ (ffi.try (.python_exec# (_.code input) globals))))
define! (is (-> unit.ID (_.Expression Any) (Try [Text Any (_.Statement Any)]))
(function (define! context input)
(let [global (reference.artifact context)
@@ -492,6 +491,10 @@
[_ (execute! content)]
(evaluate! context (_.var (reference.artifact context)))))))))))))
+(def phase_wrapper
+ phase.Wrapper
+ (..pseudo_function ..to_host))
+
(with_expansions [<jvm> (these (def extender
Extender
... TODO: Stop relying on coercions ASAP.
@@ -508,25 +511,20 @@
(as Try)
(do try.monad
[handler (try.of_maybe (..python_function! handler))
- output (org/python/core/PyFunction::__call__ (|> (ffi.array org/python/core/PyObject 5)
- (ffi.write! 0 (as org/python/core/PyObject (org/python/core/PyString::new (ffi.as_string name))))
- (ffi.write! 1 (as org/python/core/PyObject (phase_wrapper phase)))
- (ffi.write! 2 (..to_host archive))
- (ffi.write! 3 (..to_host parameters))
- (ffi.write! 4 (..to_host state)))
+ output (org/python/core/PyFunction::__call__ (|> (ffi.array org/python/core/PyObject 4)
+ (ffi.write! 0 (as org/python/core/PyObject (phase_wrapper phase)))
+ (ffi.write! 1 (..to_host archive))
+ (ffi.write! 2 (..to_host parameters))
+ (ffi.write! 3 (..to_host state)))
handler)]
(..read output)))))]
(for @.old (these <jvm>)
@.jvm (these <jvm>)
@.python
- (def (extender phase_wrapper handler)
- (-> phase.Wrapper Extender)
- (as_expected handler))))
-
-(def phase_wrapper
- phase.Wrapper
- (..pseudo_function ..to_host))
+ (def extender
+ Extender
+ (|>> as_expected))))
(def platform
(IO (Platform Register (_.Expression Any) (_.Statement Any)))
@@ -534,7 +532,7 @@
[host ..host]
(in [platform.#file_system (file.async file.default)
platform.#host host
- platform.#phase python.translate
+ platform.#phase python.expression
platform.#runtime runtime.translate
platform.#phase_wrapper ..phase_wrapper
platform.#write (|>> _.code (at utf8.codec encoded))])))
@@ -588,7 +586,7 @@
analysis.bundle
..platform
translation.bundle
- extension/bundle.empty
+ extension.empty
..lux_program
(reference.constant python/reference.system)
..extender
diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux
index 6efb9eb0d..cc8bf71b8 100644
--- a/stdlib/source/library/lux/data/text.lux
+++ b/stdlib/source/library/lux/data/text.lux
@@ -241,7 +241,7 @@
("js object do" "replaceAll" template [pattern replacement])))
@.python
(as Text
- ("python object do" "replace" template [pattern replacement]))
+ (.python_object_do# "replace" template [pattern replacement]))
... TODO @.lua
@.ruby
(as Text
@@ -368,7 +368,7 @@
("js object do" "toLowerCase" value []))
@.python
(as Text
- ("python object do" "lower" value []))
+ (.python_object_do# "lower" value []))
@.lua
(as Text
("lua apply" ("lua constant" "string.lower") [value]))
@@ -391,7 +391,7 @@
("js object do" "toUpperCase" value []))
@.python
(as Text
- ("python object do" "upper" value []))
+ (.python_object_do# "upper" value []))
@.lua
(as Text
("lua apply" ("lua constant" "string.upper") [value]))
diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux
index d90d52a2a..cc5dcacd3 100644
--- a/stdlib/source/library/lux/data/text/encoding/utf8.lux
+++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux
@@ -90,7 +90,7 @@
)
@.python
- (as Binary ("python apply" (as_expected ("python constant" "bytearray")) [value "utf-8"]))
+ (as Binary (.python_apply# (as_expected (.python_constant# "bytearray")) [value "utf-8"]))
@.lua
("lua utf8 encode" value)
@@ -133,7 +133,7 @@
{try.#Success}))
@.python
- (try (as Text ("python object do" "decode" (as_expected value) ["utf-8"])))
+ (try (as Text (.python_object_do# "decode" (as_expected value) ["utf-8"])))
@.lua
{try.#Success ("lua utf8 decode" value)}
diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux
index 39c2aecd1..d132e6256 100644
--- a/stdlib/source/library/lux/debug.lux
+++ b/stdlib/source/library/lux/debug.lux
@@ -235,14 +235,14 @@
(^.or "<type 'tuple'>" "<class 'tuple'>")
(let [variant (as (array.Array Any) value)]
(when (array.size variant)
- 3 (let [variant_tag ("python array read" 0 variant)
- variant_flag ("python array read" 1 variant)
- variant_value ("python array read" 2 variant)]
- (if (or ("python object none?" variant_tag)
- ("python object none?" variant_value))
+ 3 (let [variant_tag (.python_array_read# 0 variant)
+ variant_flag (.python_array_read# 1 variant)
+ variant_value (.python_array_read# 2 variant)]
+ (if (or (.python_object_none?# variant_tag)
+ (.python_object_none?# variant_value))
(..str value)
(|> (%.format (|> variant_tag (as .Nat) %.nat)
- " " (|> variant_flag "python object none?" not %.bit)
+ " " (|> variant_flag .python_object_none?# not %.bit)
" " (inspection variant_value))
(text.enclosed ["{" "}"]))))
_ (..str value)))
diff --git a/stdlib/source/library/lux/ffi.lux b/stdlib/source/library/lux/ffi.lux
index 575809639..e4d0878a5 100644
--- a/stdlib/source/library/lux/ffi.lux
+++ b/stdlib/source/library/lux/ffi.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Symbol Alias Global global function type_of undefined)
+ [lux (.except Symbol Alias Global Declaration global function type_of undefined)
[abstract
["[0]" monad (.only do)]]
[control
@@ -21,7 +21,7 @@
[syntax (.only syntax)]
["[0]" template]]
[type
- ["[0]" primitive (.except def)]]
+ ["[0]" primitive (.except #name def)]]
["@" target (.only)
["[0]" js]]]]])
@@ -81,9 +81,9 @@
{try.#Success [state (extension_analysis name (list))]})
(translation <undefined>
- [name phase archive state]
- (list)
- {try.#Success [state js.undefined]})
+ [name phase archive state]
+ (list)
+ {try.#Success [state js.undefined]})
(def .public undefined
(template (undefined)
@@ -98,11 +98,11 @@
(in [state (extension_analysis name (list it))])))
(translation <undefined?>
- [name phase archive state]
- (list it)
- (do try.monad
- [[state it] (phase archive it state)]
- (in [state (js.= js.undefined it)])))
+ [name phase archive state]
+ (list it)
+ (do try.monad
+ [[state it] (phase archive it state)]
+ (in [state (js.= js.undefined it)])))
(def .public undefined?
(template (undefined? <it>)
@@ -138,22 +138,22 @@
(.undefined)))
(translation <object>
- [name phase archive state]
- (list.partial head_key head_value tail)
- (do [! try.monad]
- [[state output] (monad.mix !
- (.function (_ [key value] [state output])
- (when key
- (text_synthesis key)
- (do try.monad
- [[state value] (phase archive value state)]
- (in [state (list.partial [key value] output)]))
-
- _
- (.undefined)))
- [state (list)]
- (pairs (list.partial head_key head_value tail)))]
- (in [state (js.object (list.reversed output))])))
+ [name phase archive state]
+ (list.partial head_key head_value tail)
+ (do [! try.monad]
+ [[state output] (monad.mix !
+ (.function (_ [key value] [state output])
+ (when key
+ (text_synthesis key)
+ (do try.monad
+ [[state value] (phase archive value state)]
+ (in [state (list.partial [key value] output)]))
+
+ _
+ (.undefined)))
+ [state (list)]
+ (pairs (list.partial head_key head_value tail)))]
+ (in [state (js.object (list.reversed output))])))
(def .public object
(syntax (_ [it (<>.some <code>.any)])
@@ -170,12 +170,12 @@
(in [state (extension_analysis name (list (text_analysis field) value object))])))
(translation <set>
- [name phase archive state]
- (list (text_synthesis field) value object)
- (do try.monad
- [[state value] (phase archive value state)
- [state object] (phase archive object state)]
- (in [state (js.set (js.the field object) value)])))
+ [name phase archive state]
+ (list (text_synthesis field) value object)
+ (do try.monad
+ [[state value] (phase archive value state)
+ [state object] (phase archive object state)]
+ (in [state (js.set (js.the field object) value)])))
(def .public set
(syntax (_ [field <code>.any
@@ -187,34 +187,34 @@
(these))
(with_expansions [<constant> (for @.js "js constant"
- @.python "python constant"
+ @.python .python_constant#
@.lua "lua constant"
@.ruby "ruby constant")
<apply> (for @.js "js apply"
- @.python "python apply"
+ @.python .python_apply#
@.lua "lua apply"
@.ruby "ruby apply")
<new> (for @.js "js object new"
- @.python "python apply"
+ @.python .python_apply#
(these))
<do> (for @.js "js object do"
- @.python "python object do"
+ @.python .python_object_do#
@.lua "lua object do"
@.ruby "ruby object do")
<get> (for @.js "js object get"
- @.python "python object get"
+ @.python .python_object_get#
@.lua "lua object get"
@.ruby "ruby object get"
(these))
<set> (for @.lua "lua object set"
@.ruby "ruby object set"
(these))
- <import> (for @.python "python import"
+ <import> (for @.python .python_import#
@.lua "lua import"
@.ruby "ruby import"
(these))
<function> (for @.js "js function"
- @.python "python function"
+ @.python .python_function#
@.lua "lua function"
(these))]
(primitive.def .public (Object brand) Any)
@@ -462,8 +462,8 @@
(,, (for @.js [null "js object null"
null? "js object null?"]
- @.python [none "python object none"
- none? "python object none?"]
+ @.python [none .python_object_none#
+ none? .python_object_none?#]
@.lua [nil "lua object nil"
nil? "lua object nil?"]
@.ruby [nil "ruby object nil"
diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux
index 13c54f28b..916fa95f7 100644
--- a/stdlib/source/library/lux/math/number/frac.lux
+++ b/stdlib/source/library/lux/math/number/frac.lux
@@ -142,7 +142,7 @@
[(def .public <name>
(-> Frac Frac)
(|>> []
- ("python object do" <method> ("python import" "math"))
+ (.python_object_do# <method> (.python_import# "math"))
(as Frac)))]
[cos "cos"]
@@ -164,7 +164,7 @@
(def .public (pow param subject)
(-> Frac Frac Frac)
- (as Frac ("python object do" "pow" ("python import" "math") [subject param])))
+ (as Frac (.python_object_do# "pow" (.python_import# "math") [subject param])))
(def .public (root_3 it)
(-> Frac Frac)
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
index adfdc2e52..d79128c56 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
@@ -53,6 +53,12 @@
{try.#Failure error}
(phase.failure error))))
+(def .public translation
+ (-> Text
+ Symbol)
+ (|>> (text.suffix "|translation")
+ [.prelude]))
+
(def .public (install name anonymous)
(-> Text (-> Text Handler)
(-> Bundle Bundle))
@@ -78,7 +84,7 @@
(analyse archive argC)))
(list.zipped_2 inputsT+ args))
@ meta.location]
- (in [@ {analysis.#Extension [.prelude (format extension_name "|translation")] argsA}]))
+ (in [@ {analysis.#Extension (..translation extension_name) argsA}]))
(analysis.except ..incorrect_arity [num_expected num_actual]))))))
(def .public (nullary valueT)
@@ -153,7 +159,7 @@
(list (analysis.tuple @ (list#each (|>> (analysis.nat @)) cases))
branch))))
(list.partial input else)
- {analysis.#Extension [.prelude (format extension_name "|translation")]}
+ {analysis.#Extension (..translation extension_name)}
[@]))))])))
... .is?# represents reference/pointer equality.
@@ -180,7 +186,7 @@
(analyse archive)
(typeA.expecting (type_literal (-> .Any :var:)))
(at ! each (|>> list
- {analysis.#Extension [.prelude (format extension_name "|translation")]}
+ {analysis.#Extension (..translation extension_name)}
[@]))))))]))
(def lux::in_module
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux
index 823ffe79a..eb457c03a 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux
@@ -11,17 +11,16 @@
["[0]" array]
["[0]" dictionary]
["[0]" list]]]
- [meta
+ ["[0]" meta (.only)
["@" target (.only)
["_" python]]
["[0]" code
["<[1]>" \\parser (.only Parser)]]
["[0]" type (.only)
["[0]" check]]]]]
- [//
+ ["[0]" //
["/" lux (.only custom)]
- [//
- ["[0]" bundle]
+ ["/[1]" // (.only)
[///
["[0]" analysis (.only Analysis Operation Phase Handler Bundle)
["[1]/[0]" type]]
@@ -29,7 +28,7 @@
["[0]" phase]]]]])
(def array::new
- Handler
+ (-> Text Handler)
(custom
[<code>.any
(function (_ extension phase archive lengthC)
@@ -40,11 +39,13 @@
(do phase.monad
[lengthA (analysis/type.expecting Nat
(phase archive lengthC))
- _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))]
- (in {analysis.#Extension extension (list lengthA)}))))]))
+ _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list lengthA)}]))))]))
(def array::length
- Handler
+ (-> Text Handler)
(custom
[<code>.any
(function (_ extension phase archive arrayC)
@@ -55,11 +56,13 @@
(do phase.monad
[arrayA (analysis/type.expecting (type_literal (array.Array' :read: :write:))
(phase archive arrayC))
- _ (analysis/type.inference Nat)]
- (in {analysis.#Extension extension (list arrayA)}))))]))
+ _ (analysis/type.inference Nat)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list arrayA)}]))))]))
(def array::read
- Handler
+ (-> Text Handler)
(custom
[(<>.and <code>.any <code>.any)
(function (_ extension phase archive [indexC arrayC])
@@ -72,11 +75,13 @@
(phase archive indexC))
arrayA (analysis/type.expecting (type_literal (array.Array' :read: :write:))
(phase archive arrayC))
- _ (analysis/type.inference :read:)]
- (in {analysis.#Extension extension (list indexA arrayA)}))))]))
+ _ (analysis/type.inference :read:)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list indexA arrayA)}]))))]))
(def array::write
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.any <code>.any <code>.any)
(function (_ extension phase archive [indexC valueC arrayC])
@@ -91,11 +96,13 @@
(phase archive valueC))
arrayA (analysis/type.expecting (type_literal (array.Array' :read: :write:))
(phase archive arrayC))
- _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))]
- (in {analysis.#Extension extension (list indexA valueA arrayA)}))))]))
+ _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list indexA valueA arrayA)}]))))]))
(def array::delete
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.any <code>.any)
(function (_ extension phase archive [indexC arrayC])
@@ -108,19 +115,19 @@
(phase archive indexC))
arrayA (analysis/type.expecting (type_literal (array.Array' :read: :write:))
(phase archive arrayC))
- _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))]
- (in {analysis.#Extension extension (list indexA arrayA)}))))]))
+ _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list indexA arrayA)}]))))]))
-(def bundle::array
- Bundle
- (<| (bundle.prefix "array")
- (|> bundle.empty
- (bundle.install "new" array::new)
- (bundle.install "length" array::length)
- (bundle.install "read" array::read)
- (bundle.install "write" array::write)
- (bundle.install "delete" array::delete)
- )))
+(def with_array_extensions
+ (-> Bundle Bundle)
+ (|>> (/.install "python_array_new#" array::new)
+ (/.install "python_array_length#" array::length)
+ (/.install "python_array_read#" array::read)
+ (/.install "python_array_write#" array::write)
+ (/.install "python_array_delete#" array::delete)
+ ))
(def None
(for @.python ffi.None
@@ -139,19 +146,21 @@
Any))
(def object::get
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.text <code>.any)
(function (_ extension phase archive [fieldC objectC])
(do phase.monad
[objectA (analysis/type.expecting ..Object
(phase archive objectC))
- _ (analysis/type.inference .Any)]
- (in {analysis.#Extension extension (list (analysis.text fieldC)
- objectA)})))]))
+ _ (analysis/type.inference .Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list (analysis.text @ fieldC)
+ objectA)}])))]))
(def object::do
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any)))
(function (_ extension phase archive [methodC objectC inputsC])
@@ -159,41 +168,45 @@
[objectA (analysis/type.expecting ..Object
(phase archive objectC))
inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC)
- _ (analysis/type.inference .Any)]
- (in {analysis.#Extension extension (list.partial (analysis.text methodC)
- objectA
- inputsA)})))]))
+ _ (analysis/type.inference .Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list.partial (analysis.text @ methodC)
+ objectA
+ inputsA)}])))]))
-(def bundle::object
- Bundle
- (<| (bundle.prefix "object")
- (|> bundle.empty
- (bundle.install "get" object::get)
- (bundle.install "do" object::do)
- (bundle.install "none" (/.nullary ..None))
- (bundle.install "none?" (/.unary Any Bit))
- )))
+(def with_object_extensions
+ (-> Bundle Bundle)
+ (|>> (/.install "python_object_get#" object::get)
+ (/.install "python_object_do#" object::do)
+ (/.install "python_object_none#" (/.nullary ..None))
+ (/.install "python_object_none?#" (/.unary Any Bit))
+ ))
(def python::constant
- Handler
+ (-> Text Handler)
(custom
[<code>.text
(function (_ extension phase archive name)
(do phase.monad
- [_ (analysis/type.inference Any)]
- (in {analysis.#Extension extension (list (analysis.text name))})))]))
+ [_ (analysis/type.inference Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list (analysis.text @ name))}])))]))
(def python::import
- Handler
+ (-> Text Handler)
(custom
[<code>.text
(function (_ extension phase archive name)
(do phase.monad
- [_ (analysis/type.inference ..Object)]
- (in {analysis.#Extension extension (list (analysis.text name))})))]))
+ [_ (analysis/type.inference ..Object)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list (analysis.text @ name))}])))]))
(def python::apply
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.any (<code>.tuple (<>.some <code>.any)))
(function (_ extension phase archive [abstractionC inputsC])
@@ -201,11 +214,13 @@
[abstractionA (analysis/type.expecting ..Function
(phase archive abstractionC))
inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC)
- _ (analysis/type.inference Any)]
- (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))]))
+ _ (analysis/type.inference Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list.partial abstractionA inputsA)}])))]))
(def python::function
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.nat <code>.any)
(function (_ extension phase archive [arity abstractionC])
@@ -213,12 +228,14 @@
[.let [inputT (type.tuple (list.repeated arity Any))]
abstractionA (analysis/type.expecting (-> inputT Any)
(phase archive abstractionC))
- _ (analysis/type.inference ..Function)]
- (in {analysis.#Extension extension (list (analysis.nat arity)
- abstractionA)})))]))
+ _ (analysis/type.inference ..Function)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list (analysis.nat @ arity)
+ abstractionA)}])))]))
(def python::exec
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.any <code>.any)
(function (_ extension phase archive [codeC globalsC])
@@ -227,19 +244,20 @@
(phase archive codeC))
globalsA (analysis/type.expecting ..Dict
(phase archive globalsC))
- _ (analysis/type.inference .Any)]
- (in {analysis.#Extension extension (list codeA globalsA)})))]))
+ _ (analysis/type.inference .Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list codeA globalsA)}])))]))
(def .public bundle
Bundle
- (<| (bundle.prefix "python")
- (|> bundle.empty
- (dictionary.composite bundle::array)
- (dictionary.composite bundle::object)
-
- (bundle.install "constant" python::constant)
- (bundle.install "import" python::import)
- (bundle.install "apply" python::apply)
- (bundle.install "function" python::function)
- (bundle.install "exec" python::exec)
- )))
+ (|> ///.empty
+ with_array_extensions
+ with_object_extensions
+
+ (/.install "python_constant#" python::constant)
+ (/.install "python_import#" python::import)
+ (/.install "python_apply#" python::apply)
+ (/.install "python_function#" python::function)
+ (/.install "python_exec#" python::exec)
+ ))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux
index 034560910..b7ddc07e9 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux
@@ -465,4 +465,5 @@
with_text_extensions
with_i64_extensions
with_int_extensions
- with_frac_extensions))
+ with_frac_extensions
+ ))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux
index ff724bd07..edabbd255 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux
@@ -21,43 +21,44 @@
[macro
["^" pattern]]
[target
- ["_" python (.only Expression Statement)]]]]]
- ["[0]" ////
- ["/" bundle]
- ["/[1]" //
- ["[0]" extension]
- [translation
- ["[0]" reference]
- [extension (.only Nullary Unary Binary Trinary
- nullary unary binary trinary)]
- ["//" python
- ["[1][0]" runtime (.only Operation Phase Phase! Handler Bundle Translator)]
- ["[1][0]" primitive]
- ["[1][0]" structure]
- ["[1][0]" reference]
- ["[1][0]" function]
- ["[1][0]" when]
- ["[1][0]" loop]]]
- [//
- [analysis (.only)]
- ["[0]" translation]
- ["[0]" synthesis (.only %synthesis)
- ["<[1]>" \\parser (.only Parser)]]
- [///
- ["[1]" phase (.use "[1]#[0]" monad)]]]]])
+ ["_" python (.only Expression Statement)]]
+ [compiler
+ [meta
+ [archive (.only Archive)]]]]]]
+ [/////
+ ["[0]" extension]
+ [translation
+ ["[0]" reference]
+ [extension (.only Nullary Unary Binary Trinary Variadic
+ nullary unary binary trinary variadic)]
+ ["//" python
+ ["[1][0]" runtime (.only Operation Phase Phase! Handler Bundle Translator)]
+ ["[1][0]" primitive]
+ ["[1][0]" structure]
+ ["[1][0]" reference]
+ ["[1][0]" function]
+ ["[1][0]" when]
+ ["[1][0]" loop]]]
+ [//
+ [analysis (.only)]
+ ["[0]" translation]
+ ["[0]" synthesis (.only %synthesis)
+ ["<[1]>" \\parser (.only Parser)]]
+ [///
+ ["[0]" phase (.use "[1]#[0]" monad)]]]])
(def .public (statement expression archive synthesis)
Phase!
(when synthesis
... TODO: Get rid of this ASAP
- {synthesis.#Extension [.prelude "when_char#|translation"] parameters}
- (do /////.monad
+ [@ {synthesis.#Extension [.prelude "when_char#|translation"] parameters}]
+ (do phase.monad
[body (expression archive synthesis)]
(in (as (Statement Any) body)))
(^.with_template [<tag>]
- [(<tag> value)
- (/////#each _.return (expression archive synthesis))])
+ [(<tag> @ value)
+ (phase#each _.return (expression archive synthesis))])
([synthesis.bit]
[synthesis.i64]
[synthesis.f64]
@@ -68,16 +69,16 @@
[synthesis.function/apply])
(^.with_template [<tag>]
- [{<tag> value}
- (/////#each _.return (expression archive synthesis))])
+ [[@ {<tag> value}]
+ (phase#each _.return (expression archive synthesis))])
([synthesis.#Reference]
[synthesis.#Extension])
- (synthesis.branch/when when)
+ (synthesis.branch/when @ when)
(//when.when! false statement expression archive when)
(^.with_template [<tag> <translator>]
- [(<tag> value)
+ [(<tag> @ value)
(<translator> statement expression archive value)])
([synthesis.branch/exec //when.exec!]
[synthesis.branch/let //when.let!]
@@ -85,10 +86,23 @@
[synthesis.loop/scope //loop.scope!]
[synthesis.loop/again //loop.again!])
- (synthesis.function/abstraction abstraction)
- (/////#each _.return (//function.function statement expression archive abstraction))
+ (synthesis.function/abstraction @ abstraction)
+ (phase#each _.return (//function.function statement expression archive abstraction))
))
+(def .public (custom [parser handler])
+ (All (_ s)
+ (-> [(Parser s)
+ (-> Phase Archive s (Operation (Expression Any)))]
+ Handler))
+ (function (_ phase archive input)
+ (when (<synthesis>.result parser input)
+ {try.#Success input'}
+ (handler phase archive input')
+
+ {try.#Failure error}
+ (phase.failure error))))
+
... TODO: Get rid of this ASAP
(def lux::syntax_char_case!
(..custom [(all <>.and
@@ -97,8 +111,8 @@
(<>.some (<synthesis>.tuple (all <>.and
(<synthesis>.tuple (<>.many <synthesis>.i64))
<synthesis>.any))))
- (function (_ extension_name phase archive [input else conditionals])
- (do [! /////.monad]
+ (function (_ phase archive [input else conditionals])
+ (do [! phase.monad]
[inputG (phase archive input)
else! (..statement phase archive else)
@input (at ! each _.var (translation.symbol "input"))
@@ -144,55 +158,55 @@
else!
conditionals!))))))]))
-(def lux_procs
- Bundle
- (|> /.empty
- (/.install "syntax char case!" lux::syntax_char_case!)
- (/.install "is" (binary (product.uncurried _.is)))
- (/.install "try" (unary //runtime.lux::try))))
+(def with_basic_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "when_char#|translation" lux::syntax_char_case!)
+ (dictionary.has "is?#|translation" (binary (product.uncurried _.is)))
+ (dictionary.has "try#|translation" (unary //runtime.lux::try))))
(def (capped operation parameter subject)
(-> (-> (Expression Any) (Expression Any) (Expression Any))
(-> (Expression Any) (Expression Any) (Expression Any)))
(//runtime.i64::64 (operation parameter subject)))
-(def i64_procs
- Bundle
- (<| (/.prefix "i64")
- (|> /.empty
- (/.install "and" (binary (product.uncurried //runtime.i64::and)))
- (/.install "or" (binary (product.uncurried //runtime.i64::or)))
- (/.install "xor" (binary (product.uncurried //runtime.i64::xor)))
- (/.install "left-shift" (binary (product.uncurried //runtime.i64::left_shifted)))
- (/.install "right-shift" (binary (product.uncurried //runtime.i64::right_shifted)))
-
- (/.install "<" (binary (product.uncurried _.<)))
- (/.install "=" (binary (product.uncurried _.=)))
- (/.install "+" (binary (product.uncurried (..capped _.+))))
- (/.install "-" (binary (product.uncurried (..capped _.-))))
- (/.install "*" (binary (product.uncurried (..capped _.*))))
- (/.install "/" (binary (product.uncurried //runtime.i64#/)))
- (/.install "%" (binary (product.uncurried //runtime.i64::remainder)))
- (/.install "f64" (unary _.float/1))
- (/.install "char" (unary //runtime.i64::char))
- )))
-
-(def f64_procs
- Bundle
- (<| (/.prefix "f64")
- (|> /.empty
- (/.install "+" (binary (product.uncurried _.+)))
- (/.install "-" (binary (product.uncurried _.-)))
- (/.install "*" (binary (product.uncurried _.*)))
- (/.install "/" (binary (product.uncurried //runtime.f64::/)))
- (/.install "%" (binary (function (_ [parameter subject])
- (|> (_.__import__/1 (_.unicode "math"))
- (_.do "fmod" (list subject parameter))))))
- (/.install "=" (binary (product.uncurried _.=)))
- (/.install "<" (binary (product.uncurried _.<)))
- (/.install "i64" (unary _.int/1))
- (/.install "encode" (unary _.repr/1))
- (/.install "decode" (unary //runtime.f64::decode)))))
+(def with_i64_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "i64_and#|translation" (binary (product.uncurried //runtime.i64::and)))
+ (dictionary.has "i64_or#|translation" (binary (product.uncurried //runtime.i64::or)))
+ (dictionary.has "i64_xor#|translation" (binary (product.uncurried //runtime.i64::xor)))
+ (dictionary.has "i64_left#|translation" (binary (product.uncurried //runtime.i64::left_shifted)))
+ (dictionary.has "i64_right#|translation" (binary (product.uncurried //runtime.i64::right_shifted)))
+
+ (dictionary.has "i64_=#|translation" (binary (product.uncurried _.=)))
+ (dictionary.has "i64_+#|translation" (binary (product.uncurried (..capped _.+))))
+ (dictionary.has "i64_-#|translation" (binary (product.uncurried (..capped _.-))))
+ ))
+
+(def with_int_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "int_<#|translation" (binary (product.uncurried _.<)))
+ (dictionary.has "int_*#|translation" (binary (product.uncurried (..capped _.*))))
+ (dictionary.has "int_/#|translation" (binary (product.uncurried //runtime.i64#/)))
+ (dictionary.has "int_%#|translation" (binary (product.uncurried //runtime.i64::remainder)))
+
+ (dictionary.has "int_f64#|translation" (unary _.float/1))
+ (dictionary.has "int_char#|translation" (unary //runtime.i64::char))
+ ))
+
+(def with_frac_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "f64_+#|translation" (binary (product.uncurried _.+)))
+ (dictionary.has "f64_-#|translation" (binary (product.uncurried _.-)))
+ (dictionary.has "f64_*#|translation" (binary (product.uncurried _.*)))
+ (dictionary.has "f64_/#|translation" (binary (product.uncurried //runtime.f64::/)))
+ (dictionary.has "f64_%#|translation" (binary (function (_ [parameter subject])
+ (|> (_.__import__/1 (_.unicode "math"))
+ (_.do "fmod" (list subject parameter))))))
+ (dictionary.has "f64_=#|translation" (binary (product.uncurried _.=)))
+ (dictionary.has "f64_<#|translation" (binary (product.uncurried _.<)))
+ (dictionary.has "f64_int#|translation" (unary _.int/1))
+ (dictionary.has "f64_encoded#|translation" (unary _.repr/1))
+ (dictionary.has "f64_decoded#|translation" (unary //runtime.f64::decode))))
(def (text::clip [paramO extraO subjectO])
(Trinary (Expression Any))
@@ -202,32 +216,41 @@
(Trinary (Expression Any))
(//runtime.text::index startO partO textO))
-(def text_procs
- Bundle
- (<| (/.prefix "text")
- (|> /.empty
- (/.install "=" (binary (product.uncurried _.=)))
- (/.install "<" (binary (product.uncurried _.<)))
- (/.install "concat" (binary (product.uncurried (function.flipped _.+))))
- (/.install "index" (trinary ..text::index))
- (/.install "size" (unary _.len/1))
- (/.install "char" (binary (product.uncurried //runtime.text::char)))
- (/.install "clip" (trinary ..text::clip))
- )))
-
-(def io_procs
- Bundle
- (<| (/.prefix "io")
- (|> /.empty
- (/.install "log" (unary //runtime.io::log!))
- (/.install "error" (unary //runtime.io::throw!)))))
+(def (text::composite parts)
+ (Variadic (Expression Any))
+ (when parts
+ (list)
+ (_.string "")
+
+ (list single)
+ single
+
+ _
+ (_.do "join" (list (_.list parts)) (_.string ""))))
+
+(def with_text_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "text_=#|translation" (binary (product.uncurried _.=)))
+ (dictionary.has "text_<#|translation" (binary (product.uncurried _.<)))
+ (dictionary.has "text_composite#|translation" (variadic ..text::composite))
+ (dictionary.has "text_index#|translation" (trinary ..text::index))
+ (dictionary.has "text_size#|translation" (unary _.len/1))
+ (dictionary.has "text_char#|translation" (binary (product.uncurried //runtime.text::char)))
+ (dictionary.has "text_clip#|translation" (trinary ..text::clip))
+ ))
+
+(def with_io_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "log!#|translation" (unary //runtime.io::log!))
+ (dictionary.has "error#|translation" (unary //runtime.io::throw!))))
(def .public bundle
Bundle
- (<| (/.prefix "lux")
- (|> lux_procs
- (dictionary.composite i64_procs)
- (dictionary.composite f64_procs)
- (dictionary.composite text_procs)
- (dictionary.composite io_procs)
- )))
+ (|> extension.empty
+ with_basic_extensions
+ with_i64_extensions
+ with_int_extensions
+ with_frac_extensions
+ with_text_extensions
+ with_io_extensions
+ ))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux
index d9af74b71..adb650f17 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux
@@ -15,24 +15,22 @@
[meta
[target
["_" python (.only Expression SVar)]]]]]
- ["[0]" //
- ["[1][0]" common (.only custom)]
- ["//[1]" ///
- ["/" bundle]
- ["/[1]" //
- ["[0]" extension]
- [translation
- [extension (.only Nullary Unary Binary Trinary
- nullary unary binary trinary)]
- ["//" python
- ["[1][0]" runtime (.only Operation Phase Handler Bundle
- with_vars)]]]
- ["/[1]" //
- ["[0]" translation]
- [synthesis
- ["<s>" \\parser (.only Parser)]]
- ["//[1]" ///
- ["[1][0]" phase]]]]]])
+ [//
+ [common (.only custom)]
+ [////
+ ["[0]" extension]
+ [translation
+ [extension (.only Nullary Unary Binary Trinary
+ nullary unary binary trinary)]
+ ["//" python
+ ["[1][0]" runtime (.only Operation Phase Handler Bundle
+ with_vars)]]]
+ [//
+ ["[0]" translation]
+ [synthesis
+ ["<s>" \\parser (.only Parser)]]
+ [///
+ ["[0]" phase]]]]])
(def (array::new size)
(Unary (Expression Any))
@@ -56,23 +54,21 @@
(Binary (Expression Any))
(//runtime.array::write indexG _.none arrayG))
-(def array
- Bundle
- (<| (/.prefix "array")
- (|> /.empty
- (/.install "new" (unary array::new))
- (/.install "length" (unary array::length))
- (/.install "read" (binary array::read))
- (/.install "write" (trinary array::write))
- (/.install "delete" (binary array::delete))
- )))
+(def with_array_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "python_array_new#|translation" (unary array::new))
+ (dictionary.has "python_array_length#|translation" (unary array::length))
+ (dictionary.has "python_array_read#|translation" (binary array::read))
+ (dictionary.has "python_array_write#|translation" (trinary array::write))
+ (dictionary.has "python_array_delete#|translation" (binary array::delete))
+ ))
(def object::get
Handler
(custom
[(all <>.and <s>.text <s>.any)
- (function (_ extension phase archive [fieldS objectS])
- (do ////////phase.monad
+ (function (_ phase archive [fieldS objectS])
+ (do phase.monad
[objectG (phase archive objectS)]
(in (_.the fieldS objectG))))]))
@@ -80,8 +76,8 @@
Handler
(custom
[(all <>.and <s>.text <s>.any (<>.some <s>.any))
- (function (_ extension phase archive [methodS objectS inputsS])
- (do [! ////////phase.monad]
+ (function (_ phase archive [methodS objectS inputsS])
+ (do [! phase.monad]
[objectG (phase archive objectS)
inputsG (monad.each ! (phase archive) inputsS)]
(in (_.do methodS inputsG objectG))))]))
@@ -93,37 +89,35 @@
[object::none object::none? _.none]
)
-(def object
- Bundle
- (<| (/.prefix "object")
- (|> /.empty
- (/.install "get" object::get)
- (/.install "do" object::do)
- (/.install "none" (nullary object::none))
- (/.install "none?" (unary object::none?))
- )))
+(def with_object_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "python_object_get#|translation" object::get)
+ (dictionary.has "python_object_do#|translation" object::do)
+ (dictionary.has "python_object_none#|translation" (nullary object::none))
+ (dictionary.has "python_object_none?#|translation" (unary object::none?))
+ ))
(def python::constant
(custom
[<s>.text
- (function (_ extension phase archive name)
- (do ////////phase.monad
+ (function (_ phase archive name)
+ (do phase.monad
[]
(in (_.var name))))]))
(def python::import
(custom
[<s>.text
- (function (_ extension phase archive module)
- (do ////////phase.monad
+ (function (_ phase archive module)
+ (do phase.monad
[]
(in (_.apply (list (_.string module)) (_.var "__import__")))))]))
(def python::apply
(custom
[(all <>.and <s>.any (<>.some <s>.any))
- (function (_ extension phase archive [abstractionS inputsS])
- (do [! ////////phase.monad]
+ (function (_ phase archive [abstractionS inputsS])
+ (do [! phase.monad]
[abstractionG (phase archive abstractionS)
inputsG (monad.each ! (phase archive) inputsS)]
(in (_.apply inputsG abstractionG))))]))
@@ -131,8 +125,8 @@
(def python::function
(custom
[(all <>.and <s>.i64 <s>.any)
- (function (_ extension phase archive [arity abstractionS])
- (do [! ////////phase.monad]
+ (function (_ phase archive [arity abstractionS])
+ (do [! phase.monad]
[abstractionG (phase archive abstractionS)
.let [variable (is (-> Text (Operation SVar))
(|>> translation.symbol
@@ -148,22 +142,21 @@
(def python::exec
(custom
[(all <>.and <s>.any <s>.any)
- (function (_ extension phase archive [codeS globalsS])
- (do [! ////////phase.monad]
+ (function (_ phase archive [codeS globalsS])
+ (do [! phase.monad]
[codeG (phase archive codeS)
globalsG (phase archive globalsS)]
(in (//runtime.lux::exec codeG globalsG))))]))
(def .public bundle
Bundle
- (<| (/.prefix "python")
- (|> /.empty
- (dictionary.composite ..array)
- (dictionary.composite ..object)
-
- (/.install "constant" python::constant)
- (/.install "import" python::import)
- (/.install "apply" python::apply)
- (/.install "function" python::function)
- (/.install "exec" python::exec)
- )))
+ (|> extension.empty
+ with_array_extensions
+ with_object_extensions
+
+ (dictionary.has "python_constant#|translation" python::constant)
+ (dictionary.has "python_import#|translation" python::import)
+ (dictionary.has "python_apply#|translation" python::apply)
+ (dictionary.has "python_function#|translation" python::function)
+ (dictionary.has "python_exec#|translation" python::exec)
+ ))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
index 4555c1b6a..bc59b8d93 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
@@ -35,46 +35,45 @@
(exception.def .public cannot_recur_as_an_expression)
-(def .public (expression archive synthesis)
- Phase
- (when synthesis
- (^.with_template [<tag> <translator>]
- [(<tag> value)
- (//////phase#in (<translator> value))])
- ([////synthesis.bit /primitive.bit]
- [////synthesis.i64 /primitive.i64]
- [////synthesis.f64 /primitive.f64]
- [////synthesis.text /primitive.text])
+(def .public (expression extender lux)
+ (-> ///extension.Extender Lux Phase)
+ (function (expression archive synthesis)
+ (when synthesis
+ (^.with_template [<tag> <translator>]
+ [(<tag> @ value)
+ (//////phase#in (<translator> value))])
+ ([////synthesis.bit /primitive.bit]
+ [////synthesis.i64 /primitive.i64]
+ [////synthesis.f64 /primitive.f64]
+ [////synthesis.text /primitive.text])
- (^.with_template [<tag> <translator>]
- [(<tag> value)
- (<translator> expression archive value)])
- ([////synthesis.variant /structure.variant]
- [////synthesis.tuple /structure.tuple]
-
- [////synthesis.branch/exec /when.exec]
- [////synthesis.branch/let /when.let]
- [////synthesis.branch/if /when.if]
- [////synthesis.branch/get /when.get]
-
- [////synthesis.function/apply /function.apply])
+ (^.with_template [<tag> <translator>]
+ [(<tag> @ value)
+ (<translator> expression archive value)])
+ ([////synthesis.variant /structure.variant]
+ [////synthesis.tuple /structure.tuple]
+
+ [////synthesis.branch/exec /when.exec]
+ [////synthesis.branch/let /when.let]
+ [////synthesis.branch/if /when.if]
+ [////synthesis.branch/get /when.get]
+
+ [////synthesis.function/apply /function.apply])
- (^.with_template [<tag> <translator>]
- [(<tag> value)
- (<translator> ///extension/common.statement expression archive value)])
- ([////synthesis.branch/when /when.when]
- [////synthesis.loop/scope /loop.scope]
- [////synthesis.function/abstraction /function.function])
+ (^.with_template [<tag> <translator>]
+ [(<tag> @ value)
+ (<translator> ///extension/common.statement expression archive value)])
+ ([////synthesis.branch/when /when.when]
+ [////synthesis.loop/scope /loop.scope]
+ [////synthesis.function/abstraction /function.function])
- (////synthesis.loop/again updates)
- (//////phase.except ..cannot_recur_as_an_expression [])
+ (////synthesis.loop/again @ updates)
+ (//////phase.except ..cannot_recur_as_an_expression [])
- {////synthesis.#Reference value}
- (//reference.reference /reference.system archive value)
+ [@ {////synthesis.#Reference value}]
+ (//reference.reference /reference.system archive value)
- {////synthesis.#Extension extension}
- (///extension.apply archive expression extension)))
-
-(def .public translate
- Phase
- ..expression)
+ [@ {////synthesis.#Extension [name parameters]}]
+ (///extension.application extender lux expression archive .Translation false name parameters
+ (|>>)
+ (function (_ _) {.#None})))))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux
index 5ee68797a..f176eb403 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except function)
+ [lux (.except Analysis Synthesis function)
[abstract
["[0]" monad (.only do)]]
[data
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux
index 3d4943710..1d4a4a01b 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Scope)
+ [lux (.except Scope Synthesis)
[abstract
["[0]" monad (.only do)]]
[data
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux
index 723796d21..cdca9d0b1 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Variant Tuple)
+ [lux (.except Variant Tuple Synthesis)
[abstract
["[0]" monad (.only do)]]
[meta
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux
index 4a92d11ef..9dadc3fab 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except when exec let if symbol)
+ [lux (.except Synthesis when exec let if symbol)
[abstract
["[0]" monad (.only do)]]
[data
diff --git a/stdlib/source/library/lux/world/time/instant.lux b/stdlib/source/library/lux/world/time/instant.lux
index 233c8d511..db49c57c6 100644
--- a/stdlib/source/library/lux/world/time/instant.lux
+++ b/stdlib/source/library/lux/world/time/instant.lux
@@ -167,8 +167,8 @@
(|> ("js object do" "getTime" date [])
(as Frac)
.f64_int#))
- @.python (let [time ("python import" "time")]
- (|> ("python object do" "time" time [])
+ @.python (let [time (.python_import# "time")]
+ (|> (.python_object_do# "time" time [])
(as Frac)
(f.* +1,000.0)
.f64_int#))
diff --git a/stdlib/source/test/lux/meta/target/python.lux b/stdlib/source/test/lux/meta/target/python.lux
index 7b0b0d77a..13510a10b 100644
--- a/stdlib/source/test/lux/meta/target/python.lux
+++ b/stdlib/source/test/lux/meta/target/python.lux
@@ -440,7 +440,7 @@
random.nat)
environment (..dict [])]
(exec
- ("python exec" (/.code (it (/.var $output))) (as_expected environment))
+ (.python_exec# (/.code (it (/.var $output))) (as_expected environment))
(Dict::get $output environment))))
(def test|access
diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux
index 1e79c9480..83a6df975 100644
--- a/stdlib/source/unsafe/lux/data/binary.lux
+++ b/stdlib/source/unsafe/lux/data/binary.lux
@@ -80,7 +80,7 @@
(,, (.static @.python))
(.|> <size>
[]
- ("python apply" (.as ffi.Function ("python constant" "bytearray")))
+ (.python_apply# (.as ffi.Function (.python_constant# "bytearray")))
(.as ..Binary))
(,, (.static @.scheme))
@@ -107,7 +107,7 @@
(,, (.static @.python))
(.|> <it>
(.as (array.Array (.I64 .Any)))
- "python array length")
+ .python_array_length#)
(,, (.static @.scheme))
(..bytevector-length [<it>])
@@ -145,7 +145,7 @@
(,, (.static @.python))
(.|> <it>
(.as (array.Array .I64))
- ("python array read" <index>))
+ (.python_array_read# <index>))
(,, (.static @.scheme))
(..bytevector-u8-ref [<it> <index>])
@@ -228,7 +228,7 @@
(.|> <it>
(.is ..Binary)
(.as (array.Array (.I64 .Any)))
- ("python array write" <index> (.|> <value> (.i64_and# <byte>) (.is (.I64 .Any))))
+ (.python_array_write# <index> (.|> <value> (.i64_and# <byte>) (.is (.I64 .Any))))
(.as ..Binary))
(,, (.static @.scheme))
diff --git a/stdlib/source/unsafe/lux/data/collection/array.lux b/stdlib/source/unsafe/lux/data/collection/array.lux
index c8c98508c..8c1d0ce47 100644
--- a/stdlib/source/unsafe/lux/data/collection/array.lux
+++ b/stdlib/source/unsafe/lux/data/collection/array.lux
@@ -46,7 +46,7 @@
(.is (..Array <item_type>)))
(,, (.static @.js)) ("js array new" size)
- (,, (.static @.python)) ("python array new" size)
+ (,, (.static @.python)) (.python_array_new# size)
(,, (.static @.lua)) ("lua array new" size)
(,, (.static @.ruby)) ("ruby array new" size)
(,, (.static @.php)) ("php array new" size)
@@ -69,7 +69,7 @@
(.as .Nat))
(,, (.static @.js)) ("js array length" array)
- (,, (.static @.python)) ("python array length" array)
+ (,, (.static @.python)) (.python_array_length# array)
(,, (.static @.lua)) ("lua array length" array)
(,, (.static @.ruby)) ("ruby array length" array)
(,, (.static @.php)) ("php array length" array)
@@ -96,7 +96,7 @@
.jvm_object_null?#)
(,, (.static @.js)) (,, (lacks?' "js array read" "js object undefined?" index array))
- (,, (.static @.python)) (,, (lacks?' "python array read" "python object none?" index array))
+ (,, (.static @.python)) (,, (lacks?' .python_array_read# .python_object_none?# index array))
(,, (.static @.lua)) (,, (lacks?' "lua array read" "lua object nil?" index array))
(,, (.static @.ruby)) (,, (lacks?' "ruby array read" "ruby object nil?" index array))
(,, (.static @.php)) (,, (lacks?' "php array read" "php object null?" index array))
@@ -121,7 +121,7 @@
(.jvm_array_read_object# (,, (jvm_int index)) array)
(,, (.static @.js)) ("js array read" index array)
- (,, (.static @.python)) ("python array read" index array)
+ (,, (.static @.python)) (.python_array_read# index array)
(,, (.static @.lua)) ("lua array read" index array)
(,, (.static @.ruby)) ("ruby array read" index array)
(,, (.static @.php)) ("php array read" index array)
@@ -142,7 +142,7 @@
.as_expected)
(,, (.static @.js)) ("js array write" index (.as_expected value) array)
- (,, (.static @.python)) ("python array write" index (.as_expected value) array)
+ (,, (.static @.python)) (.python_array_write# index (.as_expected value) array)
(,, (.static @.lua)) ("lua array write" index (.as_expected value) array)
(,, (.static @.ruby)) ("ruby array write" index (.as_expected value) array)
(,, (.static @.php)) ("php array write" index (.as_expected value) array)
@@ -163,7 +163,7 @@
(..has! index (.as_expected (is <item_type> (.jvm_object_null#))) array)
(,, (.static @.js)) ("js array delete" index array)
- (,, (.static @.python)) ("python array delete" index array)
+ (,, (.static @.python)) (.python_array_delete# index array)
(,, (.static @.lua)) ("lua array delete" index array)
(,, (.static @.ruby)) ("ruby array delete" index array)
(,, (.static @.php)) ("php array delete" index array)