diff --git a/documentation/bookmark/business/hiring.md b/documentation/bookmark/business/hiring.md index 75ea8b833e..53f5888879 100644 --- a/documentation/bookmark/business/hiring.md +++ b/documentation/bookmark/business/hiring.md @@ -1,5 +1,6 @@ # Reference +0. [Those jobs you’re applying to? They might not be real](https://www.marketplace.org/2024/01/03/those-jobs-youre-applying-to-they-might-not-be-real/) 0. [Draft: Matching ideas & upcoming talents](https://www.draftcommunity.xyz/) 0. [Spotting Talent: A new book offers surprising insights into the traits of outstanding people.](https://www.city-journal.org/spotting-talent) 0. [Talent: How to Identify Energizers, Creatives, and Winners Around the World](https://www.amazon.com/Talent-Identify-Energizers-Creatives-Winners/dp/1250275814/) diff --git a/documentation/bookmark/business/metric.md b/documentation/bookmark/business/metric.md new file mode 100644 index 0000000000..539f404986 --- /dev/null +++ b/documentation/bookmark/business/metric.md @@ -0,0 +1,4 @@ +# Reference + +0. [16 Startup Metrics](https://a16z.com/16-startup-metrics/) + diff --git a/documentation/bookmark/css.md b/documentation/bookmark/css.md index 5a425976ae..80c47a3b90 100644 --- a/documentation/bookmark/css.md +++ b/documentation/bookmark/css.md @@ -4,6 +4,7 @@ # Reference +0. [Flexbugs: A community-curated list of flexbox issues and cross-browser workarounds for them](https://github.com/philipwalton/flexbugs) 0. [StyleX](https://stylexjs.com/) 0. [Introducing StyleX](https://stylexjs.com/blog/introducing-stylex/) 0. [CSS Hooks: Inline styles doing what we thought they couldn't](https://css-hooks.com/) diff --git a/documentation/bookmark/design/ui__user_interface/human_computer_interaction.md b/documentation/bookmark/design/ui__user_interface/hci__human_computer_interaction.md similarity index 87% rename from documentation/bookmark/design/ui__user_interface/human_computer_interaction.md rename to documentation/bookmark/design/ui__user_interface/hci__human_computer_interaction.md index 23cedd37b9..122bd06c05 100644 --- a/documentation/bookmark/design/ui__user_interface/human_computer_interaction.md +++ b/documentation/bookmark/design/ui__user_interface/hci__human_computer_interaction.md @@ -1,6 +1,6 @@ # Reference -0. []() +0. [Fitts's law](https://en.wikipedia.org/wiki/Fitts%27s_law) 0. [Smarter Defaults by Paying Attention](https://textslashplain.com/2022/02/15/smarter-defaults-by-paying-attention/) 0. [Formality Considered Harmful: Experiences, Emerging Themes, and Directions on the Use of Formal Representations in Interactive Systems](https://andymatuschak.org/files/papers/Shipman%20and%20Marshall%20-%201999%20-%20Formality%20Considered%20Harmful%20Experiences,%20Emergin.pdf) diff --git a/documentation/bookmark/ecology.md b/documentation/bookmark/ecology.md index ecbd032359..d7bcce7350 100644 --- a/documentation/bookmark/ecology.md +++ b/documentation/bookmark/ecology.md @@ -1,5 +1,7 @@ # Reference +0. [Coastal Risk Screening Tool](https://coastal.climatecentral.org/) +0. [Open Sustainable Technology](https://opensustain.tech/) 0. [POLLUTANT ABSORPTION SYSTEM](https://www.pollutantabsorptionsystem.com/) 0. [Fungi may offer ‘jaw-dropping’ solution to climate change](https://thehill.com/policy/equilibrium-sustainability/4034986-fungi-may-offer-jaw-dropping-solution-to-climate-change/) 0. [Towards sustainable desalination](https://www.unep.org/news-and-stories/story/towards-sustainable-desalination) diff --git a/documentation/bookmark/economics.md b/documentation/bookmark/economics.md new file mode 100644 index 0000000000..ab679f43ed --- /dev/null +++ b/documentation/bookmark/economics.md @@ -0,0 +1,4 @@ +# Reference + +0. [Economic surveillance of EU economies](https://economy-finance.ec.europa.eu/economic-surveillance-eu-economies_en) + diff --git a/documentation/bookmark/health/disease.md b/documentation/bookmark/health/disease.md new file mode 100644 index 0000000000..8d49e6bb0d --- /dev/null +++ b/documentation/bookmark/health/disease.md @@ -0,0 +1,5 @@ +# Reference + +0. [Global Outbreaks](https://preventepidemics.org/map/?=undefined) +0. [Search for a rare disease]https://www.orpha.net/consor/cgi-bin/Disease.php?lng=EN() + diff --git a/documentation/bookmark/math/statistics/index.md b/documentation/bookmark/math/statistics/index.md new file mode 100644 index 0000000000..c35889cd10 --- /dev/null +++ b/documentation/bookmark/math/statistics/index.md @@ -0,0 +1,39 @@ +# Reference + +0. [International Database: World Population Estimates and Projections](https://www.census.gov/programs-surveys/international-programs/about/idb.html) +0. [Purchasing Managers' Index](https://www.pmi.spglobal.com/) +0. [STATE RESILIENCE INDEX: Measuring Capacities and Capabilities In 154 Countries](https://www.fundforpeace.org/SRI/about.html) +0. [](https://www.dashboard-deutschland.de/) +0. [Human Development Index](https://hdr.undp.org/data-center/human-development-index#/indicies/HDI) +0. [InfraTracker](https://infratracker.gihub.org/) +0. [Inflation rate, average consumer prices](https://www.imf.org/external/datamapper/PCPIPCH@WEO/OEMDC) +0. [Trading Economics](https://tradingeconomics.com/indicators) + 0. [](https://tradingeconomics.com/matrix) + 0. [](https://tradingeconomics.com/united-states/calendar) +0. [Global Slavery Index](https://www.walkfree.org/global-slavery-index/map/) +0. [OFR Financial Stress Index](https://www.financialresearch.gov/financial-stress-index/) +0. [Fragile States Index](https://fragilestatesindex.org/) +0. [Global Conflict Tracker](https://www.cfr.org/global-conflict-tracker) +0. [Conflict Forecast](https://conflictforecast.org/) +0. [Corruption Perceptions Index](https://www.transparency.org/en/cpi/2022) +0. [Tax Justice Network](https://taxjustice.net/country-profiles/) +0. [Uppsala Conflict Data Program](https://ucdp.uu.se/encyclopedia) +0. [Water Risk Atlas](https://www.wri.org/applications/aqueduct/water-risk-atlas/#/?advanced=false&basemap=hydro&indicator=w_awr_def_tot_cat&lat=52.802761415419674&lng=-32.43164062500001&mapMode=view&month=1&opacity=0.5&ponderation=DEF&predefined=false&projection=absolute&scenario=optimistic&scope=baseline&threshold&timeScale=annual&year=baseline&zoom=5) +0. [Geopolitical risk dashboard](https://www.blackrock.com/corporate/insights/blackrock-investment-institute/interactive-charts/geopolitical-risk-dashboard) +0. [Armed Conflict Location & Event Data Project (ACLED)](https://acleddata.com/dashboard/#/dashboard) +0. [Global Maritime Traffic](https://globalmaritimetraffic.org/gmtds.html?$root.map.zoom=3&$root.map.center={%22lat%22:-0.08789059053082422,%22lng%22:0}&$root.projectionSelect=%22EPSG:3857%22) +0. [Global Energy Monitor](https://globalenergymonitor.org/) +0. [Population Density Explorer](https://populationexplorer.org/) +0. [Energy Statistics Data Browser](https://www.iea.org/data-and-statistics/data-tools/energy-statistics-data-browser?country=WORLD&fuel=Energy%20supply&indicator=TESbySource) +0. [ND-GAIN Country Index](https://gain.nd.edu/our-work/country-index/rankings/) +0. [Productive Capacities Index](https://unctadstat.unctad.org/EN/Pci.html) +0. [water, peace and Security](https://waterpeacesecurity.org/map) +0. [Global Organized Crime Index](https://ocindex.net/) +0. [Global Terrorism Index](https://www.visionofhumanity.org/maps/global-terrorism-index/#/) +0. [Global Peace Index](https://www.visionofhumanity.org/maps/#/) +0. [Ecological Threat Report](https://www.visionofhumanity.org/maps/ecological-threat-report/#/) +0. [Mexico Peace Index](https://www.visionofhumanity.org/maps/mexico-peace-index/#/) +0. [Positive Peace Index](https://www.visionofhumanity.org/maps/positive-peace-index/#/) +0. [US Peace Index](https://www.visionofhumanity.org/maps/us-peace-index/#/) +0. [UK Peace Index](https://www.visionofhumanity.org/maps/uk-peace-index/#/) + diff --git a/documentation/bookmark/media/podcast.md b/documentation/bookmark/media/podcast.md new file mode 100644 index 0000000000..8c359668bc --- /dev/null +++ b/documentation/bookmark/media/podcast.md @@ -0,0 +1,4 @@ +# Reference + +0. [Erik Torenberg on the Evolution of Media](https://www.youtube.com/watch?v=beR7vqtW_X4) + diff --git a/documentation/bookmark/music.md b/documentation/bookmark/music.md index 11d9c4f4da..613148c9b5 100644 --- a/documentation/bookmark/music.md +++ b/documentation/bookmark/music.md @@ -8,6 +8,7 @@ # Reference +0. [What's the difference between 3/4 and 6/8 time?](https://www.youtube.com/watch?v=N4q2kBe82-o) 0. [F2P, a new business model for music.](https://danfowler.substack.com/p/f2p-a-new-business-model-for-music) 0. [](https://oscilloscopemusic.com/) 0. [Introduction to Music (Theory)](https://soundcloud.com/languagetransfer/sets/introduction-to-music-theory) diff --git a/documentation/bookmark/news.md b/documentation/bookmark/news.md new file mode 100644 index 0000000000..9a7e81e51f --- /dev/null +++ b/documentation/bookmark/news.md @@ -0,0 +1,5 @@ +# Reference + +0. [EMM News Explorer: News analysis, across languages and over time](http://emm.newsexplorer.eu/) +0. [GDELT Project](https://www.gdeltproject.org/) + diff --git a/documentation/bookmark/science.md b/documentation/bookmark/science.md index 625f758637..e62eee2de7 100644 --- a/documentation/bookmark/science.md +++ b/documentation/bookmark/science.md @@ -1,4 +1,5 @@ # Reference +0. [Invisible College](https://invisible.college/) 0. [Beware the Man of Many Studies: Low-quality literatures mean meta-analyses are frequently worse than single studies](https://cremieux.substack.com/p/beware-the-man-of-many-studies) diff --git a/documentation/bookmark/security/privacy.md b/documentation/bookmark/security/privacy.md index 3aa0051a43..c94b30d567 100644 --- a/documentation/bookmark/security/privacy.md +++ b/documentation/bookmark/security/privacy.md @@ -1,5 +1,6 @@ # Reference +0. [NO2DIGITALID](https://bigbrotherwatch.org.uk/campaigns/no2digitalid/) 0. [Choose your browser carefully](https://www.unixsheikh.com/articles/choose-your-browser-carefully.html) 0. ["Demystifying Privacy Preserving Computing" by Tejas Chopra (Strange Loop 2022)](https://www.youtube.com/watch?v=10Qj0eYqbuo) 0. [Mullvad Browser](https://mullvad.net/en/browser) diff --git a/documentation/bookmark/tool/text_editor.md b/documentation/bookmark/tool/text_editor.md index be7bb673f5..8cce077861 100644 --- a/documentation/bookmark/tool/text_editor.md +++ b/documentation/bookmark/tool/text_editor.md @@ -193,6 +193,7 @@ ## General +0. [Byte Positions Are Better Than Line Numbers](https://www.computerenhance.com/p/byte-positions-are-better-than-line) 0. [Lesser Known Terminal Editors](https://codeberg.org/CoopCoding/Lesser-Known-Terminal-Editors) 0. [Gamut: The Idea Editor](https://gamut.ink/) 0. [How to Build a Text Editor With Java](https://www.youtube.com/playlist?list=PLIRBoI92yManB1eHCupZ6iG61qMTA9hWe) diff --git a/documentation/bookmark/transparency.md b/documentation/bookmark/transparency.md new file mode 100644 index 0000000000..89e0e90124 --- /dev/null +++ b/documentation/bookmark/transparency.md @@ -0,0 +1,4 @@ +# Reference + +0. [Supreme Connections](https://projects.propublica.org/supreme-connections/) + diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index b511ea822f..fa4b42bfe0 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -348,18 +348,25 @@ Called by `imenu--generic-function'." (defconst lux-font-lock-keywords (eval-when-compile (let* ((natural "[0-9][0-9,]*") + + (sign (altRE "-" "\\+")) + (integer (concat sign natural)) + + (decimal_separator "\\.") + (revolution (concat decimal_separator natural)) + (decimal (concat integer revolution "\\(\\(e\\|E\\)" integer "\\)?")) + + (fraction_separator "/") + (fraction (concat natural fraction_separator natural)) + (rational (concat integer fraction_separator natural)) + (identifier_h|label "#") (identifier_h|type "[:upper:]") ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Special.html (identifier_t "][)(}{.\"[:space:]") (identifier_h (concat identifier_t "0-9")) - (sign (altRE "-" "\\+")) (identifier (concat (-class identifier_h) (-class identifier_t) "*")) - (integer (concat sign natural)) (bitRE (literal (altRE "#0" "#1"))) - (natRE (literal natural)) - (int&decRE (literal (concat integer "\\(\\." natural "\\(\\(e\\|E\\)" integer "\\)?\\)?"))) - (revRE (literal (concat "\\." natural))) (specialRE (let (;; Control (control//flow (altRE "when" "exec" "let" "loop" "do" "be" "if" "unless")) @@ -455,9 +462,12 @@ Called by `imenu--generic-function'." (typeRE (concat global_prefix (+class identifier_h|type) (-class identifier_t) "*")) (labelRE (concat global_prefix (+class identifier_h|label) (-class identifier_t) "+")) (literalRE (altRE bitRE ;; Bit literals - natRE ;; Nat literals - int&decRE ;; Int literals && Dec literals - revRE ;; Rev literals + (literal natural) + (literal integer) + (literal revolution) + (literal decimal) + (literal fraction) + (literal rational) ))) `(;; Special forms (,specialRE 1 font-lock-builtin-face) diff --git a/stdlib/source/library/lux/math/number/fraction.lux b/stdlib/source/library/lux/math/number/fraction.lux index 29c4a6afb9..452ebe304a 100644 --- a/stdlib/source/library/lux/math/number/fraction.lux +++ b/stdlib/source/library/lux/math/number/fraction.lux @@ -66,8 +66,8 @@ (the .public fraction (syntax.macro (_ [numerator .any ?denominator (<>.maybe .any)]) - (in (list (` (normal [..#numerator (, numerator) - ..#denominator (, (maybe.else (' 1) ?denominator))])))))) + (in (list (` (..normal [..#numerator (, numerator) + ..#denominator (, (maybe.else (' 1) ?denominator))])))))) (the .public (= parameter subject) (-> It It @@ -171,7 +171,8 @@ [..#numerator /#denominator ..#denominator /#numerator]) -(the separator "/") +(the .public separator + "/") (the .public (as_text (open "/[0]")) (text.Injection It) @@ -338,3 +339,6 @@ (if (..< standard value) (..- value standard) (..- standard value)))))) + +(the .public extension + "fraction#") diff --git a/stdlib/source/library/lux/math/number/rational.lux b/stdlib/source/library/lux/math/number/rational.lux index 052bebf932..a8b6ad95b7 100644 --- a/stdlib/source/library/lux/math/number/rational.lux +++ b/stdlib/source/library/lux/math/number/rational.lux @@ -32,6 +32,7 @@ ["//" integer (.use "[1]#[0]" base_10)] ["d" decimal] ["[0]" natural (.use "[1]#[0]" base_10)] + ["[0]" fraction] [// [arithmetic (.only Arithmetic)] ["[0]" unit]]]) @@ -180,7 +181,8 @@ (the * ..*) (the / ../))) -(the separator "/") +(the .public separator + fraction.separator) (the .public (as_text (open "/[0]")) (text.Injection It) @@ -376,3 +378,6 @@ (..- standard) ..absolute (..< margin_of_error))))) + +(the .public extension + "rational#") diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux index 56553c312b..3e5bfa8a93 100644 --- a/stdlib/source/library/lux/meta/compiler/default/platform.lux +++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux @@ -634,7 +634,7 @@ phase.Wrapper (Extender ) Expander Text (Maybe Module) (//init.Extensions ) (///.Compiler .Module))) - (let [instancer (//init.compiler program global phase_wrapper extender expander syntax.prelude (its #write platform) program_module program_definition + (let [instancer (//init.compiler program global phase_wrapper extender expander .prelude (its #write platform) program_module program_definition all_extensions)] (instancer $.key (list)))) 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 e9ff335e1c..09286778a4 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 @@ -20,7 +20,9 @@ ["[0]" dictionary (.only Dictionary)]]] [math [number - ["n" natural]]] + ["n" natural] + ["[0]" fraction] + ["[0]" rational]]] ["[0]" meta (.only) ["[0]" module] ["[0]" binding] @@ -30,7 +32,8 @@ ["[0]" code ["?[1]" \\projection (.only Projection)]] [macro - ["^" pattern]] + ["^" pattern] + ["[0]" template]] ["[0]" type (.only) ["[0]" check]]]]] ["[0]" /// (.only) @@ -364,6 +367,25 @@ (.function (_ extension_name phase archive [function_name arg_name body]) (function.function phase function_name arg_name archive body))])) +(template.with [,name ,type ,normal ,numerator_projection ,numerator_analysis] + [(the ,name + (-> Text Handler) + (..custom + [(all ?.and + ,numerator_projection + ?code.natural) + (.function (_ extension_name phase archive [numerator denominator]) + (do phase.monad + [.let [[numerator denominator] (,normal [numerator denominator])] + _ (typeA.inference ,type) + @ meta.location] + (in (analysis.tuple @ (list (,numerator_analysis @ numerator) + (analysis.natural @ denominator))))))]))] + + [fraction fraction.Number fraction.normal ?code.natural analysis.natural] + [rational rational.Number rational.normal ?code.integer analysis.integer] + ) + (the with_basic_extensions (-> Bundle Bundle) @@ -375,7 +397,10 @@ (install "global#" ..global) (install "universe#" ..universe) (install "when#" ..when) - (install "function#" ..function))) + (install "function#" ..function) + + (install fraction.extension ..fraction) + (install rational.extension ..rational))) (the with_io_extensions (-> Bundle 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 8bc80b44bc..ed904acd5f 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 @@ -26,6 +26,7 @@ [target [jvm ["_" bytecode (.only Label Bytecode) (.use "[1]#[0]" monad)] + ["[0]" constant] [encoding ["[0]" signed (.only S4)]] ["[0]" type (.only Type) @@ -375,7 +376,7 @@ parts (do [! _.monad] - [_ (_.int (.i64 +0)) + [_ (_.int (constant.integer (.i64 +0))) _ (monad.each ! (is (-> (Bytecode Any) (Bytecode Any)) (function (_ it) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux index 664c83c382..5e51d82189 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux @@ -40,7 +40,7 @@ ["[0]" modifier (.use "[1]#[0]" monoid)] ["[0]" method (.only Method)] ["[0]" class (.only Class)] - [constant + ["[0]" constant (.only) [pool (.only Resource)]] [encoding ["[0]" name]] @@ -258,7 +258,7 @@ actual expected - (_.int (i32.i32 (.i64 ))) + (_.int (constant.integer (i32.i32 (.i64 )))) (_.if_icmpeq @then) falseG (_.goto @end) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux index 03b8f4ce9a..d25ca93dd3 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux @@ -20,6 +20,7 @@ [target [jvm ["_" bytecode (.only Bytecode)] + ["[0]" constant] ["[0]" type] [encoding ["[0]" signed]]]]]]]] @@ -53,7 +54,7 @@ (_.sipush value) {try.#Failure _} - (_.int (.i64 lefts)))))) + (_.int (constant.integer (.i64 lefts))))))) (the .public (right? right?) (-> Bit @@ -94,10 +95,10 @@ [memberI (phase archive member)] (in (do _.monad [_ _.dup - _ (_.int (.i64 idx)) + _ (_.int (constant.integer (.i64 idx))) _ memberI] _.aastore))))))] (in (do [! _.monad] - [_ (_.int (.i64 (list.size membersS))) + [_ (_.int (constant.integer (.i64 (list.size membersS)))) _ (_.anewarray //type.value)] (monad.all ! membersI)))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/apply.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/apply.lux index ad568c461a..f08057fdc4 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/apply.lux @@ -21,6 +21,7 @@ [target [jvm ["_" bytecode (.only Label Bytecode) (.use "[1]#[0]" monad)] + ["[0]" constant] ["[0]" method (.only Method)] [constant [pool (.only Resource)]] @@ -56,7 +57,7 @@ (-> Natural (Bytecode Any)) (all _.composite - (<| _.int .i64 by) + (<| _.int constant.integer .i64 by) _.iadd)) (the (inputs offset amount) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/runtime.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/runtime.lux index ee662d5191..1768dee6e6 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/runtime.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/runtime.lux @@ -300,7 +300,7 @@ super_nested_lefts (all _.composite _.swap _.isub - (_.int (i32.i32 (.i64 +1))) + (_.int (constant.integer (i32.i32 (.i64 +1)))) _.isub) super_nested (all _.composite ... lefts, sumT @@ -315,7 +315,7 @@ _.astore_0) update_$lefts (all _.composite _.isub - (_.int (i32.i32 (.i64 +1))) + (_.int (constant.integer (i32.i32 (.i64 +1)))) _.isub) again (is (-> Label (Bytecode Any)) (function (_ @) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux index 477db62c1c..47570a8b4d 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux @@ -21,6 +21,7 @@ [target [jvm ["_" bytecode (.only Label Bytecode) (.use "[1]#[0]" monad)] + ["[0]" constant] ["[0]" type (.only Type) [category (.only Method)]]]]]]]] ["[0]" // @@ -53,7 +54,7 @@ (the int (-> (I64 Any) (Bytecode Any)) - (|>> .i64 i32.i32 _.int)) + (|>> .i64 i32.i32 constant.integer _.int)) (the long (-> (I64 Any) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/meta/compiler/language/lux/syntax.lux index 85ea00471e..c12ce116c6 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/syntax.lux @@ -29,7 +29,7 @@ ... location, which is helpful for documentation and debugging. (.using [library - [lux (.except prelude) + [lux (.except) [abstract [monad (.only do)]] [control @@ -56,7 +56,9 @@ ["n" natural] ["[0]" integer] ["[0]" revolution] - ["[0]" decimal]]]]]) + ["[0]" decimal] + ["[0]" fraction] + ["[0]" rational]]]]]) (the declaration_name (syntax.macro (_ [[name parameters] (.form (<>.and .any (<>.some .any)))]) @@ -84,16 +86,13 @@ ... producing the locations only involved building them, without any need ... for pattern-matching and de-structuring. -(every Character - Natural) - (template.with [ ] [(the (template.macro (_ value) [( value)]))] - [.i64_+# 1 !++] - [.i64_+# 2 !++/2] + [.i64_+# 1 after] + [.i64_+# 2 after/2] [.i64_-# 1 !--] ) @@ -126,9 +125,6 @@ Aliases (dictionary.empty text.hash)) -(the .public prelude - .prelude) - (the .public text_delimiter text.double_quote) (template.with [ ] @@ -229,13 +225,13 @@ (the !horizontal (template.macro (_ where offset source_code) [[(revised .#column ++ where) - (!++ offset) + (after offset) source_code]])) (inlined (!new_line where) (-> Location Location) (let [[where::file where::line where::column] where] - [where::file (!++ where::line) 0])) + [where::file (after where::line) 0])) (inlined (!forward length where) (-> Natural Location Location) @@ -245,18 +241,18 @@ (the !vertical (template.macro (_ where offset source_code) [[(!new_line where) - (!++ offset) + (after offset) source_code]])) (template.with [ ] [(inlined ( parse where offset source_code) (-> (Projection Code) Location Offset Text (Either [Source Text] [Source Code])) - (loop (again [source (is Source [(!forward 1 where) offset source_code]) - stack (is (List Code) {.#End})]) + (loop ( [source (is Source [(!forward 1 where) offset source_code]) + stack (is (List Code) {.#End})]) (when (parse source) {.#Right [source' top]} - (again source' {.#Item top stack}) + ( source' {.#Item top stack}) {.#Left [source' error]} (if (same? error) @@ -278,22 +274,22 @@ {.#None} body - g!_ + '_ {.#Left [[where offset source_code] (exception.error ..text_cannot_contain_new_lines content)]})])) (the (text_projection where offset source_code) (-> Location Offset Text (Either [Source Text] [Source Code])) (when (.text_index# offset (static ..text_delimiter) source_code) - {.#Some g!end} - (<| (let [g!content (!clip offset g!end source_code)]) - (!guarantee_no_new_lines where offset source_code g!content) - {.#Right [[(let [size (!n/- offset g!end)] + {.#Some 'end} + (<| (let ['content (!clip offset 'end source_code)]) + (!guarantee_no_new_lines where offset source_code 'content) + {.#Right [[(let [size (!n/- offset 'end)] (revised .#column (|>> (!n/+ size) (!n/+ 2)) where)) - (!++ g!end) + (after 'end) source_code] [where - {.#Text g!content}]]}) + {.#Text 'content}]]}) _ (!failure ..text_projection where offset source_code))) @@ -349,6 +345,23 @@ @then)])))) ) +(the !value_output + (template.macro (_ ,where ) + [(when (|> + (!clip ) + (text.replaced ..digit_separator "") + (of projection)) + {.#Right output} + {.#Right [[(let [[where::file where::line where::column] ,where] + [where::file where::line (!n/+ (!n/- ) where::column)]) + + ] + output]} + + {.#Left error} + {.#Left [[,where ] + error]})])) + (the !number_output (template.macro (_ ) [(when (|> @@ -374,6 +387,7 @@ (these (!number_output source_code start end decimal.base_10 .#Decimal)) (!failure ..decimal_projection where offset source_code) (static ..decimal_separator) + ,rational_separator (static rational.separator) (template.with [] [(,, (static ))] @@ -386,11 +400,11 @@ exponent (static ..no_exponent)]) (<| (!with_character+ source_code//size source_code end character/0 ) (!if_digit?+ character/0 - (again (!++ end) exponent) + (again (after end) exponent) [["e" "E"] (if (same? (static ..no_exponent) exponent) - (<| (!with_character+ source_code//size source_code (!++ end) character/1 ) + (<| (!with_character+ source_code//size source_code (after end) character/1 ) (`` (.when_char# character/1 [[] (<| (!with_character+ source_code//size source_code (!n/+ 2 end) character/2 ) @@ -404,42 +418,94 @@ )))) + (inlined (as_rational where numerator denominator) + (-> Location Integer Natural + Code) + [where {.#Form (list [where {.#Symbol [.prelude rational.extension]}] + [where {.#Integer numerator}] + [where {.#Natural denominator}])}]) + + (inlined (rational numerator source_code//size denominator_start where source_code) + (-> Integer Natural Natural Location Text + (Either [Source Text] [Source Code])) + (<| (!letE [[where' denominator_end _] denominator] (..natural_projection source_code//size denominator_start where denominator_start source_code)) + {.#Right [[where' denominator_end source_code] + (as_rational where numerator denominator)]})) + (inlined (signed_projection source_code//size start where offset source_code) (-> Natural Natural Location Offset Text (Either [Source Text] [Source Code])) (loop (again [end offset]) (<| (!with_character+ source_code//size source_code end character ) (!if_digit?+ character - (again (!++ end)) + (again (after end)) [[] - (decimal_projection source_code//size start where (!++ end) source_code)] + (decimal_projection source_code//size start where (after end) source_code) - ))))) - ) + [,rational_separator] + (!letE [_ numerator] (..!value_output where source_code start end integer.base_10) + (..rational numerator source_code//size (after end) where source_code))] + + )))) + )) (template.with [ ] [(inlined ( source_code//size start where offset source_code) (-> Natural Natural Location Offset Text (Either [Source Text] [Source Code])) - (loop (again [g!end offset]) - (<| (!with_character+ source_code//size source_code g!end g!character (!number_output source_code start g!end )) - (!if_digit?+ g!character - (again (!++ g!end)) + (loop ( ['end offset]) + (<| (!with_character+ source_code//size source_code 'end 'character (!number_output source_code start 'end )) + (!if_digit?+ 'character + ( (after 'end)) [] - (!number_output source_code start g!end )))))] + (!number_output source_code start 'end )))))] - [natural_projection n.base_10 .#Natural] [revolution_projection revolution.base_10 .#Revolution] ) +(inlined (natural_projection source_code//size start where offset source_code) + (-> Natural Natural Location Offset Text + (Either [Source Text] [Source Nat])) + (loop (next ['end offset]) + (<| (!with_character+ source_code//size source_code 'end 'character (!value_output where source_code start 'end n.base_10)) + (!if_digit?+ 'character + (next (after 'end)) + [] + (!value_output where source_code start 'end n.base_10))))) + +(inlined (as_fraction where numerator denominator) + (-> Location Natural Natural + Code) + [where {.#Form (list [where {.#Symbol [.prelude fraction.extension]}] + [where {.#Natural numerator}] + [where {.#Natural denominator}])}]) + +(inlined (fraction numerator source_code//size denominator_start where source_code) + (-> Natural Natural Natural Location Text + (Either [Source Text] [Source Code])) + (<| (!letE [[where' denominator_end _] denominator] (..natural_projection source_code//size denominator_start where denominator_start source_code)) + {.#Right [[where' denominator_end source_code] + (as_fraction where numerator denominator)]})) + +(inlined (positive source_code//size start where offset source_code) + (-> Natural Natural Location Offset Text + (Either [Source Text] [Source Code])) + (<| (!letE [[where' numerator_end _] numerator] (..natural_projection source_code//size start where offset source_code)) + (expansion.let [,natural (!number_output source_code start numerator_end n.base_10 .#Natural)]) + (!with_character source_code numerator_end potential_separator ,natural) + (if (!n/= (`` (character (,, (static fraction.separator)))) + potential_separator) + (..fraction numerator source_code//size (after numerator_end) where' source_code) + ,natural))) + (the !signed_projection (template.macro (_ source_code//size offset where source_code @aliases @end) - [(<| (let [g!offset/1 (!++ offset)]) - (!with_character+ source_code//size source_code g!offset/1 g!character/1 @end) - (!if_digit? g!character/1 - (signed_projection source_code//size offset where (!++/2 offset) source_code) - (!full_symbol_projection offset [where (!++ offset) source_code] where @aliases .#Symbol)))])) + [(<| (let ['offset/1 (after offset)]) + (!with_character+ source_code//size source_code 'offset/1 'character/1 @end) + (!if_digit? 'character/1 + (signed_projection source_code//size offset where (after/2 offset) source_code) + (!full_symbol_projection offset [where (after offset) source_code] where @aliases .#Symbol)))])) (expansion.let [ {.#Right [[(revised .#column (|>> (!n/+ (!n/- start end))) where) end @@ -452,13 +518,13 @@ (loop (again [end offset]) (<| (!with_character+ source_code//size source_code end character ) (!if_symbol_character?|tail character - (again (!++ end)) + (again (after end)) )))))) (the !half_symbol_projection (template.macro (_ @offset @character @module) [(!if_symbol_character?|head @character - (!letE [source' symbol] (..symbol_part_projection @offset (!forward 1 where) (!++ @offset) source_code) + (!letE [source' symbol] (..symbol_part_projection @offset (!forward 1 where) (after @offset) source_code) {.#Right [source' [@module symbol]]}) (!failure ..!half_symbol_projection where @offset source_code))])) @@ -467,11 +533,11 @@ (<| (!with_character+ source_code//size source_code offset/0 character/0 (!end_of_file where offset/0 source_code current_module)) (if (!n/= (character (,, (static ..symbol_separator))) character/0) - (<| (let [offset/1 (!++ offset/0)]) + (<| (let [offset/1 (after offset/0)]) (!with_character+ source_code//size source_code offset/1 character/1 (!end_of_file where offset/1 source_code current_module)) (!half_symbol_projection offset/1 character/1 current_module)) - (!half_symbol_projection offset/0 character/0 (static ..prelude)))))) + (!half_symbol_projection offset/0 character/0 (static .prelude)))))) (the !short_symbol_projection (template.macro (_ source_code//size @current_module @source @where @tag) @@ -486,7 +552,7 @@ (let [[where' offset' source_code'] source']) (!with_character source_code' offset' character/separator ) (if (!n/= (character (,, (static ..symbol_separator))) character/separator) - (<| (let [offset'' (!++ offset')]) + (<| (let [offset'' (after offset')]) (!letE [source'' complex] (..symbol_part_projection offset'' (!forward 1 where') offset'' source_code')) (if (.text_=# "" complex) (let [[where offset source_code] source] @@ -507,9 +573,9 @@ ... (grammar [expression "..."] ... [form "(" [#* expression] ")"])) -(expansion.let [ (these where (!++ offset/0) source_code) - (these [(!forward 1 where) (!++ offset/0) source_code]) - (these [(!forward 1 where) (!++/2 offset/0) source_code]) +(expansion.let [ (these where (after offset/0) source_code) + (these [(!forward 1 where) (after offset/0) source_code]) + (these [(!forward 1 where) (after/2 offset/0) source_code]) (these (parse current_module aliases source_code//size))] (these (the !close @@ -518,8 +584,8 @@ (the (bit_syntax value [where offset/0 source_code]) (-> Bit (Projection Code)) - {.#Right [[(revised .#column (|>> !++/2) where) - (!++/2 offset/0) + {.#Right [[(revised .#column (|>> after/2) where) + (after/2 offset/0) source_code] [where {.#Bit value}]]}) @@ -556,22 +622,22 @@ ... Text [(,, (static ..text_delimiter))] - (text_projection where (!++ offset/0) source_code) + (text_projection where (after offset/0) source_code) ... Coincidentally (= ..symbol_separator ..decimal_separator) [(,, (static ..symbol_separator)) ... (,, (static ..decimal_separator)) ] ... It's either a Revolution, a symbol, or a comment. - (expansion.let [ (revolution_projection source_code//size offset/0 where (!++ offset/1) source_code) + (expansion.let [ (revolution_projection source_code//size offset/0 where (after offset/1) source_code) (!short_symbol_projection source_code//size current_module [where offset/1 source_code] where .#Symbol) - (when (.text_index# (!++ offset/1) (static text.new_line) source_code) + (when (.text_index# (after offset/1) (static text.new_line) source_code) {.#Some end} (again (!vertical where end source_code)) _ (!end_of_file where offset/1 source_code current_module))] - (<| (let [offset/1 (!++ offset/0)]) + (<| (let [offset/1 (after offset/0)]) (!with_character+ source_code//size source_code offset/1 character/1 (!end_of_file where offset/1 source_code current_module)) (!if_digit? character/1 @@ -581,7 +647,7 @@ (.when_char# character/1 [[(,, (static ..symbol_separator))] ... It's either a symbol, or a comment. - (<| (let [offset/2 (!++ offset/1)]) + (<| (let [offset/2 (after offset/1)]) (!with_character+ source_code//size source_code offset/2 character/2 (!end_of_file where offset/2 source_code current_module)) (.when_char# character/2 @@ -599,7 +665,7 @@ (!end_of_file where offset/0 source_code current_module)) [(,, (static ..sigil))] - (<| (let [offset/1 (!++ offset/0)]) + (<| (let [offset/1 (after offset/0)]) (!with_character+ source_code//size source_code offset/1 character/1 (!end_of_file where offset/1 source_code current_module)) (.when_char# character/1 @@ -616,7 +682,7 @@ ... else (!if_digit? character/0 ... Natural number - (natural_projection source_code//size offset/0 where (!++ offset/0) source_code) + (..positive source_code//size offset/0 where (after offset/0) source_code) ... Symbol (!full_symbol_projection offset/0 [] where aliases .#Symbol)) ))) diff --git a/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux b/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux index a4c76286e6..abd267cda7 100644 --- a/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux @@ -638,8 +638,8 @@ {try.#Failure _} (..bytecode $0 $1 @_ [index])))))))] - [int //constant/integer.Integer //constant/pool.integer _.ldc_w/integer - (<| .integer i32.i64) + [int //constant.Integer //constant/pool.integer _.ldc_w/integer + (<| .integer i32.i64 //constant.value) [[-1 _.iconst_m1] [+0 _.iconst_0] [+1 _.iconst_1] diff --git a/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode/instruction.lux index 05e77f0c23..571bcd6399 100644 --- a/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode/instruction.lux @@ -541,7 +541,7 @@ [["10" bipush [[byte S1]] [byte]]]] [..unary/2 - [["13" ldc_w/integer [[index (Index Integer)]] [(///index.value index)]] + [["13" ldc_w/integer [[index (Index ///constant.Integer)]] [(///index.value index)]] ["13" ldc_w/float [[index (Index ///constant.Float)]] [(///index.value index)]] ["13" ldc_w/string [[index (Index ///constant.String)]] [(///index.value index)]] ["14" ldc2_w/long [[index (Index ///constant.Long)]] [(///index.value index)]] diff --git a/stdlib/source/library/lux/meta/compiler/target/jvm/constant.lux b/stdlib/source/library/lux/meta/compiler/target/jvm/constant.lux index 02fed6cba4..9ec1026c6c 100644 --- a/stdlib/source/library/lux/meta/compiler/target/jvm/constant.lux +++ b/stdlib/source/library/lux/meta/compiler/target/jvm/constant.lux @@ -35,7 +35,7 @@ ["[0]" class (.only Class)] ["[0]" name_and_type (.only Name_And_Type)] ["[0]" reference (.only Reference)] - ["[1][0]" integer (.only Integer)] + ["[1][0]" integer] ["/[1]" // ["[1][0]" index (.only Index)] [type @@ -84,6 +84,7 @@ (-> ) (|>> nominal.abstraction))] + [integer Integer /integer.Integer] [float Float java/lang/Float] [long Long .Integer] [double Double Decimal] @@ -97,6 +98,7 @@ (,, (template.spliced )) (,, (template.spliced )))))] + [integer_injection Integer [] [/integer.as_binary]] [float_injection Float [[] java/lang/Float::floatToRawIntBits ffi.of_int .i64] [i32.i32 binaryF.bits_32]] [long_injection Long [] [binaryF.bits_64]] [double_injection Double [[] java/lang/Double::doubleToRawLongBits ffi.of_long] [binaryF.bits_64]] @@ -140,7 +142,7 @@ (of = expected actual)] [#UTF8 text.equivalence] - [#Integer /integer.equivalence] + [#Integer (..value_equivalence /integer.equivalence)] [#Long (..value_equivalence integer.equivalence)] [#Float (..value_equivalence float_equivalence)] [#Double (..value_equivalence decimal.equivalence)] @@ -181,7 +183,7 @@ (the .public injection (Injection Constant) (expansion.let [ (these [#UTF8 /tag.utf8 /utf8.injection] - [#Integer /tag.integer /integer.as_binary] + [#Integer /tag.integer ..integer_injection] [#Float /tag.float ..float_injection] [#Long /tag.long ..long_injection] [#Double /tag.double ..double_injection] diff --git a/stdlib/source/library/lux/meta/compiler/target/jvm/constant/pool.lux b/stdlib/source/library/lux/meta/compiler/target/jvm/constant/pool.lux index 726d8cbf5d..f12b816e84 100644 --- a/stdlib/source/library/lux/meta/compiler/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/meta/compiler/target/jvm/constant/pool.lux @@ -3,7 +3,7 @@ (.using [library - [lux (.except Integer Double + [lux (.except Double integer) ["[0]" ffi] [abstract @@ -35,7 +35,7 @@ ["[0]" name_and_type (.only Name_And_Type)] ["[0]" class (.only Class)] ["[0]" reference (.only Reference)] - ["[1][0]" integer (.only Integer)] + ["[1][0]" integer] [// ["[1][0]" index (.only Index)] [encoding @@ -160,7 +160,7 @@ (<| (/|do %) (!add % value)))] - [integer Integer //.#Integer //integer.equivalence] + [integer //.Integer //.#Integer (//.value_equivalence //integer.equivalence)] [float Float //.#Float (//.value_equivalence //.float_equivalence)] [long Long //.#Long (//.value_equivalence integer.equivalence)] [double Double //.#Double (//.value_equivalence decimal.equivalence)] diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 7153e3b251..cc3466ce13 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -867,32 +867,37 @@ true) (alias? /.Nothing /.False) (alias? /.Nothing /.Falsum))) - (_.for [/.__adjusted_quantified_type__] + (_.for [/.Quantification + /.__adjusted_quantified_type__] (all _.and - (_.coverage [/.for_any] - (let [identity (is (/.for_any (_ a) (-> a a)) - (|>>))] - (and (exec - (is Natural - (identity left)) - true) + (_.coverage [/.for_any /.for_all /.for_every] + (and (let [identity (is (/.for_any (_ a) (-> a a)) + (|>>))] + (and (exec + (is Natural + (identity left)) + true) + (exec + (is Text + (identity right)) + true))) + (alias? /.for_any /.for_all) + (alias? /.for_any /.for_every))) + (_.coverage [/.for_some /.there_exists] + (and (let [hide (is (/.for_some (_ a) (-> Natural a)) + (|>>))] (exec - (is Text - (identity right)) - true)))) - (_.coverage [/.for_some] - (let [hide (is (/.for_some (_ a) (-> Natural a)) - (|>>))] - (exec - (is /.Any - (hide left)) - true))))) - (_.coverage [/.same?] - (let [not_left (atom.atom left) - left (atom.atom left)] - (and (/.same? left left) - (/.same? not_left not_left) - (not (/.same? left not_left))))) + (is /.Any + (hide left)) + true)) + (alias? /.for_some /.there_exists))))) + (_.coverage [/.same? /.alias?] + (and (let [not_left (atom.atom left) + left (atom.atom left)] + (and (/.same? left left) + (/.same? not_left not_left) + (not (/.same? left not_left)))) + (/.alias? /.same? /.alias?))) (_.coverage [/.Rec] (let [list (is (/.Rec NList (Maybe [Natural NList])) @@ -1221,6 +1226,24 @@ verdict))) 0 1 2)) +(the target + Test + (<| (_.for [/.Target]) + (all _.and + (_.coverage [/.c++ /.common_lisp /.js + /.jvm /.lua /.php + /.python /.r /.ruby + /.scheme] + (let [options (is (List /.Target) + (list /.c++ /.common_lisp /.js + /.jvm /.lua /.php + /.python /.r /.ruby + /.scheme)) + uniques (set.of_list text.hash options)] + (n.= (list.size options) + (set.size uniques)))) + ))) + (the test|lux Test (`` (`` (all _.and @@ -1248,6 +1271,7 @@ ..for_complex ..for_extension ..for_bindings + ..target )))) (the test diff --git a/stdlib/source/test/lux/math/number/decimal.lux b/stdlib/source/test/lux/math/number/decimal.lux index 717b84fd2e..e29827c1dd 100644 --- a/stdlib/source/test/lux/math/number/decimal.lux +++ b/stdlib/source/test/lux/math/number/decimal.lux @@ -280,8 +280,9 @@ (_.coverage [/.%] (let [rem (/.% left right) div (|> right (/.- rem) (/./ left))] - (/.= right - (|> div (/.* left) (/.+ rem))))) + (of (/.approximately +0.0000000001) = + right + (|> div (/.* left) (/.+ rem))))) (_.coverage [/./%] (let [[div rem] (/./% left right)] (and (/.= div (/./ left right)) diff --git a/stdlib/source/test/lux/math/number/revolution.lux b/stdlib/source/test/lux/math/number/revolution.lux index d8450c6892..c91f30826b 100644 --- a/stdlib/source/test/lux/math/number/revolution.lux +++ b/stdlib/source/test/lux/math/number/revolution.lux @@ -84,6 +84,8 @@ (<| (_.covering /._) (_.for [.Revolution]) (`` (all _.and + (_.coverage [.Rev] + (alias? .Revolution .Rev)) (,, (template.with [ ] [(_.coverage [] (/.= diff --git a/stdlib/source/test/lux/meta/compiler/language/lux.lux b/stdlib/source/test/lux/meta/compiler/language/lux.lux index 6eb91d7512..c9dc0a86b1 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux.lux @@ -39,7 +39,7 @@ [\\library ["[0]" /]] ["[0]" / - ... ["[1][0]" syntax] + ["[1][0]" syntax] ... ["[1][0]" analysis] ... ["[1][0]" synthesis] ["[1][0]" phase @@ -139,6 +139,7 @@ (and (text.= expected_module actual_module))) (same? version.latest (its signature.#version it))))) + /syntax.test /phase.test /translation.test ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/syntax.lux b/stdlib/source/test/lux/meta/compiler/language/lux/syntax.lux index f65c29a7ee..86e95dcf79 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/syntax.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/syntax.lux @@ -2,82 +2,87 @@ ... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. (.using - [lux (.except) - [abstract/monad (.only do)] - [data - ["%" text/injection] - [number - ["n" natural]]] - ["r" math/random (.only Random) (.use "[1]#[0]" monad)] - [control - ["[0]" try] - [projection - ["l" text]]] - [data - ["[0]" text] - [collection - ["[0]" list] - ["[0]" dictionary (.only Dictionary)]]] - [meta - ["[0]" code] - ["[0]" location] - ["[0]" symbol]] - [test - ["_" property (.only Test)]]] - [\\ + [library + [lux (.except) + [abstract + [monad (.only do)]] + [data + ["[0]" text (.only) + ["%" \\injection]] + [collection + ["[0]" dictionary]]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" functor)] + [number + ["n" natural] + ["[0]" fraction (.only) + ["[1]T" \\test]] + ["[0]" rational (.only) + ["[1]T" \\test]]]] + [meta + ["[0]" code] + ["[0]" location] + ["[0]" symbol]] + [test + ["_" property (.only Test)]]]] + [\\library ["[0]" /]]) (the symbol_part^ (Random Text) - (do [! r.monad] - [size (|> r.natural (of ! each (|>> (n.% 20) (n.max 1))))] - (r.lower_case_alpha size))) + (do [! random.monad] + [size (|> random.natural (of ! each (|>> (n.% 20) (n.max 1))))] + (random.lower_cased size))) (the symbol^ (Random Symbol) - (r.and symbol_part^ symbol_part^)) + (random.and symbol_part^ + symbol_part^)) (the code^ (Random Code) (let [numeric^ (is (Random Code) - (all r.either - (|> r.bit (r#each code.bit)) - (|> r.natural (r#each code.natural)) - (|> r.integer (r#each code.integer)) - (|> r.revolution (r#each code.revolution)) - (|> r.unit_decimal (r#each code.decimal)))) + (all random.either + (|> random.bit (random#each code.bit)) + (|> random.natural (random#each code.natural)) + (|> random.integer (random#each code.integer)) + (|> random.revolution (random#each code.revolution)) + (|> random.unit_decimal (random#each code.decimal)) + )) textual^ (is (Random Code) - (all r.either - (do r.monad - [size (|> r.natural (r#each (n.% 20)))] - (|> (r.upper_case_alpha size) (r#each code.text))) - (|> symbol^ (r#each code.symbol)) - (|> symbol^ (r#each code.tag)))) + (all random.either + (do random.monad + [size (|> random.natural (random#each (n.% 20)))] + (|> (random.upper_cased size) (random#each code.text))) + (|> symbol^ (random#each code.symbol)) + )) simple^ (is (Random Code) - (all r.either + (all random.either numeric^ - textual^))] - (r.rec + textual^ + ))] + (random.rec (function (_ code^) - (let [multi^ (do r.monad - [size (|> r.natural (r#each (n.% 3)))] - (r.list size code^)) + (let [multi^ (is (Random (List Code)) + (do random.monad + [size (|> random.natural (random#each (n.% 3)))] + (random.list size code^))) composite^ (is (Random Code) - (all r.either - (|> multi^ (r#each code.form)) - (|> multi^ (r#each code.tuple)) - (do r.monad - [size (|> r.natural (r#each (n.% 3)))] - (|> (r.list size (r.and code^ code^)) - (r#each code.record)))))] - (all r.either + (all random.either + (|> multi^ (random#each code.form)) + (|> multi^ (random#each code.tuple)) + ))] + (all random.either simple^ - composite^)))))) + composite^ + )))))) (the code Test - (do [! r.monad] - [sample code^] + (do [! random.monad] + [sample code^ + expected_fraction fractionT.random + expected_rational rationalT.random] (all _.and (_.test "Can parse Lux code." (when (let [source_code (code.as_text sample)] @@ -107,24 +112,50 @@ {.#Right [_ =other]} (and (of code.equivalence = sample =sample) (of code.equivalence = other =other))))))) + (_.coverage [fraction.extension] + (when (let [source_code (of fraction.format injection expected_fraction)] + (/.parse "" (dictionary.empty text.hash) (text.size source_code) + [location.dummy 0 source_code])) + {.#Left _} + false + + {.#Right [_ actual]} + (of code.equivalence = + (` ((, (code.symbol [.prelude fraction.extension])) + (, (code.natural (its fraction.#numerator expected_fraction))) + (, (code.natural (its fraction.#denominator expected_fraction))))) + actual))) + (_.coverage [rational.extension] + (when (let [source_code (of rational.format injection expected_rational)] + (/.parse "" (dictionary.empty text.hash) (text.size source_code) + [location.dummy 0 source_code])) + {.#Left _} + false + + {.#Right [_ actual]} + (of code.equivalence = + (` ((, (code.symbol [.prelude rational.extension])) + (, (code.integer (its rational.#numerator expected_rational))) + (, (code.natural (its rational.#denominator expected_rational))))) + actual))) ))) (the comment_text^ (Random Text) - (let [character_gen (|> r.natural (r.only (|>> (n.= (`` (character (,, (static text.new_line))))) not)))] - (do r.monad - [size (|> r.natural (r#each (n.% 20)))] - (r.text character_gen size)))) + (let [character_gen (|> random.natural (random.only (|>> (n.= (`` (character (,, (static text.new_line))))) not)))] + (do random.monad + [size (|> random.natural (random#each (n.% 20)))] + (random.text character_gen size)))) (the comment^ (Random Text) - (do r.monad + (do random.monad [comment comment_text^] (in (%.message "... " comment text.new_line)))) (the comments Test - (do r.monad + (do random.monad [sample code^ comment comment^] (all _.and @@ -142,7 +173,7 @@ (the .public test Test - (<| (_.context (symbol.module (symbol /._))) + (<| (_.covering /._) (all _.and ..code ..comments diff --git a/stdlib/source/test/lux/meta/compiler/target/jvm.lux b/stdlib/source/test/lux/meta/compiler/target/jvm.lux index 6f63be74ff..9cb84390f4 100644 --- a/stdlib/source/test/lux/meta/compiler/target/jvm.lux +++ b/stdlib/source/test/lux/meta/compiler/target/jvm.lux @@ -55,7 +55,7 @@ ["[0]" class] ["[1][0]" attribute (.only) ["[1]/[0]" code]] - ["[1][0]" constant (.only) + ["[0]" constant (.only) ["[0]" pool (.only Resource)]] [encoding ["[0]" name] @@ -191,8 +191,8 @@ (the $Boolean::wrap (/.invokestatic ..$Boolean "valueOf" (type.method [(list) (list type.boolean) ..$Boolean (list)]))) (the $Boolean::random (as (Random java/lang/Boolean) random.bit)) -(the !false (|> 0 .i64 i32.i32 /.int)) -(the !true (|> 1 .i64 i32.i32 /.int)) +(the !false (|> 0 .i64 i32.i32 constant.integer /.int)) +(the !true (|> 1 .i64 i32.i32 constant.integer /.int)) (the ($Boolean::literal value) (-> java/lang/Boolean (Bytecode Any)) (if (as Bit value) @@ -215,7 +215,7 @@ (of random.monad each (|>> (as java/lang/Long) ffi.long_to_byte) random.integer)) (the $Byte::literal (-> java/lang/Byte (Bytecode Any)) - (|>> ffi.byte_to_long (as I64) i32.i32 /.int)) + (|>> ffi.byte_to_long (as I64) i32.i32 constant.integer /.int)) (the $Byte::primitive (Primitive java/lang/Byte) [#unboxed type.byte @@ -233,7 +233,7 @@ (of random.monad each (|>> (as java/lang/Long) ffi.long_to_short) random.integer)) (the $Short::literal (-> java/lang/Short (Bytecode Any)) - (|>> ffi.short_to_long (as I64) i32.i32 /.int)) + (|>> ffi.short_to_long (as I64) i32.i32 constant.integer /.int)) (the $Short::primitive (Primitive java/lang/Short) [#unboxed type.short @@ -251,7 +251,7 @@ (of random.monad each (|>> (as java/lang/Long) ffi.long_to_int) random.integer)) (the $Integer::literal (-> java/lang/Integer (Bytecode Any)) - (|>> ffi.int_to_long (as I64) i32.i32 /.int)) + (|>> ffi.int_to_long (as I64) i32.i32 constant.integer /.int)) (the $Integer::primitive (Primitive java/lang/Integer) [#unboxed type.int @@ -318,7 +318,7 @@ (of random.monad each (|>> (as java/lang/Long) ffi.long_to_int ffi.int_to_char) random.integer)) (the $Character::literal (-> java/lang/Character (Bytecode Any)) - (|>> ffi.char_to_long (as I64) i32.i32 /.int)) + (|>> ffi.char_to_long (as I64) i32.i32 constant.integer /.int)) (the $Character::primitive (Primitive java/lang/Character) [#unboxed type.char diff --git a/stdlib/source/test/lux/meta/label.lux b/stdlib/source/test/lux/meta/label.lux index a28c55c5a1..27be0e387a 100644 --- a/stdlib/source/test/lux/meta/label.lux +++ b/stdlib/source/test/lux/meta/label.lux @@ -60,25 +60,26 @@ (the singular Test - (all _.and - (_.coverage [/.tag] - (and (static.expansion - (do //.monad - [it (/.tag (symbol ,tag_0))] - (in (list (code.bit (same? (as Label ,tag_0) it)))))) - (static.expansion - (do //.monad - [it (/.tag (symbol ,tag_1))] - (in (list (code.bit (same? (as Label ,tag_1) it)))))))) - (_.coverage [/.slot] - (and (static.expansion - (do //.monad - [it (/.slot (symbol ,slot_0))] - (in (list (code.bit (same? (as Label ,slot_0) it)))))) - (static.expansion - (do //.monad - [it (/.slot (symbol ,slot_1))] - (in (list (code.bit (same? (as Label ,slot_1) it)))))))))) + (<| (_.for [.Label]) + (all _.and + (_.coverage [.Tag /.tag] + (and (static.expansion + (do //.monad + [it (/.tag (symbol ,tag_0))] + (in (list (code.bit (same? (as Label ,tag_0) it)))))) + (static.expansion + (do //.monad + [it (/.tag (symbol ,tag_1))] + (in (list (code.bit (same? (as Label ,tag_1) it)))))))) + (_.coverage [.Slot /.slot] + (and (static.expansion + (do //.monad + [it (/.slot (symbol ,slot_0))] + (in (list (code.bit (same? (as Label ,slot_0) it)))))) + (static.expansion + (do //.monad + [it (/.slot (symbol ,slot_1))] + (in (list (code.bit (same? (as Label ,slot_1) it))))))))))) (the plural Test @@ -213,7 +214,6 @@ (all _.and ..singular ..plural - (_.for [.Label] - ..label_related) + ..label_related ))) ))