diff options
458 files changed, 5342 insertions, 3994 deletions
diff --git a/commands.md b/commands.md index 00c3e621a..4c23f7c00 100644 --- a/commands.md +++ b/commands.md @@ -9,6 +9,14 @@ cd ~/lux/ && find . -name '*.lux' | xargs wc -l | sort -rn --- +# Find & replace + +``` +cd ~/lux && grep -r "" --include *.lux | sort +``` + +--- + # Clean everything ``` diff --git a/documentation/book/the_lux_programming_language/chapter_14.md b/documentation/book/the_lux_programming_language/chapter_14.md index 8be6afcd5..e0a0fc638 100644 --- a/documentation/book/the_lux_programming_language/chapter_14.md +++ b/documentation/book/the_lux_programming_language/chapter_14.md @@ -189,5 +189,5 @@ But if you think about it, being able to hold onto values or pass them around co Well, read the next chapter if you want to learn how to take your data to the next level with the help of persistent data structures. -See you in the next chapter! +See you in [the next chapter](chapter_15.md)! diff --git a/documentation/book/the_lux_programming_language/chapter_15.md b/documentation/book/the_lux_programming_language/chapter_15.md new file mode 100644 index 000000000..d03014f42 --- /dev/null +++ b/documentation/book/the_lux_programming_language/chapter_15.md @@ -0,0 +1,93 @@ +# Chapter 15: Persistent data structures + +_Where you will learn a new way to organize your data._ + +--- + +So far, you know how to use variants, tuples and records to structure your data. + +You're also familiar with lists, and you might even have come up with clever ways to use lists to implement key-value structures, like _property lists_. + +But the reality is that there are many different ways to organize data, and how you implement the mechanisms to do so will have an impact on the performance of your programs. + +That is why there are so many different types of data-structures, and so many different implementations for them. + +But not all such implementations fit into the functional paradigm of keeping all your data immutable, and most implementations of data-structures are actually mutable, and meant for imperative programming. + +Now, let's not be naïve. +Everybody can figure out that making a data-structure immutable and just copying the whole thing every time you want to make a change would make those data-structures prohibitively expensive to use. + +Luckily for us, there is a way to have immutable data-structures that have _reasonable performance_. +The reason why they are _fast enough_ to be used, is that they are designed to re-use as many nodes as they can whenever an update needs to be done, in order to avoid wasteful re-work wherever possible. + +Make no mistake, they are still not as fast as their mutable counterparts (which you can still access by doing host-interop), but they are designed with high-performance in mind, and so they tend to be _fast enough_ for most use-cases. + +Lux offers a variety of these persistent data-structures. +Here are some examples: + +## Rows + + Located in `library/lux/data/collection/row`. + +These are similar to lists in that they are sequential data-structures, but there are a few differences: + +1. Whereas lists prepend values to the front, rows append them to the back. +2. Random access on lists has a complexity of O(N), whereas it's O(log N) for rows. + +Rows are a great substitute for lists whenever random access is a must, and their implementation ensures updates are as cheap as possible. + +## Queues + + Located in `library/lux/data/collection/queue`. + +Queues are the classic first-in first-out (FIFO) data-structure. + +Use them whenever processing order matters, but you need to add to the back (unlike lists, where order matters but add to the front). + +## Dictionaries + + Located in `library/lux/data/collection/dictionary`. + +This is your standard key-value data-structure. + +Known by other names (tables, maps, etc), dictionaries give you efficient access and updating functionality. + +All you need to do is give it a `Hash` instance (from `library/lux/abstract/hash`) for your _"key"_ type, and you're good to go. + +## Sets + + Located in `library/lux/data/collection/set`. + +This is similar to dictionaries in that a `Hash` implementation is needed, but instead of it being a key-value data-structure, it only stores values (and then tells you if any given value is a member of the set). + +This is a useful data-structure for modelling group membership and keeping track of things. Plus, there are several set-theoretic operations defined in that module. + +## Persistent data structures and Software Transactional Memory + +This is a killer combination. + +Instead of using mutable data-structures for your changing program data, you can just use persistent data-structures, with the mutability being delegated the the STM system. + +This will make concurrently working with these data-structures a piece of cake, since you never have to worry about synchronizing/locking anything to avoid simultaneous updating, or any of the other crazy things programmers have to do to avoid data corruption. + +## Arrays: the not-so-persistent data structures + + Located in `library/lux/data/collection/array`. + +The `library/lux/data/collection/array` module features mutable arrays you can use if you need fast access and mutation and are willing to run the risks involved with using mutable data. + +Another possible use is to implement other data-structures (and, as it turns out, rows, dictionaries and sets all rely on arrays in their implementations). + +Also, it's worth nothing that in the _JVM_, this corresponds to _object arrays_. +If you want primitive arrays, you should check out the functionality for that in `library/lux/ffi`. + +--- + +It may seem odd that this chapter doesn't feature any code samples, but most of what you need to know is already located in the standard library documentation. + +These data-structures are very easy to use and offer decent performance, so you're encouraged to use them to model all your data processing code. + +The next chapter is going to be slightly different, in that we're going to be learning not how to write programs, but how to test them. + +See you in the next chapter! + diff --git a/documentation/bookmark/hashing.md b/documentation/bookmark/hashing.md new file mode 100644 index 000000000..eda334300 --- /dev/null +++ b/documentation/bookmark/hashing.md @@ -0,0 +1,4 @@ +# Reference + +1. [The construct of a bit mixer](http://jonkagstrom.com/bit-mixer-construction/) + diff --git a/documentation/bookmark/math/number/dual.md b/documentation/bookmark/math/number/dual.md index 508adae9a..345bddca3 100644 --- a/documentation/bookmark/math/number/dual.md +++ b/documentation/bookmark/math/number/dual.md @@ -1,5 +1,7 @@ # Reference +1. [Sensitivity of y w.r.t. to x in y=f(x) where f is a routine](https://scicomp.stackexchange.com/questions/38899/sensitivity-of-y-w-r-t-to-x-in-y-fx-where-f-is-a-routine/38900#38900) +1. [Differentiable programming](https://en.wikipedia.org/wiki/Differentiable_programming) 1. [Ditching Backpropagation: Automatic Differentiation and Dual Numbers](https://matiasmorant.wordpress.com/2017/12/29/dual-numbers/) 1. [The Dual Numbers](https://www.youtube.com/watch?v=4nU-09e3iP8) 1. [Dual number](https://en.wikipedia.org/wiki/Dual_number) diff --git a/documentation/bookmark/mixin.md b/documentation/bookmark/mixin.md new file mode 100644 index 000000000..bdcc7ae9c --- /dev/null +++ b/documentation/bookmark/mixin.md @@ -0,0 +1,8 @@ +# Reference + +1. [Prototypes: Object-Orientation, Functionally](http://fare.tunes.org/files/cs/poof.pdf) +1. [The Different Aspects of Monads and Mixins](http://ropas.snu.ac.kr/~bruno/papers/MixinAspects.pdf) +1. [THAT ABOUT WRAPS IT UP: Using FIX to Handle Errors Without Exceptions, and Other Programming Tricks](http://www.lfcs.inf.ed.ac.uk/reports/97/ECS-LFCS-97-375/ECS-LFCS-97-375.pdf) +1. [EffectiveAdvice: Disciplined Advice with Explicit Effects](http://www.cs.utexas.edu/~wcook/Drafts/2010/EffectiveAdvice.pdf) +1. [16. Object Reorientation: Generic Functions](http://www.gigamonkeys.com/book/object-reorientation-generic-functions.html) + diff --git a/licentia/project.lux b/licentia/project.lux index 9e25516a4..93f43aa47 100644 --- a/licentia/project.lux +++ b/licentia/project.lux @@ -7,7 +7,7 @@ #repositories ["https://oss.sonatype.org/content/repositories/snapshots/" "https://oss.sonatype.org/service/local/staging/deploy/maven2/"] - #dependencies [["com.github.luxlang" "stdlib" "0.6.0-SNAPSHOT" "jar"]] + #dependencies [["com.github.luxlang" "stdlib" "0.6.0-SNAPSHOT" "tar"]] #compiler ["com.github.luxlang" "lux-jvm" "0.6.0-SNAPSHOT" "jar"] ... #compiler ["com.github.luxlang" "lux-js" "0.6.0-SNAPSHOT" "js"] ... #compiler ["com.github.luxlang" "lux-python" "0.6.0-SNAPSHOT" "jar"] diff --git a/licentia/source/program/licentia/document.lux b/licentia/source/program/licentia/document.lux index c7806ab6a..8b2d1300c 100644 --- a/licentia/source/program/licentia/document.lux +++ b/licentia/source/program/licentia/document.lux @@ -45,5 +45,5 @@ (def: .public (section value) (-> Section Text) - (format (..block (get@ #title value)) - (get@ #content value))) + (format (..block (value@ #title value)) + (value@ #content value))) diff --git a/licentia/source/program/licentia/input.lux b/licentia/source/program/licentia/input.lux index 5482daba4..ede659fcf 100644 --- a/licentia/source/program/licentia/input.lux +++ b/licentia/source/program/licentia/input.lux @@ -58,8 +58,8 @@ (exception: .public (invalid_period {period (Period Nat)}) (exception.report - ["Start" (%.nat (get@ #time.start period))] - ["End" (%.nat (get@ #time.end period))])) + ["Start" (%.nat (value@ #time.start period))] + ["End" (%.nat (value@ #time.end period))])) (def: period (Parser (Period Nat)) diff --git a/licentia/source/program/licentia/license/addendum.lux b/licentia/source/program/licentia/license/addendum.lux index 256b516cc..a3518f68e 100644 --- a/licentia/source/program/licentia/license/addendum.lux +++ b/licentia/source/program/licentia/license/addendum.lux @@ -24,6 +24,6 @@ "")] ["“Commons Clause” License Condition v1.0" - (get@ #//.commons_clause? value) + (value@ #//.commons_clause? value) ..commons_clause] ))))) diff --git a/licentia/source/program/licentia/license/black_list.lux b/licentia/source/program/licentia/license/black_list.lux index 577f53242..fc1257875 100644 --- a/licentia/source/program/licentia/license/black_list.lux +++ b/licentia/source/program/licentia/license/black_list.lux @@ -22,11 +22,11 @@ (let [scope (format "The rights granted under " _.license) effect "shall not be granted to the following entities, or any subsidiary thereof" justification (|> black_list - (get@ #//.justification) + (value@ #//.justification) (maybe\map (|>> (format ", due to "))) (maybe.default "")) entities (|> black_list - (get@ #//.entities) + (value@ #//.entities) (list\map ..entity) (text.interposed text.new_line))] (format scope " " effect justification ":" text.new_line diff --git a/licentia/source/program/licentia/license/definition.lux b/licentia/source/program/licentia/license/definition.lux index 0335a9b30..81be7ffc6 100644 --- a/licentia/source/program/licentia/license/definition.lux +++ b/licentia/source/program/licentia/license/definition.lux @@ -54,7 +54,7 @@ ($.paragraph (list (format "the terms and conditions defined in this document")))] [licensable "Licensable" - ($.paragraph (list (format "having the right to grant any and all of the rights conveyed by " (get@ #term license))))] + ($.paragraph (list (format "having the right to grant any and all of the rights conveyed by " (value@ #term license))))] [legal_entity "Legal Entity" (let [abilities (: (List Text) @@ -64,28 +64,28 @@ ($.paragraph (list (format "any human or non-human entity that is recognized as having privileges and obligations, such as having the ability " ($.and abilities)))))] [recipient "Recipient" - ($.paragraph (list (format "a " (get@ #term legal_entity) " exercising permissions by " (get@ #term license))))] + ($.paragraph (list (format "a " (value@ #term legal_entity) " exercising permissions by " (value@ #term license))))] [licensor "The Licensor" - ($.paragraph (list (format "the copyright owner granting " (get@ #term license) ", or a " (get@ #term legal_entity) " authorized by the copyright owner")))] + ($.paragraph (list (format "the copyright owner granting " (value@ #term license) ", or a " (value@ #term legal_entity) " authorized by the copyright owner")))] [source_code_form "Source Code Form" ($.paragraph (list (format "the preferred form of the " ..covered_work_description " in order to make modifications to it")))] [object_form "Object Form" - ($.paragraph (list (format "any form produced by transforming a " (get@ #term source_code_form) ", including but not limited to compiled code and transpiled code")))] + ($.paragraph (list (format "any form produced by transforming a " (value@ #term source_code_form) ", including but not limited to compiled code and transpiled code")))] [licensed_work "The Licensed Work" ($.paragraph (list (format "the " ..covered_work_description - ", whether in a " (get@ #term source_code_form) - " or in an " (get@ #term object_form) - ", made available under " (get@ #term license) + ", whether in a " (value@ #term source_code_form) + " or in an " (value@ #term object_form) + ", made available under " (value@ #term license) ", as indicated by a copyright notice that is included in or attached to the " ..covered_work_description)))] [derivative_work "Derivative Work" - ($.paragraph (list (format "any work, whether in a " (get@ #term source_code_form) - " or in an " (get@ #term object_form) - ", that is based on (or derived from) " (get@ #term licensed_work) + ($.paragraph (list (format "any work, whether in a " (value@ #term source_code_form) + " or in an " (value@ #term object_form) + ", that is based on (or derived from) " (value@ #term licensed_work) " and which represents an original " ..covered_work_description)))] [submission "Submission" @@ -93,17 +93,17 @@ (list "electronic" "verbal" "written"))] - ($.paragraph (list (format "any form of " ($.or forms_of_communication) " communication sent to " (get@ #term licensor) - ", or its representatives, for the purpose of discussing and improving " (get@ #term licensed_work) + ($.paragraph (list (format "any form of " ($.or forms_of_communication) " communication sent to " (value@ #term licensor) + ", or its representatives, for the purpose of discussing and improving " (value@ #term licensed_work) ", but excluding communication that is designated in writing by the copyright owner as " not_a_contribution_notice))))] [modification "Modification" (let [alteration "any addition to, or deletion from, the substance or structure of" object "file or other storage" targets (: (List Text) - (list (format "a " object " contained in " (get@ #term licensed_work)) - (format "any new " object " that contains any part of " (get@ #term licensed_work)) - (format "any " object " which replaces or otherwise alters the original functionality of "(get@ #term licensed_work) " at runtime")))] + (list (format "a " object " contained in " (value@ #term licensed_work)) + (format "any new " object " that contains any part of " (value@ #term licensed_work)) + (format "any " object " which replaces or otherwise alters the original functionality of "(value@ #term licensed_work) " at runtime")))] ($.paragraph (list (format alteration " " ($.or targets)))))] [required_component "Required Component" @@ -116,74 +116,74 @@ "control file" "other work"))] ($.paragraph (list (format "any " ($.or possibilities) - " created by " (get@ #term recipient) - " which is required by a third party to successfully install and run a " (get@ #term derivative_work) - " by " (get@ #term recipient)))))] + " created by " (value@ #term recipient) + " which is required by a third party to successfully install and run a " (value@ #term derivative_work) + " by " (value@ #term recipient)))))] [extension "Extension" (let [possibilities (: (List Text) - (list (get@ #term modification) - (get@ #term derivative_work) - (get@ #term required_component)))] + (list (value@ #term modification) + (value@ #term derivative_work) + (value@ #term required_component)))] ($.paragraph (list (format "any " ($.or possibilities)))))] [contribution "Contribution" - ($.paragraph (list (format "any " covered_work_description ", including the original version of " (get@ #term licensed_work) - " and any " (get@ #term extension) " to " (get@ #term licensed_work) - ", that is intentionally communicated as a " (get@ #term submission) - " to " (get@ #term licensor) - " for inclusion in " (get@ #term licensed_work) " by the copyright owner" - ", or by a " (get@ #term legal_entity) " authorized to submit on behalf of the copyright owner")))] + ($.paragraph (list (format "any " covered_work_description ", including the original version of " (value@ #term licensed_work) + " and any " (value@ #term extension) " to " (value@ #term licensed_work) + ", that is intentionally communicated as a " (value@ #term submission) + " to " (value@ #term licensor) + " for inclusion in " (value@ #term licensed_work) " by the copyright owner" + ", or by a " (value@ #term legal_entity) " authorized to submit on behalf of the copyright owner")))] [contributor "Contributor" - ($.paragraph (list (format (get@ #term licensor) - " or any " (get@ #term legal_entity) - " on behalf of whom a " (get@ #term contribution) - " has been received by " (get@ #term licensor) - ", and subsequently incorporated within " (get@ #term licensed_work))))] + ($.paragraph (list (format (value@ #term licensor) + " or any " (value@ #term legal_entity) + " on behalf of whom a " (value@ #term contribution) + " has been received by " (value@ #term licensor) + ", and subsequently incorporated within " (value@ #term licensed_work))))] - [patent_claim (format "Patent Claim Of A " (get@ #term contributor)) + [patent_claim (format "Patent Claim Of A " (value@ #term contributor)) (let [claim_types (: (List Text) (list "method" "process" "apparatus"))] ($.paragraph (list (format "any patent claim(s), including without limitation " ($.and claim_types) " claims, in any patent " - (get@ #term licensable) " by such " (get@ #term contributor) - " that would be infringed, but for the grant of " (get@ #term license) - ", to " ($.or patent_rights) " its " (get@ #term contribution)))))] + (value@ #term licensable) " by such " (value@ #term contributor) + " that would be infringed, but for the grant of " (value@ #term license) + ", to " ($.or patent_rights) " its " (value@ #term contribution)))))] [secondary_license "Secondary License" - ($.paragraph (list (format "any license for which compliance does not imply or require violating the terms of " (get@ #term license))))] + ($.paragraph (list (format "any license for which compliance does not imply or require violating the terms of " (value@ #term license))))] [sell "Sell" - ($.paragraph (list (format "practicing any or all of the rights granted to " (get@ #term recipient) - " under " (get@ #term license) + ($.paragraph (list (format "practicing any or all of the rights granted to " (value@ #term recipient) + " under " (value@ #term license) " to provide to third parties, for a fee or other consideration " "(including without limitation fees for " ($.or commercial_services) - " related to "(get@ #term licensed_work) ")" - ", a product or service whose value derives, entirely or substantially, from the functionality of " (get@ #term licensed_work))))] + " related to "(value@ #term licensed_work) ")" + ", a product or service whose value derives, entirely or substantially, from the functionality of " (value@ #term licensed_work))))] [personal_use "Personal Use" (let [valid_purposes (: (List Text) (list "personal" "private" "non-commercial"))] - ($.paragraph (list (format "use of " (get@ #term licensed_work) " by an individual solely for his or her " ($.and valid_purposes) " purposes") - (format "An individual's use of " (get@ #term licensed_work) " in his or her capacity as an " ($.or individual_capacities) " does not qualify"))))] + ($.paragraph (list (format "use of " (value@ #term licensed_work) " by an individual solely for his or her " ($.and valid_purposes) " purposes") + (format "An individual's use of " (value@ #term licensed_work) " in his or her capacity as an " ($.or individual_capacities) " does not qualify"))))] [serve "Serve" - ($.paragraph (list (format "to deliver " (get@ #term licensed_work) - " and/or any " (get@ #term extension) - " by means of a computer network to one or more computers for purposes of execution of " (get@ #term licensed_work) - ", and/or the " (get@ #term extension))))] + ($.paragraph (list (format "to deliver " (value@ #term licensed_work) + " and/or any " (value@ #term extension) + " by means of a computer network to one or more computers for purposes of execution of " (value@ #term licensed_work) + ", and/or the " (value@ #term extension))))] [research "Research" - ($.paragraph (list (format "investigation or experimentation for the purpose of understanding the nature and limits of " (get@ #term licensed_work) " and its potential uses")))] + ($.paragraph (list (format "investigation or experimentation for the purpose of understanding the nature and limits of " (value@ #term licensed_work) " and its potential uses")))] [deploy "Deploy" (let [deployment_types (: (List Text) (list "use" - (get@ #term serve) + (value@ #term serve) "sublicense" "distribute")) sub_licensing (: (-> Text Text) @@ -194,20 +194,20 @@ (sub_licensing "indirect") "distribution")) basic_definition (format "to " ($.or deployment_types) - " " (get@ #term licensed_work) - " other than for internal " (get@ #term research) - " and/or " (get@ #term personal_use) - " by " (get@ #term recipient)) - examples (format "any and all internal use or distribution of " (get@ #term licensed_work) - " within a business or organization in which " (get@ #term recipient) + " " (value@ #term licensed_work) + " other than for internal " (value@ #term research) + " and/or " (value@ #term personal_use) + " by " (value@ #term recipient)) + examples (format "any and all internal use or distribution of " (value@ #term licensed_work) + " within a business or organization in which " (value@ #term recipient) " participates") - exceptions (format "for " (get@ #term research) " and/or " (get@ #term personal_use))] + exceptions (format "for " (value@ #term research) " and/or " (value@ #term personal_use))] ($.paragraph (list (format basic_definition ", and includes without limitation, " examples ", other than " exceptions ", as well as " ($.or third_party_interactions) - " of " (get@ #term licensed_work) - " by " (get@ #term recipient) + " of " (value@ #term licensed_work) + " by " (value@ #term recipient) " to any third party in any form or manner"))))] [electronic_distribution_mechanism "Electronic Distribution Mechanism" diff --git a/licentia/source/program/licentia/license/distribution.lux b/licentia/source/program/licentia/license/distribution.lux index ca5e37f1c..6324a60d8 100644 --- a/licentia/source/program/licentia/license/distribution.lux +++ b/licentia/source/program/licentia/license/distribution.lux @@ -105,9 +105,9 @@ (def: .public (extension distribution) (-> Distribution Text) ($.paragraph ($_ list\compose - (if (get@ #//.can_re_license? distribution) + (if (value@ #//.can_re_license? distribution) (list allow_re_licensing) (list)) - (if (get@ #//.can_multi_license? distribution) + (if (value@ #//.can_multi_license? distribution) (list allow_multi_licensing) (list))))) diff --git a/licentia/source/program/licentia/license/notice.lux b/licentia/source/program/licentia/license/notice.lux index 87308f87b..2a4857c31 100644 --- a/licentia/source/program/licentia/license/notice.lux +++ b/licentia/source/program/licentia/license/notice.lux @@ -21,12 +21,12 @@ (def: .public (copyright_holder holder) (-> //copyright.Holder Text) - (let [(^slots [#//time.start #//time.end]) (get@ #//copyright.period holder) + (let [(^slots [#//time.start #//time.end]) (value@ #//copyright.period holder) single_year? (n.= start end) period_section (if single_year? (%.nat start) (format (%.nat start) "-" (%.nat end)))] - (format "Copyright (C) " period_section " " (get@ #//copyright.name holder)))) + (format "Copyright (C) " period_section " " (value@ #//copyright.name holder)))) (def: .public copyright (-> (List //copyright.Holder) Text) diff --git a/licentia/source/program/licentia/license/term.lux b/licentia/source/program/licentia/license/term.lux index c66afc56c..9b210fb2b 100644 --- a/licentia/source/program/licentia/license/term.lux +++ b/licentia/source/program/licentia/license/term.lux @@ -7,7 +7,7 @@ (template [<term> <definition>] [(def: .public <term> Text - (get@ #//definition.term <definition>))] + (value@ #//definition.term <definition>))] [source_code_form //definition.source_code_form] [object_form //definition.object_form] diff --git a/licentia/source/program/licentia/output.lux b/licentia/source/program/licentia/output.lux index bef7014b3..22b81de8b 100644 --- a/licentia/source/program/licentia/output.lux +++ b/licentia/source/program/licentia/output.lux @@ -38,12 +38,12 @@ (def: .public (definition value) (-> Definition Text) - (format ($.quote (get@ #definition.term value)) ": " (get@ #definition.meaning value))) + (format ($.quote (value@ #definition.term value)) ": " (value@ #definition.meaning value))) (def: .public (identification value) (-> Identification Text) - (format (get@ #license.name value) text.new_line - (get@ #license.version value))) + (format (value@ #license.name value) text.new_line + (value@ #license.version value))) (def: .public (grant termination) (-> Termination Text) @@ -55,14 +55,14 @@ grant.copyright] ["Grant of Patent License" - (grant.patent (get@ #license.patent_retaliation? termination))] + (grant.patent (value@ #license.patent_retaliation? termination))] ["Effective Date for the Grants" grant.date] ["Grant Termination" - (grant.termination (get@ #license.termination_period termination) - (get@ #license.grace_period termination))] + (grant.termination (value@ #license.termination_period termination) + (value@ #license.grace_period termination))] ["No Retroactive Effect of Termination" grant.no_retroactive_termination]))))) @@ -115,11 +115,11 @@ liability.litigation] ["Accepting Warranty or Additional Liability" - (get@ #license.can_accept? value) + (value@ #license.can_accept? value) liability.can_accept] ["High Risk Activities" - (get@ #license.disclaim_high_risk? value) + (value@ #license.disclaim_high_risk? value) liability.disclaim_high_risk]))))) (def: .public (distribution distribution) @@ -139,8 +139,8 @@ distribution.object_form] [(format "Distribution of an " _.extension) - (or (get@ #license.can_re_license? distribution) - (get@ #license.can_multi_license? distribution)) + (or (value@ #license.can_re_license? distribution) + (value@ #license.can_multi_license? distribution)) (distribution.extension distribution)]))))) (def: .public (commercial value) @@ -152,21 +152,21 @@ "")] ["Non-Commerciality" - (not (get@ #license.can_sell? value)) + (not (value@ #license.can_sell? value)) commercial.cannot_sell] [(format _.contributor " Attribution") - (get@ #license.require_contributor_credit? value) + (value@ #license.require_contributor_credit? value) commercial.require_contributor_attribution] [(format _.contributor " Endorsement") - (not (get@ #license.allow_contributor_endorsement? value)) + (not (value@ #license.allow_contributor_endorsement? value)) commercial.disallow_contributor_endorsement] ))))) (def: .public (extension value) (-> Extension Text) - (let [[show? document] (case (get@ #license.notification_period value) + (let [[show? document] (case (value@ #license.notification_period value) (#.Some period) [true (extension.notification_requirement period)] @@ -178,30 +178,30 @@ #$.content <content>})) "")] - [(get@ #license.same_license? value) "License Retention" + [(value@ #license.same_license? value) "License Retention" ($.paragraph (list\compose extension.sharing_requirement extension.license_conflict_resolution))] - [(get@ #license.must_be_distinguishable? value) (format _.extension " Distinctness") + [(value@ #license.must_be_distinguishable? value) (format _.extension " Distinctness") extension.distinctness_requirement] [show? (format _.source_code_form " Availability") document] - [(get@ #license.must_describe_modifications? value) (format "Description of " ($.plural _.modification)) + [(value@ #license.must_describe_modifications? value) (format "Description of " ($.plural _.modification)) extension.description_requirement])))))) (def: .public (attribution value) (-> Attribution Text) - (let [copyright_notice (format "Attribution Copyright Notice: " (get@ #license.copyright_notice value)) - phrase (case (get@ #license.phrase value) + (let [copyright_notice (format "Attribution Copyright Notice: " (value@ #license.copyright_notice value)) + phrase (case (value@ #license.phrase value) (#.Some phrase) (format text.new_line "Attribution Phrase: " phrase text.new_line) #.None "") - url (format text.new_line "Attribution URL: " (get@ #license.url value)) - image (case (get@ #license.image value) + url (format text.new_line "Attribution URL: " (value@ #license.url value)) + image (case (value@ #license.image value) (#.Some image) (format text.new_line "Attribution Image: " image) @@ -254,19 +254,19 @@ (def: .public (license value) (-> License Text) (let [identification (|> value - (get@ #license.identification) + (value@ #license.identification) (maybe\map ..identification) (maybe.default "")) - identified? (case (get@ #license.identification value) + identified? (case (value@ #license.identification value) (#.Some _) true #.None false)] (`` (format ($.block identification) - ($.block (notice.copyright (get@ #license.copyright_holders value))) + ($.block (notice.copyright (value@ #license.copyright_holders value))) - (case (get@ #license.black_lists value) + (case (value@ #license.black_lists value) #.Nil "" @@ -284,20 +284,20 @@ ($.block ($.section {#$.title (format "Acceptance of " _.license) #$.content limitation.acceptance})) - (..grant (get@ #license.termination value)) + (..grant (value@ #license.termination value)) ..limitation ..assurance ($.block ($.section {#$.title (format _.submission " of " ($.plural _.contribution)) #$.content submission.contribution})) - (..liability (get@ #license.liability value)) - (..distribution (get@ #license.distribution value)) - (..commercial (get@ #license.commercial value)) - (..extension (get@ #license.extension value)) + (..liability (value@ #license.liability value)) + (..distribution (value@ #license.distribution value)) + (..commercial (value@ #license.commercial value)) + (..extension (value@ #license.extension value)) (|> value - (get@ #license.attribution) + (value@ #license.attribution) (maybe\map (|>> ..attribution ["Attribution Information"] $.section @@ -306,7 +306,7 @@ (..miscellaneous identified?) - (addendum.output (get@ #license.addendum value)) + (addendum.output (value@ #license.addendum value)) notice.end_of_license )))) diff --git a/licentia/source/test/licentia.lux b/licentia/source/test/licentia.lux index b2302d8ef..e9a1da86e 100644 --- a/licentia/source/test/licentia.lux +++ b/licentia/source/test/licentia.lux @@ -161,16 +161,16 @@ (_.test "Copyright grant is present." (present? grant.copyright)) (_.test "Patent grant is present." - (present? (grant.patent (get@ #license.patent_retaliation? termination)))) + (present? (grant.patent (value@ #license.patent_retaliation? termination)))) (_.test "Effective date for the grants is present." (present? grant.date)) (_.test "Patent grant is present." - (present? (grant.termination (get@ #license.termination_period termination) - (get@ #license.grace_period termination)))) + (present? (grant.termination (value@ #license.termination_period termination) + (value@ #license.grace_period termination)))) (_.test "The termination period is accurately conveyed." - (present? (grant.grant_restoration_clause (get@ #license.termination_period termination)))) + (present? (grant.grant_restoration_clause (value@ #license.termination_period termination)))) (_.test "The grace period is accurately conveyed." - (present? (grant.grace_period_clause (get@ #license.grace_period termination)))) + (present? (grant.grace_period_clause (value@ #license.grace_period termination)))) (_.test "The grants are not retro-actively terminated." (present? grant.no_retroactive_termination)) )) @@ -185,10 +185,10 @@ (_.test "Litigation conditions are present." (present? liability.litigation)) (_.test "Liability acceptance conditions may be present." - (bit\= (get@ #license.can_accept? liability) + (bit\= (value@ #license.can_accept? liability) (present? liability.can_accept))) (_.test "Liability acceptance conditions may be present." - (bit\= (get@ #license.disclaim_high_risk? liability) + (bit\= (value@ #license.disclaim_high_risk? liability) (present? liability.disclaim_high_risk))) )) @@ -207,13 +207,13 @@ (Concern Commercial) ($_ _.and (_.test "Non-commercial clause is present." - (bit\= (not (get@ #license.can_sell? commercial)) + (bit\= (not (value@ #license.can_sell? commercial)) (present? commercial.cannot_sell))) (_.test "Contributor credit condition is present." - (bit\= (get@ #license.require_contributor_credit? commercial) + (bit\= (value@ #license.require_contributor_credit? commercial) (present? commercial.require_contributor_attribution))) (_.test "Anti-endorsement condition is present." - (bit\= (not (get@ #license.allow_contributor_endorsement? commercial)) + (bit\= (not (value@ #license.allow_contributor_endorsement? commercial)) (present? commercial.disallow_contributor_endorsement))) )) @@ -221,21 +221,21 @@ (Concern Extension) ($_ _.and (_.test "The license is viral." - (bit\= (get@ #license.same_license? extension) + (bit\= (value@ #license.same_license? extension) (and (list.every? present? extension.sharing_requirement) (list.every? present? extension.license_conflict_resolution)))) (_.test "Extensions must be distinguishable from the original work." - (bit\= (get@ #license.must_be_distinguishable? extension) + (bit\= (value@ #license.must_be_distinguishable? extension) (present? extension.distinctness_requirement))) (_.test "The community must be notified of new extensions." - (case (get@ #license.notification_period extension) + (case (value@ #license.notification_period extension) (#.Some period) (present? (extension.notification_requirement period)) #.None true)) (_.test "Must describe modifications." - (bit\= (get@ #license.must_describe_modifications? extension) + (bit\= (value@ #license.must_describe_modifications? extension) (present? extension.description_requirement))) )) @@ -243,17 +243,17 @@ (Concern Attribution) ($_ _.and (_.test "The attribution copyright notice is present." - (present? (get@ #license.copyright_notice attribution))) + (present? (value@ #license.copyright_notice attribution))) (_.test "The attribution phrase is present." (|> attribution - (get@ #license.phrase) + (value@ #license.phrase) (maybe\map present?) (maybe.default true))) (_.test "The attribution URL is present." - (present? (get@ #license.url attribution))) + (present? (value@ #license.url attribution))) (_.test "The attribution image is present." (|> attribution - (get@ #license.image) + (value@ #license.image) (maybe\map present?) (maybe.default true))) )) @@ -279,7 +279,7 @@ (Concern Addendum) ($_ _.and (_.test "Commons clause" - (bit\= (get@ #license.commons_clause? value) + (bit\= (value@ #license.commons_clause? value) (present? addendum.commons_clause))) )) @@ -294,10 +294,10 @@ ($_ _.and (_.test "Copyright notices are present." (list.every? (|>> notice.copyright_holder present?) - (get@ #license.copyright_holders license))) + (value@ #license.copyright_holders license))) (_.test "Identification is present (if the license is identified)." - (case (get@ #license.identification license) + (case (value@ #license.identification license) (#.Some identification) (and (present? (output.identification identification)) (present? miscellaneous.new_versions)) @@ -307,19 +307,19 @@ (_.test "Black-lists (if wanted by licensor) are explicitly enumerated and justified." (list.every? (function (_ black_list) - (let [black_list_is_justified? (case (get@ #license.justification black_list) + (let [black_list_is_justified? (case (value@ #license.justification black_list) (#.Some justification) (present? justification) #.None bit.yes) every_entity_is_mentioned? (|> black_list - (get@ #license.entities) + (value@ #license.entities) (list\map black_list.entity) (list.every? present?))] (and black_list_is_justified? every_entity_is_mentioned?))) - (get@ #license.black_lists license))) + (value@ #license.black_lists license))) (_.test "All definitions are present." (list.every? (|>> output.definition present?) @@ -328,7 +328,7 @@ (_.test "Acceptance of the license is demanded." (present? limitation.acceptance)) - (..about_grant present? (get@ #license.termination license)) + (..about_grant present? (value@ #license.termination license)) (_.test "All limitations are present." (present? output.limitation)) @@ -339,15 +339,15 @@ (_.test "The terms of submission are present." (present? submission.contribution)) - (..about_liability present? (get@ #license.liability license)) + (..about_liability present? (value@ #license.liability license)) - (..about_distribution present? (get@ #license.distribution license)) + (..about_distribution present? (value@ #license.distribution license)) - (..about_commercial present? (get@ #license.commercial license)) + (..about_commercial present? (value@ #license.commercial license)) - (..about_extension present? (get@ #license.extension license)) + (..about_extension present? (value@ #license.extension license)) - (case (get@ #license.attribution license) + (case (value@ #license.attribution license) (#.Some attribution) (..about_attribution present? attribution) @@ -357,7 +357,7 @@ (..about_miscellaneous present?) - (..about_addendum present? (get@ #license.addendum license)) + (..about_addendum present? (value@ #license.addendum license)) (_.test "License ending footer is present." (present? notice.end_of_license)) diff --git a/lux-cl/source/program.lux b/lux-cl/source/program.lux index dfff7fb92..36ce1f0cd 100644 --- a/lux-cl/source/program.lux +++ b/lux-cl/source/program.lux @@ -243,7 +243,7 @@ (#try.Failure error) (#try.Success member) - (recur (inc idx) (array.write! idx (:as Any member) output))) + (recur (++ idx) (array.write! idx (:as Any member) output))) (#try.Success output))))) (def: (read host_object) diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index 22e12f197..2bc4f4a49 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -327,18 +327,18 @@ (#.Some member) (case (ffi.check org/openjdk/nashorn/internal/runtime/Undefined member) (#.Some _) - (recur (inc idx) output) + (recur (++ idx) output) #.None (case (lux_object member) (#try.Success parsed_member) - (recur (inc idx) (array.write! idx (:as java/lang/Object parsed_member) output)) + (recur (++ idx) (array.write! idx (:as java/lang/Object parsed_member) output)) (#try.Failure error) #.None)) #.None - (recur (inc idx) output)) + (recur (++ idx) output)) (#.Some output)))) #.None)) diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux index 99ac39c78..a7314b0dc 100644 --- a/lux-jvm/source/luxc/lang/directive/jvm.lux +++ b/lux-jvm/source/luxc/lang/directive/jvm.lux @@ -517,7 +517,7 @@ (Re_labeler (/.Bytecode Inst)) (row\fold (function (_ input [mapping output]) (let [[mapping input'] (..relabel_instruction [mapping input])] - [mapping (row.add input' output)])) + [mapping (row.suffix input' output)])) [mapping (row.row)] bytecode)) diff --git a/lux-jvm/source/luxc/lang/host/jvm.lux b/lux-jvm/source/luxc/lang/host/jvm.lux index 6ce7badc5..e24922771 100644 --- a/lux-jvm/source/luxc/lang/host/jvm.lux +++ b/lux-jvm/source/luxc/lang/host/jvm.lux @@ -101,7 +101,7 @@ (` (def: .public (~ (code.local_identifier option)) (~ g!type) (|> (~ g!none) - (set@ (~ (code.local_tag option)) #1))))) + (with@ (~ (code.local_tag option)) #1))))) options)] (in (list& (` (type: .public (~ g!type) (~ (code.record (list/map (function (_ tag) @@ -117,8 +117,8 @@ (` (def: .public ((~ (code.local_identifier ++)) (~ g!_left) (~ g!_right)) (-> (~ g!type) (~ g!type) (~ g!type)) (~ (code.record (list/map (function (_ tag) - [tag (` (or (get@ (~ tag) (~ g!_left)) - (get@ (~ tag) (~ g!_right))))]) + [tag (` (or (value@ (~ tag) (~ g!_left)) + (value@ (~ tag) (~ g!_right))))]) g!tags+))))) g!options+)))) diff --git a/lux-jvm/source/luxc/lang/host/jvm/def.lux b/lux-jvm/source/luxc/lang/host/jvm/def.lux index f8233222d..130e0bb56 100644 --- a/lux-jvm/source/luxc/lang/host/jvm/def.lux +++ b/lux-jvm/source/luxc/lang/host/jvm/def.lux @@ -83,7 +83,7 @@ (-> (List Text) (Array Text)) (let [output (ffi.array java/lang/String (list.size values))] (exec (list@map (function (_ [idx value]) - (ffi.array_write idx value output)) + (ffi.write! idx value output)) (list.enumeration values)) output))) @@ -110,23 +110,23 @@ (def: (class_flags config) (-> //.Class_Config Int) ($_ i.+ - (if (get@ #//.finalC config) (org/objectweb/asm/Opcodes::ACC_FINAL) +0))) + (if (value@ #//.finalC config) (org/objectweb/asm/Opcodes::ACC_FINAL) +0))) (def: (method_flags config) (-> //.Method_Config Int) ($_ i.+ - (if (get@ #//.staticM config) (org/objectweb/asm/Opcodes::ACC_STATIC) +0) - (if (get@ #//.finalM config) (org/objectweb/asm/Opcodes::ACC_FINAL) +0) - (if (get@ #//.synchronizedM config) (org/objectweb/asm/Opcodes::ACC_SYNCHRONIZED) +0) - (if (get@ #//.strictM config) (org/objectweb/asm/Opcodes::ACC_STRICT) +0))) + (if (value@ #//.staticM config) (org/objectweb/asm/Opcodes::ACC_STATIC) +0) + (if (value@ #//.finalM config) (org/objectweb/asm/Opcodes::ACC_FINAL) +0) + (if (value@ #//.synchronizedM config) (org/objectweb/asm/Opcodes::ACC_SYNCHRONIZED) +0) + (if (value@ #//.strictM config) (org/objectweb/asm/Opcodes::ACC_STRICT) +0))) (def: (field_flags config) (-> //.Field_Config Int) ($_ i.+ - (if (get@ #//.staticF config) (org/objectweb/asm/Opcodes::ACC_STATIC) +0) - (if (get@ #//.finalF config) (org/objectweb/asm/Opcodes::ACC_FINAL) +0) - (if (get@ #//.transientF config) (org/objectweb/asm/Opcodes::ACC_TRANSIENT) +0) - (if (get@ #//.volatileF config) (org/objectweb/asm/Opcodes::ACC_VOLATILE) +0))) + (if (value@ #//.staticF config) (org/objectweb/asm/Opcodes::ACC_STATIC) +0) + (if (value@ #//.finalF config) (org/objectweb/asm/Opcodes::ACC_FINAL) +0) + (if (value@ #//.transientF config) (org/objectweb/asm/Opcodes::ACC_TRANSIENT) +0) + (if (value@ #//.volatileF config) (org/objectweb/asm/Opcodes::ACC_VOLATILE) +0))) (def: param_signature (-> (Type Class) Text) diff --git a/lux-jvm/source/luxc/lang/host/jvm/inst.lux b/lux-jvm/source/luxc/lang/host/jvm/inst.lux index 0c724ca87..e0402d924 100644 --- a/lux-jvm/source/luxc/lang/host/jvm/inst.lux +++ b/lux-jvm/source/luxc/lang/host/jvm/inst.lux @@ -377,9 +377,9 @@ (if (n.< array_size idx) (let [[key label] (maybe.trusted (list.item idx keys+labels))] (exec - (ffi.array_write idx (ffi.long_to_int key) keys_array) - (ffi.array_write idx label labels_array) - (recur (inc idx)))) + (ffi.write! idx (ffi.long_to_int key) keys_array) + (ffi.write! idx label labels_array) + (recur (++ idx)))) []))] (do_to visitor (org/objectweb/asm/MethodVisitor::visitLookupSwitchInsn default keys_array labels_array))))) @@ -391,10 +391,10 @@ labels_array (ffi.array org/objectweb/asm/Label num_labels) _ (loop [idx 0] (if (n.< num_labels idx) - (exec (ffi.array_write idx - (maybe.trusted (list.item idx labels)) - labels_array) - (recur (inc idx))) + (exec (ffi.write! idx + (maybe.trusted (list.item idx labels)) + labels_array) + (recur (++ idx))) []))] (do_to visitor (org/objectweb/asm/MethodVisitor::visitTableSwitchInsn min max default labels_array))))) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/case.lux b/lux-jvm/source/luxc/lang/translation/jvm/case.lux index d3f6a29c1..3a6291036 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/case.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/case.lux @@ -212,7 +212,7 @@ (#synthesis.Alt leftP rightP) (do phase.monad [@alt_else _.make_label - leftI (path' (inc stack_depth) @alt_else @end phase archive leftP) + leftI (path' (++ stack_depth) @alt_else @end phase archive leftP) rightI (path' stack_depth @else @end phase archive rightP)] (in (|>> _.DUP leftI diff --git a/lux-jvm/source/luxc/lang/translation/jvm/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/common.lux index b6bba249f..cfdadecb5 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/common.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/common.lux @@ -31,18 +31,18 @@ ... (def: .public (with-artifacts action) ... (All [a] (-> (Meta a) (Meta [Artifacts a]))) ... (function (_ state) -... (case (action (update@ #.host +... (case (action (revised@ #.host ... (|>> (:coerce Host) -... (set@ #artifacts (dictionary.new text.hash)) +... (with@ #artifacts (dictionary.new text.hash)) ... (:coerce Nothing)) ... state)) ... (#try.Success [state' output]) -... (#try.Success [(update@ #.host +... (#try.Success [(revised@ #.host ... (|>> (:coerce Host) -... (set@ #artifacts (|> (get@ #.host state) (:coerce Host) (get@ #artifacts))) +... (with@ #artifacts (|> (value@ #.host state) (:coerce Host) (value@ #artifacts))) ... (:coerce Nothing)) ... state') -... [(|> state' (get@ #.host) (:coerce Host) (get@ #artifacts)) +... [(|> state' (value@ #.host) (:coerce Host) (value@ #artifacts)) ... output]]) ... (#try.Failure error) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux index 20962c13d..31538a0bd 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -977,7 +977,7 @@ list.indices (list\map (.function (_ register) (|>> (_.ALOAD 0) - (_.ALOAD (inc register)) + (_.ALOAD (++ register)) (_.PUTFIELD class (///reference.foreign_name register) $Object)))) _.fuse)] (_def.method #$.Public $.noneM "<init>" (anonymous_init_method env) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux index 9af108496..0508e9c62 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux @@ -58,9 +58,9 @@ (-> (Environment Synthesis) Arity (Type Method)) (if (poly_arg? arity) (type.method [(list) - (list.joined (list (captured_args env) - (list type.int) - (list.repeated (dec arity) //.$Value))) + (list.together (list (captured_args env) + (list type.int) + (list.repeated (-- arity) //.$Value))) type.void (list)]) (type.method [(list) (captured_args env) type.void (list)]))) @@ -80,7 +80,7 @@ (def: (inputsI start amount) (-> Register Nat Inst) - (|> (enum.range n.enum start (n.+ start (dec amount))) + (|> (enum.range n.enum start (n.+ start (-- amount))) (list@map _.ALOAD) _.fuse)) @@ -111,7 +111,7 @@ (do {@ phase.monad} [captureI+ (monad.map @ (generate archive) env) .let [argsI (if (poly_arg? arity) - (|> (nullsI (dec arity)) + (|> (nullsI (-- arity)) (list (_.int +0)) _.fuse) function.identity)]] @@ -132,12 +132,12 @@ (let [env_size (list.size env) captureI (|> (case env_size 0 (list) - _ (enum.range n.enum 0 (dec env_size))) + _ (enum.range n.enum 0 (-- env_size))) (list@map (.function (_ source) (|>> (_.ALOAD 0) (_.GETFIELD class (reference.foreign_name source) //.$Value)))) _.fuse) - argsI (|> (nullsI (dec arity)) + argsI (|> (nullsI (-- arity)) (list (_.int +0)) _.fuse)] (|>> (_.NEW class) @@ -164,20 +164,20 @@ (if (n.= 1 arity) (|>> (_.int +0) (_.INVOKESPECIAL //.$Function "<init>" function_init_method)) - (|>> (_.ILOAD (inc env_size)) + (|>> (_.ILOAD (++ env_size)) (_.INVOKESPECIAL //.$Function "<init>" function_init_method)))) (def: (with_init class env arity) (-> (Type Class) (Environment Synthesis) Arity Def) (let [env_size (list.size env) offset_partial (: (-> Nat Nat) - (|>> inc (n.+ env_size))) + (|>> ++ (n.+ env_size))) store_capturedI (|> (case env_size 0 (list) - _ (enum.range n.enum 0 (dec env_size))) + _ (enum.range n.enum 0 (-- env_size))) (list@map (.function (_ register) (|>> (_.ALOAD 0) - (_.ALOAD (inc register)) + (_.ALOAD (++ register)) (_.PUTFIELD class (reference.foreign_name register) //.$Value)))) _.fuse) store_partialI (if (poly_arg? arity) @@ -185,7 +185,7 @@ (list@map (.function (_ idx) (let [register (offset_partial idx)] (|>> (_.ALOAD 0) - (_.ALOAD (inc register)) + (_.ALOAD (++ register)) (_.PUTFIELD class (reference.partial_name idx) //.$Value))))) _.fuse) function.identity)] @@ -199,7 +199,7 @@ (def: (with_apply class env function_arity @begin bodyI apply_arity) (-> (Type Class) (Environment Synthesis) Arity Label Inst Arity Def) - (let [num_partials (dec function_arity) + (let [num_partials (-- function_arity) @default ($.new_label []) @labels (list@map $.new_label (list.repeated num_partials [])) over_extent (|> (.int function_arity) (i.- (.int apply_arity))) @@ -207,7 +207,7 @@ (list.zipped/2 (enum.range n.enum 0 num_partials)) (list@map (.function (_ [stage @label]) (let [load_partialsI (if (n.> 0 stage) - (|> (enum.range n.enum 0 (dec stage)) + (|> (enum.range n.enum 0 (-- stage)) (list@map (|>> reference.partial_name (load_fieldI class))) _.fuse) function.identity)] @@ -230,14 +230,14 @@ load_partialsI (inputsI 1 args_to_completion) (_.INVOKEVIRTUAL class "impl" (implementation_method function_arity)) - (applysI (inc args_to_completion) args_left) + (applysI (++ args_to_completion) args_left) _.ARETURN)) ... (i.< over_extent (.int stage)) (let [env_size (list.size env) load_capturedI (|> (case env_size 0 (list) - _ (enum.range n.enum 0 (dec env_size))) + _ (enum.range n.enum 0 (-- env_size))) (list@map (|>> reference.foreign_name (load_fieldI class))) _.fuse)] (|>> (_.label @label) @@ -255,7 +255,7 @@ _.fuse)] (def.method #$.Public $.noneM //runtime.apply_method (//runtime.apply_signature apply_arity) (|>> get_amount_of_partialsI - (_.TABLESWITCH +0 (|> num_partials dec .int) + (_.TABLESWITCH +0 (|> num_partials -- .int) @default @labels) casesI )))) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/program.lux b/lux-jvm/source/luxc/lang/translation/jvm/program.lux index 8d95becc1..ab36835da 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/program.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/program.lux @@ -29,7 +29,7 @@ (-> (-> Context Text) (Program _.Inst _.Definition)) (let [nilI runtime.noneI num_inputsI (|>> ($i.ALOAD 0) $i.ARRAYLENGTH) - decI (|>> ($i.int +1) $i.ISUB) + --I (|>> ($i.int +1) $i.ISUB) headI (|>> $i.DUP ($i.ALOAD 0) $i.SWAP @@ -59,7 +59,7 @@ (|>> nilI num_inputsI ($i.label @loop) - decI + --I $i.DUP ($i.IFLT @end) headI diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux index 2808065c6..23d59b8f4 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux @@ -361,11 +361,11 @@ (let [applyI (|> (enum.range n.enum 2 num_apply_variants) (list@map (function (_ arity) ($d.method #$.Public $.noneM apply_method (apply_signature arity) - (let [preI (|> (enum.range n.enum 0 (dec arity)) + (let [preI (|> (enum.range n.enum 0 (-- arity)) (list@map _.ALOAD) _.fuse)] (|>> preI - (_.INVOKEVIRTUAL //.$Function apply_method (apply_signature (dec arity))) + (_.INVOKEVIRTUAL //.$Function apply_method (apply_signature (-- arity))) (_.CHECKCAST //.$Function) (_.ALOAD arity) (_.INVOKEVIRTUAL //.$Function apply_method (apply_signature 1)) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/structure.lux b/lux-jvm/source/luxc/lang/translation/jvm/structure.lux index ce9c56aed..71e9c514f 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/structure.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/structure.lux @@ -75,7 +75,7 @@ (def: .public (tagI lefts right?) (-> Nat Bit Inst) (case (if right? - (.inc lefts) + (.++ lefts) lefts) 0 _.ICONST_0 1 _.ICONST_1 diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux index 767101102..deef09f36 100644 --- a/lux-jvm/source/program.lux +++ b/lux-jvm/source/program.lux @@ -95,22 +95,22 @@ (def: _apply1_args (Array (java/lang/Class java/lang/Object)) (|> (ffi.array (java/lang/Class java/lang/Object) 1) - (ffi.array_write 0 _object_class))) + (ffi.write! 0 _object_class))) (def: _apply2_args (Array (java/lang/Class java/lang/Object)) (|> (ffi.array (java/lang/Class java/lang/Object) 2) - (ffi.array_write 0 _object_class) - (ffi.array_write 1 _object_class))) + (ffi.write! 0 _object_class) + (ffi.write! 1 _object_class))) (def: _apply5_args (Array (java/lang/Class java/lang/Object)) (|> (ffi.array (java/lang/Class java/lang/Object) 5) - (ffi.array_write 0 _object_class) - (ffi.array_write 1 _object_class) - (ffi.array_write 2 _object_class) - (ffi.array_write 3 _object_class) - (ffi.array_write 4 _object_class))) + (ffi.write! 0 _object_class) + (ffi.write! 1 _object_class) + (ffi.write! 2 _object_class) + (ffi.write! 3 _object_class) + (ffi.write! 4 _object_class))) (def: .public (expander macro inputs lux) Expander @@ -123,8 +123,8 @@ (java/lang/reflect/Method::invoke (:as java/lang/Object macro) (|> (ffi.array java/lang/Object 2) - (ffi.array_write 0 (:as java/lang/Object inputs)) - (ffi.array_write 1 (:as java/lang/Object lux))) + (ffi.write! 0 (:as java/lang/Object inputs)) + (ffi.write! 1 (:as java/lang/Object lux))) apply_method)))) (def: how_to_wrap_a_phase @@ -150,13 +150,13 @@ (#$.Extension "jvm conversion long-to-int"))) literal_nat (: (-> Nat Synthesis) (|>> .i64 $.i64 unwrap_long long_to_int)) - array_write (: (-> Text Nat Synthesis Synthesis Synthesis) - (function (_ element_class index value array) - ((#$.Extension "jvm array write object" - (list (jvm_type (jvm/type.array (jvm/type.class element_class (list)))) - (literal_nat index) - value - array))))) + write! (: (-> Text Nat Synthesis Synthesis Synthesis) + (function (_ element_class index value array) + ((#$.Extension "jvm array write object" + (list (jvm_type (jvm/type.array (jvm/type.class element_class (list)))) + (literal_nat index) + value + array))))) object_array (: (-> Text Nat Synthesis) (function (_ class_name size) (#$.Extension "jvm array new object" @@ -191,9 +191,9 @@ ($.text runtime.apply_method)) (input <java/lang/Class> (|> (object_array "java.lang.Class" phase_arity) - (array_write "java.lang.Class" 0 (class_of example_object)) - (array_write "java.lang.Class" 1 (class_of example_object)) - (array_write "java.lang.Class" 2 (class_of example_object)))))))] + (write! "java.lang.Class" 0 (class_of example_object)) + (write! "java.lang.Class" 1 (class_of example_object)) + (write! "java.lang.Class" 2 (class_of example_object)))))))] (#$.Extension "jvm member invoke virtual" (list& (class_type "java.lang.reflect.Method") ($.text "invoke") @@ -203,9 +203,9 @@ $phase) (input <java/lang/Object> (|> (object_array "java.lang.Object" phase_arity) - (array_write "java.lang.Object" 0 $archive) - (array_write "java.lang.Object" 1 $input) - (array_write "java.lang.Object" 2 $state)))))))) + (write! "java.lang.Object" 0 $archive) + (write! "java.lang.Object" 1 $input) + (write! "java.lang.Object" 2 $state)))))))) (def: (phase_wrapper archive) (-> Archive (generation.Operation _.Anchor _.Inst _.Definition platform.Phase_Wrapper)) @@ -223,7 +223,7 @@ (java/lang/reflect/Method::invoke (:as java/lang/Object phase_wrapper) (|> (ffi.array java/lang/Object 1) - (ffi.array_write 0 (:as java/lang/Object phase))) + (ffi.write! 0 (:as java/lang/Object phase))) apply_method))))))) (def: .public platform @@ -265,11 +265,11 @@ (java/lang/reflect/Method::invoke (:as java/lang/Object handler) (|> (ffi.array java/lang/Object 5) - (ffi.array_write 0 (:as java/lang/Object name)) - (ffi.array_write 1 (:as java/lang/Object (phase_wrapper phase))) - (ffi.array_write 2 (:as java/lang/Object archive)) - (ffi.array_write 3 (:as java/lang/Object parameters)) - (ffi.array_write 4 (:as java/lang/Object state))) + (ffi.write! 0 (:as java/lang/Object name)) + (ffi.write! 1 (:as java/lang/Object (phase_wrapper phase))) + (ffi.write! 2 (:as java/lang/Object archive)) + (ffi.write! 3 (:as java/lang/Object parameters)) + (ffi.write! 4 (:as java/lang/Object state))) method)))) (def: (declare_success! _) diff --git a/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux b/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux index ae3b84518..77f5b34bc 100644 --- a/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux +++ b/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux @@ -266,7 +266,7 @@ (let [entries (dict.entries hostAE.boxes) num-entries (list.size entries)] (do r.Monad<Random> - [choice (|> r.nat (:: @ map (n/% (inc num-entries)))) + [choice (|> r.nat (:: @ map (n/% (++ num-entries)))) #let [[unboxed boxed] (: [Text Text] (|> entries (list.nth choice) @@ -343,7 +343,7 @@ unboxedC (`' ("lux check" (+0 (~ (code.text unboxed)) (+0)) ("jvm object null")))] throwable (|> r.nat - (:: @ map (n/% (inc (list.size throwables)))) + (:: @ map (n/% (++ (list.size throwables)))) (:: @ map (function (_ idx) (|> throwables (list.nth idx) diff --git a/lux-jvm/test/test/luxc/lang/synthesis/loop.lux b/lux-jvm/test/test/luxc/lang/synthesis/loop.lux index 63ad3a395..7aeafab5f 100644 --- a/lux-jvm/test/test/luxc/lang/synthesis/loop.lux +++ b/lux-jvm/test/test/luxc/lang/synthesis/loop.lux @@ -62,14 +62,14 @@ #let [bad-bodies (list.repeat num-cases (' []))] good-body (gen-body arity output) where-to-set (|> r.nat (:: @ map (n/% num-cases))) - #let [bodies (list.joined (list (list.first where-to-set bad-bodies) - (list good-body) - (list.after (n/inc where-to-set) bad-bodies)))]] + #let [bodies (list.together (list (list.first where-to-set bad-bodies) + (list good-body) + (list.after (n/++ where-to-set) bad-bodies)))]] (wrap (` ("lux case" (~ inputA) (~ (code.record (list.zip2 tests bodies)))))))) (r.either (do r.Monad<Random> [valueS r.bit - output' (gen-body (n/inc arity) output)] + output' (gen-body (n/++ arity) output)] (wrap (` ("lux case" (~ (code.bit valueS)) {("lux case bind" (~ (code.nat arity))) (~ output')})))) (do r.Monad<Random> @@ -87,7 +87,7 @@ (-> ls.Arity la.Analysis la.Analysis) (case arity +0 body - _ (` ("lux function" [] (~ (make-function (n/dec arity) body)))))) + _ (` ("lux function" [] (~ (make-function (n/-- arity) body)))))) (def: gen-recursion (r.Random [Bit Nat la.Analysis]) diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 2a530ba13..41df182c0 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -188,7 +188,7 @@ (net/sandius/rembulan/impl/DefaultTable [] (rawget self {idx long}) java/lang/Object - (|> value (array.read! (|> idx (:as Nat) dec)) maybe.trusted re_wrap)) + (|> value (array.read! (|> idx (:as Nat) --)) maybe.trusted re_wrap)) (net/sandius/rembulan/impl/DefaultTable [] (rawget self {field java/lang/Object}) java/lang/Object @@ -215,7 +215,7 @@ #.None (case (ffi.check java/lang/Long field) (#.Some idx) - (|> value (array.read! (|> idx (:as Nat) dec)) maybe.trusted re_wrap) + (|> value (array.read! (|> idx (:as Nat) --)) maybe.trusted re_wrap) #.None (panic! (exception.construct ..unknown_kind_of_object field))))) @@ -247,14 +247,14 @@ output (: (Array java/lang/Object) (array.new init_num_keys))] (if (n.< num_keys idx) - (case (net/sandius/rembulan/Table::get_idx (:as java/lang/Long (inc idx)) host_object) + (case (net/sandius/rembulan/Table::get_idx (:as java/lang/Long (++ idx)) host_object) #.None - (recur num_keys (inc idx) output) + (recur num_keys (++ idx) output) (#.Some member) (case (read member) (#try.Success parsed_member) - (recur num_keys (inc idx) (array.write! idx (:as java/lang/Object parsed_member) output)) + (recur num_keys (++ idx) (array.write! idx (:as java/lang/Object parsed_member) output)) (#try.Failure error) (#try.Failure error))) diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index 7349017a2..0e1d21866 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -376,7 +376,7 @@ Called by `imenu--generic-function'." (type//dynamic (altRE ":dynamic" "/.:static")) (type//capability (altRE "capability:")) ;; Data - (data//record (altRE "get@" "set@" "update@")) + (data//record (altRE "value@" "with@" "revised@")) (data//interface (altRE "open:" "implementation" "\\\\")) (data//implicit (altRE "implicit:" "\\\\\\\\")) (data//collection (altRE "list" "list&" "row" "tree")) diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux index 688626084..214960667 100644 --- a/lux-php/source/program.lux +++ b/lux-php/source/program.lux @@ -310,7 +310,7 @@ (let [size (|> host_object php/runtime/memory/ArrayMemory::size (:as Nat) - dec)] + --)] (loop [idx 0 output (:as (Array Any) (array.new size))] (if (n.< size idx) @@ -321,12 +321,12 @@ php/runtime/memory/ReferenceMemory::getValue)] (case (ffi.check php/runtime/memory/NullMemory value) (#.Some _) - (recur (inc idx) output) + (recur (++ idx) output) #.None (case (read value) (#try.Success lux_value) - (recur (inc idx) (array.write! idx lux_value output)) + (recur (++ idx) (array.write! idx lux_value output)) error error))) @@ -450,9 +450,9 @@ (do try.monad [output (php/runtime/lang/Closure::call ..default_environment (|> (ffi.array php/runtime/Memory 3) - (ffi.array_write 0 macro) - (ffi.array_write 1 (lux_structure (:as (Array java/lang/Object) inputs))) - (ffi.array_write 2 (lux_structure (:as (Array java/lang/Object) lux)))) + (ffi.write! 0 macro) + (ffi.write! 1 (lux_structure (:as (Array java/lang/Object) inputs))) + (ffi.write! 2 (lux_structure (:as (Array java/lang/Object) lux)))) (:as php/runtime/lang/Closure (php/runtime/memory/ObjectMemory::value macro)))] (..read (:as java/lang/Object output))))) @@ -537,12 +537,12 @@ (|>> (:as (Array java/lang/Object)) lux_structure (:as php/runtime/Memory)))] output (php/runtime/lang/Closure::call ..default_environment (|> (ffi.array php/runtime/Memory 6) - (ffi.array_write 0 handler) - (ffi.array_write 1 (php/runtime/memory/StringMemory::new name)) - (ffi.array_write 2 (to_php phase)) - (ffi.array_write 3 (to_php archive)) - (ffi.array_write 4 (to_php parameters)) - (ffi.array_write 5 (to_php state))) + (ffi.write! 0 handler) + (ffi.write! 1 (php/runtime/memory/StringMemory::new name)) + (ffi.write! 2 (to_php phase)) + (ffi.write! 3 (to_php archive)) + (ffi.write! 4 (to_php parameters)) + (ffi.write! 5 (to_php state))) (:as php/runtime/lang/Closure (php/runtime/memory/ObjectMemory::value handler)))] (..read output)))) diff --git a/lux-python/commands.md b/lux-python/commands.md index 7de744436..7ea35927c 100644 --- a/lux-python/commands.md +++ b/lux-python/commands.md @@ -13,11 +13,20 @@ cd ~/lux/lux-python/ \ && lein clean \ && lein lux auto build +cd ~/lux/lux-python/ \ +&& lux clean \ +&& lux auto build + ## Build JVM-based compiler cd ~/lux/lux-python/ \ && lein clean \ && lein lux build \ && mv target/program.jar jvm_based_compiler.jar + +cd ~/lux/lux-python/ \ +&& lux clean \ +&& lux build \ +&& mv target/program.jar jvm_based_compiler.jar ``` # Try diff --git a/lux-python/project.lux b/lux-python/project.lux new file mode 100644 index 000000000..53ffe351b --- /dev/null +++ b/lux-python/project.lux @@ -0,0 +1,14 @@ +{"" + {#identity ["com.github.luxlang" "stdlib" "0.6.0-SNAPSHOT"] + + #deploy_repositories {"snapshots" "https://oss.sonatype.org/content/repositories/snapshots/" + "releases" "https://oss.sonatype.org/service/local/staging/deploy/maven2/"} + + #repositories ["https://oss.sonatype.org/content/repositories/snapshots/" + "https://oss.sonatype.org/service/local/staging/deploy/maven2/"] + + #compiler ["com.github.luxlang" "lux-jvm" "0.6.0-SNAPSHOT" "jar"] + #dependencies [["com.github.luxlang" "stdlib" "0.6.0-SNAPSHOT" "tar"] + ["org.python" "jython-standalone" "2.7.2" "jar"]] + + #program "program"}} diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index 6204a721b..2949fa54e 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -67,403 +67,416 @@ ["/." cli] ["/." static]]]) -(for {@.old - (as_is (import: java/lang/String) - - (import: (java/lang/Class a)) - - (import: java/lang/Object - ["#::." - (new []) - (toString [] java/lang/String) - (getClass [] (java/lang/Class java/lang/Object))]) - - (import: org/python/core/PyNone) - (import: org/python/core/PyBoolean) - (import: org/python/core/PyInteger) - (import: org/python/core/PyLong) - (import: org/python/core/PyFloat) - (import: org/python/core/PyTuple) - (import: org/python/core/PyList) - - (import: org/python/core/PyString - ["#::." - (new [java/lang/String])]) - - (import: org/python/core/PyObject - ["#::." - (asInt [] java/lang/Integer) - (asLong [] long) - (asDouble [] double) - (asString [] java/lang/String) - (__nonzero__ [] boolean) - (__getitem__ [int] #try org/python/core/PyObject) - (__getitem__ #as __getitem__dict [org/python/core/PyObject] #try org/python/core/PyObject) - (__len__ [] int)]) - - (import: org/python/core/PyFunction - ["#::." - (__call__ [[org/python/core/PyObject]] #try org/python/core/PyObject)]) - - (import: org/python/core/ThreadState) - - (import: org/python/core/PyArray - ["#::." - (new [(java/lang/Class java/lang/Object) java/lang/Object]) - (getArray [] java/lang/Object)]) - - (import: org/python/util/PythonInterpreter - ["#::." - (new []) - (exec [java/lang/String] #try void) - (eval [java/lang/String] #try PyObject)]) - - (type: Translator - (-> org/python/core/PyObject (Try Any))) - - (def: (read_tuple read host_object) - (-> Translator Translator) - (let [size (|> host_object org/python/core/PyObject::__len__ .nat)] - (loop [idx 0 - output (:as (Array Any) (array.new size))] - (if (n.< size idx) - (case (org/python/core/PyObject::__getitem__ (.int idx) host_object) - (#try.Failure try) - (#try.Failure try) - - (#try.Success value) - (case (read value) - (#try.Failure try) - (#try.Failure try) - - (#try.Success lux_value) - (recur (inc idx) (array.write! idx lux_value output)))) - (#try.Success output))))) - - (exception: (unknown_kind_of_object {object java/lang/Object}) - (exception.report - ["Object" (java/lang/Object::toString object)])) - - (def: (read_variant read host_object) - (-> Translator Translator) - (case [(org/python/core/PyObject::__getitem__ +0 host_object) - (org/python/core/PyObject::__getitem__ +1 host_object) - (org/python/core/PyObject::__getitem__ +2 host_object)] - (^or [(#try.Failure try) _ _] [_ (#try.Failure try) _] [_ _ (#try.Failure try)]) - (#try.Failure try) - - (^multi [(#try.Success tag) (#try.Success flag) (#try.Success value)] - {(read tag) - (#try.Success tag)} - {(read value) - (#try.Success value)}) - (#try.Success [tag - (: Any - (case (ffi.check org/python/core/PyNone flag) - (#.Some _) - (ffi.null) - - #.None - synthesis.unit)) - value]) - - _ - (exception.throw ..unknown_kind_of_object host_object))) - - (def: (read host_object) - Translator - (`` (<| (~~ (template [<class> <processing>] - [(case (ffi.check <class> host_object) - (#.Some host_object) - (#try.Success (<| <processing> host_object)) - - _)] - - [org/python/core/PyNone (new> [] [])] - [org/python/core/PyBoolean org/python/core/PyObject::__nonzero__] - [org/python/core/PyInteger org/python/core/PyObject::asInt] - [org/python/core/PyLong org/python/core/PyObject::asLong] - [org/python/core/PyFloat org/python/core/PyObject::asDouble] - [org/python/core/PyString org/python/core/PyObject::asString] - [org/python/core/PyFunction (|>)] - [org/python/core/PyArray org/python/core/PyArray::getArray] - [[java/lang/Object] (|>)] - )) - (~~ (template [<class> <processing>] - [(case (ffi.check <class> host_object) - (#.Some host_object) - (<| <processing> host_object) - - _)] - - [org/python/core/PyTuple (..read_variant read)] - [org/python/core/PyList (..read_tuple read)] - )) - ... (exception.throw ..unknown_kind_of_object host_object) - (exception.return host_object)))) - - (exception: (cannot_apply_a_non_function {object java/lang/Object}) - (exception.report - ["Non-function" (java/lang/Object::toString object)])) - - (def: (ensure_macro macro) - (-> Macro (Maybe org/python/core/PyFunction)) - (ffi.check org/python/core/PyFunction (:as java/lang/Object macro))) - - (def: object_class - (java/lang/Class java/lang/Object) - (java/lang/Object::getClass (java/lang/Object::new))) - - (def: to_host - (-> Any org/python/core/PyObject) - (|>> (:as java/lang/Object) (org/python/core/PyArray::new ..object_class))) - - (def: ensure_function - (-> Any (Maybe org/python/core/PyFunction)) - (|>> (:as java/lang/Object) - (ffi.check org/python/core/PyFunction))) - ) - - @.python - (as_is)}) - -(for {@.old - (as_is (def: (call_macro inputs lux macro) - (-> (List Code) Lux org/python/core/PyFunction (Try (Try [Lux (List Code)]))) - (:expected - (do try.monad - [expansion (org/python/core/PyFunction::__call__ (|> (ffi.array org/python/core/PyObject 2) - (ffi.array_write 0 (..to_host inputs)) - (ffi.array_write 1 (..to_host lux))) - macro)] - (..read expansion)))) - - (def: (expander macro inputs lux) - Expander - (case (ensure_macro macro) - (#.Some macro) - (case (..call_macro inputs lux macro) - (#try.Success output) - (|> output - (:as org/python/core/PyObject) - ..read - (:as (Try (Try [Lux (List Code)])))) - - (#try.Failure error) - (#try.Failure error)) - - #.None - (exception.throw ..cannot_apply_a_non_function (:as java/lang/Object macro))))) - - @.python - (def: (expander macro inputs lux) - Expander - (#try.Success ((:as Macro' macro) inputs lux)))}) - -(for {@.old - (def: host - (IO (Host (_.Expression Any) (_.Statement Any))) - (io (let [interpreter (org/python/util/PythonInterpreter::new) - evaluate! (: (-> Context (_.Expression Any) (Try Any)) - (function (evaluate! context input) - (do try.monad - [output (org/python/util/PythonInterpreter::eval (_.code input) interpreter)] - (..read output)))) - execute! (: (-> (_.Statement Any) (Try Any)) - (function (execute! input) - (org/python/util/PythonInterpreter::exec (_.code input) interpreter)))] - (: (Host (_.Expression Any) (_.Statement Any)) - (implementation - (def: evaluate! evaluate!) - (def: execute! execute!) - (def: (define! context custom input) - (let [global (maybe.default (reference.artifact context) - custom) - @global (_.var global)] - (do try.monad - [#let [definition (_.set (list @global) input)] - _ (execute! definition) - value (evaluate! context @global)] - (wrap [global value definition])))) - - (def: (ingest context content) - (|> content - (\ utf8.codec decode) - try.trusted - (:as (_.Statement Any)))) - - (def: (re_learn context custom content) - (execute! content)) - - (def: (re_load context custom content) - (do try.monad - [_ (execute! content)] - (evaluate! context (_.var (reference.artifact context)))))))))) - - @.python - (as_is (import: (dict [] ffi.Dict)) - (import: (eval [ffi.String ffi.Dict] #try Any)) - - (def: host - (IO (Host (_.Expression Any) (_.Statement Any))) - (io (: (Host (_.Expression Any) (_.Statement Any)) - (let [globals (..dict []) - evaluate! (: (-> Context (_.Expression Any) (Try Any)) - (function (evaluate! context input) - (..eval [(_.code input) globals]))) - execute! (: (-> (_.Statement Any) (Try Any)) - (function (execute! input) - (ffi.try ("python exec" (_.code input) globals)))) - define! (: (-> Context (_.Expression Any) (Try [Text Any (_.Statement Any)])) - (function (define! context input) - (let [global (reference.artifact context) - @global (_.var global)] +(with_expansions [<jvm> (as_is (import: java/lang/String) + + (import: (java/lang/Class a)) + + (import: java/lang/Object + ["#::." + (new []) + (toString [] java/lang/String) + (getClass [] (java/lang/Class java/lang/Object))]) + + (import: org/python/core/PyNone) + (import: org/python/core/PyBoolean) + (import: org/python/core/PyInteger) + (import: org/python/core/PyLong) + (import: org/python/core/PyFloat) + (import: org/python/core/PyTuple) + (import: org/python/core/PyList) + + (import: org/python/core/PyString + ["#::." + (new [java/lang/String])]) + + (import: org/python/core/PyObject + ["#::." + ... (asInt [] int) + (asLong [] long) + (asDouble [] double) + (asString [] java/lang/String) + (__nonzero__ [] boolean) + (__getitem__ [int] #try org/python/core/PyObject) + (__getitem__ #as __getitem__dict [org/python/core/PyObject] #try org/python/core/PyObject) + (__len__ [] int)]) + + (import: org/python/core/PyFunction + ["#::." + (__call__ [[org/python/core/PyObject]] #try org/python/core/PyObject)]) + + (import: org/python/core/ThreadState) + + (import: org/python/core/PyArray + ["#::." + (new [(java/lang/Class [? < java/lang/Object]) java/lang/Object]) + (getArray [] java/lang/Object)]) + + (import: org/python/util/PythonInterpreter + ["#::." + (new []) + (exec [java/lang/String] #try void) + (eval [java/lang/String] #try PyObject)]) + + (type: Translator + (-> org/python/core/PyObject (Try Any))) + + (def: (read_tuple read host_object) + (-> Translator Translator) + (let [size (|> host_object org/python/core/PyObject::__len__ .nat)] + (loop [idx 0 + output (:as (Array Any) + (array.empty size))] + (if (n.< size idx) + (case (org/python/core/PyObject::__getitem__ (.int idx) host_object) + (#try.Failure try) + (#try.Failure try) + + (#try.Success value) + (case (read value) + (#try.Failure try) + (#try.Failure try) + + (#try.Success lux_value) + (recur (++ idx) (array.write! idx lux_value output)))) + (#try.Success output))))) + + (exception: (unknown_kind_of_object {object java/lang/Object}) + (exception.report + ["Object" (java/lang/Object::toString object)])) + + (def: (read_variant read host_object) + (-> Translator Translator) + (case [(org/python/core/PyObject::__getitem__ +0 host_object) + (org/python/core/PyObject::__getitem__ +1 host_object) + (org/python/core/PyObject::__getitem__ +2 host_object)] + (^or [(#try.Failure try) _ _] + [_ (#try.Failure try) _] + [_ _ (#try.Failure try)]) + (#try.Failure try) + + (^multi [(#try.Success tag) (#try.Success flag) (#try.Success value)] + {(read tag) + (#try.Success tag)} + {(read value) + (#try.Success value)}) + (#try.Success [tag + (: Any + (case (ffi.check org/python/core/PyNone + (:as java/lang/Object flag)) + (#.Some _) + (:as Any (ffi.null)) + + #.None + (:as Any synthesis.unit))) + value]) + + _ + (exception.except ..unknown_kind_of_object [(:as java/lang/Object host_object)]))) + + (def: (read host_object) + Translator + (`` (<| (~~ (template [<class> <processing>] + [(case (ffi.check <class> (:as <class> host_object)) + (#.Some host_object) + (#try.Success (`` (|> host_object (~~ (template.spliced <processing>))))) + + _)] + + [org/python/core/PyNone [(new> [] [])]] + [org/python/core/PyBoolean [org/python/core/PyObject::__nonzero__]] + ... [org/python/core/PyInteger [(ffi.:as org/python/core/PyObject) org/python/core/PyObject::asInt]] + [org/python/core/PyInteger [(ffi.:as org/python/core/PyObject) + ("jvm member invoke virtual" [] "org.python.core.PyObject" "asInt" []) + "jvm object cast" + (: (primitive "java.lang.Integer"))]] + [org/python/core/PyLong [org/python/core/PyObject::asLong]] + [org/python/core/PyFloat [org/python/core/PyObject::asDouble]] + [org/python/core/PyString [org/python/core/PyObject::asString]] + [org/python/core/PyFunction []] + [org/python/core/PyArray [org/python/core/PyArray::getArray]] + [[java/lang/Object] [(|>)]] + )) + (~~ (template [<class> <processing>] + [(case (ffi.check <class> host_object) + (#.Some host_object) + (<| <processing> (:as org/python/core/PyObject) host_object) + + _)] + + [org/python/core/PyTuple (..read_variant read)] + [org/python/core/PyList (..read_tuple read)] + )) + ... (exception.except ..unknown_kind_of_object [(:as java/lang/Object host_object)]) + (#try.Success host_object)))) + + (exception: (cannot_apply_a_non_function {object java/lang/Object}) + (exception.report + ["Non-function" (java/lang/Object::toString object)])) + + (def: (ensure_macro macro) + (-> Macro (Maybe org/python/core/PyFunction)) + (ffi.check org/python/core/PyFunction (:as java/lang/Object macro))) + + (def: object_class + (java/lang/Class java/lang/Object) + (java/lang/Object::getClass (java/lang/Object::new))) + + (def: to_host + (-> Any org/python/core/PyObject) + (|>> (:as java/lang/Object) + (org/python/core/PyArray::new ..object_class) + (:as org/python/core/PyObject))) + + (def: ensure_function + (-> Any (Maybe org/python/core/PyFunction)) + (|>> (:as java/lang/Object) + (ffi.check org/python/core/PyFunction))) + )] + (for {@.old (as_is <jvm>) + @.jvm (as_is <jvm>) + @.python (as_is)})) + +(with_expansions [<jvm> (as_is (def: (call_macro inputs lux macro) + (-> (List Code) Lux org/python/core/PyFunction (Try (Try [Lux (List Code)]))) + (:expected + (do try.monad + [expansion (org/python/core/PyFunction::__call__ (|> (ffi.array org/python/core/PyObject 2) + (ffi.write! 0 (..to_host inputs)) + (ffi.write! 1 (..to_host lux))) + macro)] + (..read expansion)))) + + (def: (expander macro inputs lux) + Expander + (case (ensure_macro macro) + (#.Some macro) + (case (..call_macro inputs lux macro) + (#try.Success output) + (|> output + (:as org/python/core/PyObject) + ..read + (:as (Try (Try [Lux (List Code)])))) + + (#try.Failure error) + (#try.Failure error)) + + #.None + (exception.except ..cannot_apply_a_non_function (:as java/lang/Object macro)))))] + (for {@.old (as_is <jvm>) + @.jvm (as_is <jvm>) + + @.python + (def: (expander macro inputs lux) + Expander + (#try.Success ((:as Macro' macro) inputs lux)))})) + +(with_expansions [<jvm> (def: host + (IO (Host (_.Expression Any) (_.Statement Any))) + (io (let [interpreter (org/python/util/PythonInterpreter::new) + evaluate! (: (-> Context (_.Expression Any) (Try Any)) + (function (evaluate! context input) + (do try.monad + [output (org/python/util/PythonInterpreter::eval (_.code input) interpreter)] + (..read output)))) + execute! (: (-> (_.Statement Any) (Try Any)) + (function (execute! input) + (org/python/util/PythonInterpreter::exec (_.code input) interpreter)))] + (: (Host (_.Expression Any) (_.Statement Any)) + (implementation + (def: evaluate! evaluate!) + (def: execute! execute!) + (def: (define! context custom input) + (let [global (maybe.else (reference.artifact context) + custom) + @global (_.var global)] + (do try.monad + [.let [definition (_.set (list @global) input)] + _ (execute! definition) + value (evaluate! context @global)] + (in [global value definition])))) + + (def: (ingest context content) + (|> content + (\ utf8.codec decode) + try.trusted + (:as (_.Statement Any)))) + + (def: (re_learn context custom content) + (execute! content)) + + (def: (re_load context custom content) + (do try.monad + [_ (execute! content)] + (evaluate! context (_.var (reference.artifact context))))))))))] + (for {@.old <jvm> + @.jvm <jvm> + + @.python + (as_is (import: (dict [] ffi.Dict)) + (import: (eval [ffi.String ffi.Dict] #try Any)) + + (def: host + (IO (Host (_.Expression Any) (_.Statement Any))) + (io (: (Host (_.Expression Any) (_.Statement Any)) + (let [globals (..dict []) + evaluate! (: (-> Context (_.Expression Any) (Try Any)) + (function (evaluate! context input) + (..eval [(_.code input) globals]))) + execute! (: (-> (_.Statement Any) (Try Any)) + (function (execute! input) + (ffi.try ("python exec" (_.code input) globals)))) + define! (: (-> Context (_.Expression Any) (Try [Text Any (_.Statement Any)])) + (function (define! context input) + (let [global (reference.artifact context) + @global (_.var global)] + (do try.monad + [.let [definition (_.set (list @global) input)] + _ (execute! definition) + value (evaluate! context @global)] + (in [global value definition])))))] + (implementation + (def: evaluate! evaluate!) + (def: execute! execute!) + (def: define! define!) + + (def: (ingest context content) + (|> content (\ utf8.codec decode) try.trusted (:as (_.Statement Any)))) + + (def: (re_learn context content) + (execute! content)) + + (def: (re_load context content) + (do try.monad + [_ (execute! content)] + (evaluate! context (_.var (reference.artifact context)))))))))))})) + +(with_expansions [<jvm> (as_is (exception: .public (invaid_phase_application {partial_application (List Any)} + {arity Nat}) + (exception.report + ["Partial Application" (%.nat (list.size partial_application))] + ["Arity" (%.nat arity)])) + + (def: (host_phase partial_application phase) + (All [s i o] + (-> (List Any) (Phase [extension.Bundle s] i o) + org/python/core/PyObject)) + (<| (ffi.:as org/python/core/PyObject) + (ffi.object [] org/python/core/PyObject [] + [] + ... Methods + (org/python/core/PyObject + [] (__call__ self + {inputs [org/python/core/PyObject]} + {keywords [java/lang/String]}) + org/python/core/PyObject + (try.trusted + (case (array.list inputs) + (^ (list)) + (\ try.monad in (host_phase (list) phase)) + + (^ (list input/0)) (do try.monad - [#let [definition (_.set (list @global) input)] - _ (execute! definition) - value (evaluate! context @global)] - (wrap [global value definition])))))] - (implementation - (def: evaluate! evaluate!) - (def: execute! execute!) - (def: define! define!) - - (def: (ingest context content) - (|> content (\ utf8.codec decode) try.trusted (:as (_.Statement Any)))) - - (def: (re_learn context content) - (execute! content)) - - (def: (re_load context content) - (do try.monad - [_ (execute! content)] - (evaluate! context (_.var (reference.artifact context)))))))))))}) - -(for {@.old - (as_is (exception: .public (invaid_phase_application {partial_application (List Any)} - {arity Nat}) - (exception.report - ["Partial Application" (%.nat (list.size partial_application))] - ["Arity" (%.nat arity)])) - - (def: (host_phase partial_application phase) - (All [s i o] - (-> (List Any) (Phase [extension.Bundle s] i o) - org/python/core/PyObject)) - (ffi.object [] org/python/core/PyObject [] - [] - ... Methods - (org/python/core/PyObject - [] (__call__ self - {inputs [org/python/core/PyObject]} - {keywords [java/lang/String]}) - org/python/core/PyObject - (try.trusted - (case (array.to_list inputs) - (^ (list)) - (\ try.monad wrap (host_phase (list) phase)) - - (^ (list input/0)) - (do try.monad - [input/0 (..read input/0)] - (case partial_application - (^ (list partial/0 partial/1)) - (wrap (..to_host ((:as (-> Any Any Any Any) phase) - partial/0 - partial/1 - input/0))) - - (^ (list partial/0)) - (wrap (host_phase (list partial/0 input/0) phase)) - - (^ (list)) - (wrap (host_phase (list input/0) phase)) - - _ - (exception.throw ..invaid_phase_application [partial_application (array.size inputs)]))) - - (^ (list input/0 input/1)) - (do try.monad - [input/0 (..read input/0) - input/1 (..read input/1)] - (case partial_application - (^ (list partial/0)) - (wrap (..to_host ((:as (-> Any Any Any Any) phase) - partial/0 - input/0 - input/1))) - - (^ (list)) - (wrap (host_phase (list input/0 input/1) phase)) - - _ - (exception.throw ..invaid_phase_application [partial_application (array.size inputs)]))) - - (^ (list input/0 input/1 input/2)) - (do try.monad - [input/0 (..read input/0) - input/1 (..read input/1) - input/2 (..read input/2)] - (case partial_application - (^ (list)) - (wrap (..to_host ((:as (-> Any Any Any Any) phase) - input/0 - input/1 - input/2))) - - _ - (exception.throw ..invaid_phase_application [partial_application (array.size inputs)]))) - - _ - (exception.throw ..invaid_phase_application [partial_application (array.size inputs)])))))) - - (def: (extender phase_wrapper) - (-> platform.Phase_Wrapper Extender) - ... TODO: Stop relying on coercions ASAP. - (<| (:as Extender) - (function (_ handler)) - (:as Handler) - (function (_ name phase)) - (:as Phase) - (function (_ archive parameters)) - (:as Operation) - (function (_ state)) - (:as Try) - try.trusted - (:as Try) - (do try.monad - [handler (try.of_maybe (..ensure_function handler)) - output (org/python/core/PyFunction::__call__ (|> (ffi.array org/python/core/PyObject 5) - (ffi.array_write 0 (org/python/core/PyString::new name)) - (ffi.array_write 1 (:as org/python/core/PyObject (phase_wrapper phase))) - (ffi.array_write 2 (..to_host archive)) - (ffi.array_write 3 (..to_host parameters)) - (ffi.array_write 4 (..to_host state))) - handler)] - (..read output))))) - - @.python - (def: (extender phase_wrapper handler) - (-> platform.Phase_Wrapper Extender) - (:expected handler))}) + [input/0 (..read input/0)] + (case partial_application + (^ (list partial/0 partial/1)) + (in (..to_host ((:as (-> Any Any Any Any) phase) + partial/0 + partial/1 + input/0))) + + (^ (list partial/0)) + (in (host_phase (list partial/0 input/0) phase)) + + (^ (list)) + (in (host_phase (list input/0) phase)) + + _ + (exception.except ..invaid_phase_application [partial_application (array.size inputs)]))) + + (^ (list input/0 input/1)) + (do try.monad + [input/0 (..read input/0) + input/1 (..read input/1)] + (case partial_application + (^ (list partial/0)) + (in (..to_host ((:as (-> Any Any Any Any) phase) + partial/0 + input/0 + input/1))) + + (^ (list)) + (in (host_phase (list input/0 input/1) phase)) + + _ + (exception.except ..invaid_phase_application [partial_application (array.size inputs)]))) + + (^ (list input/0 input/1 input/2)) + (do try.monad + [input/0 (..read input/0) + input/1 (..read input/1) + input/2 (..read input/2)] + (case partial_application + (^ (list)) + (in (..to_host ((:as (-> Any Any Any Any) phase) + input/0 + input/1 + input/2))) + + _ + (exception.except ..invaid_phase_application [partial_application (array.size inputs)]))) + + _ + (exception.except ..invaid_phase_application [partial_application (array.size inputs)]))))))) + + (def: (extender phase_wrapper) + (-> platform.Phase_Wrapper Extender) + ... TODO: Stop relying on coercions ASAP. + (<| (:as Extender) + (function (_ handler)) + (:as Handler) + (function (_ name phase)) + (:as Phase) + (function (_ archive parameters)) + (:as Operation) + (function (_ state)) + (:as Try) + try.trusted + (:as Try) + (do try.monad + [handler (try.of_maybe (..ensure_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 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))) + handler)] + (..read output)))))] + (for {@.old (as_is <jvm>) + @.jvm (as_is <jvm>) + + @.python + (def: (extender phase_wrapper handler) + (-> platform.Phase_Wrapper Extender) + (:expected handler))})) (def: (phase_wrapper archive) (-> Archive (runtime.Operation platform.Phase_Wrapper)) (do phase.monad [] - (wrap (:as platform.Phase_Wrapper - (..host_phase (list)))))) + (in (:as platform.Phase_Wrapper + (..host_phase (list)))))) (def: platform (IO (Platform Register (_.Expression Any) (_.Statement Any))) (do io.monad [host ..host] - (wrap {#platform.&file_system (file.async file.default) - #platform.host host - #platform.phase python.generate - #platform.runtime runtime.generate - #platform.phase_wrapper ..phase_wrapper - #platform.write (|>> _.code (\ utf8.codec encode))}))) + (in {#platform.&file_system (file.async file.default) + #platform.host host + #platform.phase python.generate + #platform.runtime runtime.generate + #platform.phase_wrapper ..phase_wrapper + #platform.write (|>> _.code (\ utf8.codec encode))}))) (def: (program context program) (Program (_.Expression Any) (_.Statement Any)) @@ -497,29 +510,30 @@ (program: [service /cli.service] (let [extension ".py"] - (exec (do async.monad - [_ (/.compiler {#/static.host @.python - #/static.host_module_extension extension - #/static.target (/cli.target service) - #/static.artifact_extension extension} - ..expander - analysis.bundle - ..platform - generation.bundle - (function.constant extension/bundle.empty) - ..program - [Register - (type (_.Expression Any)) - (type (_.Statement Any))] - ..extender - service - [(packager.package (: (_.Statement Any) (_.manual "")) - _.code - _.then - ..scope) - (format (/cli.target service) - (\ file.default separator) - "program" - extension)])] - (..declare_success! [])) + (exec + (do async.monad + [_ (/.compiler {#/static.host @.python + #/static.host_module_extension extension + #/static.target (/cli.target service) + #/static.artifact_extension extension} + ..expander + analysis.bundle + ..platform + generation.bundle + (function.constant extension/bundle.empty) + ..program + [Register + (type (_.Expression Any)) + (type (_.Statement Any))] + ..extender + service + [(packager.package (: (_.Statement Any) (_.manual "")) + _.code + _.then + ..scope) + (format (/cli.target service) + (\ file.default separator) + "program" + extension)])] + (..declare_success! [])) (io.io [])))) diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux index 969653315..9f956591c 100644 --- a/lux-r/source/program.lux +++ b/lux-r/source/program.lux @@ -396,7 +396,7 @@ (#try.Failure error) (#try.Success member) - (recur (inc idx) (array.write! idx (:as Any member) output))) + (recur (++ idx) (array.write! idx (:as Any member) output))) (#try.Success output))))) (def: (field_class field host_object) diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index b54acaaa9..374009830 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -243,7 +243,7 @@ (if (n.< size idx) (case (org/jruby/RubyArray::get (.int idx) host_object) #.None - (recur (inc idx) output) + (recur (++ idx) output) (#.Some value) (case (read value) @@ -251,7 +251,7 @@ (#try.Failure error) (#try.Success lux_value) - (recur (inc idx) (array.write! idx lux_value output)))) + (recur (++ idx) (array.write! idx lux_value output)))) (#try.Success output))))) (exception: (unknown_kind_of_object {object java/lang/Object}) @@ -380,7 +380,7 @@ {args [org/jruby/runtime/builtin/IRubyObject]} {block org/jruby/runtime/Block}) org/jruby/runtime/builtin/IRubyObject - (let [member (ffi.array_read 0 args)] + (let [member (ffi.read! 0 args)] (<| (case (ffi.check org/jruby/RubyFixnum member) (#.Some member) (case (array.read! (org/jruby/RubyFixnum::getLongValue member) value) @@ -451,7 +451,7 @@ {args [org/jruby/runtime/builtin/IRubyObject]} {block org/jruby/runtime/Block}) org/jruby/runtime/builtin/IRubyObject - (let [reference (ffi.array_read 0 args)] + (let [reference (ffi.read! 0 args)] (case (..read (:as java/lang/Object reference)) (#try.Success reference) (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime (same? (: Any reference) (: Any value))) @@ -514,7 +514,7 @@ {block org/jruby/runtime/Block}) org/jruby/runtime/builtin/IRubyObject (case (|> args - (ffi.array_read 0) + (ffi.read! 0) (ffi.check org/jruby/RubySymbol)) (#.Some method) (|> (case (|> method @@ -587,8 +587,8 @@ (do try.monad [expansion (org/jruby/RubyProc::call (!ruby_thread_context) (|> (ffi.array org/jruby/runtime/builtin/IRubyObject 2) - (ffi.array_write 0 (..to_host inputs)) - (ffi.array_write 1 (..to_host lux))) + (ffi.write! 0 (..to_host inputs)) + (ffi.write! 1 (..to_host lux))) macro)] (..read (:as java/lang/Object expansion))))) @@ -778,11 +778,11 @@ [handler (try.of_maybe (..ensure_macro handler)) output (org/jruby/RubyProc::call (!ruby_thread_context) (|> (ffi.array org/jruby/runtime/builtin/IRubyObject 5) - (ffi.array_write 0 (org/jruby/RubyString::newInternalFromJavaExternal (!ruby_runtime) name)) - (ffi.array_write 1 (:as org/jruby/runtime/builtin/IRubyObject (phase_wrapper phase))) - (ffi.array_write 2 (..to_host archive)) - (ffi.array_write 3 (..to_host parameters)) - (ffi.array_write 4 (..to_host state))) + (ffi.write! 0 (org/jruby/RubyString::newInternalFromJavaExternal (!ruby_runtime) name)) + (ffi.write! 1 (:as org/jruby/runtime/builtin/IRubyObject (phase_wrapper phase))) + (ffi.write! 2 (..to_host archive)) + (ffi.write! 3 (..to_host parameters)) + (ffi.write! 4 (..to_host state))) handler)] (..read (:as java/lang/Object output)))))) diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux index f16b8cdcc..16d1ebcaa 100644 --- a/lux-scheme/source/program.lux +++ b/lux-scheme/source/program.lux @@ -289,7 +289,7 @@ (#try.Failure error) (#try.Success lux_value) - (recur (inc idx) (array.write! idx (: Any lux_value) output))) + (recur (++ idx) (array.write! idx (: Any lux_value) output))) (#try.Success output))))) (def: (read host_object) diff --git a/stdlib/commands.md b/stdlib/commands.md index ff590d8a6..00de913b2 100644 --- a/stdlib/commands.md +++ b/stdlib/commands.md @@ -9,7 +9,7 @@ cd ~/lux/stdlib/ \ cd ~/lux/stdlib/ \ && lux clean \ -&& lux auto test +&& lux with bibliotheca auto test ``` ## Deploy @@ -26,6 +26,9 @@ cd ~/lux/stdlib/ && mvn deploy:deploy-file \ -DartifactId=stdlib \ -Dversion=0.6.0-SNAPSHOT \ -Dpackaging=tar + +cd ~/lux/stdlib/ \ +&& lux install ``` ## Generate documentation @@ -60,6 +63,15 @@ cd ~/lux/stdlib/ \ && lein clean \ && lein with-profile aedifex lux build \ && mv target/program.jar aedifex.jar + +cd ~/lux/stdlib/ \ +&& lux clean \ +&& lux with aedifex auto build + +cd ~/lux/stdlib/ \ +&& lux clean \ +&& lux with aedifex build \ +&& mv target/program.jar aedifex.jar ``` ## Test @@ -68,5 +80,9 @@ cd ~/lux/stdlib/ \ cd ~/lux/stdlib/ \ && lein clean \ && lein with-profile aedifex lux auto test + +cd ~/lux/stdlib/ \ +&& lux clean \ +&& lux with aedifex auto test ``` diff --git a/stdlib/project.clj b/stdlib/project.clj index 81a7dc180..3b0ac6982 100644 --- a/stdlib/project.clj +++ b/stdlib/project.clj @@ -22,13 +22,10 @@ :source-paths ["source"] :dependencies [[com.github.luxlang/lux-bootstrapper ~version]] :profiles {:bibliotheca {:description "Standard library for the Lux programming language." - :dependencies [] :lux {:test "test/lux"}} :aedifex {:description "A build system/tool made exclusively for Lux." - :dependencies [] :lux {:program "program/aedifex" :test "test/aedifex"}} :scriptum {:description "A documentation generator for Lux code." - :dependencies [] :lux {:program "program/scriptum"}}} ) diff --git a/stdlib/project.lux b/stdlib/project.lux index de7325890..e617e015c 100644 --- a/stdlib/project.lux +++ b/stdlib/project.lux @@ -7,10 +7,17 @@ #repositories ["https://oss.sonatype.org/content/repositories/snapshots/" "https://oss.sonatype.org/service/local/staging/deploy/maven2/"] - #compiler ["com.github.luxlang" "lux-jvm" "0.6.0-SNAPSHOT" "jar"] - + #compiler ["com.github.luxlang" "lux-jvm" "0.6.0-SNAPSHOT" "jar"]} + + "bibliotheca" + {#description "Standard library for the Lux programming language." #test "test/lux"} "documentation" {#program "documentation/lux" - #test "documentation/lux"}} + #test "documentation/lux"} + + "aedifex" + {#description "A build system/tool made exclusively for Lux." + #program "program/aedifex" + #test "test/aedifex"}} diff --git a/stdlib/source/documentation/lux/abstract.lux b/stdlib/source/documentation/lux/abstract.lux index 9cc80dcac..a8c0d3b03 100644 --- a/stdlib/source/documentation/lux/abstract.lux +++ b/stdlib/source/documentation/lux/abstract.lux @@ -24,7 +24,7 @@ (.def: .public documentation (.List $.Module) - (list.joined + (list.together (list /apply.documentation /codec.documentation /comonad.documentation diff --git a/stdlib/source/documentation/lux/abstract/comonad.lux b/stdlib/source/documentation/lux/abstract/comonad.lux index f1e220593..5ae976a63 100644 --- a/stdlib/source/documentation/lux/abstract/comonad.lux +++ b/stdlib/source/documentation/lux/abstract/comonad.lux @@ -18,7 +18,7 @@ "A co-monadic parallel to the 'do' macro." [(let [square (function (_ n) (* n n))] (be comonad - [inputs (iterate inc +2)] + [inputs (iterate ++ +2)] (square (out inputs))))]) (.def: .public documentation diff --git a/stdlib/source/documentation/lux/abstract/interval.lux b/stdlib/source/documentation/lux/abstract/interval.lux index f4c57de2a..7162f9ee9 100644 --- a/stdlib/source/documentation/lux/abstract/interval.lux +++ b/stdlib/source/documentation/lux/abstract/interval.lux @@ -11,6 +11,10 @@ (documentation: /.Interval "A representation of top and bottom boundaries for an ordered type.") +(documentation: /.singleton + "An interval where both top and bottom are the same value." + [(singleton enum elem)]) + (documentation: /.borders? "Where a value is at the border of an interval.") @@ -31,13 +35,13 @@ ($.module /._ "" [..Interval + ..singleton ..borders? ..union ..intersection ..complement ..meets? ($.default /.between) - ($.default /.singleton) ($.default /.inner?) ($.default /.outer?) ($.default /.singleton?) diff --git a/stdlib/source/documentation/lux/abstract/monad.lux b/stdlib/source/documentation/lux/abstract/monad.lux index dd472057d..2d55ff0c5 100644 --- a/stdlib/source/documentation/lux/abstract/monad.lux +++ b/stdlib/source/documentation/lux/abstract/monad.lux @@ -21,9 +21,9 @@ z (f2 z)] (in (f3 z)))]) -(documentation: /.bind +(documentation: /.then "Apply a function with monadic effects to a monadic value and yield a new monadic value." - [(bind monad function)]) + [(then monad function)]) (documentation: /.seq "Run all the monadic values in the list and produce a list of the base values." @@ -47,7 +47,7 @@ "" [..Monad ..do - ..bind + ..then ..seq ..map ..only diff --git a/stdlib/source/documentation/lux/control.lux b/stdlib/source/documentation/lux/control.lux index 4fcbe7a98..3a1f688a9 100644 --- a/stdlib/source/documentation/lux/control.lux +++ b/stdlib/source/documentation/lux/control.lux @@ -16,30 +16,21 @@ ["#." io] ["#." lazy] ["#." maybe] - ... ["#." parser] - ... ["#." pipe] - ... ["#." reader] - ... ["#." region] - ... ["#." remember] - ... [security - ... ["#." policy] - ... ["#." capability]] - ... ["#." state] - ... ["#." thread] - ... ["#." try] - ... ["#." writer] + ["#." parser] + ["#." pipe] + ["#." reader] + ["#." region] + ["#." remember] + ["#." security] + ["#." state] + ["#." thread] + ["#." try] + ["#." writer] ]) -... (def: security -... Test -... ($_ _.and -... /policy.documentation -... /capability.documentation -... )) - (.def: .public documentation (.List $.Module) - (list.joined + (list.together (list /concatenative.documentation /concurrency.documentation /continuation.documentation @@ -48,14 +39,14 @@ /io.documentation /lazy.documentation /maybe.documentation - ... /parser.documentation - ... /pipe.documentation - ... /reader.documentation - ... /region.documentation - ... /remember.documentation - ... ..security - ... /state.documentation - ... /thread.documentation - ... /try.documentation - ... /writer.documentation + /parser.documentation + /pipe.documentation + /reader.documentation + /region.documentation + /remember.documentation + /security.documentation + /state.documentation + /thread.documentation + /try.documentation + /writer.documentation ))) diff --git a/stdlib/source/documentation/lux/control/concatenative.lux b/stdlib/source/documentation/lux/control/concatenative.lux index 495bc5512..6c97e056f 100644 --- a/stdlib/source/documentation/lux/control/concatenative.lux +++ b/stdlib/source/documentation/lux/control/concatenative.lux @@ -51,7 +51,7 @@ (documentation: /.apply "A generator for functions that turn arity N functions into arity N concatenative functions." [(: (=> [Nat] [Nat]) - ((apply 1) inc))]) + ((apply 1) ++))]) (template [<arity>] [(with_expansions [<name> (template.identifier [/._] ["apply/" <arity>]) @@ -167,7 +167,7 @@ (documentation: /.do "Do-while loop expression." - [(n.= (inc sample) + [(n.= (++ sample) (||> (push sample) (push (push false)) (push (|>> (push 1) n/+)) diff --git a/stdlib/source/documentation/lux/control/concurrency.lux b/stdlib/source/documentation/lux/control/concurrency.lux index f9b751494..1408c984a 100644 --- a/stdlib/source/documentation/lux/control/concurrency.lux +++ b/stdlib/source/documentation/lux/control/concurrency.lux @@ -18,7 +18,7 @@ (.def: .public documentation (.List $.Module) - (list.joined + (list.together (list /actor.documentation /async.documentation /atom.documentation diff --git a/stdlib/source/documentation/lux/control/concurrency/actor.lux b/stdlib/source/documentation/lux/control/concurrency/actor.lux index 29513888c..6f9327a9a 100644 --- a/stdlib/source/documentation/lux/control/concurrency/actor.lux +++ b/stdlib/source/documentation/lux/control/concurrency/actor.lux @@ -87,7 +87,7 @@ [(actor {Nat 123} ((on_mail message state self) - (message (inc state) self)))]) + (message (++ state) self)))]) (documentation: /.message: (format "A message can access the actor's state through the state parameter." diff --git a/stdlib/source/documentation/lux/control/concurrency/async.lux b/stdlib/source/documentation/lux/control/concurrency/async.lux index 2842ed06b..823967b36 100644 --- a/stdlib/source/documentation/lux/control/concurrency/async.lux +++ b/stdlib/source/documentation/lux/control/concurrency/async.lux @@ -59,17 +59,17 @@ \n "Returns an async that will eventually host its result.") [(future computation)]) -(documentation: /.delayed +(documentation: /.after "Delivers a value after a certain period has passed." - [(delayed milli_seconds value)]) + [(after milli_seconds value)]) (documentation: /.delay "An async that will be resolved after the specified amount of milli-seconds." [(delay milli_seconds)]) -(documentation: /.time_out +(documentation: /.within "Wait for an async to be resolved within the specified amount of milli-seconds." - [(time_out milli_seconds async)]) + [(within milli_seconds async)]) (.def: .public documentation (.List $.Module) @@ -87,9 +87,9 @@ ..either ..schedule! ..future - ..delayed + ..after ..delay - ..time_out + ..within ($.default /.functor) ($.default /.apply) ($.default /.monad)] diff --git a/stdlib/source/documentation/lux/control/concurrency/frp.lux b/stdlib/source/documentation/lux/control/concurrency/frp.lux index 71f740782..2500b119d 100644 --- a/stdlib/source/documentation/lux/control/concurrency/frp.lux +++ b/stdlib/source/documentation/lux/control/concurrency/frp.lux @@ -57,7 +57,7 @@ ($.default /.apply) ($.default /.monad) ($.default /.subscribe!) - ($.default /.folds) + ($.default /.aggregates) ($.default /.poll) ($.default /.periodic) ($.default /.iterations) diff --git a/stdlib/source/documentation/lux/control/exception.lux b/stdlib/source/documentation/lux/control/exception.lux index ec225630a..fae2b0163 100644 --- a/stdlib/source/documentation/lux/control/exception.lux +++ b/stdlib/source/documentation/lux/control/exception.lux @@ -63,7 +63,7 @@ (.def: .public documentation (.List $.Module) ($.module /._ - "" + "Pure-Lux exception-handling functionality." [..Exception ..match? ..when diff --git a/stdlib/source/documentation/lux/control/function.lux b/stdlib/source/documentation/lux/control/function.lux index 889cc8655..88556dda7 100644 --- a/stdlib/source/documentation/lux/control/function.lux +++ b/stdlib/source/documentation/lux/control/function.lux @@ -8,7 +8,12 @@ [macro ["." template]]]] [\\library - ["." /]]) + ["." /]] + ["." / #_ + ["#." contract] + ["#." memo] + ["#." mixin] + ["#." mutual]]) (documentation: /.identity (format "Identity function." @@ -45,4 +50,7 @@ ..flipped ..apply ($.default /.monoid)] - [])) + [/contract.documentation + /memo.documentation + /mixin.documentation + /mutual.documentation])) diff --git a/stdlib/source/documentation/lux/control/function/contract.lux b/stdlib/source/documentation/lux/control/function/contract.lux new file mode 100644 index 000000000..84ef6ad13 --- /dev/null +++ b/stdlib/source/documentation/lux/control/function/contract.lux @@ -0,0 +1,36 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.pre + (format "Pre-conditions." + \n "Given a test and an expression to run, only runs the expression if the test passes." + \n "Otherwise, an error is raised.") + [(pre (i.= +4 (i.+ +2 +2)) + (foo +123 +456 +789))]) + +(documentation: /.post + (format "Post-conditions." + \n "Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate." + \n "If the predicate returns #1, returns the value of the expression." + \n "Otherwise, an error is raised.") + [(post i.even? + (i.+ +2 +2))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..pre + ..post + ($.default /.pre_condition_failed) + ($.default /.post_condition_failed)] + [])) diff --git a/stdlib/source/documentation/lux/control/function/memo.lux b/stdlib/source/documentation/lux/control/function/memo.lux new file mode 100644 index 000000000..823b49772 --- /dev/null +++ b/stdlib/source/documentation/lux/control/function/memo.lux @@ -0,0 +1,36 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.open + "Memoization where the memoized results can be re-used accross invocations." + [(open memo)]) + +(documentation: /.closed + (format "Memoization confined to a single invocation to the function (not counting any subsequent recursive invocations)." + \n "Memoized results will be re-used during recursive invocations, but cannot be accessed after the main invocation has ended.") + [(closed hash memo)]) + +(documentation: /.none + (format "No memoization at all." + \n "This is useful as a test control when measuring the effect of using memoization.") + [(none hash memo)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..open + ..closed + ..none + ($.default /.memoization) + ($.default /.Memo)] + [])) diff --git a/stdlib/source/documentation/lux/control/function/mixin.lux b/stdlib/source/documentation/lux/control/function/mixin.lux new file mode 100644 index 000000000..f23f065b0 --- /dev/null +++ b/stdlib/source/documentation/lux/control/function/mixin.lux @@ -0,0 +1,60 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Mixin + "A partially-defined function which can be mixed with others to inherit their behavior.") + +(documentation: /.mixin + "Given a mixin, produces a normal function." + [(mixin f)]) + +(documentation: /.nothing + "A mixin that does nothing and just delegates work to the next mixin.") + +(documentation: /.with + "Produces a new mixin, where the behavior of the child can make use of the behavior of the parent." + [(with parent child)]) + +(documentation: /.advice + "Only apply then mixin when the input meets some criterion." + [(advice when then)]) + +(documentation: /.before + "Executes an action before doing the main work." + [(before monad action)]) + +(documentation: /.after + "Executes an action after doing the main work." + [(after monad action)]) + +(documentation: /.Recursive + "An indirectly recursive function.") + +(documentation: /.of_recursive + "Transform an indirectly recursive function into a mixin." + [(of_recursive recursive)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Mixin + ..mixin + ..nothing + ..with + ..advice + ..before + ..after + ..Recursive + ..of_recursive + ($.default /.monoid)] + [])) diff --git a/stdlib/source/documentation/lux/control/function/mutual.lux b/stdlib/source/documentation/lux/control/function/mutual.lux new file mode 100644 index 000000000..9dd7588b7 --- /dev/null +++ b/stdlib/source/documentation/lux/control/function/mutual.lux @@ -0,0 +1,50 @@ +(.module: + [library + [lux (#- let def:) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.let + "Locally-defined mutually-recursive functions." + [(let [(even? number) + (-> Nat Bit) + (case number + 0 true + _ (odd? (-- number))) + + (odd? number) + (-> Nat Bit) + (case number + 0 false + _ (even? (-- number)))] + (and (even? 4) + (odd? 5)))]) + +(documentation: /.def: + "Globally-defined mutually-recursive functions." + [(def: + [.public (even? number) + (-> Nat Bit) + (case number + 0 true + _ (odd? (-- number)))] + + [.public (odd? number) + (-> Nat Bit) + (case number + 0 false + _ (even? (-- number)))])]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..let + ..def:] + [])) diff --git a/stdlib/source/documentation/lux/control/io.lux b/stdlib/source/documentation/lux/control/io.lux index 81cf08740..085a70314 100644 --- a/stdlib/source/documentation/lux/control/io.lux +++ b/stdlib/source/documentation/lux/control/io.lux @@ -26,7 +26,7 @@ (.def: .public documentation (.List $.Module) ($.module /._ - "" + "A method for abstracting I/O and effectful computations to make it safe while writing pure functional code." [..IO ..io ..run! diff --git a/stdlib/source/documentation/lux/control/parser.lux b/stdlib/source/documentation/lux/control/parser.lux new file mode 100644 index 000000000..081c5a792 --- /dev/null +++ b/stdlib/source/documentation/lux/control/parser.lux @@ -0,0 +1,180 @@ +(.module: + [library + [lux (#- or and not) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." analysis] + ["#." binary] + ["#." cli] + ["#." code] + ["#." environment] + ... ["#." json] + ... ["#." synthesis] + ... ["#." text] + ... ["#." tree] + ... ["#." type] + ... ["#." xml] + ]) + +(documentation: /.Parser + "A generic parser.") + +(documentation: /.assertion + "Fails with the given message if the test is #0." + [(assertion message test)]) + +(documentation: /.maybe + "Optionality combinator." + [(maybe parser)]) + +(documentation: /.result + (format "Executes the parser on the input." + \n "Does not verify that all of the input has been consumed by the parser." + \n "Returns both the parser's output, and a value that represents the remaining input.") + [(result parser input)]) + +(documentation: /.and + "Sequencing combinator." + [(and first second)]) + +(documentation: /.or + "Heterogeneous alternative combinator." + [(or left right)]) + +(documentation: /.either + "Homogeneous alternative combinator." + [(either this that)]) + +(documentation: /.some + "0-or-more combinator." + [(some parser)]) + +(documentation: /.many + "1-or-more combinator." + [(many parser)]) + +(documentation: /.exactly + "Parse exactly N times." + [(exactly amount parser)]) + +(documentation: /.at_least + "Parse at least N times." + [(at_least amount parser)]) + +(documentation: /.at_most + "Parse at most N times." + [(at_most amount parser)]) + +(documentation: /.between + "" + [(between minimum additional parser)]) + +(documentation: /.separated_by + "Parses instances of 'parser' that are separated by instances of 'separator'." + [(separated_by separator parser)]) + +(documentation: /.not + "Only succeeds when the underlying parser fails." + [(not parser)]) + +(documentation: /.failure + "Always fail with this 'message'." + [(failure message)]) + +(documentation: /.lifted + "Lift a potentially failed computation into a parser." + [(lifted operation)]) + +(documentation: /.else + "If the given parser fails, returns the default value." + [(else value parser)]) + +(documentation: /.remaining + "Yield the remaining input (without consuming it).") + +(documentation: /.rec + "Combinator for recursive parsers." + [(rec parser)]) + +(documentation: /.after + "Run the parser after another one (whose output is ignored)." + [(after param subject)]) + +(documentation: /.before + "Run the parser before another one (whose output is ignored)." + [(before param subject)]) + +(documentation: /.only + "Only succeed when the parser's output passes a test." + [(only test parser)]) + +(documentation: /.parses? + "Ignore a parser's output and just verify that it succeeds." + [(parses? parser)]) + +(documentation: /.parses + "Ignore a parser's output and just execute it." + [(parses parser)]) + +(documentation: /.speculative + (format "Executes a parser, without actually consuming the input." + \n "That way, the same input can be consumed again by another parser.") + [(speculative parser)]) + +(documentation: /.codec + "Decode the output of a parser using a codec." + [(codec codec parser)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Parser + ..assertion + ..maybe + ..result + ..and + ..or + ..either + ..some + ..many + ..exactly + ..at_least + ..at_most + ..between + ..separated_by + ..not + ..failure + ..lifted + ..else + ..remaining + ..rec + ..after + ..before + ..only + ..parses? + ..parses + ..speculative + ..codec + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [/analysis.documentation + /binary.documentation + /cli.documentation + /code.documentation + /environment.documentation + ... /json.documentation + ... /synthesis.documentation + ... /text.documentation + ... /tree.documentation + ... /type.documentation + ... /xml.documentation + ])) diff --git a/stdlib/source/documentation/lux/control/parser/analysis.lux b/stdlib/source/documentation/lux/control/parser/analysis.lux new file mode 100644 index 000000000..1f66be4bf --- /dev/null +++ b/stdlib/source/documentation/lux/control/parser/analysis.lux @@ -0,0 +1,71 @@ +(.module: + [library + [lux (#- nat int rev local) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Parser + "A parser for Lux code analysis nodes.") + +(documentation: /.result + "Executes a parser and makes sure no inputs go unconsumed." + [(result parser input)]) + +(documentation: /.any + "Matches any value, without discrimination.") + +(documentation: /.end! + "Ensures there are no more inputs.") + +(documentation: /.end? + "Checks whether there are no more inputs.") + +(template [<query> <assertion>] + [(`` (as_is (`` (documentation: <query> + (format "Queries for a " (~~ (template.text [<query>])) " value."))) + (`` (documentation: <assertion> + (format "Assert a specific " (~~ (template.text [<query>])) " value.")))))] + + [/.bit /.bit!] + [/.nat /.nat!] + [/.int /.int!] + [/.rev /.rev!] + [/.frac /.frac!] + [/.text /.text!] + [/.local /.local!] + [/.foreign /.foreign!] + [/.constant /.constant!] + ) + +(documentation: /.tuple + "Parses only within the context of a tuple's contents." + [(tuple parser)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Parser + ..result + ..any + ..end! + ..end? + ..bit ..bit! + ..nat ..nat! + ..int ..int! + ..rev ..rev! + ..frac ..frac! + ..text ..text! + ..local ..local! + ..foreign ..foreign! + ..constant ..constant! + ..tuple + ($.default /.cannot_parse) + ($.default /.unconsumed_input)] + [])) diff --git a/stdlib/source/documentation/lux/control/parser/binary.lux b/stdlib/source/documentation/lux/control/parser/binary.lux new file mode 100644 index 000000000..c20d3b0a7 --- /dev/null +++ b/stdlib/source/documentation/lux/control/parser/binary.lux @@ -0,0 +1,139 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Offset + "An offset for reading within binary data.") + +(documentation: /.Parser + "A parser for raw binary data.") + +(documentation: /.result + "Runs a parser and checks that all the binary data was read by it." + [(result parser input)]) + +(documentation: /.end? + "Checks whether there is no more data to read.") + +(documentation: /.offset + "The current offset (i.e. how much data has been read).") + +(documentation: /.remaining + "How much of the data remains to be read.") + +(documentation: /.Size + "The size of a chunk of data within a binary array.") + +(documentation: /.rec + "Tie the knot for a recursive parser.") + +(documentation: /.any + "Does no parsing, and just returns a dummy value.") + +(documentation: /.segment + "Parses a chunk of data of a given size." + [(segment size)]) + +(template [<size> <name>] + [(documentation: <name> + (format "Parses a block of data prefixed with a size that is " (%.nat <size>) " bytes long."))] + + [08 /.binary/8] + [16 /.binary/16] + [32 /.binary/32] + [64 /.binary/64] + ) + +(template [<size> <name>] + [(documentation: <name> + (format "Parses a block of (UTF-8 encoded) text prefixed with a size that is " (%.nat <size>) " bytes long."))] + + [08 /.utf8/8] + [16 /.utf8/16] + [32 /.utf8/32] + [64 /.utf8/64] + ) + +(template [<size> <name>] + [(documentation: <name> + (format "Parses a row of values prefixed with a size that is " (%.nat <size>) " bytes long."))] + + [08 /.row/8] + [16 /.row/16] + [32 /.row/32] + [64 /.row/64] + ) + +(documentation: /.list + "Parses an arbitrarily long list of values." + [(list value)]) + +(documentation: /.set + "" + [(set hash value)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Offset + ..Parser + ..result + ..end? + ..offset + ..remaining + ..Size + ..rec + ..any + ..segment + + ..binary/8 + ..binary/16 + ..binary/32 + ..binary/64 + + ..utf8/8 + ..utf8/16 + ..utf8/32 + ..utf8/64 + + ..row/8 + ..row/16 + ..row/32 + ..row/64 + + ..list + ..set + ($.default /.binary_was_not_fully_read) + ($.default /.size/8) + ($.default /.size/16) + ($.default /.size/32) + ($.default /.size/64) + ($.default /.bits/8) + ($.default /.bits/16) + ($.default /.bits/32) + ($.default /.bits/64) + ($.default /.nat) + ($.default /.int) + ($.default /.rev) + ($.default /.frac) + ($.default /.invalid_tag) + ($.default /.or) + ($.default /.not_a_bit) + ($.default /.bit) + ($.default /.text) + ($.default /.maybe) + ($.default /.set_elements_are_not_unique) + ($.default /.name) + ($.default /.type) + ($.default /.location) + ($.default /.code)] + [])) diff --git a/stdlib/source/documentation/lux/control/parser/cli.lux b/stdlib/source/documentation/lux/control/parser/cli.lux new file mode 100644 index 000000000..ecb2b4cb7 --- /dev/null +++ b/stdlib/source/documentation/lux/control/parser/cli.lux @@ -0,0 +1,59 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Parser + "A command-line interface parser.") + +(documentation: /.result + "Executes the parser and verifies that all inputs are processed." + [(result parser inputs)]) + +(documentation: /.any + "Just returns the next input without applying any logic.") + +(documentation: /.parse + "Parses the next input with a parsing function." + [(parse parser)]) + +(documentation: /.this + "Checks that a token is in the inputs." + [(this reference)]) + +(documentation: /.somewhere + "Given a parser, tries to parse it somewhere in the inputs (i.e. not necessarily parsing the immediate inputs)." + [(somewhere cli)]) + +(documentation: /.end + "Ensures there are no more inputs.") + +(documentation: /.named + "Parses a named parameter and yields its value." + [(named name value)]) + +(documentation: /.parameter + "Parses a parameter that can have either a short or a long name." + [(parameter [short long] value)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Parser + ..result + ..any + ..parse + ..this + ..somewhere + ..end + ..named + ..parameter] + [])) diff --git a/stdlib/source/documentation/lux/control/parser/code.lux b/stdlib/source/documentation/lux/control/parser/code.lux new file mode 100644 index 000000000..aa7e91442 --- /dev/null +++ b/stdlib/source/documentation/lux/control/parser/code.lux @@ -0,0 +1,113 @@ +(.module: + [library + [lux (#- nat int rev local) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Parser + "A Lux code parser.") + +(documentation: /.any + "Yields the next input without applying any logic.") + +(template [<query> <check>] + [(`` (documentation: <query> + (format "Parses the next " (~~ (template.text [<query>])) " input."))) + (`` (documentation: <check> + (format "Checks for a specific " (~~ (template.text [<query>])) " input.")))] + + [/.bit /.bit!] + [/.nat /.nat!] + [/.int /.int!] + [/.rev /.rev!] + [/.frac /.frac!] + [/.text /.text!] + [/.identifier /.identifier!] + [/.tag /.tag!] + ) + +(documentation: /.this! + "Ensures the given Code is the next input." + [(this! code)]) + +(template [<query> <check> <desc>] + [(documentation: <query> + (format "Parse a local " <desc> " (a " <desc> " that has no module prefix).")) + (documentation: <check> + (format "Checks for a specific local " <desc> " (a " <desc> " that has no module prefix)."))] + + [/.local_identifier /.local_identifier! "local identifier"] + [ /.local_tag /.local_tag! "local tag"] + ) + +(template [<name>] + [(`` (documentation: <name> + (format "Parses the contents of a " (~~ (template.text [<name>])) ".")))] + + [/.form] + [/.tuple] + ) + +(documentation: /.record + "Parses the contents of a record.") + +(documentation: /.end! + "Verifies there are no more inputs.") + +(documentation: /.end? + "Checks whether there are no more inputs.") + +(documentation: /.result + "Executes a parser against a stream of code, and verifies all the inputs are consumed." + [(result parser inputs)]) + +(documentation: /.local + "Runs parser against the given list of inputs." + [(local inputs parser)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Parser + ..any + + ..bit + ..bit! + ..nat + ..nat! + ..int + ..int! + ..rev + ..rev! + ..frac + ..frac! + ..text + ..text! + ..identifier + ..identifier! + ..tag + ..tag! + + ..this! + + ..local_identifier + ..local_identifier! + ..local_tag + ..local_tag! + + ..form + ..tuple + + ..record + ..end! + ..end? + ..result + ..local] + [])) diff --git a/stdlib/source/documentation/lux/control/parser/environment.lux b/stdlib/source/documentation/lux/control/parser/environment.lux new file mode 100644 index 000000000..f4961a0d4 --- /dev/null +++ b/stdlib/source/documentation/lux/control/parser/environment.lux @@ -0,0 +1,45 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Property + "A property in the environment.") + +(documentation: /.Environment + "An abstraction for environment variables of a program.") + +(documentation: /.Parser + "A parser of environment variables of a program.") + +(documentation: /.empty + "An empty environment.") + +(documentation: /.property + "" + [(property name)]) + +(documentation: /.result + (format "Executes a parser against the given environment variables." + \n "Does not check whether all environment variables were parsed, since they're usually an open set.") + [(result parser environment)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Property + ..Environment + ..Parser + ..empty + ..property + ..result + ($.default /.unknown_property)] + [])) diff --git a/stdlib/source/documentation/lux/control/pipe.lux b/stdlib/source/documentation/lux/control/pipe.lux new file mode 100644 index 000000000..f18415290 --- /dev/null +++ b/stdlib/source/documentation/lux/control/pipe.lux @@ -0,0 +1,117 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.new> + "Ignores the piped argument, and begins a new pipe." + [(n.= 1 + (|> 20 + (n.* 3) + (n.+ 4) + (new> 0 [++])))]) + +(documentation: /.let> + "Gives a name to the piped-argument, within the given expression." + [(n.= 10 + (|> 5 + (let> x (n.+ x x))))]) + +(documentation: /.cond> + (format "Branching for pipes." + \n "Both the tests and the bodies are piped-code, and must be given inside a tuple.") + [(|> +5 + (cond> [i.even?] [(i.* +2)] + [i.odd?] [(i.* +3)] + [(new> -1 [])]))]) + +(documentation: /.if> + "If-branching." + [(same? (if (n.even? sample) + "even" + "odd") + (|> sample + (if> [n.even?] + [(new> "even" [])] + [(new> "odd" [])])))]) + +(documentation: /.when> + "Only execute the body when the test passes." + [(same? (if (n.even? sample) + (n.* 2 sample) + sample) + (|> sample + (when> [n.even?] + [(n.* 2)])))]) + +(documentation: /.loop> + (format "Loops for pipes." + \n "Both the testing and calculating steps are pipes and must be given inside tuples.") + [(|> +1 + (loop> [(i.< +10)] + [++]))]) + +(documentation: /.do> + (format "Monadic pipes." + \n "Each steps in the monadic computation is a pipe and must be given inside a tuple.") + [(|> +5 + (do> identity.monad + [(i.* +3)] + [(i.+ +4)] + [++]))]) + +(documentation: /.exec> + (format "Non-updating pipes." + \n "Will generate piped computations, but their results will not be used in the larger scope.") + [(|> +5 + (exec> [.nat %n log!]) + (i.* +10))]) + +(documentation: /.tuple> + (format "Parallel branching for pipes." + \n "Allows to run multiple pipelines for a value and gives you a tuple of the outputs.") + [(|> +5 + (tuple> [(i.* +10)] + [-- (i./ +2)] + [i\encode])) + "=>" + [+50 +2 "+5"]]) + +(documentation: /.case> + (format "Pattern-matching for pipes." + \n "The bodies of each branch are NOT pipes; just regular values.") + [(|> +5 + (case> +0 "zero" + +1 "one" + +2 "two" + +3 "three" + +4 "four" + +5 "five" + +6 "six" + +7 "seven" + +8 "eight" + +9 "nine" + _ "???"))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..new> + ..let> + ..cond> + ..if> + ..when> + ..loop> + ..do> + ..exec> + ..tuple> + ..case>] + [])) diff --git a/stdlib/source/documentation/lux/control/reader.lux b/stdlib/source/documentation/lux/control/reader.lux new file mode 100644 index 000000000..959c44217 --- /dev/null +++ b/stdlib/source/documentation/lux/control/reader.lux @@ -0,0 +1,47 @@ +(.module: + [library + [lux (#- local) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Reader + "Computations that have access to some environmental value.") + +(documentation: /.read + "Get the environment.") + +(documentation: /.local + "Run computation with a locally-modified environment." + [(local change proc)]) + +(documentation: /.result + "Executes the reader against the given environment." + [(result env proc)]) + +(documentation: /.with + "Monad transformer for Reader." + [(with monad)]) + +(documentation: /.lifted + "Lift monadic values to the Reader wrapper.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Reader + ..read + ..local + ..result + ..with + ..lifted + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/documentation/lux/control/region.lux b/stdlib/source/documentation/lux/control/region.lux new file mode 100644 index 000000000..08e8177b9 --- /dev/null +++ b/stdlib/source/documentation/lux/control/region.lux @@ -0,0 +1,51 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Region + (format "A region where resources may be be claimed and where a side-effecting computation may be performed." + \n "Every resource is paired with a function that knows how to clean/reclaim it, to make sure there are no leaks.")) + +(documentation: /.run! + "Executes a region-based computation, with a side-effect determined by the monad." + [(run! monad computation)]) + +(documentation: /.acquire! + "Acquire a resource while pairing it a function that knows how to reclaim it." + [(acquire! monad cleaner value)]) + +(documentation: /.failure + "Immediately fail with this 'message'." + [(failure monad error)]) + +(documentation: /.except + "Fail by throwing/raising an exception." + [(except monad exception message)]) + +(documentation: /.lifted + "Lift an effectful computation into a region-based computation." + [(lifted monad operation)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Region + ..run! + ..acquire! + ..failure + ..except + ..lifted + ($.default /.clean_up_error) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/documentation/lux/control/remember.lux b/stdlib/source/documentation/lux/control/remember.lux new file mode 100644 index 000000000..c17fdf3cc --- /dev/null +++ b/stdlib/source/documentation/lux/control/remember.lux @@ -0,0 +1,38 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(template [<name> <type>] + [(`` (documentation: <name> + (format "A" <type> " message with an expiration date." + \n "Can have an optional piece of code to focus on.") + [((~~ (template.identifier [<name>])) + "2022-04-01" + "Do this, that and the other.")] + [((~~ (template.identifier [<name>])) + "2022-04-01" + "Improve the performace." + (some (complicated (computation 123))))]))] + + [/.remember ""] + [/.to_do " TODO"] + [/.fix_me " FIXME"] + ) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..remember + ..to_do + ..fix_me + ($.default /.must_remember)] + [])) diff --git a/stdlib/source/documentation/lux/control/security.lux b/stdlib/source/documentation/lux/control/security.lux new file mode 100644 index 000000000..ac39298dd --- /dev/null +++ b/stdlib/source/documentation/lux/control/security.lux @@ -0,0 +1,18 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list]]]]] + ["." / #_ + ["#." capability] + ["#." policy]]) + +(.def: .public documentation + (.List $.Module) + (list.together + (list /policy.documentation + /capability.documentation))) diff --git a/stdlib/source/documentation/lux/control/security/capability.lux b/stdlib/source/documentation/lux/control/security/capability.lux new file mode 100644 index 000000000..fb43184d8 --- /dev/null +++ b/stdlib/source/documentation/lux/control/security/capability.lux @@ -0,0 +1,44 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Capability + (format "Represents the capability to perform an operation." + \n "This operation is assumed to have security implications.")) + +(documentation: /.use + "Applies a capability against its required input." + [(use capability input)]) + +(documentation: /.capability: + "Defines a capability as a unique type, and a constructor for instances." + [(capability: (Can_Duplicate a) + (can_duplicate a [a a])) + + (let [capability (can_duplicate + (function (_ value) + [value value])) + [left right] (..use capability 123)] + (same? left right))]) + +(documentation: /.async + "Converts a synchronous I/O-based capability into an asynchronous capability." + [(async capability)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Capability + ..use + ..capability: + ..async] + [])) diff --git a/stdlib/source/documentation/lux/control/security/policy.lux b/stdlib/source/documentation/lux/control/security/policy.lux new file mode 100644 index 000000000..9d9cb655d --- /dev/null +++ b/stdlib/source/documentation/lux/control/security/policy.lux @@ -0,0 +1,89 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Policy + "A security policy encoded as the means to 'upgrade' or 'downgrade' in a secure context.") + +(documentation: /.Can_Upgrade + "Represents the capacity to 'upgrade' a value.") + +(documentation: /.Can_Downgrade + "Represents the capacity to 'downgrade' a value.") + +(documentation: /.Privilege + "Represents the privilege to both 'upgrade' and 'downgrade' a value.") + +(documentation: /.Delegation + "Represents the act of delegating policy capacities.") + +(documentation: /.delegation + "Delegating policy capacities." + [(delegation downgrade upgrade)]) + +(documentation: /.Context + "A computational context with an associated policy privilege.") + +(documentation: /.with_policy + "Activates a security context with the priviledge to enforce it's policy." + [(type: Password + (Private Text)) + + (interface: (Policy %) + (: (-> Text (Password %)) + password) + (: (-> (Password %) Text) + unsafe)) + + (def: (policy _) + (Ex [%] (-> Any (Policy %))) + (with_policy + (: (Context Privacy Policy) + (function (_ (^open "%::.")) + (implementation + (def: (password value) + (%::can_upgrade value)) + (def: (unsafe password) + (%::can_downgrade password)))))))] + [(with_policy context)]) + +(documentation: /.Privacy + (format "A security context for privacy." + \n "Private data is data which cannot be allowed to leak outside of the programmed.")) + +(documentation: /.Safety + (format "A security context for safety." + \n "Safe data is data coming from outside the program which can be trusted to be properly formatted and lacking injections.")) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Policy + ..Can_Upgrade + ..Can_Downgrade + ..Privilege + ..Delegation + ..delegation + ..Context + ..with_policy + ..Privacy + ..Safety + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.Private) + ($.default /.Can_Conceal) + ($.default /.Can_Reveal) + ($.default /.Safe) + ($.default /.Can_Trust) + ($.default /.Can_Distrust)] + [])) diff --git a/stdlib/source/documentation/lux/control/state.lux b/stdlib/source/documentation/lux/control/state.lux new file mode 100644 index 000000000..99be4d130 --- /dev/null +++ b/stdlib/source/documentation/lux/control/state.lux @@ -0,0 +1,82 @@ +(.module: + [library + [lux (#- local) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.State + "Stateful computations.") + +(documentation: /.get + "Read the current state.") + +(documentation: /.put + "Set the new state." + [(put new_state)]) + +(documentation: /.update + "Compute the new state." + [(update change)]) + +(documentation: /.use + "Run a function on the current state." + [(use user)]) + +(documentation: /.local + "Run the computation with a locally-modified state." + [(local change action)]) + +(documentation: /.result + "Run a stateful computation." + [(result state action)]) + +(documentation: /.while + "A stateful while loop." + [(while condition body)]) + +(documentation: /.do_while + "A stateful do-while loop." + [(do_while condition body)]) + +(documentation: /.+State + "Stateful computations decorated by a monad.") + +(documentation: /.result' + "Execute a stateful computation decorated by a monad." + [(result' state action)]) + +(documentation: /.with + "A monad transformer to create composite stateful computations." + [(with monad)]) + +(documentation: /.lifted + "Lift monadic values to the +State wrapper." + [(lifted monad ma)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..State + ..get + ..put + ..update + ..use + ..local + ..result + ..while + ..do_while + ..+State + ..result' + ..with + ..lifted + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/documentation/lux/control/thread.lux b/stdlib/source/documentation/lux/control/thread.lux new file mode 100644 index 000000000..cc3134d2f --- /dev/null +++ b/stdlib/source/documentation/lux/control/thread.lux @@ -0,0 +1,57 @@ +(.module: + [library + [lux (#- local) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Thread + "An imperative process with access to mutable values.") + +(documentation: /.Box + "A mutable box holding a value.") + +(documentation: /.box + "A brand-new box initialized to the given value." + [(box init)]) + +(documentation: /.read! + "Reads the current value in the box." + [(read! box)]) + +(documentation: /.write! + "Mutates the value in the box." + [(write! value box)]) + +(documentation: /.result + "Executes the imperative thread in a self-contained way." + [(result thread)]) + +(documentation: /.io + "Transforms the imperative thread into an I/O computation.") + +(documentation: /.update! + "Update a box's value by applying a function to it." + [(update! f box)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Thread + ..Box + ..box + ..read! + ..write! + ..result + ..io + ..update! + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/documentation/lux/control/try.lux b/stdlib/source/documentation/lux/control/try.lux new file mode 100644 index 000000000..7b226c132 --- /dev/null +++ b/stdlib/source/documentation/lux/control/try.lux @@ -0,0 +1,62 @@ +(.module: + [library + [lux (#- local) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Try + "A computation that can fail with an error message.") + +(documentation: /.with + "Enhances a monad with error-handling functionality." + [(with monad)]) + +(documentation: /.lifted + "Wraps a monadic value with error-handling machinery." + [(lifted monad)]) + +(documentation: /.trusted + (format "Assumes a Try value succeeded, and yields its value." + \n "If it didn't, raises the error as a runtime error." + \n "WARNING: Use with caution.") + [(trusted try)]) + +(documentation: /.maybe + "" + [(maybe try)]) + +(documentation: /.of_maybe + "" + [(of_maybe maybe)]) + +(documentation: /.else + (format "Allows you to provide a default value that will be used" + \n "if a (Try x) value turns out to be #Failure." + \n "Note: the expression for the default value will not be computed if the base computation succeeds.") + [(= "bar" + (else "foo" (#..Success "bar")))] + [(= "foo" + (else "foo" (#..Failure "KABOOM!")))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Try + ..with + ..lifted + ..trusted + ..maybe + ..of_maybe + ..else + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.equivalence)] + [])) diff --git a/stdlib/source/documentation/lux/control/writer.lux b/stdlib/source/documentation/lux/control/writer.lux new file mode 100644 index 000000000..99cbe0463 --- /dev/null +++ b/stdlib/source/documentation/lux/control/writer.lux @@ -0,0 +1,39 @@ +(.module: + [library + [lux (#- local) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Writer + "Represents a value with an associated 'log' to record arbitrary information.") + +(documentation: /.write + "Write a value to the log." + [(write message)]) + +(documentation: /.with + "Enhances a monad with Writer functionality." + [(with monoid monad)]) + +(documentation: /.lifted + "Wraps a monadic value with Writer machinery." + [(lifted monoid monad)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Writer + ..write + ..with + ..lifted + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index f9be2bf36..6554978c9 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -2109,8 +2109,8 @@ "... By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." __paragraph "(template [<name> <diff>]" ..\n " " "[(def: .public <name> (-> Int Int) (+ <diff>))]" __paragraph - " " "[inc +1]" ..\n - " " "[dec -1]"))]) + " " "[++ +1]" ..\n + " " "[-- -1]"))]) ({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])]) ({[(#Some bindings') (#Some data')] (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) @@ -4460,16 +4460,16 @@ (All [a] (-> (List a) (List [Nat a]))) (enumeration' 0 xs)) -(macro: .public (get@ tokens) +(macro: .public (value@ tokens) {#.doc (text$ ($_ "lux text concat" "... Accesses the value of a record at a given tag." ..\n - "(get@ #field my_record)" + "(value@ #field my_record)" __paragraph "... Can also work with multiple levels of nesting:" ..\n - "(get@ [#foo #bar #baz] my_record)" + "(value@ [#foo #bar #baz] my_record)" __paragraph "... And, if only the slot/path is given, generates an accessor function:" ..\n - "(let [getter (get@ [#foo #bar #baz])]" ..\n + "(let [getter (value@ [#foo #bar #baz])]" ..\n " (getter my_record))"))} (case tokens (^ (list [_ (#Tag slot')] record)) @@ -4491,12 +4491,12 @@ (in_meta (list (` ({(~ pattern) (~ g!output)} (~ record)))))) _ - (failure "get@ can only use records."))) + (failure "value@ can only use records."))) (^ (list [_ (#Tuple slots)] record)) (in_meta (list (list\fold (: (-> Code Code Code) (function (_ slot inner) - (` (..get@ (~ slot) (~ inner))))) + (` (..value@ (~ slot) (~ inner))))) record slots))) @@ -4504,10 +4504,10 @@ (do meta_monad [g!_ (..identifier "_") g!record (..identifier "record")] - (in (list (` (function ((~ g!_) (~ g!record)) (..get@ (~ selector) (~ g!record))))))) + (in (list (` (function ((~ g!_) (~ g!record)) (..value@ (~ selector) (~ g!record))))))) _ - (failure "Wrong syntax for get@"))) + (failure "Wrong syntax for value@"))) (def: (open_declaration alias tags my_tag_index [module short] source type) (-> Text (List Name) Nat Name Code Type (Meta (List Code))) @@ -4774,17 +4774,17 @@ _ (failure "Wrong syntax for \"))) -(macro: .public (set@ tokens) +(macro: .public (with@ tokens) {#.doc (text$ ($_ "lux text concat" "... Sets the value of a record at a given tag." ..\n - "(set@ #name ''Lux'' lang)" + "(with@ #name ''Lux'' lang)" __paragraph "... Can also work with multiple levels of nesting:" ..\n - "(set@ [#foo #bar #baz] value my_record)" + "(with@ [#foo #bar #baz] value my_record)" __paragraph "... And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..\n - "(let [setter (set@ [#foo #bar #baz] value)] (setter my_record))" ..\n - "(let [setter (set@ [#foo #bar #baz])] (setter value my_record))"))} + "(let [setter (with@ [#foo #bar #baz] value)] (setter my_record))" ..\n + "(let [setter (with@ [#foo #bar #baz])] (setter value my_record))"))} (case tokens (^ (list [_ (#Tag slot')] value record)) (do meta_monad @@ -4816,12 +4816,12 @@ (in_meta (list (` ({(~ pattern) (~ output)} (~ record))))))) _ - (failure "set@ can only use records."))) + (failure "with@ can only use records."))) (^ (list [_ (#Tuple slots)] value record)) (case slots #End - (failure "Wrong syntax for set@") + (failure "Wrong syntax for with@") _ (do meta_monad @@ -4832,12 +4832,12 @@ .let [pairs (zipped/2 slots bindings) update_expr (list\fold (: (-> [Code Code] Code Code) (function (_ [s b] v) - (` (..set@ (~ s) (~ v) (~ b))))) + (` (..with@ (~ s) (~ v) (~ b))))) value (list\reverse pairs)) [_ accesses'] (list\fold (: (-> [Code Code] [Code (List (List Code))] [Code (List (List Code))]) (function (_ [new_slot new_binding] [old_record accesses']) - [(` (get@ (~ new_slot) (~ new_binding))) + [(` (value@ (~ new_slot) (~ new_binding))) (#Item (list new_binding old_record) accesses')])) [record (: (List (List Code)) #End)] pairs) @@ -4850,7 +4850,7 @@ [g!_ (..identifier "_") g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!record)) - (..set@ (~ selector) (~ value) (~ g!record))))))) + (..with@ (~ selector) (~ value) (~ g!record))))))) (^ (list selector)) (do meta_monad @@ -4858,22 +4858,22 @@ g!value (..identifier "value") g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!value) (~ g!record)) - (..set@ (~ selector) (~ g!value) (~ g!record))))))) + (..with@ (~ selector) (~ g!value) (~ g!record))))))) _ - (failure "Wrong syntax for set@"))) + (failure "Wrong syntax for with@"))) -(macro: .public (update@ tokens) +(macro: .public (revised@ tokens) {#.doc (text$ ($_ "lux text concat" "... Modifies the value of a record at a given tag, based on some function." ..\n - "(update@ #age inc person)" + "(revised@ #age ++ person)" __paragraph "... Can also work with multiple levels of nesting:" ..\n - "(update@ [#foo #bar #baz] func my_record)" + "(revised@ [#foo #bar #baz] func my_record)" __paragraph "... And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..\n - "(let [updater (update@ [#foo #bar #baz] func)] (updater my_record))" ..\n - "(let [updater (update@ [#foo #bar #baz])] (updater func my_record))"))} + "(let [updater (revised@ [#foo #bar #baz] func)] (updater my_record))" ..\n + "(let [updater (revised@ [#foo #bar #baz])] (updater func my_record))"))} (case tokens (^ (list [_ (#Tag slot')] fun record)) (do meta_monad @@ -4905,27 +4905,27 @@ (in_meta (list (` ({(~ pattern) (~ output)} (~ record))))))) _ - (failure "update@ can only use records."))) + (failure "revised@ can only use records."))) (^ (list [_ (#Tuple slots)] fun record)) (case slots #End - (failure "Wrong syntax for update@") + (failure "Wrong syntax for revised@") _ (do meta_monad [g!record (..identifier "record") g!temp (..identifier "temp")] (in (list (` (let [(~ g!record) (~ record) - (~ g!temp) (get@ [(~+ slots)] (~ g!record))] - (set@ [(~+ slots)] ((~ fun) (~ g!temp)) (~ g!record)))))))) + (~ g!temp) (value@ [(~+ slots)] (~ g!record))] + (with@ [(~+ slots)] ((~ fun) (~ g!temp)) (~ g!record)))))))) (^ (list selector fun)) (do meta_monad [g!_ (..identifier "_") g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!record)) - (..update@ (~ selector) (~ fun) (~ g!record))))))) + (..revised@ (~ selector) (~ fun) (~ g!record))))))) (^ (list selector)) (do meta_monad @@ -4933,10 +4933,10 @@ g!fun (..identifier "fun") g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!fun) (~ g!record)) - (..update@ (~ selector) (~ g!fun) (~ g!record))))))) + (..revised@ (~ selector) (~ g!fun) (~ g!record))))))) _ - (failure "Wrong syntax for update@"))) + (failure "Wrong syntax for revised@"))) (macro: .public (^template tokens) {#.doc (text$ ($_ "lux text concat" @@ -5047,8 +5047,8 @@ (All [s] (-> (I64 s) (I64 s))) (|>> (<extension> 1)))] - [inc "lux i64 +" "Increment function."] - [dec "lux i64 -" "Decrement function."] + [++ "lux i64 +" "Increment function."] + [-- "lux i64 -" "Decrement function."] ) (def: tag\encode @@ -5107,9 +5107,9 @@ (let [[group_location' parts_text] (list\fold (function (_ part [last_location text_accum]) (let [[part_location part_text] (example_documentation last_location baseline part)] [part_location (text\compose text_accum part_text)])) - [(update@ #column inc group_location) ""] + [(revised@ #column ++ group_location) ""] (<prep> parts))] - [(update@ #column inc group_location') + [(revised@ #column ++ group_location') ($_ text\compose (location_padding baseline prev_location group_location) <open> parts_text @@ -5134,7 +5134,7 @@ (#Documentation_Example example) (let [baseline (baseline_column example) [location _] example - [_ text] (..example_documentation (set@ #.column baseline location) baseline example)] + [_ text] (..example_documentation (with@ #.column baseline location) baseline example)] (text\compose text __paragraph)))) (macro: .public (example tokens) @@ -5147,7 +5147,7 @@ " (loop [count +0" ..\n " x init]" ..\n " (if (< +10 count)" ..\n - " (recur (inc count) (f x))" ..\n + " (recur (++ count) (f x))" ..\n " x)))"))} (in_meta (list (` [(~ location_code) (#.Text (~ (|> tokens @@ -5206,7 +5206,7 @@ (loop [count +0 x init] (if (< +10 count) - (recur (inc count) (f x)) + (recur (++ count) (f x)) x)) "Loops can also be given custom names." @@ -5214,7 +5214,7 @@ [count +0 x init] (if (< +10 count) - (my_loop (inc count) (f x)) + (my_loop (++ count) (f x)) x)))} (let [?params (case tokens (^ (list name [_ (#Tuple bindings)] body)) @@ -5665,7 +5665,7 @@ (macro: .public (^|> tokens) {#.doc (example "Pipes the value being pattern-matched against prior to binding it to a variable." (case input - (^|> value [inc (% 10) (max 1)]) + (^|> value [++ (% 10) (max 1)]) (foo value)))} (case tokens (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] [_ (#Tuple steps)]))] body branches)) @@ -5696,7 +5696,7 @@ {#.doc "The location of the current expression being analyzed."} (Meta Location) (function (_ compiler) - (#Right [compiler (get@ #location compiler)]))) + (#Right [compiler (value@ #location compiler)]))) (macro: .public (undefined tokens) {#.doc (example "Meant to be used as a stand-in for functions with undefined implementations." @@ -5845,7 +5845,7 @@ (def: target (Meta Text) (function (_ compiler) - (#Right [compiler (get@ [#info #target] compiler)]))) + (#Right [compiler (value@ [#info #target] compiler)]))) (def: (platform_name choice) (-> Code (Meta Text)) diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index 7b57f5671..0b80263e8 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -19,7 +19,8 @@ (Apply (All [a] (F (G a)))))) (def: &functor - (functor.composite (get@ #&functor f_apply) (get@ #&functor g_apply))) + (functor.composite (value@ #&functor f_apply) + (value@ #&functor g_apply))) (def: (apply fgf fgx) ... TODO: Switch from this version to the one below (in comments) ASAP. diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index cea44c57b..4c6060d4d 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -25,7 +25,6 @@ (def: top top))) (def: .public (singleton enum elem) - {#.doc (example "An interval where both top and bottom are the same value.")} (All [a] (-> (Enum a) a (Interval a))) (implementation (def: &enum enum) @@ -76,21 +75,21 @@ (implementation: .public (union left right) (All [a] (-> (Interval a) (Interval a) (Interval a))) - (def: &enum (get@ #&enum right)) + (def: &enum (value@ #&enum right)) (def: bottom (order.min (\ right &order) (\ left bottom) (\ right bottom))) (def: top (order.max (\ right &order) (\ left top) (\ right top)))) (implementation: .public (intersection left right) (All [a] (-> (Interval a) (Interval a) (Interval a))) - (def: &enum (get@ #&enum right)) + (def: &enum (value@ #&enum right)) (def: bottom (order.max (\ right &order) (\ left bottom) (\ right bottom))) (def: top (order.min (\ right &order) (\ left top) (\ right top)))) (implementation: .public (complement interval) (All [a] (-> (Interval a) (Interval a))) - (def: &enum (get@ #&enum interval)) + (def: &enum (value@ #&enum interval)) (def: bottom (\ interval succ (\ interval top))) (def: top (\ interval pred (\ interval bottom)))) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 6ba4f74aa..2d81c09e7 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -25,7 +25,7 @@ counter (#.Item _ xs') - (recur (inc counter) xs')))) + (recur (++ counter) xs')))) (def: (reversed xs) (All [a] @@ -105,17 +105,17 @@ #.None (#.Left "Wrong syntax for 'do'"))) -(def: .public (bind monad f) +(def: .public (then monad f) (All [! a b] (-> (Monad !) (-> a (! b)) (-> (! a) (! b)))) (|>> (\ monad map f) (\ monad join))) -(def: .public (seq monad) - (All [M a] - (-> (Monad M) (List (M a)) - (M (List a)))) +(def: .public (all monad) + (All [! a] + (-> (Monad !) (List (! a)) + (! (List a)))) (let [(^open "!\.") monad] (function (recur xs) (case xs diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index 9f64ec76d..b43ac87e8 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -21,7 +21,7 @@ (-> (-> vi (m it io vo)) (m ii it vi) (m ii io vo))) - bind)) + then)) (type: Binding [Code Code]) @@ -32,7 +32,7 @@ (type: Context (#Macro Name Code) - (#Bind Binding)) + (#Binding Binding)) (def: global_identifier (Parser Name) @@ -62,7 +62,7 @@ (syntax: .public (do [[?name monad] ..named_monad context (<code>.tuple (<>.some context)) expression <code>.any]) - (macro.with_identifiers [g!_ g!bind] + (macro.with_identifiers [g!_ g!then] (let [body (list\fold (function (_ context next) (case context (#Macro macro parameter) @@ -70,8 +70,8 @@ (~ parameter) (~ next))) - (#Bind [binding value]) - (` ((~ g!bind) + (#Binding [binding value]) + (` ((~ g!then) (.function ((~ g!_) (~ binding)) (~ next)) (~ value))))) @@ -82,10 +82,10 @@ (let [name (code.local_identifier name)] (` (let [(~ name) (~ monad) {#..in (~' in) - #..bind (~ g!bind)} (~ name)] + #..then (~ g!then)} (~ name)] (~ body)))) #.None (` (let [{#..in (~' in) - #..bind (~ g!bind)} (~ monad)] + #..then (~ g!then)} (~ monad)] (~ body))))))))) diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index 53c3288c6..fac4862ae 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -3,8 +3,6 @@ [lux #*]]) (interface: .public (Monoid a) - {#.doc (example "A way to compose values." - "Includes an identity value which does not alter any other value when combined with.")} (: a identity) (: (-> a a a) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 03ae8afe6..93a99ceb2 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -78,20 +78,20 @@ (code.replaced (code.local_identifier from) to pre)) aliased aliases))] - (case [(|> inputs (get@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`)))) - (|> outputs (get@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`))))] + (case [(|> inputs (value@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`)))) + (|> outputs (value@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`))))] [(#.Some bottomI) (#.Some bottomO)] (monad.do meta.monad - [inputC (singleton (macro.full_expansion (stack_fold (get@ #top inputs) bottomI))) - outputC (singleton (macro.full_expansion (stack_fold (get@ #top outputs) bottomO)))] + [inputC (singleton (macro.full_expansion (stack_fold (value@ #top inputs) bottomI))) + outputC (singleton (macro.full_expansion (stack_fold (value@ #top outputs) bottomO)))] (in (list (` (-> (~ (de_alias inputC)) (~ (de_alias outputC))))))) [?bottomI ?bottomO] (with_identifiers [g!stack] (monad.do meta.monad - [inputC (singleton (macro.full_expansion (stack_fold (get@ #top inputs) (maybe.else g!stack ?bottomI)))) - outputC (singleton (macro.full_expansion (stack_fold (get@ #top outputs) (maybe.else g!stack ?bottomO))))] + [inputC (singleton (macro.full_expansion (stack_fold (value@ #top inputs) (maybe.else g!stack ?bottomI)))) + outputC (singleton (macro.full_expansion (stack_fold (value@ #top outputs) (maybe.else g!stack ?bottomO))))] (in (list (` (All [(~ g!stack)] (-> (~ (de_alias inputC)) (~ (de_alias outputC)))))))))))) @@ -130,7 +130,7 @@ (syntax: .public (apply [arity (<>.only (n.> 0) <code>.nat)]) (with_identifiers [g! g!func g!stack g!output] (monad.do {! meta.monad} - [g!inputs (|> (macro.identifier "input") (list.repeated arity) (monad.seq !))] + [g!inputs (|> (macro.identifier "input") (list.repeated arity) (monad.all !))] (in (list (` (: (All [(~+ g!inputs) (~ g!output)] (-> (-> (~+ g!inputs) (~ g!output)) (=> [(~+ g!inputs)] [(~ g!output)]))) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index e51be0b98..20ab00c06 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -90,13 +90,13 @@ (:abstraction {#obituary (async.async []) #mailbox (atom (async.async []))})) process (loop [state (on_init init) - [|mailbox| _] (io.run! (atom.read! (get@ #mailbox (:representation self))))] + [|mailbox| _] (io.run! (atom.read! (value@ #mailbox (:representation self))))] (do {! async.monad} [[head tail] |mailbox| ?state' (on_mail head state self)] (case ?state' (#try.Failure error) - (let [[_ resolve] (get@ #obituary (:representation self))] + (let [[_ resolve] (value@ #obituary (:representation self))] (exec (io.run! (do io.monad [pending (..pending tail)] @@ -109,7 +109,7 @@ (def: .public (alive? actor) (All [s] (-> (Actor s) (IO Bit))) - (let [[obituary _] (get@ #obituary (:representation actor))] + (let [[obituary _] (value@ #obituary (:representation actor))] (|> obituary async.value (\ io.functor map @@ -121,13 +121,13 @@ (def: .public (obituary' actor) (All [s] (-> (Actor s) (IO (Maybe (Obituary s))))) - (let [[obituary _] (get@ #obituary (:representation actor))] + (let [[obituary _] (value@ #obituary (:representation actor))] (async.value obituary))) (def: .public obituary (All [s] (-> (Actor s) (Async (Obituary s)))) (|>> :representation - (get@ #obituary) + (value@ #obituary) product.left)) (def: .public (mail! mail actor) @@ -137,7 +137,7 @@ (if alive? (let [entry [mail (async.async [])]] (do ! - [|mailbox|&resolve (atom.read! (get@ #mailbox (:representation actor)))] + [|mailbox|&resolve (atom.read! (value@ #mailbox (:representation actor)))] (loop [[|mailbox| resolve] |mailbox|&resolve] (do ! [|mailbox| (async.value |mailbox|)] @@ -147,7 +147,7 @@ [resolved? (resolve entry)] (if resolved? (do ! - [_ (atom.write! (product.right entry) (get@ #mailbox (:representation actor)))] + [_ (atom.write! (product.right entry) (value@ #mailbox (:representation actor)))] (in (#try.Success []))) (recur |mailbox|&resolve))) @@ -323,27 +323,27 @@ (with_identifiers [g!_ g!return] (do meta.monad [actor_scope abstract.current - .let [g!type (code.local_identifier (get@ #abstract.name actor_scope)) - g!message (code.local_identifier (get@ #name signature)) - g!actor_vars (get@ #abstract.type_vars actor_scope) - g!all_vars (|> signature (get@ #vars) (list\map code.local_identifier) (list\compose g!actor_vars)) - g!inputsC (|> signature (get@ #inputs) (list\map product.left)) - g!inputsT (|> signature (get@ #inputs) (list\map product.right)) - g!state (|> signature (get@ #state) code.local_identifier) - g!self (|> signature (get@ #self) code.local_identifier)]] + .let [g!type (code.local_identifier (value@ #abstract.name actor_scope)) + g!message (code.local_identifier (value@ #name signature)) + g!actor_vars (value@ #abstract.type_vars actor_scope) + g!all_vars (|> signature (value@ #vars) (list\map code.local_identifier) (list\compose g!actor_vars)) + g!inputsC (|> signature (value@ #inputs) (list\map product.left)) + g!inputsT (|> signature (value@ #inputs) (list\map product.right)) + g!state (|> signature (value@ #state) code.local_identifier) + g!self (|> signature (value@ #self) code.local_identifier)]] (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) (~ (|annotations|.format annotations)) (All [(~+ g!all_vars)] (-> (~+ g!inputsT) - (..Message (~ (get@ #abstract.abstraction actor_scope)) + (..Message (~ (value@ #abstract.abstraction actor_scope)) (~ output_type)))) (function ((~ g!_) (~ g!state) (~ g!self)) - (let [(~ g!state) (:as (~ (get@ #abstract.representation actor_scope)) + (let [(~ g!state) (:as (~ (value@ #abstract.representation actor_scope)) (~ g!state))] (|> (~ body) - (: ((~! async.Async) ((~! try.Try) [(~ (get@ #abstract.representation actor_scope)) + (: ((~! async.Async) ((~! try.Try) [(~ (value@ #abstract.representation actor_scope)) (~ output_type)]))) - (:as ((~! async.Async) ((~! try.Try) [(~ (get@ #abstract.abstraction actor_scope)) + (:as ((~! async.Async) ((~! try.Try) [(~ (value@ #abstract.abstraction actor_scope)) (~ output_type)])))))))) ))))) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index 3dcb864b6..58fbb4ea6 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -25,8 +25,8 @@ (type: .public (Resolver a) (-> a (IO Bit))) + ... Sets an async's value if it has not been done yet. (def: (resolver async) - {#.doc "Sets an async's value if it has not been done yet."} (All [a] (-> (Async a) (Resolver a))) (function (resolve value) (let [async (:representation async)] @@ -181,14 +181,15 @@ (All [a] (-> (IO a) (Async a))) (..schedule! 0)) -(def: .public (delayed milli_seconds value) +(def: .public (after milli_seconds value) (All [a] (-> Nat a (Async a))) (..schedule! milli_seconds (io value))) (def: .public (delay milli_seconds) (-> Nat (Async Any)) - (..delayed milli_seconds [])) + (..after milli_seconds [])) -(def: .public (time_out milli_seconds async) +(def: .public (within milli_seconds async) (All [a] (-> Nat (Async a) (Async (Maybe a)))) - (..or (..delay milli_seconds) async)) + (..or (..delay milli_seconds) + async)) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index e14fb6505..cb3645138 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -189,7 +189,7 @@ (#.Some [value ..empty])) async)) -(def: .public (fold f init channel) +(def: .public (aggregate f init channel) (All [a b] (-> (-> b a (Async a)) a (Channel b) (Async a))) @@ -202,9 +202,9 @@ (#.Some [head tail]) (do ! [init' (f head init)] - (fold f init' tail))))) + (aggregate f init' tail))))) -(def: .public (folds f init channel) +(def: .public (aggregates f init channel) (All [a b] (-> (-> b a (Async a)) a (Channel b) (Channel a))) @@ -217,7 +217,7 @@ (#.Some [head tail]) (do ! [init' (f head init)] - (in (#.Some [init (folds f init' tail)])))))) + (in (#.Some [init (aggregates f init' tail)])))))) (def: .public (poll milli_seconds action) (All [a] diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index c266617a5..e2cdb2aca 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -52,12 +52,12 @@ (async.async []))] (exec (io.run! - (with_expansions [<had_open_position?> (as_is (get@ #open_positions) (i.> -1))] + (with_expansions [<had_open_position?> (as_is (value@ #open_positions) (i.> -1))] (do io.monad - [[_ state'] (atom.update! (|>> (update@ #open_positions dec) + [[_ state'] (atom.update! (|>> (revised@ #open_positions --) (if> [<had_open_position?>] [] - [(update@ #waiting_list (queue.end sink))])) + [(revised@ #waiting_list (queue.end sink))])) semaphore)] (with_expansions [<go_ahead> (sink []) <get_in_line> (in false)] @@ -76,23 +76,23 @@ (async.future (do {! io.monad} [[pre post] (atom.update! (function (_ state) - (if (i.= (.int (get@ #max_positions state)) - (get@ #open_positions state)) + (if (i.= (.int (value@ #max_positions state)) + (value@ #open_positions state)) state (|> state - (update@ #open_positions inc) - (update@ #waiting_list queue.next)))) + (revised@ #open_positions ++) + (revised@ #waiting_list queue.next)))) semaphore)] (if (same? pre post) - (in (exception.except ..semaphore_is_maxed_out [(get@ #max_positions pre)])) + (in (exception.except ..semaphore_is_maxed_out [(value@ #max_positions pre)])) (do ! - [_ (case (queue.front (get@ #waiting_list pre)) + [_ (case (queue.front (value@ #waiting_list pre)) #.None (in true) (#.Some sink) (sink []))] - (in (#try.Success (get@ #open_positions post))))))))) + (in (#try.Success (value@ #open_positions post))))))))) ) (abstract: .public Mutex @@ -148,23 +148,23 @@ (if (n.< times step) (do async.monad [outcome (..signal! turnstile)] - (recur (inc step))) + (recur (++ step))) (\ async.monad in [])))) (template [<phase> <update> <goal> <turnstile>] [(def: (<phase> (^:representation barrier)) (-> Barrier (Async Any)) (do async.monad - [.let [limit (refinement.value (get@ #limit barrier)) + [.let [limit (refinement.value (value@ #limit barrier)) goal <goal> - [_ count] (io.run! (atom.update! <update> (get@ #count barrier))) + [_ count] (io.run! (atom.update! <update> (value@ #count barrier))) reached? (n.= goal count)]] (if reached? - (..un_block! (dec limit) (get@ <turnstile> barrier)) - (..wait! (get@ <turnstile> barrier)))))] + (..un_block! (-- limit) (value@ <turnstile> barrier)) + (..wait! (value@ <turnstile> barrier)))))] - [start! inc limit #start_turnstile] - [end! dec 0 #end_turnstile] + [start! ++ limit #start_turnstile] + [end! -- 0 #end_turnstile] ) (def: .public (block! barrier) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index e067d1ac5..1011da5bb 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -143,8 +143,8 @@ (as_is (exception: .public cannot_continue_running_threads) ... https://en.wikipedia.org/wiki/Event_loop + ... Starts the event-loop. (def: .public run! - {#.doc (example "Starts the event-loop.")} (IO Any) (loop [_ []] (do {! io.monad} @@ -158,14 +158,14 @@ (do ! [now (\ ! map (|>> instant.millis .nat) instant.now) .let [[ready pending] (list.partition (function (_ thread) - (|> (get@ #creation thread) - (n.+ (get@ #delay thread)) + (|> (value@ #creation thread) + (n.+ (value@ #delay thread)) (n.<= now))) threads)] swapped? (atom.compare_and_swap! threads pending ..runner)] (if swapped? (do ! - [_ (monad.map ! (|>> (get@ #action) ..execute! io.io) ready)] + [_ (monad.map ! (|>> (value@ #action) ..execute! io.io) ready)] (recur [])) (panic! (exception.error ..cannot_continue_running_threads [])))) )))) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index f89611e19..d957188ea 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -1,5 +1,4 @@ (.module: - {#.doc "Pure-Lux exception-handling functionality."} [library [lux #* ["." macro] @@ -33,7 +32,7 @@ (def: .public (match? exception error) (All [e] (-> (Exception e) Text Bit)) - (text.starts_with? (get@ #label exception) error)) + (text.starts_with? (value@ #label exception) error)) (def: .public (when exception then try) (All [e a] @@ -44,7 +43,7 @@ (#//.Success output) (#//.Failure error) - (let [reference (get@ #label exception)] + (let [reference (value@ #label exception)] (if (text.starts_with? reference error) (#//.Success (|> error (text.clip' (text.size reference)) @@ -64,7 +63,7 @@ (def: .public (error exception message) (All [e] (-> (Exception e) e Text)) - ((get@ #..constructor exception) message)) + ((value@ #..constructor exception) message)) (def: .public (except exception message) (All [e a] (-> (Exception e) e (Try a))) @@ -91,9 +90,6 @@ ))) (syntax: .public (exception: [[export_policy t_vars [name inputs] body] ..exception]) - {#.doc (example - "" - )} (macro.with_identifiers [g!descriptor] (do meta.monad [current_module meta.current_module_name @@ -102,10 +98,10 @@ (in (list (` (def: (~ export_policy) (~ g!self) (All [(~+ (list\map |type_variable|.format t_vars))] - (..Exception [(~+ (list\map (get@ #|input|.type) inputs))])) + (..Exception [(~+ (list\map (value@ #|input|.type) inputs))])) (let [(~ g!descriptor) (~ (code.text descriptor))] {#..label (~ g!descriptor) - #..constructor (function ((~ g!self) [(~+ (list\map (get@ #|input|.binding) inputs))]) + #..constructor (function ((~ g!self) [(~+ (list\map (value@ #|input|.binding) inputs))]) ((~! text\compose) (~ g!descriptor) (~ (maybe.else (' "") body))))})))))))) @@ -119,14 +115,14 @@ on_new_line (|> " " (list.repeated (n.+ (text.size header_separator) largest_header_size)) - text.joined + text.together (text\compose text.new_line)) on_entry (: (-> [Text Text] Text) (function (_ [header message]) (let [padding (|> " " (list.repeated (n.- (text.size header) largest_header_size)) - text.joined)] + text.together)] (|> message (text.replaced text.new_line on_new_line) ($_ text\compose padding header header_separator)))))] @@ -150,7 +146,7 @@ (-> (-> a Text) (List a) Text)) (|> entries (list\fold (function (_ entry [index next]) - [(inc index) + [(++ index) (#.Item [(n\encode index) (format entry)] next)]) [0 #.End]) @@ -160,7 +156,7 @@ (def: separator (let [gap ($_ "lux text concat" text.new_line text.new_line) - horizontal_line (|> "-" (list.repeated 64) text.joined)] + horizontal_line (|> "-" (list.repeated 64) text.together)] ($_ "lux text concat" gap horizontal_line diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 865ea6930..11cc82e62 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -22,7 +22,7 @@ (-> (-> a b c) (-> b a c))) (function (_ x y) (f y x))) -(def: .public (apply input function) +(def: .public (on input function) (All [i o] (-> i (-> i o) o)) (function input)) diff --git a/stdlib/source/library/lux/control/function/contract.lux b/stdlib/source/library/lux/control/function/contract.lux index 0fb706a14..b568a7068 100644 --- a/stdlib/source/library/lux/control/function/contract.lux +++ b/stdlib/source/library/lux/control/function/contract.lux @@ -16,7 +16,7 @@ ["i" int]]]]]) (template [<name>] - [(exception: (<name> {condition Code}) + [(exception: .public (<name> {condition Code}) (exception.report ["Condition" (%.code condition)]))] @@ -32,11 +32,6 @@ (syntax: .public (pre [test <code>.any expr <code>.any]) - {#.doc (example "Pre-conditions." - "Given a test and an expression to run, only runs the expression if the test passes." - "Otherwise, an error is raised." - (pre (i.= +4 (i.+ +2 +2)) - (foo +123 +456 +789)))} (in (list (` (exec ((~! ..assert!) (~ (code.text (exception.error ..pre_condition_failed test))) (~ test)) @@ -44,12 +39,6 @@ (syntax: .public (post [test <code>.any expr <code>.any]) - {#.doc (example "Post-conditions." - "Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate." - "If the predicate returns #1, returns the value of the expression." - "Otherwise, an error is raised." - (post i.even? - (i.+ +2 +2)))} (with_identifiers [g!output] (in (list (` (let [(~ g!output) (~ expr)] (exec diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index ee20672b1..4d89e9778 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -36,7 +36,6 @@ (Recursive i (State (Dictionary i o) o))) (def: .public (open memo) - {#.doc (example "Memoization where the memoized results can be re-used accross invocations.")} (All [i o] (:let [Memory (Dictionary i o)] (-> (Memo i o) (-> [Memory i] [Memory o])))) @@ -45,8 +44,6 @@ (|> input memo (state.result memory))))) (def: .public (closed hash memo) - {#.doc (example "Memoization confined to a single invocation to the function (not counting any subsequent recursive invocations)." - "Memoized results will be re-used during recursive invocations, but cannot be accessed after the main invocation has ended.")} (All [i o] (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.mixin (//.with ..memoization (//.of_recursive memo))) @@ -54,8 +51,6 @@ (|>> memo (state.result empty) product.right))) (def: .public (none hash memo) - {#.doc (example "No memoization at all." - "This is useful as a test control when measuring the effect of using memoization.")} (All [i o] (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.mixin (//.of_recursive memo)) diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index cdaa35a6c..98009b21d 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -10,23 +10,19 @@ [monad (#+ Monad do)]]]]) (type: .public (Mixin i o) - {#.doc (example "A function which can be mixed with others to inherit their behavior.")} (-> (-> i o) (-> i o) (-> i o))) (def: .public (mixin f) - {#.doc (example "Given a mixin, produces a normal function.")} (All [i o] (-> (Mixin i o) (-> i o))) (function (mix input) ((f mix mix) input))) (def: .public nothing - {#.doc (example "A mixin that does nothing and just delegates work to the next mixin.")} Mixin (function (_ delegate recur) delegate)) (def: .public (with parent child) - {#.doc (example "Produces a new mixin, where the behavior of the child can make use of the behavior of the parent.")} (All [i o] (-> (Mixin i o) (Mixin i o) (Mixin i o))) (function (_ delegate recur) (parent (child delegate recur) recur))) @@ -38,7 +34,6 @@ (def: compose ..with)) (def: .public (advice when then) - {#.doc (example "Only apply then mixin when the input meets some criterion.")} (All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o))) (function (_ delegate recur input) (if (when input) @@ -46,7 +41,6 @@ (delegate input)))) (def: .public (before monad action) - {#.doc (example "Executes an action before doing the main work.")} (All [! i o] (-> (Monad !) (-> i (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad @@ -54,7 +48,6 @@ (delegate input)))) (def: .public (after monad action) - {#.doc (example "Executes an action after doing the main work.")} (All [! i o] (-> (Monad !) (-> i o (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad @@ -63,11 +56,9 @@ (in output)))) (type: .public (Recursive i o) - {#.doc (example "An indirectly recursive function.")} (-> (-> i o) (-> i o))) (def: .public (of_recursive recursive) - {#.doc (example "Transform an indirectly recursive function into a mixin.")} (All [i o] (-> (Recursive i o) (Mixin i o))) (function (_ delegate recur) (recursive recur))) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index fd36ac10b..dd647ce41 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -1,5 +1,4 @@ (.module: - {#.doc (.example "Macros for implementing mutually-recursive functions.")} [library [lux (#- Definition let def:) ["." meta] @@ -42,8 +41,8 @@ (-> (List Code) Code [Code Mutual] Code) (` (function ((~ g!name) (~ g!context)) (.let [[(~+ context)] (~ g!context)] - (function (~ (declaration.format (get@ #declaration mutual))) - (~ (get@ #body mutual))))))) + (function (~ (declaration.format (value@ #declaration mutual))) + (~ (value@ #body mutual))))))) (.def: (macro g!context g!self) (-> Code Code Macro) @@ -54,29 +53,15 @@ (syntax: .public (let [functions (<code>.tuple (<>.some ..mutual)) body <code>.any]) - {#.doc (example "Locally-defined mutually-recursive functions." - (let [(even? number) - (-> Nat Bit) - (case number - 0 true - _ (odd? (dec number))) - - (odd? number) - (-> Nat Bit) - (case number - 0 false - _ (even? (dec number)))] - (and (even? 4) - (odd? 5))))} (case functions #.End (in (list body)) (#.Item mutual #.End) - (.let [g!name (|> mutual (get@ [#declaration #declaration.name]) code.local_identifier)] - (in (list (` (.let [(~ g!name) (: (~ (get@ #type mutual)) - (function (~ (declaration.format (get@ #declaration mutual))) - (~ (get@ #body mutual))))] + (.let [g!name (|> mutual (value@ [#declaration #declaration.name]) code.local_identifier)] + (in (list (` (.let [(~ g!name) (: (~ (value@ #type mutual)) + (function (~ (declaration.format (value@ #declaration mutual))) + (~ (value@ #body mutual))))] (~ body)))))) _ @@ -89,12 +74,12 @@ (list.zipped/2 hidden_names functions)) context_types (list\map (function (_ mutual) - (` (-> (~ g!context) (~ (get@ #type mutual))))) + (` (-> (~ g!context) (~ (value@ #type mutual))))) functions) - user_names (list\map (|>> (get@ [#declaration #declaration.name]) code.local_identifier) + user_names (list\map (|>> (value@ [#declaration #declaration.name]) code.local_identifier) functions)] g!pop (local.push (list\map (function (_ [g!name mutual]) - [[here_name (get@ [#declaration #declaration.name] mutual)] + [[here_name (value@ [#declaration #declaration.name] mutual)] (..macro g!context g!name)]) (list.zipped/2 hidden_names functions)))] @@ -119,19 +104,6 @@ (<>.and (<>\in (` .private)) ..mutual)))) (syntax: .public (def: [functions (<>.many ..definition)]) - {#.doc (example "Globally-defined mutually-recursive functions." - (def: - [.public (even? number) - (-> Nat Bit) - (case number - 0 true - _ (odd? (dec number)))] - - [.public (odd? number) - (-> Nat Bit) - (case number - 0 false - _ (even? (dec number)))]))} (case functions #.End (in (list)) @@ -151,19 +123,19 @@ functions) .let [definitions (list\map (..mutual_definition hidden_names g!context) (list.zipped/2 hidden_names - (list\map (get@ #mutual) functions))) + (list\map (value@ #mutual) functions))) context_types (list\map (function (_ mutual) - (` (-> (~ g!context) (~ (get@ [#mutual #type] mutual))))) + (` (-> (~ g!context) (~ (value@ [#mutual #type] mutual))))) functions) - user_names (list\map (|>> (get@ [#mutual #declaration #declaration.name]) code.local_identifier) + user_names (list\map (|>> (value@ [#mutual #declaration #declaration.name]) code.local_identifier) functions)] g!pop (local.push (list\map (function (_ [g!name mutual]) - [[here_name (get@ [#mutual #declaration #declaration.name] mutual)] + [[here_name (value@ [#mutual #declaration #declaration.name] mutual)] (..macro g!context g!name)]) (list.zipped/2 hidden_names functions)))] (in (list& (` (.def: (~ g!context) - [(~+ (list\map (get@ [#mutual #type]) functions))] + [(~+ (list\map (value@ [#mutual #type]) functions))] (.let [(~ g!context) (: (Rec (~ g!context) [(~+ context_types)]) [(~+ definitions)]) @@ -173,11 +145,11 @@ user_names))]))) g!pop (list\map (function (_ mutual) - (.let [g!name (|> mutual (get@ [#mutual #declaration #declaration.name]) code.local_identifier)] + (.let [g!name (|> mutual (value@ [#mutual #declaration #declaration.name]) code.local_identifier)] (` (.def: - (~ (get@ #export_policy mutual)) + (~ (value@ #export_policy mutual)) (~ g!name) - (~ (get@ [#mutual #type] mutual)) + (~ (value@ [#mutual #type] mutual)) (.let [[(~+ user_names)] (~ g!context)] (~ g!name)))))) functions))))))) diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 1b3b58f7b..125ebfb67 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -1,5 +1,4 @@ (.module: - {#.doc "A method for abstracting I/O and effectful computations to make it safe while writing pure functional code."} [library [lux #* [abstract diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 74b5f06d2..7dcf84574 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -97,7 +97,8 @@ (All [M] (-> (Monad M) (Monad (All [a] (M (Maybe a)))))) (def: &functor - (functor.composite (get@ #monad.&functor monad) ..functor)) + (functor.composite (value@ #monad.&functor monad) + ..functor)) (def: in (|>> (\ ..monad in) (\ monad in))) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index f4e304045..6d3246295 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -17,7 +17,6 @@ ["n" nat]]]]]) (type: .public (Parser s a) - {#.doc "A generic parser."} (-> s (Try [s a]))) (implementation: .public functor @@ -70,7 +69,6 @@ (ma input'))))) (def: .public (assertion message test) - {#.doc "Fails with the given message if the test is #0."} (All [s] (-> Text Bit (Parser s Any))) (function (_ input) (if test @@ -78,7 +76,6 @@ (#try.Failure message)))) (def: .public (maybe parser) - {#.doc "Optionality combinator."} (All [s a] (-> (Parser s a) (Parser s (Maybe a)))) (function (_ input) @@ -90,15 +87,11 @@ (#try.Success [input' (#.Some x)])))) (def: .public (result parser input) - {#.doc (example "Executes the parser on the input." - "Does not verify that all of the input has been consumed by the parser." - "Returns both the parser's output, and a value that represents the remaining input.")} (All [s a] (-> (Parser s a) s (Try [s a]))) (parser input)) (def: .public (and first second) - {#.doc "Sequencing combinator."} (All [s a b] (-> (Parser s a) (Parser s b) (Parser s [a b]))) (do {! ..monad} @@ -106,7 +99,6 @@ (\ ! map (|>> [head]) second))) (def: .public (or left right) - {#.doc "Heterogeneous alternative combinator."} (All [s a b] (-> (Parser s a) (Parser s b) (Parser s (Or a b)))) (function (_ tokens) @@ -123,7 +115,6 @@ (#try.Failure error))))) (def: .public (either this that) - {#.doc "Homogeneous alternative combinator."} (All [s a] (-> (Parser s a) (Parser s a) (Parser s a))) (function (_ tokens) @@ -135,7 +126,6 @@ output))) (def: .public (some parser) - {#.doc "0-or-more combinator."} (All [s a] (-> (Parser s a) (Parser s (List a)))) (function (_ input) @@ -149,7 +139,6 @@ input')))) (def: .public (many parser) - {#.doc "1-or-more combinator."} (All [s a] (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) @@ -157,25 +146,22 @@ (\ ..monad map (|>> #.Item)))) (def: .public (exactly amount parser) - {#.doc "Parse exactly N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (case amount 0 (\ ..monad in (list)) _ (do {! ..monad} [x parser] (|> parser - (exactly (dec amount)) + (exactly (-- amount)) (\ ! map (|>> (#.Item x))))))) (def: .public (at_least amount parser) - {#.doc "Parse at least N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (do {! ..monad} [minimum (..exactly amount parser)] (\ ! map (list\compose minimum) (..some parser)))) (def: .public (at_most amount parser) - {#.doc "Parse at most N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (case amount 0 (\ ..monad in (list)) @@ -186,7 +172,7 @@ (#try.Success [input' x]) (..result (\ ..monad map (|>> (#.Item x)) - (at_most (dec amount) parser)) + (at_most (-- amount) parser)) input'))))) (def: .public (between minimum additional parser) @@ -199,7 +185,6 @@ (..at_most additional parser))))) (def: .public (separated_by separator parser) - {#.doc "Parses instances of 'parser' that are separated by instances of 'separator'."} (All [s a b] (-> (Parser s b) (Parser s a) (Parser s (List a)))) (do {! ..monad} [?x (..maybe parser)] @@ -214,7 +199,6 @@ (\ ! map (|>> (list\map product.right) (#.Item x))))))) (def: .public (not parser) - {#.doc (example "Only succeeds when the underlying parser fails.")} (All [s a] (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -225,13 +209,11 @@ (#try.Failure "Expected to fail; yet succeeded.")))) (def: .public (failure message) - {#.doc (example "Always fail with this 'message'.")} (All [s a] (-> Text (Parser s a))) (function (_ input) (#try.Failure message))) (def: .public (lifted operation) - {#.doc (example "Lift a potentially failed computation into a parser.")} (All [s a] (-> (Try a) (Parser s a))) (function (_ input) (case operation @@ -242,7 +224,6 @@ (#try.Failure error)))) (def: .public (else value parser) - {#.doc "If the given parser fails, returns the default value."} (All [s a] (-> a (Parser s a) (Parser s a))) (function (_ input) (case (parser input) @@ -253,26 +234,22 @@ (#try.Success [input' output])))) (def: .public remaining - {#.doc (example "Yield the remaining input (without consuming it).")} (All [s] (Parser s s)) (function (_ inputs) (#try.Success [inputs inputs]))) (def: .public (rec parser) - {#.doc "Combinator for recursive parsers."} (All [s a] (-> (-> (Parser s a) (Parser s a)) (Parser s a))) (function (_ inputs) (..result (parser (rec parser)) inputs))) (def: .public (after param subject) - {#.doc (example "Run the parser after another one (whose output is ignored).")} (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [_ param] subject)) (def: .public (before param subject) - {#.doc (example "Run the parser before another one (whose output is ignored).")} (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [output subject @@ -280,7 +257,6 @@ (in output))) (def: .public (only test parser) - {#.doc (example "Only succeed when the parser's output passes a test.")} (All [s a] (-> (-> a Bit) (Parser s a) (Parser s a))) (do ..monad [output parser @@ -288,7 +264,6 @@ (in output))) (def: .public (parses? parser) - {#.doc (example "Ignore a parser's output and just verify that it succeeds.")} (All [s a] (-> (Parser s a) (Parser s Bit))) (function (_ input) (case (parser input) @@ -299,7 +274,6 @@ (#try.Success [input' true])))) (def: .public (parses parser) - {#.doc (example "Ignore a parser's output and just execute it.")} (All [s a] (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -310,8 +284,6 @@ (#try.Success [input' []])))) (def: .public (speculative parser) - {#.doc (example "Executes a parser, without actually consuming the input." - "That way, the same input can be consumed again by another parser.")} (All [s a] (-> (Parser s a) (Parser s a))) (function (_ input) (case (parser input) @@ -322,7 +294,6 @@ output))) (def: .public (codec codec parser) - {#.doc (example "Decode the output of a parser using a codec.")} (All [s a z] (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) (case (parser input) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index fb32f4608..42bffc310 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -48,11 +48,9 @@ ["Input" (exception.listing /.%analysis input)])) (type: .public Parser - {#.doc (example "A parser for Lux code analysis nodes.")} (//.Parser (List Analysis))) (def: .public (result parser input) - {#.doc (example "Executes a parser and makes sure no inputs go unconsumed.")} (All [a] (-> (Parser a) (List Analysis) (Try a))) (case (parser input) (#try.Failure error) @@ -65,7 +63,6 @@ (exception.except ..unconsumed_input unconsumed))) (def: .public any - {#.doc (example "Matches any value, without discrimination.")} (Parser Analysis) (function (_ input) (case input @@ -76,7 +73,6 @@ (#try.Success [tail head])))) (def: .public end! - {#.doc "Ensures there are no more inputs."} (Parser Any) (function (_ tokens) (case tokens @@ -85,7 +81,6 @@ (remaining_inputs tokens)))))) (def: .public end? - {#.doc "Checks whether there are no more inputs."} (Parser Bit) (function (_ tokens) (#try.Success [tokens (case tokens @@ -94,7 +89,6 @@ (template [<query> <assertion> <tag> <type> <eq>] [(`` (as_is (def: .public <query> - {#.doc (example (~~ (template.text ["Queries for a " <query> " value."])))} (Parser <type>) (function (_ input) (case input @@ -105,7 +99,6 @@ (exception.except ..cannot_parse input)))) (def: .public (<assertion> expected) - {#.doc (example (~~ (template.text ["Assert a specific " <query> " value."])))} (-> <type> (Parser Any)) (function (_ input) (case input @@ -129,7 +122,6 @@ ) (def: .public (tuple parser) - {#.doc (example "Parses only within the context of a tuple's contents.")} (All [a] (-> (Parser a) (Parser a))) (function (_ input) (case input diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index d2d195888..ec251b304 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -27,11 +27,9 @@ ["." // ("#\." monad)]) (type: .public Offset - {#.doc (example "An offset for reading within binary data.")} Nat) (type: .public Parser - {#.doc (example "A parser for raw binary data.")} (//.Parser [Offset Binary])) (exception: .public (binary_was_not_fully_read {binary_length Nat} {bytes_read Nat}) @@ -40,7 +38,6 @@ ["Bytes read" (%.nat bytes_read)])) (def: .public (result parser input) - {#.doc (example "Runs a parser and checks that all the binary data was read by it.")} (All [a] (-> (Parser a) Binary (Try a))) (case (parser [0 input]) (#try.Failure msg) @@ -53,25 +50,21 @@ (exception.except ..binary_was_not_fully_read [length end]))))) (def: .public end? - {#.doc (example "Checks whether there is no more data to read.")} (Parser Bit) (function (_ (^@ input [offset data])) (#try.Success [input (n.= offset (/.size data))]))) (def: .public offset - {#.doc (example "The current offset (i.e. how much data has been read).")} (Parser Offset) (function (_ (^@ input [offset data])) (#try.Success [input offset]))) (def: .public remaining - {#.doc (example "How much of the data remains to be read.")} (Parser Nat) (function (_ (^@ input [offset data])) (#try.Success [input (n.- offset (/.size data))]))) (type: .public Size - {#.doc (example "The size of a chunk of data within a binary array.")} Nat) (def: .public size/8 Size 1) @@ -129,14 +122,12 @@ [1 #.Right right]])) (def: .public (rec body) - {#.doc (example "Tie the knot for a recursive parser.")} (All [a] (-> (-> (Parser a) (Parser a)) (Parser a))) (function (_ input) (let [parser (body (rec body))] (parser input)))) (def: .public any - {#.doc (example "Does no parsing, and just returns a dummy value.")} (Parser Any) (//\in [])) @@ -156,7 +147,6 @@ _ (//.lifted (exception.except ..not_a_bit [value]))))) (def: .public (segment size) - {#.doc (example "Parses a chunk of data of a given size.")} (-> Nat (Parser Binary)) (function (_ [offset binary]) (case size @@ -167,7 +157,6 @@ (template [<size> <name> <bits>] [(`` (def: .public <name> - {#.doc (example (~~ (template.text ["Parses a block of data prefixed with a size that is " <size> " bytes long."])))} (Parser Binary) (do //.monad [size (//\map .nat <bits>)] @@ -181,7 +170,6 @@ (template [<size> <name> <binary>] [(`` (def: .public <name> - {#.doc (example (~~ (template.text ["Parses a block of (UTF-8 encoded) text prefixed with a size that is " <size> " bytes long."])))} (Parser Text) (do //.monad [utf8 <binary>] @@ -197,7 +185,6 @@ (template [<size> <name> <bits>] [(def: .public (<name> valueP) - {#.doc (example (~~ (template.text ["Parses a row of values prefixed with a size that is " <size> " bytes long."])))} (All [v] (-> (Parser v) (Parser (Row v)))) (do //.monad [amount (: (Parser Nat) @@ -212,8 +199,8 @@ (if (n.< amount index) (do //.monad [value valueP] - (recur (.inc index) - (row.add value output))) + (recur (.++ index) + (row.suffix value output))) (//\in output)))))] [08 row/8 ..bits/8] @@ -227,7 +214,6 @@ (..or ..any)) (def: .public (list value) - {#.doc (example "Parses an arbitrarily long list of values.")} (All [a] (-> (Parser a) (Parser (List a)))) (..rec (|>> (//.and value) diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index 3dd50a349..d9b4928ab 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -11,11 +11,9 @@ ["." //]) (type: .public (Parser a) - {#.doc "A command-line interface parser."} (//.Parser (List Text) a)) (def: .public (result parser inputs) - {#.doc (example "Executes the parser and verifies that all inputs are processed.")} (All [a] (-> (Parser a) (List Text) (Try a))) (case (//.result parser inputs) (#try.Success [remaining output]) @@ -30,7 +28,6 @@ (#try.Failure try))) (def: .public any - {#.doc "Just returns the next input without applying any logic."} (Parser Text) (function (_ inputs) (case inputs @@ -41,7 +38,6 @@ (#try.Failure "Cannot parse empty arguments.")))) (def: .public (parse parser) - {#.doc "Parses the next input with a parsing function."} (All [a] (-> (-> Text (Try a)) (Parser a))) (function (_ inputs) (do try.monad @@ -50,7 +46,6 @@ (in [remaining output])))) (def: .public (this reference) - {#.doc "Checks that a token is in the inputs."} (-> Text (Parser Any)) (function (_ inputs) (do try.monad @@ -60,7 +55,6 @@ (#try.Failure (format "Missing token: '" reference "'")))))) (def: .public (somewhere cli) - {#.doc "Given a parser, tries to parse it somewhere in the inputs (i.e. not necessarily parsing the immediate inputs)."} (All [a] (-> (Parser a) (Parser a))) (function (_ inputs) (loop [immediate inputs] @@ -80,7 +74,6 @@ output]))))))) (def: .public end - {#.doc "Ensures there are no more inputs."} (Parser Any) (function (_ inputs) (case inputs @@ -88,14 +81,12 @@ _ (#try.Failure (format "Unknown parameters: " (text.interposed " " inputs)))))) (def: .public (named name value) - {#.doc (example "Parses a named parameter and yields its value.")} (All [a] (-> Text (Parser a) (Parser a))) (|> value (//.after (..this name)) ..somewhere)) (def: .public (parameter [short long] value) - {#.doc (example "Parses a parameter that can have either a short or a long name.")} (All [a] (-> [Text Text] (Parser a) (Parser a))) (|> value (//.after (//.either (..this short) (..this long))) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index 93a2f65d9..1a3bbc5a7 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -28,7 +28,6 @@ (#.Item [[x y] pairs']) (list& x y (un_paired pairs')))) (type: .public Parser - {#.doc "A Lux code parser."} (//.Parser (List Code))) (def: remaining_inputs @@ -38,7 +37,6 @@ ($_ text\compose text.new_line "Remaining input: "))) (def: .public any - {#.doc "Yields the next input without applying any logic."} (Parser Code) (function (_ tokens) (case tokens @@ -51,7 +49,6 @@ (template [<query> <check> <type> <tag> <eq> <desc>] [(with_expansions [<failure> (as_is (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))] (def: .public <query> - {#.doc (code.text ($_ text\compose "Parses the next " <desc> " input."))} (Parser <type>) (function (_ tokens) (case tokens @@ -62,7 +59,6 @@ <failure>))) (def: .public (<check> expected) - {#.doc (code.text ($_ text\compose "Checks for a specific " <desc> " input."))} (-> <type> (Parser Any)) (function (_ tokens) (case tokens @@ -85,7 +81,6 @@ ) (def: .public (this! code) - {#.doc "Ensures the given Code is the next input."} (-> Code (Parser Any)) (function (_ tokens) (case tokens @@ -101,7 +96,6 @@ (template [<query> <check> <tag> <eq> <desc>] [(with_expansions [<failure> (as_is (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))] (def: .public <query> - {#.doc (code.text ($_ text\compose "Parse a local " <desc> " (a " <desc> " that has no module prefix)."))} (Parser Text) (function (_ tokens) (case tokens @@ -112,7 +106,6 @@ <failure>))) (def: .public (<check> expected) - {#.doc (code.text ($_ text\compose "Checks for a specific local " <desc> " (a " <desc> " that has no module prefix)."))} (-> Text (Parser Any)) (function (_ tokens) (case tokens @@ -130,7 +123,6 @@ (template [<name> <tag> <desc>] [(def: .public (<name> p) - {#.doc (code.text ($_ text\compose "Parses the contents of a " <desc> "."))} (All [a] (-> (Parser a) (Parser a))) (function (_ tokens) @@ -148,7 +140,6 @@ ) (def: .public (record p) - {#.doc "Parses the contents of a record."} (All [a] (-> (Parser a) (Parser a))) (function (_ tokens) @@ -162,7 +153,6 @@ (#try.Failure ($_ text\compose "Cannot parse record" (remaining_inputs tokens)))))) (def: .public end! - {#.doc "Verifies there are no more inputs."} (Parser Any) (function (_ tokens) (case tokens @@ -170,7 +160,6 @@ _ (#try.Failure ($_ text\compose "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) (def: .public end? - {#.doc "Checks whether there are no more inputs."} (Parser Bit) (function (_ tokens) (#try.Success [tokens (case tokens @@ -178,7 +167,6 @@ _ false)]))) (def: .public (result parser inputs) - {#.doc (example "Executes a parser against a stream of code, and verifies all the inputs are consumed.")} (All [a] (-> (Parser a) (List Code) (Try a))) (case (parser inputs) (#try.Failure error) @@ -196,7 +184,6 @@ (text\compose "Unconsumed inputs: ")))))) (def: .public (local inputs parser) - {#.doc "Runs parser against the given list of inputs."} (All [a] (-> (List Code) (Parser a) (Parser a))) (function (_ real) (do try.monad diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index e12febdf3..f084a838d 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -13,11 +13,9 @@ ["." //]) (type: .public Property - {#.doc (example "A property in the environment.")} Text) (type: .public Environment - {#.doc (example "An abstraction for environment variables of a program.")} (Dictionary Property Text)) (exception: .public (unknown_property {property Property}) @@ -25,11 +23,9 @@ ["Property" (%.text property)])) (type: .public (Parser a) - {#.doc (example "A parser of environment variables of a program.")} (//.Parser Environment a)) (def: .public empty - {#.doc (example "An empty environment.")} Environment (dictionary.empty text.hash)) @@ -44,7 +40,5 @@ (exception.except ..unknown_property [name])))) (def: .public (result parser environment) - {#.doc (example "Executes a parser against the given environment variables." - "Does not check whether all environment variables were parsed, since they're usually an open set.")} (All [a] (-> (Parser a) Environment (Try a))) (\ try.monad map product.right (parser environment))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 51c3cc2bf..65569ff9e 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -159,7 +159,7 @@ dictionary.entries (list\map (function (_ [key value]) (list (#/.String key) value))) - list.joined + list.together (//.result parser)) (#try.Failure error) (//.failure error) diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index fb2c59128..46ed6e987 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -302,7 +302,7 @@ [(def: .public (<name> parser) {#.doc (code.text ($_ /\compose "Yields " <doc_modifier> " characters as a single continuous text (as a slice)."))} (-> (Parser Text) (Parser Text)) - (|> parser <base> (\ //.monad map /.joined)))] + (|> parser <base> (\ //.monad map /.together)))] [some //.some "some"] [many //.many "many"] @@ -324,7 +324,7 @@ (-> Nat (Parser Text) (Parser Text)) (|> parser (<base> amount) - (\ //.monad map /.joined)))] + (\ //.monad map /.together)))] [exactly //.exactly "exactly"] [at_most //.at_most "at most"] @@ -347,7 +347,7 @@ (-> Nat Nat (Parser Text) (Parser Text)) (|> parser (//.between minimum additional) - (\ //.monad map /.joined))) + (\ //.monad map /.together))) (def: .public (between! minimum additional parser) (-> Nat Nat (Parser Slice) (Parser Slice)) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 8016080b5..e6ea2b3dd 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -197,19 +197,19 @@ all_varsL (: (List Code) (list))] (if (n.< num_args current_arg) (if (n.= 0 current_arg) - (let [varL (label (inc funcI))] - (recur (inc current_arg) + (let [varL (label (++ funcI))] + (recur (++ current_arg) (|> env' (dictionary.has funcI [headT funcL]) - (dictionary.has (inc funcI) [(#.Parameter (inc funcI)) varL])) + (dictionary.has (++ funcI) [(#.Parameter (++ funcI)) varL])) (#.Item varL all_varsL))) (let [partialI (|> current_arg (n.* 2) (n.+ funcI)) - partial_varI (inc partialI) + partial_varI (++ partialI) partial_varL (label partial_varI) partialC (` ((~ funcL) (~+ (|> (list.indices num_args) - (list\map (|>> (n.* 2) inc (n.+ funcI) label)) + (list\map (|>> (n.* 2) ++ (n.+ funcI) label)) list.reversed))))] - (recur (inc current_arg) + (recur (++ current_arg) (|> env' (dictionary.has partialI [.Nothing partialC]) (dictionary.has partial_varI [(#.Parameter partial_varI) partial_varL])) @@ -265,7 +265,7 @@ (let [env_level (n./ 2 (dictionary.size env)) parameter_level (n./ 2 idx) parameter_idx (n.% 2 idx)] - (|> env_level dec (n.- parameter_level) (n.* 2) (n.+ parameter_idx)))) + (|> env_level -- (n.- parameter_level) (n.* 2) (n.+ parameter_idx)))) (def: .public parameter (Parser Code) diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 66d3f2a06..b194d6749 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -27,21 +27,11 @@ (syntax: .public (new> [start <code>.any body body^ prev <code>.any]) - {#.doc (example "Ignores the piped argument, and begins a new pipe." - (n.= 1 - (|> 20 - (n.* 3) - (n.+ 4) - (new> 0 [inc]))))} (in (list (` (|> (~ start) (~+ body)))))) (syntax: .public (let> [binding <code>.any body <code>.any prev <code>.any]) - {#.doc (example "Gives a name to the piped-argument, within the given expression." - (n.= 10 - (|> 5 - (let> x (n.+ x x)))))} (in (list (` (let [(~ binding) (~ prev)] (~ body)))))) @@ -55,12 +45,6 @@ else body^ _ _reversed_ branches (<>.some (<>.and body^ body^))]) - {#.doc (example "Branching for pipes." - "Both the tests and the bodies are piped-code, and must be given inside a tuple." - (|> +5 - (cond> [i.even?] [(i.* +2)] - [i.odd?] [(i.* +3)] - [(new> -1 [])])))} (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] (cond (~+ (do list.monad @@ -73,14 +57,6 @@ then body^ else body^ prev <code>.any]) - {#.doc (example "If-branching." - (same? (if (n.even? sample) - "even" - "odd") - (|> sample - (if> [n.even?] - [(new> "even" [])] - [(new> "odd" [])]))))} (in (list (` (cond> [(~+ test)] [(~+ then)] [(~+ else)] (~ prev)))))) @@ -88,13 +64,6 @@ (syntax: .public (when> [test body^ then body^ prev <code>.any]) - {#.doc (example "Only execute the body when the test passes." - (same? (if (n.even? sample) - (n.* 2 sample) - sample) - (|> sample - (when> [n.even?] - [(n.* 2)]))))} (in (list (` (cond> [(~+ test)] [(~+ then)] [] (~ prev)))))) @@ -102,11 +71,6 @@ (syntax: .public (loop> [test body^ then body^ prev <code>.any]) - {#.doc (example "Loops for pipes." - "Both the testing and calculating steps are pipes and must be given inside tuples." - (|> +1 - (loop> [(i.< +10)] - [inc])))} (with_identifiers [g!temp] (in (list (` (loop [(~ g!temp) (~ prev)] (if (|> (~ g!temp) (~+ test)) @@ -116,13 +80,6 @@ (syntax: .public (do> [monad <code>.any steps (<>.some body^) prev <code>.any]) - {#.doc (example "Monadic pipes." - "Each steps in the monadic computation is a pipe and must be given inside a tuple." - (|> +5 - (do> identity.monad - [(i.* +3)] - [(i.+ +4)] - [inc])))} (with_identifiers [g!temp] (case (list.reversed steps) (^ (list& last_step prev_steps)) @@ -139,11 +96,6 @@ (syntax: .public (exec> [body body^ prev <code>.any]) - {#.doc (example "Non-updating pipes." - "Will generate piped computations, but their results will not be used in the larger scope." - (|> +5 - (exec> [.nat %n log!]) - (i.* +10)))} (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] (exec (|> (~ g!temp) (~+ body)) @@ -151,13 +103,6 @@ (syntax: .public (tuple> [paths (<>.many body^) prev <code>.any]) - {#.doc (example "Parallel branching for pipes." - "Allows to run multiple pipelines for a value and gives you a tuple of the outputs." - (|> +5 - (tuple> [(i.* +10)] - [dec (i./ +2)] - [Int/encode])) - "Will become: [+50 +2 '+5']")} (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body)))) @@ -165,20 +110,6 @@ (syntax: .public (case> [branches (<>.many (<>.and <code>.any <code>.any)) prev <code>.any]) - {#.doc (example "Pattern-matching for pipes." - "The bodies of each branch are NOT pipes; just regular values." - (|> +5 - (case> +0 "zero" - +1 "one" - +2 "two" - +3 "three" - +4 "four" - +5 "five" - +6 "six" - +7 "seven" - +8 "eight" - +9 "nine" - _ "???")))} (in (list (` (case (~ prev) (~+ (list\join (list\map (function (_ [pattern body]) (list pattern body)) branches)))))))) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index 09fcd2058..e1ffffd7b 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -7,21 +7,17 @@ ["." monad (#+ Monad do)]]]]) (type: .public (Reader r a) - {#.doc "Computations that have access to some environmental value."} (-> r a)) (def: .public read - {#.doc "Get the environment."} (All [r] (Reader r r)) (function (_ env) env)) (def: .public (local change proc) - {#.doc "Run computation with a locally-modified environment."} (All [r a] (-> (-> r r) (Reader r a) (Reader r a))) (|>> change proc)) (def: .public (result env proc) - {#.doc "Executes the reader against the given environment."} (All [r a] (-> r (Reader r a) a)) (proc env)) @@ -54,11 +50,10 @@ (mma env env)))) (implementation: .public (with monad) - {#.doc "Monad transformer for Reader."} (All [M] (-> (Monad M) (All [e] (Monad (All [a] (Reader e (M a))))))) (def: &functor - (functor.composite ..functor (get@ #monad.&functor monad))) + (functor.composite ..functor (value@ #monad.&functor monad))) (def: in (|>> (\ monad in) (\ ..monad in))) @@ -70,6 +65,5 @@ (result env eMa))))) (def: .public lifted - {#.doc "Lift monadic values to the Reader wrapper."} (All [M e a] (-> (M a) (Reader e (M a)))) (\ ..monad in)) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 191c6a328..9d9f579c0 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -19,8 +19,6 @@ (-> r (! (Try Any)))) (type: .public (Region r ! a) - {#.doc (example "A region where resources may be be claimed and where a side-effecting computation may be performed." - "Every resource is paired with a function that knows how to clean/reclaim it, to make sure there are no leaks.")} (-> [r (List (Cleaner r !))] (! [(List (Cleaner r !)) (Try a)]))) @@ -54,7 +52,6 @@ (exception.except ..clean_up_error [error output]))) (def: .public (run! monad computation) - {#.doc (example "Executes a region-based computation, with a side-effect determined by the monad.")} (All [! a] (-> (Monad !) (All [r] (Region r ! a)) (! (Try a)))) @@ -65,7 +62,6 @@ (\ ! map (list\fold clean output))))) (def: .public (acquire! monad cleaner value) - {#.doc (example "Acquire a resource while pairing it a function that knows how to reclaim it.")} (All [! a] (-> (Monad !) (-> a (! (Try Any))) a (All [r] (Region r ! a)))) (function (_ [region cleaners]) @@ -97,7 +93,7 @@ (All [r] (Apply (Region r !))))) (def: &functor - (..functor (get@ #monad.&functor super))) + (..functor (value@ #monad.&functor super))) (def: (apply ff fa) (function (_ [region cleaners]) @@ -122,7 +118,7 @@ (All [r] (Monad (Region r !))))) (def: &functor - (..functor (get@ #monad.&functor super))) + (..functor (value@ #monad.&functor super))) (def: (in value) (function (_ [region cleaners]) @@ -140,7 +136,6 @@ (in [cleaners (#try.Failure error)])))))) (def: .public (failure monad error) - {#.doc (example "Immediately fail with this 'message'.")} (All [! a] (-> (Monad !) Text (All [r] (Region r ! a)))) @@ -148,14 +143,12 @@ (\ monad in [cleaners (#try.Failure error)]))) (def: .public (except monad exception message) - {#.doc (example "Fail by throwing/raising an exception.")} (All [! e a] (-> (Monad !) (Exception e) e (All [r] (Region r ! a)))) (failure monad (exception.error exception message))) (def: .public (lifted monad operation) - {#.doc (example "Lift an effectful computation into a region-based computation.")} (All [! a] (-> (Monad !) (! a) (All [r] (Region r ! a)))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index 25b595b63..9c6e7a97e 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -50,13 +50,6 @@ (syntax: .public (remember [deadline ..deadline message <c>.text focus (<>.maybe <c>.any)]) - {#.doc (example "A message with an expiration date." - "Can have an optional piece of code to focus on." - (remember "2022-04-01" - "Do this, that and the other.") - (remember "2022-04-01" - "Improve the performace." - (some (complicated (computation 123)))))} (let [now (io.run! instant.now) today (instant.date now)] (if (date\< deadline today) diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index 3762c6e8f..45b2bd083 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -25,8 +25,7 @@ ["|.|" annotations]]]]]) (abstract: .public (Capability brand input output) - {#.doc (example "Represents the capability to perform an operation." - "This operation is assumed to have security implications.")} + {} (-> input output) @@ -37,7 +36,6 @@ (|>> :abstraction)) (def: .public (use capability input) - {#.doc (example "Applies a capability against its required input.")} (All [brand input output] (-> (Capability brand input output) input @@ -50,16 +48,6 @@ |declaration|.parser (<>.maybe |annotations|.parser) (<c>.form ($_ <>.and <c>.local_identifier <c>.any <c>.any))))]) - {#.doc (example "Defines a capability as a unique type, and a constructor for instances." - - (capability: (Can_Duplicate a) - (can_duplicate a [a a])) - - (let [capability (can_duplicate - (function (_ value) - [value value])) - [left right] (..use capability 123)] - (same? left right)))} (do {! meta.monad} [this_module meta.current_module_name .let [[name vars] declaration] @@ -77,7 +65,6 @@ )))) (def: .public (async capability) - {#.doc (example "Converts a synchronous I/O-based capability into an asynchronous capability.")} (All [brand input output] (-> (Capability brand input (IO output)) (Capability brand input (Async output)))) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index ea47056bd..9e33fa86b 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -9,38 +9,32 @@ abstract]]]) (abstract: .public (Policy brand value label) - {#.doc (example "A security policy encoded as the means to 'upgrade' or 'downgrade' in a secure context.")} + {} value (type: .public (Can_Upgrade brand label value) - {#.doc (example "Represents the capacity to 'upgrade' a value.")} (-> value (Policy brand value label))) (type: .public (Can_Downgrade brand label value) - {#.doc (example "Represents the capacity to 'downgrade' a value.")} (-> (Policy brand value label) value)) (type: .public (Privilege brand label) - {#.doc (example "Represents the privilege to both 'upgrade' and 'downgrade' a value.")} {#can_upgrade (Can_Upgrade brand label) #can_downgrade (Can_Downgrade brand label)}) (type: .public (Delegation brand from to) - {#.doc (example "Represents the act of delegating policy capacities.")} (All [value] (-> (Policy brand value from) (Policy brand value to)))) (def: .public (delegation downgrade upgrade) - {#.doc (example "Delegating policy capacities.")} (All [brand from to] (-> (Can_Downgrade brand from) (Can_Upgrade brand to) (Delegation brand from to))) (|>> downgrade upgrade)) (type: .public (Context brand scope label) - {#.doc (example "A computational context with an associated policy privilege.")} (-> (Privilege brand label) (scope label))) @@ -50,27 +44,6 @@ #can_downgrade (|>> :representation)}) (def: .public (with_policy context) - {#.doc (example "Activates a security context with the priviledge to enforce it's policy." - - (type: Password - (Private Text)) - - (interface: (Policy %) - (: (-> Text (Password %)) - password) - (: (-> (Password %) Text) - unsafe)) - - (def: (policy _) - (Ex [%] (-> Any (Policy %))) - (with_policy - (: (Context Privacy Policy) - (function (_ (^open "%::.")) - (implementation - (def: (password value) - (%::can_upgrade value)) - (def: (unsafe password) - (%::can_downgrade password))))))))} (All [brand scope] (Ex [label] (-> (Context brand scope label) @@ -104,9 +77,9 @@ (def: join (|>> :representation))) ) -(template [<brand> <value> <upgrade> <downgrade> <doc>] +(template [<brand> <value> <upgrade> <downgrade>] [(abstract: .public <brand> - {#.doc <doc>} + {} Any @@ -120,10 +93,6 @@ (Can_Downgrade <brand>)) )] - [Privacy Private Can_Conceal Can_Reveal - (example "A security context for privacy." - "Private data is data which cannot be allowed to leak outside of the programmed.")] - [Safety Safe Can_Trust Can_Distrust - (example "A security context for safety." - "Safe data is data coming from outside the program which can be trusted to be properly formatted and lacking injections.")] + [Privacy Private Can_Conceal Can_Reveal] + [Safety Safe Can_Trust Can_Distrust] ) diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 470751832..109491fee 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -7,42 +7,35 @@ [monad (#+ Monad do)]]]]) (type: .public (State s a) - {#.doc "Stateful computations."} (-> s [s a])) (def: .public get - {#.doc "Read the current state."} (All [s] (State s s)) (function (_ state) [state state])) (def: .public (put new_state) - {#.doc "Set the new state."} (All [s] (-> s (State s Any))) (function (_ state) [new_state []])) (def: .public (update change) - {#.doc "Compute the new state."} (All [s] (-> (-> s s) (State s Any))) (function (_ state) [(change state) []])) (def: .public (use user) - {#.doc "Run a function on the current state."} (All [s a] (-> (-> s a) (State s a))) (function (_ state) [state (user state)])) (def: .public (local change action) - {#.doc "Run the computation with a locally-modified state."} (All [s a] (-> (-> s s) (State s a) (State s a))) (function (_ state) (let [[state' output] (action (change state))] [state output]))) (def: .public (result state action) - {#.doc "Run a stateful computation."} (All [s a] (-> s (State s a) [s a])) (action state)) @@ -80,7 +73,6 @@ (ma state'))))) (def: .public (while condition body) - {#.doc (example "A stateful while loop.")} (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do {! ..monad} [execute? condition] @@ -91,7 +83,6 @@ (in [])))) (def: .public (do_while condition body) - {#.doc (example "A stateful do-while loop.")} (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do ..monad [_ body] @@ -118,16 +109,13 @@ (in [state (f a)]))))) (type: .public (+State M s a) - {#.doc "Stateful computations decorated by a monad."} (-> s (M [s a]))) (def: .public (result' state action) - {#.doc "Execute a stateful computation decorated by a monad."} (All [M s a] (-> s (+State M s a) (M [s a]))) (action state)) (implementation: .public (with monad) - {#.doc "A monad transformer to create composite stateful computations."} (All [M s] (-> (Monad M) (Monad (+State M s)))) (def: &functor (with//functor (\ monad &functor))) @@ -143,7 +131,6 @@ (sMa state'))))) (def: .public (lifted monad ma) - {#.doc "Lift monadic values to the +State wrapper."} (All [M s a] (-> (Monad M) (M a) (+State M s a))) (function (_ state) (do monad diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index 266c12afc..b70813ec9 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -15,16 +15,14 @@ abstract]]]) (type: .public (Thread ! a) - {#.doc (example "An imperative process with access to mutable values.")} (-> ! a)) (abstract: .public (Box t v) - {#.doc "A mutable box holding a value."} + {} (Array v) (def: .public (box init) - {#.doc (example "A brand-new box initialized to the given value.")} (All [a] (-> a (All [!] (Thread ! (Box ! a))))) (function (_ !) (|> (array.empty 1) @@ -32,7 +30,6 @@ :abstraction))) (def: .public (read! box) - {#.doc (example "Reads the current value in the box.")} (All [! a] (-> (Box ! a) (Thread ! a))) (function (_ !) (for {@.old @@ -54,21 +51,18 @@ @.scheme ("scheme array read" 0 (:representation box))}))) (def: .public (write! value box) - {#.doc (example "Mutates the value in the box.")} (All [a] (-> a (All [!] (-> (Box ! a) (Thread ! Any))))) (function (_ !) (|> box :representation (array.write! 0 value) :abstraction))) ) (def: .public (result thread) - {#.doc (example "Executes the imperative thread in a self-contained way.")} (All [a] (-> (All [!] (Thread ! a)) a)) (thread [])) (def: .public io - {#.doc (example "Transforms the imperative thread into an I/O computation.")} (All [a] (-> (All [!] (Thread ! a)) (IO a))) @@ -105,7 +99,6 @@ ((ffa !) !)))) (def: .public (update! f box) - {#.doc (example "Update a box's value by applying a function to it.")} (All [a !] (-> (-> a a) (Box ! a) (Thread ! a))) (do ..monad [old (read! box) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index c7dc9f1d9..05d7d69ea 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -10,7 +10,6 @@ ["." location]]]]) (type: .public (Try a) - {#.doc (example "A computation that can fail with an error message.")} (#Failure Text) (#Success a)) @@ -60,12 +59,11 @@ ma))) (implementation: .public (with monad) - {#.doc (example "Enhances a monad with error-handling functionality.")} ... TODO: Replace (All [a] (! (Try a))) with (functor.Then ! Try) (All [!] (-> (Monad !) (Monad (All [a] (! (Try a)))))) (def: &functor - (functor.composite (get@ #monad.&functor monad) ..functor)) + (functor.composite (value@ #monad.&functor monad) ..functor)) (def: in (|>> (\ ..monad in) @@ -82,7 +80,6 @@ Mea)))) (def: .public (lifted monad) - {#.doc (example "Wraps a monadic value with error-handling machinery.")} (All [! a] (-> (Monad !) (-> (! a) (! (Try a))))) (\ monad map (\ ..monad in))) @@ -102,9 +99,6 @@ ))) (def: .public (trusted try) - {#.doc (example "Assumes a Try value succeeded, and yields its value." - "If it didn't, raises the error as a runtime error." - "WARNING: Use with caution.")} (All [a] (-> (Try a) a)) (case try (#Success value) @@ -133,13 +127,6 @@ (name_of ..of_maybe)))))) (macro: .public (else tokens compiler) - {#.doc (example "Allows you to provide a default value that will be used" - "if a (Try x) value turns out to be #Failure." - "Note: the expression for the default value will not be computed if the base computation succeeds." - (= "bar" - (else "foo" (#..Success "bar"))) - (= "foo" - (else "foo" (#..Failure "KABOOM!"))))} (case tokens (^ (list else try)) (#Success [compiler (list (` (case (~ try) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index 18a0fc7e1..194822f60 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -9,12 +9,10 @@ ["." monad (#+ Monad do)]]]]) (type: .public (Writer log value) - {#.doc "Represents a value with an associated 'log' to record arbitrary information."} {#log log #value value}) (def: .public (write message) - {#.doc "Write a value to the log."} (All [log] (-> log (Writer log Any))) [message []]) @@ -51,11 +49,10 @@ [(\ monoid compose log1 log2) a]))) (implementation: .public (with monoid monad) - {#.doc (example "Enhances a monad with Writer functionality.")} (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a)))))) (def: &functor - (functor.composite (get@ #monad.&functor monad) + (functor.composite (value@ #monad.&functor monad) ..functor)) (def: in @@ -73,7 +70,6 @@ (in [(\ monoid compose l1 l2) a])))) (def: .public (lifted monoid monad) - {#.doc (example "Wraps a monadic value with Writer machinery.")} (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index cff9714e2..13b9b5a9d 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -102,8 +102,8 @@ (array.Array (I64 Any))))) (template: (!size binary) - [(for {@.old (ffi.array_length binary) - @.jvm (ffi.array_length binary) + [(for {@.old (ffi.length binary) + @.jvm (ffi.length binary) @.js (|> binary @@ -122,8 +122,8 @@ (array.size binary))]) (template: (!read index binary) - [(for {@.old (..i64 (ffi.array_read index binary)) - @.jvm (..i64 (ffi.array_read index binary)) + [(for {@.old (..i64 (ffi.read! index binary)) + @.jvm (..i64 (ffi.read! index binary)) @.js (|> binary @@ -155,8 +155,8 @@ (:as ..Binary))]) (template: (!write index value binary) - [(for {@.old (ffi.array_write index (..byte value) binary) - @.jvm (ffi.array_write index (..byte value) binary) + [(for {@.old (ffi.write! index (..byte value) binary) + @.jvm (ffi.write! index (..byte value) binary) @.js (!!write .Frac n.frac "js array write" index value binary) @.python (!!write (I64 Any) (:as (I64 Any)) "python array write" index value binary) @@ -190,13 +190,13 @@ ... Default (array.empty size))) -(def: .public (fold f init binary) +(def: .public (aggregate f init binary) (All [a] (-> (-> I64 a a) a Binary a)) (let [size (..!size binary)] (loop [index 0 output init] (if (n.< size index) - (recur (inc index) (f (!read index binary) output)) + (recur (++ index) (f (!read index binary) output)) output)))) (def: .public (read/8! index binary) @@ -307,7 +307,7 @@ (if (n.< limit index) (and (n.= (!read index reference) (!read index sample)) - (recur (inc index))) + (recur (++ index))) true)))))))) (for {@.old (as_is) @@ -341,7 +341,7 @@ (exec (!write (n.+ target_offset index) (!read (n.+ source_offset index) source) target) - (recur (inc index))) + (recur (++ index))) (#try.Success target)))))))) (def: .public (slice offset length binary) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 5d306f773..ae6aa7b96 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -205,7 +205,7 @@ count (#.Some _) - (inc count))) + (++ count))) 0 (list.indices (size array)))) @@ -239,12 +239,12 @@ (if (n.< arr_size idx) (case (read! idx xs) #.None - (recur (inc idx)) + (recur (++ idx)) (#.Some x) (if (p x) (#.Some x) - (recur (inc idx)))) + (recur (++ idx)))) #.None)))) (def: .public (example+ p xs) @@ -256,12 +256,12 @@ (if (n.< arr_size idx) (case (read! idx xs) #.None - (recur (inc idx)) + (recur (++ idx)) (#.Some x) (if (p idx x) (#.Some [idx x]) - (recur (inc idx)))) + (recur (++ idx)))) #.None)))) (def: .public (clone xs) @@ -281,25 +281,25 @@ (def: .public (of_list xs) (All [a] (-> (List a) (Array a))) (product.right (list\fold (function (_ x [idx arr]) - [(inc idx) (write! idx x arr)]) + [(++ idx) (write! idx x arr)]) [0 (empty (list.size xs))] xs))) (def: underflow Nat - (dec 0)) + (-- 0)) (def: .public (list array) {#.doc (.example "Yields a list with every non-empty item in the array.")} (All [a] (-> (Array a) (List a))) - (loop [idx (dec (size array)) + (loop [idx (-- (size array)) output #.End] (case idx (^ (static ..underflow)) output _ - (recur (dec idx) + (recur (-- idx) (case (read! idx array) (#.Some head) (#.Item head output) @@ -310,14 +310,14 @@ (def: .public (list' default array) {#.doc (.example "Like 'list', but uses the 'default' value when encountering an empty cell in the array.")} (All [a] (-> a (Array a) (List a))) - (loop [idx (dec (size array)) + (loop [idx (-- (size array)) output #.End] (case idx (^ (static ..underflow)) output _ - (recur (dec idx) + (recur (-- idx) (#.Item (maybe.else default (read! idx array)) output))))) @@ -382,10 +382,10 @@ (if (n.< arr_size idx) (case (read! idx xs) #.None - (recur so_far (inc idx)) + (recur so_far (++ idx)) (#.Some value) - (recur (f value so_far) (inc idx))) + (recur (f value so_far) (++ idx))) so_far))))) (template [<name> <init> <op>] @@ -399,10 +399,10 @@ (case (..read! idx array) (#.Some value) (<op> (predicate value) - (recur (inc idx))) + (recur (++ idx))) #.None - (recur (inc idx))) + (recur (++ idx))) <init>)))))] [every? true and] diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux index e5e85e361..b5059ea8a 100644 --- a/stdlib/source/library/lux/data/collection/bits.lux +++ b/stdlib/source/library/lux/data/collection/bits.lux @@ -66,10 +66,10 @@ [(def: .public (<name> index input) (-> Nat Bits Bits) (let [[chunk_index bit_index] (n./% chunk_size index)] - (loop [size|output (n.max (inc chunk_index) + (loop [size|output (n.max (++ chunk_index) (array.size input)) output ..empty] - (let [idx|output (dec size|output)] + (let [idx|output (-- size|output)] (if (n.> 0 size|output) (case (|> (..chunk idx|output input) (cond> [(new> (n.= chunk_index idx|output) [])] @@ -80,7 +80,7 @@ .nat) 0 ... TODO: Remove 'no_op' once new-luxc is the official compiler. - (let [no_op (recur (dec size|output) output)] + (let [no_op (recur (-- size|output) output)] no_op) chunk @@ -88,7 +88,7 @@ (: Bits (array.empty size|output)) output) (array.write! idx|output (.i64 chunk)) - (recur (dec size|output)))) + (recur (-- size|output)))) output)))))] [one i64.one] @@ -106,7 +106,7 @@ (i64.and (..chunk idx reference)) ("lux i64 =" empty_chunk) .not) - (recur (inc idx))) + (recur (++ idx))) #0)))) (def: .public (not input) @@ -118,10 +118,10 @@ size|output (loop [size|output size|output output ..empty] - (let [idx (dec size|output)] + (let [idx (-- size|output)] (case (|> input (..chunk idx) i64.not .nat) 0 - (recur (dec size|output) output) + (recur (-- size|output) output) chunk (if (n.> 0 size|output) @@ -129,7 +129,7 @@ (: Bits (array.empty size|output)) output) (array.write! idx (.i64 chunk)) - (recur (dec size|output))) + (recur (-- size|output))) output)))))) (template [<name> <op>] @@ -143,20 +143,20 @@ size|output (loop [size|output size|output output ..empty] - (let [idx (dec size|output)] + (let [idx (-- size|output)] (if (n.> 0 size|output) (case (|> (..chunk idx subject) (<op> (..chunk idx param)) .nat) 0 - (recur (dec size|output) output) + (recur (-- size|output) output) chunk (|> (if (same? ..empty output) (: Bits (array.empty size|output)) output) (array.write! idx (.i64 chunk)) - (recur (dec size|output)))) + (recur (-- size|output)))) output)))))] [and i64.and] @@ -175,5 +175,5 @@ (.and ("lux i64 =" (..chunk idx reference) (..chunk idx sample)) - (recur (inc idx))) + (recur (++ idx))) #1))))) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index fb7aaaa83..6773a3b95 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -133,10 +133,10 @@ (def: (array\has idx value old_array) (All [a] (-> Index a (Array a) (Array a))) (let [old_size (array.size old_array)] - (|> (array.empty (inc old_size)) + (|> (array.empty (++ old_size)) (array.copy! idx 0 old_array 0) (array.write! idx value) - (array.copy! (n.- idx old_size) idx old_array (inc idx))))) + (array.copy! (n.- idx old_size) idx old_array (++ idx))))) ... Creates a copy of an array with an index set to a particular value. (def: (array\revised idx value array) @@ -151,10 +151,10 @@ ... Shrinks a copy of the array by removing the space at index. (def: (array\lacks idx array) (All [a] (-> Index (Array a) (Array a))) - (let [new_size (dec (array.size array))] + (let [new_size (-- (array.size array))] (|> (array.empty new_size) (array.copy! idx 0 array 0) - (array.copy! (n.- idx new_size) (inc idx) array idx)))) + (array.copy! (n.- idx new_size) (++ idx) array idx)))) ... Increases the level-shift by the branching-exponent, to explore ... levels further down the tree. @@ -164,7 +164,7 @@ (def: hierarchy_mask Bit_Map - (dec hierarchy_nodes_size)) + (-- hierarchy_nodes_size)) ... Gets the branching-factor sized section of the hash corresponding ... to a particular level, and uses that as an index into the array. @@ -214,7 +214,7 @@ ... associated with it. (def: bit_position_mask (-> Bit_Position Bit_Map) - dec) + --) ... The index on the base array, based on its bit-position. (def: (base_index bit_position bitmap) @@ -240,12 +240,12 @@ #.None [insertion_idx node] (#.Some sub_node) (if (n.= except_idx idx) [insertion_idx node] - [(inc insertion_idx) + [(++ insertion_idx) [(with_bit_position (to_bit_position idx) bitmap) (array.write! insertion_idx (#.Left sub_node) base)]]) ))) [0 [clean_bitmap - (array.empty (dec h_size))]] + (array.empty (-- h_size))]] (list.indices (array.size h_array))))) ... When #Base nodes grow too large, they're promoted to #Hierarchy to @@ -263,7 +263,7 @@ (product.right (list\fold (function (_ hierarchy_idx (^@ default [base_idx h_array])) (if (with_bit_position? (to_bit_position hierarchy_idx) bitmap) - [(inc base_idx) + [(++ base_idx) (case (array.read! base_idx base) (#.Some (#.Left sub_node)) (array.write! hierarchy_idx sub_node h_array) @@ -304,7 +304,7 @@ [_size sub_node] _ - [(inc _size) empty_node])] + [(++ _size) empty_node])] (#Hierarchy _size' (array\revised idx (node\has (level_up level) hash key val key_hash sub_node) hierarchy))) @@ -357,7 +357,7 @@ (if (n.>= ..promotion_threshold base_count) ... If so, promote it to a #Hierarchy node, and add the new ... KV-pair as a singleton node to it. - (#Hierarchy (inc base_count) + (#Hierarchy (++ base_count) (|> base (promotion node\has key_hash level bitmap) (array.write! (level_index level hash) @@ -415,7 +415,7 @@ ... If so, perform it. (#Base (demotion idx [h_size h_array])) ... Otherwise, just clear the space. - (#Hierarchy (dec h_size) (array\lacks' idx h_array))) + (#Hierarchy (-- h_size) (array\lacks' idx h_array))) ... But if the sub_removal yielded a non_empty node, then ... just update the hiearchy branch. (#Hierarchy h_size (array\revised idx sub_node' h_array))))))) @@ -562,7 +562,7 @@ (def: .public key_hash (All [k v] (-> (Dictionary k v) (Hash k))) - (get@ #..hash)) + (value@ #..hash)) (def: .public (empty key_hash) {#.doc (example "An empty dictionary.")} @@ -737,4 +737,4 @@ (All [k] (Functor (Dictionary k))) (def: (map f fa) - (update@ #root (\ ..functor' map f) fa))) + (revised@ #root (\ ..functor' map f) fa))) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 84e883b1d..567c1f457 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -60,60 +60,60 @@ ... TODO: Must improve it as soon as bug is fixed. (def: .public (value key dict) (All [k v] (-> k (Dictionary k v) (Maybe v))) - (let [... (^open "_\.") (get@ #&order dict) + (let [... (^open "_\.") (value@ #&order dict) ] - (loop [node (get@ #root dict)] + (loop [node (value@ #root dict)] (case node #.None #.None (#.Some node) - (let [node_key (get@ #key node)] + (let [node_key (value@ #key node)] (cond (\ dict = node_key key) ... (_\= node_key key) - (#.Some (get@ #value node)) + (#.Some (value@ #value node)) (\ dict < node_key key) ... (_\< node_key key) - (recur (get@ #left node)) + (recur (value@ #left node)) - ... (_\> (get@ #key node) key) - (recur (get@ #right node)))) + ... (_\> (value@ #key node) key) + (recur (value@ #right node)))) )))) ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. (def: .public (key? dict key) (All [k v] (-> (Dictionary k v) k Bit)) - (let [... (^open "_\.") (get@ #&order dict) + (let [... (^open "_\.") (value@ #&order dict) ] - (loop [node (get@ #root dict)] + (loop [node (value@ #root dict)] (case node #.None #0 (#.Some node) - (let [node_key (get@ #key node)] + (let [node_key (value@ #key node)] (or (\ dict = node_key key) ... (_\= node_key key) (if (\ dict < node_key key) ... (_\< node_key key) - (recur (get@ #left node)) - (recur (get@ #right node))))))))) + (recur (value@ #left node)) + (recur (value@ #right node))))))))) (template [<name> <side>] [(def: .public (<name> dict) {#.doc (example (~~ (template.text ["Yields value under the " <name> "imum key."])))} (All [k v] (-> (Dictionary k v) (Maybe v))) - (case (get@ #root dict) + (case (value@ #root dict) #.None #.None (#.Some node) (loop [node node] - (case (get@ <side> node) + (case (value@ <side> node) #.None - (#.Some (get@ #value node)) + (#.Some (value@ #value node)) (#.Some side) (recur side)))))] @@ -124,14 +124,14 @@ (def: .public (size dict) (All [k v] (-> (Dictionary k v) Nat)) - (loop [node (get@ #root dict)] + (loop [node (value@ #root dict)] (case node #.None 0 (#.Some node) - (inc (n.+ (recur (get@ #left node)) - (recur (get@ #right node))))))) + (++ (n.+ (recur (value@ #left node)) + (recur (value@ #right node))))))) (def: .public empty? (All [k v] (-> (Dictionary k v) Bit)) @@ -140,9 +140,9 @@ (template [<name> <other_color> <self_color> <no_change>] [(def: (<name> self) (All [k v] (-> (Node k v) (Node k v))) - (case (get@ #color self) + (case (value@ #color self) <other_color> - (set@ #color <self_color> self) + (with@ #color <self_color> self) <self_color> <no_change> @@ -154,46 +154,46 @@ (def: (with_left addition center) (All [k v] (-> (Node k v) (Node k v) (Node k v))) - (case (get@ #color center) + (case (value@ #color center) #Red - (red (get@ #key center) - (get@ #value center) + (red (value@ #key center) + (value@ #value center) (#.Some addition) - (get@ #right center)) + (value@ #right center)) #Black (with_expansions - [<default_behavior> (as_is (black (get@ #key center) - (get@ #value center) + [<default_behavior> (as_is (black (value@ #key center) + (value@ #value center) (#.Some addition) - (get@ #right center)))] - (case (get@ #color addition) + (value@ #right center)))] + (case (value@ #color addition) #Red - (case (get@ #left addition) + (case (value@ #left addition) (^multi (#.Some left) - {(get@ #color left) #Red}) - (red (get@ #key addition) - (get@ #value addition) + {(value@ #color left) #Red}) + (red (value@ #key addition) + (value@ #value addition) (#.Some (blackened left)) - (#.Some (black (get@ #key center) - (get@ #value center) - (get@ #right addition) - (get@ #right center)))) + (#.Some (black (value@ #key center) + (value@ #value center) + (value@ #right addition) + (value@ #right center)))) _ - (case (get@ #right addition) + (case (value@ #right addition) (^multi (#.Some right) - {(get@ #color right) #Red}) - (red (get@ #key right) - (get@ #value right) - (#.Some (black (get@ #key addition) - (get@ #value addition) - (get@ #left addition) - (get@ #left right))) - (#.Some (black (get@ #key center) - (get@ #value center) - (get@ #right right) - (get@ #right center)))) + {(value@ #color right) #Red}) + (red (value@ #key right) + (value@ #value right) + (#.Some (black (value@ #key addition) + (value@ #value addition) + (value@ #left addition) + (value@ #left right))) + (#.Some (black (value@ #key center) + (value@ #value center) + (value@ #right right) + (value@ #right center)))) _ <default_behavior>)) @@ -203,46 +203,46 @@ (def: (with_right addition center) (All [k v] (-> (Node k v) (Node k v) (Node k v))) - (case (get@ #color center) + (case (value@ #color center) #Red - (red (get@ #key center) - (get@ #value center) - (get@ #left center) + (red (value@ #key center) + (value@ #value center) + (value@ #left center) (#.Some addition)) #Black (with_expansions - [<default_behavior> (as_is (black (get@ #key center) - (get@ #value center) - (get@ #left center) + [<default_behavior> (as_is (black (value@ #key center) + (value@ #value center) + (value@ #left center) (#.Some addition)))] - (case (get@ #color addition) + (case (value@ #color addition) #Red - (case (get@ #right addition) + (case (value@ #right addition) (^multi (#.Some right) - {(get@ #color right) #Red}) - (red (get@ #key addition) - (get@ #value addition) - (#.Some (black (get@ #key center) - (get@ #value center) - (get@ #left center) - (get@ #left addition))) + {(value@ #color right) #Red}) + (red (value@ #key addition) + (value@ #value addition) + (#.Some (black (value@ #key center) + (value@ #value center) + (value@ #left center) + (value@ #left addition))) (#.Some (blackened right))) _ - (case (get@ #left addition) + (case (value@ #left addition) (^multi (#.Some left) - {(get@ #color left) #Red}) - (red (get@ #key left) - (get@ #value left) - (#.Some (black (get@ #key center) - (get@ #value center) - (get@ #left center) - (get@ #left left))) - (#.Some (black (get@ #key addition) - (get@ #value addition) - (get@ #right left) - (get@ #right addition)))) + {(value@ #color left) #Red}) + (red (value@ #key left) + (value@ #value left) + (#.Some (black (value@ #key center) + (value@ #value center) + (value@ #left center) + (value@ #left left))) + (#.Some (black (value@ #key addition) + (value@ #value addition) + (value@ #right left) + (value@ #right addition)))) _ <default_behavior>)) @@ -252,17 +252,17 @@ (def: .public (has key value dict) (All [k v] (-> k v (Dictionary k v) (Dictionary k v))) - (let [(^open "_\.") (get@ #&order dict) - root' (loop [?root (get@ #root dict)] + (let [(^open "_\.") (value@ #&order dict) + root' (loop [?root (value@ #root dict)] (case ?root #.None (#.Some (red key value #.None #.None)) (#.Some root) - (let [reference (get@ #key root)] + (let [reference (value@ #key root)] (`` (cond (~~ (template [<comp> <tag> <add>] [(<comp> reference key) - (let [side_root (get@ <tag> root) + (let [side_root (value@ <tag> root) outcome (recur side_root)] (if (same? side_root outcome) ?root @@ -270,39 +270,39 @@ root))))] [_\< #left ..with_left] - [(order.> (get@ #&order dict)) #right ..with_right] + [(order.> (value@ #&order dict)) #right ..with_right] )) ... (_\= reference key) - (#.Some (set@ #value value root)) + (#.Some (with@ #value value root)) ))) ))] - (set@ #root root' dict))) + (with@ #root root' dict))) (def: (left_balanced key value ?left ?right) (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^multi (#.Some left) - {(get@ #color left) #Red} - {(get@ #left left) (#.Some left>>left)} - {(get@ #color left>>left) #Red}) - (red (get@ #key left) - (get@ #value left) + {(value@ #color left) #Red} + {(value@ #left left) (#.Some left>>left)} + {(value@ #color left>>left) #Red}) + (red (value@ #key left) + (value@ #value left) (#.Some (blackened left>>left)) - (#.Some (black key value (get@ #right left) ?right))) + (#.Some (black key value (value@ #right left) ?right))) (^multi (#.Some left) - {(get@ #color left) #Red} - {(get@ #right left) (#.Some left>>right)} - {(get@ #color left>>right) #Red}) - (red (get@ #key left>>right) - (get@ #value left>>right) - (#.Some (black (get@ #key left) - (get@ #value left) - (get@ #left left) - (get@ #left left>>right))) + {(value@ #color left) #Red} + {(value@ #right left) (#.Some left>>right)} + {(value@ #color left>>right) #Red}) + (red (value@ #key left>>right) + (value@ #value left>>right) + (#.Some (black (value@ #key left) + (value@ #value left) + (value@ #left left) + (value@ #left left>>right))) (#.Some (black key value - (get@ #right left>>right) + (value@ #right left>>right) ?right))) _ @@ -312,25 +312,25 @@ (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^multi (#.Some right) - {(get@ #color right) #Red} - {(get@ #right right) (#.Some right>>right)} - {(get@ #color right>>right) #Red}) - (red (get@ #key right) - (get@ #value right) - (#.Some (black key value ?left (get@ #left right))) + {(value@ #color right) #Red} + {(value@ #right right) (#.Some right>>right)} + {(value@ #color right>>right) #Red}) + (red (value@ #key right) + (value@ #value right) + (#.Some (black key value ?left (value@ #left right))) (#.Some (blackened right>>right))) (^multi (#.Some right) - {(get@ #color right) #Red} - {(get@ #left right) (#.Some right>>left)} - {(get@ #color right>>left) #Red}) - (red (get@ #key right>>left) - (get@ #value right>>left) - (#.Some (black key value ?left (get@ #left right>>left))) - (#.Some (black (get@ #key right) - (get@ #value right) - (get@ #right right>>left) - (get@ #right right)))) + {(value@ #color right) #Red} + {(value@ #left right) (#.Some right>>left)} + {(value@ #color right>>left) #Red}) + (red (value@ #key right>>left) + (value@ #value right>>left) + (#.Some (black key value ?left (value@ #left right>>left))) + (#.Some (black (value@ #key right) + (value@ #value right) + (value@ #right right>>left) + (value@ #right right)))) _ (black key value ?left ?right))) @@ -339,26 +339,26 @@ (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^multi (#.Some left) - {(get@ #color left) #Red}) + {(value@ #color left) #Red}) (red key value (#.Some (blackened left)) ?right) _ (case ?right (^multi (#.Some right) - {(get@ #color right) #Black}) + {(value@ #color right) #Black}) (right_balanced key value ?left (#.Some (reddened right))) (^multi (#.Some right) - {(get@ #color right) #Red} - {(get@ #left right) (#.Some right>>left)} - {(get@ #color right>>left) #Black}) - (red (get@ #key right>>left) - (get@ #value right>>left) - (#.Some (black key value ?left (get@ #left right>>left))) - (#.Some (right_balanced (get@ #key right) - (get@ #value right) - (get@ #right right>>left) - (\ maybe.functor map reddened (get@ #right right))))) + {(value@ #color right) #Red} + {(value@ #left right) (#.Some right>>left)} + {(value@ #color right>>left) #Black}) + (red (value@ #key right>>left) + (value@ #value right>>left) + (#.Some (black key value ?left (value@ #left right>>left))) + (#.Some (right_balanced (value@ #key right) + (value@ #value right) + (value@ #right right>>left) + (\ maybe.functor map reddened (value@ #right right))))) _ (panic! error_message)) @@ -368,26 +368,26 @@ (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^multi (#.Some right) - {(get@ #color right) #Red}) + {(value@ #color right) #Red}) (red key value ?left (#.Some (blackened right))) _ (case ?left (^multi (#.Some left) - {(get@ #color left) #Black}) + {(value@ #color left) #Black}) (left_balanced key value (#.Some (reddened left)) ?right) (^multi (#.Some left) - {(get@ #color left) #Red} - {(get@ #right left) (#.Some left>>right)} - {(get@ #color left>>right) #Black}) - (red (get@ #key left>>right) - (get@ #value left>>right) - (#.Some (left_balanced (get@ #key left) - (get@ #value left) - (\ maybe.functor map reddened (get@ #left left)) - (get@ #left left>>right))) - (#.Some (black key value (get@ #right left>>right) ?right))) + {(value@ #color left) #Red} + {(value@ #right left) (#.Some left>>right)} + {(value@ #color left>>right) #Black}) + (red (value@ #key left>>right) + (value@ #value left>>right) + (#.Some (left_balanced (value@ #key left) + (value@ #value left) + (\ maybe.functor map reddened (value@ #left left)) + (value@ #left left>>right))) + (#.Some (black key value (value@ #right left>>right) ?right))) _ (panic! error_message) @@ -403,70 +403,70 @@ ?left [(#.Some left) (#.Some right)] - (case [(get@ #color left) (get@ #color right)] + (case [(value@ #color left) (value@ #color right)] [#Red #Red] (do maybe.monad - [fused (prepended (get@ #right left) (get@ #right right))] - (case (get@ #color fused) + [fused (prepended (value@ #right left) (value@ #right right))] + (case (value@ #color fused) #Red - (in (red (get@ #key fused) - (get@ #value fused) - (#.Some (red (get@ #key left) - (get@ #value left) - (get@ #left left) - (get@ #left fused))) - (#.Some (red (get@ #key right) - (get@ #value right) - (get@ #right fused) - (get@ #right right))))) + (in (red (value@ #key fused) + (value@ #value fused) + (#.Some (red (value@ #key left) + (value@ #value left) + (value@ #left left) + (value@ #left fused))) + (#.Some (red (value@ #key right) + (value@ #value right) + (value@ #right fused) + (value@ #right right))))) #Black - (in (red (get@ #key left) - (get@ #value left) - (get@ #left left) - (#.Some (red (get@ #key right) - (get@ #value right) + (in (red (value@ #key left) + (value@ #value left) + (value@ #left left) + (#.Some (red (value@ #key right) + (value@ #value right) (#.Some fused) - (get@ #right right))))))) + (value@ #right right))))))) [#Red #Black] - (#.Some (red (get@ #key left) - (get@ #value left) - (get@ #left left) - (prepended (get@ #right left) + (#.Some (red (value@ #key left) + (value@ #value left) + (value@ #left left) + (prepended (value@ #right left) ?right))) [#Black #Red] - (#.Some (red (get@ #key right) - (get@ #value right) + (#.Some (red (value@ #key right) + (value@ #value right) (prepended ?left - (get@ #left right)) - (get@ #right right))) + (value@ #left right)) + (value@ #right right))) [#Black #Black] (do maybe.monad - [fused (prepended (get@ #right left) (get@ #left right))] - (case (get@ #color fused) + [fused (prepended (value@ #right left) (value@ #left right))] + (case (value@ #color fused) #Red - (in (red (get@ #key fused) - (get@ #value fused) - (#.Some (black (get@ #key left) - (get@ #value left) - (get@ #left left) - (get@ #left fused))) - (#.Some (black (get@ #key right) - (get@ #value right) - (get@ #right fused) - (get@ #right right))))) + (in (red (value@ #key fused) + (value@ #value fused) + (#.Some (black (value@ #key left) + (value@ #value left) + (value@ #left left) + (value@ #left fused))) + (#.Some (black (value@ #key right) + (value@ #value right) + (value@ #right fused) + (value@ #right right))))) #Black - (in (without_left (get@ #key left) - (get@ #value left) - (get@ #left left) - (#.Some (black (get@ #key right) - (get@ #value right) + (in (without_left (value@ #key left) + (value@ #value left) + (value@ #left left) + (#.Some (black (value@ #key right) + (value@ #value right) (#.Some fused) - (get@ #right right))))) + (value@ #right right))))) )) ) @@ -475,45 +475,45 @@ (def: .public (lacks key dict) (All [k v] (-> k (Dictionary k v) (Dictionary k v))) - (let [(^open "_\.") (get@ #&order dict) - [?root found?] (loop [?root (get@ #root dict)] + (let [(^open "_\.") (value@ #&order dict) + [?root found?] (loop [?root (value@ #root dict)] (case ?root #.None [#.None #0] (#.Some root) - (let [root_key (get@ #key root) - root_val (get@ #value root)] + (let [root_key (value@ #key root) + root_val (value@ #value root)] (if (_\= root_key key) - [(prepended (get@ #left root) - (get@ #right root)) + [(prepended (value@ #left root) + (value@ #right root)) #1] (let [go_left? (_\< root_key key)] (case (recur (if go_left? - (get@ #left root) - (get@ #right root))) + (value@ #left root) + (value@ #right root))) [#.None #0] [#.None #0] [side_outcome _] (if go_left? - (case (get@ #left root) + (case (value@ #left root) (^multi (#.Some left) - {(get@ #color left) #Black}) - [(#.Some (without_left root_key root_val side_outcome (get@ #right root))) + {(value@ #color left) #Black}) + [(#.Some (without_left root_key root_val side_outcome (value@ #right root))) #0] _ - [(#.Some (red root_key root_val side_outcome (get@ #right root))) + [(#.Some (red root_key root_val side_outcome (value@ #right root))) #0]) - (case (get@ #right root) + (case (value@ #right root) (^multi (#.Some right) - {(get@ #color right) #Black}) - [(#.Some (without_right root_key root_val (get@ #left root) side_outcome)) + {(value@ #color right) #Black}) + [(#.Some (without_right root_key root_val (value@ #left root) side_outcome)) #0] _ - [(#.Some (red root_key root_val (get@ #left root) side_outcome)) + [(#.Some (red root_key root_val (value@ #left root) side_outcome)) #0]) ))) )) @@ -521,11 +521,11 @@ (case ?root #.None (if found? - (set@ #root ?root dict) + (with@ #root ?root dict) dict) (#.Some root) - (set@ #root (#.Some (blackened root)) dict) + (with@ #root (#.Some (blackened root)) dict) ))) (def: .public (revised key transform dict) @@ -547,27 +547,27 @@ (template [<name> <type> <output>] [(def: .public (<name> dict) (All [k v] (-> (Dictionary k v) (List <type>))) - (loop [node (get@ #root dict)] + (loop [node (value@ #root dict)] (case node #.None (list) (#.Some node') ($_ list\compose - (recur (get@ #left node')) + (recur (value@ #left node')) (list <output>) - (recur (get@ #right node'))))))] + (recur (value@ #right node'))))))] - [entries [k v] [(get@ #key node') (get@ #value node')]] - [keys k (get@ #key node')] - [values v (get@ #value node')] + [entries [k v] [(value@ #key node') (value@ #value node')]] + [keys k (value@ #key node')] + [values v (value@ #value node')] ) (implementation: .public (equivalence (^open ",\.")) (All [k v] (-> (Equivalence v) (Equivalence (Dictionary k v)))) (def: (= reference sample) - (let [(^open "/\.") (get@ #&order reference)] + (let [(^open "/\.") (value@ #&order reference)] (loop [entriesR (entries reference) entriesS (entries sample)] (case [entriesR entriesS] diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 8cba7efb2..cb52d478d 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -34,14 +34,14 @@ (#.Item x xs') (fold f (f x init) xs')))) -(def: .public (folds f init inputs) +(def: .public (aggregates f init inputs) (All [a b] (-> (-> a b b) b (List a) (List b))) (case inputs #.End (list init) (#.Item [head tail]) - (#.Item [init (folds f (f head init) tail)]))) + (#.Item [init (aggregates f (f head init) tail)]))) (def: .public (reversed xs) (All [a] @@ -100,8 +100,8 @@ <then>) <else>))] - [first (#.Item x (first (dec n) xs')) #.End] - [after (after (dec n) xs') xs] + [first (#.Item x (first (-- n) xs')) #.End] + [after (after (-- n) xs') xs] ) (template [<name> <then> <else>] @@ -130,7 +130,7 @@ [#.End #.End] (#.Item x xs') - (let [[tail rest] (split_at (dec n) xs')] + (let [[tail rest] (split_at (-- n) xs')] [(#.Item x tail) rest])) [#.End xs])) @@ -170,7 +170,7 @@ (-> Nat a (List a))) (case n 0 #.End - _ (#.Item x (repeated (dec n) x)))) + _ (#.Item x (repeated (-- n) x)))) (def: (iterations' f x) (All [a] @@ -263,21 +263,16 @@ (fold (function (_ _ acc) (n.+ 1 acc)) 0 list)) (template [<name> <init> <op>] - [(def: .public (<name> predicate xs) + [(def: .public (<name> predicate items) (All [a] (-> (Predicate a) (List a) Bit)) - (loop [xs xs] - (case xs - #.End - <init> - - (#.Item x xs') - (case (predicate x) - <init> - (recur xs') + (case items + #.End + <init> - output - output))))] + (#.Item head tail) + (<op> (predicate head) + (<name> predicate tail))))] [every? #1 and] [any? #0 or] @@ -292,9 +287,9 @@ #.None (#.Item x xs') - (if (n.= 0 i) - (#.Some x) - (item (dec i) xs')))) + (case i + 0 (#.Some x) + _ (item (-- i) xs')))) (implementation: .public (equivalence Equivalence<a>) (All [a] (-> (Equivalence a) (Equivalence (List a)))) @@ -428,9 +423,9 @@ (def: .public (indices size) {#.doc "Produces all the valid indices for a given size."} (All [a] (-> Nat (List Nat))) - (if (n.= 0 size) - (list) - (|> size dec (enum.range n.enum 0)))) + (case size + 0 (list) + _ (|> size -- (enum.range n.enum 0)))) (def: (identifier$ name) (-> Text Code) @@ -454,9 +449,9 @@ _ (undefined)) output' ("lux text concat" digit output) input' (n./ 10 input)] - (if (n.= 0 input') - output' - (recur input' output'))))) + (case input' + 0 output' + _ (recur input' output'))))) (macro: .public (zipped tokens state) {#.doc (.example "Create list zippers with the specified number of input lists." @@ -475,7 +470,7 @@ type_vars)) (List [(~+ type_vars)])))) vars+lists (|> indices - (map inc) + (map ++) (map (function (_ idx) (let [base (nat\encode idx)] [(identifier$ base) @@ -523,7 +518,7 @@ type_vars)) (List (~ g!return_type))))) vars+lists (|> indices - (map inc) + (map ++) (map (function (_ idx) (let [base (nat\encode idx)] [(identifier$ base) @@ -583,7 +578,7 @@ (#.Some (#.Item x tail))) )) -(def: .public joined +(def: .public together {#.doc (.example "The sequential combination of all the lists.")} (All [a] (-> (List (List a)) (List a))) (\ ..monad join)) @@ -593,7 +588,8 @@ (All [M] (-> (Monad M) (Monad (All [a] (M (List a)))))) (def: &functor - (functor.composite (get@ #monad.&functor monad) ..functor)) + (functor.composite (value@ #monad.&functor monad) + ..functor)) (def: in (|>> (\ ..monad in) (\ monad in))) @@ -604,9 +600,9 @@ ... TODO: Remove this version ASAP and use one below. lla (for {@.old (: ((:parameter 0) (List (List (:parameter 1)))) - (monad.seq ! lMla))} - (monad.seq ! lMla))] - (in (..joined lla))))) + (monad.all ! lMla))} + (monad.all ! lMla))] + (in (..together lla))))) (def: .public (lifted monad) {#.doc (.example "Wraps a monadic value with List machinery.")} @@ -623,7 +619,7 @@ #.End (#.Item x xs') - (#.Item [idx x] (recur (inc idx) xs'))))) + (#.Item [idx x] (recur (++ idx) xs'))))) (macro: .public (when tokens state) {#.doc (.example "Can be used as a guard in (co)monadic be/do expressions." diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index 3e017d382..a54543eae 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -34,7 +34,7 @@ (def: .public front {#.doc (example "Yields the first value in the queue, if any.")} (All [a] (-> (Queue a) (Maybe a))) - (|>> (get@ #front) list.head)) + (|>> (value@ #front) list.head)) (def: .public (size queue) (All [a] (-> (Queue a) Nat)) @@ -44,7 +44,7 @@ (def: .public empty? (All [a] (-> (Queue a) Bit)) - (|>> (get@ #front) list.empty?)) + (|>> (value@ #front) list.empty?)) (def: .public (member? equivalence queue member) (All [a] (-> (Equivalence a) (Queue a) a Bit)) @@ -54,7 +54,7 @@ (def: .public (next queue) (All [a] (-> (Queue a) (Queue a))) - (case (get@ #front queue) + (case (value@ #front queue) ... Empty... (^ (.list)) queue @@ -62,22 +62,22 @@ ... Front has dried up... (^ (.list _)) (|> queue - (set@ #front (list.reversed (get@ #rear queue))) - (set@ #rear (.list))) + (with@ #front (list.reversed (value@ #rear queue))) + (with@ #rear (.list))) ... Consume front! (^ (.list& _ front')) (|> queue - (set@ #front front')))) + (with@ #front front')))) (def: .public (end val queue) (All [a] (-> a (Queue a) (Queue a))) - (case (get@ #front queue) + (case (value@ #front queue) #.End - (set@ #front (.list val) queue) + (with@ #front (.list val) queue) _ - (update@ #rear (|>> (#.Item val)) queue))) + (revised@ #rear (|>> (#.Item val)) queue))) (implementation: .public (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (Queue a)))) @@ -91,5 +91,5 @@ (Functor Queue) (def: (map f fa) - {#front (|> fa (get@ #front) (list\map f)) - #rear (|> fa (get@ #rear) (list\map f))})) + {#front (|> fa (value@ #front) (list\map f)) + #rear (|> fa (value@ #rear) (list\map f))})) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index 6a4b88587..e77ef1bdf 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -17,8 +17,8 @@ ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] - ["p" parser - ["s" code (#+ Parser)]]] + ["<>" parser + ["<.>" code (#+ Parser)]]] [data ["." product] [collection @@ -29,8 +29,8 @@ ["." code]] [math [number - ["." i64] - ["n" nat]]]]]) + ["n" nat] + ["." i64]]]]]) (type: (Node a) (#Base (Array a)) @@ -66,7 +66,7 @@ (def: branch_idx_mask Nat - (dec full_node_size)) + (-- full_node_size)) (def: branch_idx (-> Index Index) @@ -80,7 +80,7 @@ (-> Nat Nat) (if (n.< full_node_size row_size) 0 - (|> (dec row_size) + (|> (-- row_size) (i64.right_shifted branching_exponent) (i64.left_shifted branching_exponent)))) @@ -99,7 +99,7 @@ (def: (with_tail size level tail parent) (All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) - (let [sub_idx (branch_idx (i64.right_shifted level (dec size))) + (let [sub_idx (branch_idx (i64.right_shifted level (-- size))) ... If we're currently on a bottom node sub_node (if (n.= branching_exponent level) ... Just add the tail to it @@ -122,7 +122,7 @@ (def: (expanded_tail val tail) (All [a] (-> a (Base a) (Base a))) (let [tail_size (array.size tail)] - (|> (array.empty (inc tail_size)) + (|> (array.empty (++ tail_size)) (array.copy! tail_size 0 tail 0) (array.write! tail_size val)))) @@ -198,45 +198,45 @@ (def: .public (size row) (All [a] (-> (Row a) Nat)) - (get@ #size row)) + (value@ #size row)) -(def: .public (add val row) +(def: .public (suffix val row) (All [a] (-> a (Row a) (Row a))) ... Check if there is room in the tail. - (let [row_size (get@ #size row)] + (let [row_size (value@ #size row)] (if (|> row_size (n.- (tail_off row_size)) (n.< full_node_size)) ... If so, append to it. (|> row - (update@ #size inc) - (update@ #tail (..expanded_tail val))) + (revised@ #size ++) + (revised@ #tail (..expanded_tail val))) ... Otherwise, push tail into the tree ... -------------------------------------------------------- ... Will the root experience an overflow with this addition? - (|> (if (n.> (i64.left_shifted (get@ #level row) 1) + (|> (if (n.> (i64.left_shifted (value@ #level row) 1) (i64.right_shifted branching_exponent row_size)) ... If so, a brand-new root must be established, that is ... 1-level taller. (|> row - (set@ #root (|> (for {@.old - (: (Hierarchy (:parameter 0)) - (empty_hierarchy []))} - (empty_hierarchy [])) - (array.write! 0 (#Hierarchy (get@ #root row))) - (array.write! 1 (..path (get@ #level row) (get@ #tail row))))) - (update@ #level level_up)) + (with@ #root (|> (for {@.old + (: (Hierarchy (:parameter 0)) + (empty_hierarchy []))} + (empty_hierarchy [])) + (array.write! 0 (#Hierarchy (value@ #root row))) + (array.write! 1 (..path (value@ #level row) (value@ #tail row))))) + (revised@ #level level_up)) ... Otherwise, just push the current tail onto the root. (|> row - (update@ #root (..with_tail row_size (get@ #level row) (get@ #tail row))))) + (revised@ #root (..with_tail row_size (value@ #level row) (value@ #tail row))))) ... Finally, update the size of the row and grow a new ... tail with the new element as it's sole member. - (update@ #size inc) - (set@ #tail (..tail val))) + (revised@ #size ++) + (with@ #tail (..tail val))) ))) (exception: incorrect_row_structure) (exception: .public [a] (index_out_of_bounds {row (Row a)} {index Nat}) - (exception.report ["Size" (\ n.decimal encode (get@ #size row))] + (exception.report ["Size" (\ n.decimal encode (value@ #size row))] ["Index" (\ n.decimal encode index)])) (exception: base_was_not_found) @@ -244,15 +244,15 @@ (def: .public (within_bounds? row idx) {#.doc (example "Determines whether the index is within the bounds of the row.")} (All [a] (-> (Row a) Nat Bit)) - (n.< (get@ #size row) idx)) + (n.< (value@ #size row) idx)) (def: (base_for idx row) (All [a] (-> Index (Row a) (Try (Base a)))) (if (within_bounds? row idx) - (if (n.>= (tail_off (get@ #size row)) idx) - (#try.Success (get@ #tail row)) - (loop [level (get@ #level row) - hierarchy (get@ #root row)] + (if (n.>= (tail_off (value@ #size row)) idx) + (#try.Success (value@ #tail row)) + (loop [level (value@ #level row) + hierarchy (value@ #root row)] (case [(n.> branching_exponent level) (array.read! (branch_idx (i64.right_shifted level idx)) hierarchy)] [#1 (#.Some (#Hierarchy sub))] @@ -281,16 +281,16 @@ (def: .public (has idx val row) (All [a] (-> Nat a (Row a) (Try (Row a)))) - (let [row_size (get@ #size row)] + (let [row_size (value@ #size row)] (if (within_bounds? row idx) (#try.Success (if (n.>= (tail_off row_size) idx) - (update@ #tail (for {@.old - (: (-> (Base (:parameter 0)) (Base (:parameter 0))) - (|>> array.clone (array.write! (branch_idx idx) val)))} - (|>> array.clone (array.write! (branch_idx idx) val))) - row) - (update@ #root (has' (get@ #level row) idx val) - row))) + (revised@ #tail (for {@.old + (: (-> (Base (:parameter 0)) (Base (:parameter 0))) + (|>> array.clone (array.write! (branch_idx idx) val)))} + (|>> array.clone (array.write! (branch_idx idx) val))) + row) + (revised@ #root (has' (value@ #level row) idx val) + row))) (exception.except ..index_out_of_bounds [row idx])))) (def: .public (revised idx f row) @@ -299,9 +299,9 @@ [val (..item idx row)] (..has idx (f val) row))) -(def: .public (pop row) +(def: .public (prefix row) (All [a] (-> (Row a) (Row a))) - (case (get@ #size row) + (case (value@ #size row) 0 empty @@ -310,19 +310,19 @@ row_size (if (|> row_size (n.- (tail_off row_size)) (n.> 1)) - (let [old_tail (get@ #tail row) - new_tail_size (dec (array.size old_tail))] + (let [old_tail (value@ #tail row) + new_tail_size (-- (array.size old_tail))] (|> row - (update@ #size dec) - (set@ #tail (|> (array.empty new_tail_size) - (array.copy! new_tail_size 0 old_tail 0))))) + (revised@ #size --) + (with@ #tail (|> (array.empty new_tail_size) + (array.copy! new_tail_size 0 old_tail 0))))) (maybe.trusted (do maybe.monad [new_tail (base_for (n.- 2 row_size) row) - .let [[level' root'] (let [init_level (get@ #level row)] + .let [[level' root'] (let [init_level (value@ #level row)] (loop [level init_level root (maybe.else (empty_hierarchy []) - (without_tail row_size init_level (get@ #root row)))] + (without_tail row_size init_level (value@ #root row)))] (if (n.> branching_exponent level) (case [(array.read! 1 root) (array.read! 0 root)] [#.None (#.Some (#Hierarchy sub_node))] @@ -335,20 +335,20 @@ [level root]) [level root])))]] (in (|> row - (update@ #size dec) - (set@ #level level') - (set@ #root root') - (set@ #tail new_tail)))))) + (revised@ #size --) + (with@ #level level') + (with@ #root root') + (with@ #tail new_tail)))))) )) (def: .public (list row) (All [a] (-> (Row a) (List a))) - (list\compose (list' (#Hierarchy (get@ #root row))) - (list' (#Base (get@ #tail row))))) + (list\compose (list' (#Hierarchy (value@ #root row))) + (list' (#Base (value@ #tail row))))) (def: .public of_list (All [a] (-> (List a) (Row a))) - (list\fold ..add ..empty)) + (list\fold ..suffix ..empty)) (def: .public (member? a/Equivalence row val) (All [a] (-> (Equivalence a) (Row a) a Bit)) @@ -356,9 +356,9 @@ (def: .public empty? (All [a] (-> (Row a) Bit)) - (|>> (get@ #size) (n.= 0))) + (|>> (value@ #size) (n.= 0))) -(syntax: .public (row [elems (p.some s.any)]) +(syntax: .public (row [elems (<>.some <code>.any)]) {#.doc (example "Row literals." (row 12 34 56 78 90))} (in (.list (` (..of_list (.list (~+ elems))))))) @@ -381,12 +381,12 @@ (All [a] (-> (Equivalence a) (Equivalence (Row a)))) (def: (= v1 v2) - (and (n.= (get@ #size v1) (get@ #size v2)) + (and (n.= (value@ #size v1) (value@ #size v2)) (let [(^open "node\.") (node_equivalence Equivalence<a>)] - (and (node\= (#Base (get@ #tail v1)) - (#Base (get@ #tail v2))) - (node\= (#Hierarchy (get@ #root v1)) - (#Hierarchy (get@ #root v2)))))))) + (and (node\= (#Base (value@ #tail v1)) + (#Base (value@ #tail v2))) + (node\= (#Hierarchy (value@ #root v1)) + (#Hierarchy (value@ #root v2)))))))) (implementation: node_fold (Fold Node) @@ -409,8 +409,8 @@ (fold f (fold f init - (#Hierarchy (get@ #root xs))) - (#Base (get@ #tail xs)))))) + (#Hierarchy (value@ #root xs))) + (#Base (value@ #tail xs)))))) (implementation: .public monoid (All [a] (Monoid (Row a))) @@ -418,7 +418,7 @@ (def: identity ..empty) (def: (compose xs ys) - (list\fold add xs (..list ys)))) + (list\fold suffix xs (..list ys)))) (implementation: node_functor (Functor Node) @@ -435,10 +435,10 @@ (Functor Row) (def: (map f xs) - {#level (get@ #level xs) - #size (get@ #size xs) - #root (|> xs (get@ #root) (array\map (\ node_functor map f))) - #tail (|> xs (get@ #tail) (array\map f))})) + {#level (value@ #level xs) + #size (value@ #size xs) + #root (|> xs (value@ #root) (array\map (\ node_functor map f))) + #tail (|> xs (value@ #tail) (array\map f))})) (implementation: .public apply (Apply Row) @@ -469,7 +469,7 @@ (All [a] (-> (Row a) (Row a))) (|>> ..list list.reversed - (list\fold add ..empty))) + (list\fold suffix ..empty))) (template [<name> <array> <init> <op>] [(def: .public <name> diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index a7d2cc0b4..42cd682df 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -65,7 +65,7 @@ (let [[head tail] (//.result sequence)] (case idx 0 head - _ (item (dec idx) tail)))) + _ (item (-- idx) tail)))) (template [<taker> <dropper> <pred_type> <pred_test> <pred_step> <post_test>] [(def: .public (<taker> pred xs) @@ -85,7 +85,7 @@ xs)))] [while until (-> a Bit) (pred x) pred |>] - [first after Nat (n.= 0 pred) (dec pred) not] + [first after Nat (n.= 0 pred) (-- pred) not] ) (template [<splitter> <pred_type> <pred_test> <pred_step>] @@ -99,7 +99,7 @@ [(#.Item [x tail]) next]))))] [split_when (-> a Bit) (pred x) pred] - [split_at Nat (n.= 0 pred) (dec pred)] + [split_at Nat (n.= 0 pred) (-- pred)] ) (def: .public (only predicate sequence) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index 6ef570c31..28bbf1876 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -60,13 +60,13 @@ (All [a] (-> (Set a) (Set a) (Set a))) (|> (..list right) (list.only (..member? left)) - (..of_list (get@ #/.&order (:representation right))))) + (..of_list (value@ #/.&order (:representation right))))) (def: .public (difference param subject) (All [a] (-> (Set a) (Set a) (Set a))) (|> (..list subject) (list.only (|>> (..member? param) not)) - (..of_list (get@ #/.&order (:representation subject))))) + (..of_list (value@ #/.&order (:representation subject))))) (implementation: .public equivalence (All [a] (Equivalence (Set a))) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 451fc6143..112932a50 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -25,10 +25,10 @@ {#.doc (example "All the leaf values of the tree, in order.")} (All [a] (-> (Tree a) (List a))) (|> tree - (get@ #children) + (value@ #children) (list\map flat) list\join - (#.Item (get@ #value tree)))) + (#.Item (value@ #value tree)))) (def: .public (leaf value) (All [a] (-> a (Tree a))) @@ -69,22 +69,22 @@ (All [a] (-> (Equivalence a) (Equivalence (Tree a)))) (def: (= tx ty) - (and (\ super = (get@ #value tx) (get@ #value ty)) - (\ (list.equivalence (equivalence super)) = (get@ #children tx) (get@ #children ty))))) + (and (\ super = (value@ #value tx) (value@ #value ty)) + (\ (list.equivalence (equivalence super)) = (value@ #children tx) (value@ #children ty))))) (implementation: .public functor (Functor Tree) (def: (map f fa) - {#value (f (get@ #value fa)) + {#value (f (value@ #value fa)) #children (list\map (map f) - (get@ #children fa))})) + (value@ #children fa))})) (implementation: .public fold (Fold Tree) (def: (fold f init tree) (list\fold (function (_ tree' init') (fold f init' tree')) - (f (get@ #value tree) + (f (value@ #value tree) init) - (get@ #children tree)))) + (value@ #children tree)))) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 9c2844be7..588cb4e5a 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -33,7 +33,7 @@ (template [<name> <tag> <output>] [(def: .public <name> (All [@ t v] (-> (Tree @ t v) <output>)) - (|>> :representation (get@ <tag>)))] + (|>> :representation (value@ <tag>)))] [tag #tag t] [root #root (Either v [(Tree @ t v) (Tree @ t v)])] @@ -57,7 +57,7 @@ (def: .public (value tree) (All [@ t v] (-> (Tree @ t v) v)) - (case (get@ #root (:representation tree)) + (case (value@ #root (:representation tree)) (0 #0 value) value @@ -66,9 +66,9 @@ (def: .public (tags tree) (All [@ t v] (-> (Tree @ t v) (List t))) - (case (get@ #root (:representation tree)) + (case (value@ #root (:representation tree)) (0 #0 value) - (list (get@ #tag (:representation tree))) + (list (value@ #tag (:representation tree))) (0 #1 [left right]) (list\compose (tags left) @@ -76,7 +76,7 @@ (def: .public (values tree) (All [@ t v] (-> (Tree @ t v) (List v))) - (case (get@ #root (:representation tree)) + (case (value@ #root (:representation tree)) (0 #0 value) (list value) @@ -99,8 +99,8 @@ (0 #1 [left right]) (let [shifted_tag (tag//compose _tag (..tag left))] (if (predicate shifted_tag) - (recur _tag (get@ #root (:representation left))) - (recur shifted_tag (get@ #root (:representation right)))))))) + (recur _tag (value@ #root (:representation left))) + (recur shifted_tag (value@ #root (:representation right)))))))) #.None))) ) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index b6fb27355..6d1709c55 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -50,23 +50,23 @@ (def: .public tree (All [a] (-> (Zipper a) (Tree a))) - (get@ #node)) + (value@ #node)) (def: .public value (All [a] (-> (Zipper a) a)) - (get@ [#node #//.value])) + (value@ [#node #//.value])) (def: .public (set value zipper) (All [a] (-> a (Zipper a) (Zipper a))) - (set@ [#node #//.value] value zipper)) + (with@ [#node #//.value] value zipper)) (def: .public (update transform zipper) (All [a] (-> (-> a a) (Zipper a) (Zipper a))) - (update@ [#node #//.value] transform zipper)) + (revised@ [#node #//.value] transform zipper)) (def: children (All [a] (-> (Zipper a) (List (Tree a)))) - (get@ [#node #//.children])) + (value@ [#node #//.children])) (def: .public leaf? (All [a] (-> (Zipper a) Bit)) @@ -78,7 +78,7 @@ (def: .public (start? zipper) (All [a] (-> (Zipper a) Bit)) - (case (get@ #family zipper) + (case (value@ #family zipper) #.None true @@ -92,7 +92,7 @@ #.None (#.Item head tail) - (#.Some {#family (#.Some {#parent (set@ [#node #//.children] (list) zipper) + (#.Some {#family (#.Some {#parent (with@ [#node #//.children] (list) zipper) #lefts #.End #rights tail}) #node head}))) @@ -100,37 +100,37 @@ (def: .public (up zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad - [family (get@ #family zipper)] + [family (value@ #family zipper)] (in (let [(^slots [#parent #lefts #rights]) family] (for {@.old - (update@ #node (: (-> (Tree (:parameter 0)) - (Tree (:parameter 0))) - (set@ #//.children (list\compose (list.reversed lefts) - (#.Item (get@ #node zipper) - rights)))) - parent)} - (set@ [#node #//.children] - (list\compose (list.reversed lefts) - (#.Item (get@ #node zipper) - rights)) - parent)))))) + (revised@ #node (: (-> (Tree (:parameter 0)) + (Tree (:parameter 0))) + (with@ #//.children (list\compose (list.reversed lefts) + (#.Item (value@ #node zipper) + rights)))) + parent)} + (with@ [#node #//.children] + (list\compose (list.reversed lefts) + (#.Item (value@ #node zipper) + rights)) + parent)))))) (template [<one> <all> <side> <op_side>] [(def: .public (<one> zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) - (case (get@ #family zipper) + (case (value@ #family zipper) (#.Some family) - (case (get@ <side> family) + (case (value@ <side> family) (#.Item next side') (#.Some (for {@.old {#family (#.Some (|> family - (set@ <side> side') - (update@ <op_side> (|>> (#.Item (get@ #node zipper)))))) + (with@ <side> side') + (revised@ <op_side> (|>> (#.Item (value@ #node zipper)))))) #node next}} (let [move (: (All [a] (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ side' zipper) - (|>> (set@ <side> side') - (update@ <op_side> (|>> (#.Item (get@ #node zipper)))))))] + (|>> (with@ <side> side') + (revised@ <op_side> (|>> (#.Item (value@ #node zipper)))))))] {#family (#.Some (move side' zipper family)) #node next}))) @@ -142,26 +142,26 @@ (def: .public (<all> zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) - (case (get@ #family zipper) + (case (value@ #family zipper) #.None #.None (#.Some family) - (case (list.reversed (get@ <side> family)) + (case (list.reversed (value@ <side> family)) #.End #.None (#.Item last prevs) (#.Some (for {@.old {#family (#.Some (|> family - (set@ <side> #.End) - (update@ <op_side> (|>> (#.Item (get@ #node zipper)) - (list\compose prevs))))) + (with@ <side> #.End) + (revised@ <op_side> (|>> (#.Item (value@ #node zipper)) + (list\compose prevs))))) #node last}} (let [move (: (All [a] (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) - (|>> (set@ <side> #.End) - (update@ <op_side> (|>> (#.Item (get@ #node zipper)) - (list\compose prevs))))))] + (|>> (with@ <side> #.End) + (revised@ <op_side> (|>> (#.Item (value@ #node zipper)) + (list\compose prevs))))))] {#family (#.Some (move prevs zipper family)) #node last}))))))] @@ -245,44 +245,44 @@ (def: .public (interpose value zipper) (All [a] (-> a (Zipper a) (Zipper a))) - (update@ [#node #//.children] - (|>> (//.branch value) list) - zipper)) + (revised@ [#node #//.children] + (|>> (//.branch value) list) + zipper)) (def: .public (adopt value zipper) (All [a] (-> a (Zipper a) (Zipper a))) - (update@ [#node #//.children] - (|>> (#.Item (//.leaf value))) - zipper)) + (revised@ [#node #//.children] + (|>> (#.Item (//.leaf value))) + zipper)) (def: .public (remove zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad - [family (get@ #family zipper)] - (case (get@ #lefts family) + [family (value@ #family zipper)] + (case (value@ #lefts family) #.End - (in (set@ [#node #//.children] - (get@ #rights family) - (get@ #parent family))) + (in (with@ [#node #//.children] + (value@ #rights family) + (value@ #parent family))) (#.Item next side) (in (|> zipper - (set@ #family (|> family - (set@ #lefts side) - #.Some)) - (set@ #node next)))))) + (with@ #family (|> family + (with@ #lefts side) + #.Some)) + (with@ #node next)))))) (template [<name> <side>] [(def: .public (<name> value zipper) (All [a] (-> a (Zipper a) (Maybe (Zipper a)))) - (case (get@ #family zipper) + (case (value@ #family zipper) #.None #.None (#.Some family) - (#.Some (set@ #family - (#.Some (update@ <side> (|>> (#.Item (//.leaf value))) family)) - zipper))))] + (#.Some (with@ #family + (#.Some (revised@ <side> (|>> (#.Item (//.leaf value))) family)) + zipper))))] [insert_left #lefts] [insert_right #rights] @@ -304,14 +304,14 @@ (def: &functor ..functor) - (def: out (get@ [#node #//.value])) + (def: out (value@ [#node #//.value])) (def: (split (^slots [#family #node])) (let [tree_splitter (: (All [a] (-> (Tree a) (Tree (Zipper a)))) (function (tree_splitter tree) {#//.value (..zipper tree) #//.children (|> tree - (get@ #//.children) + (value@ #//.children) (list\map tree_splitter))}))] {#family (maybe\map (function (_ (^slots [#parent #lefts #rights])) {#parent (split parent) diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index 19cdb0b66..1cebc0408 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -28,7 +28,7 @@ abstract]]]) (def: rgb_limit 256) -(def: top (dec rgb_limit)) +(def: top (-- rgb_limit)) (def: rgb_factor (|> top .int int.frac)) @@ -420,7 +420,7 @@ (let [[hue saturation brightness] (hsb color) spread (..normal spread)] (list\map (function (_ idx) - (of_hsb [(|> idx inc .int int.frac (f.* spread) (f.+ hue) ..normal) + (of_hsb [(|> idx ++ .int int.frac (f.* spread) (f.+ hue) ..normal) saturation brightness])) (list.indices variations))))) @@ -431,7 +431,7 @@ (let [[hue saturation brightness] (hsb color) spread (..normal spread)] (|> (list.indices variations) - (list\map (|>> inc .int int.frac + (list\map (|>> ++ .int int.frac (f.* spread) (f.+ brightness) ..normal diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index e23ade3fb..7a6ccadba 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -93,12 +93,12 @@ (^template [<number> <tag> <writer>] [(<tag> caseV) (let [[caseS caseT] (<writer> caseV)] - [(.inc caseS) + [(.++ caseS) (function (_ [offset binary]) (|> binary (binary.write/8! offset <number>) try.trusted - [(.inc offset)] + [(.++ offset)] caseT))])]) ([0 #.Left left] [1 #.Right right]) @@ -243,12 +243,12 @@ (^template [<number> <tag> <writer>] [(<tag> caseV) (let [[caseS caseT] (<writer> caseV)] - [(.inc caseS) + [(.++ caseS) (function (_ [offset binary]) (|> binary (binary.write/8! offset <number>) try.trusted - [(.inc offset)] + [(.++ offset)] caseT))])]) ([0 #.Primitive (..and ..text (..list recur))] [1 #.Sum pair] @@ -278,12 +278,12 @@ (^template [<number> <tag> <writer>] [(<tag> caseV) (let [[caseS caseT] (<writer> caseV)] - [(.inc caseS) + [(.++ caseS) (function (_ [offset binary]) (|> binary (binary.write/8! offset <number>) try.trusted - [(.inc offset)] + [(.++ offset)] caseT))])]) ([0 #.Bit ..bit] [1 #.Nat ..nat] diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index 7ec9a0d35..8b3a9270c 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -51,19 +51,19 @@ (def: .public (font font) (-> Font (CSS Special)) - (let [with_unicode (case (get@ #/font.unicode_range font) + (let [with_unicode (case (value@ #/font.unicode_range font) (#.Some unicode_range) - (let [unicode_range' (format "U+" (\ nat.hex encode (get@ #/font.start unicode_range)) - "-" (\ nat.hex encode (get@ #/font.end unicode_range)))] + (let [unicode_range' (format "U+" (\ nat.hex encode (value@ #/font.start unicode_range)) + "-" (\ nat.hex encode (value@ #/font.end unicode_range)))] (list ["unicode-range" unicode_range'])) #.None (list))] - (|> (list& ["font-family" (get@ #/font.family font)] - ["src" (format "url(" (get@ #/font.source font) ")")] - ["font-stretch" (|> font (get@ #/font.stretch) (maybe.else /value.normal_stretch) /value.value)] - ["font-style" (|> font (get@ #/font.style) (maybe.else /value.normal_style) /value.value)] - ["font-weight" (|> font (get@ #/font.weight) (maybe.else /value.normal_weight) /value.value)] + (|> (list& ["font-family" (value@ #/font.family font)] + ["src" (format "url(" (value@ #/font.source font) ")")] + ["font-stretch" (|> font (value@ #/font.stretch) (maybe.else /value.normal_stretch) /value.value)] + ["font-style" (|> font (value@ #/font.style) (maybe.else /value.normal_style) /value.value)] + ["font-weight" (|> font (value@ #/font.weight) (maybe.else /value.normal_weight) /value.value)] with_unicode) (list\map (function (_ [property value]) (format property ": " value ";"))) @@ -95,8 +95,8 @@ (:abstraction (format "@keyframes " (/value.value animation) " {" (|> frames (list\map (function (_ frame) - (format (/value.percentage (get@ #when frame)) " {" - (/style.inline (get@ #what frame)) + (format (/value.percentage (value@ #when frame)) " {" + (/style.inline (value@ #what frame)) "}"))) (text.interposed ..css_separator)) "}"))) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index 0c8e8f70f..54de6d97a 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -988,7 +988,7 @@ (-> Percentage Text) (|>> :representation)) - (def: percentage_limit Nat (.inc 100)) + (def: percentage_limit Nat (.++ 100)) (def: .public (%% value) (-> Nat Percentage) @@ -1131,7 +1131,7 @@ (def: .public (clip rectangle) (-> Rectangle (Value Clip)) (`` (..apply "rect" (list (~~ (template [<side>] - [(:representation (get@ <side> rectangle))] + [(:representation (value@ <side> rectangle))] [#top] [#right] [#bottom] [#left])))))) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index 7f1346df1..c26a7a751 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -44,7 +44,7 @@ max_size) padding (|> "0" (list.repeated padding_size) - text.joined)] + text.together)] (format padding number))) (def: blank " ") @@ -61,12 +61,12 @@ (|> ..octal_size (list.repeated <size>) (list\fold n.* 1) - inc)) + ++)) (exception: .public (<exception> {value Nat}) (exception.report ["Value" (%.nat value)] - ["Maximum" (%.nat (dec <limit>))])) + ["Maximum" (%.nat (-- <limit>))])) (abstract: .public <type> {} @@ -171,7 +171,7 @@ (def: checksum (-> Binary Nat) - (binary.fold n.+ 0)) + (binary.aggregate n.+ 0)) (def: checksum_checksum (|> ..dummy_checksum @@ -216,10 +216,10 @@ (def: ascii? (-> Text Bit) (|>> (\ utf8.codec encode) - (binary.fold (function (_ char verdict) - (.and verdict - (n.<= ..last_ascii char))) - true))) + (binary.aggregate (function (_ char verdict) + (.and verdict + (n.<= ..last_ascii char))) + true))) (exception: .public (not_ascii {text Text}) (exception.report @@ -232,17 +232,17 @@ (-> Binary (Try Binary)) (case (binary.size string) 0 (#try.Success string) - size (loop [end (dec size)] + size (loop [end (-- size)] (case end 0 (#try.Success (\ utf8.codec encode "")) _ (do try.monad [last_char (binary.read/8! end string)] (`` (case (.nat last_char) (^ (char (~~ (static ..null)))) - (recur (dec end)) + (recur (-- end)) _ - (binary.slice 0 (inc end) string)))))))) + (binary.slice 0 (++ end) string)))))))) (template [<type> <representation> <size> <exception> <in> <out> <writer> <parser> <none>] [(abstract: .public <type> @@ -640,11 +640,11 @@ (def: (header_writer header) (Writer Header) (let [checksum (|> header - (set@ #checksum ..dummy_checksum) + (with@ #checksum ..dummy_checksum) (format.result ..header_writer') ..checksum_code)] (|> header - (set@ #checksum checksum) + (with@ #checksum checksum) (format.result ..header_writer') (format.segment ..block_size)))) @@ -664,16 +664,16 @@ (format.segment (..rounded_content_size size)))] (writer [{#path path #mode mode - #user_id (get@ [#user #id] ownership) - #group_id (get@ [#group #id] ownership) + #user_id (value@ [#user #id] ownership) + #group_id (value@ [#group #id] ownership) #size size #modification_time (..modification_time modification_time) #checksum ..dummy_checksum #link_flag link_flag #link_name ..no_path #magic ..ustar - #user_name (get@ [#user #name] ownership) - #group_name (get@ [#group #name] ownership) + #user_name (value@ [#user #name] ownership) + #group_name (value@ [#group #name] ownership) #major_device ..no_device #minor_device ..no_device} content])))) @@ -812,26 +812,26 @@ (-> Link_Flag (Parser File)) (do <>.monad [header ..header_parser - _ (<>.assertion (exception.error ..wrong_link_flag [expected (get@ #link_flag header)]) - (same? expected (get@ #link_flag header))) - .let [size (get@ #size header) + _ (<>.assertion (exception.error ..wrong_link_flag [expected (value@ #link_flag header)]) + (same? expected (value@ #link_flag header))) + .let [size (value@ #size header) rounded_size (..rounded_content_size size)] content (<binary>.segment (..from_big size)) content (<>.lifted (..content content)) _ (<binary>.segment (n.- (..from_big size) rounded_size))] - (in [(get@ #path header) + (in [(value@ #path header) (|> header - (get@ #modification_time) + (value@ #modification_time) ..from_big .int duration.of_millis (duration.up (|> duration.second duration.millis .nat)) instant.absolute) - (get@ #mode header) - {#user {#name (get@ #user_name header) - #id (get@ #user_id header)} - #group {#name (get@ #group_name header) - #id (get@ #group_id header)}} + (value@ #mode header) + {#user {#name (value@ #user_name header) + #id (value@ #user_id header)} + #group {#name (value@ #group_name header) + #id (value@ #group_id header)}} content]))) (def: (file_name_parser expected extractor) @@ -839,9 +839,9 @@ (do <>.monad [header ..header_parser _ (<>.lifted - (exception.assertion ..wrong_link_flag [expected (get@ #link_flag header)] + (exception.assertion ..wrong_link_flag [expected (value@ #link_flag header)] (n.= (..link_flag expected) - (..link_flag (get@ #link_flag header)))))] + (..link_flag (value@ #link_flag header)))))] (in (extractor header)))) (def: entry_parser @@ -851,9 +851,9 @@ (<>.either (..file_parser ..normal) (..file_parser ..old_normal))) (\ <>.monad map (|>> #..Symbolic_Link) - (..file_name_parser ..symbolic_link (get@ #link_name))) + (..file_name_parser ..symbolic_link (value@ #link_name))) (\ <>.monad map (|>> #..Directory) - (..file_name_parser ..directory (get@ #path))) + (..file_name_parser ..directory (value@ #path))) (\ <>.monad map (|>> #..Contiguous) (..file_parser ..contiguous)))) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 67722607c..b596734ea 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -269,7 +269,7 @@ ($_ text\compose prefix "<" tag attrs ">" (|> xml_children (list\map (|>> (recur (text\compose prefix text.tab)) (text\compose text.new_line))) - text.joined) + text.together) text.new_line prefix "</" tag ">"))))) )))) (def: decode diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index 4173f8133..aba9488bc 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -41,7 +41,7 @@ (let [[x y] xy] [y x])) -(def: .public (apply f g) +(def: .public (then f g) {#.doc (example "Apply functions to both sides of a pair.")} (All [a b c d] (-> (-> a c) (-> b d) @@ -49,7 +49,7 @@ (function (_ [x y]) [(f x) (g y)])) -(def: .public (fork f g) +(def: .public (forked f g) {#.doc (example "Yields a pair by applying both functions to a single value.")} (All [a l r] (-> (-> a l) (-> a r) diff --git a/stdlib/source/library/lux/data/store.lux b/stdlib/source/library/lux/data/store.lux index ba795f4d1..a25331cd4 100644 --- a/stdlib/source/library/lux/data/store.lux +++ b/stdlib/source/library/lux/data/store.lux @@ -13,8 +13,8 @@ (def: (extend f wa) (All [s a b] (-> (-> (Store s a) b) (Store s a) (Store s b))) - {#cursor (get@ #cursor wa) - #peek (function (_ s) (f (set@ #cursor s wa)))}) + {#cursor (value@ #cursor wa) + #peek (function (_ s) (f (with@ #cursor s wa)))}) (implementation: .public functor (All [s] (Functor (Store s))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 84b19ffc3..f14efa463 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -28,7 +28,7 @@ (0 #0 l) (fl l) (0 #1 r) (fr r)))) -(def: .public (apply fl fr) +(def: .public (then fl fr) {#.doc (example "Applies functions to both sides of a 2-variant.")} (All [l l' r r'] (-> (-> l l') (-> r r') diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 2670bdae3..baeade224 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -78,7 +78,7 @@ output (#.Some from') - (recur (inc from') output'))))) + (recur (++ from') output'))))) (def: .public (last_index_of part text) (-> Text Text (Maybe Nat)) @@ -284,14 +284,14 @@ (loop [index 0 hash 0] (if (n.< length index) - (recur (inc index) + (recur (++ index) (|> hash (i64.left_shifted 5) (n.- hash) (n.+ ("lux text char" index input)))) hash)))))) -(def: .public joined +(def: .public together (-> (List Text) Text) (let [(^open ".") ..monoid] (|>> list.reversed @@ -300,8 +300,8 @@ (def: .public (interposed separator texts) (-> Text (List Text) Text) (case separator - "" (..joined texts) - _ (|> texts (list.interposed separator) ..joined))) + "" (..together texts) + _ (|> texts (list.interposed separator) ..together))) (def: .public (empty? text) (-> Text Bit) diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux index 2d8708c58..196227220 100644 --- a/stdlib/source/library/lux/data/text/buffer.lux +++ b/stdlib/source/library/lux/data/text/buffer.lux @@ -67,37 +67,37 @@ ... default row.empty)))) - (def: .public (append chunk buffer) + (def: .public (then chunk buffer) (-> Text Buffer Buffer) (with_expansions [<jvm> (let [[capacity transform] (:representation buffer) - append! (: (-> Text java/lang/StringBuilder java/lang/StringBuilder) - (function (_ chunk builder) - (exec - (java/lang/Appendable::append (:as java/lang/CharSequence chunk) - builder) - builder)))] + then! (: (-> Text java/lang/StringBuilder java/lang/StringBuilder) + (function (_ chunk builder) + (exec + (java/lang/Appendable::append (:as java/lang/CharSequence chunk) + builder) + builder)))] (:abstraction [(n.+ (//.size chunk) capacity) - (|>> transform (append! chunk))]))] + (|>> transform (then! chunk))]))] (for {@.old <jvm> @.jvm <jvm> @.js (let [[capacity transform] (:representation buffer) - append! (: (-> (JS_Array Text) (JS_Array Text)) - (function (_ array) - (exec - (JS_Array::push [chunk] array) - array)))] + then! (: (-> (JS_Array Text) (JS_Array Text)) + (function (_ array) + (exec + (JS_Array::push [chunk] array) + array)))] (:abstraction [(n.+ (//.size chunk) capacity) - (|>> transform append!)])) + (|>> transform then!)])) @.lua (let [[capacity transform] (:representation buffer) - append! (: (-> (array.Array Text) (array.Array Text)) - (function (_ array) - (exec - (table/insert [array chunk]) - array)))] + then! (: (-> (array.Array Text) (array.Array Text)) + (function (_ array) + (exec + (table/insert [array chunk]) + array)))] (:abstraction [(n.+ (//.size chunk) capacity) - (|>> transform append!)]))} + (|>> transform then!)]))} ... default - (|> buffer :representation (row.add chunk) :abstraction)))) + (|> buffer :representation (row.suffix chunk) :abstraction)))) (def: .public size (-> Buffer Nat) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index f46331176..89205cbff 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -84,7 +84,7 @@ (def: (ascii_escaped replacement pre_offset pre_limit previous current) (-> Text Nat Nat Text Text [Text Text Nat]) - (let [post_offset (inc pre_offset) + (let [post_offset (++ pre_offset) post_limit (n.- post_offset pre_limit)] [(format previous ("lux text clip" 0 pre_offset current) @@ -101,7 +101,7 @@ 2 (format "00" code) 3 (format "0" code) _ code)) - post_offset (inc pre_offset) + post_offset (++ pre_offset) post_limit (n.- post_offset pre_limit)] [(format previous ("lux text clip" 0 pre_offset current) @@ -138,13 +138,13 @@ (n.> ..ascii_top char)) (let [[previous' current' limit'] (unicode_escaped char offset limit previous current)] (recur 0 previous' current' limit')) - (recur (inc offset) previous current limit))) + (recur (++ offset) previous current limit))) (format previous current)))) (exception: .public (dangling_escape {text Text}) (exception.report ["In" (%.text text)] - ["At" (%.nat (dec (//.size text)))])) + ["At" (%.nat (-- (//.size text)))])) (exception: .public (invalid_escape {text Text} {offset Nat} {sigil Char}) (exception.report @@ -202,7 +202,7 @@ (if (n.< limit offset) (case ("lux text char" offset current) (^ (static ..sigil_char)) - (let [@sigil (inc offset)] + (let [@sigil (++ offset)] (if (n.< limit @sigil) (case ("lux text char" @sigil current) (^template [<sigil> <un_escaped>] @@ -233,7 +233,7 @@ (exception.except ..dangling_escape [text]))) _ - (recur (inc offset) previous current limit)) + (recur (++ offset) previous current limit)) (#try.Success (case previous "" current _ (format previous current)))))) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index 1a274b692..894dd8321 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -121,7 +121,7 @@ (def: .public (list formatter) (All [a] (-> (Format a) (Format (List a)))) (|>> (list\map (|>> formatter (format " "))) - text.joined + text.together (text.enclosed ["(list" ")"]))) (def: .public (maybe format) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 4998e9ce9..3b26dac8e 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -54,7 +54,7 @@ (def: join_text^ (-> (Parser (List Text)) (Parser Text)) - (\ <>.monad map //.joined)) + (\ <>.monad map //.together)) (def: name_char^ (Parser Text) @@ -300,7 +300,7 @@ [idx (code.identifier ["" _name])] #.None - [(inc idx) (code.identifier ["" (n\encode idx)])]) + [(++ idx) (code.identifier ["" (n\encode idx)])]) access (if (n.> 0 num_captures) (` ((~! product.left) (~ name!))) name!)] diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index deb289a22..95931ff4a 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -48,7 +48,7 @@ (template [<name> <slot>] [(def: .public <name> (-> Block Char) - (|>> :representation (get@ <slot>)))] + (|>> :representation (value@ <slot>)))] [start #interval.bottom] [end #interval.top] @@ -56,9 +56,9 @@ (def: .public (size block) (-> Block Nat) - (let [start (get@ #interval.bottom (:representation block)) - end (get@ #interval.top (:representation block))] - (|> end (n.- start) inc))) + (let [start (value@ #interval.bottom (:representation block)) + end (value@ #interval.top (:representation block))] + (|> end (n.- start) ++))) (def: .public (within? block char) (All [a] (-> Block Char Bit)) diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index 8917fc89a..4b5da0b54 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -13,22 +13,22 @@ (implementation: .public functor (All [t] (Functor (Trace t))) (def: (map f fa) - (update@ #trace (compose f) fa))) + (revised@ #trace (compose f) fa))) (implementation: .public comonad (All [t] (CoMonad (Trace t))) (def: &functor ..functor) (def: (out wa) - ((get@ #trace wa) - (get@ [#monoid #monoid.identity] wa))) + ((value@ #trace wa) + (value@ [#monoid #monoid.identity] wa))) (def: (split wa) - (let [monoid (get@ #monoid wa)] + (let [monoid (value@ #monoid wa)] {#monoid monoid #trace (function (_ t1) {#monoid monoid #trace (function (_ t2) - ((get@ #trace wa) + ((value@ #trace wa) (\ monoid compose t1 t2)))})}))) (def: .public (result context tracer) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 8183fb6ff..7a5a9a153 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -126,7 +126,7 @@ (let [member ("lua array read" idx tuple)] (if ("lua object nil?" member) #.End - (#.Item member (recur (inc idx))))))))} + (#.Item member (recur (++ idx))))))))} (as_is)) (def: (tuple_inspection inspection) @@ -461,7 +461,7 @@ [lefts #1 (rightR right)] _ - (recur (inc lefts) (#.Item rightR extraR+) right))) + (recur (++ lefts) (#.Item rightR extraR+) right))) _ (undefined)))] @@ -601,7 +601,7 @@ [location meta.location locals meta.locals .let [environment (|> locals - list.joined + list.together ... The list is reversed to make sure that, when building the dictionary, ... later bindings overshadow earlier ones if they have the same name. list.reversed diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 8651dbdcc..37147b2f0 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -2,6 +2,7 @@ [library [lux (#- Definition Module example type) ["." meta] + ["." type ("#\." equivalence)] [abstract [monad (#+ do)]] [control @@ -18,7 +19,7 @@ ["." set (#+ Set)]] [format ["md" markdown (#+ Markdown Block)]]] - [macro + ["." macro [syntax (#+ syntax:)] ["." code] ["." template]] @@ -74,13 +75,13 @@ (if (n.= old_line new_line) (if (n.< old_column new_column) "" - (text.joined (list.repeated (n.- old_column new_column) " "))) + (text.together (list.repeated (n.- old_column new_column) " "))) (format (if (n.< old_line new_line) "" - (text.joined (list.repeated (n.- old_line new_line) \n))) + (text.together (list.repeated (n.- old_line new_line) \n))) (if (n.< reference_column new_column) "" - (text.joined (list.repeated (n.- reference_column new_column) " ")))))) + (text.together (list.repeated (n.- reference_column new_column) " ")))))) (def: un_paired (All [a] (-> (List [a a]) (List a))) @@ -96,7 +97,7 @@ (^template [<tag> <format>] [[new_location (<tag> value)] (let [documentation (`` (|> value (~~ (template.spliced <format>))))] - [(update@ #.column (n.+ (text.size documentation)) new_location) + [(revised@ #.column (n.+ (text.size documentation)) new_location) (format (padding reference_column old_location new_location) documentation)])]) ([#.Bit [%.bit]] @@ -113,9 +114,9 @@ (let [[group_location' members_documentation] (list\fold (function (_ part [last_location text_accum]) (let [[member_location member_documentation] (code_documentation last_location reference_column part)] [member_location (format text_accum member_documentation)])) - [(update@ #.column inc group_location) ""] + [(revised@ #.column ++ group_location) ""] (<prep> members))] - [(update@ #.column inc group_location') + [(revised@ #.column ++ group_location') (format (padding reference_column old_location group_location) |<| members_documentation |>|)])]) ([syntax.open_form syntax.close_form #.Form |>] @@ -141,7 +142,7 @@ (let [reference_column (..reference_column example) [location _] example] (|> example - (..code_documentation (set@ #.column reference_column location) reference_column) + (..code_documentation (with@ #.column reference_column location) reference_column) product.right)))) (def: type @@ -194,16 +195,26 @@ (syntax: (minimal_definition_documentation [name ..qualified_identifier]) (with_expansions [<\n> (~! text.\n)] - (in (list (` ($_ ((~! md.then)) - ... Name - (<| ((~! md.heading/3)) - (~ (code.text (|> name product.right [""] %.name)))) - ... Type - (<| ((~! md.code)) - ((~! ..type) ("lux in-module" - (~ (code.text (product.left name))) - (.:of (~ (code.identifier name))))))) - ))))) + (macro.with_identifiers [g!type] + (in (list (` ($_ ((~! md.then)) + ... Name + (<| ((~! md.heading/3)) + (~ (code.text (|> name product.right [""] %.name)))) + ... Type + (let [(~ g!type) ("lux in-module" + (~ (code.text (product.left name))) + (.:of (~ (code.identifier name))))] + ((~! md.code) + (if ((~! type\=) .Type (~ g!type)) + (|> (~ (code.identifier name)) + (:as .Type) + ((~! type.anonymous)) + ((~! ..type)) + ((~! %.format) + ((~! ..single_line_comment) ((~! ..type) (~ g!type))) + <\n>)) + ((~! ..type) (~ g!type)))))) + )))))) (syntax: (definition_documentation [name ..qualified_identifier @@ -265,9 +276,9 @@ (def: definitions_documentation (-> (List Definition) (Markdown Block)) (|>> (list.sorted (function (_ left right) - (text\< (get@ #definition right) - (get@ #definition left)))) - (list\map (get@ #documentation)) + (text\< (value@ #definition right) + (value@ #definition left)))) + (list\map (value@ #documentation)) (list\fold md.then md.empty))) (def: expected_separator @@ -326,23 +337,25 @@ (let [(^slots [#expected]) module] ($_ md.then ... Name - (md.heading/1 (get@ #module module)) + (md.heading/1 (value@ #module module)) ... Description - (<| md.paragraph - md.text - (get@ #description module)) + (case (value@ #description module) + "" md.empty + description (<| md.paragraph + md.text + description)) ... Definitions (md.heading/2 "Definitions") (|> module - (get@ #definitions) - (list.only (|>> (get@ #definition) + (value@ #definitions) + (list.only (|>> (value@ #definition) (set.member? expected))) ..definitions_documentation) ... Missing documentation (case (|> module - (get@ #definitions) + (value@ #definitions) (list\fold (function (_ definition missing) - (set.lacks (get@ #definition definition) missing)) + (set.lacks (value@ #definition definition) missing)) expected) set.list) #.End @@ -354,9 +367,9 @@ (..listing missing))) ... Un-expected documentation (case (|> module - (get@ #definitions) - (list.only (|>> (get@ #definition) (set.member? expected) not)) - (list\map (get@ #definition))) + (value@ #definitions) + (list.only (|>> (value@ #definition) (set.member? expected) not)) + (list\map (value@ #definition))) #.End md.empty @@ -369,7 +382,7 @@ (def: .public documentation (-> (List Module) Text) (|>> (list.sorted (function (_ left right) - (text\< (get@ #module right) (get@ #module left)))) + (text\< (value@ #module right) (value@ #module left)))) (list\map ..module_documentation) (list.interposed md.horizontal_rule) (list\fold md.then (: (Markdown Block) md.empty)) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 52fdef075..d7f3c9544 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -1403,15 +1403,15 @@ (-> (List (Type Var)) Import_Member_Declaration (List (Type Var))) (case member (#ConstructorDecl [commons _]) - (list\compose class_tvars (get@ #import_member_tvars commons)) + (list\compose class_tvars (value@ #import_member_tvars commons)) (#MethodDecl [commons _]) - (case (get@ #import_member_kind commons) + (case (value@ #import_member_kind commons) #StaticIMK - (get@ #import_member_tvars commons) + (value@ #import_member_tvars commons) _ - (list\compose class_tvars (get@ #import_member_tvars commons))) + (list\compose class_tvars (value@ #import_member_tvars commons))) _ class_tvars)) @@ -1431,7 +1431,7 @@ .let [input_jvm_types (list\map product.right import_member_args) arg_types (list\map (: (-> [Bit (Type Value)] Code) (function (_ [maybe? arg]) - (let [arg_type (value_type (get@ #import_member_mode commons) arg)] + (let [arg_type (value_type (value@ #import_member_mode commons) arg)] (if maybe? (` (Maybe (~ arg_type))) arg_type)))) @@ -1449,7 +1449,7 @@ (dictionary.key? ..boxes unboxed)) return_term - (get@ #import_member_maybe? commons) + (value@ #import_member_maybe? commons) (` (??? (~ return_term))) ... else @@ -1468,7 +1468,7 @@ (-> Import_Member_Declaration Code Code) (case member (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) - (if (get@ <tag> commons) + (if (value@ <tag> commons) <term_trans> return_term) @@ -1599,16 +1599,16 @@ (#ConstructorDecl [commons _]) (do meta.monad [.let [classT (type.class full_name (list)) - def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))]) + def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) jvm_interop (|> [classT (` ("jvm member invoke constructor" [(~+ (list\map ..var$ class_tvars))] (~ (code.text full_name)) - [(~+ (list\map ..var$ (get@ #import_member_tvars commons)))] - (~+ (|> (jvm_invoke_inputs (get@ #import_member_mode commons) input_jvm_types arg_function_inputs) + [(~+ (list\map ..var$ (value@ #import_member_tvars commons)))] + (~+ (|> (jvm_invoke_inputs (value@ #import_member_mode commons) input_jvm_types arg_function_inputs) (list.zipped/2 input_jvm_types) (list\map ..decorate_input)))))] - (with_automatic_output_conversion (get@ #import_member_mode commons)) + (with_automatic_output_conversion (value@ #import_member_mode commons)) (with_return_maybe member true classT) (with_return_try member) (with_return_io member))]] @@ -1618,7 +1618,7 @@ (#MethodDecl [commons method]) (with_identifiers [g!obj] (do meta.monad - [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))]) + [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) (^slots [#import_member_kind]) commons (^slots [#import_method_name]) method [jvm_op object_ast] (: [Text (List Code)] @@ -1637,18 +1637,18 @@ ["jvm member invoke interface" (list g!obj)] ))) - method_return (get@ #import_method_return method) + method_return (value@ #import_method_return method) callC (: Code (` ((~ (code.text jvm_op)) [(~+ (list\map ..var$ class_tvars))] (~ (code.text full_name)) (~ (code.text import_method_name)) - [(~+ (list\map ..var$ (get@ #import_member_tvars commons)))] + [(~+ (list\map ..var$ (value@ #import_member_tvars commons)))] (~+ (|> object_ast (list\map ..un_quoted) (list.zipped/2 (list (type.class full_name (list)))) - (list\map (with_automatic_input_conversion (get@ #import_member_mode commons))))) - (~+ (|> (jvm_invoke_inputs (get@ #import_member_mode commons) input_jvm_types arg_function_inputs) + (list\map (with_automatic_input_conversion (value@ #import_member_mode commons))))) + (~+ (|> (jvm_invoke_inputs (value@ #import_member_mode commons) input_jvm_types arg_function_inputs) (list.zipped/2 input_jvm_types) (list\map ..decorate_input)))))) jvm_interop (: Code @@ -1656,7 +1656,7 @@ (#.Left method_return) (|> [method_return callC] - (with_automatic_output_conversion (get@ #import_member_mode commons)) + (with_automatic_output_conversion (value@ #import_member_mode commons)) (with_return_maybe member false method_return) (with_return_try member) (with_return_io member)) @@ -1809,7 +1809,7 @@ =members (|> bundles (list\map (function (_ [import_format members]) (list\map (|>> [import_format]) members))) - list.joined + list.together (monad.map ! (member_import$ class_type_vars kind declaration)))] (in (list& (class_import$ declaration) (list\join =members))))) @@ -1933,9 +1933,9 @@ _ <failure>)))) -(syntax: .public (array_length [array <code>.any]) +(syntax: .public (length [array <code>.any]) {#.doc (example "Gives the length of an array." - (array_length my_array))} + (length my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -1967,12 +1967,12 @@ _ (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] - (..array_length (~ g!array))))))))) + (..length (~ g!array))))))))) -(syntax: .public (array_read [idx <code>.any - array <code>.any]) +(syntax: .public (read! [idx <code>.any + array <code>.any]) {#.doc (example "Loads an element from an array." - (array_read 10 my_array))} + (read! 10 my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -2006,13 +2006,13 @@ _ (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] - (..array_read (~ idx) (~ g!array))))))))) + (..read! (~ idx) (~ g!array))))))))) -(syntax: .public (array_write [idx <code>.any - value <code>.any - array <code>.any]) +(syntax: .public (write! [idx <code>.any + value <code>.any + array <code>.any]) {#.doc (example "Stores an element into an array." - (array_write 10 my_object my_array))} + (write! 10 my_object my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -2047,7 +2047,7 @@ _ (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] - (..array_write (~ idx) (~ value) (~ g!array))))))))) + (..write! (~ idx) (~ value) (~ g!array))))))))) (syntax: .public (class_for [type (..type^ (list))]) {#.doc (example "Loads the class as a java.lang.Class object." diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 29c286b23..9acf8e055 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -1098,7 +1098,7 @@ .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ (list))) arg_decls))]] (in (`' ((~ (code.text (format "jvm invokespecial" - ":" (get@ #super_class_name super_class) + ":" (value@ #super_class_name super_class) ":" name ":" (text.interposed "," arg_decls')))) (~' _jvm_this) (~+ args)))))))] @@ -1368,15 +1368,15 @@ (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter)) (case member (#ConstructorDecl [commons _]) - (list\compose class_tvars (get@ #import_member_tvars commons)) + (list\compose class_tvars (value@ #import_member_tvars commons)) (#MethodDecl [commons _]) - (case (get@ #import_member_kind commons) + (case (value@ #import_member_kind commons) #StaticIMK - (get@ #import_member_tvars commons) + (value@ #import_member_tvars commons) _ - (list\compose class_tvars (get@ #import_member_tvars commons))) + (list\compose class_tvars (value@ #import_member_tvars commons))) _ class_tvars)) @@ -1398,7 +1398,7 @@ import_member_args)) arg_types (list\map (: (-> [Bit GenericType] Code) (function (_ [maybe? arg]) - (let [arg_type (class_type (get@ #import_member_mode commons) type_params arg)] + (let [arg_type (class_type (value@ #import_member_mode commons) type_params arg)] (if maybe? (` (Maybe (~ arg_type))) arg_type)))) @@ -1412,7 +1412,7 @@ (-> Class_Declaration Import_Member_Declaration Code Code) (case member (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) - (if (get@ #import_member_maybe? commons) + (if (value@ #import_member_maybe? commons) (` (??? (~ return_term))) (let [g!temp (` ((~' ~') (~ (code.identifier ["" " Ω "]))))] (` (let [(~ g!temp) (~ return_term)] @@ -1420,8 +1420,8 @@ (~ g!temp)))) (~ g!temp) (panic! (~ (code.text (format "Cannot produce null references from method calls @ " - (get@ #class_name class) - "." (get@ #import_member_alias commons)))))))))) + (value@ #class_name class) + "." (value@ #import_member_alias commons)))))))))) _ return_term)) @@ -1431,7 +1431,7 @@ (-> Import_Member_Declaration Code Code) (case member (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) - (if (get@ <tag> commons) + (if (value@ <tag> commons) <term_trans> return_term) @@ -1527,10 +1527,10 @@ (#ConstructorDecl [commons _]) (do meta.monad - [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))]) + [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) jvm_extension (code.text (format "jvm new" ":" full_name ":" (text.interposed "," arg_classes))) jvm_interop (|> (` ((~ jvm_extension) - (~+ (jvm_extension_inputs (get@ #import_member_mode commons) arg_classes arg_function_inputs)))) + (~+ (jvm_extension_inputs (value@ #import_member_mode commons) arg_classes arg_function_inputs)))) (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] @@ -1540,7 +1540,7 @@ (#MethodDecl [commons method]) (with_identifiers [g!obj] (do meta.monad - [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))]) + [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) (^slots [#import_member_kind]) commons (^slots [#import_method_name]) method [jvm_op object_ast] (: [Text (List Code)] @@ -1560,10 +1560,10 @@ (list g!obj)] ))) jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" import_method_name ":" (text.interposed "," arg_classes))) - jvm_interop (|> [(simple_class$ (list) (get@ #import_method_return method)) + jvm_interop (|> [(simple_class$ (list) (value@ #import_method_return method)) (` ((~ jvm_extension) (~+ (list\map un_quote object_ast)) - (~+ (jvm_extension_inputs (get@ #import_member_mode commons) arg_classes arg_function_inputs))))] - (auto_convert_output (get@ #import_member_mode commons)) + (~+ (jvm_extension_inputs (value@ #import_member_mode commons) arg_classes arg_function_inputs))))] + (auto_convert_output (value@ #import_member_mode commons)) (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] @@ -1717,7 +1717,7 @@ =members (|> bundles (list\map (function (_ [import_format members]) (list\map (|>> [import_format]) members))) - list.joined + list.together (monad.map ! (member_import$ (product.right class_decl) kind class_decl)))] (in (list& (class_import$ class_decl) (list\join =members))))) @@ -1741,9 +1741,9 @@ _ (in (list (` ("jvm anewarray" (~ (code.text (generic_type$ type))) (~ size))))))) -(syntax: .public (array_length [array <code>.any]) +(syntax: .public (length [array <code>.any]) {#.doc (example "Gives the length of an array." - (array_length my_array))} + (length my_array))} (in (list (` ("jvm arraylength" (~ array)))))) (def: (type_class_name type) @@ -1768,10 +1768,10 @@ _ (meta.failure (format "Cannot convert to JvmType: " (type.format type)))))) -(syntax: .public (array_read [idx <code>.any - array <code>.any]) +(syntax: .public (read! [idx <code>.any + array <code>.any]) {#.doc (example "Loads an element from an array." - (array_read 10 my_array))} + (read! 10 my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -1796,13 +1796,13 @@ _ (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] - (..array_read (~ idx) (~ g!array))))))))) + (..read! (~ idx) (~ g!array))))))))) -(syntax: .public (array_write [idx <code>.any - value <code>.any - array <code>.any]) +(syntax: .public (write! [idx <code>.any + value <code>.any + array <code>.any]) {#.doc (example "Stores an element into an array." - (array_write 10 my_object my_array))} + (write! 10 my_object my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -1827,7 +1827,7 @@ _ (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] - (..array_write (~ idx) (~ value) (~ g!array))))))))) + (..write! (~ idx) (~ value) (~ g!array))))))))) (syntax: .public (class_for [type (..generic_type^ (list))]) {#.doc (example "Loads the class as a java.lang.Class object." diff --git a/stdlib/source/library/lux/locale/language.lux b/stdlib/source/library/lux/locale/language.lux index 1a7b52201..29ec7c190 100644 --- a/stdlib/source/library/lux/locale/language.lux +++ b/stdlib/source/library/lux/locale/language.lux @@ -21,7 +21,7 @@ (template [<name> <tag>] [(def: .public <name> (-> Language Text) - (|>> :representation (get@ <tag>)))] + (|>> :representation (value@ <tag>)))] [name #name] [code #code] diff --git a/stdlib/source/library/lux/locale/territory.lux b/stdlib/source/library/lux/locale/territory.lux index e0f569100..6309e1a86 100644 --- a/stdlib/source/library/lux/locale/territory.lux +++ b/stdlib/source/library/lux/locale/territory.lux @@ -24,7 +24,7 @@ [(def: .public <name> (-> Territory <type>) (|>> :representation - (get@ <field>)))] + (value@ <field>)))] [name #name Text] [short_code #short Text] @@ -309,6 +309,6 @@ (def: hash (|>> :representation - (get@ #long) + (value@ #long) (\ text.hash hash)))) ) diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index 8a10f5f26..8c518b855 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -34,11 +34,11 @@ (def: (with_module name body) (All [a] (-> Text (-> Module (Try [Module a])) (Meta a))) (function (_ compiler) - (case (|> compiler (get@ #.modules) (plist.value name)) + (case (|> compiler (value@ #.modules) (plist.value name)) (#.Some module) (case (body module) (#try.Success [module' output]) - (#try.Success [(update@ #.modules (plist.has name module') compiler) + (#try.Success [(revised@ #.modules (plist.has name module') compiler) output]) (#try.Failure error) @@ -56,9 +56,9 @@ (plist.has definition_name definition))]] (..with_module module_name (function (_ module) - (case (|> module (get@ #.definitions) (plist.value definition_name)) + (case (|> module (value@ #.definitions) (plist.value definition_name)) #.None - (#try.Success [(update@ #.definitions add_macro! module) + (#try.Success [(revised@ #.definitions add_macro! module) []]) (#.Some _) @@ -72,9 +72,9 @@ (plist.lacks definition_name))]] (..with_module module_name (function (_ module) - (case (|> module (get@ #.definitions) (plist.value definition_name)) + (case (|> module (value@ #.definitions) (plist.value definition_name)) (#.Some _) - (#try.Success [(update@ #.definitions lacks_macro! module) + (#try.Success [(revised@ #.definitions lacks_macro! module) []]) #.None @@ -88,7 +88,7 @@ [_ (monad.map ! ..pop_one macros) _ (..pop_one self) compiler meta.compiler_state] - (in (case (get@ #.expected compiler) + (in (case (value@ #.expected compiler) (#.Some _) (list (' [])) diff --git a/stdlib/source/library/lux/macro/syntax/annotations.lux b/stdlib/source/library/lux/macro/syntax/annotations.lux index 1db17d9b5..5e23ea9d8 100644 --- a/stdlib/source/library/lux/macro/syntax/annotations.lux +++ b/stdlib/source/library/lux/macro/syntax/annotations.lux @@ -31,7 +31,7 @@ (def: .public format (-> Annotations Code) - (let [entry (product.apply code.tag function.identity)] + (let [entry (product.then code.tag function.identity)] (|>> (list\map entry) code.record))) diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index c85e74822..1a529d3db 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -39,8 +39,8 @@ (def: .public (format value) (-> Declaration Code) - (let [g!name (code.local_identifier (get@ #name value))] - (case (get@ #arguments value) + (let [g!name (code.local_identifier (value@ #name value))] + (case (value@ #arguments value) #.End g!name diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index 7ebf281d4..14e907870 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -66,9 +66,9 @@ (def: dummy Code - (` {#.module (~ (code.text (get@ #.module location.dummy))) - #.line (~ (code.nat (get@ #.line location.dummy))) - #.column (~ (code.nat (get@ #.column location.dummy)))})) + (` {#.module (~ (code.text (value@ #.module location.dummy))) + #.line (~ (code.nat (value@ #.line location.dummy))) + #.column (~ (code.nat (value@ #.column location.dummy)))})) (def: .public (format (^slots [#name #value #anns #export?])) (-> Definition Code) @@ -133,7 +133,7 @@ (-> Lux (Parser Definition)) (do <>.monad [definition (..parser compiler) - _ (case (get@ #value definition) + _ (case (value@ #value definition) (#.Left _) (in []) diff --git a/stdlib/source/library/lux/macro/syntax/input.lux b/stdlib/source/library/lux/macro/syntax/input.lux index 6754185af..77623fbd7 100644 --- a/stdlib/source/library/lux/macro/syntax/input.lux +++ b/stdlib/source/library/lux/macro/syntax/input.lux @@ -26,8 +26,8 @@ (def: .public (format value) (-> Input Code) (code.record - (list [(get@ #binding value) - (get@ #type value)]))) + (list [(value@ #binding value) + (value@ #type value)]))) (def: .public parser {#.doc "Parser for the common typed-argument syntax used by many macros."} diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index 8de4f2501..d378f9409 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -44,7 +44,7 @@ (do {! meta.monad} [g!locals (|> locals (list\map //.identifier) - (monad.seq !))] + (monad.all !))] (in (list (` (.with_expansions [(~+ (|> (list.zipped/2 locals g!locals) (list\map (function (_ [name identifier]) (list (code.local_identifier name) (as_is identifier)))) @@ -196,14 +196,14 @@ [here_name meta.current_module_name expression? (: (Meta Bit) (function (_ lux) - (#try.Success [lux (case (get@ #.expected lux) + (#try.Success [lux (case (value@ #.expected lux) #.None false (#.Some _) true)]))) g!pop (local.push (list\map (function (_ local) - [[here_name (get@ #name local)] + [[here_name (value@ #name local)] (..macro local)]) locals))] (if expression? diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 7f19f1a85..e088df673 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -331,7 +331,7 @@ n n] (if (n.<= 1 n) acc - (recur (n.* n acc) (dec n))))) + (recur (n.* n acc) (-- n))))) (def: .public (hypotenuse catA catB) (-> Frac Frac Frac) diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index 1615bf633..d26544c0b 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -50,23 +50,23 @@ (..complex +0.0 +0.0)) (def: .public (not_a_number? complex) - (or (f.not_a_number? (get@ #real complex)) - (f.not_a_number? (get@ #imaginary complex)))) + (or (f.not_a_number? (value@ #real complex)) + (f.not_a_number? (value@ #imaginary complex)))) (def: .public (= param input) (-> Complex Complex Bit) - (and (f.= (get@ #real param) - (get@ #real input)) - (f.= (get@ #imaginary param) - (get@ #imaginary input)))) + (and (f.= (value@ #real param) + (value@ #real input)) + (f.= (value@ #imaginary param) + (value@ #imaginary input)))) (template [<name> <op>] [(def: .public (<name> param input) (-> Complex Complex Complex) - {#real (<op> (get@ #real param) - (get@ #real input)) - #imaginary (<op> (get@ #imaginary param) - (get@ #imaginary input))})] + {#real (<op> (value@ #real param) + (value@ #real input)) + #imaginary (<op> (value@ #imaginary param) + (value@ #imaginary input))})] [+ f.+] [- f.-] @@ -80,8 +80,8 @@ (template [<name> <transform>] [(def: .public <name> (-> Complex Complex) - (|>> (update@ #real <transform>) - (update@ #imaginary <transform>)))] + (|>> (revised@ #real <transform>) + (revised@ #imaginary <transform>)))] [opposite f.opposite] [signum f.signum] @@ -89,25 +89,25 @@ (def: .public conjugate (-> Complex Complex) - (update@ #imaginary f.opposite)) + (revised@ #imaginary f.opposite)) (def: .public (*' param input) (-> Frac Complex Complex) {#real (f.* param - (get@ #real input)) + (value@ #real input)) #imaginary (f.* param - (get@ #imaginary input))}) + (value@ #imaginary input))}) (def: .public (* param input) (-> Complex Complex Complex) - {#real (f.- (f.* (get@ #imaginary param) - (get@ #imaginary input)) - (f.* (get@ #real param) - (get@ #real input))) - #imaginary (f.+ (f.* (get@ #real param) - (get@ #imaginary input)) - (f.* (get@ #imaginary param) - (get@ #real input)))}) + {#real (f.- (f.* (value@ #imaginary param) + (value@ #imaginary input)) + (f.* (value@ #real param) + (value@ #real input))) + #imaginary (f.+ (f.* (value@ #real param) + (value@ #imaginary input)) + (f.* (value@ #imaginary param) + (value@ #real input)))}) (def: .public (/ param input) (-> Complex Complex Complex) @@ -116,12 +116,12 @@ (f.abs real)) (let [quot (f./ imaginary real) denom (|> real (f.* quot) (f.+ imaginary))] - {#real (|> (get@ #real input) (f.* quot) (f.+ (get@ #imaginary input)) (f./ denom)) - #imaginary (|> (get@ #imaginary input) (f.* quot) (f.- (get@ #real input)) (f./ denom))}) + {#real (|> (value@ #real input) (f.* quot) (f.+ (value@ #imaginary input)) (f./ denom)) + #imaginary (|> (value@ #imaginary input) (f.* quot) (f.- (value@ #real input)) (f./ denom))}) (let [quot (f./ real imaginary) denom (|> imaginary (f.* quot) (f.+ real))] - {#real (|> (get@ #imaginary input) (f.* quot) (f.+ (get@ #real input)) (f./ denom)) - #imaginary (|> (get@ #imaginary input) (f.- (f.* quot (get@ #real input))) (f./ denom))})))) + {#real (|> (value@ #imaginary input) (f.* quot) (f.+ (value@ #real input)) (f./ denom)) + #imaginary (|> (value@ #imaginary input) (f.- (f.* quot (value@ #real input))) (f./ denom))})))) (def: .public (/' param subject) (-> Frac Complex Complex) @@ -133,8 +133,8 @@ (-> Complex Complex Complex) (let [scaled (/ param input) quotient (|> scaled - (update@ #real math.floor) - (update@ #imaginary math.floor))] + (revised@ #real math.floor) + (revised@ #imaginary math.floor))] (- (* quotient param) input))) @@ -311,8 +311,8 @@ (def: .public (approximately? margin_of_error standard value) (-> Frac Complex Complex Bit) (and (f.approximately? margin_of_error - (get@ #..real standard) - (get@ #..real value)) + (value@ #..real standard) + (value@ #..real value)) (f.approximately? margin_of_error - (get@ #..imaginary standard) - (get@ #..imaginary value)))) + (value@ #..imaginary standard) + (value@ #..imaginary value)))) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 9e49975f8..1d92184b8 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -288,7 +288,7 @@ exponent_bits (|> (if (..< +0.0 min_gap) (|> (..int exponent) (//int.- (..int min_gap)) - dec) + --) (..int exponent)) (//int.+ (.int ..double_bias)) (//i64.and ..exponent_mask)) @@ -302,7 +302,7 @@ (template [<getter> <size> <offset>] [(def: <getter> (-> (I64 Any) I64) - (let [mask (|> 1 (//i64.left_shifted <size>) dec (//i64.left_shifted <offset>))] + (let [mask (|> 1 (//i64.left_shifted <size>) -- (//i64.left_shifted <offset>))] (|>> (//i64.and mask) (//i64.right_shifted <offset>) .i64)))] [mantissa ..mantissa_size 0] @@ -400,7 +400,7 @@ [whole decimal] (case ("lux text index" 0 "." mantissa) (#.Some split_index) (do ! - [.let [after_offset (inc split_index) + [.let [after_offset (++ split_index) after_length (//nat.- after_offset ("lux text size" mantissa))] decimal (|> mantissa ("lux text clip" after_offset after_length) @@ -410,7 +410,7 @@ #.None (#try.Failure ("lux text concat" <error> representation))) - .let [whole ("lux text clip" 1 (dec ("lux text size" whole)) whole)] + .let [whole ("lux text clip" 1 (-- ("lux text size" whole)) whole)] mantissa (\ <nat> decode (case decimal 0 whole _ ("lux text concat" whole (\ <nat> encode decimal)))) diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index fd0c5545b..42c08e00a 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -48,12 +48,12 @@ (def: .public sign {#.doc (example "A mask for the sign bit of ints.")} Mask - (..bit (dec ..width))) + (..bit (-- ..width))) (def: .public not {#.doc "Bitwise negation."} (All [s] (-> (I64 s) (I64 s))) - (..xor (.i64 (dec 0)))) + (..xor (.i64 (-- 0)))) (def: .public false Mask @@ -70,7 +70,7 @@ 0 ..false bits (case (n.% ..width bits) 0 ..true - bits (|> 1 .i64 (..left_shifted (n.% ..width bits)) .dec)))) + bits (|> 1 .i64 (..left_shifted (n.% ..width bits)) .--)))) (def: (with_shift shift value) (-> Nat Nat Nat) @@ -161,7 +161,7 @@ (loop [iterations 1 output char] (if (n.< times iterations) - (recur (inc iterations) + (recur (++ iterations) ("lux text concat" char output)) output)))) pattern (repetitions (n./ (n.+ size size) ..width) @@ -206,8 +206,8 @@ (if (.and (n.> 0 width) (n.< ..width width)) (let [sign_shift (n.- width ..width) - sign (..bit (dec width)) - mantissa (..mask (dec width)) + sign (..bit (-- width)) + mantissa (..mask (-- width)) co_mantissa (..xor (.i64 -1) mantissa)] (#.Some (: Sub (implementation diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index 88ba6bba1..d5546a4a5 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -186,8 +186,8 @@ (Enum Int) (def: &order ..order) - (def: succ inc) - (def: pred dec)) + (def: succ ++) + (def: pred --)) ... TODO: Find out why the numeric literals fail during JS compilation. (implementation: .public interval @@ -198,7 +198,7 @@ ... +9,223,372,036,854,775,807 (let [half (//i64.left_shifted 62 +1)] (+ half - (dec half)))) + (-- half)))) (def: bottom ... -9,223,372,036,854,775,808 (//i64.left_shifted 63 +1))) @@ -225,7 +225,7 @@ (def: (encode value) (if (..< +0 value) - (|> value inc ..opposite .nat inc (\ <codec> encode) ("lux text concat" ..-sign)) + (|> value ++ ..opposite .nat ++ (\ <codec> encode) ("lux text concat" ..-sign)) (|> value .nat (\ <codec> encode) ("lux text concat" ..+sign)))) (def: (decode repr) @@ -234,15 +234,15 @@ (case ("lux text clip" 0 1 repr) (^ (static ..+sign)) (|> repr - ("lux text clip" 1 (dec input_size)) + ("lux text clip" 1 (-- input_size)) (\ <codec> decode) (\ try.functor map .int)) (^ (static ..-sign)) (|> repr - ("lux text clip" 1 (dec input_size)) + ("lux text clip" 1 (-- input_size)) (\ <codec> decode) - (\ try.functor map (|>> dec .int ..opposite dec))) + (\ try.functor map (|>> -- .int ..opposite --))) _ (#try.Failure <error>)) diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index bd6ff389c..c72289e0d 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -170,14 +170,14 @@ (Enum Nat) (def: &order ..order) - (def: succ inc) - (def: pred dec)) + (def: succ ++) + (def: pred --)) (implementation: .public interval (Interval Nat) (def: &enum ..enum) - (def: top (dec 0)) + (def: top (-- 0)) (def: bottom 0)) (template [<name> <compose> <identity>] @@ -303,7 +303,7 @@ (Codec Text Nat) (def: encode - (let [mask (|> 1 ("lux i64 left-shift" <shift>) dec)] + (let [mask (|> 1 ("lux i64 left-shift" <shift>) --)] (function (_ value) (loop [input value output ""] @@ -325,7 +325,7 @@ (if (..< input_size idx) (case (<to_value> ("lux text char" idx repr)) (#.Some digit_value) - (recur (inc idx) + (recur (++ idx) (|> output ("lux i64 left-shift" <shift>) ("lux i64 or" digit_value))) @@ -367,7 +367,7 @@ <failure> (#.Some digit_value) - (recur (inc idx) + (recur (++ idx) (|> output (..* 10) (..+ digit_value)))) (#try.Success output))) <failure>))))) diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index cfb3eca00..5d5962b47 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -30,8 +30,8 @@ (def: .public (nat value) (-> Ratio (Maybe Nat)) - (case (get@ #denominator value) - 1 (#.Some (get@ #numerator value)) + (case (value@ #denominator value) + 1 (#.Some (value@ #numerator value)) _ #.None)) (def: (normal (^slots [#numerator #denominator])) @@ -51,10 +51,10 @@ (def: .public (= parameter subject) (-> Ratio Ratio Bit) - (and (n.= (get@ #numerator parameter) - (get@ #numerator subject)) - (n.= (get@ #denominator parameter) - (get@ #denominator subject)))) + (and (n.= (value@ #numerator parameter) + (value@ #numerator subject)) + (n.= (value@ #denominator parameter) + (value@ #denominator subject)))) (implementation: .public equivalence (Equivalence Ratio) @@ -63,10 +63,10 @@ (def: (equalized parameter subject) (-> Ratio Ratio [Nat Nat]) - [(n.* (get@ #denominator subject) - (get@ #numerator parameter)) - (n.* (get@ #denominator parameter) - (get@ #numerator subject))]) + [(n.* (value@ #denominator subject) + (value@ #numerator parameter)) + (n.* (value@ #denominator parameter) + (value@ #numerator subject))]) (def: .public (< parameter subject) (-> Ratio Ratio Bit) @@ -97,22 +97,22 @@ (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [(n.+ parameter' subject') - (n.* (get@ #denominator parameter) - (get@ #denominator subject))]))) + (n.* (value@ #denominator parameter) + (value@ #denominator subject))]))) (def: .public (- parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [(n.- parameter' subject') - (n.* (get@ #denominator parameter) - (get@ #denominator subject))]))) + (n.* (value@ #denominator parameter) + (value@ #denominator subject))]))) (def: .public (* parameter subject) (-> Ratio Ratio Ratio) - (normal [(n.* (get@ #numerator parameter) - (get@ #numerator subject)) - (n.* (get@ #denominator parameter) - (get@ #denominator subject))])) + (normal [(n.* (value@ #numerator parameter) + (value@ #numerator subject)) + (n.* (value@ #denominator parameter) + (value@ #denominator subject))])) (def: .public (/ parameter subject) (-> Ratio Ratio Ratio) @@ -123,7 +123,7 @@ (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject) quot (n./ parameter' subject')] - (..- (update@ #numerator (n.* quot) parameter) + (..- (revised@ #numerator (n.* quot) parameter) subject))) (def: .public (reciprocal (^slots [#numerator #denominator])) diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index 4eea3ecf7..3fc60202c 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -119,7 +119,7 @@ ("lux i64 +" top)))) (def: even_one (//i64.right_rotated 1 1)) -(def: odd_one (dec 0)) +(def: odd_one (-- 0)) (def: (even_reciprocal numerator) (-> Nat Nat) @@ -205,8 +205,8 @@ (Enum Rev) (def: &order ..order) - (def: succ inc) - (def: pred dec)) + (def: succ ++) + (def: pred --)) (implementation: .public interval (Interval Rev) @@ -229,7 +229,7 @@ (def: (decimals input) (-> Text Text) - ("lux text clip" 1 (dec ("lux text size" input)) input)) + ("lux text clip" 1 (-- ("lux text size" input)) input)) (template [<struct> <codec> <char_bit_size> <error>] [(with_expansions [<error_output> (as_is (#try.Failure ("lux text concat" <error> repr)))] @@ -248,7 +248,7 @@ output (: Text "")] (if (//nat.= 0 zeroes_left) output - (recur (dec zeroes_left) + (recur (-- zeroes_left) ("lux text concat" "0" output)))))] (|> raw_output ("lux text concat" zero_padding) @@ -311,7 +311,7 @@ (let [raw (|> (..digit idx output) (//nat.* 5) (//nat.+ carry))] - (recur (dec idx) + (recur (-- idx) (//nat./ 10 raw) (digits\put! idx (//nat.% 10 raw) output))) output))) @@ -322,21 +322,21 @@ output (|> (..digits []) (digits\put! power 1))] (if (//int.>= +0 (.int times)) - (recur (dec times) + (recur (-- times) (digits\times_5! power output)) output))) (def: (format digits) (-> Digits Text) - (loop [idx (dec //i64.width) + (loop [idx (-- //i64.width) all_zeroes? true output ""] (if (//int.>= +0 (.int idx)) (let [digit (..digit idx digits)] (if (and (//nat.= 0 digit) all_zeroes?) - (recur (dec idx) true output) - (recur (dec idx) + (recur (-- idx) true output) + (recur (-- idx) false ("lux text concat" (\ //nat.decimal encode digit) @@ -347,7 +347,7 @@ (def: (digits\+! param subject) (-> Digits Digits Digits) - (loop [idx (dec //i64.width) + (loop [idx (-- //i64.width) carry 0 output (..digits [])] (if (//int.>= +0 (.int idx)) @@ -355,7 +355,7 @@ carry (..digit idx param) (..digit idx subject))] - (recur (dec idx) + (recur (-- idx) (//nat./ 10 raw) (digits\put! idx (//nat.% 10 raw) output))) output))) @@ -372,7 +372,7 @@ #.None (#.Some digit) - (recur (inc idx) + (recur (++ idx) (digits\put! idx digit output))) (#.Some output))) #.None))) @@ -384,7 +384,7 @@ (let [pd (..digit idx param) sd (..digit idx subject)] (if (//nat.= pd sd) - (recur (inc idx)) + (recur (++ idx)) (//nat.< pd sd)))))) (def: (digits\-!' idx param subject) @@ -397,14 +397,14 @@ (//nat.- param))] (|> subject (digits\put! idx diff) - (digits\-!' (dec idx) 1)))))) + (digits\-!' (-- idx) 1)))))) (def: (digits\-! param subject) (-> Digits Digits Digits) - (loop [idx (dec //i64.width) + (loop [idx (-- //i64.width) output subject] (if (//int.>= +0 (.int idx)) - (recur (dec idx) + (recur (-- idx) (digits\-!' idx (..digit idx param) output)) output))) @@ -417,16 +417,16 @@ ".0" input - (let [last_idx (dec //i64.width)] + (let [last_idx (-- //i64.width)] (loop [idx last_idx digits (..digits [])] (if (//int.>= +0 (.int idx)) (if (//i64.one? idx input) (let [digits' (digits\+! (power_digits (//nat.- idx last_idx)) digits)] - (recur (dec idx) + (recur (-- idx) digits')) - (recur (dec idx) + (recur (-- idx) digits)) ("lux text concat" "." (..format digits)) ))))) @@ -438,7 +438,7 @@ _ false) - within_limits? (//nat.<= (inc //i64.width) + within_limits? (//nat.<= (++ //i64.width) ("lux text size" input))] (if (and dotted? within_limits?) (case (|> input ..decimals ..text_digits) @@ -450,10 +450,10 @@ (let [power (power_digits idx)] (if (digits\< power digits) ... Skip power - (recur digits (inc idx) output) + (recur digits (++ idx) output) (recur (digits\-! power digits) - (inc idx) - (//i64.one (//nat.- idx (dec //i64.width)) output)))) + (++ idx) + (//i64.one (//nat.- idx (-- //i64.width)) output)))) (#try.Success (.rev output)))) #.None diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index bb66000be..6b61b5159 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -145,7 +145,7 @@ {#.doc (example "A number in the interval [0.0,1.0].")} (Random Frac) (let [mantissa_range (.int (i64.left_shifted 53 1)) - mantissa_max (i.frac (dec mantissa_range))] + mantissa_max (i.frac (-- mantissa_range))] (\ ..monad map (|>> (i.% mantissa_range) i.frac @@ -169,7 +169,7 @@ (\ ..monad in "") (do ..monad [x char_gen - xs (text char_gen (dec size))] + xs (text char_gen (-- size))] (in (text\compose (text.of_char x) xs))))) (template [<name> <set>] @@ -251,12 +251,12 @@ (if (n.> 0 size) (do ..monad [x value_gen - xs (<name> (dec size) value_gen)] + xs (<name> (-- size) value_gen)] (in (<plus> x xs))) (\ ..monad in <zero>)))] [list List (.list) #.Item] - [row Row row.empty row.add] + [row Row row.empty row.suffix] ) (template [<name> <type> <ctor>] @@ -275,7 +275,7 @@ (All [a] (-> (Hash a) Nat (Random a) (Random (Set a)))) (if (n.> 0 size) (do {! ..monad} - [xs (set hash (dec size) value_gen)] + [xs (set hash (-- size) value_gen)] (loop [_ []] (do ! [x value_gen @@ -289,7 +289,7 @@ (All [k v] (-> (Hash k) Nat (Random k) (Random v) (Random (Dictionary k v)))) (if (n.> 0 size) (do {! ..monad} - [kv (dictionary hash (dec size) key_gen value_gen)] + [kv (dictionary hash (-- size) key_gen value_gen)] (loop [_ []] (do ! [k key_gen diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index b415adb91..7b6e893d3 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -118,13 +118,13 @@ (All [a] (-> Text (Meta a))) (function (_ state) - (#try.Failure (location.with (get@ #.location state) error)))) + (#try.Failure (location.with (value@ #.location state) error)))) (def: .public (module name) {#.doc (example "Looks-up a module with the given name.")} (-> Text (Meta Module)) (function (_ lux) - (case (plist.value name (get@ #.modules lux)) + (case (plist.value name (value@ #.modules lux)) (#.Some module) (#try.Success [lux module]) @@ -135,7 +135,7 @@ {#.doc (example "The name of the module currently being compiled, if any.")} (Meta Text) (function (_ lux) - (case (get@ #.current_module lux) + (case (value@ #.current_module lux) (#.Some current_module) (#try.Success [lux current_module]) @@ -179,7 +179,7 @@ [$module (plist.value module modules) definition (: (Maybe Global) (|> (: Module $module) - (get@ #.definitions) + (value@ #.definitions) (plist.value name)))] (case definition (#.Alias [r_module r_name]) @@ -202,7 +202,7 @@ #.None (#try.Success [_ this_module]) - (macro' (get@ #.modules lux) this_module module name))] + (macro' (value@ #.modules lux) this_module module name))] (#try.Success [lux macro])))))) (def: .public seed @@ -211,13 +211,13 @@ "This number can be used for generating data 'randomly' during compilation.")} (Meta Nat) (function (_ lux) - (#try.Success [(update@ #.seed inc lux) - (get@ #.seed lux)]))) + (#try.Success [(revised@ #.seed ++ lux) + (value@ #.seed lux)]))) (def: .public (module_exists? module) (-> Text (Meta Bit)) (function (_ lux) - (#try.Success [lux (case (plist.value module (get@ #.modules lux)) + (#try.Success [lux (case (plist.value module (value@ #.modules lux)) (#.Some _) #1 @@ -248,7 +248,7 @@ (#.Var var) (function (_ lux) (case (|> lux - (get@ [#.type_context #.var_bindings]) + (value@ [#.type_context #.var_bindings]) (type_variable var)) (^or #.None (#.Some (#.Var _))) (#try.Success [lux type]) @@ -268,15 +268,15 @@ (case (do maybe.monad [scope (list.example (function (_ env) (or (list.any? test (: (List [Text [Type Any]]) - (get@ [#.locals #.mappings] env))) + (value@ [#.locals #.mappings] env))) (list.any? test (: (List [Text [Type Any]]) - (get@ [#.captured #.mappings] env))))) - (get@ #.scopes lux)) + (value@ [#.captured #.mappings] env))))) + (value@ #.scopes lux)) [_ [type _]] (on_either (list.example test) (: (List [Text [Type Any]]) - (get@ [#.locals #.mappings] scope)) + (value@ [#.locals #.mappings] scope)) (: (List [Text [Type Any]]) - (get@ [#.captured #.mappings] scope)))] + (value@ [#.captured #.mappings] scope)))] (in type)) (#.Some var_type) ((clean_type var_type) lux) @@ -310,28 +310,28 @@ (case (: (Maybe Global) (do maybe.monad [(^slots [#.definitions]) (|> lux - (get@ #.modules) + (value@ #.modules) (plist.value normal_module))] (plist.value normal_short definitions))) (#.Some definition) (#try.Success [lux definition]) _ - (let [current_module (|> lux (get@ #.current_module) (maybe.else "???")) + (let [current_module (|> lux (value@ #.current_module) (maybe.else "???")) all_known_modules (|> lux - (get@ #.modules) + (value@ #.modules) (list\map product.left) ..module_listing)] (#try.Failure ($_ text\compose "Unknown definition: " (name\encode name) text.new_line " Current module: " current_module text.new_line - (case (plist.value current_module (get@ #.modules lux)) + (case (plist.value current_module (value@ #.modules lux)) (#.Some this_module) (let [candidates (|> lux - (get@ #.modules) + (value@ #.modules) (list\map (function (_ [module_name module]) (|> module - (get@ #.definitions) + (value@ #.definitions) (list.all (function (_ [def_name global]) (case global (#.Definition [exported? _ _ _]) @@ -342,14 +342,14 @@ (#.Alias _) #.None)))))) - list.joined + list.together (list.sorted text\<) (text.interposed ..listing_separator)) imports (|> this_module - (get@ #.imports) + (value@ #.imports) ..module_listing) aliases (|> this_module - (get@ #.module_aliases) + (value@ #.module_aliases) (list\map (function (_ [alias real]) ($_ text\compose alias " => " real))) (list.sorted text\<) (text.interposed ..listing_separator))] @@ -425,12 +425,12 @@ {#.doc "The entire list of globals in a module (including the non-exported/private ones)."} (-> Text (Meta (List [Text Global]))) (function (_ lux) - (case (plist.value module (get@ #.modules lux)) + (case (plist.value module (value@ #.modules lux)) #.None (#try.Failure ($_ text\compose "Unknown module: " module)) (#.Some module) - (#try.Success [lux (get@ #.definitions module)])))) + (#try.Success [lux (value@ #.definitions module)])))) (def: .public (definitions module) {#.doc "The entire list of definitions in a module (including the non-exported/private ones)."} @@ -461,7 +461,7 @@ (Meta (List [Text Module])) (function (_ lux) (|> lux - (get@ #.modules) + (value@ #.modules) [lux] #try.Success))) @@ -471,7 +471,7 @@ (do ..monad [.let [[module name] type_name] module (..module module)] - (case (plist.value name (get@ #.types module)) + (case (plist.value name (value@ #.types module)) (#.Some [tags _]) (in (#.Some tags)) @@ -482,13 +482,13 @@ {#.doc "The location of the current expression being analyzed."} (Meta Location) (function (_ lux) - (#try.Success [lux (get@ #.location lux)]))) + (#try.Success [lux (value@ #.location lux)]))) (def: .public expected_type {#.doc "The expected type of the current expression being analyzed."} (Meta Type) (function (_ lux) - (case (get@ #.expected lux) + (case (value@ #.expected lux) (#.Some type) (#try.Success [lux type]) @@ -512,7 +512,7 @@ {#.doc (example "Checks if the given module has been imported by the current module.")} (-> Text (Meta Bit)) (\ ..functor map - (|>> (get@ #.imports) (list.any? (text\= import))) + (|>> (value@ #.imports) (list.any? (text\= import))) ..current_module)) (def: .public (tag tag_name) @@ -523,7 +523,7 @@ =module (..module module) this_module_name ..current_module_name imported! (..imported? module)] - (case (plist.value name (get@ #.tags =module)) + (case (plist.value name (value@ #.tags =module)) (#.Some [idx tag_list exported? type]) (if (or (text\= this_module_name module) (and imported! exported?)) @@ -534,9 +534,9 @@ (..failure ($_ text\compose "Unknown tag: " (name\encode tag_name) text.new_line " Known tags: " (|> =module - (get@ #.tags) + (value@ #.tags) (list\map (|>> product.left [module] name\encode (text.prefix text.new_line))) - text.joined) + text.together) ))))) (def: .public (tag_lists module) @@ -545,7 +545,7 @@ (do ..monad [=module (..module module) this_module_name ..current_module_name] - (in (|> (get@ #.types =module) + (in (|> (value@ #.types =module) (list.only (function (_ [type_name [tag_list exported? type]]) (or exported? (text\= this_module_name module)))) @@ -556,13 +556,13 @@ {#.doc "All the local variables currently in scope, separated in different scopes."} (Meta (List (List [Text Type]))) (function (_ lux) - (case (list.inits (get@ #.scopes lux)) + (case (list.inits (value@ #.scopes lux)) #.None (#try.Failure "No local environment") (#.Some scopes) (#try.Success [lux - (list\map (|>> (get@ [#.locals #.mappings]) + (list\map (|>> (value@ [#.locals #.mappings]) (list\map (function (_ [name [type _]]) [name type]))) scopes)])))) @@ -589,7 +589,7 @@ {#.doc (example "The current type-checking context.")} (Meta Type_Context) (function (_ lux) - (#try.Success [lux (get@ #.type_context lux)]))) + (#try.Success [lux (value@ #.type_context lux)]))) (def: .public (lifted result) (All [a] (-> (Try a) (Meta a))) diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index 0c089da36..24511eb26 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -8,9 +8,9 @@ (Equivalence Location) (def: (= reference subject) - (and ("lux text =" (get@ #.module reference) (get@ #.module subject)) - ("lux i64 =" (get@ #.line reference) (get@ #.line subject)) - ("lux i64 =" (get@ #.column reference) (get@ #.column subject))))) + (and ("lux text =" (value@ #.module reference) (value@ #.module subject)) + ("lux i64 =" (value@ #.line reference) (value@ #.line subject)) + ("lux i64 =" (value@ #.column reference) (value@ #.column subject))))) (def: .public dummy Location @@ -23,12 +23,12 @@ (here))} (case tokens #.End - (let [location (get@ #.location compiler)] + (let [location (value@ #.location compiler)] (#.Right [compiler (list (` (.: .Location - [(~ [..dummy (#.Text (get@ #.module location))]) - (~ [..dummy (#.Nat (get@ #.line location))]) - (~ [..dummy (#.Nat (get@ #.column location))])])))])) + [(~ [..dummy (#.Text (value@ #.module location))]) + (~ [..dummy (#.Nat (value@ #.line location))]) + (~ [..dummy (#.Nat (value@ #.column location))])])))])) _ (#.Left (`` (("lux in-module" (~~ (static .prelude_module)) wrong_syntax_error) (name_of ..here)))))) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index 95c49a200..191b5520a 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Location Code or and function if cond undefined for comment not int try) + [lux (#- Location Code or and function if cond undefined for comment not int try ++ --) [control [pipe (#+ case>)]] [data diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux index 1c1cb95a9..81f487d2d 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux @@ -37,19 +37,19 @@ ... u4 code_length; ///unsigned.bytes/4 ... u1 code[code_length]; - (binary.size (get@ #code code)) + (binary.size (value@ #code code)) ... u2 exception_table_length; ///unsigned.bytes/2 ... exception_table[exception_table_length]; (|> code - (get@ #exception_table) + (value@ #exception_table) row.size (n.* /exception.length)) ... u2 attributes_count; ///unsigned.bytes/2 ... attribute_info attributes[attributes_count]; (|> code - (get@ #attributes) + (value@ #attributes) (row\map length) (row\fold n.+ 0)))) @@ -69,14 +69,14 @@ ($_ binaryF\compose ... u2 max_stack; ... u2 max_locals; - (///limit.writer (get@ #limit code)) + (///limit.writer (value@ #limit code)) ... u4 code_length; ... u1 code[code_length]; - (binaryF.binary/32 (get@ #code code)) + (binaryF.binary/32 (value@ #code code)) ... u2 exception_table_length; ... exception_table[exception_table_length]; - ((binaryF.row/16 /exception.writer) (get@ #exception_table code)) + ((binaryF.row/16 /exception.writer) (value@ #exception_table code)) ... u2 attributes_count; ... attribute_info attributes[attributes_count]; - ((binaryF.row/16 writer) (get@ #attributes code)) + ((binaryF.row/16 writer) (value@ #attributes code)) )) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 87b0a75c5..a97f4a1c2 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -105,9 +105,9 @@ (function (_ [pool environment tracker]) (#try.Success [[pool environment - (update@ #next inc tracker)] + (revised@ #next ++ tracker)] [..relative_identity - (get@ #next tracker)]]))) + (value@ #next tracker)]]))) (exception: .public (label_has_already_been_set {label Label}) (exception.report @@ -127,16 +127,16 @@ (with_expansions [<success> (as_is (in [[pool environment - (update@ #known - (dictionary.has label [actual (#.Some @here)]) - tracker)] + (revised@ #known + (dictionary.has label [actual (#.Some @here)]) + tracker)] [..relative_identity []]]))] (def: .public (set_label label) (-> Label (Bytecode Any)) (function (_ [pool environment tracker]) - (let [@here (get@ #program_counter tracker)] - (case (dictionary.value label (get@ #known tracker)) + (let [@here (value@ #program_counter tracker)] + (case (dictionary.value label (value@ #known tracker)) (#.Some [expected (#.Some address)]) (exception.except ..label_has_already_been_set [label]) @@ -148,7 +148,7 @@ #.None (do try.monad [[actual environment] (/environment.continue (|> environment - (get@ #/environment.stack) + (value@ #/environment.stack) (maybe.else /stack.empty)) environment)] <success>)))))) @@ -175,7 +175,7 @@ (function (_ pool) (do try.monad [[[pool environment tracker] [relative output]] (bytecode [pool environment ..fresh]) - [exceptions instruction] (relative (get@ #known tracker))] + [exceptions instruction] (relative (value@ #known tracker))] (in [pool [environment exceptions instruction output]])))) (def: (step estimator counter) @@ -188,12 +188,12 @@ (do {! try.monad} [environment' (|> environment (/environment.consumes consumption) - (monad.bind ! (/environment.produces production)) - (monad.bind ! (/environment.has registry))) - program_counter' (step estimator (get@ #program_counter tracker))] + (monad.then ! (/environment.produces production)) + (monad.then ! (/environment.has registry))) + program_counter' (step estimator (value@ #program_counter tracker))] (in [[pool environment' - (set@ #program_counter program_counter' tracker)] + (with@ #program_counter program_counter' tracker)] [(function.constant (in [..no_exceptions (bytecode input)])) []]])))) @@ -721,19 +721,19 @@ (def: (acknowledge_label stack label tracker) (-> Stack Label Tracker Tracker) - (case (dictionary.value label (get@ #known tracker)) + (case (dictionary.value label (value@ #known tracker)) (#.Some _) tracker #.None - (update@ #known (dictionary.has label [stack #.None]) tracker))) + (revised@ #known (dictionary.has label [stack #.None]) tracker))) (template [<consumption> <name> <instruction>] [(def: .public (<name> label) (-> Label (Bytecode Any)) (let [[estimator bytecode] <instruction>] (function (_ [pool environment tracker]) - (let [@here (get@ #program_counter tracker)] + (let [@here (value@ #program_counter tracker)] (do try.monad [environment' (|> environment (/environment.consumes <consumption>)) @@ -744,7 +744,7 @@ environment' (|> tracker (..acknowledge_label actual label) - (set@ #program_counter program_counter'))] + (with@ #program_counter program_counter'))] [(function (_ resolver) (do try.monad [[expected @to] (..resolve_label label resolver) @@ -787,14 +787,14 @@ (function (_ [pool environment tracker]) (do try.monad [actual (/environment.stack environment) - .let [@here (get@ #program_counter tracker)] + .let [@here (value@ #program_counter tracker)] program_counter' (step estimator @here)] (in (let [@from @here] [[pool (/environment.discontinue environment) (|> tracker (..acknowledge_label actual label) - (set@ #program_counter program_counter'))] + (with@ #program_counter program_counter'))] [(function (_ resolver) (case (dictionary.value label resolver) (#.Some [expected (#.Some @to)]) @@ -843,22 +843,22 @@ [environment' (|> environment (/environment.consumes $1)) actual (/environment.stack environment') - program_counter' (step (estimator (list.size afterwards)) (get@ #program_counter tracker))] - (in (let [@from (get@ #program_counter tracker)] + program_counter' (step (estimator (list.size afterwards)) (value@ #program_counter tracker))] + (in (let [@from (value@ #program_counter tracker)] [[pool environment' (|> (list\fold (..acknowledge_label actual) tracker (list& default at_minimum afterwards)) - (set@ #program_counter program_counter'))] + (with@ #program_counter program_counter'))] [(function (_ resolver) (let [get (: (-> Label (Maybe [Stack (Maybe Address)])) (function (_ label) (dictionary.value label resolver)))] (case (do {! maybe.monad} - [@default (|> default get (monad.bind ! product.right)) - @at_minimum (|> at_minimum get (monad.bind ! product.right)) + [@default (|> default get (monad.then ! product.right)) + @at_minimum (|> at_minimum get (monad.then ! product.right)) @afterwards (|> afterwards (monad.map ! get) - (monad.bind ! (monad.map ! product.right)))] + (monad.then ! (monad.map ! product.right)))] (in [@default @at_minimum @afterwards])) (#.Some [@default @at_minimum @afterwards]) (do {! try.monad} @@ -886,21 +886,21 @@ [environment' (|> environment (/environment.consumes $1)) actual (/environment.stack environment') - program_counter' (step (estimator (list.size cases)) (get@ #program_counter tracker))] - (in (let [@from (get@ #program_counter tracker)] + program_counter' (step (estimator (list.size cases)) (value@ #program_counter tracker))] + (in (let [@from (value@ #program_counter tracker)] [[pool environment' (|> (list\fold (..acknowledge_label actual) tracker (list& default (list\map product.right cases))) - (set@ #program_counter program_counter'))] + (with@ #program_counter program_counter'))] [(function (_ resolver) (let [get (: (-> Label (Maybe [Stack (Maybe Address)])) (function (_ label) (dictionary.value label resolver)))] (case (do {! maybe.monad} - [@default (|> default get (monad.bind ! product.right)) + [@default (|> default get (monad.then ! product.right)) @cases (|> cases (monad.map ! (|>> product.right get)) - (monad.bind ! (monad.map ! product.right)))] + (monad.then ! (monad.map ! product.right)))] (in [@default @cases])) (#.Some [@default @cases]) (do {! try.monad} diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index 6a09af8fd..54c754dc5 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -51,7 +51,7 @@ (def: .public (stack environment) (-> Environment (Try Stack)) - (case (get@ #..stack environment) + (case (value@ #..stack environment) (#.Some stack) (#try.Success stack) @@ -60,7 +60,7 @@ (def: .public discontinue (-> Environment Environment) - (set@ #..stack #.None)) + (with@ #..stack #.None)) (exception: .public (mismatched_stacks {expected Stack} {actual Stack}) @@ -70,14 +70,14 @@ (def: .public (continue expected environment) (-> Stack Environment (Try [Stack Environment])) - (case (get@ #..stack environment) + (case (value@ #..stack environment) (#.Some actual) (if (\ /stack.equivalence = expected actual) (#try.Success [actual environment]) (exception.except ..mismatched_stacks [expected actual])) #.None - (#try.Success [expected (set@ #..stack (#.Some expected) environment)]))) + (#try.Success [expected (with@ #..stack (#.Some expected) environment)]))) (def: .public (consumes amount) (-> U2 Condition) @@ -87,7 +87,7 @@ (do try.monad [previous (..stack environment) current (/stack.pop amount previous)] - (in (set@ #..stack (#.Some current) environment))))) + (in (with@ #..stack (#.Some current) environment))))) (def: .public (produces amount) (-> U2 Condition) @@ -96,13 +96,13 @@ [previous (..stack environment) current (/stack.push amount previous) .let [limit (|> environment - (get@ [#..limit #/limit.stack]) + (value@ [#..limit #/limit.stack]) (/stack.max current))]] (in (|> environment - (set@ #..stack (#.Some current)) - (set@ [#..limit #/limit.stack] limit)))))) + (with@ #..stack (#.Some current)) + (with@ [#..limit #/limit.stack] limit)))))) (def: .public (has registry) (-> Registry Condition) - (|>> (update@ [#..limit #/limit.registry] (/registry.has registry)) + (|>> (revised@ [#..limit #/limit.registry] (/registry.has registry)) #try.Success)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux index 48bdffd82..d57c07354 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux @@ -53,6 +53,6 @@ (def: .public (writer limit) (Writer Limit) ($_ format\compose - (/stack.writer (get@ #stack limit)) - (/registry.writer (get@ #registry limit)) + (/stack.writer (value@ #stack limit)) + (/registry.writer (value@ #registry limit)) )) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 7f8638dca..2e21d2a8e 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -54,7 +54,7 @@ (def: .public result (-> Instruction Specification) - (function.apply format.no_op)) + (function.on format.no_op)) (type: Opcode Nat) @@ -596,7 +596,7 @@ (///unsigned.value ..integer_size) (///unsigned.value ..integer_size) (n.* (///unsigned.value ..big_jump_size) - (inc amount_of_afterwards))) + (++ amount_of_afterwards))) ///unsigned.u2 try.trusted)))] [estimator @@ -622,7 +622,7 @@ _ (case padding 3 (do ! [_ (binary.write/8! offset 0 binary)] - (binary.write/16! (inc offset) 0 binary)) + (binary.write/16! (++ offset) 0 binary)) 2 (binary.write/16! offset 0 binary) 1 (binary.write/8! offset 0 binary) _ (in binary)) @@ -684,7 +684,7 @@ _ (case padding 3 (do ! [_ (binary.write/8! offset 0 binary)] - (binary.write/16! (inc offset) 0 binary)) + (binary.write/16! (++ offset) 0 binary)) 2 (binary.write/16! offset 0 binary) 1 (binary.write/8! offset 0 binary) _ (in binary)) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index b4cb88ec4..586cc2394 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -76,7 +76,7 @@ (monad.fold ! (function (_ interface @interfaces) (do ! [@interface (//constant/pool.class interface)] - (in (row.add @interface @interfaces)))) + (in (row.suffix @interface @interfaces)))) row.empty interfaces))] (in [@this @super @interfaces]))) @@ -95,8 +95,8 @@ (<| (state.result' //constant/pool.empty) (do //constant/pool.monad [classes (install_classes this super interfaces) - =fields (monad.seq //constant/pool.monad fields) - =methods (monad.seq //constant/pool.monad methods)] + =fields (monad.all //constant/pool.monad fields) + =methods (monad.all //constant/pool.monad methods)] (in [classes =fields =methods])))] (in {#magic //magic.code #minor_version //version.default_minor @@ -114,7 +114,7 @@ (Writer Class) (`` ($_ binaryF\compose (~~ (template [<writer> <slot>] - [(<writer> (get@ <slot> class))] + [(<writer> (value@ <slot> class))] [//magic.writer #magic] [//version.writer #minor_version] @@ -124,7 +124,7 @@ [//index.writer #this] [//index.writer #super])) (~~ (template [<writer> <slot>] - [((binaryF.row/16 <writer>) (get@ <slot> class))] + [((binaryF.row/16 <writer>) (value@ <slot> class))] [//index.writer #interfaces] [//field.writer #fields] diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index 2278889b8..346dd0f9e 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -53,7 +53,7 @@ (template: (!add <tag> <equivalence> <value>) [(function (_ [current pool]) (let [<value>' <value>] - (with_expansions [<try_again> (as_is (recur (.inc idx)))] + (with_expansions [<try_again> (as_is (recur (.++ idx)))] (loop [idx 0] (case (row.item idx pool) (#try.Success entry) @@ -77,7 +77,7 @@ (//unsigned.+/2 @new) (\ ! map //index.index)))] (in [[next - (row.add [current new] pool)] + (row.suffix [current new] pool)] current]))))))))]) (template: (!index <index>) diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index 8fed13354..1c03a5c47 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -58,7 +58,7 @@ (def: .public <maximum> <name> - (|> <bytes> (n.* i64.bits_per_byte) dec i64.mask :abstraction)) + (|> <bytes> (n.* i64.bits_per_byte) -- i64.mask :abstraction)) (def: .public <constructor> (-> Int (Try <name>)) diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux index a9d783621..b8d84170d 100644 --- a/stdlib/source/library/lux/target/jvm/field.lux +++ b/stdlib/source/library/lux/target/jvm/field.lux @@ -50,7 +50,7 @@ (Writer Field) (`` ($_ binaryF\compose (~~ (template [<writer> <slot>] - [(<writer> (get@ <slot> field))] + [(<writer> (value@ <slot> field))] [modifier.writer #modifier] [//index.writer #name] diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index 549fb8b01..3d644cf5d 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -66,13 +66,13 @@ (def: java/lang/ClassLoader::defineClass java/lang/reflect/Method (let [signature (|> (ffi.array <elemT> 4) - (ffi.array_write 0 (:as <elemT> - (ffi.class_for java/lang/String))) - (ffi.array_write 1 (java/lang/Object::getClass (ffi.array byte 0))) - (ffi.array_write 2 (:as <elemT> - (java/lang/Integer::TYPE))) - (ffi.array_write 3 (:as <elemT> - (java/lang/Integer::TYPE))))] + (ffi.write! 0 (:as <elemT> + (ffi.class_for java/lang/String))) + (ffi.write! 1 (java/lang/Object::getClass (ffi.array byte 0))) + (ffi.write! 2 (:as <elemT> + (java/lang/Integer::TYPE))) + (ffi.write! 3 (:as <elemT> + (java/lang/Integer::TYPE))))] (do_to (java/lang/Class::getDeclaredMethod "defineClass" signature (ffi.class_for java/lang/ClassLoader)) diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index 8c42130d1..e604eb3c2 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -54,7 +54,7 @@ [@name (//constant/pool.utf8 name) @descriptor (//constant/pool.descriptor (//type.descriptor type)) attributes (|> attributes - (monad.seq !) + (monad.all !) (\ ! map row.of_list)) attributes (case code (#.Some code) @@ -69,11 +69,11 @@ (function (_ _) (#try.Failure error))) [environment exceptions instruction output] (//bytecode.resolve environment code) .let [bytecode (|> instruction //bytecode/instruction.result format.instance)] - @code (//attribute.code {#//attribute/code.limit (get@ #//bytecode/environment.limit environment) + @code (//attribute.code {#//attribute/code.limit (value@ #//bytecode/environment.limit environment) #//attribute/code.code bytecode #//attribute/code.exception_table exceptions #//attribute/code.attributes (row.row)})] - (in (row.add @code attributes))) + (in (row.suffix @code attributes))) #.None (in attributes))] @@ -95,7 +95,7 @@ (Writer Method) (`` ($_ format\compose (~~ (template [<writer> <slot>] - [(<writer> (get@ <slot> field))] + [(<writer> (value@ <slot> field))] [//modifier.writer #modifier] [//index.writer #name] diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index f68b6b59d..db554e4fb 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -132,7 +132,7 @@ (#try.Success class) (#try.Failure _) - (exception.except ..unknown_class name))) + (exception.except ..unknown_class [name]))) (def: .public (sub? class_loader super sub) (-> java/lang/ClassLoader External External (Try Bit)) @@ -182,10 +182,10 @@ paramsT))) _ - (exception.except ..not_a_class raw))) + (exception.except ..not_a_class [raw]))) _) ... else - (exception.except ..cannot_convert_to_a_lux_type reflection))) + (exception.except ..cannot_convert_to_a_lux_type [reflection]))) (def: .public (parameter reflection) (-> java/lang/reflect/Type (Try (/.Type Parameter))) diff --git a/stdlib/source/library/lux/target/jvm/type/descriptor.lux b/stdlib/source/library/lux/target/jvm/type/descriptor.lux index 9c0f56021..099a68287 100644 --- a/stdlib/source/library/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/library/lux/target/jvm/type/descriptor.lux @@ -98,7 +98,7 @@ (:abstraction (format (|> inputs (list\map ..descriptor) - text.joined + text.together (text.enclosed ["(" ")"])) (:representation output)))) diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index a9021109b..99845fa7e 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -135,7 +135,7 @@ (<>.before (<text>.this //signature.parameters_end)) (<>.else (list)))] (in (do {! check.monad} - [parameters (monad.seq ! parameters)] + [parameters (monad.all ! parameters)] (in (#.Primitive name parameters))))) (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index 683ba1432..7195c4918 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -78,8 +78,13 @@ [upper ..upper_prefix] ) - (def: .public parameters_start "<") - (def: .public parameters_end ">") + (template [<char> <name>] + [(def: .public <name> + <char>)] + + ["<" parameters_start] + [">" parameters_end] + ) (def: .public (class name parameters) (-> External (List (Signature Parameter)) (Signature Class)) @@ -94,7 +99,7 @@ (format ..parameters_start (|> parameters (list\map ..signature) - text.joined) + text.together) ..parameters_end)) //descriptor.class_suffix))) @@ -130,18 +135,18 @@ (|> type_variables (list\map (|>> ..var_name (text.suffix ..class_bound))) - text.joined + text.together (text.enclosed [..parameters_start ..parameters_end]))) (|> inputs (list\map ..signature) - text.joined + text.together (text.enclosed [..arguments_start ..arguments_end])) (:representation output) (|> exceptions (list\map (|>> :representation (format ..exception_prefix))) - text.joined)))) + text.together)))) (implementation: .public equivalence (All [category] (Equivalence (Signature category))) diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index b79db8fc4..b70cf80f0 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -374,7 +374,7 @@ (syntax: (arity_inputs [arity <code>.nat]) (in (case arity 0 (.list) - _ (|> (dec arity) + _ (|> (-- arity) (enum.range n.enum 0) (list\map (|>> %.nat code.local_identifier)))))) diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 11aea7808..860c33713 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -230,7 +230,7 @@ (syntax: (arity_inputs [arity <code>.nat]) (in (case arity 0 (.list) - _ (|> (dec arity) + _ (|> (-- arity) (enum.range n.enum 0) (list\map (|>> %.nat code.local_identifier)))))) @@ -481,10 +481,10 @@ (def: (catch except) (-> Except Text) - (let [declaration (format (:representation (get@ #class except)) - " " (:representation (get@ #exception except)))] + (let [declaration (format (:representation (value@ #class except)) + " " (:representation (value@ #exception except)))] (format "catch" (..group declaration) " " - (..block (:representation (get@ #handler except)))))) + (..block (:representation (value@ #handler except)))))) (def: .public (try body! excepts) (-> Statement (List Except) Statement) diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index c8a62c58b..06ad85593 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -243,7 +243,7 @@ (format (:representation func) (format "(" (|> args (list\map (function (_ arg) (format (:representation arg) ", "))) - text.joined) + text.together) (<splat> extra) ")"))))] [apply_poly splat_poly] @@ -268,7 +268,7 @@ [do_keyword apply_keyword] ) - (def: .public (nth idx array) + (def: .public (item idx array) (-> (Expression Any) (Expression Any) Location) (:abstraction (format (:representation array) "[" (:representation idx) "]"))) @@ -409,7 +409,7 @@ (format text.new_line "except (" (text.interposed ", " (list\map ..code classes)) ") as " (:representation exception) ":" (..nested (:representation catch!))))) - text.joined)))) + text.together)))) (template [<name> <keyword> <pre>] [(def: .public (<name> value) @@ -460,7 +460,7 @@ (syntax: (arity_inputs [arity <code>.nat]) (in (case arity 0 (.list) - _ (|> (dec arity) + _ (|> (-- arity) (enum.range n.enum 0) (list\map (|>> %.nat code.local_identifier)))))) diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index 15804b77b..d5344a1c9 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -170,7 +170,7 @@ (let [func (:representation func) spacing (|> " " (list.repeated (text.size func)) - text.joined)] + text.together)] (:abstraction (format func "(" (|> args diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index 032ebb265..954a91d97 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -436,7 +436,7 @@ (syntax: (arity_inputs [arity <code>.nat]) (in (case arity 0 (.list) - _ (|> (dec arity) + _ (|> (-- arity) (enum.range n.enum 0) (list\map (|>> %.nat code.local_identifier)))))) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index 7e910a91f..4390d9981 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -341,7 +341,7 @@ (-> Var Arguments Expression Computation) (..form (list (..var "define") (|> arguments - (update@ #mandatory (|>> (#.Item name))) + (revised@ #mandatory (|>> (#.Item name))) ..arguments) body))) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index dbd87627e..29af87345 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -50,12 +50,12 @@ (def: (total parameter subject) (-> Tally Tally Tally) - {#successes (n.+ (get@ #successes parameter) (get@ #successes subject)) - #failures (n.+ (get@ #failures parameter) (get@ #failures subject)) - #expected_coverage (set.union (get@ #expected_coverage parameter) - (get@ #expected_coverage subject)) - #actual_coverage (set.union (get@ #actual_coverage parameter) - (get@ #actual_coverage subject))}) + {#successes (n.+ (value@ #successes parameter) (value@ #successes subject)) + #failures (n.+ (value@ #failures parameter) (value@ #failures subject)) + #expected_coverage (set.union (value@ #expected_coverage parameter) + (value@ #expected_coverage subject)) + #actual_coverage (set.union (value@ #actual_coverage parameter) + (value@ #actual_coverage subject))}) (def: start Tally @@ -67,7 +67,7 @@ (template [<name> <category>] [(def: <name> Tally - (update@ <category> .inc ..start))] + (revised@ <category> .++ ..start))] [success_tally #successes] [failure_tally #failures] @@ -166,7 +166,7 @@ (def: failed? (-> Tally Bit) - (|>> (get@ #failures) (n.> 0))) + (|>> (value@ #failures) (n.> 0))) (def: (times_failure seed documentation) (-> Seed Text Text) @@ -193,26 +193,26 @@ (case amount 1 instance _ (|> test - (times (dec amount)) + (times (-- amount)) (random.result prng') product.right))))]))))) (def: (description duration tally) (-> Duration Tally Text) - (let [successes (get@ #successes tally) - failures (get@ #failures tally) - missing (set.difference (get@ #actual_coverage tally) - (get@ #expected_coverage tally)) - unexpected (set.difference (get@ #expected_coverage tally) - (get@ #actual_coverage tally)) + (let [successes (value@ #successes tally) + failures (value@ #failures tally) + missing (set.difference (value@ #actual_coverage tally) + (value@ #expected_coverage tally)) + unexpected (set.difference (value@ #expected_coverage tally) + (value@ #actual_coverage tally)) report (: (-> (Set Name) Text) (|>> set.list (list.sorted (\ name.order <)) (exception.listing %.name))) - expected_definitions_to_cover (set.size (get@ #expected_coverage tally)) + expected_definitions_to_cover (set.size (value@ #expected_coverage tally)) unexpected_definitions_covered (set.size unexpected) actual_definitions_covered (n.- unexpected_definitions_covered - (set.size (get@ #actual_coverage tally))) + (set.size (value@ #actual_coverage tally))) coverage (case expected_definitions_to_cover 0 "N/A" expected (let [missing_ratio (f./ (n.frac expected) @@ -265,7 +265,7 @@ (..description duration tally) text.new_line))]] (async.future (\ program.default exit - (case (get@ #failures tally) + (case (value@ #failures tally) 0 ..success_exit_code _ ..failure_exit_code))))) @@ -277,7 +277,7 @@ coverage (set.of_list name.hash coverage)] (|> (..assertion message condition) (async\map (function (_ [tally documentation]) - [(update@ #actual_coverage (set.union coverage) tally) + [(revised@ #actual_coverage (set.union coverage) tally) documentation]))))) (def: (|cover| coverage condition) @@ -292,7 +292,7 @@ (text.interposed " & ")) coverage (set.of_list name.hash coverage)] (random\map (async\map (function (_ [tally documentation]) - [(update@ #actual_coverage (set.union coverage) tally) + [(revised@ #actual_coverage (set.union coverage) tally) documentation])) (..context context test)))) @@ -369,7 +369,7 @@ (let [coverage (..decode_coverage module coverage)] (|> (..context module test) (random\map (async\map (function (_ [tally documentation]) - [(update@ #expected_coverage (set.union coverage) tally) + [(revised@ #expected_coverage (set.union coverage) tally) documentation])))))) (syntax: .public (covering [module <code>.identifier diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index eb0928f5c..c6206e167 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -46,7 +46,7 @@ (exception: .public (time_exceeds_a_day {time Nat}) (exception.report ["Time (in milli-seconds)" (n\encode time)] - ["Maximum (in milli-seconds)" (n\encode (dec limit))])) + ["Maximum (in milli-seconds)" (n\encode (-- limit))])) (def: separator ":") @@ -66,7 +66,7 @@ (exception.report ["Value" (n\encode value)] ["Minimum" (n\encode 0)] - ["Maximum" (n\encode (dec <maximum>))])) + ["Maximum" (n\encode (-- <maximum>))])) (def: <parser> (Parser Nat) @@ -121,13 +121,13 @@ (def: &order ..order) (def: succ - (|>> :representation inc (n.% ..limit) :abstraction)) + (|>> :representation ++ (n.% ..limit) :abstraction)) (def: pred (|>> :representation (case> 0 ..limit millis millis) - dec + -- :abstraction)))) (def: .public parser @@ -197,10 +197,10 @@ (def: .public (time clock) (-> Clock (Try Time)) (|> ($_ duration.merged - (duration.up (get@ #hour clock) duration.hour) - (duration.up (get@ #minute clock) duration.minute) - (duration.up (get@ #second clock) duration.second) - (duration.of_millis (.int (get@ #milli_second clock)))) + (duration.up (value@ #hour clock) duration.hour) + (duration.up (value@ #minute clock) duration.minute) + (duration.up (value@ #second clock) duration.second) + (duration.of_millis (.int (value@ #milli_second clock)))) duration.millis .nat ..of_millis)) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index 75e5609ea..d06910711 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -95,7 +95,7 @@ (template [<name> <type> <field>] [(def: .public <name> (-> Date <type>) - (|>> :representation (get@ <field>)))] + (|>> :representation (value@ <field>)))] [year Year #year] [month Month #month] @@ -109,13 +109,13 @@ (let [reference (:representation reference) sample (:representation sample)] (and (\ //year.equivalence = - (get@ #year reference) - (get@ #year sample)) + (value@ #year reference) + (value@ #year sample)) (\ //month.equivalence = - (get@ #month reference) - (get@ #month sample)) - (n.= (get@ #day reference) - (get@ #day sample)))))) + (value@ #month reference) + (value@ #month sample)) + (n.= (value@ #day reference) + (value@ #day sample)))))) (implementation: .public order (Order Date) @@ -126,19 +126,19 @@ (let [reference (:representation reference) sample (:representation sample)] (or (\ //year.order < - (get@ #year reference) - (get@ #year sample)) + (value@ #year reference) + (value@ #year sample)) (and (\ //year.equivalence = - (get@ #year reference) - (get@ #year sample)) + (value@ #year reference) + (value@ #year sample)) (or (\ //month.order < - (get@ #month reference) - (get@ #month sample)) + (value@ #month reference) + (value@ #month sample)) (and (\ //month.order = - (get@ #month reference) - (get@ #month sample)) - (n.< (get@ #day reference) - (get@ #day sample))))))))) + (value@ #month reference) + (value@ #month sample)) + (n.< (value@ #day reference) + (value@ #day sample))))))))) ) (def: section_parser @@ -271,17 +271,17 @@ ..civil_month))) (def: last_era_leap_day - (.int (dec ..days_per_leap))) + (.int (-- ..days_per_leap))) (def: last_era_day - (.int (dec ..days_per_era))) + (.int (-- ..days_per_era))) (def: (civil_year utc_month utc_year) (-> Nat Year Int) (let [... Coercing, because the year is already in external form. utc_year (:as Int utc_year)] (if (n.< ..first_month_of_civil_year utc_month) - (dec utc_year) + (-- utc_year) utc_year))) ... http://howardhinnant.github.io/date_algorithms.html @@ -290,7 +290,7 @@ (let [utc_month (|> date ..month //month.number) civil_year (..civil_year utc_month (..year date)) era (|> (if (i.< +0 civil_year) - (i.- (.int (dec //year.era)) + (i.- (.int (-- //year.era)) civil_year) civil_year) (i./ (.int //year.era))) @@ -299,7 +299,7 @@ civil_year) day_of_year (|> utc_month ..day_of_year_from_month - (i.+ (.int (dec (..day_of_month date))))) + (i.+ (.int (-- (..day_of_month date))))) day_of_era (|> day_of_year (i.+ (i.* (.int //year.days) year_of_era)) (i.+ (i./ (.int //year.leap) year_of_era)) @@ -334,7 +334,7 @@ (i.+ +1) .nat) year (if (n.< ..first_month_of_civil_year month) - (inc year) + (++ year) year)] ... Coercing, because the year is already in internal form. (try.trusted @@ -348,7 +348,7 @@ (def: &order ..order) (def: succ - (|>> ..days inc ..of_days)) + (|>> ..days ++ ..of_days)) (def: pred - (|>> ..days dec ..of_days))) + (|>> ..days -- ..of_days))) diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index 36e0b2504..f454c1425 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -102,7 +102,7 @@ (let [[days millis] (i./% ..millis_per_day offset)] (case millis +0 [days millis] - _ [(dec days) (i.+ ..millis_per_day millis)])) + _ [(-- days) (i.+ ..millis_per_day millis)])) (i./% ..millis_per_day offset))] [(date.of_days days) (duration.of_millis day_time)])) @@ -214,7 +214,7 @@ day_time (duration.framed duration.day offset) days (if (and (duration.negative? offset) (not (duration.neutral? day_time))) - (dec days) + (-- days) days) ... 1970/01/01 was a Thursday y1970m0d0 +4] diff --git a/stdlib/source/library/lux/time/month.lux b/stdlib/source/library/lux/time/month.lux index d8203e175..07fcc6269 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -184,7 +184,7 @@ {#.doc (example "The amount of days of a month (in a leap year).")} (-> Month Nat) (case month - #February (inc (..days month)) + #February (++ (..days month)) _ (..days month))) (def: .public year diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index dd303ed85..3eb12ad90 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -23,14 +23,14 @@ (def: (internal year) (-> Int Int) (if (i.< +0 year) - (inc year) + (++ year) year)) (def: (external year) (-> Int Int) (if (i.> +0 year) year - (dec year))) + (-- year))) (exception: .public there_is_no_year_0) @@ -100,8 +100,8 @@ (-> Year Int) (let [year (|> year ..value ..internal) limit (if (i.> +0 year) - (dec year) - (inc year))] + (-- year) + (++ year))] (`` (|> +0 (~~ (template [<polarity> <years>] [(<polarity> (i./ (.int <years>) limit))] diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index e8b91db8c..04971dadd 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -107,8 +107,8 @@ (#.Right [source' output]) (let [[location _] output] (#try.Success [[bundle (|> compiler - (set@ #.source source') - (set@ #.location location))] + (with@ #.source source') + (with@ #.location location))] [source' output]]))))) (type: (Operation a) @@ -125,13 +125,13 @@ (///directive.Operation anchor expression directive [Source (Payload directive)]))) (do ///phase.monad - [.let [module (get@ #///.module input)] + [.let [module (value@ #///.module input)] _ (///directive.set_current_module module)] (///directive.lifted_analysis (do {! ///phase.monad} [_ (module.create hash module) _ (monad.map ! module.import dependencies) - .let [source (///analysis.source (get@ #///.module input) (get@ #///.code input))] + .let [source (///analysis.source (value@ #///.module input) (value@ #///.code input))] _ (///analysis.set_source_code source)] (in [source [///generation.empty_buffer artifact.empty]]))))) @@ -220,13 +220,13 @@ (def: (default_dependencies prelude input) (-> Module ///.Input (List Module)) (list& archive.runtime_module - (if (text\= prelude (get@ #///.module input)) + (if (text\= prelude (value@ #///.module input)) (list) (list prelude)))) (def: module_aliases (-> .Module Aliases) - (|>> (get@ #.module_aliases) (dictionary.of_list text.hash))) + (|>> (value@ #.module_aliases) (dictionary.of_list text.hash))) (def: .public (compiler expander prelude write_directive) (All [anchor expression directive] @@ -238,10 +238,10 @@ {#///.dependencies dependencies #///.process (function (_ state archive) (do {! try.monad} - [.let [hash (text\hash (get@ #///.code input))] + [.let [hash (text\hash (value@ #///.code input))] [state [source buffer]] (<| (///phase.result' state) (..begin dependencies hash input)) - .let [module (get@ #///.module input)]] + .let [module (value@ #///.module input)]] (loop [iteration (<| (///phase.result' state) (..iteration archive expander module source buffer ///syntax.no_aliases))] (do ! @@ -252,7 +252,7 @@ [[state [analysis_module [final_buffer final_registry]]] (///phase.result' state (..end module)) .let [descriptor {#descriptor.hash hash #descriptor.name module - #descriptor.file (get@ #///.file input) + #descriptor.file (value@ #///.file input) #descriptor.references (set.of_list text.hash dependencies) #descriptor.state #.Compiled #descriptor.registry final_registry}]] @@ -267,7 +267,7 @@ (let [[temporary_buffer temporary_registry] temporary_payload] (in [state (#.Left {#///.dependencies (|> requirements - (get@ #///directive.imports) + (value@ #///directive.imports) (list\map product.left)) #///.process (function (_ state archive) (recur (<| (///phase.result' state) @@ -281,7 +281,7 @@ _ (///directive.lifted_generation (///generation.set_registry temporary_registry)) _ (|> requirements - (get@ #///directive.referrals) + (value@ #///directive.referrals) (monad.map ! (execute! archive))) temporary_payload (..get_current_payload temporary_payload)] (..iteration archive expander module source temporary_payload (..module_aliases analysis_module))))))})])) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index 53cb07e22..1ac28821f 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -97,7 +97,7 @@ (All [<type_vars>] (-> Static <Platform> archive.ID [Descriptor (Document Any) Output] (Async (Try Any)))) - (let [system (get@ #&file_system platform) + (let [system (value@ #&file_system platform) write_artifact! (: (-> [artifact.ID (Maybe Text) Binary] (Action Any)) (function (_ [artifact_id custom content]) (ioW.write system static module_id artifact_id content)))] @@ -129,7 +129,7 @@ (-> <Platform> (///generation.Operation <type_vars> [Registry Output]))) (do ///phase.monad [_ ..initialize_buffer!] - (get@ #runtime platform))) + (value@ #runtime platform))) (def: (runtime_descriptor registry) (-> Registry Descriptor) @@ -198,7 +198,7 @@ (def: (phase_wrapper archive platform state) (All [<type_vars>] (-> Archive <Platform> <State+> (Try [<State+> Phase_Wrapper]))) - (let [phase_wrapper (get@ #phase_wrapper platform)] + (let [phase_wrapper (value@ #phase_wrapper platform)] (|> archive phase_wrapper ///directive.lifted_generation @@ -236,15 +236,15 @@ Import (List Context) (Async (Try [<State+> Archive])))) (do {! (try.with async.monad)} - [.let [state (//init.state (get@ #static.host static) + [.let [state (//init.state (value@ #static.host static) module expander host_analysis - (get@ #host platform) - (get@ #phase platform) + (value@ #host platform) + (value@ #phase platform) generation_bundle)] - _ (ioW.enable (get@ #&file_system platform) static) - [archive analysis_state bundles] (ioW.thaw (get@ #host platform) (get@ #&file_system platform) static import compilation_sources) + _ (ioW.enable (value@ #&file_system platform) static) + [archive analysis_state bundles] (ioW.thaw (value@ #host platform) (value@ #&file_system platform) static import compilation_sources) .let [with_missing_extensions (: (All [<type_vars>] (-> <Platform> (Program expression directive) <State+> (Async (Try <State+>)))) @@ -276,11 +276,11 @@ (def: (module_compilation_log module) (All [<type_vars>] (-> Module <State+> Text)) - (|>> (get@ [#extension.state - #///directive.generation - #///directive.state - #extension.state - #///generation.log]) + (|>> (value@ [#extension.state + #///directive.generation + #///directive.state + #extension.state + #///generation.log]) (row\fold (function (_ right left) (format left ..compilation_log_separator right)) module))) @@ -288,12 +288,12 @@ (def: with_reset_log (All [<type_vars>] (-> <State+> <State+>)) - (set@ [#extension.state - #///directive.generation - #///directive.state - #extension.state - #///generation.log] - row.empty)) + (with@ [#extension.state + #///directive.generation + #///directive.state + #extension.state + #///generation.log] + row.empty)) (def: empty (Set Module) @@ -320,8 +320,8 @@ lens (dictionary.value module) (maybe.else ..empty)))) - transitive_depends_on (transitive_dependency (get@ #depends_on) import) - transitive_depended_by (transitive_dependency (get@ #depended_by) module) + transitive_depends_on (transitive_dependency (value@ #depends_on) import) + transitive_depended_by (transitive_dependency (value@ #depended_by) module) update_dependence (: (-> [Module (Set Module)] [Module (Set Module)] (-> Mapping Mapping)) (function (_ [source forward] [target backward]) @@ -335,14 +335,14 @@ with_dependence+transitives (set.list backward))))))] (|> dependence - (update@ #depends_on - (update_dependence - [module transitive_depends_on] - [import transitive_depended_by])) - (update@ #depended_by - ((function.flipped update_dependence) - [module transitive_depends_on] - [import transitive_depended_by]))))) + (revised@ #depends_on + (update_dependence + [module transitive_depends_on] + [import transitive_depended_by])) + (revised@ #depended_by + ((function.flipped update_dependence) + [module transitive_depends_on] + [import transitive_depended_by]))))) (def: (circular_dependency? module import dependence) (-> Module Module Dependence Bit) @@ -353,8 +353,8 @@ (dictionary.value from) (maybe.else ..empty))] (set.member? targets to))))] - (or (dependence? import (get@ #depends_on) module) - (dependence? module (get@ #depended_by) import)))) + (or (dependence? import (value@ #depends_on) module) + (dependence? module (value@ #depended_by) import)))) (exception: .public (module_cannot_import_itself {module Module}) (exception.report @@ -499,21 +499,21 @@ .let [additions (|> modules (list\map product.left) (set.of_list text.hash))]] - (in (update@ [#extension.state - #///directive.analysis - #///directive.state - #extension.state] - (function (_ analysis_state) - (|> analysis_state - (:as .Lux) - (update@ #.modules (function (_ current) - (list\compose (list.only (|>> product.left - (set.member? additions) - not) - current) - modules))) - :expected)) - state)))) + (in (revised@ [#extension.state + #///directive.analysis + #///directive.state + #extension.state] + (function (_ analysis_state) + (|> analysis_state + (:as .Lux) + (revised@ #.modules (function (_ current) + (list\compose (list.only (|>> product.left + (set.member? additions) + not) + current) + modules))) + :expected)) + state)))) (def: (set_current_module module state) (All [<type_vars>] @@ -533,24 +533,24 @@ (///.Compiler <State+> .Module Any) (:expected - ((//init.compiler expander syntax.prelude (get@ #write platform)) $.key (list)))) + ((//init.compiler expander syntax.prelude (value@ #write platform)) $.key (list)))) compiler (..parallel context (function (_ importer import! module_id [archive state] module) (do {! (try.with async.monad)} [.let [state (..set_current_module module state)] - input (context.read (get@ #&file_system platform) + input (context.read (value@ #&file_system platform) importer import compilation_sources - (get@ #static.host_module_extension static) + (value@ #static.host_module_extension static) module)] (loop [[archive state] [archive state] compilation (base_compiler (:as ///.Input input)) all_dependencies (: (Set Module) (set.of_list text.hash (list)))] (do ! - [.let [new_dependencies (get@ #///.dependencies compilation) + [.let [new_dependencies (value@ #///.dependencies compilation) continue! (:sharing [<type_vars>] <Platform> platform @@ -582,14 +582,14 @@ (do ! [archive,document+ (|> new_dependencies (list\map (import! module)) - (monad.seq ..monad)) + (monad.all ..monad)) .let [archive (|> archive,document+ (list\map product.left) (list\fold archive.merged archive))]] (in [archive (try.trusted (..updated_state archive state))]))) (async\in (exception.except ..cannot_import_twice [module duplicates])))] - (case ((get@ #///.process compilation) + (case ((value@ #///.process compilation) ... TODO: The "///directive.set_current_module" below shouldn't be necessary. Remove it ASAP. ... TODO: The context shouldn't need to be re-set either. (|> (///directive.set_current_module module) @@ -605,7 +605,7 @@ (#.Right [descriptor document output]) (do ! [.let [_ (debug.log! (..module_compilation_log module state)) - descriptor (set@ #descriptor.references all_dependencies descriptor)] + descriptor (with@ #descriptor.references all_dependencies descriptor)] _ (..cache_module static platform module_id [descriptor document output])] (case (archive.has module [descriptor document output] archive) (#try.Success archive) @@ -617,7 +617,7 @@ (#try.Failure error) (do ! - [_ (ioW.freeze (get@ #&file_system platform) static archive)] + [_ (ioW.freeze (value@ #&file_system platform) static archive)] (async\in (#try.Failure error)))))))))] (compiler archive.runtime_module compilation_module))) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux index 571185dee..aefd908c4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -55,18 +55,18 @@ (def: .public (tag lefts right?) (-> Nat Bit Nat) (if right? - (inc lefts) + (++ lefts) lefts)) (def: (lefts tag right?) (-> Nat Bit Nat) (if right? - (dec tag) + (-- tag) tag)) (def: .public (choice options pick) (-> Nat Nat [Nat Bit]) - (let [right? (n.= (dec options) pick)] + (let [right? (n.= (-- options) pick)] [(..lefts pick right?) right?])) @@ -253,7 +253,7 @@ (def: (last? size tag) (-> Nat Tag Bit) - (n.= (dec size) tag)) + (n.= (-- size) tag)) (template: .public (no_op value) [(|> 1 #variable.Local #reference.Variable #..Reference @@ -402,10 +402,10 @@ (def: .public (with_source_code source action) (All [a] (-> Source (Operation a) (Operation a))) (function (_ [bundle state]) - (let [old_source (get@ #.source state)] - (case (action [bundle (set@ #.source source state)]) + (let [old_source (value@ #.source state)] + (case (action [bundle (with@ #.source source state)]) (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (set@ #.source old_source state')] + (#try.Success [[bundle' (with@ #.source old_source state')] output]) (#try.Failure error) @@ -426,11 +426,11 @@ (def: .public (with_scope action) (All [a] (-> (Operation a) (Operation [Scope a]))) (function (_ [bundle state]) - (case (action [bundle (update@ #.scopes (|>> (#.Item fresh_scope)) state)]) + (case (action [bundle (revised@ #.scopes (|>> (#.Item fresh_scope)) state)]) (#try.Success [[bundle' state'] output]) - (case (get@ #.scopes state') + (case (value@ #.scopes state') (#.Item head tail) - (#try.Success [[bundle' (set@ #.scopes tail state')] + (#try.Success [[bundle' (with@ #.scopes tail state')] [head output]]) #.End @@ -441,8 +441,8 @@ (def: .public (with_current_module name) (All [a] (-> Text (Operation a) (Operation a))) - (extension.localized (get@ #.current_module) - (set@ #.current_module) + (extension.localized (value@ #.current_module) + (with@ #.current_module) (function.constant (#.Some name)))) (def: .public (with_location location action) @@ -450,10 +450,10 @@ (if (text\= "" (product.left location)) action (function (_ [bundle state]) - (let [old_location (get@ #.location state)] - (case (action [bundle (set@ #.location location state)]) + (let [old_location (value@ #.location state)] + (case (action [bundle (with@ #.location location state)]) (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (set@ #.location old_location state')] + (#try.Success [[bundle' (with@ #.location old_location state')] output]) (#try.Failure error) @@ -467,7 +467,7 @@ (def: .public (failure error) (-> Text Operation) (function (_ [bundle state]) - (#try.Failure (locate_error (get@ #.location state) error)))) + (#try.Failure (locate_error (value@ #.location state) error)))) (def: .public (except exception parameters) (All [e] (-> (Exception e) e Operation)) @@ -482,7 +482,7 @@ (def: .public (failure' error) (-> Text (phase.Operation Lux)) (function (_ state) - (#try.Failure (locate_error (get@ #.location state) error)))) + (#try.Failure (locate_error (value@ #.location state) error)))) (def: .public (except' exception parameters) (All [e] (-> (Exception e) e (phase.Operation Lux))) @@ -498,7 +498,7 @@ (#try.Failure error) (let [[bundle state] bundle,state] - (#try.Failure (locate_error (get@ #.location state) error)))))) + (#try.Failure (locate_error (value@ #.location state) error)))))) (def: .public (install state) (-> .Lux (Operation Any)) @@ -509,7 +509,7 @@ (template [<name> <type> <field> <value>] [(def: .public (<name> value) (-> <type> (Operation Any)) - (extension.update (set@ <field> <value>)))] + (extension.update (with@ <field> <value>)))] [set_source_code Source #.source value] [set_current_module Text #.current_module (#.Some value)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux index 478697fd4..5f2770068 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux @@ -47,8 +47,8 @@ (def: .public (merge_requirements left right) (-> Requirements Requirements Requirements) - {#imports (list\compose (get@ #imports left) (get@ #imports right)) - #referrals (list\compose (get@ #referrals left) (get@ #referrals right))}) + {#imports (list\compose (value@ #imports left) (value@ #imports right)) + #referrals (list\compose (value@ #referrals left) (value@ #referrals right))}) (template [<special> <general>] [(type: .public (<special> anchor expression directive) @@ -66,7 +66,7 @@ (All [anchor expression directive] (Operation anchor expression directive <phase>)) (function (_ [bundle state]) - (#try.Success [[bundle state] (get@ [<component> #..phase] state)])))] + (#try.Success [[bundle state] (value@ [<component> #..phase] state)])))] [analysis #..analysis analysis.Phase] [synthesis #..synthesis synthesis.Phase] @@ -78,8 +78,8 @@ (All [anchor expression directive output] (-> (<operation> output) (Operation anchor expression directive output))) - (|>> (phase.sub [(get@ [<component> #..state]) - (set@ [<component> #..state])]) + (|>> (phase.sub [(value@ [<component> #..state]) + (with@ [<component> #..state])]) extension.lifted))] [lifted_analysis #..analysis analysis.Operation] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index 0a1841ad1..aee61ebc7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -111,9 +111,9 @@ (All [anchor expression directive output] <with_type>) (function (_ body) (function (_ [bundle state]) - (case (body [bundle (set@ <tag> (#.Some <with_value>) state)]) + (case (body [bundle (with@ <tag> (#.Some <with_value>) state)]) (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (set@ <tag> (get@ <tag> state) state')] + (#try.Success [[bundle' (with@ <tag> (value@ <tag> state) state')] output]) (#try.Failure error) @@ -123,7 +123,7 @@ (All [anchor expression directive] (Operation anchor expression directive <get_type>)) (function (_ (^@ stateE [bundle state])) - (case (get@ <tag> state) + (case (value@ <tag> state) (#.Some output) (#try.Success [stateE output]) @@ -134,7 +134,7 @@ (All [anchor expression directive] (-> <get_type> (Operation anchor expression directive Any))) (function (_ [bundle state]) - (#try.Success [[bundle (set@ <tag> (#.Some value) state)] + (#try.Success [[bundle (with@ <tag> (#.Some value) state)] []])))] [#anchor @@ -156,21 +156,21 @@ (All [anchor expression directive] (Operation anchor expression directive artifact.Registry)) (function (_ (^@ stateE [bundle state])) - (#try.Success [stateE (get@ #registry state)]))) + (#try.Success [stateE (value@ #registry state)]))) (def: .public (set_registry value) (All [anchor expression directive] (-> artifact.Registry (Operation anchor expression directive Any))) (function (_ [bundle state]) - (#try.Success [[bundle (set@ #registry value state)] + (#try.Success [[bundle (with@ #registry value state)] []]))) (def: .public next (All [anchor expression directive] (Operation anchor expression directive Nat)) (do phase.monad - [count (extension.read (get@ #counter)) - _ (extension.update (update@ #counter inc))] + [count (extension.read (value@ #counter)) + _ (extension.update (revised@ #counter ++))] (in count))) (def: .public (identifier prefix) @@ -181,18 +181,18 @@ (def: .public (enter_module module) (All [anchor expression directive] (-> Module (Operation anchor expression directive Any))) - (extension.update (set@ #module module))) + (extension.update (with@ #module module))) (def: .public module (All [anchor expression directive] (Operation anchor expression directive Module)) - (extension.read (get@ #module))) + (extension.read (value@ #module))) (def: .public (evaluate! label code) (All [anchor expression directive] (-> Context expression (Operation anchor expression directive Any))) (function (_ (^@ state+ [bundle state])) - (case (\ (get@ #host state) evaluate! label code) + (case (\ (value@ #host state) evaluate! label code) (#try.Success output) (#try.Success [state+ output]) @@ -203,7 +203,7 @@ (All [anchor expression directive] (-> directive (Operation anchor expression directive Any))) (function (_ (^@ state+ [bundle state])) - (case (\ (get@ #host state) execute! code) + (case (\ (value@ #host state) execute! code) (#try.Success output) (#try.Success [state+ output]) @@ -214,7 +214,7 @@ (All [anchor expression directive] (-> Context (Maybe Text) expression (Operation anchor expression directive [Text Any directive]))) (function (_ (^@ stateE [bundle state])) - (case (\ (get@ #host state) define! context custom code) + (case (\ (value@ #host state) define! context custom code) (#try.Success output) (#try.Success [stateE output]) @@ -225,13 +225,13 @@ (All [anchor expression directive] (-> artifact.ID (Maybe Text) directive (Operation anchor expression directive Any))) (do {! phase.monad} - [?buffer (extension.read (get@ #buffer))] + [?buffer (extension.read (value@ #buffer))] (case ?buffer (#.Some buffer) ... TODO: Optimize by no longer checking for overwrites... (if (row.any? (|>> product.left (n.= artifact_id)) buffer) (phase.except ..cannot_overwrite_output [artifact_id]) - (extension.update (set@ #buffer (#.Some (row.add [artifact_id custom code] buffer))))) + (extension.update (with@ #buffer (#.Some (row.suffix [artifact_id custom code] buffer))))) #.None (phase.except ..no_buffer_for_saving_code [artifact_id])))) @@ -241,8 +241,8 @@ (All [anchor expression directive] (-> Text (Operation anchor expression directive artifact.ID))) (function (_ (^@ stateE [bundle state])) - (let [[id registry'] (<artifact> name (get@ #registry state))] - (#try.Success [[bundle (set@ #registry registry' state)] + (let [[id registry'] (<artifact> name (value@ #registry state))] + (#try.Success [[bundle (with@ #registry registry' state)] id]))))] [learn artifact.definition] @@ -267,11 +267,11 @@ (let [[_module _name] name] (do try.monad [module_id (archive.id _module archive) - registry (if (text\= (get@ #module state) _module) - (#try.Success (get@ #registry state)) + registry (if (text\= (value@ #module state) _module) + (#try.Success (value@ #registry state)) (do try.monad [[descriptor document] (archive.find _module archive)] - (#try.Success (get@ #descriptor.registry descriptor))))] + (#try.Success (value@ #descriptor.registry descriptor))))] (case (artifact.remember _name registry) #.None (exception.except ..unknown_definition [name (artifact.definitions registry)]) @@ -293,13 +293,13 @@ (All [anchor expression directive] (-> Archive (Operation anchor expression directive Context))) (function (_ (^@ stateE [bundle state])) - (case (get@ #context state) + (case (value@ #context state) #.None (exception.except ..no_context []) (#.Some id) (do try.monad - [module_id (archive.id (get@ #module state) archive)] + [module_id (archive.id (value@ #module state) archive)] (in [stateE [module_id id]]))))) (def: .public (with_context id body) @@ -309,8 +309,8 @@ (Operation anchor expression directive a))) (function (_ [bundle state]) (do try.monad - [[[bundle' state'] output] (body [bundle (set@ #context (#.Some id) state)])] - (in [[bundle' (set@ #context (get@ #context state) state')] + [[[bundle' state'] output] (body [bundle (with@ #context (#.Some id) state)])] + (in [[bundle' (with@ #context (value@ #context state) state')] output])))) (def: .public (with_new_context archive body) @@ -318,13 +318,13 @@ (-> Archive (Operation anchor expression directive a) (Operation anchor expression directive [Context a]))) (function (_ (^@ stateE [bundle state])) - (let [[id registry'] (artifact.resource (get@ #registry state))] + (let [[id registry'] (artifact.resource (value@ #registry state))] (do try.monad [[[bundle' state'] output] (body [bundle (|> state - (set@ #registry registry') - (set@ #context (#.Some id)))]) - module_id (archive.id (get@ #module state) archive)] - (in [[bundle' (set@ #context (get@ #context state) state')] + (with@ #registry registry') + (with@ #context (#.Some id)))]) + module_id (archive.id (value@ #module state) archive)] + (in [[bundle' (with@ #context (value@ #context state) state')] [[module_id id] output]]))))) @@ -333,5 +333,5 @@ (-> Text (Operation anchor expression directive Any))) (function (_ [bundle state]) (#try.Success [[bundle - (update@ #log (row.add message) state)] + (revised@ #log (row.suffix message) state)] []]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux index c8cfe9c0e..ee12a8bf0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux @@ -124,10 +124,10 @@ (compile archive expansion)) _ - (/function.apply compile argsC+ functionT functionA archive functionC))) + (/function.on compile argsC+ functionT functionA archive functionC))) _ - (/function.apply compile argsC+ functionT functionA archive functionC))) + (/function.on compile argsC+ functionT functionA archive functionC))) _ (//.except ..unrecognized_syntax [location.dummy code']))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux index 9463eeb8f..b3642f5f3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -193,20 +193,28 @@ [inputT' (simplify_case inputT)] (.case inputT' (#.Product _) - (let [subs (type.flat_tuple inputT') - num_subs (maybe.else (list.size subs) - num_tags) - num_sub_patterns (list.size sub_patterns) - matches (cond (n.< num_subs num_sub_patterns) - (let [[prefix suffix] (list.split_at (dec num_sub_patterns) subs)] - (list.zipped/2 (list\compose prefix (list (type.tuple suffix))) sub_patterns)) - - (n.> num_subs num_sub_patterns) - (let [[prefix suffix] (list.split_at (dec num_subs) sub_patterns)] - (list.zipped/2 subs (list\compose prefix (list (code.tuple suffix))))) - - ... (n.= num_subs num_sub_patterns) - (list.zipped/2 subs sub_patterns))] + (let [matches (loop [types (type.flat_tuple inputT') + patterns sub_patterns + output (: (List [Type Code]) + #.End)] + (.case [types patterns] + [#.End #.End] + output + + [(#.Item headT #.End) (#.Item headP #.End)] + (#.Item [headT headP] output) + + [remainingT (#.Item headP #.End)] + (#.Item [(type.tuple remainingT) headP] output) + + [(#.Item headT #.End) remainingP] + (#.Item [headT (code.tuple remainingP)] output) + + [(#.Item headT tailT) (#.Item headP tailP)] + (recur tailT tailP (#.Item [headT headP] output)) + + _ + (undefined)))] (do ! [[memberP+ thenA] (list\fold (: (All [a] (-> [Type Code] (Operation [(List Pattern) a]) @@ -220,7 +228,7 @@ (do ! [nextA next] (in [(list) nextA])) - (list.reversed matches))] + matches)] (in [(/.pattern/tuple memberP+) thenA]))) @@ -231,7 +239,7 @@ [location (#.Record record)] (do ///.monad [record (//structure.normal record) - [members recordT] (//structure.order record) + [record_size members recordT] (//structure.order record) _ (.case inputT (#.Var _id) (//type.with_env @@ -239,7 +247,7 @@ _ (in []))] - (analyse_pattern (#.Some (list.size members)) inputT [location (#.Tuple members)] next)) + (analyse_pattern (#.Some record_size) inputT [location (#.Tuple members)] next)) [location (#.Tag tag)] (/.with_location location @@ -260,9 +268,9 @@ (n.< num_cases idx)) (do ///.monad [[testP nextA] (if (and (n.> num_cases size_sum) - (n.= (dec num_cases) idx)) + (n.= (-- num_cases) idx)) (analyse_pattern #.None - (type.variant (list.after (dec num_cases) flat_sum)) + (type.variant (list.after (-- num_cases) flat_sum)) (` [(~+ values)]) next) (analyse_pattern #.None caseT (` [(~+ values)]) next))] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux index 25c85514e..e7efacf3c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux @@ -146,7 +146,7 @@ (do ////.monad [value_coverage (determine value) .let [idx (if right? - (inc lefts) + (++ lefts) lefts)]] (in (#Variant (if right? (#.Some idx) @@ -256,7 +256,7 @@ casesSF (dictionary.entries casesA))] (in (if (and (or (known_cases? addition_cases) (known_cases? so_far_cases)) - (n.= (inc (n.max addition_cases so_far_cases)) + (n.= (++ (n.max addition_cases so_far_cases)) (dictionary.size casesM)) (list.every? exhaustive? (dictionary.values casesM))) #Exhaustive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux index 6282980be..0420b7811 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux @@ -10,7 +10,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor)]]] + ["." list ("#\." functor monoid)]]] [math [number ["n" nat]]] @@ -204,16 +204,16 @@ base))) ... Turns a record type into the kind of function type suitable for inference. -(def: (record' target originalT inferT) - (-> Nat Type Type (Operation Type)) +(def: (record' record_size target originalT inferT) + (-> Nat Nat Type Type (Operation Type)) (case inferT (#.Named name unnamedT) - (record' target originalT unnamedT) + (record' record_size target originalT unnamedT) (^template [<tag>] [(<tag> env bodyT) (do ///.monad - [bodyT+ (record' (n.+ 2 target) originalT bodyT)] + [bodyT+ (record' record_size (n.+ 2 target) originalT bodyT)] (in (<tag> env bodyT+)))]) ([#.UnivQ] [#.ExQ]) @@ -221,22 +221,23 @@ (#.Apply inputT funcT) (case (type.applied (list inputT) funcT) (#.Some outputT) - (record' target originalT outputT) + (record' record_size target originalT outputT) #.None (/.except ..invalid_type_application inferT)) (#.Product _) - (///\in (|> inferT - (type.function (type.flat_tuple inferT)) - (substitute_bound target originalT))) + (let [[lefts right] (list.split_at (-- record_size) (type.flat_tuple inferT))] + (///\in (|> inferT + (type.function (list\compose lefts (list (type.tuple right)))) + (substitute_bound target originalT)))) _ (/.except ..not_a_record_type inferT))) -(def: .public (record inferT) - (-> Type (Operation Type)) - (record' (n.- 2 0) inferT inferT)) +(def: .public (record record_size inferT) + (-> Nat Type (Operation Type)) + (record' record_size (n.- 2 0) inferT inferT)) ... Turns a variant type into the kind of function type suitable for inference. (def: .public (variant tag expected_size inferT) @@ -252,7 +253,7 @@ (^template [<tag>] [(<tag> env bodyT) (do ///.monad - [bodyT+ (recur (inc depth) bodyT)] + [bodyT+ (recur (++ depth) bodyT)] (in (<tag> env bodyT+)))]) ([#.UnivQ] [#.ExQ]) @@ -260,7 +261,7 @@ (#.Sum _) (let [cases (type.flat_variant currentT) actual_size (list.size cases) - boundary (dec expected_size)] + boundary (-- expected_size)] (cond (or (n.= expected_size actual_size) (and (n.> expected_size actual_size) (n.< boundary tag))) @@ -268,7 +269,7 @@ (#.Some caseT) (///\in (if (n.= 0 depth) (type.function (list caseT) currentT) - (let [replace' (replace (|> depth dec (n.* 2)) inferT)] + (let [replace' (replace (|> depth -- (n.* 2)) inferT)] (type.function (list (replace' caseT)) (replace' currentT))))) @@ -282,7 +283,7 @@ (let [caseT (type.variant (list.after boundary cases))] (///\in (if (n.= 0 depth) (type.function (list caseT) currentT) - (let [replace' (replace (|> depth dec (n.* 2)) inferT)] + (let [replace' (replace (|> depth -- (n.* 2)) inferT)] (type.function (list (replace' caseT)) (replace' currentT)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux index d5e2fd691..14e08a4c0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux @@ -84,12 +84,12 @@ (do ///.monad [self_name meta.current_module_name self meta.current_module] - (case (get@ #.module_annotations self) + (case (value@ #.module_annotations self) #.None (function (_ state) - (#try.Success [(update@ #.modules - (plist.has self_name (set@ #.module_annotations (#.Some annotations) self)) - state) + (#try.Success [(revised@ #.modules + (plist.has self_name (with@ #.module_annotations (#.Some annotations) self)) + state) []])) (#.Some old) @@ -101,13 +101,13 @@ (do ///.monad [self_name meta.current_module_name] (function (_ state) - (#try.Success [(update@ #.modules - (plist.revised self_name (update@ #.imports (function (_ current) - (if (list.any? (text\= module) - current) - current - (#.Item module current))))) - state) + (#try.Success [(revised@ #.modules + (plist.revised self_name (revised@ #.imports (function (_ current) + (if (list.any? (text\= module) + current) + current + (#.Item module current))))) + state) []]))))) (def: .public (alias alias module) @@ -116,10 +116,10 @@ (do ///.monad [self_name meta.current_module_name] (function (_ state) - (#try.Success [(update@ #.modules - (plist.revised self_name (update@ #.module_aliases (: (-> (List [Text Text]) (List [Text Text])) - (|>> (#.Item [alias module]))))) - state) + (#try.Success [(revised@ #.modules + (plist.revised self_name (revised@ #.module_aliases (: (-> (List [Text Text]) (List [Text Text])) + (|>> (#.Item [alias module]))))) + state) []]))))) (def: .public (exists? module) @@ -127,7 +127,7 @@ (///extension.lifted (function (_ state) (|> state - (get@ #.modules) + (value@ #.modules) (plist.value module) (case> (#.Some _) #1 #.None #0) [state] #try.Success)))) @@ -139,15 +139,15 @@ [self_name meta.current_module_name self meta.current_module] (function (_ state) - (case (plist.value name (get@ #.definitions self)) + (case (plist.value name (value@ #.definitions self)) #.None - (#try.Success [(update@ #.modules - (plist.has self_name - (update@ #.definitions - (: (-> (List [Text Global]) (List [Text Global])) - (|>> (#.Item [name definition]))) - self)) - state) + (#try.Success [(revised@ #.modules + (plist.has self_name + (revised@ #.definitions + (: (-> (List [Text Global]) (List [Text Global])) + (|>> (#.Item [name definition]))) + self)) + state) []]) (#.Some already_existing) @@ -157,9 +157,9 @@ (-> Nat Text (Operation Any)) (///extension.lifted (function (_ state) - (#try.Success [(update@ #.modules - (plist.has name (..empty hash)) - state) + (#try.Success [(revised@ #.modules + (plist.has name (..empty hash)) + state) []])))) (def: .public (with_module hash name action) @@ -176,15 +176,15 @@ (-> Text (Operation Any)) (///extension.lifted (function (_ state) - (case (|> state (get@ #.modules) (plist.value module_name)) + (case (|> state (value@ #.modules) (plist.value module_name)) (#.Some module) - (let [active? (case (get@ #.module_state module) + (let [active? (case (value@ #.module_state module) #.Active #1 _ #0)] (if active? - (#try.Success [(update@ #.modules - (plist.has module_name (set@ #.module_state <tag> module)) - state) + (#try.Success [(revised@ #.modules + (plist.has module_name (with@ #.module_state <tag> module)) + state) []]) ((/.except' can_only_change_state_of_active_module [module_name <tag>]) state))) @@ -196,10 +196,10 @@ (-> Text (Operation Bit)) (///extension.lifted (function (_ state) - (case (|> state (get@ #.modules) (plist.value module_name)) + (case (|> state (value@ #.modules) (plist.value module_name)) (#.Some module) (#try.Success [state - (case (get@ #.module_state module) + (case (value@ #.module_state module) <tag> #1 _ #0)]) @@ -216,9 +216,9 @@ (-> Text (Operation <type>)) (///extension.lifted (function (_ state) - (case (|> state (get@ #.modules) (plist.value module_name)) + (case (|> state (value@ #.modules) (plist.value module_name)) (#.Some module) - (#try.Success [state (get@ <tag> module)]) + (#try.Success [state (value@ <tag> module)]) #.None ((/.except' unknown_module module_name) state)))))] @@ -258,18 +258,18 @@ (text\= self_name type_module))] (///extension.lifted (function (_ state) - (case (|> state (get@ #.modules) (plist.value self_name)) + (case (|> state (value@ #.modules) (plist.value self_name)) (#.Some module) (let [namespaced_tags (list\map (|>> [self_name]) tags)] - (#try.Success [(update@ #.modules - (plist.revised self_name - (|>> (update@ #.tags (function (_ tag_bindings) - (list\fold (function (_ [idx tag] table) - (plist.has tag [idx namespaced_tags exported? type] table)) - tag_bindings - (list.enumeration tags)))) - (update@ #.types (plist.has type_name [namespaced_tags exported? type])))) - state) + (#try.Success [(revised@ #.modules + (plist.revised self_name + (|>> (revised@ #.tags (function (_ tag_bindings) + (list\fold (function (_ [idx tag] table) + (plist.has tag [idx namespaced_tags exported? type] table)) + tag_bindings + (list.enumeration tags)))) + (revised@ #.types (plist.has type_name [namespaced_tags exported? type])))) + state) []])) #.None ((/.except' unknown_module self_name) state)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux index 052173d1f..44d3b7deb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux @@ -32,13 +32,13 @@ (def: (local? name scope) (-> Text Scope Bit) (|> scope - (get@ [#.locals #.mappings]) + (value@ [#.locals #.mappings]) (plist.contains? name))) (def: (local name scope) (-> Text Scope (Maybe [Type Variable])) (|> scope - (get@ [#.locals #.mappings]) + (value@ [#.locals #.mappings]) (plist.value name) (maybe\map (function (_ [type value]) [type (#variable.Local value)])))) @@ -46,18 +46,18 @@ (def: (captured? name scope) (-> Text Scope Bit) (|> scope - (get@ [#.captured #.mappings]) + (value@ [#.captured #.mappings]) (plist.contains? name))) (def: (captured name scope) (-> Text Scope (Maybe [Type Variable])) (loop [idx 0 - mappings (get@ [#.captured #.mappings] scope)] + mappings (value@ [#.captured #.mappings] scope)] (case mappings (#.Item [_name [_source_type _source_ref]] mappings') (if (text\= name _name) (#.Some [_source_type (#variable.Foreign idx)]) - (recur (inc idx) mappings')) + (recur (++ idx) mappings')) #.End #.None))) @@ -81,7 +81,7 @@ (///extension.lifted (function (_ state) (let [[inner outer] (|> state - (get@ #.scopes) + (value@ #.scopes) (list.split_when (|>> (reference? name))))] (case outer #.End @@ -92,17 +92,17 @@ (..reference name top_outer)) [ref inner'] (list\fold (: (-> Scope [Variable (List Scope)] [Variable (List Scope)]) (function (_ scope ref+inner) - [(#variable.Foreign (get@ [#.captured #.counter] scope)) - (#.Item (update@ #.captured - (: (-> Foreign Foreign) - (|>> (update@ #.counter inc) - (update@ #.mappings (plist.has name [ref_type (product.left ref+inner)])))) - scope) + [(#variable.Foreign (value@ [#.captured #.counter] scope)) + (#.Item (revised@ #.captured + (: (-> Foreign Foreign) + (|>> (revised@ #.counter ++) + (revised@ #.mappings (plist.has name [ref_type (product.left ref+inner)])))) + scope) (product.right ref+inner))])) [init_ref #.End] (list.reversed inner)) scopes (list\compose inner' outer)] - (#.Right [(set@ #.scopes scopes state) + (#.Right [(with@ #.scopes scopes state) (#.Some [ref_type ref])])) ))))) @@ -112,23 +112,23 @@ (def: .public (with_local [name type] action) (All [a] (-> [Text Type] (Operation a) (Operation a))) (function (_ [bundle state]) - (case (get@ #.scopes state) + (case (value@ #.scopes state) (#.Item head tail) - (let [old_mappings (get@ [#.locals #.mappings] head) - new_var_id (get@ [#.locals #.counter] head) - new_head (update@ #.locals - (: (-> Local Local) - (|>> (update@ #.counter inc) - (update@ #.mappings (plist.has name [type new_var_id])))) - head)] - (case (///.result' [bundle (set@ #.scopes (#.Item new_head tail) state)] + (let [old_mappings (value@ [#.locals #.mappings] head) + new_var_id (value@ [#.locals #.counter] head) + new_head (revised@ #.locals + (: (-> Local Local) + (|>> (revised@ #.counter ++) + (revised@ #.mappings (plist.has name [type new_var_id])))) + head)] + (case (///.result' [bundle (with@ #.scopes (#.Item new_head tail) state)] action) (#try.Success [[bundle' state'] output]) - (case (get@ #.scopes state') + (case (value@ #.scopes state') (#.Item head' tail') - (let [scopes' (#.Item (set@ #.locals (get@ #.locals head) head') + (let [scopes' (#.Item (with@ #.locals (value@ #.locals head) head') tail')] - (#try.Success [[bundle' (set@ #.scopes scopes' state')] + (#try.Success [[bundle' (with@ #.scopes scopes' state')] output])) _ @@ -161,19 +161,19 @@ (def: .public (with_scope name action) (All [a] (-> Text (Operation a) (Operation a))) (function (_ [bundle state]) - (let [parent_name (case (get@ #.scopes state) + (let [parent_name (case (value@ #.scopes state) #.End (list) (#.Item top _) - (get@ #.name top))] - (case (action [bundle (update@ #.scopes - (|>> (#.Item (scope parent_name name))) - state)]) + (value@ #.name top))] + (case (action [bundle (revised@ #.scopes + (|>> (#.Item (scope parent_name name))) + state)]) (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (update@ #.scopes - (|>> list.tail (maybe.else (list))) - state')] + (#try.Success [[bundle' (revised@ #.scopes + (|>> list.tail (maybe.else (list))) + state')] output]) (#try.Failure error) @@ -185,9 +185,9 @@ (Operation Register) (///extension.lifted (function (_ state) - (case (get@ #.scopes state) + (case (value@ #.scopes state) (#.Item top _) - (#try.Success [state (get@ [#.locals #.counter] top)]) + (#try.Success [state (value@ [#.locals #.counter] top)]) #.End (exception.except ..cannot_get_next_reference_when_there_is_no_scope []))))) @@ -204,5 +204,5 @@ (def: .public (environment scope) (-> Scope (List Variable)) (|> scope - (get@ [#.captured #.mappings]) + (value@ [#.captured #.mappings]) (list\map (function (_ [_ [_ ref]]) (ref_variable ref))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux index 56924a102..fe296c83e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -299,11 +299,11 @@ ... re-implementing the same functionality for records makes no sense. ... Records, thus, get transformed into tuples by ordering the elements. (def: .public (order record) - (-> (List [Name Code]) (Operation [(List Code) Type])) + (-> (List [Name Code]) (Operation [Nat (List Code) Type])) (case record - ... empty_record = empty_tuple = unit = [] + ... empty_record = empty_tuple = unit/any = [] #.End - (\ ///.monad in [(list) Any]) + (\ ///.monad in [0 (list) Any]) (#.Item [head_k head_v] _) (do {! ///.monad} @@ -334,7 +334,7 @@ .let [ordered_tuple (list\map (function (_ idx) (maybe.trusted (dictionary.value idx idx->val))) tuple_range)]] - (in [ordered_tuple recordT])) + (in [size_ts ordered_tuple recordT])) )) (def: .public (record archive analyse members) @@ -349,12 +349,12 @@ _ (do {! ///.monad} [members (normal members) - [membersC recordT] (order members) + [record_size membersC recordT] (..order members) expectedT (///extension.lifted meta.expected_type)] (case expectedT (#.Var _) (do ! - [inferenceT (//inference.record recordT) + [inferenceT (//inference.record record_size recordT) [inferredT membersA] (//inference.general archive analyse inferenceT membersC)] (in (/.tuple membersA))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux index ed980b1e6..f1ffa9026 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux @@ -18,15 +18,15 @@ (def: .public (with_type expected) (All [a] (-> Type (Operation a) (Operation a))) - (///extension.localized (get@ #.expected) (set@ #.expected) + (///extension.localized (value@ #.expected) (with@ #.expected) (function.constant (#.Some expected)))) (def: .public (with_env action) (All [a] (-> (Check a) (Operation a))) (function (_ (^@ stateE [bundle state])) - (case (action (get@ #.type_context state)) + (case (action (value@ #.type_context state)) (#try.Success [context' output]) - (#try.Success [[bundle (set@ #.type_context context' state)] + (#try.Success [[bundle (with@ #.type_context context' state)] output]) (#try.Failure error) @@ -34,7 +34,7 @@ (def: .public with_fresh_env (All [a] (-> (Operation a) (Operation a))) - (///extension.localized (get@ #.type_context) (set@ #.type_context) + (///extension.localized (value@ #.type_context) (with@ #.type_context) (function.constant check.fresh_context))) (def: .public (infer actualT) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux index 81fc21caa..cc34e04cf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux @@ -68,7 +68,7 @@ (case expansion (^ (list& <lux_def_module> referrals)) (|> (recur archive <lux_def_module>) - (\ ! map (update@ #/.referrals (list\compose referrals)))) + (\ ! map (revised@ #/.referrals (list\compose referrals)))) _ (|> expansion diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index aa1730655..508242cd8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -1140,24 +1140,22 @@ phase.lifted)] (in (and (java/lang/Object::equals class (java/lang/reflect/Constructor::getDeclaringClass constructor)) (n.= (list.size inputsJT) (list.size parameters)) - (list\fold (function (_ [expectedJC actualJC] prev) - (and prev - (jvm\= expectedJC (: (Type Value) - (case (jvm_parser.var? actualJC) - (#.Some name) - (|> aliasing - (dictionary.value name) - (maybe.else name) - jvm.var) - - #.None - actualJC))))) - true - (list.zipped/2 parameters inputsJT)))))) + (list.every? (function (_ [expectedJC actualJC]) + (jvm\= expectedJC (: (Type Value) + (case (jvm_parser.var? actualJC) + (#.Some name) + (|> aliasing + (dictionary.value name) + (maybe.else name) + jvm.var) + + #.None + actualJC)))) + (list.zipped/2 parameters inputsJT)))))) (def: index_parameter (-> Nat .Type) - (|>> (n.* 2) inc #.Parameter)) + (|>> (n.* 2) ++ #.Parameter)) (def: (jvm_type_var_mapping owner_tvars method_tvars) (-> (List Text) (List Text) [(List .Type) Mapping]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 61f4e3763..0242d94b6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -279,9 +279,9 @@ super_classT super_interfaceT+)] state (extension.lifted phase.get_state) - .let [analyse (get@ [#directive.analysis #directive.phase] state) - synthesize (get@ [#directive.synthesis #directive.phase] state) - generate (get@ [#directive.generation #directive.phase] state)] + .let [analyse (value@ [#directive.analysis #directive.phase] state) + synthesize (value@ [#directive.synthesis #directive.phase] state) + generate (value@ [#directive.generation #directive.phase] state)] methods (monad.map ! (..method_definition [mapping selfT] [analyse synthesize generate]) methods) ... _ (directive.lifted_generation diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index 604292cdd..329c79611 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -63,7 +63,7 @@ (def: (context [module_id artifact_id]) (-> Context Context) ... TODO: Find a better way that doesn't rely on clever tricks. - [module_id (n.- (inc artifact_id) 0)]) + [module_id (n.- (++ artifact_id) 0)]) ... TODO: Inline "evaluate!'" into "evaluate!" ASAP (def: (evaluate!' archive generate code//type codeS) @@ -87,9 +87,9 @@ (-> Archive Type Code (Operation anchor expression directive [Type expression Any]))) (do phase.monad [state (///.lifted phase.get_state) - .let [analyse (get@ [#/////directive.analysis #/////directive.phase] state) - synthesize (get@ [#/////directive.synthesis #/////directive.phase] state) - generate (get@ [#/////directive.generation #/////directive.phase] state)] + .let [analyse (value@ [#/////directive.analysis #/////directive.phase] state) + synthesize (value@ [#/////directive.synthesis #/////directive.phase] state) + generate (value@ [#/////directive.generation #/////directive.phase] state)] [_ codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env @@ -123,9 +123,9 @@ (Operation anchor expression directive [Type expression Any]))) (do {! phase.monad} [state (///.lifted phase.get_state) - .let [analyse (get@ [#/////directive.analysis #/////directive.phase] state) - synthesize (get@ [#/////directive.synthesis #/////directive.phase] state) - generate (get@ [#/////directive.generation #/////directive.phase] state)] + .let [analyse (value@ [#/////directive.analysis #/////directive.phase] state) + synthesize (value@ [#/////directive.synthesis #/////directive.phase] state) + generate (value@ [#/////directive.generation #/////directive.phase] state)] [_ code//type codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env @@ -175,9 +175,9 @@ (Operation anchor expression directive [expression Any]))) (do phase.monad [state (///.lifted phase.get_state) - .let [analyse (get@ [#/////directive.analysis #/////directive.phase] state) - synthesize (get@ [#/////directive.synthesis #/////directive.phase] state) - generate (get@ [#/////directive.generation #/////directive.phase] state)] + .let [analyse (value@ [#/////directive.analysis #/////directive.phase] state) + synthesize (value@ [#/////directive.synthesis #/////directive.phase] state) + generate (value@ [#/////directive.generation #/////directive.phase] state)] [_ codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env @@ -199,15 +199,15 @@ (do phase.monad [[bundle state] phase.get_state .let [eval (/////analysis/evaluation.evaluator expander - (get@ [#/////directive.synthesis #/////directive.state] state) - (get@ [#/////directive.generation #/////directive.state] state) - (get@ [#/////directive.generation #/////directive.phase] state))]] + (value@ [#/////directive.synthesis #/////directive.state] state) + (value@ [#/////directive.generation #/////directive.state] state) + (value@ [#/////directive.generation #/////directive.phase] state))]] (phase.set_state [bundle - (update@ [#/////directive.analysis #/////directive.state] - (: (-> /////analysis.State+ /////analysis.State+) - (|>> product.right - [(///analysis.bundle eval host_analysis)])) - state)]))) + (revised@ [#/////directive.analysis #/////directive.state] + (: (-> /////analysis.State+ /////analysis.State+) + (|>> product.right + [(///analysis.bundle eval host_analysis)])) + state)]))) (def: (announce_definition! short type) (All [anchor expression directive] @@ -310,8 +310,8 @@ (function (_ extension_name phase archive [alias def_name]) (do phase.monad [_ (///.lifted - (phase.sub [(get@ [#/////directive.analysis #/////directive.state]) - (set@ [#/////directive.analysis #/////directive.state])] + (phase.sub [(value@ [#/////directive.analysis #/////directive.state]) + (with@ [#/////directive.analysis #/////directive.state])] (define_alias alias def_name)))] (in /////directive.no_requirements)))])) @@ -405,9 +405,9 @@ (^ (list programC)) (do phase.monad [state (///.lifted phase.get_state) - .let [analyse (get@ [#/////directive.analysis #/////directive.phase] state) - synthesize (get@ [#/////directive.synthesis #/////directive.phase] state) - generate (get@ [#/////directive.generation #/////directive.phase] state)] + .let [analyse (value@ [#/////directive.analysis #/////directive.phase] state) + synthesize (value@ [#/////directive.synthesis #/////directive.phase] state) + generate (value@ [#/////directive.generation #/////directive.phase] state)] programS (prepare_program archive analyse synthesize programC) current_module (/////directive.lifted_analysis (///.lifted meta.current_module_name)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index a8caf13bf..e18b6d356 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -128,7 +128,7 @@ list\join) conditionalsG (|> conditionalsG+ (list\map product.right) - (monad.seq _.monad))]] + (monad.all _.monad))]] (in (do _.monad [@else _.new_label] ($_ _.composite diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index a749fb6cd..be90b8876 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -948,7 +948,7 @@ (monad.map _.monad (.function (_ register) ($_ _.composite (_.aload 0) - (_.aload (inc register)) + (_.aload (++ register)) (_.putfield class (///reference.foreign_name register) $Object)))))] (method.method method.public "<init>" (anonymous_init_method env) (list) @@ -966,7 +966,7 @@ (in ($_ _.composite (_.new class) _.dup - (monad.seq _.monad captureG+) + (monad.all _.monad captureG+) (_.invokespecial class "<init>" (anonymous_init_method env)))))) (def: (returnG returnT) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux index 45d6873da..02ddfbd71 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux @@ -84,7 +84,7 @@ .let [foreigns (|> conditionals (list\map (|>> product.right synthesis.path/then //case.dependencies)) (list& (//case.dependencies (synthesis.path/then else))) - list.joined + list.together (set.of_list _.hash) set.list) @expression (_.constant (reference.artifact [context_module context_artifact])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux index f683c9b9a..c531d05d9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux @@ -7,7 +7,7 @@ ["." function] ["." try] ["<>" parser - ["<s>" synthesis (#+ Parser)]]] + ["<.>" synthesis (#+ Parser)]]] [data ["." product] ["." text @@ -41,7 +41,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.result parser input) + (case (<synthesis>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -51,11 +51,11 @@ ... TODO: Get rid of this ASAP (def: lux::syntax_char_case! (..custom [($_ <>.and - <s>.any - <s>.any - (<>.some (<s>.tuple ($_ <>.and - (<s>.tuple (<>.many <s>.i64)) - <s>.any)))) + <synthesis>.any + <synthesis>.any + (<>.some (<synthesis>.tuple ($_ <>.and + (<synthesis>.tuple (<>.many <synthesis>.i64)) + <synthesis>.any)))) (function (_ extension_name phase archive [input else conditionals]) (do {! /////.monad} [inputG (phase archive input) @@ -101,9 +101,9 @@ (/.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_shift))) - (/.install "right-shift" (binary (product.uncurried //runtime.i64::right_shift))) - + (/.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 _.+)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux index 7bc4f46df..fae91850c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux @@ -124,7 +124,7 @@ (list))))))] [left_choice _.nil (<|)] - [right_choice (_.string "") inc] + [right_choice (_.string "") ++] ) (def: (alternation @otherwise pre! post!) @@ -248,7 +248,7 @@ pattern_matching! (pattern_matching $output expression archive pathP) .let [storage (|> pathP ////synthesis/case.storage - (get@ #////synthesis/case.bindings) + (value@ #////synthesis/case.bindings) set.list (list\map (function (_ register) [(..register register) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux index 917ab8503..41faa95b6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux @@ -56,7 +56,7 @@ (_.funcall/+ [(_.function/1 @closure) inits])))))) (def: input - (|>> inc //case.register)) + (|>> ++ //case.register)) (def: .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux index db8c9b18e..7eca077bf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Location inc) + [lux (#- Location) ["." meta] [abstract ["." monad (#+ do)]] @@ -90,13 +90,13 @@ (syntax: .public (with_vars [vars (<code>.tuple (<>.some <code>.local_identifier)) body <code>.any]) (do {! meta.monad} - [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] + [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) (list (code.local_identifier var) (` (_.var (~ (code.text (format "v" (%.nat id))))))))) - list.joined))] + list.together))] (~ body))))))) (syntax: (runtime: [declaration (<>.or <code>.local_identifier diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux index df957a3cd..6755b8f33 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux @@ -31,7 +31,7 @@ (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? - (inc lefts) + (++ lefts) lefts)] (///////phase\map (|>> [tag right?] //runtime.variant) (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux index 6a5f40ef7..3802776c8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux @@ -36,7 +36,7 @@ type <code>.any]) (with_identifiers [g!_ g!extension g!name g!phase g!archive g!inputs g!of g!anchor g!expression g!directive] (do {! meta.monad} - [g!input+ (monad.seq ! (list.repeated arity (macro.identifier "input")))] + [g!input+ (monad.all ! (list.repeated arity (macro.identifier "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!extension)) (All [(~ g!anchor) (~ g!expression) (~ g!directive)] (-> ((~ type) (~ g!expression)) @@ -48,7 +48,7 @@ [(~+ (|> g!input+ (list\map (function (_ g!input) (list g!input (` ((~ g!phase) (~ g!archive) (~ g!input)))))) - list.joined))] + list.together))] ((~' in) ((~ g!extension) [(~+ g!input+)]))) (~' _) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux index b89ca3c5a..9b0431808 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux @@ -144,7 +144,7 @@ (push_cursor! @temp)))))] [left_choice _.null (<|)] - [right_choice (_.string "") inc] + [right_choice (_.string "") ++] ) (def: (alternation pre! post!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux index cccb72dd5..fdfc768a0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux @@ -56,7 +56,7 @@ (_.var "curried")) (def: input - (|>> inc //case.register)) + (|>> ++ //case.register)) (def: @@arguments (_.var "arguments")) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 57916d38a..368c69bb0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -68,7 +68,7 @@ (def: .public low (-> (I64 Any) (I64 Any)) - (let [mask (dec (i64.left_shifted 32 1))] + (let [mask (-- (i64.left_shifted 32 1))] (|>> (i64.and mask)))) (def: .public unit @@ -88,13 +88,13 @@ (syntax: .public (with_vars [vars (<code>.tuple (<>.some <code>.local_identifier)) body <code>.any]) (do {! meta.monad} - [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] + [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) (list (code.local_identifier var) (` (_.var (~ (code.text (format "v" (%.nat id))))))))) - list.joined))] + list.together))] (~ body))))))) (syntax: (runtime: [declaration (<>.or <code>.local_identifier diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux index ebaaa7f49..6253b38b5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux @@ -31,7 +31,7 @@ (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? - (inc lefts) + (++ lefts) lefts)] (///////phase\map (//runtime.variant (_.i32 (.int tag)) (//runtime.flag right?)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux index aebb30404..417f74d2d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux @@ -174,7 +174,7 @@ (#synthesis.Alt leftP rightP) (do phase.monad [@alt_else //runtime.forge_label - left! (path' (inc stack_depth) @alt_else @end phase archive leftP) + left! (path' (++ stack_depth) @alt_else @end phase archive leftP) right! (path' stack_depth @else @end phase archive rightP)] (in ($_ _.composite _.dup diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux index f3938db06..5eafc6556 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux @@ -74,7 +74,7 @@ (if (arity.multiary? arity) (|> (n.min arity /arity.maximum) list.indices - (list\map (|>> inc (/apply.method classT environment arity @begin body))) + (list\map (|>> ++ (/apply.method classT environment arity @begin body))) (list& (/implementation.method arity @begin body))) (list (/implementation.method' //runtime.apply::name arity @begin body)))))] (do phase.monad @@ -129,7 +129,7 @@ (function (_ batchG) ($_ _.composite (_.checkcast /abstract.class) - (monad.seq _.monad batchG) + (monad.all _.monad batchG) (_.invokevirtual /abstract.class //runtime.apply::name (//runtime.apply::type (list.size batchG))) )))) )))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial/count.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux index 30f27def6..1ec854f71 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial/count.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux @@ -6,11 +6,11 @@ [target [jvm ["_" bytecode (#+ Bytecode)] + ["." type] [encoding [name (#+ External)] - ["." signed]] - ["." type]]]]] - ["." ///// #_ + ["." signed]]]]]] + ["." //// #_ ["#." abstract]]) (def: .public field "partials") @@ -30,5 +30,5 @@ (Bytecode Any) ($_ _.composite ..this - (_.getfield /////abstract.class ..field ..type) + (_.getfield ////abstract.class ..field ..type) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux index 57d285e8a..19dc23779 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux @@ -35,7 +35,7 @@ ($_ _.composite (|> _.aconst_null (list.repeated amount) - (monad.seq _.monad)) + (monad.all _.monad)) (_\in []))) (def: .public (get class register) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux index da3292be8..1addefe99 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux @@ -79,7 +79,7 @@ (def: .public (method class environment function_arity @begin body apply_arity) (-> (Type Class) (Environment Synthesis) Arity Label (Bytecode Any) Arity (Resource Method)) - (let [num_partials (dec function_arity) + (let [num_partials (-- function_arity) over_extent (i.- (.int apply_arity) (.int function_arity))] (method.method //.modifier ////runtime.apply::name @@ -95,15 +95,15 @@ [@default _.new_label @labelsH _.new_label @labelsT (|> _.new_label - (list.repeated (dec num_partials)) - (monad.seq _.monad)) + (list.repeated (-- num_partials)) + (monad.all _.monad)) .let [cases (|> (list\compose (#.Item [@labelsH @labelsT]) (list @default)) list.enumeration (list\map (function (_ [stage @case]) (let [current_partials (|> (list.indices stage) (list\map (///partial.get class)) - (monad.seq _.monad)) + (monad.all _.monad)) already_partial? (n.> 0 stage) exact_match? (i.= over_extent (.int stage)) has_more_than_necessary? (i.> over_extent (.int stage))] @@ -135,10 +135,10 @@ ... (i.< over_extent (.int stage)) (let [current_environment (|> (list.indices (list.size environment)) (list\map (///foreign.get class)) - (monad.seq _.monad)) + (monad.all _.monad)) missing_partials (|> _.aconst_null (list.repeated (|> num_partials (n.- apply_arity) (n.- stage))) - (monad.seq _.monad))] + (monad.all _.monad))] ($_ _.composite (_.new class) _.dup @@ -150,7 +150,7 @@ missing_partials (_.invokevirtual class //init.name (//init.type environment function_arity)) _.areturn))))))) - (monad.seq _.monad))]] + (monad.all _.monad))]] ($_ _.composite ///partial/count.value (_.tableswitch (try.trusted (signed.s4 +0)) @default [@labelsH @labelsT]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux index cd92f4aca..3c1922063 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux @@ -45,7 +45,7 @@ (def: (partials arity) (-> Arity (List (Type Value))) - (list.repeated (dec arity) ////type.value)) + (list.repeated (-- arity) ////type.value)) (def: .public (type environment arity) (-> (Environment Synthesis) Arity (Type category.Method)) @@ -64,7 +64,7 @@ (def: .public (super environment_size arity) (-> Nat Arity (Bytecode Any)) - (let [arity_register (inc environment_size)] + (let [arity_register (++ environment_size)] ($_ _.composite (if (arity.unary? arity) ..no_partials @@ -80,7 +80,7 @@ (list\map (function (_ register) (put register (_.aload (offset register))))) - (monad.seq _.monad))) + (monad.all _.monad))) (def: .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) @@ -98,5 +98,5 @@ ////reference.this (..super environment_size arity) (store_all environment_size (///foreign.put class) offset_foreign) - (store_all (dec arity) (///partial.put class) offset_partial) + (store_all (-- arity) (///partial.put class) offset_partial) _.return))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux index d153b35e9..c126f0296 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux @@ -47,7 +47,7 @@ ($_ _.composite (_.new class) _.dup - (monad.seq _.monad foreign_setup) + (monad.all _.monad foreign_setup) (///partial.new arity) (_.invokespecial class //init.name (//init.type environment arity)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux index 6757bc987..9b69ffbae 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux @@ -64,11 +64,11 @@ ... should be the case. (|> updatesG (list\map product.left) - (monad.seq _.monad)) + (monad.all _.monad)) (|> updatesG list.reversed (list\map product.right) - (monad.seq _.monad)) + (monad.all _.monad)) (_.goto @begin))))) (def: .public (scope translate archive [offset initsS+ iterationS]) @@ -83,7 +83,7 @@ ($_ _.composite initG (_.astore (n.+ offset index))))) - (monad.seq _.monad))]] + (monad.all _.monad))]] (in ($_ _.composite initializationG (_.set_label @begin) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index f11c871c1..1d414ab77 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -44,8 +44,7 @@ [constant ["#/." arity]] [variable - [partial - ["#/." count]]]]] + ["#/." count]]]] ["//#" /// #_ [// ["." version] @@ -60,11 +59,14 @@ [io (#+ lux_context)] [archive (#+ Archive)]]]]]]) -(type: .public Byte_Code Binary) +(type: .public Byte_Code + Binary) -(type: .public Definition [Text Byte_Code]) +(type: .public Definition + [Text Byte_Code]) -(type: .public Anchor [Label Register]) +(type: .public Anchor + [Label Register]) (template [<name> <base>] [(type: .public <name> @@ -542,7 +544,7 @@ (def: generate_function (Operation Any) (let [apply::method+ (|> (enum.range n.enum - (inc //function/arity.minimum) + (++ //function/arity.minimum) //function/arity.maximum) (list\map (function (_ arity) (method.method method.public ..apply::name (..apply::type arity) @@ -553,7 +555,7 @@ (monad.map _.monad _.aload))] ($_ _.composite previous_inputs - (_.invokevirtual //function.class ..apply::name (..apply::type (dec arity))) + (_.invokevirtual //function.class ..apply::name (..apply::type (-- arity))) (_.checkcast //function.class) (_.aload arity) (_.invokevirtual //function.class ..apply::name (..apply::type //function/arity.minimum)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux index 062708388..815c4fca0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux @@ -50,12 +50,12 @@ (in (do {! _.monad} [_ (_.int (.i64 (list.size membersS))) _ (_.anewarray $Object)] - (monad.seq ! membersI)))))) + (monad.all ! membersI)))))) (def: .public (tag lefts right?) (-> Nat Bit (Bytecode Any)) (case (if right? - (.inc lefts) + (.++ lefts) lefts) 0 _.iconst_0 1 _.iconst_1 diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux index d21adc3ef..ef53de88c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux @@ -145,7 +145,7 @@ (..push! @temp)))))] [left_choice _.nil (<|)] - [right_choice (_.string "") inc] + [right_choice (_.string "") ++] ) (def: (alternation pre! post!) @@ -250,7 +250,7 @@ (def: .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage - (get@ #////synthesis/case.dependencies) + (value@ #////synthesis/case.dependencies) set.list (list\map (function (_ variable) (.case variable diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux index 65930fb75..509808d62 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux @@ -57,7 +57,7 @@ (_.apply/* inits @self)]))) (def: input - (|>> inc //case.register)) + (|>> ++ //case.register)) (def: (@scope function_name) (-> Context Label) @@ -82,7 +82,7 @@ initialize! (list\fold (.function (_ post pre!) ($_ _.then pre! - (_.local/1 (..input post) (_.item (|> post inc .int _.int) @curried)))) + (_.local/1 (..input post) (_.item (|> post ++ .int _.int) @curried)))) initialize_self! (list.indices arity)) pack (|>> (list) _.array) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index a1c3d7ca2..988274333 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Location inc) + [lux (#- Location) ["." meta] [abstract ["." monad (#+ do)]] @@ -105,13 +105,13 @@ (syntax: .public (with_vars [vars (<code>.tuple (<>.some <code>.local_identifier)) body <code>.any]) (do {! meta.monad} - [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] + [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) (list (code.local_identifier var) (` (_.var (~ (code.text (format "v" (%.nat id))))))))) - list.joined))] + list.together))] (~ body))))))) (def: module_id diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux index 8c78dea65..6bbd167eb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux @@ -31,7 +31,7 @@ (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? - (inc lefts) + (++ lefts) lefts)] (///////phase\map (//runtime.variant tag right?) (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux index 04cce603a..28744fe33 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux @@ -145,7 +145,7 @@ (..push! @temp)))))] [left_choice _.null (<|)] - [right_choice (_.string "") inc] + [right_choice (_.string "") ++] ) (def: (alternation pre! post!) @@ -260,7 +260,7 @@ (def: .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage - (get@ #////synthesis/case.dependencies) + (value@ #////synthesis/case.dependencies) set.list (list\map (function (_ variable) (.case variable diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux index 5cc25a622..175fadfc3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux @@ -41,7 +41,7 @@ (|>> (///reference.foreign //reference.system) :expected)) (def: input - (|>> inc //case.register)) + (|>> ++ //case.register)) (def: (@scope function_name) (-> Context Label) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index 6f69ba6e6..bd36c0785 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Location inc) + [lux (#- Location) ["." meta] [abstract ["." monad (#+ do)]] @@ -73,13 +73,13 @@ (syntax: .public (with_vars [vars (<code>.tuple (<>.some <code>.local_identifier)) body <code>.any]) (do {! meta.monad} - [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] + [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) (list (code.local_identifier var) (` (_.var (~ (code.text (format "v" (%.nat id))))))))) - list.joined))] + list.together))] (~ body))))))) (def: module_id @@ -342,7 +342,7 @@ (def: .public low (-> (I64 Any) (I64 Any)) - (let [mask (dec (i64.left_shifted 32 1))] + (let [mask (-- (i64.left_shifted 32 1))] (|>> (i64.and mask)))) (runtime: (i64//right_shifted param subject) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux index 69979afd6..a7fe22f6d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux @@ -36,7 +36,7 @@ (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? - (inc lefts) + (++ lefts) lefts)] (///////phase\map (//runtime.variant tag right?) (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index df2a1a3fc..5d66730d1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -148,7 +148,7 @@ )))] [left_choice _.none (<|)] - [right_choice (_.string "") inc] + [right_choice (_.string "") ++] ) (def: (with_looping in_closure? g!once body!) @@ -298,7 +298,7 @@ (def: .public dependencies (-> Path (List SVar)) (|>> case.storage - (get@ #case.dependencies) + (value@ #case.dependencies) set.list (list\map (function (_ variable) (.case variable diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux index b1ce3f5c8..eee714ea8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux @@ -19,7 +19,7 @@ ["/#" // #_ ["#." reference] ["//#" /// #_ - [analysis (#+ Variant Tuple Environment Abstraction Application Analysis)] + [analysis (#+ Environment Abstraction Application Analysis)] [synthesis (#+ Synthesis)] ["#." generation (#+ Context)] ["//#" /// #_ @@ -64,7 +64,7 @@ (in (_.apply/* @function inits))))) (def: input - (|>> inc //case.register)) + (|>> ++ //case.register)) (def: .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index e26aca84a..207b74654 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- inc) + [lux (#- ++) ["." meta] [abstract ["." monad (#+ do)]] @@ -112,13 +112,13 @@ (syntax: .public (with_vars [vars (<code>.tuple (<>.some <code>.local_identifier)) body <code>.any]) (do {! meta.monad} - [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] + [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) (list (code.local_identifier var) (` (_.var (~ (code.text (format "v" (%.nat id))))))))) - list.joined))] + list.together))] (~ body))))))) (syntax: (runtime: [declaration (<>.or <code>.local_identifier @@ -395,7 +395,7 @@ ..none (..some (..i64::64 idx))))))) -(def: inc +(def: ++ (|>> (_.+ (_.int +1)))) (def: (within? top value) @@ -408,7 +408,7 @@ (runtime: (text::char idx text) (_.if (|> idx (within? (_.len/1 text))) - (_.return (|> text (_.slice idx (..inc idx)) _.ord/1 ..i64::64)) + (_.return (|> text (_.slice idx (..++ idx)) _.ord/1 ..i64::64)) (_.raise (_.Exception/1 (_.unicode "[Lux Error] Cannot get char from text."))))) (def: runtime::text diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux index 1ab751074..756e3f00d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux @@ -1,6 +1,6 @@ (.module: [library - [lux #* + [lux (#- Variant Tuple) [abstract ["." monad (#+ do)]] [target @@ -31,7 +31,7 @@ (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? - (inc lefts) + (++ lefts) lefts)] (///////phase\map (//runtime.variant tag right?) (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux index cd41e5f3d..288fdc4bf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux @@ -187,7 +187,7 @@ ..fail! (..push_cursor! $temp))))]) ([/////synthesis.side/left false (<|)] - [/////synthesis.side/right true inc]) + [/////synthesis.side/right true ++]) (^ (/////synthesis.member/left 0)) (///////phase\in (_.item (_.int +1) ..peek)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux index 34334c668..4ae6231c5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux @@ -68,8 +68,8 @@ (def: (input_declaration register) (-> Register Expression) - (_.set! (|> register inc //case.register) - (|> $curried (_.item (|> register inc .int _.int))))) + (_.set! (|> register ++ //case.register) + (|> $curried (_.item (|> register ++ .int _.int))))) (def: .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index e6134cb95..624826639 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -67,7 +67,7 @@ arity s.nat]) (with_identifiers [g!_ g!proc g!name g!translate g!inputs] (do {@ macro.monad} - [g!input+ (monad.seq @ (list.repeated arity (macro.identifier "input")))] + [g!input+ (monad.all @ (list.repeated arity (macro.identifier "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!proc)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) (-> Text ..Proc)) @@ -79,7 +79,7 @@ [(~+ (|> g!input+ (list/map (function (_ g!input) (list g!input (` ((~ g!translate) (~ g!input)))))) - list.joined))] + list.together))] ((~' in) ((~ g!proc) [(~+ g!input+)]))) (~' _) @@ -125,7 +125,7 @@ (-> Text Proc) (function (_ proc_name) (function (_ translate inputsS) - (case (s.result inputsS ($_ p.seq s.nat (s.tuple (p.many s.any)) s.any)) + (case (s.result inputsS ($_ p.and s.nat (s.tuple (p.many s.any)) s.any)) (#e.Success [offset initsS+ bodyS]) (loopT.translate_loop translate offset initsS+ bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index 36e86df65..21f2ded5a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Location inc i64) + [lux (#- Location ++ i64) ["." meta] [abstract ["." monad (#+ do)]] @@ -79,13 +79,13 @@ (syntax: .public (with_vars [vars (<code>.tuple (<>.some <code>.local_identifier)) body <code>.any]) (do {! meta.monad} - [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] + [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) (list (code.local_identifier var) (` (_.var (~ (code.text (format "v" (%.nat id))))))))) - list.joined))] + list.together))] (~ body))))))) (syntax: (runtime: [declaration (<>.or <code>.local_identifier @@ -718,7 +718,7 @@ @frac::decode )) -(def: inc +(def: ++ (-> Expression Expression) (|>> (_.+ (_.int +1)))) @@ -749,8 +749,8 @@ ($_ _.then (_.set! idx (|> (_.apply_kw (list param (_.if (|> startF (_.= (_.int +0))) subject - (text_clip (inc startF) - (inc subjectL) + (text_clip (++ startF) + (++ subjectL) subject))) (list ["fixed" (_.bool #1)]) (_.var "regexpr")) @@ -766,7 +766,7 @@ (_.set! length (_.length text)) (_.set! to (_.+ additional minimum)) (_.if (within? length to) - (..some (text_clip (inc minimum) (inc to) text)) + (..some (text_clip (++ minimum) (++ to) text)) ..none)))) (def: (char_at idx text) @@ -777,7 +777,7 @@ (runtime: (text::char text idx) (_.if (|> idx (within? (_.length text))) ($_ _.then - (_.set! idx (inc idx)) + (_.set! idx (++ idx)) (..some (i64::of_float (char_at idx text)))) ..none)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux index 3c74989df..748f56955 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux @@ -34,7 +34,7 @@ (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? - (inc lefts) + (++ lefts) lefts)] (///////phase\map (|>> (//runtime.variant tag right?)) (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index 608bffb04..26ccf116d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -1,6 +1,6 @@ (.module: [library - [lux #* + [lux (#- local) ["@" target] [data [text diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index fa95d1ba3..2af4e0dee 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -151,7 +151,7 @@ (..push! @temp)))))] [left_choice _.nil (<|)] - [right_choice (_.string "") inc] + [right_choice (_.string "") ++] ) (def: (with_looping in_closure? g!once g!continue? body!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux index b64895b0e..192807829 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux @@ -61,7 +61,7 @@ (_.apply/* inits @self)]))) (def: input - (|>> inc //case.register)) + (|>> ++ //case.register)) (def: .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) @@ -73,7 +73,7 @@ .let [function_name (///reference.artifact [function_module function_artifact]) @curried (_.local "curried") arityO (|> arity .int _.int) - limitO (|> arity dec .int _.int) + limitO (|> arity -- .int _.int) @num_args (_.local "num_args") @self (_.local function_name) initialize_self! (_.set (list (//case.register 0)) @self) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index 1bcb1d528..8a825e466 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- inc) + [lux #* ["." meta] [abstract ["." monad (#+ do)]] @@ -74,13 +74,13 @@ (syntax: .public (with_vars [vars (<code>.tuple (<>.some <code>.local_identifier)) body <code>.any]) (do {! meta.monad} - [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] + [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) (list (code.local_identifier var) (` (_.local (~ (code.text (format "v" (%.nat id))))))))) - list.joined))] + list.together))] (~ body))))))) (def: module_id diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux index f51cad8bc..57861f7d4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux @@ -31,7 +31,7 @@ (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? - (inc lefts) + (++ lefts) lefts)] (///////phase\map (//runtime.variant tag right?) (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux index 70dfee409..ae841dc5b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux @@ -180,7 +180,7 @@ ..fail! (push_cursor! @temp))))]) ([/////synthesis.side/left false (<|)] - [/////synthesis.side/right true inc]) + [/////synthesis.side/right true ++]) (^ (/////synthesis.member/left 0)) (///////phase\in (..push_cursor! (_.vector_ref/2 ..peek (_.int +0)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux index c52ecd6dd..dc3c75d98 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux @@ -42,7 +42,7 @@ arity <code>.nat]) (with_identifiers [g!_ g!extension g!name g!phase g!inputs] (do {! macro.monad} - [g!input+ (monad.seq ! (list.repeated arity (macro.identifier "input")))] + [g!input+ (monad.all ! (list.repeated arity (macro.identifier "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!extension)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Computation) Handler) @@ -53,7 +53,7 @@ [(~+ (|> g!input+ (list\map (function (_ g!input) (list g!input (` ((~ g!phase) (~ g!input)))))) - list.joined))] + list.together))] ((~' in) ((~ g!extension) [(~+ g!input+)]))) (~' _) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux index a36feb036..58d8b55c6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux @@ -58,7 +58,7 @@ (def: @missing (_.var "missing")) (def: input - (|>> inc //case.register)) + (|>> ++ //case.register)) (def: .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux index 95dfef826..452da33ef 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Location inc) + [lux (#- Location) ["." meta] [abstract ["." monad (#+ do)]] @@ -61,13 +61,13 @@ (syntax: .public (with_vars [vars (<code>.tuple (<>.some <code>.local_identifier)) body <code>.any]) (do {! meta.monad} - [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] + [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) (list (code.local_identifier var) (` (_.var (~ (code.text (format "v" (%.nat id))))))))) - list.joined))] + list.together))] (~ body))))))) (syntax: (runtime: [declaration (<>.or <code>.local_identifier diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux index ebc933d4c..3c21b5e17 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux @@ -34,7 +34,7 @@ (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? - (inc lefts) + (++ lefts) lefts)] (///////phase\map (|>> [tag right?] //runtime.variant) (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux index c234f9902..9e80130aa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux @@ -59,8 +59,8 @@ (case structure (#///analysis.Variant variant) (do phase.monad - [valueS (optimization' (get@ #///analysis.value variant))] - (in (/.variant (set@ #///analysis.value valueS variant)))) + [valueS (optimization' (value@ #///analysis.value variant))] + (in (/.variant (with@ #///analysis.value valueS variant)))) (#///analysis.Tuple tuple) (|> tuple diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 7f2666d8b..1a178900e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -71,7 +71,7 @@ thenC) (#///analysis.Complex (#///analysis.Tuple tuple)) - (let [tuple::last (dec (list.size tuple))] + (let [tuple::last (-- (list.size tuple))] (list\fold (function (_ [tuple::lefts tuple::member] nextC) (.case tuple::member (#///analysis.Simple #///analysis.Unit) @@ -81,7 +81,7 @@ (let [right? (n.= tuple::last tuple::lefts) end?' (and end? right?)] (<| (///\map (|>> (#/.Seq (#/.Access (#/.Member (if right? - (#.Right (dec tuple::lefts)) + (#.Right (-- tuple::lefts)) (#.Left tuple::lefts))))))) (path' tuple::member end?') (when> [(new> (not end?') [])] [(///\map ..clean_up)]) @@ -193,10 +193,10 @@ (loop [lefts 0 patterns patterns] (with_expansions [<failure> (as_is (list)) - <continue> (as_is (recur (inc lefts) + <continue> (as_is (recur (++ lefts) tail)) <member> (as_is (if (list.empty? tail) - (#.Right (dec lefts)) + (#.Right (-- lefts)) (#.Left lefts)))] (case patterns #.End @@ -308,7 +308,7 @@ (case path (^ (/.path/seq #/.Pop path')) (let [[pops post_pops] (count_pops path')] - [(inc pops) post_pops]) + [(++ pops) post_pops]) _ [0 path])) @@ -341,8 +341,8 @@ path_storage (^ (/.path/bind register)) - (update@ #bindings (set.has register) - path_storage) + (revised@ #bindings (set.has register) + path_storage) (#/.Bit_Fork _ default otherwise) (|> (case otherwise @@ -376,12 +376,12 @@ (list\fold for_synthesis synthesis_storage members) (#/.Reference (#///reference.Variable (#///reference/variable.Local register))) - (if (set.member? (get@ #bindings synthesis_storage) register) + (if (set.member? (value@ #bindings synthesis_storage) register) synthesis_storage - (update@ #dependencies (set.has (#///reference/variable.Local register)) synthesis_storage)) + (revised@ #dependencies (set.has (#///reference/variable.Local register)) synthesis_storage)) (#/.Reference (#///reference.Variable var)) - (update@ #dependencies (set.has var) synthesis_storage) + (revised@ #dependencies (set.has var) synthesis_storage) (^ (/.function/apply [functionS argsS])) (list\fold for_synthesis synthesis_storage (#.Item functionS argsS)) @@ -390,17 +390,17 @@ (list\fold for_synthesis synthesis_storage environment) (^ (/.branch/case [inputS pathS])) - (update@ #dependencies - (set.union (get@ #dependencies (for_path pathS synthesis_storage))) - (for_synthesis inputS synthesis_storage)) + (revised@ #dependencies + (set.union (value@ #dependencies (for_path pathS synthesis_storage))) + (for_synthesis inputS synthesis_storage)) (^ (/.branch/let [inputS register exprS])) - (update@ #dependencies - (set.union (|> synthesis_storage - (update@ #bindings (set.has register)) - (for_synthesis exprS) - (get@ #dependencies))) - (for_synthesis inputS synthesis_storage)) + (revised@ #dependencies + (set.union (|> synthesis_storage + (revised@ #bindings (set.has register)) + (for_synthesis exprS) + (value@ #dependencies))) + (for_synthesis inputS synthesis_storage)) (^ (/.branch/if [testS thenS elseS])) (list\fold for_synthesis synthesis_storage (list testS thenS elseS)) @@ -409,15 +409,15 @@ (for_synthesis whole synthesis_storage) (^ (/.loop/scope [start initsS+ iterationS])) - (update@ #dependencies - (set.union (|> synthesis_storage - (update@ #bindings (set.union (|> initsS+ - list.enumeration - (list\map (|>> product.left (n.+ start))) - (set.of_list n.hash)))) - (for_synthesis iterationS) - (get@ #dependencies))) - (list\fold for_synthesis synthesis_storage initsS+)) + (revised@ #dependencies + (set.union (|> synthesis_storage + (revised@ #bindings (set.union (|> initsS+ + list.enumeration + (list\map (|>> product.left (n.+ start))) + (set.of_list n.hash)))) + (for_synthesis iterationS) + (value@ #dependencies))) + (list\fold for_synthesis synthesis_storage initsS+)) (^ (/.loop/recur replacementsS+)) (list\fold for_synthesis synthesis_storage replacementsS+) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 7becfbe4d..1e7ca8cc3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -55,7 +55,7 @@ (with_expansions [<apply> (as_is (/.function/apply [funcS argsS]))] (case funcS (^ (/.function/abstraction functionS)) - (if (n.= (get@ #/.arity functionS) + (if (n.= (value@ #/.arity functionS) (list.size argsS)) (do ! [locals /.locals] @@ -94,7 +94,7 @@ (-> (-> Synthesis (Operation Synthesis)) Path (Operation Path)) (case path (#/.Bind register) - (phase\in (#/.Bind (inc register))) + (phase\in (#/.Bind (++ register))) (^template [<tag>] [(<tag> left right) @@ -160,7 +160,7 @@ (#////reference.Variable variable) (case variable (#////reference/variable.Local register) - (phase\in (/.variable/local (inc register))) + (phase\in (/.variable/local (++ register))) (#////reference/variable.Foreign register) (..find_foreign environment register)) @@ -176,7 +176,7 @@ (do phase.monad [inputS' (grow environment inputS) bodyS' (grow environment bodyS)] - (in (/.branch/let [inputS' (inc register) bodyS']))) + (in (/.branch/let [inputS' (++ register) bodyS']))) (#/.If [testS thenS elseS]) (do phase.monad @@ -202,7 +202,7 @@ (do {! phase.monad} [initsS+' (monad.map ! (grow environment) initsS+) iterationS' (grow environment iterationS)] - (in (/.loop/scope [(inc start) initsS+' iterationS']))) + (in (/.loop/scope [(++ start) initsS+' iterationS']))) (#/.Recur argumentsS+) (|> argumentsS+ @@ -258,7 +258,7 @@ (grow env') (\ ! map (function (_ body) {#/.environment environment - #/.arity (inc down_arity') + #/.arity (++ down_arity') #/.body body}))) _ @@ -270,7 +270,7 @@ (case (//loop.optimization false 1 (list) abstraction) (#.Some [startL initsL bodyL]) (/.function/abstraction {#/.environment environment - #/.arity (get@ #/.arity abstraction) + #/.arity (value@ #/.arity abstraction) #/.body (/.loop/scope [startL initsL bodyL])}) #.None diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index d9890dbc9..a615c00ef 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -24,7 +24,7 @@ (def: .public (register_optimization offset) (-> Register (-> Register Register)) - (|>> dec (n.+ offset))) + (|>> -- (n.+ offset))) (def: (path_optimization body_optimization offset) (-> (Transform Synthesis) Register (Transform Path)) @@ -86,9 +86,9 @@ (case structure (#analysis.Variant variant) (do maybe.monad - [value' (|> variant (get@ #analysis.value) (recur false))] + [value' (|> variant (value@ #analysis.value) (recur false))] (in (|> variant - (set@ #analysis.value value') + (with@ #analysis.value value') /.variant))) (#analysis.Tuple tuple) @@ -141,10 +141,10 @@ (^ (/.loop/scope scope)) (do {! maybe.monad} [inits' (|> scope - (get@ #/.inits) + (value@ #/.inits) (monad.map ! (recur false))) - iteration' (recur return? (get@ #/.iteration scope))] - (in (/.loop/scope {#/.start (|> scope (get@ #/.start) (register_optimization offset)) + iteration' (recur return? (value@ #/.iteration scope))] + (in (/.loop/scope {#/.start (|> scope (value@ #/.start) (register_optimization offset)) #/.inits inits' #/.iteration iteration'}))) @@ -183,6 +183,6 @@ (def: .public (optimization true_loop? offset inits functionS) (-> Bit Register (List Synthesis) Abstraction (Maybe [Register (List Synthesis) Synthesis])) - (|> (get@ #/.body functionS) - (body_optimization true_loop? offset (get@ #/.environment functionS) (get@ #/.arity functionS)) + (|> (value@ #/.body functionS) + (body_optimization true_loop? offset (value@ #/.environment functionS) (value@ #/.arity functionS)) (maybe\map (|>> [offset inits])))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index feadf7fa5..cb647c284 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -29,7 +29,7 @@ (def: (prune redundant register) (-> Register Register Register) (if (n.> redundant register) - (dec register) + (-- register) register)) (type: (Remover a) @@ -44,7 +44,7 @@ (if (n.= redundant register) (recur post) (#/.Seq (#/.Bind (if (n.> redundant register) - (dec register) + (-- register) register)) (recur post))) @@ -60,7 +60,7 @@ (recur post) (#/.Seq (#/.Access (#/.Member member)) (#/.Seq (#/.Bind (if (n.> redundant register) - (dec register) + (-- register) register)) (recur post)))) @@ -188,7 +188,7 @@ (def: (default arity) (-> Arity Redundancy) - (product.right (..extended 0 (inc arity) ..initial))) + (product.right (..extended 0 (++ arity) ..initial))) (type: (Optimization a) (-> [Redundancy a] (Try [Redundancy a]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux index 365f9e804..f181fd077 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -42,7 +42,7 @@ (do ! [id (archive.id module archive) [descriptor document] (archive.find module archive)] - (in [[module id] (get@ #descriptor.registry descriptor)])))))] + (in [[module id] (value@ #descriptor.registry descriptor)])))))] (case (list.one (function (_ [[module module_id] registry]) (do maybe.monad [program_id (artifact.remember ..name registry)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index 15539ae10..d4b612bf2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -70,13 +70,13 @@ (type: Char Nat) -(template [<name> <extension> <diff>] +(template [<extension> <diff> <name>] [(template: (<name> value) [(<extension> <diff> value)])] - [!inc "lux i64 +" 1] - [!inc/2 "lux i64 +" 2] - [!dec "lux i64 -" 1] + ["lux i64 +" 1 !++] + ["lux i64 +" 2 !++/2] + ["lux i64 -" 1 !--] ) (template: (!clip from to text) @@ -198,14 +198,14 @@ (:expected <<otherwise>>))]) (template: (!horizontal where offset source_code) - [[(update@ #.column inc where) - (!inc offset) + [[(revised@ #.column ++ where) + (!++ offset) source_code]]) (inline: (!new_line where) (-> Location Location) (let [[where::file where::line where::column] where] - [where::file (!inc where::line) 0])) + [where::file (!++ where::line) 0])) (inline: (!forward length where) (-> Nat Location Location) @@ -214,7 +214,7 @@ (template: (!vertical where offset source_code) [[(!new_line where) - (!inc offset) + (!++ offset) source_code]]) (template [<name> <close> <tag>] @@ -272,8 +272,8 @@ (<| (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)] - (update@ #.column (|>> (!n/+ size) (!n/+ 2)) where)) - (!inc g!end) + (revised@ #.column (|>> (!n/+ size) (!n/+ 2)) where)) + (!++ g!end) source_code] [where (#.Text g!content)]])) @@ -365,11 +365,11 @@ exponent (static ..no_exponent)] (<| (!with_char+ source_code//size source_code end char/0 <frac_output>) (!if_digit?+ char/0 - (recur (!inc end) exponent) + (recur (!++ end) exponent) [["e" "E"] (if (same? (static ..no_exponent) exponent) - (<| (!with_char+ source_code//size source_code (!inc end) char/1 <failure>) + (<| (!with_char+ source_code//size source_code (!++ end) char/1 <failure>) (`` ("lux syntax char case!" char/1 [[<signs>] (<| (!with_char+ source_code//size source_code (!n/+ 2 end) char/2 <failure>) @@ -389,10 +389,10 @@ (loop [end offset] (<| (!with_char+ source_code//size source_code end char <int_output>) (!if_digit?+ char - (recur (!inc end)) + (recur (!++ end)) [[<frac_separator>] - (frac_parser source_code//size start where (!inc end) source_code)] + (frac_parser source_code//size start where (!++ end) source_code)] <int_output>)))) ) @@ -404,7 +404,7 @@ (loop [g!end offset] (<| (!with_char+ source_code//size source_code g!end g!char (!number_output source_code start g!end <codec> <tag>)) (!if_digit?+ g!char - (recur (!inc g!end)) + (recur (!++ g!end)) [] (!number_output source_code start g!end <codec> <tag>)))))] @@ -413,13 +413,13 @@ ) (template: (!signed_parser source_code//size offset where source_code @aliases @end) - [(<| (let [g!offset/1 (!inc offset)]) + [(<| (let [g!offset/1 (!++ offset)]) (!with_char+ source_code//size source_code g!offset/1 g!char/1 @end) (!if_digit? g!char/1 - (signed_parser source_code//size offset where (!inc/2 offset) source_code) - (!full_name_parser offset [where (!inc offset) source_code] where @aliases #.Identifier)))]) + (signed_parser source_code//size offset where (!++/2 offset) source_code) + (!full_name_parser offset [where (!++ offset) source_code] where @aliases #.Identifier)))]) -(with_expansions [<output> (#.Right [[(update@ #.column (|>> (!n/+ (!n/- start end))) where) +(with_expansions [<output> (#.Right [[(revised@ #.column (|>> (!n/+ (!n/- start end))) where) end source_code] (!clip start end source_code)])] @@ -430,12 +430,12 @@ (loop [end offset] (<| (!with_char+ source_code//size source_code end char <output>) (!if_name_char?|tail char - (recur (!inc end)) + (recur (!++ end)) <output>)))))) (template: (!half_name_parser @offset @char @module) [(!if_name_char?|head @char - (!letE [source' name] (..name_part_parser @offset where (!inc @offset) source_code) + (!letE [source' name] (..name_part_parser @offset where (!++ @offset) source_code) (#.Right [source' [@module name]])) (!failure ..!half_name_parser where @offset source_code))]) @@ -444,7 +444,7 @@ (<| (!with_char+ source_code//size source_code offset/0 char/0 (!end_of_file where offset/0 source_code current_module)) (if (!n/= (char (~~ (static ..name_separator))) char/0) - (<| (let [offset/1 (!inc offset/0)]) + (<| (let [offset/1 (!++ offset/0)]) (!with_char+ source_code//size source_code offset/1 char/1 (!end_of_file where offset/1 source_code current_module)) (!half_name_parser offset/1 char/1 current_module)) @@ -462,7 +462,7 @@ (let [[where' offset' source_code'] source']) (!with_char source_code' offset' char/separator <simple>) (if (!n/= (char (~~ (static ..name_separator))) char/separator) - (<| (let [offset'' (!inc offset')]) + (<| (let [offset'' (!++ offset')]) (!letE [source'' complex] (..name_part_parser offset'' (!forward 1 where') offset'' source_code')) (if ("lux text =" "" complex) (let [[where offset source_code] source] @@ -482,9 +482,9 @@ ... [expression ...] ... [form "(" [#* expression] ")"]) -(with_expansions [<consume_1> (as_is where (!inc offset/0) source_code) - <move_1> (as_is [(!forward 1 where) (!inc offset/0) source_code]) - <move_2> (as_is [(!forward 1 where) (!inc/2 offset/0) source_code]) +(with_expansions [<consume_1> (as_is where (!++ offset/0) source_code) + <move_1> (as_is [(!forward 1 where) (!++ offset/0) source_code]) + <move_2> (as_is [(!forward 1 where) (!++/2 offset/0) source_code]) <recur> (as_is (parse current_module aliases source_code//size))] (template: (!close closer) @@ -492,8 +492,8 @@ (def: (bit_syntax value [where offset/0 source_code]) (-> Bit (Parser Code)) - (#.Right [[(update@ #.column (|>> !inc/2) where) - (!inc/2 offset/0) + (#.Right [[(revised@ #.column (|>> !++/2) where) + (!++/2 offset/0) source_code] [where (#.Bit value)]])) @@ -530,11 +530,11 @@ ... Text [(~~ (static ..text_delimiter))] - (text_parser where (!inc offset/0) source_code) + (text_parser where (!++ offset/0) source_code) ... Special code [(~~ (static ..sigil))] - (<| (let [offset/1 (!inc offset/0)]) + (<| (let [offset/1 (!++ offset/0)]) (!with_char+ source_code//size source_code offset/1 char/1 (!end_of_file where offset/1 source_code current_module)) ("lux syntax char case!" char/1 @@ -559,15 +559,15 @@ ... (~~ (static ..frac_separator)) ] ... It's either a Rev, an identifier, or a comment. - (with_expansions [<rev_parser> (rev_parser source_code//size offset/0 where (!inc offset/1) source_code) + (with_expansions [<rev_parser> (rev_parser source_code//size offset/0 where (!++ offset/1) source_code) <short_name_parser> (!short_name_parser source_code//size current_module [where offset/1 source_code] where #.Identifier) - <comment_parser> (case ("lux text index" (!inc offset/1) (static text.new_line) source_code) + <comment_parser> (case ("lux text index" (!++ offset/1) (static text.new_line) source_code) (#.Some end) (recur (!vertical where end source_code)) _ (!end_of_file where offset/1 source_code current_module))] - (<| (let [offset/1 (!inc offset/0)]) + (<| (let [offset/1 (!++ offset/0)]) (!with_char+ source_code//size source_code offset/1 char/1 (!end_of_file where offset/1 source_code current_module)) (!if_digit? char/1 @@ -577,7 +577,7 @@ ("lux syntax char case!" char/1 [[(~~ (static ..name_separator))] ... It's either an identifier, or a comment. - (<| (let [offset/2 (!inc offset/1)]) + (<| (let [offset/2 (!++ offset/1)]) (!with_char+ source_code//size source_code offset/2 char/2 (!end_of_file where offset/2 source_code current_module)) ("lux syntax char case!" char/2 @@ -597,7 +597,7 @@ ... else (!if_digit? char/0 ... Natural number - (nat_parser source_code//size offset/0 where (!inc offset/0) source_code) + (nat_parser source_code//size offset/0 where (!++ offset/0) source_code) ... Identifier (!full_name_parser offset/0 [<consume_1>] where aliases #.Identifier)) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index 58dc336dd..7f7d205c3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -190,11 +190,11 @@ (template [<with> <query> <tag> <type>] [(def: .public (<with> value) (-> <type> (All [a] (-> (Operation a) (Operation a)))) - (extension.temporary (set@ <tag> value))) + (extension.temporary (with@ <tag> value))) (def: .public <query> (Operation <type>) - (extension.read (get@ <tag>)))] + (extension.read (value@ <tag>)))] [with_locals locals #locals Nat] [with_currying? currying? #currying? Bit] @@ -204,7 +204,7 @@ (All [a] (-> (Operation a) (Operation a))) (<<| (do phase.monad [locals ..locals]) - (..with_locals (inc locals)))) + (..with_locals (++ locals)))) (template [<name> <tag>] [(template: .public (<name> content) @@ -389,12 +389,12 @@ (#Loop loop) (case loop (#Scope scope) - (|> (format (%.nat (get@ #start scope)) - " " (|> (get@ #inits scope) + (|> (format (%.nat (value@ #start scope)) + " " (|> (value@ #inits scope) (list\map %synthesis) (text.interposed " ") (text.enclosed ["[" "]"])) - " " (%synthesis (get@ #iteration scope))) + " " (%synthesis (value@ #iteration scope))) (text.enclosed ["(#loop " ")"])) (#Recur args) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index 06a2d5ca8..d810d7aca 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -82,7 +82,7 @@ (def: next (-> Archive ID) - (|>> :representation (get@ #next))) + (|>> :representation (value@ #next))) (def: .public empty Archive @@ -111,8 +111,8 @@ (#try.Success [next (|> archive :representation - (update@ #..resolver (dictionary.has module [next #.None])) - (update@ #..next inc) + (revised@ #..resolver (dictionary.has module [next #.None])) + (revised@ #..next ++) :abstraction)])))) (def: .public (has module [descriptor document output] archive) @@ -122,7 +122,7 @@ (#.Some [id #.None]) (#try.Success (|> archive :representation - (update@ #..resolver (dictionary.has module [id (#.Some [descriptor document output])])) + (revised@ #..resolver (dictionary.has module [id (#.Some [descriptor document output])])) :abstraction)) (#.Some [id (#.Some [existing_descriptor existing_document existing_output])]) @@ -160,7 +160,7 @@ (def: .public archived (-> Archive (List Module)) (|>> :representation - (get@ #resolver) + (value@ #resolver) dictionary.entries (list.all (function (_ [module [id descriptor+document]]) (case descriptor+document @@ -180,13 +180,13 @@ (def: .public reserved (-> Archive (List Module)) (|>> :representation - (get@ #resolver) + (value@ #resolver) dictionary.keys)) (def: .public reservations (-> Archive (List [Module ID])) (|>> :representation - (get@ #resolver) + (value@ #resolver) dictionary.entries (list\map (function (_ [module [id _]]) [module id])))) @@ -196,17 +196,17 @@ (let [[+next +resolver] (:representation additions)] (|> archive :representation - (update@ #next (n.max +next)) - (update@ #resolver (function (_ resolver) - (list\fold (function (_ [module [id entry]] resolver) - (case entry - (#.Some _) - (dictionary.has module [id entry] resolver) - - #.None - resolver)) - resolver - (dictionary.entries +resolver)))) + (revised@ #next (n.max +next)) + (revised@ #resolver (function (_ resolver) + (list\fold (function (_ [module [id entry]] resolver) + (case entry + (#.Some _) + (dictionary.has module [id entry] resolver) + + #.None + resolver)) + resolver + (dictionary.entries +resolver)))) :abstraction))) (type: Reservation @@ -281,6 +281,6 @@ {#next next #resolver (list\fold (function (_ [module id] archive) (dictionary.has module [id #.None] archive)) - (get@ #resolver (:representation ..empty)) + (value@ #resolver (:representation ..empty)) reservations)})))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index de1858b97..e4cc633de 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -50,7 +50,7 @@ (def: .public artifacts (-> Registry (Row Artifact)) - (|>> :representation (get@ #artifacts))) + (|>> :representation (value@ #artifacts))) (def: next (-> Registry ID) @@ -62,8 +62,8 @@ [id (|> registry :representation - (update@ #artifacts (row.add {#id id - #category #Anonymous})) + (revised@ #artifacts (row.suffix {#id id + #category #Anonymous})) :abstraction)])) (template [<tag> <create> <fetch>] @@ -73,18 +73,18 @@ [id (|> registry :representation - (update@ #artifacts (row.add {#id id - #category (<tag> name)})) - (update@ #resolver (dictionary.has name id)) + (revised@ #artifacts (row.suffix {#id id + #category (<tag> name)})) + (revised@ #resolver (dictionary.has name id)) :abstraction)])) (def: .public (<fetch> registry) (-> Registry (List Text)) (|> registry :representation - (get@ #artifacts) + (value@ #artifacts) row.list - (list.all (|>> (get@ #category) + (list.all (|>> (value@ #category) (case> (<tag> name) (#.Some name) _ #.None)))))] @@ -99,7 +99,7 @@ (def: .public (remember name registry) (-> Text Registry (Maybe ID)) (|> (:representation registry) - (get@ #resolver) + (value@ #resolver) (dictionary.value name))) (def: .public writer @@ -119,8 +119,8 @@ artifacts (: (Writer (Row Category)) (binary.row/64 category))] (|>> :representation - (get@ #artifacts) - (row\map (get@ #category)) + (value@ #artifacts) + (row\map (value@ #category)) artifacts))) (exception: .public (invalid_category {tag Nat}) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux index 30777c282..a14d708d5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux @@ -59,7 +59,7 @@ (def: .public signature (-> (Document Any) Signature) - (|>> :representation (get@ #signature))) + (|>> :representation (value@ #signature))) (def: .public (writer content) (All [d] (-> (Writer d) (Writer (Document d)))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux index bc413b413..8b4dfedb8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux @@ -29,7 +29,7 @@ (def: .public (description signature) (-> Signature Text) - (format (%.name (get@ #name signature)) " " (%.nat (get@ #version signature)))) + (format (%.name (value@ #name signature)) " " (%.nat (value@ #version signature)))) (def: .public writer (Writer Signature) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux index 2df8c36ec..6ee936f42 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -57,7 +57,7 @@ (do {! state.monad} [.let [parents (case (archive.find module archive) (#try.Success [descriptor document]) - (get@ #descriptor.references descriptor) + (value@ #descriptor.references descriptor) (#try.Failure error) ..fresh)] diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index c5483ac0c..b4fa30d12 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -61,9 +61,9 @@ (def: (archive fs static) (All [!] (-> (file.System !) Static file.Path)) - (format (get@ #static.target static) + (format (value@ #static.target static) (\ fs separator) - (get@ #static.host static))) + (value@ #static.host static))) (def: (unversioned_lux_archive fs static) (All [!] (-> (file.System !) Static file.Path)) @@ -88,7 +88,7 @@ (format (..module fs static module_id) (\ fs separator) (%.nat artifact_id) - (get@ #static.artifact_extension static))) + (value@ #static.artifact_extension static))) (def: (ensure_directory fs path) (-> (file.System Async) file.Path (Async (Try Any))) @@ -125,7 +125,7 @@ (def: .public (enable fs static) (-> (file.System Async) Static (Async (Try Any))) (do (try.with async.monad) - [_ (..ensure_directory fs (get@ #static.target static))] + [_ (..ensure_directory fs (value@ #static.target static))] (..ensure_directory fs (..archive fs static)))) (def: (general_descriptor fs static) @@ -174,7 +174,7 @@ content (document.read $.key document)] (in [module content]))) (archive.archived archive)))] - (in (set@ #.modules modules (fresh_analysis_state host))))) + (in (with@ #.modules modules (fresh_analysis_state host))))) (def: (cached_artifacts fs static module_id) (-> (file.System Async) Static archive.ID (Async (Try (Dictionary Text Binary)))) @@ -231,7 +231,7 @@ (case artifact_category #artifact.Anonymous (do ! - [.let [output (row.add [artifact_id #.None data] output)] + [.let [output (row.suffix [artifact_id #.None data] output)] _ (\ host re_learn context #.None directive)] (in [definitions [analysers @@ -241,7 +241,7 @@ output])) (#artifact.Definition name) - (let [output (row.add [artifact_id #.None data] output)] + (let [output (row.suffix [artifact_id #.None data] output)] (if (text\= $/program.name name) (in [definitions [analysers @@ -260,7 +260,7 @@ (#artifact.Analyser extension) (do ! - [.let [output (row.add [artifact_id #.None data] output)] + [.let [output (row.suffix [artifact_id #.None data] output)] value (\ host re_load context #.None directive)] (in [definitions [(dictionary.has extension (:as analysis.Handler value) analysers) @@ -271,7 +271,7 @@ (#artifact.Synthesizer extension) (do ! - [.let [output (row.add [artifact_id #.None data] output)] + [.let [output (row.suffix [artifact_id #.None data] output)] value (\ host re_load context #.None directive)] (in [definitions [analysers @@ -282,7 +282,7 @@ (#artifact.Generator extension) (do ! - [.let [output (row.add [artifact_id #.None data] output)] + [.let [output (row.suffix [artifact_id #.None data] output)] value (\ host re_load context #.None directive)] (in [definitions [analysers @@ -293,7 +293,7 @@ (#artifact.Directive extension) (do ! - [.let [output (row.add [artifact_id #.None data] output)] + [.let [output (row.suffix [artifact_id #.None data] output)] value (\ host re_load context #.None directive)] (in [definitions [analysers @@ -304,7 +304,7 @@ (#artifact.Custom name) (do ! - [.let [output (row.add [artifact_id (#.Some name) data] output)] + [.let [output (row.suffix [artifact_id (#.Some name) data] output)] _ (\ host re_learn context (#.Some name) directive)] (in [definitions [analysers @@ -333,8 +333,8 @@ (\ ! map (|>> [exported? type annotations] #.Definition [def_name]))))) - (get@ #.definitions content))] - (in [(document.write $.key (set@ #.definitions definitions content)) + (value@ #.definitions content))] + (in [(document.write $.key (with@ #.definitions definitions content)) bundles]))) (def: (load_definitions fs static module_id host_environment descriptor document) @@ -345,8 +345,8 @@ Bundles])))) (do (try.with async.monad) [actual (cached_artifacts fs static module_id) - .let [expected (|> descriptor (get@ #descriptor.registry) artifact.artifacts)] - [document bundles output] (async\in (loaded_document (get@ #static.artifact_extension static) host_environment module_id expected actual document))] + .let [expected (|> descriptor (value@ #descriptor.registry) artifact.artifacts)] + [document bundles output] (async\in (loaded_document (value@ #static.artifact_extension static) host_environment module_id expected actual document))] (in [[descriptor document output] bundles]))) (def: (purge! fs static [module_name module_id]) @@ -361,12 +361,12 @@ (def: (valid_cache? expected actual) (-> Descriptor Input Bit) - (and (text\= (get@ #descriptor.name expected) - (get@ #////.module actual)) - (text\= (get@ #descriptor.file expected) - (get@ #////.file actual)) - (n.= (get@ #descriptor.hash expected) - (get@ #////.hash actual)))) + (and (text\= (value@ #descriptor.name expected) + (value@ #////.module actual)) + (text\= (value@ #descriptor.file expected) + (value@ #////.file actual)) + (n.= (value@ #descriptor.hash expected) + (value@ #////.hash actual)))) (type: Purge (Dictionary Module archive.ID)) @@ -390,7 +390,7 @@ (if (purged? module_name) purge (if (|> descriptor - (get@ #descriptor.references) + (value@ #descriptor.references) set.list (list.any? purged?)) (dictionary.has module_name module_id purge) @@ -417,7 +417,7 @@ (in [true [module_name [module_id [descriptor document]]]]) (do ! - [input (//context.read fs ..pseudo_module import contexts (get@ #static.host_module_extension static) module_name)] + [input (//context.read fs ..pseudo_module import contexts (value@ #static.host_module_extension static) module_name)] (in [(..valid_cache? descriptor input) [module_name [module_id [descriptor document]]]]))))))) load_order (|> pre_loaded_caches @@ -447,7 +447,7 @@ (archive.has module descriptor,document,output archive)) archive loaded_caches) - analysis_state (..analysis_state (get@ #static.host static) archive)] + analysis_state (..analysis_state (value@ #static.host static) archive)] (in [archive analysis_state (list\fold (function (_ [_ [+analysers +synthesizers +generators +directives]] @@ -473,5 +473,5 @@ (#try.Failure error) (in (#try.Success [archive.empty - (fresh_analysis_state (get@ #static.host static)) + (fresh_analysis_state (value@ #static.host static)) ..empty_bundles]))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index 0c7969507..979edaa76 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -6,6 +6,7 @@ [predicate (#+ Predicate)] ["." monad (#+ Monad do)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] [concurrency @@ -17,7 +18,8 @@ [encoding ["." utf8]]] [collection - ["." dictionary (#+ Dictionary)]]] + ["." dictionary (#+ Dictionary)] + ["." list]]] [world ["." file]]]] [program @@ -138,8 +140,8 @@ (type: .public Enumeration (Dictionary file.Path Binary)) -(def: (context_listing fs directory enumeration) - (-> (file.System Async) Context Enumeration (Async (Try Enumeration))) +(def: (context_listing fs context directory enumeration) + (-> (file.System Async) Context file.Path Enumeration (Async (Try Enumeration))) (do {! (try.with async.monad)} [enumeration (|> directory (\ fs directory_files) @@ -147,23 +149,40 @@ (if (text.ends_with? ..lux_extension file) (do ! [source_code (\ fs read file)] - (async\in (dictionary.has' (file.name fs file) source_code enumeration))) + (async\in (dictionary.has' (text.replaced context "" file) source_code enumeration))) (in enumeration))) enumeration)) (\ ! join))] (|> directory (\ fs sub_directories) - (\ ! map (monad.fold ! (context_listing fs) enumeration)) + (\ ! map (monad.fold ! (context_listing fs context) enumeration)) (\ ! join)))) (def: Action (type (All [a] (Async (Try a))))) +(def: (canonical fs context) + (-> (file.System Async) Context (Action Context)) + (do (try.with async.monad) + [subs (\ fs sub_directories context)] + (in (|> subs + list.head + (maybe.else context) + (file.parent fs) + (maybe.else context))))) + (def: .public (listing fs contexts) (-> (file.System Async) (List Context) (Action Enumeration)) - (monad.fold (: (Monad Action) - (try.with async.monad)) - (..context_listing fs) - (: Enumeration - (dictionary.empty text.hash)) - contexts)) + (let [! (: (Monad Action) + (try.with async.monad))] + (monad.fold ! + (function (_ context enumeration) + (do ! + [context (..canonical fs context)] + (..context_listing fs + (format context (\ fs separator)) + context + enumeration))) + (: Enumeration + (dictionary.empty text.hash)) + contexts))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager.lux b/stdlib/source/library/lux/tool/compiler/meta/packager.lux index 21c15d551..744d0ecb9 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager.lux @@ -35,8 +35,8 @@ (-> dependency.Order Order) (list\map (function (_ [module [module_id [descriptor document]]]) (|> descriptor - (get@ #descriptor.registry) + (value@ #descriptor.registry) artifact.artifacts row.list - (list\map (|>> (get@ #artifact.id))) + (list\map (|>> (value@ #artifact.id))) [module_id])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index 06ef9b25b..d9707b0c0 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -143,7 +143,7 @@ (let [class_path (|> custom (maybe\map (|>> name.internal name.read)) (maybe.else (runtime.class_name [module artifact])) - (text.suffix (get@ #static.artifact_extension static)))] + (text.suffix (value@ #static.artifact_extension static)))] (do try.monad [_ (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path) sink)] (in (do_to sink diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index 90d28197a..a229c78a1 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -104,7 +104,7 @@ (..bundle_module output)) entry_content (: (Try tar.Content) (|> descriptor - (get@ #descriptor.references) + (value@ #descriptor.references) set.list (list.all (function (_ module) (dictionary.value module mapping))) (list\map (|>> ..module_file _.string _.load_relative/1)) diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index 6e28d5c1a..ee02eacc9 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -75,14 +75,14 @@ (do Monad<!> [state (platform.initialize platform generation_bundle) state (platform.compile platform - (set@ #cli.module syntax.prelude configuration) - (set@ [#extension.state - #directive.analysis #directive.state - #extension.state - #.info #.mode] - #.Interpreter - state)) - [state _] (\ (get@ #platform.file_system platform) + (with@ #cli.module syntax.prelude configuration) + (with@ [#extension.state + #directive.analysis #directive.state + #extension.state + #.info #.mode] + #.Interpreter + state)) + [state _] (\ (value@ #platform.file_system platform) lift (phase.result' state enter_module)) _ (\ Console<!> write ..welcome_message)] (in state))) @@ -102,9 +102,9 @@ (-> Code <Interpretation>)) (do {! phase.monad} [state (extension.lifted phase.get_state) - .let [analyse (get@ [#directive.analysis #directive.phase] state) - synthesize (get@ [#directive.synthesis #directive.phase] state) - generate (get@ [#directive.generation #directive.phase] state)] + .let [analyse (value@ [#directive.analysis #directive.phase] state) + synthesize (value@ [#directive.synthesis #directive.phase] state) + generate (value@ [#directive.generation #directive.phase] state)] [_ codeT codeA] (directive.lifted_analysis (analysis.with_scope (type.with_fresh_env @@ -154,10 +154,10 @@ (do phase.monad [[codeT codeV] (interpret configuration code) state phase.get_state] - (in (/type.represent (get@ [#extension.state - #directive.analysis #directive.state - #extension.state] - state) + (in (/type.represent (value@ [#extension.state + #directive.analysis #directive.state + #extension.state] + state) codeT codeV)))) @@ -171,24 +171,24 @@ (All [anchor expression directive] (-> <Context> (Try [<Context> Text]))) (do try.monad - [.let [[_where _offset _code] (get@ #source context)] - [source' input] (syntax.parse ..module syntax.no_aliases (text.size _code) (get@ #source context)) + [.let [[_where _offset _code] (value@ #source context)] + [source' input] (syntax.parse ..module syntax.no_aliases (text.size _code) (value@ #source context)) [state' representation] (let [... TODO: Simplify ASAP state (:sharing [anchor expression directive] {<Context> context} {(State+ anchor expression directive) - (get@ #state context)})] + (value@ #state context)})] (<| (phase.result' state) ... TODO: Simplify ASAP (:sharing [anchor expression directive] {<Context> context} {(Operation anchor expression directive Text) - (execute (get@ #configuration context) input)})))] + (execute (value@ #configuration context) input)})))] (in [(|> context - (set@ #state state') - (set@ #source source')) + (with@ #state state') + (with@ #source source')) representation])))) (def: .public (run! Monad<!> Console<!> platform configuration generation_bundle) @@ -212,7 +212,7 @@ (if (and (not multi_line?) (text\= ..exit_command line)) (\ Console<!> write ..farewell_message) - (case (read_eval_print (update@ #source (add_line line) context)) + (case (read_eval_print (revised@ #source (add_line line) context)) (#try.Success [context' representation]) (do ! [_ (\ Console<!> write representation)] @@ -222,5 +222,5 @@ (if (ex.match? syntax.end_of_file error) (recur context #1) (exec (log! (ex.error ..error error)) - (recur (set@ #source ..fresh_source context) #0)))))) + (recur (with@ #source ..fresh_source context) #0)))))) ))) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index c6be00945..2a99dded3 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -36,7 +36,7 @@ type type] (case type (<tag> env sub_type) - (recur (inc num_args) sub_type) + (recur (++ num_args) sub_type) _ [num_args type])))] @@ -345,7 +345,7 @@ (-> Nat Type Type) (case size 0 body - _ (|> body (<name> (dec size)) (<tag> (list)))))] + _ (|> body (<name> (-- size)) (<tag> (list)))))] [univ_q #.UnivQ] [ex_q #.ExQ] @@ -375,7 +375,7 @@ (case depth 0 element_type _ (|> element_type - (array (dec depth)) + (array (-- depth)) (list) (#.Primitive array.type_name)))) @@ -386,7 +386,7 @@ (^multi (^ (#.Primitive name (list element_type))) (text\= array.type_name name)) (let [[depth element_type] (flat_array element_type)] - [(inc depth) element_type]) + [(++ depth) element_type]) _ [0 type])) @@ -487,11 +487,11 @@ (bar expression))))} (macro.with_identifiers [g!_] (let [shareC (` (: (All [(~+ (list\map code.local_identifier type_vars))] - (-> (~ (get@ #type exemplar)) - (~ (get@ #type computation)))) + (-> (~ (value@ #type exemplar)) + (~ (value@ #type computation)))) (.function ((~ g!_) (~ g!_)) - (~ (get@ #expression computation)))))] - (in (list (` ((~ shareC) (~ (get@ #expression exemplar))))))))) + (~ (value@ #expression computation)))))] + (in (list (` ((~ shareC) (~ (value@ #expression exemplar))))))))) (syntax: .public (:by_example [type_vars ..type_parameters exemplar ..typed @@ -509,8 +509,8 @@ (in (list (` (:of ((~! :sharing) [(~+ (list\map code.local_identifier type_vars))] - (~ (get@ #type exemplar)) - (~ (get@ #expression exemplar)) + (~ (value@ #type exemplar)) + (~ (value@ #expression exemplar)) (~ extraction) (:expected []))))))) diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index 25c864755..9b657cb19 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -69,7 +69,7 @@ (def: (peek_frames reference definition_reference source) (-> Text Text (List [Text Module]) (Stack Frame)) (!peek source reference - (peek_frames_definition definition_reference (get@ #.definitions head)))) + (peek_frames_definition definition_reference (value@ #.definitions head)))) (exception: .public no_active_frames) @@ -77,7 +77,7 @@ (-> (Maybe Text) (Meta Frame)) (function (_ compiler) (let [[reference definition_reference] (name_of ..frames) - current_frames (peek_frames reference definition_reference (get@ #.modules compiler))] + current_frames (peek_frames reference definition_reference (value@ #.modules compiler))] (case (case frame (#.Some frame) (list.example (function (_ [actual _]) @@ -131,14 +131,14 @@ (def: (push_frame [module_reference definition_reference] frame source) (-> Name Frame (List [Text Module]) (List [Text Module])) (!push source module_reference - (update@ #.definitions (push_frame_definition definition_reference frame) head))) + (revised@ #.definitions (push_frame_definition definition_reference frame) head))) (def: (push! frame) (-> Frame (Meta Any)) (function (_ compiler) - (#.Right [(update@ #.modules - (..push_frame (name_of ..frames) frame) - compiler) + (#.Right [(revised@ #.modules + (..push_frame (name_of ..frames) frame) + compiler) []]))) (def: (pop_frame_definition reference source) @@ -163,13 +163,13 @@ (def: (pop_frame [module_reference definition_reference] source) (-> Name (List [Text Module]) (List [Text Module])) (!push source module_reference - (|> head (update@ #.definitions (pop_frame_definition definition_reference))))) + (|> head (revised@ #.definitions (pop_frame_definition definition_reference))))) (syntax: (pop! []) (function (_ compiler) - (#.Right [(update@ #.modules - (..pop_frame (name_of ..frames)) - compiler) + (#.Right [(revised@ #.modules + (..pop_frame (name_of ..frames)) + compiler) (list)]))) (def: cast diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index b4aedaef1..aa8e213af 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -188,15 +188,15 @@ {#.doc "A brand-new existential type."} (Check [Nat Type]) (function (_ context) - (let [id (get@ #.ex_counter context)] - (#try.Success [(update@ #.ex_counter inc context) + (let [id (value@ #.ex_counter context)] + (#try.Success [(revised@ #.ex_counter ++ context) [id (#.Ex id)]])))) (template [<name> <outputT> <fail> <succeed>] [(def: .public (<name> id) (-> Var (Check <outputT>)) (function (_ context) - (case (|> context (get@ #.var_bindings) (var::get id)) + (case (|> context (value@ #.var_bindings) (var::get id)) (^or (#.Some (#.Some (#.Var _))) (#.Some #.None)) (#try.Success [context <fail>]) @@ -208,13 +208,13 @@ (exception.except ..unknown_type_var id))))] [bound? Bit false true] - [read (Maybe Type) #.None (#.Some bound)] + [read' (Maybe Type) #.None (#.Some bound)] ) -(def: .public (read! id) +(def: .public (read id) (-> Var (Check Type)) (do ..monad - [?type (read id)] + [?type (read' id)] (case ?type (#.Some type) (in type) @@ -225,7 +225,7 @@ (def: (bound id) (-> Var (Check Type)) (function (_ context) - (case (|> context (get@ #.var_bindings) (var::get id)) + (case (|> context (value@ #.var_bindings) (var::get id)) (#.Some (#.Some bound)) (#try.Success [context bound]) @@ -240,9 +240,9 @@ "Fails if the variable has been bound already.")} (-> Type Var (Check Any)) (function (_ context) - (case (|> context (get@ #.var_bindings) (var::get id)) + (case (|> context (value@ #.var_bindings) (var::get id)) (#.Some #.None) - (#try.Success [(update@ #.var_bindings (var::put id (#.Some type)) context) + (#try.Success [(revised@ #.var_bindings (var::put id (#.Some type)) context) []]) (#.Some (#.Some bound)) @@ -251,12 +251,12 @@ _ (exception.except ..unknown_type_var id)))) -(def: (update type id) +(def: (re_bind type id) (-> Type Var (Check Any)) (function (_ context) - (case (|> context (get@ #.var_bindings) (var::get id)) + (case (|> context (value@ #.var_bindings) (var::get id)) (#.Some _) - (#try.Success [(update@ #.var_bindings (var::put id (#.Some type)) context) + (#try.Success [(revised@ #.var_bindings (var::put id (#.Some type)) context) []]) _ @@ -266,29 +266,29 @@ {#.doc (example "A brand-new (unbound) type-variable.")} (Check [Var Type]) (function (_ context) - (let [id (get@ #.var_counter context)] + (let [id (value@ #.var_counter context)] (#try.Success [(|> context - (update@ #.var_counter inc) - (update@ #.var_bindings (var::new id))) + (revised@ #.var_counter ++) + (revised@ #.var_bindings (var::new id))) [id (#.Var id)]])))) -(def: (apply_type! funcT argT) +(def: (on argT funcT) (-> Type Type (Check Type)) (case funcT (#.Var func_id) (do ..monad - [?funcT' (read func_id)] + [?funcT' (read' func_id)] (case ?funcT' (#.Some funcT') - (apply_type! funcT' argT) + (on argT funcT') _ (except ..invalid_type_application [funcT argT]))) (#.Apply argT' funcT') (do ..monad - [funcT'' (apply_type! funcT' argT')] - (apply_type! funcT'' argT)) + [funcT'' (on argT' funcT')] + (on argT funcT'')) _ (case (//.applied (list argT) funcT) @@ -311,7 +311,7 @@ (function (_ context) (loop [current start output (set.has start empty_ring)] - (case (|> context (get@ #.var_bindings) (var::get current)) + (case (|> context (value@ #.var_bindings) (var::get current)) (#.Some (#.Some type)) (case type (#.Var post) @@ -362,12 +362,8 @@ (//\= a a'))) assumptions)) -(def: (assume! assumption assumptions) - (-> Assumption (List Assumption) (List Assumption)) - (#.Item assumption assumptions)) - -... TODO: "if_bind" can be optimized... -(def: (if_bind id type then else) +... TODO: "if_can_bind" can be optimized... +(def: (if_can_bind id type then else) (All [a] (-> Var Type (Check a) (-> Type (Check a)) (Check a))) @@ -378,10 +374,10 @@ (do {! ..monad} [ring (..ring id) _ (..assertion "" (n.> 1 (set.size ring))) - _ (monad.map ! (update type) (set.list ring))] + _ (monad.map ! (re_bind type) (set.list ring))] then) (do ..monad - [?bound (read id)] + [?bound (read' id)] (else (maybe.else (#.Var id) ?bound))))) ... TODO: "link/2" can be optimized... @@ -395,8 +391,8 @@ (def: (link/3 interpose to from) (-> Var Var Var (Check Any)) (do ..monad - [_ (update (#.Var interpose) from)] - (update (#.Var to) interpose))) + [_ (re_bind (#.Var interpose) from)] + (re_bind (#.Var to) interpose))) ... TODO: "check_vars" can be optimized... (def: (check_vars check' assumptions idE idA) @@ -457,7 +453,7 @@ [<pattern> (do ! [ring (..ring <id>) - _ (monad.map ! (update <type>) (set.list ring))] + _ (monad.map ! (re_bind <type>) (set.list ring))] (in assumptions))]) ([[(#.Var _) _] idE atype] [[_ (#.Var _)] idA etype]) @@ -482,22 +478,22 @@ [(#.UnivQ _ _) (#.Ex _)] (do ..monad - [expected' (apply_type! expected_function expected_input)] + [expected' (..on expected_input expected_function)] (check' assumptions expected' (#.Apply actual))) [(#.Ex _) (#.UnivQ _ _)] (do ..monad - [actual' (apply_type! actual_function actual_input)] + [actual' (..on actual_input actual_function)] (check' assumptions (#.Apply expected) actual')) [(#.Apply [expected_input' expected_function']) (#.Ex _)] (do ..monad - [expected_function'' (apply_type! expected_function' expected_input')] + [expected_function'' (..on expected_input' expected_function')] (check' assumptions (#.Apply [expected_input expected_function'']) (#.Apply actual))) [(#.Ex _) (#.Apply [actual_input' actual_function'])] (do ..monad - [actual_function'' (apply_type! actual_function' actual_input')] + [actual_function'' (..on actual_input' actual_function')] (check' assumptions (#.Apply expected) (#.Apply [actual_input actual_function'']))) (^or [(#.Ex _) _] [_ (#.Ex _)]) @@ -508,7 +504,7 @@ [(#.Var id) _] (function (_ context) (case ((do ..monad - [expected_function' (..read! id)] + [expected_function' (..read id)] (check' assumptions (#.Apply expected_input expected_function') (#.Apply actual))) context) (#try.Success output) @@ -518,7 +514,7 @@ (case actual_function (#.UnivQ _ _) ((do ..monad - [actual' (apply_type! actual_function actual_input)] + [actual' (..on actual_input actual_function)] (check' assumptions (#.Apply expected) actual')) context) @@ -531,15 +527,15 @@ _ ((do ..monad [assumptions (check' assumptions expected_function actual_function) - expected' (apply_type! actual_function expected_input) - actual' (apply_type! actual_function actual_input)] + expected' (..on expected_input actual_function) + actual' (..on actual_input actual_function)] (check' assumptions expected' actual')) context)))) [_ (#.Var id)] (function (_ context) (case ((do ..monad - [actual_function' (read! id)] + [actual_function' (read id)] (check' assumptions (#.Apply expected) (#.Apply actual_input actual_function'))) context) (#try.Success output) @@ -548,8 +544,8 @@ _ ((do ..monad [assumptions (check' assumptions expected_function actual_function) - expected' (apply_type! expected_function expected_input) - actual' (apply_type! expected_function actual_input)] + expected' (..on expected_input expected_function) + actual' (..on actual_input expected_function)] (check' assumptions expected' actual')) context))) @@ -573,16 +569,16 @@ (check_vars check' assumptions idE idA) [(#.Var id) _] - (if_bind id actual - (check\in assumptions) - (function (_ bound) - (check' assumptions bound actual))) + (if_can_bind id actual + (check\in assumptions) + (function (_ bound) + (check' assumptions bound actual))) [_ (#.Var id)] - (if_bind id expected - (check\in assumptions) - (function (_ bound) - (check' assumptions expected bound))) + (if_can_bind id expected + (check\in assumptions) + (function (_ bound) + (check' assumptions expected bound))) (^template [<fE> <fA>] [[(#.Apply aE <fE>) (#.Apply aA <fA>)] @@ -597,12 +593,12 @@ (if (assumed? new_assumption assumptions) (check\in assumptions) (do ..monad - [expected' (apply_type! F A)] - (check' (assume! new_assumption assumptions) expected' actual)))) + [expected' (..on A F)] + (check' (#.Item new_assumption assumptions) expected' actual)))) [_ (#.Apply A F)] (do ..monad - [actual' (apply_type! F A)] + [actual' (..on A F)] (check' assumptions expected actual')) ... TODO: Refactor-away as cold-code @@ -610,7 +606,7 @@ [[(<tag> _) _] (do ..monad [[_ paramT] <instancer> - expected' (apply_type! expected paramT)] + expected' (..on paramT expected)] (check' assumptions expected' actual))]) ([#.UnivQ ..existential] [#.ExQ ..var]) @@ -620,7 +616,7 @@ [[_ (<tag> _)] (do ..monad [[_ paramT] <instancer> - actual' (apply_type! actual paramT)] + actual' (..on paramT actual)] (check' assumptions expected actual'))]) ([#.UnivQ ..var] [#.ExQ ..existential]) @@ -713,7 +709,7 @@ (#.Var id) (do ..monad - [?actualT (read id)] + [?actualT (read' id)] (case ?actualT (#.Some actualT) (clean actualT) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 99cafdcda..cc54a82a1 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -30,7 +30,7 @@ (def: (type_var id env) (-> Nat Type_Context (Meta Type)) (case (list.example (|>> product.left (n.= id)) - (get@ #.var_bindings env)) + (value@ #.var_bindings env)) (#.Some [_ (#.Some type)]) (case type (#.Var id') @@ -53,7 +53,7 @@ compiler meta.compiler_state] (case raw_type (#.Var id) - (type_var id (get@ #.type_context compiler)) + (type_var id (value@ #.type_context compiler)) _ (in raw_type)))) @@ -75,7 +75,7 @@ (#.Product left right) (if (n.= 0 idx) (\ check.monad in left) - (member_type (dec idx) right)) + (member_type (-- idx) right)) _ (if (n.= 0 idx) @@ -336,7 +336,7 @@ (list.indices 10) (list.indices 10)) "(Functor List) map" - (\\ map inc (list.indices 10)) + (\\ map ++ (list.indices 10)) "Caveat emptor: You need to make sure to import the module of any implementation you want to use." "Otherwise, this macro will not find it.")} (case args @@ -364,7 +364,7 @@ (#.Right [args _]) (do {! meta.monad} - [labels (|> (macro.identifier "") (list.repeated (list.size args)) (monad.seq !))] + [labels (|> (macro.identifier "") (list.repeated (list.size args)) (monad.all !))] (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\map ..pair_list) list\join))] (..\\ (~ (code.identifier member)) (~+ labels))))))) )) @@ -373,7 +373,7 @@ (-> Nat (Meta (List Code))) (|> (macro.identifier "g!implicit") (list.repeated amount) - (monad.seq meta.monad))) + (monad.all meta.monad))) (def: implicits (Parser (List Code)) diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index edd21a88c..51f0b7618 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -86,7 +86,7 @@ (let [idx (<type>.adjusted_idx env idx)] (if (n.= 0 idx) (|> (dictionary.value idx env) maybe.trusted product.left (code env)) - (` (.$ (~ (code.nat (dec idx))))))) + (` (.$ (~ (code.nat (-- idx))))))) (#.Apply (#.Named [(~~ (static .prelude_module)) "Nothing"] _) (#.Parameter idx)) (let [idx (<type>.adjusted_idx env idx)] diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux index 0006d9dbd..6334d68f3 100644 --- a/stdlib/source/library/lux/type/quotient.lux +++ b/stdlib/source/library/lux/type/quotient.lux @@ -40,7 +40,7 @@ (template [<name> <output> <slot>] [(def: .public <name> (All [t c %] (-> (Quotient t c %) <output>)) - (|>> :representation (get@ <slot>)))] + (|>> :representation (value@ <slot>)))] [value t #value] [label c #label] diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 4e1a88c09..7bb718659 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -34,7 +34,7 @@ (template [<name> <output> <slot>] [(def: .public <name> (All [t %] (-> (Refined t %) <output>)) - (|>> :representation (get@ <slot>)))] + (|>> :representation (value@ <slot>)))] [value t #value] [predicate (Predicate t) #predicate] diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 5ee949bd3..fee4aaf79 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -55,7 +55,7 @@ (function (_ keys) (\ monad in [keys value]))) - (def: (bind f input) + (def: (then f input) (function (_ keysI) (do monad [[keysT value] (input keysI)] @@ -166,12 +166,12 @@ (#.Item head tail) (do {! meta.monad} [.let [max_idx (list\fold n.max head tail)] - g!inputs (<| (monad.seq !) (list.repeated (inc max_idx)) (macro.identifier "input")) + g!inputs (<| (monad.all !) (list.repeated (++ max_idx)) (macro.identifier "input")) .let [g!outputs (|> (monad.fold maybe.monad (function (_ from to) (do maybe.monad [input (list.item from g!inputs)] - (in (row.add input to)))) + (in (row.suffix input to)))) (: (Row Code) row.empty) swaps) maybe.trusted @@ -210,7 +210,7 @@ (do {! meta.monad} [g!keys (|> (macro.identifier "keys") (list.repeated amount) - (monad.seq !))] + (monad.all !))] (in (list (` (: (All [(~ g!!) (~+ g!keys) (~ g!context)] (-> ((~! monad.Monad) (~ g!!)) (Procedure (~ g!!) diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux index fcbfe0711..e18af25b0 100644 --- a/stdlib/source/library/lux/type/unit.lux +++ b/stdlib/source/library/lux/type/unit.lux @@ -217,5 +217,5 @@ (All [unit] (Enum (Qty unit))) (def: &order ..order) - (def: succ (|>> ..out inc ..in)) - (def: pred (|>> ..out dec ..in))) + (def: succ (|>> ..out ++ ..in)) + (def: pred (|>> ..out -- ..in))) diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux index 2906cebeb..76c1cc17b 100644 --- a/stdlib/source/library/lux/world/db/jdbc.lux +++ b/stdlib/source/library/lux/world/db/jdbc.lux @@ -92,10 +92,10 @@ (-> java/sql/PreparedStatement (IO (Try a))) (IO (Try a)))) (do (try.with io.monad) - [prepared (io.io (java/sql/Connection::prepareStatement (sql.sql (get@ #sql statement)) + [prepared (io.io (java/sql/Connection::prepareStatement (sql.sql (value@ #sql statement)) (java/sql/Statement::RETURN_GENERATED_KEYS) conn)) - _ (io.io ((get@ #input statement) (get@ #value statement) [1 prepared])) + _ (io.io ((value@ #input statement) (value@ #value statement) [1 prepared])) result (action prepared) _ (java/sql/Statement::close prepared)] (in result))) @@ -114,29 +114,29 @@ (def: .public (connect creds) (-> Credentials (IO (Try (DB IO)))) (do (try.with io.monad) - [connection (java/sql/DriverManager::getConnection (get@ #url creds) - (get@ #user creds) - (get@ #password creds))] + [connection (java/sql/DriverManager::getConnection (value@ #url creds) + (value@ #user creds) + (value@ #password creds))] (in (: (DB IO) (implementation (def: execute (..can_execute (function (execute statement) (with_statement statement connection - (function (_ prepared) - (do (try.with io.monad) - [row_count (java/sql/PreparedStatement::executeUpdate prepared)] - (in (.nat row_count)))))))) + (function (_ prepared) + (do (try.with io.monad) + [row_count (java/sql/PreparedStatement::executeUpdate prepared)] + (in (.nat row_count)))))))) (def: insert (..can_insert (function (insert statement) (with_statement statement connection - (function (_ prepared) - (do (try.with io.monad) - [_ (java/sql/PreparedStatement::executeUpdate prepared) - result_set (io.io (java/sql/Statement::getGeneratedKeys prepared))] - (/output.rows /output.long result_set))))))) + (function (_ prepared) + (do (try.with io.monad) + [_ (java/sql/PreparedStatement::executeUpdate prepared) + result_set (io.io (java/sql/Statement::getGeneratedKeys prepared))] + (/output.rows /output.long result_set))))))) (def: close (..can_close @@ -147,10 +147,10 @@ (..can_query (function (query [statement output]) (with_statement statement connection - (function (_ prepared) - (do (try.with io.monad) - [result_set (java/sql/PreparedStatement::executeQuery prepared)] - (/output.rows output result_set))))))) + (function (_ prepared) + (do (try.with io.monad) + [result_set (java/sql/PreparedStatement::executeQuery prepared)] + (/output.rows output result_set))))))) ))))) (def: .public (with_db creds action) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index fe510ea66..4a2f43507 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -75,7 +75,7 @@ (function (_ value [idx statement]) (do try.monad [_ (<setter> (.int idx) value statement)] - (in [(.inc idx) statement]))))] + (in [(.++ idx) statement]))))] [boolean Bit java/sql/PreparedStatement::setBoolean] @@ -99,7 +99,7 @@ [_ (<setter> (.int idx) (<constructor> (instant.millis value)) statement)] - (in [(.inc idx) statement]))))] + (in [(.++ idx) statement]))))] [date java/sql/PreparedStatement::setDate java/sql/Date::new] [time java/sql/PreparedStatement::setTime java/sql/Time::new] diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index 08c7354f5..e6e9a8306 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -121,7 +121,7 @@ (#try.Failure error) (#try.Success value) - (#try.Success [(inc idx) value]))))] + (#try.Success [(++ idx) value]))))] [boolean java/sql/ResultSet::getBoolean Bit] @@ -146,7 +146,7 @@ (#try.Failure error) (#try.Success value) - (#try.Success [(inc idx) + (#try.Success [(++ idx) (instant.from_millis (java/util/Date::getTime value))]))))] [date java/sql/ResultSet::getDate] diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index e6c10352f..05925b4e8 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -1059,8 +1059,8 @@ [(#.Left file) #.End] (#try.Success (dictionary.has head (#.Left (|> file - (set@ #mock_last_modified now) - (set@ #mock_content content))) + (with@ #mock_last_modified now) + (with@ #mock_content content))) directory)) [(#.Right sub_directory) (#.Item _)] @@ -1239,7 +1239,7 @@ (in (|> |store| (..retrieve_mock_file! separator path) (try\map (|>> product.right - (get@ #mock_content) + (value@ #mock_content) binary.size))))))) (def: (last_modified path) @@ -1249,7 +1249,7 @@ (in (|> |store| (..retrieve_mock_file! separator path) (try\map (|>> product.right - (get@ #mock_last_modified)))))))) + (value@ #mock_last_modified)))))))) (def: (can_execute? path) (stm.commit! @@ -1258,7 +1258,7 @@ (in (|> |store| (..retrieve_mock_file! separator path) (try\map (|>> product.right - (get@ #mock_can_execute)))))))) + (value@ #mock_can_execute)))))))) (def: (read path) (stm.commit! @@ -1267,7 +1267,7 @@ (in (|> |store| (..retrieve_mock_file! separator path) (try\map (|>> product.right - (get@ #mock_content)))))))) + (value@ #mock_content)))))))) (def: (delete path) (stm.commit! @@ -1278,7 +1278,7 @@ (..attempt! (function (_ |store|) (do try.monad [[name file] (..retrieve_mock_file! separator path |store|)] - (..update_mock_file! separator path now (get@ #mock_content file) |store|))) + (..update_mock_file! separator path now (value@ #mock_content file) |store|))) store))) (def: (write content path) @@ -1296,7 +1296,7 @@ [[name file] (..retrieve_mock_file! separator path |store|)] (..update_mock_file! separator path now (\ binary.monoid compose - (get@ #mock_content file) + (value@ #mock_content file) content) |store|))) store)))) @@ -1308,7 +1308,7 @@ (case (do try.monad [[name file] (..retrieve_mock_file! separator origin |store|) |store| (..delete_mock_node! separator origin |store|)] - (..update_mock_file! separator destination (get@ #mock_last_modified file) (get@ #mock_content file) |store|)) + (..update_mock_file! separator destination (value@ #mock_last_modified file) (value@ #mock_content file) |store|)) (#try.Success |store|) (do ! [_ (stm.write |store| store)] diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 3a0b98f86..0e5deec4a 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -56,7 +56,7 @@ (def: .public <predicate> (Predicate Concern) - (|>> :representation (get@ <event>)))] + (|>> :representation (value@ <event>)))] [creation creation? #create true false false] @@ -283,7 +283,7 @@ (loop [idx 0 output #.End] (if (n.< size idx) - (recur (inc idx) + (recur (++ idx) (#.Item (java/util/List::get (.int idx) list) output)) output)))) @@ -365,7 +365,7 @@ (def: (default_start watch_events watcher path) (-> (List Watch_Event) java/nio/file/WatchService //.Path (Async (Try java/nio/file/WatchKey))) (let [watch_events' (list\fold (function (_ [index watch_event] watch_events') - (ffi.array_write index watch_event watch_events')) + (ffi.write! index watch_event watch_events')) (ffi.array (java/nio/file/WatchEvent$Kind java/lang/Object) (list.size watch_events)) (list.enumeration watch_events))] diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 167d87c88..50a5a2436 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -182,7 +182,7 @@ (#.Some name) (do ! [?value (java/net/URLConnection::getHeaderField index connection)] - (recur (inc index) + (recur (++ index) (dictionary.has name (maybe.else "" ?value) headers))) #.None @@ -232,10 +232,10 @@ async.future (\ async.monad map (|>> (case> (#try.Success [status message]) - (#try.Success [status (update@ #//.body (: (-> (//.Body IO) (//.Body Async)) - (function (_ body) - (|>> body async.future))) - message)]) + (#try.Success [status (revised@ #//.body (: (-> (//.Body IO) (//.Body Async)) + (function (_ body) + (|>> body async.future))) + message)]) (#try.Failure error) (#try.Failure error))))))) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 6d9e94b8e..5b0a254e4 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -56,7 +56,7 @@ (All [a] (-> (<json>.Reader a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?raw (read_text_body (get@ #//.body message))] + [?raw (read_text_body (value@ #//.body message))] (case (do try.monad [raw ?raw content (\ json.codec decode raw)] @@ -71,7 +71,7 @@ (-> (-> Text Server) Server) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?raw (read_text_body (get@ #//.body message))] + [?raw (read_text_body (value@ #//.body message))] (case ?raw (#try.Success content) (server content request) @@ -82,14 +82,14 @@ (def: .public (query property server) (All [a] (-> (Property a) (-> a Server) Server)) (function (_ [identification protocol resource message]) - (let [full (get@ #//.uri resource) + (let [full (value@ #//.uri resource) [uri query] (|> full (text.split_by "?") (maybe.else [full ""]))] (case (do try.monad [query (//query.parameters query) input (context.result query property)] - (in [[identification protocol (set@ #//.uri uri resource) message] + (in [[identification protocol (with@ #//.uri uri resource) message] input])) (#try.Success [request input]) (server input request) @@ -101,7 +101,7 @@ (All [a] (-> (Property a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?body (read_text_body (get@ #//.body message))] + [?body (read_text_body (value@ #//.body message))] (case (do try.monad [body ?body form (//query.parameters body)] @@ -116,7 +116,7 @@ (All [a] (-> (Property a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (case (do try.monad - [cookies (|> (get@ #//.headers message) + [cookies (|> (value@ #//.headers message) (dictionary.value "Cookie") (maybe.else "") //cookie.get)] diff --git a/stdlib/source/library/lux/world/net/http/response.lux b/stdlib/source/library/lux/world/net/http/response.lux index 9d74ced0c..b49715c4d 100644 --- a/stdlib/source/library/lux/world/net/http/response.lux +++ b/stdlib/source/library/lux/world/net/http/response.lux @@ -40,7 +40,7 @@ (def: .public (temporary_redirect to) (-> URL Response) (let [[status message] (..empty status.temporary_redirect)] - [status (update@ #//.headers (header.location to) message)])) + [status (revised@ #//.headers (header.location to) message)])) (def: .public not_found Response diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux index a650f53d2..9689e3414 100644 --- a/stdlib/source/library/lux/world/net/http/route.lux +++ b/stdlib/source/library/lux/world/net/http/route.lux @@ -18,7 +18,7 @@ [(def: .public (<name> server) (-> Server Server) (function (_ (^@ request [identification protocol resource message])) - (case (get@ #//.scheme protocol) + (case (value@ #//.scheme protocol) <scheme> (server request) @@ -33,7 +33,7 @@ [(def: .public (<name> server) (-> Server Server) (function (_ (^@ request [identification protocol resource message])) - (case (get@ #//.method resource) + (case (value@ #//.method resource) <method> (server request) @@ -54,12 +54,12 @@ (def: .public (uri path server) (-> URI Server Server) (function (_ [identification protocol resource message]) - (if (text.starts_with? path (get@ #//.uri resource)) + (if (text.starts_with? path (value@ #//.uri resource)) (server [identification protocol - (update@ #//.uri - (|>> (text.clip' (text.size path)) maybe.trusted) - resource) + (revised@ #//.uri + (|>> (text.clip' (text.size path)) maybe.trusted) + resource) message]) (async.resolved //response.not_found)))) diff --git a/stdlib/source/library/lux/world/service/journal.lux b/stdlib/source/library/lux/world/service/journal.lux index 424288cb5..afab93a3e 100644 --- a/stdlib/source/library/lux/world/service/journal.lux +++ b/stdlib/source/library/lux/world/service/journal.lux @@ -33,12 +33,12 @@ (implementation: .public (equivalence (^open "_\.")) (All [a] (-> (Equivalence a) (Equivalence (Entry a)))) (def: (= reference sample) - (and (_\= (get@ #what reference) (get@ #what sample)) - (text\= (get@ #why reference) (get@ #why sample)) - (text\= (get@ #how reference) (get@ #how sample)) - (text\= (get@ #who reference) (get@ #who sample)) - (text\= (get@ #where reference) (get@ #where sample)) - (instant\= (get@ #when reference) (get@ #when sample))))) + (and (_\= (value@ #what reference) (value@ #what sample)) + (text\= (value@ #why reference) (value@ #why sample)) + (text\= (value@ #how reference) (value@ #how sample)) + (text\= (value@ #who reference) (value@ #who sample)) + (text\= (value@ #where reference) (value@ #where sample)) + (instant\= (value@ #when reference) (value@ #when sample))))) (capability: .public (Can_Write ! a) (can_write (Entry a) (! (Try Any)))) diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index 429c46897..d59b72786 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -182,9 +182,9 @@ (-> (List Argument) (Array java/lang/String)) (product.right (list\fold (function (_ argument [idx output]) - [(inc idx) (jvm.array_write idx - (:as java/lang/String argument) - output)]) + [(++ idx) (jvm.write! idx + (:as java/lang/String argument) + output)]) [0 (jvm.array java/lang/String (list.size arguments))] arguments))) @@ -197,9 +197,10 @@ (java/util/Map java/lang/String java/lang/String) (java/util/Map java/lang/String java/lang/String)) (list\fold (function (_ [key value] target') - (exec (java/util/Map::put (:as java/lang/String key) - (:as java/lang/String value) - target') + (exec + (java/util/Map::put (:as java/lang/String key) + (:as java/lang/String value) + target') target')) target (dictionary.entries input))) diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/poly/lux/abstract/equivalence.lux index b311d97ec..bcb2574bc 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -108,7 +108,7 @@ ... Variants (do ! [members (<type>.variant (<>.many equivalence)) - .let [last (dec (list.size members)) + .let [last (-- (list.size members)) g!_ (code.local_identifier "_____________") g!left (code.local_identifier "_____________left") g!right (code.local_identifier "_____________right")]] @@ -117,8 +117,8 @@ (case [(~ g!left) (~ g!right)] (~+ (list\join (list\map (function (_ [tag g!eq]) (if (nat.= last tag) - (list (` [((~ (code.nat (dec tag))) #1 (~ g!left)) - ((~ (code.nat (dec tag))) #1 (~ g!right))]) + (list (` [((~ (code.nat (-- tag))) #1 (~ g!left)) + ((~ (code.nat (-- tag))) #1 (~ g!right))]) (` ((~ g!eq) (~ g!left) (~ g!right)))) (list (` [((~ (code.nat tag)) #0 (~ g!left)) ((~ (code.nat tag)) #0 (~ g!right))]) diff --git a/stdlib/source/poly/lux/abstract/functor.lux b/stdlib/source/poly/lux/abstract/functor.lux index 57f047798..d68d55af8 100644 --- a/stdlib/source/poly/lux/abstract/functor.lux +++ b/stdlib/source/poly/lux/abstract/functor.lux @@ -38,7 +38,7 @@ (function (_ unwrappedT) (if (n.= 1 num_vars) (` ((~! /.Functor) (~ (poly.code *env* unwrappedT)))) - (let [paramsC (|> num_vars dec list.indices (list\map (|>> %.nat code.local_identifier)))] + (let [paramsC (|> num_vars -- list.indices (list\map (|>> %.nat code.local_identifier)))] (` (All [(~+ paramsC)] ((~! /.Functor) ((~ (poly.code *env* unwrappedT)) (~+ paramsC))))))))) Arg<?> (: (-> Code (<type>.Parser Code)) @@ -46,19 +46,19 @@ ($_ p.either ... Type-var (do p.monad - [.let [varI (|> num_vars (n.* 2) dec)] + [.let [varI (|> num_vars (n.* 2) --)] _ (<type>.parameter! varI)] (in (` ((~ funcC) (~ valueC))))) ... Variants (do ! [_ (in []) membersC (<type>.variant (p.many (Arg<?> valueC))) - .let [last (dec (list.size membersC))]] + .let [last (-- (list.size membersC))]] (in (` (case (~ valueC) (~+ (list\join (list\map (function (_ [tag memberC]) (if (n.= last tag) - (list (` ((~ (code.nat (dec tag))) #1 (~ valueC))) - (` ((~ (code.nat (dec tag))) #1 (~ memberC)))) + (list (` ((~ (code.nat (-- tag))) #1 (~ valueC))) + (` ((~ (code.nat (-- tag))) #1 (~ memberC)))) (list (` ((~ (code.nat tag)) #0 (~ valueC))) (` ((~ (code.nat tag)) #0 (~ memberC)))))) (list.enumeration membersC)))))))) @@ -72,7 +72,7 @@ (do ! [_ (in []) memberC (Arg<?> slotC)] - (recur (inc idx) + (recur (++ idx) (list\compose pairsCC (list [slotC memberC]))))) (in pairsCC)))))] (in (` (case (~ valueC) diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index 42f0ed7d8..1496026a7 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -51,7 +51,7 @@ (function (_ input) (non_rec (rec_encode non_rec) input))) -(def: low_mask Nat (|> 1 (i64.left_shifted 32) dec)) +(def: low_mask Nat (|> 1 (i64.left_shifted 32) --)) (def: high_mask Nat (|> low_mask (i64.left_shifted 32))) (implementation: nat_codec @@ -166,14 +166,14 @@ [.let [g!_ (code.local_identifier "_______") g!input (code.local_identifier "_______input")] members (<type>.variant (<>.many encode)) - .let [last (dec (list.size members))]] + .let [last (-- (list.size members))]] (in (` (: (~ (@JSON\encode inputT)) (function ((~ g!_) (~ g!input)) (case (~ g!input) (~+ (list\join (list\map (function (_ [tag g!encode]) (if (n.= last tag) - (.list (` ((~ (code.nat (dec tag))) #1 (~ g!input))) - (` ((~! /.json) [(~ (code.frac (..tag (dec tag)))) + (.list (` ((~ (code.nat (-- tag))) #1 (~ g!input))) + (` ((~! /.json) [(~ (code.frac (..tag (-- tag)))) #1 ((~ g!encode) (~ g!input))]))) (.list (` ((~ (code.nat tag)) #0 (~ g!input))) @@ -278,14 +278,14 @@ ((~! </>.array) ((~! <>.some) (~ subC))))))) (do ! [members (<type>.variant (<>.many decode)) - .let [last (dec (list.size members))]] + .let [last (-- (list.size members))]] (in (` (: (~ (@JSON\decode inputT)) ($_ ((~! <>.or)) (~+ (list\map (function (_ [tag memberC]) (if (n.= last tag) (` (|> (~ memberC) ((~! <>.after) ((~! </>.boolean!) (~ (code.bit #1)))) - ((~! <>.after) ((~! </>.number!) (~ (code.frac (..tag (dec tag)))))) + ((~! <>.after) ((~! </>.number!) (~ (code.frac (..tag (-- tag)))))) ((~! </>.array)))) (` (|> (~ memberC) ((~! <>.after) ((~! </>.boolean!) (~ (code.bit #0)))) diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index 05aee240b..4dd110551 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -66,7 +66,7 @@ (def: repositories (-> /.Profile (List (Repository Async))) - (|>> (get@ #/.repositories) + (|>> (value@ #/.repositories) set.list (list\map (|>> (/repository/remote.repository http.default #.None) /repository.async)))) @@ -165,20 +165,21 @@ (#/cli.Deploy repository identity) (..command - (case [(get@ #/.identity profile) - (dictionary.value repository (get@ #/.deploy_repositories profile))] - [(#.Some artifact) (#.Some repository)] - (/command/deploy.do! console - (/repository.async (/repository/remote.repository http.default (#.Some identity) repository)) - (file.async file.default) - artifact - profile) - - [#.None _] - (async\in (exception.except /.no_identity [])) - - [_ #.None] - (async\in (exception.except ..cannot_find_repository [repository (get@ #/.deploy_repositories profile)])))) + (case (value@ #/.identity profile) + (#.Some artifact) + (case (dictionary.value repository (value@ #/.deploy_repositories profile)) + (#.Some repository) + (/command/deploy.do! console + (/repository.async (/repository/remote.repository http.default (#.Some identity) repository)) + (file.async file.default) + artifact + profile) + + #.None + (async\in (exception.except ..cannot_find_repository [repository (value@ #/.deploy_repositories profile)]))) + + #.None + (async\in (exception.except /.no_identity [])))) #/cli.Dependencies (..command @@ -207,8 +208,5 @@ (..command (case auto #/cli.Build (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/build.do!) profile) - #/cli.Test (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/test.do!) profile))))) - - _ - (undefined))) + #/cli.Test (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/test.do!) profile))))))) )))))) diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux index cd53db5c4..6fd2d495f 100644 --- a/stdlib/source/program/aedifex/artifact.lux +++ b/stdlib/source/program/aedifex/artifact.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Name) + [lux (#- Name local) [abstract [equivalence (#+ Equivalence)] [order (#+ Order)] @@ -49,18 +49,18 @@ ..equivalence) (def: (< reference subject) - (<| (or (text\< (get@ #group reference) - (get@ #group subject))) + (<| (or (text\< (value@ #group reference) + (value@ #group subject))) - (and (text\= (get@ #group reference) - (get@ #group subject))) - (or (text\< (get@ #name reference) - (get@ #name subject))) + (and (text\= (value@ #group reference) + (value@ #group subject))) + (or (text\< (value@ #name reference) + (value@ #name subject))) - (and (text\= (get@ #name reference) - (get@ #name subject))) - (text\< (get@ #version reference) - (get@ #version subject))))) + (and (text\= (value@ #name reference) + (value@ #name subject))) + (text\< (value@ #version reference) + (value@ #version subject))))) (template [<separator> <definition>] [(def: <definition> @@ -74,13 +74,13 @@ (def: .public (identity artifact) (-> Artifact Text) - (%.format (get@ #name artifact) + (%.format (value@ #name artifact) ..version_separator - (get@ #version artifact))) + (value@ #version artifact))) (def: .public (format value) (Format Artifact) - (%.format (get@ #group value) + (%.format (value@ #group value) ..identity_separator (..identity value))) @@ -93,16 +93,16 @@ (def: .public (uri version artifact) (-> Version Artifact URI) (let [/ uri.separator - group (..directory / (get@ #group artifact)) - name (get@ #name artifact) - ... version (get@ #version artifact) + group (..directory / (value@ #group artifact)) + name (value@ #name artifact) + ... version (value@ #version artifact) identity (..identity artifact)] (%.format group / name / version / identity))) (def: .public (local artifact) (-> Artifact (List Text)) (list\compose (|> artifact - (get@ #group) + (value@ #group) (text.all_split_by ..group_separator)) - (list (get@ #name artifact) - (get@ #version artifact)))) + (list (value@ #name artifact) + (value@ #version artifact)))) diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 805ffb1ba..0a1998730 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -33,7 +33,7 @@ (\ ! map (|>> (try.else (list)) (monad.map ! (targets fs)))) (\ ! join) - (\ ! map (|>> list.joined (list& path)))))) + (\ ! map (|>> list.together (list& path)))))) (def: .public delay Nat @@ -41,7 +41,7 @@ (def: (pause delay) (-> Nat (Async (Try Any))) - (async.delayed delay (#try.Success []))) + (async.after delay (#try.Success []))) (def: .public (do! delay watcher command) (All [a] @@ -53,10 +53,10 @@ (with_expansions [<call> ((command console program fs shell resolution) profile)] (do {! async.monad} [targets (|> profile - (get@ #///.sources) + (value@ #///.sources) set.list (monad.map ! (..targets fs)) - (\ ! map list.joined))] + (\ ! map list.together))] (do {! ///action.monad} [_ (monad.map ! (\ watcher start watch.modification) targets) _ <call>] diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index ff469d896..e4de9ab0a 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -49,8 +49,8 @@ (-> Group Name Finder) (|>> dictionary.entries (list.one (function (_ [dependency package]) - (if (and (text\= group (get@ [#///dependency.artifact #///artifact.group] dependency)) - (text\= name (get@ [#///dependency.artifact #///artifact.name] dependency))) + (if (and (text\= group (value@ [#///dependency.artifact #///artifact.group] dependency)) + (text\= name (value@ [#///dependency.artifact #///artifact.name] dependency))) (#.Some dependency) #.None))))) @@ -111,17 +111,17 @@ (def: (path fs home dependency) (All [!] (-> (file.System !) Path Dependency Path)) (let [/ (\ fs separator) - artifact (get@ #///dependency.artifact dependency)] + artifact (value@ #///dependency.artifact dependency)] (|> artifact - (///local.uri (get@ #///artifact.version artifact)) + (///local.uri (value@ #///artifact.version artifact)) (text.replaced uri.separator /) (format home /) - (text.suffix (format "." (get@ #///dependency.type dependency)))))) + (text.suffix (format "." (value@ #///dependency.type dependency)))))) (def: (libraries fs home) (All [!] (-> (file.System !) Path Resolution (List Path))) (|>> dictionary.keys - (list.only (|>> (get@ #///dependency.type) + (list.only (|>> (value@ #///dependency.type) (text\= ///artifact/type.lux_library))) (list\map (..path fs home)))) @@ -156,14 +156,14 @@ (def: .public (host_dependencies fs home) (All [!] (-> (file.System !) Path Resolution (List Path))) (|>> dictionary.keys - (list.only (|>> (get@ #///dependency.type) + (list.only (|>> (value@ #///dependency.type) (text\= ///artifact/type.lux_library) not)) (list\fold (function (_ dependency uniques) - (let [artifact (get@ #///dependency.artifact dependency) - identity [(get@ #///artifact.group artifact) - (get@ #///artifact.name artifact)] - version (get@ #///artifact.version artifact)] + (let [artifact (value@ #///dependency.artifact dependency) + identity [(value@ #///artifact.group artifact) + (value@ #///artifact.name artifact)] + version (value@ #///artifact.version artifact)] (case (dictionary.value identity uniques) (#.Some [current_version current_path]) (if (\ version_order < version current_version) @@ -183,7 +183,7 @@ (def: (plural name) (-> Text (List Text) (List Text)) - (|>> (list\map (|>> (list name))) list.joined)) + (|>> (list\map (|>> (list name))) list.together)) (def: .public start "[BUILD STARTED]") (def: .public success "[BUILD ENDED]") @@ -245,8 +245,7 @@ (-> (List Path) Text) (|> host_dependencies (#.Item ".") - (text.interposed ..jvm_class_path_separator) - %.text)) + (text.interposed ..jvm_class_path_separator))) (def: .public (with_jvm_class_path host_dependencies runtime) (-> (List Path) ///runtime.Runtime ///runtime.Runtime) @@ -255,15 +254,15 @@ runtime _ - (update@ #///runtime.parameters - (|>> (list& "-classpath" (..jvm_class_path host_dependencies))) - runtime))) + (revised@ #///runtime.parameters + (|>> (list& "-cp" (..jvm_class_path host_dependencies))) + runtime))) (def: .public (do! console program fs shell resolution) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Compiler Path])) (function (_ profile) - (let [target (get@ #///.target profile)] - (case (get@ #///.program profile) + (let [target (value@ #///.target profile)] + (case (value@ #///.program profile) #.None (async\in (exception.except ..no_specified_program [])) @@ -273,19 +272,20 @@ .let [home (\ program home) working_directory (\ program directory)]] (do ///action.monad - [[resolution compiler] (async\in (..compiler resolution (get@ #///.compiler profile))) + [[resolution compiler] (async\in (..compiler resolution (value@ #///.compiler profile))) .let [host_dependencies (..host_dependencies fs home resolution) [[command compiler_params] output] (case compiler (#JVM dependency) - [(|> (..path fs home dependency) - (///runtime.for (get@ #///.java profile)) - (with_jvm_class_path host_dependencies)) + [(|> (value@ #///.java profile) + (with@ #///runtime.parameters (list "program._")) + (with_jvm_class_path (#.Item (..path fs home dependency) host_dependencies))) "program.jar"] (^template [<tag> <runtime> <program>] [(<tag> dependency) - [(///runtime.for (get@ <runtime> profile) - (..path fs home dependency)) + [(|> dependency + (..path fs home) + (///runtime.for (value@ <runtime> profile))) <program>]]) ([#JS #///.js "program.js"] [#Python #///.java "program.py"] @@ -294,13 +294,13 @@ / (\ fs separator) cache_directory (format working_directory / target)] _ (console.write_line ..start console) - .let [full_parameters (list.joined (list compiler_params - (list "build") - (..plural "--library" (..libraries fs home resolution)) - (..plural "--host_dependency" host_dependencies) - (..plural "--source" (set.list (get@ #///.sources profile))) - (..singular "--target" cache_directory) - (..singular "--module" program_module)))] + .let [full_parameters (list.together (list compiler_params + (list "build") + (..plural "--library" (..libraries fs home resolution)) + (..plural "--host_dependency" host_dependencies) + (..plural "--source" (set.list (value@ #///.sources profile))) + (..singular "--target" cache_directory) + (..singular "--module" program_module)))] process (\ shell execute [environment working_directory command diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux index 67d539db7..9e55ccc83 100644 --- a/stdlib/source/program/aedifex/command/clean.lux +++ b/stdlib/source/program/aedifex/command/clean.lux @@ -33,7 +33,7 @@ (def: .public (do! console fs profile) (-> (Console Async) (file.System Async) (Command Any)) (do {! async.monad} - [.let [target (get@ #///.target profile)] + [.let [target (value@ #///.target profile)] ? (\ fs directory? target) _ (let [! ///action.monad] (if ? diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux index cbddc9b27..38f975939 100644 --- a/stdlib/source/program/aedifex/command/deploy.lux +++ b/stdlib/source/program/aedifex/command/deploy.lux @@ -60,7 +60,7 @@ (-> (Console Async) (Repository Async) (file.System Async) Artifact (Command Any)) (do {! ///action.monad} [library (|> profile - (get@ #/.sources) + (value@ #/.sources) set.list (export.library fs) (\ ! map (binary.result tar.writer))) diff --git a/stdlib/source/program/aedifex/command/deps.lux b/stdlib/source/program/aedifex/command/deps.lux index 3cbb82403..3c8381e51 100644 --- a/stdlib/source/program/aedifex/command/deps.lux +++ b/stdlib/source/program/aedifex/command/deps.lux @@ -33,16 +33,16 @@ (def: format (%.Format Dependency) - (|>> (get@ #///dependency.artifact) + (|>> (value@ #///dependency.artifact) ///artifact.format %.text)) (def: .public (do! console local remotes new_repository profile) (-> (Console Async) (Repository Async) (List (Repository Async)) (-> URL (Repository Async)) (Command Resolution)) (do async.monad - [.let [dependencies (|> (get@ #///.dependencies profile) + [.let [dependencies (|> (value@ #///.dependencies profile) set.list - (#.Item (get@ #///.compiler profile)))] + (#.Item (value@ #///.compiler profile)))] [local_successes local_failures cache] (///dependency/resolution.all console (list local) new_repository diff --git a/stdlib/source/program/aedifex/command/install.lux b/stdlib/source/program/aedifex/command/install.lux index 9b06daaec..f0677afc7 100644 --- a/stdlib/source/program/aedifex/command/install.lux +++ b/stdlib/source/program/aedifex/command/install.lux @@ -51,11 +51,11 @@ (def: .public (do! console fs repository profile) (-> (Console Async) (file.System Async) (Repository Async) (Command Any)) - (case (get@ #/.identity profile) + (case (value@ #/.identity profile) (#.Some identity) (do ///action.monad [package (|> profile - (get@ #/.sources) + (value@ #/.sources) set.list (export.library fs)) pom (|> profile diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux index a7279c5ec..ae627bcb7 100644 --- a/stdlib/source/program/aedifex/command/test.lux +++ b/stdlib/source/program/aedifex/command/test.lux @@ -36,7 +36,7 @@ (do {! ///action.monad} [.let [home (\ program home)] [build_exit compiler program] (//build.do! console program fs shell resolution - (set@ #///.program (get@ #///.test profile) profile))] + (with@ #///.program (value@ #///.test profile) profile))] (if (i.= shell.normal build_exit) (do ! [_ (console.write_line ..start console) @@ -44,15 +44,14 @@ [test_command test_parameters] (case compiler (#//build.JVM dependency) (|> program - (///runtime.for (get@ #///.java profile)) + (///runtime.for (value@ #///.java profile)) (//build.with_jvm_class_path host_dependencies)) (^template [<tag> <runtime>] [(<tag> artifact) - (///runtime.for (get@ <runtime> profile) + (///runtime.for (value@ <runtime> profile) program)]) - ([#//build.JVM #///.java] - [#//build.JS #///.js] + ([#//build.JS #///.js] [#//build.Python #///.python] [#//build.Lua #///.lua] [#//build.Ruby #///.ruby]))] diff --git a/stdlib/source/program/aedifex/dependency.lux b/stdlib/source/program/aedifex/dependency.lux index f31f0ca44..b1a23c0de 100644 --- a/stdlib/source/program/aedifex/dependency.lux +++ b/stdlib/source/program/aedifex/dependency.lux @@ -35,10 +35,10 @@ ..equivalence) (def: (< reference subject) - (<| (or (//\< (get@ #artifact reference) - (get@ #artifact subject))) + (<| (or (//\< (value@ #artifact reference) + (value@ #artifact subject))) - (and (//\= (get@ #artifact reference) - (get@ #artifact subject))) - (text\< (get@ #type reference) - (get@ #type subject))))) + (and (//\= (value@ #artifact reference) + (value@ #artifact subject))) + (text\< (value@ #type reference) + (value@ #type subject))))) diff --git a/stdlib/source/program/aedifex/dependency/deployment.lux b/stdlib/source/program/aedifex/dependency/deployment.lux index d23e4a805..0e9ab0def 100644 --- a/stdlib/source/program/aedifex/dependency/deployment.lux +++ b/stdlib/source/program/aedifex/dependency/deployment.lux @@ -91,39 +91,39 @@ (do try.monad [now (: (Try ///artifact/time.Time) (///artifact/time.of_instant now)) - .let [version_template (get@ #///artifact.version artifact) + .let [version_template (value@ #///artifact.version artifact) snapshot (|> snapshot - (update@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] - (function (_ snapshot) - (case snapshot - #///artifact/snapshot.Local - #///artifact/snapshot.Local - - (#///artifact/snapshot.Remote [_ build]) - (#///artifact/snapshot.Remote [now (inc build)])))) - (set@ [#///metadata/snapshot.versioning #///artifact/versioning.last_updated] now)) - versioning_snapshot (get@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] snapshot)]] + (revised@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] + (function (_ snapshot) + (case snapshot + #///artifact/snapshot.Local + #///artifact/snapshot.Local + + (#///artifact/snapshot.Remote [_ build]) + (#///artifact/snapshot.Remote [now (++ build)])))) + (with@ [#///metadata/snapshot.versioning #///artifact/versioning.last_updated] now)) + versioning_snapshot (value@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] snapshot)]] (in (|> snapshot - (set@ [#///metadata/snapshot.versioning #///artifact/versioning.versions] - (list {#///artifact/snapshot/version.extension type - #///artifact/snapshot/version.value (///artifact/snapshot/version/value.format - {#///artifact/snapshot/version/value.version version_template - #///artifact/snapshot/version/value.snapshot versioning_snapshot}) - #///artifact/snapshot/version.updated now})) - ... (set@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] - ... (list\compose (..artifacts type (product.right (get@ #///package.library package))) - ... (..artifacts ///artifact/type.pom (product.right (get@ #///package.pom package))))) + (with@ [#///metadata/snapshot.versioning #///artifact/versioning.versions] + (list {#///artifact/snapshot/version.extension type + #///artifact/snapshot/version.value (///artifact/snapshot/version/value.format + {#///artifact/snapshot/version/value.version version_template + #///artifact/snapshot/version/value.snapshot versioning_snapshot}) + #///artifact/snapshot/version.updated now})) + ... (with@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] + ... (list\compose (..artifacts type (product.right (value@ #///package.library package))) + ... (..artifacts ///artifact/type.pom (product.right (value@ #///package.pom package))))) )))) (def: .public (one repository [artifact type] package) (-> (Repository Async) Dependency Package (Async (Try Artifact))) (do {! async.monad} [now (async.future instant.now) - .let [version_template (get@ #///artifact.version artifact)]] + .let [version_template (value@ #///artifact.version artifact)]] (do (try.with !) - [_ (with_status repository version_template [artifact type] (get@ #///package.library package)) + [_ (with_status repository version_template [artifact type] (value@ #///package.library package)) - _ (let [[pom pom_data status] (get@ #///package.pom package)] + _ (let [[pom pom_data status] (value@ #///package.pom package)] (with_status repository version_template [artifact ///artifact/type.pom] @@ -135,8 +135,8 @@ _ (///metadata/snapshot.write repository artifact snapshot) project (///metadata/artifact.read repository artifact) _ (|> project - (set@ #///metadata/artifact.versions (list version_template)) - (set@ #///metadata/artifact.last_updated now) + (with@ #///metadata/artifact.versions (list version_template)) + (with@ #///metadata/artifact.last_updated now) (///metadata/artifact.write repository artifact))] (in artifact)))) diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index 22778e25b..73c5f6608 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -1,6 +1,7 @@ (.module: [library [lux (#- Name) + ["@" target] ["." debug] ["." ffi (#+ import:)] [abstract @@ -83,9 +84,10 @@ (case ?actual (#try.Success actual) (in (do {! try.monad} - [output (\ ! map (|>> (:as java/lang/String) - java/lang/String::trim - (:as Text)) + [output (\ ! map (for {@.old (|>> (:as java/lang/String) + java/lang/String::trim + (:as Text)) + @.jvm (|>> java/lang/String::trim)}) (\ utf8.codec decode actual)) actual (|> output (text.all_split_by " ") @@ -113,10 +115,10 @@ [(#.Some sha-1) (#.Some md5)] (#//status.Verified sha-1 md5) - [(#.Some sha-1) _] + [(#.Some sha-1) #.None] (#//status.Partial (#.Left sha-1)) - [_ (#.Some md5)] + [#.None (#.Some md5)] (#//status.Partial (#.Right md5)) [#.None #.None] @@ -128,10 +130,10 @@ extension (///artifact/extension.extension type)] (do (try.with async.monad) [snapshot (///metadata/snapshot.read repository artifact) - .let [version_template (get@ [#///metadata/snapshot.artifact #///artifact.version] snapshot) + .let [version_template (value@ [#///metadata/snapshot.artifact #///artifact.version] snapshot) artifact_version (value.format {#value.version version_template - #value.snapshot (get@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] snapshot)}) - artifact (set@ #///artifact.version artifact_version artifact)] + #value.snapshot (value@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] snapshot)}) + artifact (with@ #///artifact.version artifact_version artifact)] [pom_data pom_status] (..hashed repository version_template artifact ///artifact/extension.pom) library_&_status (..hashed repository version_template artifact extension)] (\ async.monad in @@ -156,8 +158,8 @@ (exception: .public (cannot_resolve {dependency Dependency}) (exception.report - ["Artifact" (%.text (///artifact.format (get@ #//.artifact dependency)))] - ["Type" (%.text (get@ #//.type dependency))])) + ["Artifact" (%.text (///artifact.format (value@ #//.artifact dependency)))] + ["Type" (%.text (value@ #//.type dependency))])) (template [<sigil> <name> <doing> <at>] [(def: (<name> console repository artifact) @@ -184,17 +186,17 @@ (#.Item repository alternatives) (do {! async.monad} - [_ (..announce_fetching console repository (get@ #//.artifact dependency)) + [_ (..announce_fetching console repository (value@ #//.artifact dependency)) outcome (..one repository dependency)] (case outcome (#try.Success package) (do ! - [_ (..announce_success console repository (get@ #//.artifact dependency))] + [_ (..announce_success console repository (value@ #//.artifact dependency))] (in outcome)) (#try.Failure error) (do ! - [_ (..announce_failure console repository (get@ #//.artifact dependency))] + [_ (..announce_failure console repository (value@ #//.artifact dependency))] (any console alternatives dependency)))))) (def: .public (all console repositories new_repository dependencies resolution) @@ -213,7 +215,7 @@ [successes failures resolution]) (#.Item head tail) - (case (get@ [#//.artifact #///artifact.version] head) + (case (value@ [#//.artifact #///artifact.version] head) ... Skip if there is no version "" (recur repositories successes diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux index 82b15f84d..74583c8f5 100644 --- a/stdlib/source/program/aedifex/format.lux +++ b/stdlib/source/program/aedifex/format.lux @@ -108,13 +108,13 @@ (def: (info value) (Format /.Info) (|> ..empty - (..on_maybe "url" (get@ #/.url value) code.text) - (..on_maybe "scm" (get@ #/.scm value) code.text) - (..on_maybe "description" (get@ #/.description value) code.text) - (..on_list "licenses" (get@ #/.licenses value) ..license) - (..on_maybe "organization" (get@ #/.organization value) ..organization) - (..on_list "developers" (get@ #/.developers value) ..developer) - (..on_list "contributors" (get@ #/.contributors value) ..contributor) + (..on_maybe "url" (value@ #/.url value) code.text) + (..on_maybe "scm" (value@ #/.scm value) code.text) + (..on_maybe "description" (value@ #/.description value) code.text) + (..on_list "licenses" (value@ #/.licenses value) ..license) + (..on_maybe "organization" (value@ #/.organization value) ..organization) + (..on_list "developers" (value@ #/.developers value) ..developer) + (..on_list "contributors" (value@ #/.contributors value) ..contributor) ..aggregate)) (def: (artifact' [group name version]) @@ -142,19 +142,19 @@ (def: .public (profile value) (Format /.Profile) (`` (|> ..empty - (..on_list "parents" (get@ #/.parents value) code.text) - (..on_maybe "identity" (get@ #/.identity value) ..artifact) - (..on_maybe "info" (get@ #/.info value) ..info) - (..on_set "repositories" (get@ #/.repositories value) code.text) - (..on_set "dependencies" (get@ #/.dependencies value) ..dependency) - (dictionary.has "compiler" (..dependency (get@ #/.compiler value))) - (..on_set "sources" (get@ #/.sources value) code.text) - (dictionary.has "target" (code.text (get@ #/.target value))) - (..on_maybe "program" (get@ #/.program value) code.text) - (..on_maybe "test" (get@ #/.test value) code.text) - (..on_dictionary "deploy_repositories" (get@ #/.deploy_repositories value) code.text code.text) + (..on_list "parents" (value@ #/.parents value) code.text) + (..on_maybe "identity" (value@ #/.identity value) ..artifact) + (..on_maybe "info" (value@ #/.info value) ..info) + (..on_set "repositories" (value@ #/.repositories value) code.text) + (..on_set "dependencies" (value@ #/.dependencies value) ..dependency) + (dictionary.has "compiler" (..dependency (value@ #/.compiler value))) + (..on_set "sources" (value@ #/.sources value) code.text) + (dictionary.has "target" (code.text (value@ #/.target value))) + (..on_maybe "program" (value@ #/.program value) code.text) + (..on_maybe "test" (value@ #/.test value) code.text) + (..on_dictionary "deploy_repositories" (value@ #/.deploy_repositories value) code.text code.text) (~~ (template [<tag>] - [(dictionary.has (template.text [<tag>]) (..runtime (get@ <tag> value)))] + [(dictionary.has (template.text [<tag>]) (..runtime (value@ <tag> value)))] [#/.java] [#/.js] diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 63394c8c9..92414c441 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -31,10 +31,12 @@ (#static getInstance [java/lang/String] java/security/MessageDigest) (digest [[byte]] [byte])]) -(abstract: .public SHA-1 Any) -(abstract: .public MD5 Any) +(abstract: .public SHA-1 {} Any) +(abstract: .public MD5 {} Any) (abstract: .public (Hash h) + {} + Binary (def: .public data @@ -54,13 +56,13 @@ (def: encode (Format Binary) - (binary.fold (function (_ byte representation) - (let [hex (\ n.hex encode byte) - hex (case (text.size hex) - 1 (format "0" hex) - _ hex)] - (format representation hex))) - "")) + (binary.aggregate (function (_ byte representation) + (let [hex (\ n.hex encode byte) + hex (case (text.size hex) + 1 (format "0" hex) + _ hex)] + (format representation hex))) + "")) (template [<factor> <name>] [(def: <name> @@ -128,7 +130,7 @@ (do try.monad [head (\ n.hex decode head) output (binary.write/64! index head output)] - (recur tail (inc chunk) output)) + (recur tail (++ chunk) output)) #.None (case (..hash_size input) diff --git a/stdlib/source/program/aedifex/metadata.lux b/stdlib/source/program/aedifex/metadata.lux index 5badc4783..c8bad9fed 100644 --- a/stdlib/source/program/aedifex/metadata.lux +++ b/stdlib/source/program/aedifex/metadata.lux @@ -18,16 +18,16 @@ (def: .public (remote_artifact_uri artifact) (-> Artifact URI) (let [/ uri.separator] - (format (//artifact.directory / (get@ #//artifact.group artifact)) - / (get@ #//artifact.name artifact) - / (get@ #//artifact.version artifact) + (format (//artifact.directory / (value@ #//artifact.group artifact)) + / (value@ #//artifact.name artifact) + / (value@ #//artifact.version artifact) / ..remote_file))) (def: .public (remote_project_uri artifact) (-> Artifact URI) (let [/ uri.separator] - (format (//artifact.directory / (get@ #//artifact.group artifact)) - / (get@ #//artifact.name artifact) + (format (//artifact.directory / (value@ #//artifact.group artifact)) + / (value@ #//artifact.name artifact) / ..remote_file))) (def: local_file diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux index 0d6f86c2c..3512114be 100644 --- a/stdlib/source/program/aedifex/metadata/artifact.lux +++ b/stdlib/source/program/aedifex/metadata/artifact.lux @@ -99,12 +99,12 @@ (-> Metadata XML) (#xml.Node ..<metadata> xml.attributes - (list (..group_format (get@ #group value)) - (..name_format (get@ #name value)) + (list (..group_format (value@ #group value)) + (..name_format (value@ #name value)) (#xml.Node ..<versioning> xml.attributes - (list (..versions_format (get@ #versions value)) - (..last_updated_format (get@ #last_updated value))))))) + (list (..versions_format (value@ #versions value)) + (..last_updated_format (value@ #last_updated value))))))) (def: (text tag) (-> xml.Tag (Parser Text)) diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux index 90fa9bb86..6a32effef 100644 --- a/stdlib/source/program/aedifex/metadata/snapshot.lux +++ b/stdlib/source/program/aedifex/metadata/snapshot.lux @@ -95,14 +95,14 @@ #///artifact/snapshot/version.updated ///artifact/time.epoch}] (|> (<xml>.somewhere ///artifact/versioning.parser) (\ ! map - (update@ #///artifact/versioning.versions - (: (-> (List ///artifact/snapshot/version.Version) - (List ///artifact/snapshot/version.Version)) - (|>> (case> (^ (list)) - (list <default_version>) + (revised@ #///artifact/versioning.versions + (: (-> (List ///artifact/snapshot/version.Version) + (List ///artifact/snapshot/version.Version)) + (|>> (case> (^ (list)) + (list <default_version>) - versions - versions))))) + versions + versions))))) (<>.else {#///artifact/versioning.snapshot #///artifact/snapshot.Local #///artifact/versioning.last_updated ///artifact/time.epoch #///artifact/versioning.versions (list <default_version>)})))] diff --git a/stdlib/source/program/aedifex/package.lux b/stdlib/source/program/aedifex/package.lux index 6b65a936d..c0c73e0fd 100644 --- a/stdlib/source/program/aedifex/package.lux +++ b/stdlib/source/program/aedifex/package.lux @@ -1,6 +1,6 @@ (.module: [library - [lux #* + [lux (#- local) [abstract [equivalence (#+ Equivalence)]] [control @@ -36,7 +36,7 @@ (template [<name> <tag>] [(def: .public (<name> package) (-> Package Bit) - (case (get@ #origin package) + (case (value@ #origin package) (<tag> _) true @@ -61,19 +61,19 @@ (def: .public dependencies (-> Package (Try (Set Dependency))) - (|>> (get@ #pom) + (|>> (value@ #pom) product.left list (<xml>.result //pom.parser) - (try\map (get@ #/.dependencies)))) + (try\map (value@ #/.dependencies)))) (def: .public repositories (-> Package (Try (Set Address))) - (|>> (get@ #pom) + (|>> (value@ #pom) product.left list (<xml>.result //pom.parser) - (try\map (get@ #/.repositories)))) + (try\map (value@ #/.repositories)))) (def: .public equivalence (Equivalence Package) diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux index 6d4d05b92..d5f4d3bb8 100644 --- a/stdlib/source/program/aedifex/parser.lux +++ b/stdlib/source/program/aedifex/parser.lux @@ -262,7 +262,7 @@ (Parser Project) (let [default_profile (: (Parser Project) (\ <>.monad map - (|>> [/.else] (list) (dictionary.of_list text.hash)) + (|>> [/.default] (list) (dictionary.of_list text.hash)) ..profile)) multi_profile (: (Parser Project) (\ <>.monad map diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index 36e3ff440..810c30588 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -58,9 +58,9 @@ (def: (artifact value) (-> Artifact (List XML)) - (list (..property ..group_tag (get@ #//artifact.group value)) - (..property ..artifact_tag (get@ #//artifact.name value)) - (..property ..version_tag (get@ #//artifact.version value)))) + (list (..property ..group_tag (value@ #//artifact.group value)) + (..property ..artifact_tag (value@ #//artifact.name value)) + (..property ..version_tag (value@ #//artifact.version value)))) (def: distribution (-> /.Distribution XML) @@ -85,8 +85,8 @@ (-> Dependency XML) (#_.Node ["" ..dependency_tag] _.attributes - (list\compose (..artifact (get@ #//dependency.artifact value)) - (list (..property "type" (get@ #//dependency.type value)))))) + (list\compose (..artifact (value@ #//dependency.artifact value)) + (list (..property "type" (value@ #//dependency.type value)))))) (def: (group tag) (-> Text (-> (List XML) XML)) @@ -128,27 +128,27 @@ (def: (info value) (-> /.Info (List XML)) ($_ list\compose - (|> value (get@ #/.url) (maybe\map (..property ..url_tag)) maybe.list) - (|> value (get@ #/.description) (maybe\map (..property "description")) maybe.list) - (|> value (get@ #/.licenses) (list\map ..license) (..group "licenses") list) - (|> value (get@ #/.scm) (maybe\map ..scm) maybe.list) - (|> value (get@ #/.organization) (maybe\map ..organization) maybe.list) - (|> value (get@ #/.developers) (list\map ..developer) (..group "developers") list) - (|> value (get@ #/.contributors) (list\map ..contributor) (..group "contributors") list) + (|> value (value@ #/.url) (maybe\map (..property ..url_tag)) maybe.list) + (|> value (value@ #/.description) (maybe\map (..property "description")) maybe.list) + (|> value (value@ #/.licenses) (list\map ..license) (..group "licenses") list) + (|> value (value@ #/.scm) (maybe\map ..scm) maybe.list) + (|> value (value@ #/.organization) (maybe\map ..organization) maybe.list) + (|> value (value@ #/.developers) (list\map ..developer) (..group "developers") list) + (|> value (value@ #/.contributors) (list\map ..contributor) (..group "contributors") list) )) ) (def: .public (write value) (-> /.Profile (Try XML)) - (case (get@ #/.identity value) + (case (value@ #/.identity value) (#.Some identity) (#try.Success (#_.Node ["" ..project_tag] _.attributes ($_ list\compose (list ..version) (..artifact identity) - (|> value (get@ #/.repositories) set.list (list\map ..repository) (..group "repositories") list) - (|> value (get@ #/.dependencies) set.list (list\map ..dependency) (..group ..dependencies_tag) list) + (|> value (value@ #/.repositories) set.list (list\map ..repository) (..group "repositories") list) + (|> value (value@ #/.dependencies) set.list (list\map ..dependency) (..group ..dependencies_tag) list) ))) _ @@ -225,7 +225,7 @@ (<>.else (list))) _ (<>.some <xml>.any)] (in (|> (\ /.monoid identity) - (update@ #/.dependencies (function (_ empty) - (list\fold set.has empty dependencies))) - (update@ #/.repositories (function (_ empty) - (list\fold set.has empty repositories))))))))) + (revised@ #/.dependencies (function (_ empty) + (list\fold set.has empty dependencies))) + (revised@ #/.repositories (function (_ empty) + (list\fold set.has empty repositories))))))))) diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index 2ff458967..f4a1f9a0d 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -230,24 +230,24 @@ (def: (compose override baseline) (template.let [(!runtime <tag> <runtime>) - [(if (runtime\= <runtime> (get@ <tag> override)) - (get@ <tag> baseline) - (get@ <tag> override))]] - {#parents (list\compose (get@ #parents baseline) (get@ #parents override)) - #identity (maybe\compose (get@ #identity override) (get@ #identity baseline)) - #info (maybe\compose (get@ #info override) (get@ #info baseline)) - #repositories (set.union (get@ #repositories baseline) (get@ #repositories override)) - #dependencies (set.union (get@ #dependencies baseline) (get@ #dependencies override)) - #compiler (if (dependency\= ..default_compiler (get@ #compiler override)) - (get@ #compiler baseline) - (get@ #compiler override)) - #sources (set.union (get@ #sources baseline) (get@ #sources override)) - #target (if (text\= ..default_target (get@ #target baseline)) - (get@ #target override) - (get@ #target baseline)) - #program (maybe\compose (get@ #program override) (get@ #program baseline)) - #test (maybe\compose (get@ #test override) (get@ #test baseline)) - #deploy_repositories (dictionary.merged (get@ #deploy_repositories override) (get@ #deploy_repositories baseline)) + [(if (runtime\= <runtime> (value@ <tag> override)) + (value@ <tag> baseline) + (value@ <tag> override))]] + {#parents (list\compose (value@ #parents baseline) (value@ #parents override)) + #identity (maybe\compose (value@ #identity override) (value@ #identity baseline)) + #info (maybe\compose (value@ #info override) (value@ #info baseline)) + #repositories (set.union (value@ #repositories baseline) (value@ #repositories override)) + #dependencies (set.union (value@ #dependencies baseline) (value@ #dependencies override)) + #compiler (if (dependency\= ..default_compiler (value@ #compiler override)) + (value@ #compiler baseline) + (value@ #compiler override)) + #sources (set.union (value@ #sources baseline) (value@ #sources override)) + #target (if (text\= ..default_target (value@ #target baseline)) + (value@ #target override) + (value@ #target baseline)) + #program (maybe\compose (value@ #program override) (value@ #program baseline)) + #test (maybe\compose (value@ #test override) (value@ #test baseline)) + #deploy_repositories (dictionary.merged (value@ #deploy_repositories override) (value@ #deploy_repositories baseline)) #java (!runtime #java runtime.default_java) #js (!runtime #js runtime.default_js) #python (!runtime #python runtime.default_python) diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux index 951e82d34..5717221d1 100644 --- a/stdlib/source/program/aedifex/project.lux +++ b/stdlib/source/program/aedifex/project.lux @@ -55,17 +55,17 @@ (case (dictionary.value name project) (#.Some profile) (case (list.example (set.member? lineage) - (get@ #//.parents profile)) + (value@ #//.parents profile)) (#.Some ouroboros) (exception.except ..circular_dependency [ouroboros name]) #.None (do {! try.monad} [parents (monad.map ! (profile' (set.has name lineage) project) - (get@ #//.parents profile))] + (value@ #//.parents profile))] (in (list\fold (function (_ parent child) (\ //.monoid compose child parent)) - (set@ #//.parents (list) profile) + (with@ #//.parents (list) profile) parents)))) #.None diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index feaf3201f..11d29716e 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -68,11 +68,11 @@ http))] (case status (^ (static http/status.ok)) - (\ ! map product.right ((get@ #@http.body message) #.None)) + (\ ! map product.right ((value@ #@http.body message) #.None)) _ (do ! - [_ ((get@ #@http.body message) (#.Some 0))] + [_ ((value@ #@http.body message) (#.Some 0))] (\ io.monad in (exception.except ..download_failure [(format address uri) status])))))) (def: (upload uri content) @@ -88,7 +88,7 @@ ..base_headers))) (#.Some content) http)) - _ ((get@ #@http.body message) (#.Some 0))] + _ ((value@ #@http.body message) (#.Some 0))] (case status (^ (static http/status.created)) (in []) diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux index b239d03ea..f029bed15 100644 --- a/stdlib/source/program/aedifex/runtime.lux +++ b/stdlib/source/program/aedifex/runtime.lux @@ -40,7 +40,7 @@ (def: .public (for runtime path) (-> Runtime file.Path Runtime) - (update@ #parameters - (function (_ parameters) - (list\compose parameters (list path))) - runtime)) + (revised@ #parameters + (function (_ parameters) + (list\compose parameters (list path))) + runtime)) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index 1a6e7356e..7f0e29903 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -136,7 +136,7 @@ ..timed (do (try.with async.monad) [.let [[compilation_sources compilation_host_dependencies compilation_libraries compilation_target compilation_module] compilation] - import (/import.import (get@ #platform.&file_system platform) compilation_libraries) + import (/import.import (value@ #platform.&file_system platform) compilation_libraries) [state archive] (:sharing [<parameters>] (Platform <parameters>) platform @@ -151,9 +151,9 @@ (Async (Try [Archive (directive.State+ <parameters>)])) (:expected (platform.compile import static expander platform compilation [archive state]))) - _ (ioW.freeze (get@ #platform.&file_system platform) static archive) + _ (ioW.freeze (value@ #platform.&file_system platform) static archive) program_context (async\in ($/program.context archive)) - host_dependencies (..load_host_dependencies (get@ #platform.&file_system platform) compilation_host_dependencies) + host_dependencies (..load_host_dependencies (value@ #platform.&file_system platform) compilation_host_dependencies) _ (..package! (for {@.old (file.async file.default) @.jvm (file.async file.default) @.js file.default}) @@ -167,7 +167,7 @@ (#/cli.Export export) (<| (or_crash! "Export failed:") (do (try.with async.monad) - [_ (/export.export (get@ #platform.&file_system platform) + [_ (/export.export (value@ #platform.&file_system platform) export)] (in (debug.log! "Export complete!")))) diff --git a/stdlib/source/program/scriptum.lux b/stdlib/source/program/scriptum.lux index dbe3ea022..5083e0afc 100644 --- a/stdlib/source/program/scriptum.lux +++ b/stdlib/source/program/scriptum.lux @@ -51,7 +51,7 @@ (def: type_var_names (Sequence Text) - (|> 0 (sequence.iterations inc) (sequence\map parameter_type_name))) + (|> 0 (sequence.iterations ++) (sequence\map parameter_type_name))) (template [<name> <partition>] [(def: (<name> id) @@ -86,9 +86,9 @@ (if (n.= 0 level) (list) (|> level - dec + -- (enum.range n.enum 0) - (list\map (|>> (n.+ (inc offset)) parameter_type_name))))) + (list\map (|>> (n.+ (++ offset)) parameter_type_name))))) (def: (prefix_lines prefix lines) (-> Text Text Text) @@ -283,28 +283,28 @@ (def: (add_definition [name [exported? def_type def_annotations def_value]] organization) (-> [Text Definition] Organization Organization) (cond (type\= .Type def_type) - (update@ #types - (: (Mutation (List Value)) - (|>> (#.Item [name def_annotations (:as Type def_value)]))) - organization) + (revised@ #types + (: (Mutation (List Value)) + (|>> (#.Item [name def_annotations (:as Type def_value)]))) + organization) (type\= .Macro def_type) - (update@ #macros - (: (Mutation (List [Text Code])) - (|>> (#.Item [name def_annotations]))) - organization) + (revised@ #macros + (: (Mutation (List [Text Code])) + (|>> (#.Item [name def_annotations]))) + organization) (annotation.implementation? def_annotations) - (update@ #implementations - (: (Mutation (List Value)) - (|>> (#.Item [name def_annotations def_type]))) - organization) + (revised@ #implementations + (: (Mutation (List Value)) + (|>> (#.Item [name def_annotations def_type]))) + organization) ... else - (update@ #values - (: (Mutation (List Value)) - (|>> (#.Item [name def_annotations def_type]))) - organization))) + (revised@ #values + (: (Mutation (List Value)) + (|>> (#.Item [name def_annotations def_type]))) + organization))) (def: name_sort (All [r] (-> [Text r] [Text r] Bit)) @@ -319,17 +319,17 @@ #implementations (list) #values (list)}] (|> (list\fold add_definition init defs) - (update@ #types (list.sorted name_sort)) - (update@ #macros (list.sorted name_sort)) - (update@ #implementations (list.sorted name_sort)) - (update@ #values (list.sorted name_sort))))) + (revised@ #types (list.sorted name_sort)) + (revised@ #macros (list.sorted name_sort)) + (revised@ #implementations (list.sorted name_sort)) + (revised@ #values (list.sorted name_sort))))) (def: (unravel_type_func level type) (-> Nat Type Type) (if (n.> 0 level) (case type (#.UnivQ _env _type) - (unravel_type_func (dec level) _type) + (unravel_type_func (-- level) _type) _ type) @@ -371,7 +371,7 @@ (|> type (unravel_type_func nesting) (when> [(new> recursive_type? [])] [unrecurse_type]) - (pprint_type_definition (dec nesting) [_name type_arguments] (maybe.else (list) tags) module interface? recursive_type?) + (pprint_type_definition (-- nesting) [_name type_arguments] (maybe.else (list) tags) module interface? recursive_type?) (text.all_split_by text.new_line) (list\map (|>> (format " "))) (text.interposed text.new_line)) @@ -421,7 +421,7 @@ (template [<singular> <plural> <header>] [(def: (<singular> module type) (-> Text Type (Markdown Block)) - (md.code (pprint_type (dec 0) "?" module type))) + (md.code (pprint_type (-- 0) "?" module type))) (def: (<plural> module values) (-> Text (List Value) (Markdown Block)) @@ -462,7 +462,7 @@ (do meta.monad [.let [(^slots [#types #macros #implementations #values]) organization annotations (|> module - (get@ #.module_annotations) + (value@ #.module_annotations) (maybe.else (' {})) annotation.documentation) description (case annotations diff --git a/stdlib/source/specification/aedifex/repository.lux b/stdlib/source/specification/aedifex/repository.lux index 9f29b2b4c..6a834a0a8 100644 --- a/stdlib/source/specification/aedifex/repository.lux +++ b/stdlib/source/specification/aedifex/repository.lux @@ -29,11 +29,11 @@ [expected (_binary.random 100)] (in ($_ _.and' (do async.monad - [.let [good_uri (/remote.uri (get@ #//artifact.version valid_artifact) valid_artifact //artifact/extension.lux_library)] + [.let [good_uri (/remote.uri (value@ #//artifact.version valid_artifact) valid_artifact //artifact/extension.lux_library)] good_upload! (\ subject upload good_uri expected) good_download! (\ subject download good_uri) - .let [bad_uri (/remote.uri (get@ #//artifact.version invalid_artifact) invalid_artifact //artifact/extension.lux_library)] + .let [bad_uri (/remote.uri (value@ #//artifact.version invalid_artifact) invalid_artifact //artifact/extension.lux_library)] bad_upload! (\ subject upload bad_uri expected) bad_download! (\ subject download bad_uri)] (_.cover' [/.Repository] diff --git a/stdlib/source/specification/compositor.lux b/stdlib/source/specification/compositor.lux index cf7008b76..70c314997 100644 --- a/stdlib/source/specification/compositor.lux +++ b/stdlib/source/specification/compositor.lux @@ -60,7 +60,7 @@ (case ?state,runner,definer (#try.Success [[directive_bundle directive_state] runner definer]) (..test runner definer - (get@ [#directive.analysis #directive.state] directive_state) + (value@ [#directive.analysis #directive.state] directive_state) expander) (#try.Failure error) diff --git a/stdlib/source/specification/compositor/common.lux b/stdlib/source/specification/compositor/common.lux index 3a7f70731..f663de359 100644 --- a/stdlib/source/specification/compositor/common.lux +++ b/stdlib/source/specification/compositor/common.lux @@ -73,9 +73,9 @@ [?state (platform.initialize target expander analysis_bundle platform generation_bundle directive_bundle program extender)] (in (do try.monad [[directive_bundle directive_state] ?state - .let [generation_state (get@ [#directive.generation - #directive.state] - directive_state)]] + .let [generation_state (value@ [#directive.generation + #directive.state] + directive_state)]] (in [[directive_bundle directive_state] (..runner platform generation_state) (..definer platform generation_state)]))))) diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux index 371a89162..8508220ed 100644 --- a/stdlib/source/specification/compositor/generation/case.lux +++ b/stdlib/source/specification/compositor/generation/case.lux @@ -36,7 +36,7 @@ (def: (tail? size idx) (-> Nat Nat Bit) - (n.= (dec size) idx)) + (n.= (-- size) idx)) (def: .public (verify expected) (-> Frac (Try Any) Bit) @@ -70,9 +70,9 @@ [subS subP] case .let [unitS (synthesis.text synthesis.unit) caseS (synthesis.tuple - (list.joined (list (list.repeated idx unitS) - (list subS) - (list.repeated (|> size dec (n.- idx)) unitS)))) + (list.together (list (list.repeated idx unitS) + (list subS) + (list.repeated (|> size -- (n.- idx)) unitS)))) caseP ($_ synthesis.path/seq (if (tail? size idx) (synthesis.member/right idx) diff --git a/stdlib/source/specification/compositor/generation/function.lux b/stdlib/source/specification/compositor/generation/function.lux index c3143b958..8a090094f 100644 --- a/stdlib/source/specification/compositor/generation/function.lux +++ b/stdlib/source/specification/compositor/generation/function.lux @@ -34,7 +34,7 @@ (def: (local arity) (-> Arity (Random Register)) - (|> r.nat (r\map (|>> (n.% arity) inc)))) + (|> r.nat (r\map (|>> (n.% arity) ++)))) (def: function (Random [Arity Register Synthesis]) @@ -53,7 +53,7 @@ [[arity local functionS] ..function partial_arity (|> r.nat (\ ! map (|>> (n.% arity) (n.max 1)))) inputs (r.list arity r.safe_frac) - .let [expectation (maybe.trusted (list.item (dec local) inputs)) + .let [expectation (maybe.trusted (list.item (-- local) inputs)) inputsS (list\map (|>> synthesis.f64) inputs)]] ($_ _.and (_.test "Can read arguments." @@ -77,7 +77,7 @@ (enum.range n.enum 1) (list\map (|>> #reference.Local))) variableS (if (n.<= partial_arity local) - (synthesis.variable/foreign (dec local)) + (synthesis.variable/foreign (-- local)) (synthesis.variable/local (|> local (n.- partial_arity)))) inner_arity (n.- partial_arity arity) innerS (synthesis.function/abstraction diff --git a/stdlib/source/specification/compositor/generation/structure.lux b/stdlib/source/specification/compositor/generation/structure.lux index b1f0e5666..de61ed882 100644 --- a/stdlib/source/specification/compositor/generation/structure.lux +++ b/stdlib/source/specification/compositor/generation/structure.lux @@ -33,11 +33,11 @@ (do {! r.monad} [num_tags (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) tag_in (|> r.nat (\ ! map (n.% num_tags))) - .let [last?_in (|> num_tags dec (n.= tag_in))] + .let [last?_in (|> num_tags -- (n.= tag_in))] value_in r.i64] (_.test (%.name (name_of synthesis.variant)) (|> (synthesis.variant {#analysis.lefts (if last?_in - (dec tag_in) + (-- tag_in) tag_in) #analysis.right? last?_in #analysis.value (synthesis.i64 value_in)}) diff --git a/stdlib/source/specification/lux/world/file.lux b/stdlib/source/specification/lux/world/file.lux index 971e312de..0b5414dea 100644 --- a/stdlib/source/specification/lux/world/file.lux +++ b/stdlib/source/specification/lux/world/file.lux @@ -166,7 +166,7 @@ (|>> (text\= child) not) (|>> (text\= sub_dir) not)) (random.ascii/numeric 2)) - expected_file_size (\ ! map (|>> (n.% 10) inc) random.nat) + expected_file_size (\ ! map (|>> (n.% 10) ++) random.nat) content ($binary.random expected_file_size) appendix ($binary.random expected_file_size) expected_time random.instant]) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux index ada815059..915d283da 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux @@ -47,18 +47,18 @@ (do random.monad [sample random stamp $///stamp.random] - (let [version (get@ #/.version sample) + (let [version (value@ #/.version sample) local! (text\= version - (/.format (set@ #/.snapshot #///.Local sample))) + (/.format (with@ #/.snapshot #///.Local sample))) remote_format (/.format {#/.version (format version /.snapshot) #/.snapshot (#///.Remote stamp)}) remote! - (and (text.starts_with? (format version (///time.format (get@ #///stamp.time stamp))) + (and (text.starts_with? (format version (///time.format (value@ #///stamp.time stamp))) remote_format) - (text.ends_with? (%.nat (get@ #///stamp.build stamp)) + (text.ends_with? (%.nat (value@ #///stamp.build stamp)) remote_format))] (_.cover [/.snapshot /.format] (and local! diff --git a/stdlib/source/test/aedifex/artifact/time/time.lux b/stdlib/source/test/aedifex/artifact/time/time.lux index 4dcdac3cc..1f5e4c6e7 100644 --- a/stdlib/source/test/aedifex/artifact/time/time.lux +++ b/stdlib/source/test/aedifex/artifact/time/time.lux @@ -19,7 +19,7 @@ (def: .public random (Random /.Time) - (random.one (|>> time.clock (set@ #time.milli_second 0) time.time) + (random.one (|>> time.clock (with@ #time.milli_second 0) time.time) random.time)) (def: .public test diff --git a/stdlib/source/test/aedifex/cache.lux b/stdlib/source/test/aedifex/cache.lux index 44641af70..91870d680 100644 --- a/stdlib/source/test/aedifex/cache.lux +++ b/stdlib/source/test/aedifex/cache.lux @@ -57,7 +57,7 @@ (try.maybe (do try.monad [pom (//pom.write profile) - identity (try.of_maybe (get@ #//.identity profile))] + identity (try.of_maybe (value@ #//.identity profile))] (in [identity profile pom])))) @profile.random)) @@ -75,7 +75,7 @@ content ..content] (in [{#//dependency.artifact identity #//dependency.type type} - (set@ #//package.origin (#//repository/origin.Remote "") (//package.local pom content))]))) + (with@ #//package.origin (#//repository/origin.Remote "") (//package.local pom content))]))) (def: resolution (Random Resolution) @@ -88,14 +88,14 @@ (do ! [pom (random.one (function (_ [identity profile pom]) (|> profile - (set@ #//.dependencies (set.empty //dependency.hash)) - (set@ #//.identity (#.Some (get@ #//dependency.artifact dependency))) + (with@ #//.dependencies (set.empty //dependency.hash)) + (with@ #//.identity (#.Some (value@ #//dependency.artifact dependency))) //pom.write try.maybe)) ..profile) content ..content] (in [dependency - (set@ #//package.origin (#//repository/origin.Remote "") (//package.local pom content))])))))] + (with@ #//package.origin (#//repository/origin.Remote "") (//package.local pom content))])))))] (in (dictionary.of_list //dependency.hash (list& [main_dependency main_package] dependencies))))) (def: singular @@ -116,7 +116,7 @@ [_ wrote! actual_package read!] (in (\ //package.equivalence = - (set@ #//package.origin (#//repository/origin.Local "") expected_package) + (with@ #//package.origin (#//repository/origin.Local "") expected_package) actual_package))))))))) (def: plural @@ -138,7 +138,7 @@ actual read!] (in (\ //dependency/resolution.equivalence = (\ dictionary.functor map - (set@ #//package.origin (#//repository/origin.Local "")) + (with@ #//package.origin (#//repository/origin.Local "")) expected) actual))))))))) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 41d0f080f..ea62b6daa 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -53,7 +53,7 @@ [@runs (function (_ console program fs shell resolution profile) (do {! async.monad} - [[_ actual_runs] (async.future (atom.update! inc @runs))] + [[_ actual_runs] (async.future (atom.update! ++ @runs))] (if (n.= expected_runs actual_runs) (in (#try.Failure end_signal)) (do (try.with !) @@ -77,14 +77,14 @@ .let [empty_profile (: Profile (\ ///.monoid identity)) with_target (: (-> Profile Profile) - (set@ #///.target target)) + (with@ #///.target target)) with_program (: (-> Profile Profile) - (set@ #///.program (#.Some program))) + (with@ #///.program (#.Some program))) profile (|> empty_profile with_program with_target - (set@ #///.sources (set.of_list text.hash (list source))))] + (with@ #///.sources (set.of_list text.hash (list source))))] home (random.ascii/alpha 5) working_directory (random.ascii/alpha 5) @@ -103,7 +103,7 @@ _ (\ watcher poll [])] (do {! async.monad} [no_dangling_process! (|> profile - (set@ #///.compiler compiler) + (with@ #///.compiler compiler) ((/.do! 1 watcher command) ($version.echo "") (program.async (program.mock environment.empty home working_directory)) diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 81f331e41..03625f0c1 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -151,9 +151,9 @@ .let [empty_profile (: Profile (\ ///.monoid identity)) with_target (: (-> Profile Profile) - (set@ #///.target target)) + (with@ #///.target target)) with_program (: (-> Profile Profile) - (set@ #///.program (#.Some program))) + (with@ #///.program (#.Some program))) profile (|> empty_profile with_program @@ -185,7 +185,7 @@ [verdict (do ///action.monad [_ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs shell resolution - (set@ #///.compiler compiler profile)) + (with@ #///.compiler compiler profile)) start (\ console read_line []) end (\ console read_line [])] (in (and (text\= /.start start) @@ -207,7 +207,7 @@ [verdict (do ///action.monad [_ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs (shell.async (..bad_shell [])) resolution - (set@ #///.compiler compiler profile)) + (with@ #///.compiler compiler profile)) start (\ console read_line []) end (\ console read_line [])] (in (and (text\= /.start start) diff --git a/stdlib/source/test/aedifex/command/clean.lux b/stdlib/source/test/aedifex/command/clean.lux index fffef3033..30ef6eb6f 100644 --- a/stdlib/source/test/aedifex/command/clean.lux +++ b/stdlib/source/test/aedifex/command/clean.lux @@ -103,7 +103,7 @@ context_exists!/pre (..directory_exists? fs context) target_exists!/pre (..assets_exist? fs target_path direct_files) sub_exists!/pre (..assets_exist? fs sub_path sub_files) - _ (/.do! console fs (set@ #///.target target_path dummy)) + _ (/.do! console fs (with@ #///.target target_path dummy)) context_exists!/post (..directory_exists? fs context) target_exists!/post (..assets_exist? fs target_path direct_files) sub_exists!/post (..assets_exist? fs sub_path sub_files) diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 4d11234bd..1df6a4180 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -55,7 +55,7 @@ (Async (Try Text))) (do ///action.monad [.let [console ($version.echo "")] - _ ($install.make_sources! fs (get@ #///.sources profile)) + _ ($install.make_sources! fs (value@ #///.sources profile)) _ (/.do! console repository fs artifact profile)] (\ console read_line []))) @@ -66,7 +66,7 @@ [[artifact expected_pom profile] (random.one (function (_ profile) (do maybe.monad - [artifact (get@ #///.identity profile) + [artifact (value@ #///.identity profile) expected_pom (try.maybe (///pom.write profile))] (in [artifact expected_pom profile]))) $profile.random) @@ -81,19 +81,19 @@ [verdict (do {! ///action.monad} [logging (..execute! program repository fs artifact profile) expected_library (|> profile - (get@ #///.sources) + (value@ #///.sources) set.list (export.library fs) (\ ! map (format.result tar.writer))) - actual_pom (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact ///artifact/extension.pom)) - actual_library (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact ///artifact/extension.lux_library)) - actual_sha-1 (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.sha-1))) + actual_pom (\ repository download (///repository/remote.uri (value@ #///artifact.version artifact) artifact ///artifact/extension.pom)) + actual_library (\ repository download (///repository/remote.uri (value@ #///artifact.version artifact) artifact ///artifact/extension.lux_library)) + actual_sha-1 (\ repository download (///repository/remote.uri (value@ #///artifact.version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.sha-1))) actual_sha-1 (\ async.monad in (do try.monad [actual_sha-1 (\ utf8.codec decode actual_sha-1)] (\ ///hash.sha-1_codec decode actual_sha-1))) - actual_md5 (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.md5))) + actual_md5 (\ repository download (///repository/remote.uri (value@ #///artifact.version artifact) artifact (format ///artifact/extension.lux_library ///artifact/extension.md5))) actual_md5 (\ async.monad in (do try.monad [actual_md5 (\ utf8.codec decode actual_md5)] diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index 0c6676488..ec45ba697 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -73,25 +73,25 @@ #///dependency.type ///artifact/type.lux_library} dependee_pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some dependee_artifact)) + (with@ #///.identity (#.Some dependee_artifact)) ///pom.write try.trusted) depender_pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some depender_artifact)) - (set@ #///.dependencies (set.of_list ///dependency.hash (list dependee))) + (with@ #///.identity (#.Some depender_artifact)) + (with@ #///.dependencies (set.of_list ///dependency.hash (list dependee))) ///pom.write try.trusted) dependee_package (|> dependee_package - (set@ #///package.origin (#///repository/origin.Remote "")) - (set@ #///package.pom [dependee_pom - (|> dependee_pom (\ xml.codec encode) (\ utf8.codec encode)) - #///dependency/status.Unverified])) + (with@ #///package.origin (#///repository/origin.Remote "")) + (with@ #///package.pom [dependee_pom + (|> dependee_pom (\ xml.codec encode) (\ utf8.codec encode)) + #///dependency/status.Unverified])) depender_package (|> depender_package - (set@ #///package.origin (#///repository/origin.Remote "")) - (set@ #///package.pom [depender_pom - (|> depender_pom (\ xml.codec encode) (\ utf8.codec encode)) - #///dependency/status.Unverified])) + (with@ #///package.origin (#///repository/origin.Remote "")) + (with@ #///package.pom [depender_pom + (|> depender_pom (\ xml.codec encode) (\ utf8.codec encode)) + #///dependency/status.Unverified])) fs (file.mock (\ file.default separator)) program (program.async (program.mock environment.empty home working_directory))]] @@ -103,7 +103,7 @@ (dictionary.has dependee dependee_package) (///dependency/deployment.all local)) post (|> (\ ///.monoid identity) - (set@ #///.dependencies (set.of_list ///dependency.hash (list dependee depender))) + (with@ #///.dependencies (set.of_list ///dependency.hash (list dependee depender))) (/.do! console local (list (///repository.mock ($///dependency/resolution.single depender_artifact depender_package) [])) diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index 86fe5ebea..f1c0c2de1 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -56,7 +56,7 @@ (-> (Program Async) (file.System Async) ///.Profile (Async (Try Text))) (do ///action.monad [.let [console ($version.echo "")] - _ (..make_sources! fs (get@ #///.sources sample)) + _ (..make_sources! fs (value@ #///.sources sample)) _ (/.do! console fs (///repository/local.repository program fs) sample)] (\ console read_line []))) @@ -65,7 +65,7 @@ (<| (_.covering /._) (do {! random.monad} [identity $artifact.random - sample (\ ! map (set@ #///.identity (#.Some identity)) + sample (\ ! map (with@ #///.identity (#.Some identity)) $profile.random) home (random.ascii/alpha 5) working_directory (random.ascii/alpha 5) @@ -75,7 +75,7 @@ [.let [fs (file.mock /) program (program.async (program.mock environment.empty home working_directory)) - artifact_path (///local.uri (get@ #///artifact.version identity) identity) + artifact_path (///local.uri (value@ #///artifact.version identity) identity) library_path (format artifact_path ///artifact/extension.lux_library) pom_path (format artifact_path ///artifact/extension.pom)] verdict (do {! ///action.monad} @@ -97,7 +97,7 @@ (in (do {! async.monad} [.let [fs (file.mock /) program (program.async (program.mock environment.empty home working_directory))] - logging (..execute! program fs (set@ #///.identity #.None sample))] + logging (..execute! program fs (with@ #///.identity #.None sample))] (_.cover' [/.failure] (|> logging (try\map (text\= /.failure)) diff --git a/stdlib/source/test/aedifex/command/pom.lux b/stdlib/source/test/aedifex/command/pom.lux index 9577842c1..b06a7c944 100644 --- a/stdlib/source/test/aedifex/command/pom.lux +++ b/stdlib/source/test/aedifex/command/pom.lux @@ -62,7 +62,7 @@ (#try.Failure error) (_.cover' [/.do!] - (case (get@ #///.identity sample) + (case (value@ #///.identity sample) (#.Some _) false diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index f2117fad4..3e3cf85d7 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -50,9 +50,9 @@ .let [empty_profile (: Profile (\ ///.monoid identity)) with_target (: (-> Profile Profile) - (set@ #///.target target)) + (with@ #///.target target)) with_test (: (-> Profile Profile) - (set@ #///.test (#.Some test))) + (with@ #///.test (#.Some test))) profile (|> empty_profile with_test @@ -65,7 +65,7 @@ [verdict (do ///action.monad [_ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs (shell.async (@build.good_shell [])) resolution - (set@ #///.compiler compiler profile)) + (with@ #///.compiler compiler profile)) build_start (\ console read_line []) build_end (\ console read_line []) test_start (\ console read_line []) @@ -101,7 +101,7 @@ [])] _ (/.do! console (program.async (program.mock environment.empty home working_directory)) fs (shell.async bad_shell) resolution - (set@ #///.compiler compiler profile)) + (with@ #///.compiler compiler profile)) build_start (\ console read_line []) build_end (\ console read_line []) test_start (\ console read_line []) diff --git a/stdlib/source/test/aedifex/dependency/deployment.lux b/stdlib/source/test/aedifex/dependency/deployment.lux index ae97a70ca..009298783 100644 --- a/stdlib/source/test/aedifex/dependency/deployment.lux +++ b/stdlib/source/test/aedifex/dependency/deployment.lux @@ -79,20 +79,20 @@ (-> Nat URL Package (Dictionary URL Binary) Artifact Artifact Bit) (let [url (: (-> URI URL) (|>> (format address))) - library_url (url (format (artifact.uri (get@ #artifact.version expected_artifact) + library_url (url (format (artifact.uri (value@ #artifact.version expected_artifact) expected_artifact) artifact/extension.lux_library)) - pom_url (url (format (artifact.uri (get@ #artifact.version expected_artifact) + pom_url (url (format (artifact.uri (value@ #artifact.version expected_artifact) expected_artifact) artifact/extension.pom)) artifact_metadata_url (url (metadata.remote_artifact_uri expected_artifact)) project_metadata_url (url (metadata.remote_project_uri expected_artifact)) expected_library (|> package - (get@ #package.library) + (value@ #package.library) product.left) expected_pom (|> package - (get@ #package.pom) + (value@ #package.pom) product.right product.left) @@ -136,7 +136,7 @@ (do random.monad [[profile package] $///package.random .let [artifact (|> profile - (get@ #profile.identity) + (value@ #profile.identity) maybe.trusted) dependency (: Dependency [artifact diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index c7f7d6d40..44420243d 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -98,7 +98,7 @@ (def: .public (single artifact package) (-> Artifact Package (Mock Any)) - (let [expected (///artifact.uri (get@ #///artifact.version artifact) artifact)] + (let [expected (///artifact.uri (value@ #///artifact.version artifact) artifact)] (implementation (def: the_description "[1]") @@ -106,11 +106,11 @@ (if (text.contains? expected uri) (let [library (: Binary (|> package - (get@ #///package.library) + (value@ #///package.library) product.left)) pom (: Binary (|> package - (get@ #///package.pom) + (value@ #///package.pom) product.left (\ xml.codec encode) (\ utf8.codec encode)))] @@ -144,34 +144,34 @@ (def: the_description "[~SHA-1]") (def: (on_download uri state) - (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) + (if (text.contains? (///artifact.uri (value@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) (#try.Success [state (|> expected_package - (get@ #///package.library) + (value@ #///package.library) product.left)]) (text.ends_with? ..lux_sha-1 uri) (#try.Success [state (|> expected_package - (get@ #///package.library) + (value@ #///package.library) product.left ..sha-1)]) (text.ends_with? ..lux_md5 uri) (#try.Success [state (|> expected_package - (get@ #///package.library) + (value@ #///package.library) product.left ..md5)]) (text.ends_with? ///artifact/extension.pom uri) (#try.Success [state (|> expected_package - (get@ #///package.pom) + (value@ #///package.pom) product.left (\ xml.codec encode) (\ utf8.codec encode))]) (text.ends_with? ..pom_sha-1 uri) (#try.Success [state (|> dummy_package - (get@ #///package.pom) + (value@ #///package.pom) product.left (\ xml.codec encode) (\ utf8.codec encode) @@ -179,7 +179,7 @@ (text.ends_with? ..pom_md5 uri) (#try.Success [state (|> expected_package - (get@ #///package.pom) + (value@ #///package.pom) product.left (\ xml.codec encode) (\ utf8.codec encode) @@ -197,34 +197,34 @@ (def: the_description "[~MD5]") (def: (on_download uri state) - (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) + (if (text.contains? (///artifact.uri (value@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) (#try.Success [state (|> expected_package - (get@ #///package.library) + (value@ #///package.library) product.left)]) (text.ends_with? ..lux_sha-1 uri) (#try.Success [state (|> expected_package - (get@ #///package.library) + (value@ #///package.library) product.left ..sha-1)]) (text.ends_with? ..lux_md5 uri) (#try.Success [state (|> dummy_package - (get@ #///package.library) + (value@ #///package.library) product.left ..md5)]) (text.ends_with? ///artifact/extension.pom uri) (#try.Success [state (|> expected_package - (get@ #///package.pom) + (value@ #///package.pom) product.left (\ xml.codec encode) (\ utf8.codec encode))]) (text.ends_with? ..pom_sha-1 uri) (#try.Success [state (|> expected_package - (get@ #///package.pom) + (value@ #///package.pom) product.left (\ xml.codec encode) (\ utf8.codec encode) @@ -232,7 +232,7 @@ (text.ends_with? ..pom_md5 uri) (#try.Success [state (|> dummy_package - (get@ #///package.pom) + (value@ #///package.pom) product.left (\ xml.codec encode) (\ utf8.codec encode) @@ -250,7 +250,7 @@ [expected_artifact $///artifact.random [_ expected_package] $///package.random [_ dummy_package] (random.only (|>> product.right - (set@ #///package.pom (get@ #///package.pom expected_package)) + (with@ #///package.pom (value@ #///package.pom expected_package)) (\ ///package.equivalence = expected_package) not) $///package.random) @@ -266,7 +266,7 @@ (case actual_package (#try.Success actual_package) (\ ///package.equivalence = - (set@ #///package.origin (#///repository/origin.Remote "") expected_package) + (with@ #///package.origin (#///repository/origin.Remote "") expected_package) actual_package) (#try.Failure _) @@ -295,7 +295,7 @@ [expected_artifact $///artifact.random [_ expected_package] $///package.random [_ dummy_package] (random.only (|>> product.right - (set@ #///package.pom (get@ #///package.pom expected_package)) + (with@ #///package.pom (value@ #///package.pom expected_package)) (\ ///package.equivalence = expected_package) not) $///package.random) @@ -315,7 +315,7 @@ (case actual_package (#try.Success actual_package) (\ ///package.equivalence = - (set@ #///package.origin (#///repository/origin.Remote "") expected_package) + (with@ #///package.origin (#///repository/origin.Remote "") expected_package) actual_package) (#try.Failure _) @@ -344,8 +344,8 @@ (\ ///artifact.equivalence = dependee_artifact)) $///artifact.random) ignored_artifact (random.only (predicate.complement - (predicate.unite (\ ///artifact.equivalence = dependee_artifact) - (\ ///artifact.equivalence = depender_artifact))) + (predicate.and (\ ///artifact.equivalence = dependee_artifact) + (\ ///artifact.equivalence = depender_artifact))) $///artifact.random)] (in [dependee_artifact depender_artifact ignored_artifact]))) @@ -366,34 +366,34 @@ #///dependency.type ///artifact/type.lux_library} dependee_pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some dependee_artifact)) + (with@ #///.identity (#.Some dependee_artifact)) ///pom.write try.trusted) depender_pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some depender_artifact)) - (set@ #///.dependencies (set.of_list ///dependency.hash (list dependee))) + (with@ #///.identity (#.Some depender_artifact)) + (with@ #///.dependencies (set.of_list ///dependency.hash (list dependee))) ///pom.write try.trusted) ignored_pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some ignored_artifact)) + (with@ #///.identity (#.Some ignored_artifact)) ///pom.write try.trusted) - dependee_package (set@ #///package.pom - [dependee_pom - (|> dependee_pom (\ xml.codec encode) (\ utf8.codec encode)) + dependee_package (with@ #///package.pom + [dependee_pom + (|> dependee_pom (\ xml.codec encode) (\ utf8.codec encode)) + #///dependency/status.Unverified] + dependee_package) + depender_package (with@ #///package.pom + [depender_pom + (|> depender_pom (\ xml.codec encode) (\ utf8.codec encode)) + #///dependency/status.Unverified] + depender_package) + ignored_package (with@ #///package.pom + [ignored_pom + (|> ignored_pom (\ xml.codec encode) (\ utf8.codec encode)) #///dependency/status.Unverified] - dependee_package) - depender_package (set@ #///package.pom - [depender_pom - (|> depender_pom (\ xml.codec encode) (\ utf8.codec encode)) - #///dependency/status.Unverified] - depender_package) - ignored_package (set@ #///package.pom - [ignored_pom - (|> ignored_pom (\ xml.codec encode) (\ utf8.codec encode)) - #///dependency/status.Unverified] - ignored_package)]] + ignored_package)]] (in [[dependee depender ignored] [dependee_package depender_package ignored_package]]))) diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux index 086551be0..1c47fdd6f 100644 --- a/stdlib/source/test/aedifex/input.lux +++ b/stdlib/source/test/aedifex/input.lux @@ -45,7 +45,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [expected (\ ! map (set@ #//.parents (list)) $profile.random) + [expected (\ ! map (with@ #//.parents (list)) $profile.random) .let [fs (: (file.System Async) (file.mock (\ file.default separator)))]] (in (do async.monad @@ -59,8 +59,8 @@ (/.read async.monad fs //.default))] (in (\ //.equivalence = (|> expected - (update@ #//.sources ..with_default_source) - (update@ #//.repositories ..with_default_repository)) + (revised@ #//.sources ..with_default_source) + (revised@ #//.repositories ..with_default_repository)) actual)))] (_.cover' [/.read] (try.else false verdict))))))) diff --git a/stdlib/source/test/aedifex/local.lux b/stdlib/source/test/aedifex/local.lux index a797f2a97..a8c0702bb 100644 --- a/stdlib/source/test/aedifex/local.lux +++ b/stdlib/source/test/aedifex/local.lux @@ -23,5 +23,5 @@ ($_ _.and (_.cover [/.repository /.uri] (text.starts_with? /.repository - (/.uri (get@ #//artifact.version sample) sample))) + (/.uri (value@ #//artifact.version sample) sample))) )))) diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index 46ebf4eae..85aafa550 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -72,10 +72,10 @@ (_.for [/.Metadata]) (do random.monad [expected ..random - .let [artifact {#///artifact.group (get@ #/.group expected) - #///artifact.name (get@ #/.name expected) + .let [artifact {#///artifact.group (value@ #/.group expected) + #///artifact.name (value@ #/.name expected) #///artifact.version (|> expected - (get@ #/.versions) + (value@ #/.versions) list.head (maybe.else ""))}]] ($_ _.and diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index d5dc8595e..2c74296e0 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -91,7 +91,7 @@ (_.for [/.Metadata]) (do random.monad [expected ..random - .let [artifact (get@ #/.artifact expected)]] + .let [artifact (value@ #/.artifact expected)]] ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) diff --git a/stdlib/source/test/aedifex/package.lux b/stdlib/source/test/aedifex/package.lux index e05c1d753..9596eb63f 100644 --- a/stdlib/source/test/aedifex/package.lux +++ b/stdlib/source/test/aedifex/package.lux @@ -64,18 +64,18 @@ ($equivalence.spec /.equivalence (\ ! map product.right ..random))) (_.cover [/.local?] - (/.local? (set@ #/.origin (#//origin.Local "~/yolo") package))) + (/.local? (with@ #/.origin (#//origin.Local "~/yolo") package))) (_.cover [/.remote?] - (/.remote? (set@ #/.origin (#//origin.Remote "https://example.com") package))) + (/.remote? (with@ #/.origin (#//origin.Remote "https://example.com") package))) (_.cover [/.local] - (let [expected_pom (|> package (get@ #/.pom) product.left) - expected_library (|> package (get@ #/.library) product.left) + (let [expected_pom (|> package (value@ #/.pom) product.left) + expected_library (|> package (value@ #/.library) product.left) local (/.local expected_pom expected_library) - [actual_pom binary_pom pom_status] (get@ #/.pom local) - [actual_library library_status] (get@ #/.library local)] - (and (case (get@ #/.origin local) + [actual_pom binary_pom pom_status] (value@ #/.pom local) + [actual_library library_status] (value@ #/.library local)] + (and (case (value@ #/.origin local) (#//origin.Local "") true _ false) (let [expected_sha1 (//hash.sha-1 expected_library) @@ -104,7 +104,7 @@ _ false)))))) (_.cover [/.dependencies] - (let [expected (get@ #//.dependencies profile)] + (let [expected (value@ #//.dependencies profile)] (case (/.dependencies package) (#try.Success actual) (\ set.equivalence = expected actual) @@ -112,7 +112,7 @@ (#try.Failure error) false))) (_.cover [/.repositories] - (let [expected (get@ #//.repositories profile)] + (let [expected (value@ #//.repositories profile)] (case (/.repositories package) (#try.Success actual) (\ set.equivalence = expected actual) diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux index 152123d55..6f1516258 100644 --- a/stdlib/source/test/aedifex/parser.lux +++ b/stdlib/source/test/aedifex/parser.lux @@ -55,16 +55,16 @@ (def: with_default_sources (-> //.Profile //.Profile) - (update@ #//.sources - (: (-> (Set //.Source) (Set //.Source)) - (function (_ sources) - (if (set.empty? sources) - (set.of_list text.hash (list //.default_source)) - sources))))) + (revised@ #//.sources + (: (-> (Set //.Source) (Set //.Source)) + (function (_ sources) + (if (set.empty? sources) + (set.of_list text.hash (list //.default_source)) + sources))))) (def: with_default_repository (-> //.Profile //.Profile) - (update@ #//.repositories (set.has //.default_repository))) + (revised@ #//.repositories (set.has //.default_repository))) (def: single_profile Test diff --git a/stdlib/source/test/aedifex/pom.lux b/stdlib/source/test/aedifex/pom.lux index f51ac9abc..e413b69ed 100644 --- a/stdlib/source/test/aedifex/pom.lux +++ b/stdlib/source/test/aedifex/pom.lux @@ -34,15 +34,15 @@ [expected @profile.random] (_.cover [/.write /.parser] (case [(/.write expected) - (get@ #//.identity expected)] + (value@ #//.identity expected)] [(#try.Success pom) (#.Some _)] (case (<xml>.result /.parser (list pom)) (#try.Success actual) (\ //.equivalence = (|> (\ //.monoid identity) - (set@ #//.dependencies (get@ #//.dependencies expected)) - (set@ #//.repositories (get@ #//.repositories expected))) + (with@ #//.dependencies (value@ #//.dependencies expected)) + (with@ #//.repositories (value@ #//.repositories expected))) actual) (#try.Failure error) diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index b1ec22e6c..4cb58d0d0 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -154,10 +154,10 @@ (text\= "" /.default)) (_.cover [/.default_compiler] (|> (\ /.monoid identity) - (get@ #/.compiler) + (value@ #/.compiler) (same? /.default_compiler))) (_.cover [/.default_target] (|> (\ /.monoid identity) - (get@ #/.target) + (value@ #/.target) (same? /.default_target))) ))))) diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux index 3d027eec7..291935293 100644 --- a/stdlib/source/test/aedifex/project.lux +++ b/stdlib/source/test/aedifex/project.lux @@ -27,7 +27,7 @@ (def: profile (Random [//.Name //.Profile]) (|> @profile.random - (random\map (set@ #//.parents (list))) + (random\map (with@ #//.parents (list))) (random.and (random.ascii/alpha 1)))) (def: .public random @@ -66,11 +66,11 @@ .let [project ($_ (\ /.monoid compose) (/.project super_name super_profile) (/.project dummy_name dummy_profile) - (/.project sub_name (set@ #//.parents (list super_name) sub_profile))) + (/.project sub_name (with@ #//.parents (list super_name) sub_profile))) circular ($_ (\ /.monoid compose) - (/.project super_name (set@ #//.parents (list sub_name) super_profile)) + (/.project super_name (with@ #//.parents (list sub_name) super_profile)) (/.project dummy_name dummy_profile) - (/.project sub_name (set@ #//.parents (list super_name) sub_profile)))]] + (/.project sub_name (with@ #//.parents (list super_name) sub_profile)))]] ($_ _.and (_.cover [/.profile] (and (|> (/.profile super_name project) diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index c9e61b017..782b20204 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -44,7 +44,7 @@ (~~ (template [<command>] [(_.cover [/.default_java /.default_js /.default_python /.default_lua /.default_ruby] (let [listing (|> (list /.default_java /.default_js /.default_python /.default_lua /.default_ruby) - (list\map (get@ #/.program))) + (list\map (value@ #/.program))) unique (set.of_list text.hash listing)] (n.= (list.size listing) (set.size unique))))] @@ -57,10 +57,10 @@ )) (_.cover [/.for] (let [runtime' (/.for runtime path)] - (and (text\= (get@ #/.program runtime) - (get@ #/.program runtime')) + (and (text\= (value@ #/.program runtime) + (value@ #/.program runtime')) (|> runtime' - (get@ #/.parameters) + (value@ #/.parameters) list.last (maybe\map (text\= path)) (maybe.else false))))) diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index a0e00fdd4..6eab1c60b 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -280,20 +280,20 @@ (do random.monad [start random.nat factor random.nat - .let [expected (n.* factor (inc start))]] + .let [expected (n.* factor (++ start))]] ($_ _.and (_.cover [/.|>] (n.= expected - (/.|> start inc (n.* factor)))) + (/.|> start ++ (n.* factor)))) (_.cover [/.|>>] (n.= expected - ((/.|>> inc (n.* factor)) start))) + ((/.|>> ++ (n.* factor)) start))) (_.cover [/.<|] (n.= expected - (/.<| (n.* factor) inc start))) + (/.<| (n.* factor) ++ start))) (_.cover [/.<<|] (n.= expected - ((/.<<| (n.* factor) inc) start))) + ((/.<<| (n.* factor) ++) start))) ))) (def: example_identifier "YOLO") @@ -421,7 +421,7 @@ )) (_.cover [/.Ann] (|> example - (get@ #/.meta) + (value@ #/.meta) (location\= location.dummy))) ))) @@ -432,7 +432,7 @@ "This is an arbitrary text whose only purpose is to be found, somewhere, in the source-code.") (/.macro: (found_crosshair? tokens lux) - (let [[_ _ source_code] (get@ #.source lux)] + (let [[_ _ source_code] (value@ #.source lux)] (#.Right [lux (list (code.bit (text.contains? ..crosshair source_code)))]))) (def: for_macro @@ -572,11 +572,11 @@ (_.cover [/.rev] (same? (: Any expected) (: Any (/.rev expected)))) - (_.cover [/.inc] + (_.cover [/.++] (n.= 1 (n.- expected - (/.inc expected)))) - (_.cover [/.dec] - (n.= 1 (n.- (/.dec expected) + (/.++ expected)))) + (_.cover [/.--] + (n.= 1 (n.- (/.-- expected) expected))) ))) @@ -588,13 +588,13 @@ (_.cover [/.-> /.function] (and (let [actual (: (/.-> Nat Nat Nat) (/.function (_ actual_left actual_right) - (n.* (inc actual_left) (dec actual_right))))] - (n.= (n.* (inc expected_left) (dec expected_right)) + (n.* (++ actual_left) (-- actual_right))))] + (n.= (n.* (++ expected_left) (-- expected_right)) (actual expected_left expected_right))) (let [actual (: (/.-> [Nat Nat] Nat) (/.function (_ [actual_left actual_right]) - (n.* (inc actual_left) (dec actual_right))))] - (n.= (n.* (inc expected_left) (dec expected_right)) + (n.* (++ actual_left) (-- actual_right))))] + (n.= (n.* (++ expected_left) (-- expected_right)) (actual [expected_left expected_right]))))))) (/.template: (!n/+ <left> <right>) @@ -673,72 +673,72 @@ #big_right {#small_left start/s #small_right text}}]] ($_ _.and - (_.cover [/.get@] + (_.cover [/.value@] (and (and (|> sample - (/.get@ #big_left) + (/.value@ #big_left) (same? start/b)) (|> sample - ((/.get@ #big_left)) + ((/.value@ #big_left)) (same? start/b))) (and (|> sample - (/.get@ [#big_right #small_left]) + (/.value@ [#big_right #small_left]) (same? start/s)) (|> sample - ((/.get@ [#big_right #small_left])) + ((/.value@ [#big_right #small_left])) (same? start/s))))) - (_.cover [/.set@] + (_.cover [/.with@] (and (and (|> sample - (/.set@ #big_left shift/b) - (/.get@ #big_left) + (/.with@ #big_left shift/b) + (/.value@ #big_left) (same? shift/b)) (|> sample - ((/.set@ #big_left shift/b)) - (/.get@ #big_left) + ((/.with@ #big_left shift/b)) + (/.value@ #big_left) (same? shift/b)) (|> sample - ((/.set@ #big_left) shift/b) - (/.get@ #big_left) + ((/.with@ #big_left) shift/b) + (/.value@ #big_left) (same? shift/b))) (and (|> sample - (/.set@ [#big_right #small_left] shift/s) - (/.get@ [#big_right #small_left]) + (/.with@ [#big_right #small_left] shift/s) + (/.value@ [#big_right #small_left]) (same? shift/s)) (|> sample - ((/.set@ [#big_right #small_left] shift/s)) - (/.get@ [#big_right #small_left]) + ((/.with@ [#big_right #small_left] shift/s)) + (/.value@ [#big_right #small_left]) (same? shift/s)) (|> sample - ((/.set@ [#big_right #small_left]) shift/s) - (/.get@ [#big_right #small_left]) + ((/.with@ [#big_right #small_left]) shift/s) + (/.value@ [#big_right #small_left]) (same? shift/s))))) - (_.cover [/.update@] + (_.cover [/.revised@] (and (and (|> sample - (/.update@ #big_left (n.+ shift/b)) - (/.get@ #big_left) + (/.revised@ #big_left (n.+ shift/b)) + (/.value@ #big_left) (n.= expected/b)) (|> sample - ((/.update@ #big_left (n.+ shift/b))) - (/.get@ #big_left) + ((/.revised@ #big_left (n.+ shift/b))) + (/.value@ #big_left) (n.= expected/b)) (|> sample ((: (-> (-> Nat Nat) (-> Big Big)) - (/.update@ #big_left)) + (/.revised@ #big_left)) (n.+ shift/b)) - (/.get@ #big_left) + (/.value@ #big_left) (n.= expected/b))) (and (|> sample - (/.update@ [#big_right #small_left] (n.+ shift/s)) - (/.get@ [#big_right #small_left]) + (/.revised@ [#big_right #small_left] (n.+ shift/s)) + (/.value@ [#big_right #small_left]) (n.= expected/s)) (|> sample - ((/.update@ [#big_right #small_left] (n.+ shift/s))) - (/.get@ [#big_right #small_left]) + ((/.revised@ [#big_right #small_left] (n.+ shift/s))) + (/.value@ [#big_right #small_left]) (n.= expected/s)) (|> sample ((: (-> (-> Nat Nat) (-> Big Big)) - (/.update@ [#big_right #small_left])) + (/.revised@ [#big_right #small_left])) (n.+ shift/s)) - (/.get@ [#big_right #small_left]) + (/.value@ [#big_right #small_left]) (n.= expected/s))))) ))) @@ -862,7 +862,7 @@ (hide left)) true))) (_.cover [/.same?] - (let [not_left (|> left inc dec)] + (let [not_left (|> left ++ --)] (and (/.same? left left) (and (n.= not_left left) (not (/.same? not_left left)))))) @@ -1009,7 +1009,7 @@ (/.loop [counter 0 value 0] (if (n.< iterations counter) - (recur (inc counter) (n.+ factor value)) + (recur (++ counter) (n.+ factor value)) value))))) (do random.monad [pre random.nat @@ -1051,13 +1051,13 @@ (syntax: (for_meta|Info []) (function (_ lux) - (let [info (get@ #.info lux) + (let [info (value@ #.info lux) conforming_target! - (set.member? ..possible_targets (get@ #.target info)) + (set.member? ..possible_targets (value@ #.target info)) compiling! - (case (get@ #.mode info) + (case (value@ #.mode info) #.Build true _ false)] (#.Right [lux (list (code.bit (and conforming_target! @@ -1066,7 +1066,7 @@ (syntax: (for_meta|Module_State []) (do meta.monad [prelude_module (meta.module .prelude_module)] - (in (list (code.bit (case (get@ #.module_state prelude_module) + (in (list (code.bit (case (value@ #.module_state prelude_module) #.Active false _ true)))))) @@ -1103,22 +1103,22 @@ let/2 <code>.local_identifier let/3 <code>.local_identifier]) - (in (list (code.bit (case (get@ #.scopes *lux*) + (in (list (code.bit (case (value@ #.scopes *lux*) (^ (list& scope/2 _)) - (let [locals/2 (get@ #.locals scope/2) + (let [locals/2 (value@ #.locals scope/2) expected_locals/2 (set.of_list text.hash (list fn/2 var/2 let/2 let/3)) actual_locals/2 (|> locals/2 - (get@ #.mappings) + (value@ #.mappings) (list\map product.left) (set.of_list text.hash)) correct_locals! - (and (n.= 4 (get@ #.counter locals/2)) + (and (n.= 4 (value@ #.counter locals/2)) (set\= expected_locals/2 actual_locals/2)) - captured/2 (get@ #.captured scope/2) + captured/2 (value@ #.captured scope/2) local? (: (-> Ref Bit) (function (_ ref) @@ -1130,13 +1130,13 @@ binding? (: (-> (-> Ref Bit) Text Bit) (function (_ is? name) (|> captured/2 - (get@ #.mappings) + (value@ #.mappings) (plist.value name) (maybe\map (|>> product.right is?)) (maybe.else false)))) correct_closure! - (and (n.= 6 (get@ #.counter captured/2)) + (and (n.= 6 (value@ #.counter captured/2)) (binding? local? fn/1) (binding? local? var/1) (binding? local? let/1) diff --git a/stdlib/source/test/lux/abstract/comonad.lux b/stdlib/source/test/lux/abstract/comonad.lux index 431272d9f..05067e786 100644 --- a/stdlib/source/test/lux/abstract/comonad.lux +++ b/stdlib/source/test/lux/abstract/comonad.lux @@ -20,9 +20,9 @@ (<| (_.covering /._) ($_ _.and (_.cover [/.be] - (n.= (inc sample) + (n.= (++ sample) (: (Identity Nat) (/.be identity.comonad [value (out sample)] - (out (inc value)))))) + (out (++ value)))))) )))) diff --git a/stdlib/source/test/lux/abstract/enum.lux b/stdlib/source/test/lux/abstract/enum.lux index 88d4cc732..179dad8df 100644 --- a/stdlib/source/test/lux/abstract/enum.lux +++ b/stdlib/source/test/lux/abstract/enum.lux @@ -31,7 +31,7 @@ (<| (_.covering /._) ($_ _.and (_.cover [/.range] - (let [expected_size (|> end (n.- start) inc) + (let [expected_size (|> end (n.- start) ++) expected_start? (|> range list.head (maybe\map (n.= start)) (maybe.else false)) expected_end? (|> range list.last (maybe\map (n.= end)) (maybe.else false)) can_be_backwards? (\ (list.equivalence n.equivalence) = diff --git a/stdlib/source/test/lux/abstract/monad.lux b/stdlib/source/test/lux/abstract/monad.lux index 0fc605a0c..051f63a5c 100644 --- a/stdlib/source/test/lux/abstract/monad.lux +++ b/stdlib/source/test/lux/abstract/monad.lux @@ -21,30 +21,30 @@ (<| (_.covering /._) ($_ _.and (_.cover [/.do] - (n.= (inc mono) + (n.= (++ mono) (: (Identity Nat) (/.do identity.monad [sample (in mono)] - (in (inc sample)))))) - (_.cover [/.bind] - (n.= (inc mono) + (in (++ sample)))))) + (_.cover [/.then] + (n.= (++ mono) (: (Identity Nat) - (/.bind identity.monad - (|>> inc (\ identity.monad in)) + (/.then identity.monad + (|>> ++ (\ identity.monad in)) (\ identity.monad in mono))))) - (_.cover [/.seq] + (_.cover [/.all] (\ (list.equivalence n.equivalence) = - (list\map inc poly) + (list\map ++ poly) (|> poly - (list\map (|>> inc (\ identity.monad in))) + (list\map (|>> ++ (\ identity.monad in))) (: (List (Identity Nat))) - (/.seq identity.monad) + (/.all identity.monad) (: (Identity (List Nat)))))) (_.cover [/.map] (\ (list.equivalence n.equivalence) = - (list\map inc poly) + (list\map ++ poly) (|> poly - (/.map identity.monad (|>> inc (\ identity.monad in))) + (/.map identity.monad (|>> ++ (\ identity.monad in))) (: (Identity (List Nat)))))) (_.cover [/.only] (\ (list.equivalence n.equivalence) = diff --git a/stdlib/source/test/lux/abstract/monad/free.lux b/stdlib/source/test/lux/abstract/monad/free.lux index b583f4a8e..523741df6 100644 --- a/stdlib/source/test/lux/abstract/monad/free.lux +++ b/stdlib/source/test/lux/abstract/monad/free.lux @@ -31,7 +31,7 @@ (#/.Effect effect) (|> effect (list\map interpret) - list.joined))) + list.together))) (def: comparison (Comparison (/.Free List)) diff --git a/stdlib/source/test/lux/control/concatenative.lux b/stdlib/source/test/lux/control/concatenative.lux index deb5601a7..97b7a48f6 100644 --- a/stdlib/source/test/lux/control/concatenative.lux +++ b/stdlib/source/test/lux/control/concatenative.lux @@ -76,18 +76,18 @@ [/.||L #.Left] [/.||R #.Right])) (_.cover [/.dip] - (n.= (inc sample) + (n.= (++ sample) (||> (/.push sample) (/.push dummy) - (/.push (/.apply/1 inc)) + (/.push (/.apply/1 ++)) /.dip /.drop))) (_.cover [/.dip/2] - (n.= (inc sample) + (n.= (++ sample) (||> (/.push sample) (/.push dummy) (/.push dummy) - (/.push (/.apply/1 inc)) + (/.push (/.apply/1 ++)) /.dip/2 /.drop /.drop))) )))) @@ -142,13 +142,13 @@ sample random.nat start random.nat .let [distance 10 - |inc| (/.apply/1 inc) + |++| (/.apply/1 ++) |test| (/.apply/1 (|>> (n.- start) (n.< distance)))]] ($_ _.and (_.cover [/.call /.apply/1] - (n.= (inc sample) + (n.= (++ sample) (||> (/.push sample) - (/.push (/.apply/1 inc)) + (/.push (/.apply/1 ++)) /.call))) (_.cover [/.apply/2] (n.= (n.+ sample sample) @@ -235,35 +235,35 @@ /.call))) (_.cover [/.if] (n.= (if choice - (inc sample) - (dec sample)) + (++ sample) + (-- sample)) (||> (/.push sample) (/.push choice) - (/.push (/.apply/1 inc)) - (/.push (/.apply/1 dec)) + (/.push (/.apply/1 ++)) + (/.push (/.apply/1 --)) /.if))) (_.cover [/.loop] (n.= (n.+ distance start) (||> (/.push start) - (/.push (|>> |inc| /.dup |test|)) + (/.push (|>> |++| /.dup |test|)) /.loop))) (_.cover [/.while] (n.= (n.+ distance start) (||> (/.push start) (/.push (|>> /.dup |test|)) - (/.push |inc|) + (/.push |++|) /.while))) (_.cover [/.do] - (n.= (inc sample) + (n.= (++ sample) (||> (/.push sample) (/.push (|>> (/.push false))) - (/.push |inc|) + (/.push |++|) /.do /.while))) (_.cover [/.compose] - (n.= (inc (inc sample)) + (n.= (++ (++ sample)) (||> (/.push sample) - (/.push |inc|) - (/.push |inc|) + (/.push |++|) + (/.push |++|) /.compose /.call))) (_.cover [/.partial] @@ -275,19 +275,19 @@ /.call))) (_.cover [/.when] (n.= (if choice - (inc sample) + (++ sample) sample) (||> (/.push sample) (/.push choice) - (/.push (/.apply/1 inc)) + (/.push (/.apply/1 ++)) /.when))) (_.cover [/.?] (n.= (if choice - (inc sample) - (dec sample)) + (++ sample) + (-- sample)) (||> (/.push choice) - (/.push (inc sample)) - (/.push (dec sample)) + (/.push (++ sample)) + (/.push (-- sample)) /.?))) ))) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 627b294ad..93c68faff 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -55,8 +55,8 @@ (function (_ transform) (function (_ state actor) (|> state transform #try.Success async\in)))) - inc! (: (/.Mail Nat) (as_mail inc)) - dec! (: (/.Mail Nat) (as_mail dec))]] + ++! (: (/.Mail Nat) (as_mail ++)) + --! (: (/.Mail Nat) (as_mail --))]] (<| (_.covering /._) (_.for [/.Actor]) ($_ _.and @@ -116,7 +116,7 @@ (in (do async.monad [sent? (async.future (do io.monad [actor (/.spawn! /.default 0) - sent? (/.mail! inc! actor)] + sent? (/.mail! ++! actor)] (in (..mailed? sent?))))] (_.cover' [/.Behavior /.Mail /.default /.spawn! /.mail!] @@ -126,7 +126,7 @@ [result (async.future (do io.monad [counter (/.spawn! /.default 0) _ (/.poison! counter)] - (/.mail! inc! counter)))] + (/.mail! ++! counter)))] (_.cover' [/.dead] (case result (#try.Success outcome) @@ -180,18 +180,18 @@ [anonymous (/.actor {Nat initial_state} ((on_mail message state self) - (message (inc state) self))) - sent/inc? (/.mail! inc! anonymous) - sent/dec? (/.mail! dec! anonymous) + (message (++ state) self))) + sent/++? (/.mail! ++! anonymous) + sent/--? (/.mail! --! anonymous) poisoned? (/.poison! anonymous) obituary (/.obituary' anonymous)] - (in (and (..mailed? sent/inc?) - (..mailed? sent/dec?) + (in (and (..mailed? sent/++?) + (..mailed? sent/--?) (..mailed? poisoned?) (case obituary (^ (#.Some [error final_state (list poison_pill)])) (and (exception.match? /.poisoned error) - (n.= (inc (inc initial_state)) + (n.= (++ (++ initial_state)) final_state)) _ @@ -200,7 +200,7 @@ verdict))) (do ! - [num_events (\ ! map (|>> (n.% 10) inc) random.nat) + [num_events (\ ! map (|>> (n.% 10) ++) random.nat) events (random.list num_events random.nat) num_observations (\ ! map (n.% num_events) random.nat) .let [expected (list.first num_observations events) @@ -215,8 +215,8 @@ (async.future (if (n.< num_observations events_seen) (do ! - [_ (atom.update! (row.add event) sink)] - (in (#try.Success (inc events_seen)))) + [_ (atom.update! (row.suffix event) sink)] + (in (#try.Success (++ events_seen)))) (do ! [_ stop] (in (#try.Failure "YOLO"))))))) diff --git a/stdlib/source/test/lux/control/concurrency/async.lux b/stdlib/source/test/lux/control/concurrency/async.lux index a92a5c44c..f9b917ee5 100644 --- a/stdlib/source/test/lux/control/concurrency/async.lux +++ b/stdlib/source/test/lux/control/concurrency/async.lux @@ -107,16 +107,16 @@ (n.+ leftA rightA))))) (in (do /.monad [pre (/.future instant.now) - actual (/.delayed waiting_time expected) + actual (/.after waiting_time expected) post (/.future instant.now)] - (_.cover' [/.delayed] + (_.cover' [/.after] (and (n.= expected actual) (i.>= (.int waiting_time) (duration.millis (instant.span pre post))))))) (in (do /.monad [?left (/.or (in leftE) - (/.delayed waiting_time dummy)) - ?right (/.or (/.delayed waiting_time dummy) + (/.after waiting_time dummy)) + ?right (/.or (/.after waiting_time dummy) (in rightE))] (_.cover' [/.or] (case [?left ?right] @@ -128,8 +128,8 @@ false)))) (in (do /.monad [leftA (/.either (in leftE) - (/.delayed waiting_time dummy)) - rightA (/.either (/.delayed waiting_time dummy) + (/.after waiting_time dummy)) + rightA (/.either (/.after waiting_time dummy) (in rightE))] (_.cover' [/.either] (n.= (n.+ leftE rightE) @@ -155,9 +155,9 @@ (and yep (not nope))))) (in (do /.monad - [?none (/.time_out 0 (/.delayed waiting_time dummy)) - ?actual (/.time_out waiting_time (in expected))] - (_.cover' [/.time_out] + [?none (/.within 0 (/.after waiting_time dummy)) + ?actual (/.within waiting_time (in expected))] + (_.cover' [/.within] (case [?none ?actual] [#.None (#.Some actual)] (n.= expected actual) diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index 45dadc8cb..5876331b6 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -60,7 +60,7 @@ (#.Some [head tail]) (\ ! map (|>> (#.Item head)) - (take_amount (dec amount_of_polls) [channel sink])))))) + (take_amount (-- amount_of_polls) [channel sink])))))) (def: .public test Test @@ -145,9 +145,9 @@ _ (async.future (/.subscribe! (function (_ value) (do {! io.monad} [current (atom.read! sink) - _ (atom.update! (row.add value) sink)] + _ (atom.update! (row.suffix value) sink)] (if (n.< (list.size inputs) - (inc (row.size current))) + (++ (row.size current))) (in (#.Some [])) (do ! [_ (!signal [])] @@ -161,22 +161,22 @@ (_.cover' [/.Subscriber /.subscribe!] (list\= inputs listened)))) (in (do async.monad - [actual (/.fold (function (_ input total) - (async.resolved (n.+ input total))) - 0 - (/.sequential 0 inputs))] - (_.cover' [/.fold] + [actual (/.aggregate (function (_ input total) + (async.resolved (n.+ input total))) + 0 + (/.sequential 0 inputs))] + (_.cover' [/.aggregate] (n.= (list\fold n.+ 0 inputs) actual)))) (in (do async.monad [actual (|> inputs (/.sequential 0) - (/.folds (function (_ input total) - (async.resolved (n.+ input total))) - 0) + (/.aggregates (function (_ input total) + (async.resolved (n.+ input total))) + 0) /.list)] - (_.cover' [/.folds] - (list\= (list.folds n.+ 0 inputs) + (_.cover' [/.aggregates] + (list\= (list.aggregates n.+ 0 inputs) actual)))) (in (do async.monad [actual (|> (list distint/0 distint/0 distint/0 @@ -189,8 +189,8 @@ (list\= (list distint/0 distint/1 distint/2) actual)))) (do ! - [polling_delay (\ ! map (|>> (n.% 10) inc) random.nat) - amount_of_polls (\ ! map (|>> (n.% 10) inc) random.nat)] + [polling_delay (\ ! map (|>> (n.% 10) ++) random.nat) + amount_of_polls (\ ! map (|>> (n.% 10) ++) random.nat)] ($_ _.and (in (do {! async.monad} [actual (..take_amount amount_of_polls (/.poll polling_delay (: (IO Nat) (io.io sample)))) @@ -212,12 +212,12 @@ (/.iterations (function (_ [iterations current]) (async.resolved (if (n.< max_iterations iterations) - (#.Some [[(inc iterations) (n.+ shift current)] + (#.Some [[(++ iterations) (n.+ shift current)] current]) #.None)))) /.list)] (_.cover' [/.iterations] (and (n.= max_iterations (list.size actual)) - (list\= (list.folds n.+ sample (list.repeated (dec max_iterations) shift)) + (list\= (list.aggregates n.+ sample (list.repeated (-- max_iterations) shift)) actual))))) ))))) diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index a57e3bcd6..b4b07bbb0 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -42,7 +42,7 @@ [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do async.monad - [result (async.time_out ..delay (/.wait! semaphore))] + [result (async.within ..delay (/.wait! semaphore))] (_.cover' [/.semaphore] (case result (#.Some _) @@ -55,7 +55,7 @@ .let [semaphore (/.semaphore initial_open_positions)]] (in (do {! async.monad} [_ (monad.map ! /.wait! (list.repeated initial_open_positions semaphore)) - result (async.time_out ..delay (/.wait! semaphore))] + result (async.within ..delay (/.wait! semaphore))] (_.cover' [/.wait!] (case result (#.Some _) @@ -69,9 +69,9 @@ (in (do {! async.monad} [_ (monad.map ! /.wait! (list.repeated initial_open_positions semaphore)) .let [block (/.wait! semaphore)] - result/0 (async.time_out ..delay block) + result/0 (async.within ..delay block) open_positions (/.signal! semaphore) - result/1 (async.time_out ..delay block)] + result/1 (async.within ..delay block)] (_.cover' [/.signal!] (case [result/0 result/1 open_positions] [#.None (#.Some _) (#try.Success +0)] @@ -100,14 +100,14 @@ (do {! random.monad} [repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) .let [resource (atom.atom "") - expected_As (text.joined (list.repeated repetitions "A")) - expected_Bs (text.joined (list.repeated repetitions "B")) + expected_As (text.together (list.repeated repetitions "A")) + expected_Bs (text.together (list.repeated repetitions "B")) mutex (/.mutex []) processA (<| (/.synchronize! mutex) io.io async.future (do {! io.monad} - [_ (<| (monad.seq !) + [_ (<| (monad.all !) (list.repeated repetitions) (atom.update! (|>> (format "A")) resource))] (in []))) @@ -115,7 +115,7 @@ io.io async.future (do {! io.monad} - [_ (<| (monad.seq !) + [_ (<| (monad.all !) (list.repeated repetitions) (atom.update! (|>> (format "B")) resource))] (in [])))]] @@ -155,21 +155,21 @@ _ false))) (do {! random.monad} - [limit (\ ! map (|>> (n.% 9) inc) random.nat) + [limit (\ ! map (|>> (n.% 9) ++) random.nat) .let [barrier (/.barrier (maybe.trusted (/.limit limit))) resource (atom.atom "")]] (in (do {! async.monad} [.let [suffix "_" expected_ending (|> suffix (list.repeated limit) - text.joined) - expected_ids (enum.range n.enum 0 (dec limit))] + text.together) + expected_ids (enum.range n.enum 0 (-- limit))] _ (|> expected_ids (list\map (function (_ id) (exec (io.run! (atom.update! (|>> (format suffix)) resource)) (waiter resource barrier id)))) - (monad.seq !)) + (monad.all !)) .let [outcome (io.run! (atom.read! resource))]] (_.cover' [/.barrier /.block!] (and (text.ends_with? expected_ending outcome) diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux index dbe98177f..f3a5c618c 100644 --- a/stdlib/source/test/lux/control/concurrency/stm.lux +++ b/stdlib/source/test/lux/control/concurrency/stm.lux @@ -94,8 +94,8 @@ (in (let [var (/.var 0)] (do {! async.monad} [_ (|> (list.repeated iterations_per_process []) - (list\map (function (_ _) (/.commit! (/.update inc var)))) - (monad.seq !)) + (list\map (function (_ _) (/.commit! (/.update ++ var)))) + (monad.all !)) cummulative (/.commit! (/.read var))] (_.cover' [/.STM] (n.= iterations_per_process diff --git a/stdlib/source/test/lux/control/continuation.lux b/stdlib/source/test/lux/control/continuation.lux index 4844e521f..cac3794a0 100644 --- a/stdlib/source/test/lux/control/continuation.lux +++ b/stdlib/source/test/lux/control/continuation.lux @@ -63,7 +63,7 @@ (/.result (do /.monad [[restart [output idx]] (/.portal [sample 0])] (if (n.< 10 idx) - (restart [(n.+ 10 output) (inc idx)]) + (restart [(n.+ 10 output) (++ idx)]) (in output)))))) (_.cover [/.shift /.reset] (let [(^open "_\.") /.monad diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux index 369a018e0..4450991ec 100644 --- a/stdlib/source/test/lux/control/function.lux +++ b/stdlib/source/test/lux/control/function.lux @@ -56,9 +56,9 @@ outcome) (not (n.= (n.- expected extra) outcome))))) - (_.cover [/.apply] + (_.cover [/.on] (n.= (f0 extra) - (/.apply extra f0))) + (/.on extra f0))) /contract.test /memo.test diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index a91f2a69a..914247204 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -85,7 +85,7 @@ open (/.open fibonacci)] [none_time none_output] (..time none input) [open_time [memory open_output]] (..time open [memory input]) - [open_time/+1 _] (..time open [memory (inc input)]) + [open_time/+1 _] (..time open [memory (++ input)]) .let [same_output! (n.= none_output open_output) @@ -108,10 +108,10 @@ (case input (^or 0 1) (\ state.monad in 1) _ (do state.monad - [output' (recur (dec input))] + [output' (recur (-- input))] (in (n.* input output'))))))) expected (|> (list.indices input) - (list\map inc) + (list\map ++) (list\fold n.* 1)) actual (|> (memo input) (state.result (dictionary.empty n.hash)) diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index 19e67b7aa..b41da5623 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -39,7 +39,7 @@ (in (function (_ delegate recur input) output)))) expected (|> (list.indices input) - (list\map inc) + (list\map ++) (list\fold n.* 1))]]) ($_ _.and (_.for [/.Mixin] @@ -52,7 +52,7 @@ (function (_ delegate recur input) (case input (^or 0 1) 1 - _ (n.* input (recur (dec input))))))] + _ (n.* input (recur (-- input))))))] (n.= expected (factorial input)))) (_.cover [/.with] @@ -63,7 +63,7 @@ _ (delegate input)))) multiplication (: (/.Mixin Nat Nat) (function (_ delegate recur input) - (n.* input (recur (dec input))))) + (n.* input (recur (-- input))))) factorial (/.mixin (/.with bottom multiplication))] (n.= expected (factorial input)))) @@ -72,7 +72,7 @@ (function (_ delegate recur input) (case input (^or 0 1) 1 - _ (n.* input (delegate (dec input)))))) + _ (n.* input (delegate (-- input)))))) left (/.mixin (/.with /.nothing loop)) right (/.mixin (/.with loop /.nothing))] (and (n.= expected @@ -90,7 +90,7 @@ _ false))) multiplication (: (/.Mixin Nat Nat) (function (_ delegate recur input) - (n.* input (recur (dec input))))) + (n.* input (recur (-- input))))) factorial (/.mixin (/.with (/.advice bottom? bottom) multiplication))] (n.= expected @@ -129,7 +129,7 @@ (function (_ recur input) (case input (^or 0 1) 1 - _ (n.* input (recur (dec input)))))))] + _ (n.* input (recur (-- input)))))))] (n.= expected (factorial input))))) ))) diff --git a/stdlib/source/test/lux/control/function/mutual.lux b/stdlib/source/test/lux/control/function/mutual.lux index 5aeb9be71..4fe2e4219 100644 --- a/stdlib/source/test/lux/control/function/mutual.lux +++ b/stdlib/source/test/lux/control/function/mutual.lux @@ -25,13 +25,13 @@ (-> Nat Bit) (case number 0 true - _ (odd? (dec number))) + _ (odd? (-- number))) (odd? number) (-> Nat Bit) (case number 0 false - _ (even? (dec number)))] + _ (even? (-- number)))] (and (bit\= expected (even? sample)) (bit\= (not expected) (odd? sample))))))) @@ -40,13 +40,13 @@ (-> Nat Bit) (case number 0 true - _ (odd? (dec number)))] + _ (odd? (-- number)))] [(odd? number) (-> Nat Bit) (case number 0 false - _ (even? (dec number)))]) + _ (even? (-- number)))]) (def: test_def Test diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index f45ba2111..e37a2f355 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -195,7 +195,7 @@ (list.first times expected+) actual))) (|> (list\map code.nat expected+) - (/.result (/.exactly (inc variadic) <code>.nat)) + (/.result (/.exactly (++ variadic) <code>.nat)) fails?))) (_.cover [/.at_least] (and (|> (list\map code.nat expected+) @@ -205,7 +205,7 @@ expected+ actual))) (|> (list\map code.nat expected+) - (/.result (/.at_least (inc variadic) <code>.nat)) + (/.result (/.at_least (++ variadic) <code>.nat)) fails?))) (_.cover [/.at_most] (and (|> (list\map code.nat expected+) @@ -215,7 +215,7 @@ (list.first times expected+) actual))) (|> (list\map code.nat expected+) - (/.result (/.at_most (inc variadic) <code>.nat)) + (/.result (/.at_most (++ variadic) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index 50233ba6e..dcf4d0e80 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -355,7 +355,7 @@ post)))) (!expect (#try.Success #1))))) (do {! random.monad} - [to_read (\ ! map (n.% (inc ..segment_size)) random.nat) + [to_read (\ ! map (n.% (++ ..segment_size)) random.nat) data (\ ! map (\ utf8.codec encode) (random.ascii ..segment_size))] (_.cover [/.Offset /.offset] (|> data @@ -370,7 +370,7 @@ (n.= ..segment_size nothing_left))))) (!expect (#try.Success #1))))) (do {! random.monad} - [to_read (\ ! map (n.% (inc ..segment_size)) random.nat) + [to_read (\ ! map (n.% (++ ..segment_size)) random.nat) data (\ ! map (\ utf8.codec encode) (random.ascii ..segment_size))] (_.cover [/.remaining] (|> data diff --git a/stdlib/source/test/lux/control/parser/cli.lux b/stdlib/source/test/lux/control/parser/cli.lux index fb1f485c0..529986ad4 100644 --- a/stdlib/source/test/lux/control/parser/cli.lux +++ b/stdlib/source/test/lux/control/parser/cli.lux @@ -57,7 +57,7 @@ (_.cover [/.somewhere] (|> (/.result (|> (/.somewhere (/.this expected)) (<>.before (<>.some /.any))) - (list.joined (list pre_ignore (list expected) post_ignore))) + (list.together (list pre_ignore (list expected) post_ignore))) (!expect (#try.Success _)))) (_.cover [/.end] (and (|> (/.result /.end (list)) diff --git a/stdlib/source/test/lux/control/parser/synthesis.lux b/stdlib/source/test/lux/control/parser/synthesis.lux index 068ba1235..e412ff262 100644 --- a/stdlib/source/test/lux/control/parser/synthesis.lux +++ b/stdlib/source/test/lux/control/parser/synthesis.lux @@ -132,12 +132,12 @@ expected_environment ..random_environment expected_body (random.unicode 1)] (_.cover [/.wrong_arity] - (|> (/.result (/.function (inc arity) /.text) + (|> (/.result (/.function (++ arity) /.text) (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) (!expect (^multi (#try.Failure error) (exception.match? /.wrong_arity error)))))) (do {! random.monad} - [arity (\ ! map (|>> (n.% 10) inc) random.nat) + [arity (\ ! map (|>> (n.% 10) ++) random.nat) expected_offset random.nat expected_inits (random.list arity random.bit) expected_body (random.unicode 1)] diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index 7be2416d0..951bed82e 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -77,7 +77,7 @@ .let [limit (n.+ offset range)] expected (\ ! map (|>> (n.% range) (n.+ offset) text.of_char) random.nat) out_of_range (case offset - 0 (\ ! map (|>> (n.% 10) inc (n.+ limit) text.of_char) random.nat) + 0 (\ ! map (|>> (n.% 10) ++ (n.+ limit) text.of_char) random.nat) _ (\ ! map (|>> (n.% offset) text.of_char) random.nat))] (_.cover [/.range] (and (..should_pass expected (/.range offset limit)) @@ -157,7 +157,7 @@ (random.set n.hash num_options) (\ ! map (|>> set.list (list\map text.of_char) - text.joined))) + text.together))) expected (\ ! map (function (_ value) (|> options (text.char (n.% num_options value)) @@ -183,7 +183,7 @@ (random.set n.hash num_options) (\ ! map (|>> set.list (list\map text.of_char) - text.joined))) + text.together))) invalid (\ ! map (function (_ value) (|> options (text.char (n.% num_options value)) diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux index 373d549e9..dc901e3c4 100644 --- a/stdlib/source/test/lux/control/parser/type.lux +++ b/stdlib/source/test/lux/control/parser/type.lux @@ -166,7 +166,7 @@ Test (do {! random.monad} [not_polymorphic ..primitive - expected_inputs (\ ! map (|>> (n.% 10) inc) random.nat)] + expected_inputs (\ ! map (|>> (n.% 10) ++) random.nat)] ($_ _.and (_.cover [/.not_polymorphic] (and (|> (/.result (/.polymorphic /.any) diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index 92efb1121..e92216696 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -164,9 +164,9 @@ (_.cover [/.somewhere] (|> (/.result parser (list (node parent - (list.joined (list (list.repeated repetitions (node wrong (list))) - (list (node right (list))) - (list.repeated repetitions (node wrong (list)))))))) + (list.together (list (list.repeated repetitions (node wrong (list))) + (list (node right (list))) + (list.repeated repetitions (node wrong (list)))))))) (!expect (#try.Success [])))) (_.cover [/.nowhere] (|> (/.result parser diff --git a/stdlib/source/test/lux/control/pipe.lux b/stdlib/source/test/lux/control/pipe.lux index 27e92a7e0..3ef82e309 100644 --- a/stdlib/source/test/lux/control/pipe.lux +++ b/stdlib/source/test/lux/control/pipe.lux @@ -25,11 +25,11 @@ (do ! [another random.nat] (_.cover [/.new>] - (n.= (inc another) + (n.= (++ another) (|> sample (n.* 3) (n.+ 4) - (/.new> another [inc]))))) + (/.new> another [++]))))) (_.cover [/.let>] (n.= (n.+ sample sample) (|> sample @@ -63,12 +63,12 @@ (/.loop> [(n.= (n.* 10 sample)) not] [(n.+ sample)])))) (_.cover [/.do>] - (n.= (inc (n.+ 4 (n.* 3 sample))) + (n.= (++ (n.+ 4 (n.* 3 sample))) (|> sample (/.do> identity.monad [(n.* 3)] [(n.+ 4)] - [inc])))) + [++])))) (_.cover [/.exec>] (n.= (n.* 10 sample) (|> sample @@ -76,11 +76,11 @@ (n.* 10)))) (_.cover [/.tuple>] (let [[left middle right] (|> sample - (/.tuple> [inc] - [dec] + (/.tuple> [++] + [--] [%.nat]))] - (and (n.= (inc sample) left) - (n.= (dec sample) middle) + (and (n.= (++ sample) left) + (n.= (-- sample) middle) (text\= (%.nat sample) right)))) (_.cover [/.case>] (text\= (case (n.% 10 sample) diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index caabbadf6..555f30b4f 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -103,7 +103,7 @@ .let [//@ ! count_clean_up (function (_ value) (do ! - [_ (thread.update! inc clean_up_counter)] + [_ (thread.update! ++ clean_up_counter)] (in (#try.Success []))))] outcome (/.run! ! (do {! (/.monad !)} @@ -121,7 +121,7 @@ .let [//@ ! count_clean_up (function (_ value) (do ! - [_ (thread.update! inc clean_up_counter)] + [_ (thread.update! ++ clean_up_counter)] (in (#try.Success []))))] outcome (/.run! ! (do {! (/.monad !)} @@ -140,7 +140,7 @@ .let [//@ ! count_clean_up (function (_ value) (do ! - [_ (thread.update! inc clean_up_counter)] + [_ (thread.update! ++ clean_up_counter)] (in (#try.Success []))))] outcome (/.run! ! (do {! (/.monad !)} @@ -159,7 +159,7 @@ .let [//@ ! count_clean_up (function (_ value) (do ! - [_ (thread.update! inc clean_up_counter)] + [_ (thread.update! ++ clean_up_counter)] (in (: (Try Any) (exception.except ..oops [])))))] outcome (/.run! ! diff --git a/stdlib/source/test/lux/control/state.lux b/stdlib/source/test/lux/control/state.lux index 864c16bd9..eda78cbeb 100644 --- a/stdlib/source/test/lux/control/state.lux +++ b/stdlib/source/test/lux/control/state.lux @@ -46,8 +46,8 @@ [_ (/.update (n.* value))] /.get))) (_.cover [/.use] - (with_conditions [state (inc state)] - (/.use inc))) + (with_conditions [state (++ state)] + (/.use ++))) (_.cover [/.local] (with_conditions [state (n.* value state)] (/.local (n.* value) @@ -88,12 +88,12 @@ (in (n.< limit state)))]] ($_ _.and (_.cover [/.while /.result] - (|> (/.while condition (/.update inc)) + (|> (/.while condition (/.update ++)) (/.result 0) (let> [state' output'] (n.= limit state')))) (_.cover [/.do_while] - (|> (/.do_while condition (/.update inc)) + (|> (/.do_while condition (/.update ++)) (/.result 0) (let> [state' output'] (or (n.= limit state') diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 372aed7de..331e05142 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -39,7 +39,7 @@ (do random.monad [byte random.nat] (exec (try.trusted (/.write/8! idx byte output)) - (recur (inc idx)))) + (recur (++ idx)))) (\ random.monad in output))))) (def: (throws? exception try) @@ -56,8 +56,8 @@ (let [bytes (i64.left_shifted power 1) binary (/.empty bytes) cap (case bytes - 8 (dec 0) - _ (|> 1 (i64.left_shifted (n.* 8 bytes)) dec)) + 8 (-- 0) + _ (|> 1 (i64.left_shifted (n.* 8 bytes)) --)) capped_value (i64.and cap value)] (and (..succeed (do try.monad @@ -71,9 +71,9 @@ (def: as_list (-> /.Binary (List Nat)) - (/.fold (function (_ head tail) - (#.Item head tail)) - (list))) + (/.aggregate (function (_ head tail) + (#.Item head tail)) + (list))) (def: .public test Test @@ -92,9 +92,9 @@ ($equivalence.spec /.equivalence (..random size))) (_.for [/.monoid] ($monoid.spec /.equivalence /.monoid (..random size))) - (_.cover [/.fold] + (_.cover [/.aggregate] (n.= (\ list.fold fold n.+ 0 (..as_list sample)) - (/.fold n.+ 0 sample))) + (/.aggregate n.+ 0 sample))) (_.cover [/.empty] (\ /.equivalence = @@ -117,7 +117,7 @@ idxs (: (List Nat) (case length 0 (list) - _ (enum.range n.enum 0 (dec length)))) + _ (enum.range n.enum 0 (-- length)))) reader (function (_ binary idx) (/.read/8! idx binary))] (and (n.= length (/.size random_slice)) @@ -143,7 +143,7 @@ (#.Item head tail) (n.= (list.fold n.+ 0 tail) - (/.fold n.+ 0 (/.after 1 sample)))))) + (/.aggregate n.+ 0 (/.after 1 sample)))))) (_.cover [/.copy] (and (case (/.copy size 0 sample 0 (/.empty size)) (#try.Success output) diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index c1e1471f8..4045c008a 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -169,14 +169,14 @@ _ false))) (do ! - [occupancy (\ ! map (n.% (inc size)) random.nat)] + [occupancy (\ ! map (n.% (++ size)) random.nat)] (_.cover [/.occupancy /.vacancy] (let [the_array (loop [output (: (Array Nat) (/.empty size)) idx 0] (if (n.< occupancy idx) (recur (/.write! idx expected output) - (inc idx)) + (++ idx)) output))] (and (n.= occupancy (/.occupancy the_array)) (n.= size (n.+ (/.occupancy the_array) @@ -189,7 +189,7 @@ (|> the_array /.list /.of_list (\ (/.equivalence n.equivalence) = the_array))))) (do ! - [amount (\ ! map (n.% (inc size)) random.nat)] + [amount (\ ! map (n.% (++ size)) random.nat)] (_.cover [/.copy!] (let [copy (: (Array Nat) (/.empty size))] diff --git a/stdlib/source/test/lux/data/collection/bits.lux b/stdlib/source/test/lux/data/collection/bits.lux index 6710ef7c6..c0e54e3bb 100644 --- a/stdlib/source/test/lux/data/collection/bits.lux +++ b/stdlib/source/test/lux/data/collection/bits.lux @@ -17,7 +17,7 @@ (def: (size min max) (-> Nat Nat (Random Nat)) (|> random.nat - (\ random.monad map (|>> (n.% (inc max)) (n.max min))))) + (\ random.monad map (|>> (n.% (++ max)) (n.max min))))) (def: .public random (Random Bits) @@ -47,7 +47,7 @@ (/.empty? /.empty)) (do {! random.monad} - [size (\ ! map (|>> (n.% 1,000) inc) random.nat) + [size (\ ! map (|>> (n.% 1,000) ++) random.nat) idx (\ ! map (n.% size) random.nat) sample ..random] ($_ _.and @@ -73,7 +73,7 @@ /.empty)) (/.intersects? (/.one idx /.empty) (/.one idx /.empty)) - (not (/.intersects? (/.one (inc idx) /.empty) + (not (/.intersects? (/.one (++ idx) /.empty) (/.one idx /.empty))) (not (/.intersects? sample (/.not sample))))) (_.cover [/.not] diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index 080e09001..446c4e354 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -112,7 +112,7 @@ (let [merging_with_oneself (let [(^open ".") (/.equivalence n.equivalence)] (= dict (/.merged dict dict))) overwritting_keys (let [dict' (|> dict /.entries - (list\map (function (_ [k v]) [k (inc v)])) + (list\map (function (_ [k v]) [k (++ v)])) (/.of_list n.hash)) (^open ".") (/.equivalence n.equivalence)] (= dict' (/.merged dict' dict)))] @@ -155,7 +155,7 @@ _ true))) (_.cover [/.has] - (and (n.= (inc (/.size dict)) + (and (n.= (++ (/.size dict)) (/.size (/.has non_key test_val dict))) (case (/.value non_key (/.has non_key test_val dict)) (#.Some v) (n.= test_val v) @@ -193,24 +193,24 @@ true (#.Some known_key) - (n.= (dec (/.size dict)) + (n.= (-- (/.size dict)) (/.size (/.lacks known_key dict)))))) (_.cover [/.revised] (let [base (/.has non_key test_val dict) - updt (/.revised non_key inc base)] + updt (/.revised non_key ++ base)] (case [(/.value non_key base) (/.value non_key updt)] [(#.Some x) (#.Some y)] - (n.= (inc x) y) + (n.= (++ x) y) _ false))) (_.cover [/.revised'] (let [can_upsert_new_key! - (case (/.value non_key (/.revised' non_key test_val inc dict)) + (case (/.value non_key (/.revised' non_key test_val ++ dict)) (#.Some inserted) - (n.= (inc test_val) inserted) + (n.= (++ test_val) inserted) #.None false) @@ -221,9 +221,9 @@ true (#.Some [known_key known_value]) - (case (/.value known_key (/.revised' known_key test_val inc dict)) + (case (/.value known_key (/.revised' known_key test_val ++ dict)) (#.Some updated) - (n.= (inc known_value) updated) + (n.= (++ known_value) updated) #.None false))] diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 838d2cf5d..7f6178f8e 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -32,7 +32,7 @@ _ (do random.monad - [partial (dictionary order gen_key gen_value (dec size)) + [partial (dictionary order gen_key gen_value (-- size)) key (random.only (|>> (/.key? partial) not) gen_key) value gen_value] @@ -111,7 +111,7 @@ (and (not (/.key? sample extra_key)) (let [sample+ (/.has extra_key extra_value sample)] (and (/.key? sample+ extra_key) - (n.= (inc (/.size sample)) + (n.= (++ (/.size sample)) (/.size sample+)))))) (_.cover [/.value] (let [sample+ (/.has extra_key extra_value sample)] diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux index c76892185..2172fbd44 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux @@ -69,7 +69,7 @@ (let [sample+ (/.has extra_key extra_value sample)] (and (not (/.contains? extra_key sample)) (/.contains? extra_key sample+) - (n.= (inc (/.size sample)) + (n.= (++ (/.size sample)) (/.size sample+))))) (_.cover [/.value] (|> sample diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index 8ba430845..f635eca05 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -146,7 +146,7 @@ (/.sorted n.< indices)) expected_numbers! - (/.every? (n.= (dec size)) + (/.every? (n.= (-- size)) (/.zipped_with/2 n.+ indices (/.sorted n.> indices)))] @@ -185,7 +185,7 @@ ..random) .let [size (/.size sample)] idx (\ ! map (n.% size) random.nat) - sub_size (\ ! map (|>> (n.% size) inc) random.nat)] + sub_size (\ ! map (|>> (n.% size) ++) random.nat)] ($_ _.and (_.cover [/.only] (let [positives (/.only n.even? sample) @@ -222,7 +222,7 @@ (let [subs (/.sub sub_size sample)] (and (/.every? (|>> /.size (n.<= sub_size)) subs) (/\= sample - (/.joined subs))))) + (/.together subs))))) )))) (def: member @@ -341,11 +341,11 @@ ((/.zipped_with 2) +/2 sample/0 sample/1)) (/\= (/.zipped_with/3 +/3 sample/0 sample/1 sample/2) ((/.zipped_with 3) +/3 sample/0 sample/1 sample/2)))) - (_.cover [/.joined] + (_.cover [/.together] (and (/\= (/\compose sample/0 sample/1) - (/.joined (list sample/0 sample/1))) + (/.together (list sample/0 sample/1))) (/\= ($_ /\compose sample/0 sample/1 sample/2) - (/.joined (list sample/0 sample/1 sample/2))))) + (/.together (list sample/0 sample/1 sample/2))))) )))) (def: search @@ -410,7 +410,7 @@ (_.cover [/.interposed] (or (/.empty? sample) (let [sample+ (/.interposed separator sample)] - (and (n.= (|> (/.size sample) (n.* 2) dec) + (and (n.= (|> (/.size sample) (n.* 2) --) (/.size sample+)) (|> sample+ /.pairs (/.every? (|>> product.right (n.= separator)))))))) (_.cover [/.iterations] @@ -419,14 +419,14 @@ (/\= (/.indices size) (/.iterations (function (_ index) (if (n.< size index) - (#.Some (inc index)) + (#.Some (++ index)) #.None)) 0))))) - (_.cover [/.folds] + (_.cover [/.aggregates] (/\= (/\map (function (_ index) (\ /.fold fold n.+ 0 (/.first index sample))) - (/.indices (inc (/.size sample)))) - (/.folds n.+ 0 sample))) + (/.indices (++ (/.size sample)))) + (/.aggregates n.+ 0 sample))) (do random.monad [expected random.nat .let [(^open "/\.") (/.equivalence n.equivalence)]] diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index 5fcec5102..cdb7198b5 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -81,7 +81,7 @@ (let [pushed (/.end non_member sample) size_increases! - (n.= (inc (/.size sample)) (/.size pushed)) + (n.= (++ (/.size sample)) (/.size pushed)) new_member_is_identified! (/.member? n.equivalence pushed non_member) @@ -99,7 +99,7 @@ (let [popped (/.next sample) size_decreases! - (n.= (dec (/.size sample)) + (n.= (-- (/.size sample)) (/.size popped)) popped_member_is_not_identified! diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux index 4faaaf488..9be7c183f 100644 --- a/stdlib/source/test/lux/data/collection/queue/priority.lux +++ b/stdlib/source/test/lux/data/collection/queue/priority.lux @@ -64,14 +64,14 @@ (_.cover [/.end] (let [sample+ (/.end non_member_priority non_member sample)] (and (not (/.member? n.equivalence sample non_member)) - (n.= (inc (/.size sample)) + (n.= (++ (/.size sample)) (/.size sample+)) (/.member? n.equivalence sample+ non_member)))) (_.cover [/.next] (let [sample- (/.next sample)] (or (and (/.empty? sample) (/.empty? sample-)) - (n.= (dec (/.size sample)) + (n.= (-- (/.size sample)) (/.size sample-))))) (_.for [/.Priority] ($_ _.and diff --git a/stdlib/source/test/lux/data/collection/row.lux b/stdlib/source/test/lux/data/collection/row.lux index 2515f284f..8e8348617 100644 --- a/stdlib/source/test/lux/data/collection/row.lux +++ b/stdlib/source/test/lux/data/collection/row.lux @@ -81,7 +81,7 @@ (def: index_based Test (do {! random.monad} - [size (\ ! map (|>> (n.% 100) inc) random.nat)] + [size (\ ! map (|>> (n.% 100) ++) random.nat)] ($_ _.and (do ! [good_index (|> random.nat (\ ! map (n.% size))) @@ -108,9 +108,9 @@ (<| (try.else false) (do try.monad [sample (/.has good_index non_member sample) - sample (/.revised good_index inc sample) + sample (/.revised good_index ++ sample) actual (/.item good_index sample)] - (in (n.= (inc non_member) actual))))) + (in (n.= (++ non_member) actual))))) (_.cover [/.within_bounds?] (and (/.within_bounds? sample good_index) (not (/.within_bounds? sample bad_index)))) @@ -125,7 +125,7 @@ (exception.match? /.index_out_of_bounds error))))] (and (fails! (/.item bad_index sample)) (fails! (/.has bad_index non_member sample)) - (fails! (/.revised bad_index inc sample))))) + (fails! (/.revised bad_index ++ sample))))) )) ))) @@ -134,7 +134,7 @@ (<| (_.covering /._) (_.for [/.Row]) (do {! random.monad} - [size (\ ! map (|>> (n.% 100) inc) random.nat)] + [size (\ ! map (|>> (n.% 100) ++) random.nat)] ($_ _.and ..signatures ..whole @@ -158,28 +158,28 @@ (and (list.every? (/.member? n.equivalence sample) (/.list sample)) (not (/.member? n.equivalence sample non_member)))) - (_.cover [/.add] - (let [added (/.add non_member sample) + (_.cover [/.suffix] + (let [added (/.suffix non_member sample) size_increases! - (n.= (inc (/.size sample)) + (n.= (++ (/.size sample)) (/.size added)) is_a_member! (/.member? n.equivalence added non_member)] (and size_increases! is_a_member!))) - (_.cover [/.pop] + (_.cover [/.prefix] (if (/.empty? sample) - (/.empty? (/.pop sample)) + (/.empty? (/.prefix sample)) (let [expected_size! - (n.= (dec (/.size sample)) - (/.size (/.pop sample))) + (n.= (-- (/.size sample)) + (/.size (/.prefix sample))) symmetry! (|> sample - (/.add non_member) - /.pop + (/.suffix non_member) + /.prefix (/\= sample))] (and expected_size! symmetry!)))) diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index ebac1772b..fc67cf27d 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -46,7 +46,7 @@ (do {! random.monad} [repeated random.nat index (\ ! map (n.% 100) random.nat) - size (\ ! map (|>> (n.% 10) inc) random.nat) + size (\ ! map (|>> (n.% 10) ++) random.nat) offset (\ ! map (n.% 100) random.nat) cycle_start random.nat cycle_next (random.list size random.nat)] @@ -58,65 +58,65 @@ (_.cover [/.item] (n.= (n.+ offset index) - (/.item index (..iterations inc offset)))) + (/.item index (..iterations ++ offset)))) (_.cover [/.repeated] (n.= repeated (/.item index (/.repeated repeated)))) (_.cover [/.first] - (list\= (enum.range n.enum offset (dec (n.+ size offset))) - (/.first size (..iterations inc offset)))) + (list\= (enum.range n.enum offset (-- (n.+ size offset))) + (/.first size (..iterations ++ offset)))) (_.cover [/.after] - (list\= (enum.range n.enum offset (dec (n.+ size offset))) - (/.first size (/.after offset (..iterations inc 0))))) + (list\= (enum.range n.enum offset (-- (n.+ size offset))) + (/.first size (/.after offset (..iterations ++ 0))))) (_.cover [/.split_at] - (let [[drops takes] (/.split_at size (..iterations inc 0))] - (and (list\= (enum.range n.enum 0 (dec size)) + (let [[drops takes] (/.split_at size (..iterations ++ 0))] + (and (list\= (enum.range n.enum 0 (-- size)) drops) - (list\= (enum.range n.enum size (dec (n.* 2 size))) + (list\= (enum.range n.enum size (-- (n.* 2 size))) (/.first size takes))))) (_.cover [/.while] - (list\= (enum.range n.enum 0 (dec size)) - (/.while (n.< size) (..iterations inc 0)))) + (list\= (enum.range n.enum 0 (-- size)) + (/.while (n.< size) (..iterations ++ 0)))) (_.cover [/.until] - (list\= (enum.range n.enum offset (dec (n.+ size offset))) + (list\= (enum.range n.enum offset (-- (n.+ size offset))) (/.while (n.< (n.+ size offset)) - (/.until (n.< offset) (..iterations inc 0))))) + (/.until (n.< offset) (..iterations ++ 0))))) (_.cover [/.split_when] - (let [[drops takes] (/.split_when (n.= size) (..iterations inc 0))] - (and (list\= (enum.range n.enum 0 (dec size)) + (let [[drops takes] (/.split_when (n.= size) (..iterations ++ 0))] + (and (list\= (enum.range n.enum 0 (-- size)) drops) - (list\= (enum.range n.enum size (dec (n.* 2 size))) + (list\= (enum.range n.enum size (-- (n.* 2 size))) (/.while (n.< (n.* 2 size)) takes))))) (_.cover [/.head] (n.= offset - (/.head (..iterations inc offset)))) + (/.head (..iterations ++ offset)))) (_.cover [/.tail] - (list\= (enum.range n.enum (inc offset) (n.+ size offset)) - (/.first size (/.tail (..iterations inc offset))))) + (list\= (enum.range n.enum (++ offset) (n.+ size offset)) + (/.first size (/.tail (..iterations ++ offset))))) (_.cover [/.only] - (list\= (list\map (n.* 2) (enum.range n.enum 0 (dec size))) - (/.first size (/.only n.even? (..iterations inc 0))))) + (list\= (list\map (n.* 2) (enum.range n.enum 0 (-- size))) + (/.first size (/.only n.even? (..iterations ++ 0))))) (_.cover [/.partition] - (let [[evens odds] (/.partition n.even? (..iterations inc 0))] + (let [[evens odds] (/.partition n.even? (..iterations ++ 0))] (and (n.= (n.* 2 offset) (/.item offset evens)) - (n.= (inc (n.* 2 offset)) + (n.= (++ (n.* 2 offset)) (/.item offset odds))))) (_.cover [/.iterations] (let [(^open "/\.") /.functor (^open "list\.") (list.equivalence text.equivalence)] (list\= (/.first size - (/\map %.nat (..iterations inc offset))) + (/\map %.nat (..iterations ++ offset))) (/.first size - (/.iterations (function (_ n) [(inc n) (%.nat n)]) + (/.iterations (function (_ n) [(++ n) (%.nat n)]) offset))))) (_.cover [/.cycle] (let [cycle (list& cycle_start cycle_next)] - (list\= (list.joined (list.repeated size cycle)) + (list\= (list.together (list.repeated size cycle)) (/.first (n.* size (list.size cycle)) (/.cycle [cycle_start cycle_next]))))) (_.cover [/.^sequence&] - (let [(/.^sequence& first second third next) (..iterations inc offset)] + (let [(/.^sequence& first second third next) (..iterations ++ offset)] (and (n.= offset first) (n.= (n.+ 1 offset) second) (n.= (n.+ 2 offset) third)))) diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index e6dbd5c3d..66ecd0ca3 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -80,7 +80,7 @@ (/.member? (/.has non_memberL setL) non_memberL) size_increase! - (n.= (inc (/.size setL)) + (n.= (++ (/.size setL)) (/.size (/.has non_memberL setL)))] (and before_addition! after_addition!))) diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux index 09c7c2cd5..4ca359ddb 100644 --- a/stdlib/source/test/lux/data/collection/set/multi.lux +++ b/stdlib/source/test/lux/data/collection/set/multi.lux @@ -23,7 +23,7 @@ (def: count (Random Nat) - (\ random.monad map (|>> (n.% 10) inc) random.nat)) + (\ random.monad map (|>> (n.% 10) ++) random.nat)) (def: .public (random size hash count element) (All [a] (-> Nat (Hash a) (Random Nat) (Random a) (Random (/.Set a)))) diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index 725c4b3c0..b753ac1af 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -31,7 +31,7 @@ _ (do random.monad - [partial (random (dec size) &order gen_value) + [partial (random (-- size) &order gen_value) value (random.only (|>> (/.member? partial) not) gen_value)] (in (/.has value partial))))) @@ -95,7 +95,7 @@ (let [setL+ (/.has non_memberL setL)] (and (not (/.member? setL non_memberL)) (/.member? setL+ non_memberL) - (n.= (inc (/.size setL)) + (n.= (++ (/.size setL)) (/.size setL+))))) (_.cover [/.lacks] (|> setL diff --git a/stdlib/source/test/lux/data/collection/tree/zipper.lux b/stdlib/source/test/lux/data/collection/tree/zipper.lux index a4e73fb03..2b20582e9 100644 --- a/stdlib/source/test/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/test/lux/data/collection/tree/zipper.lux @@ -188,9 +188,9 @@ (n.= expected))) (_.cover [/.update] (|> (/.zipper (tree.leaf expected)) - (/.update inc) + (/.update ++) /.value - (n.= (inc expected)))) + (n.= (++ expected)))) ..move (_.cover [/.end?] (or (/.end? (/.zipper sample)) diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index a4fc0911e..67158dc10 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -135,7 +135,7 @@ random.safe_frac) .let [eS +0.5] variations (\ ! map (|>> (n.% 3) (n.+ 2)) random.nat) - .let [max_spread (f./ (|> variations inc .int int.frac) + .let [max_spread (f./ (|> variations ++ .int int.frac) +1.0) min_spread (f./ +2.0 max_spread) spread_space (f.- min_spread max_spread)] @@ -206,8 +206,8 @@ (_.for [/.Alpha /.Pigment] ($_ _.and (_.cover [/.transparent /.opaque] - (and (r.= /.opaque (dec /.transparent)) - (r.= /.transparent (inc /.opaque)))) + (and (r.= /.opaque (-- /.transparent)) + (r.= /.transparent (++ /.opaque)))) (_.cover [/.translucent] (r.= /.transparent (r.+ /.translucent /.translucent))) )) diff --git a/stdlib/source/test/lux/data/color/named.lux b/stdlib/source/test/lux/data/color/named.lux index aaf1fcab8..4e400e99c 100644 --- a/stdlib/source/test/lux/data/color/named.lux +++ b/stdlib/source/test/lux/data/color/named.lux @@ -201,13 +201,13 @@ /.yellow_green]] )] (def: all_colors - (list.joined (`` (list (~~ (template [<definition> <by_letter>] - [((: (-> Any (List //.Color)) - (function (_ _) - (`` (list (~~ (template.spliced <by_letter>)))))) - 123)] - - <colors>)))))) + (list.together (`` (list (~~ (template [<definition> <by_letter>] + [((: (-> Any (List //.Color)) + (function (_ _) + (`` (list (~~ (template.spliced <by_letter>)))))) + 123)] + + <colors>)))))) (def: unique_colors (set.of_list //.hash ..all_colors)) diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index fe0083c95..9bed1f5ed 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -41,7 +41,7 @@ (_.for [/.Path] (do {! random.monad} [expected (random.ascii/lower /.path_size) - invalid (random.ascii/lower (inc /.path_size)) + invalid (random.ascii/lower (++ /.path_size)) not_ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) /.path_size)] (`` ($_ _.and @@ -76,7 +76,7 @@ (_.for [/.Name] (do {! random.monad} [expected (random.ascii/lower /.name_size) - invalid (random.ascii/lower (inc /.name_size)) + invalid (random.ascii/lower (++ /.name_size)) not_ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) /.name_size)] (`` ($_ _.and @@ -157,14 +157,14 @@ (def: entry Test (do {! random.monad} - [expected_path (random.ascii/lower (dec /.path_size)) + [expected_path (random.ascii/lower (-- /.path_size)) expected_moment (\ ! map (|>> (n.% 1,0,00,00,00,00,000) .int instant.of_millis) random.nat) chunk (random.ascii/lower chunk_size) chunks (\ ! map (n.% 100) random.nat) .let [content (|> chunk (list.repeated chunks) - text.joined + text.together (\ utf8.codec encode))]] (`` ($_ _.and (~~ (template [<type> <tag>] @@ -317,7 +317,7 @@ (do {! random.monad} [path (random.ascii/lower /.path_size) expected (random.ascii/lower /.name_size) - invalid (random.ascii/lower (inc /.name_size)) + invalid (random.ascii/lower (++ /.name_size)) not_ascii (random.text (random.char (unicode.set [unicode/block.katakana (list)])) /.name_size)] (_.for [/.Ownership /.Owner /.ID] @@ -354,9 +354,9 @@ (in (case (row.list tar) (^ (list (#/.Normal [_ _ _ actual_ownership _]))) (and (text\= (/.from_name expected) - (/.from_name (get@ [#/.user #/.name] actual_ownership))) + (/.from_name (value@ [#/.user #/.name] actual_ownership))) (text\= (/.from_name /.anonymous) - (/.from_name (get@ [#/.group #/.name] actual_ownership)))) + (/.from_name (value@ [#/.group #/.name] actual_ownership)))) _ false))) @@ -378,13 +378,13 @@ (in (case (row.list tar) (^ (list (#/.Normal [_ _ _ actual_ownership _]))) (and (text\= (/.from_name /.anonymous) - (/.from_name (get@ [#/.user #/.name] actual_ownership))) + (/.from_name (value@ [#/.user #/.name] actual_ownership))) (n.= (/.from_small /.no_id) - (/.from_small (get@ [#/.user #/.id] actual_ownership))) + (/.from_small (value@ [#/.user #/.id] actual_ownership))) (text\= (/.from_name /.anonymous) - (/.from_name (get@ [#/.group #/.name] actual_ownership))) + (/.from_name (value@ [#/.group #/.name] actual_ownership))) (n.= (/.from_small /.no_id) - (/.from_small (get@ [#/.group #/.id] actual_ownership)))) + (/.from_small (value@ [#/.group #/.id] actual_ownership)))) _ false))) diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux index 9d9b9e248..b779678af 100644 --- a/stdlib/source/test/lux/data/product.lux +++ b/stdlib/source/test/lux/data/product.lux @@ -40,8 +40,8 @@ (n.= expected (/.left [expected dummy]))) (<| (_.cover [/.right]) (n.= expected (/.right [dummy expected]))) - (<| (_.cover [/.fork]) - (let [[left right] ((/.fork (n.+ shift) (n.- shift)) expected)] + (<| (_.cover [/.forked]) + (let [[left right] ((/.forked (n.+ shift) (n.- shift)) expected)] (and (n.= (n.+ shift expected) left) (n.= (n.- shift expected) @@ -62,8 +62,8 @@ (<| (_.cover [/.curried]) (n.= (n.+ left right) ((/.curried (/.uncurried n.+)) left right))) - (<| (_.cover [/.apply]) - (let [[left' right'] (/.apply (n.+ shift) (n.- shift) [left right])] + (<| (_.cover [/.then]) + (let [[left' right'] (/.then (n.+ shift) (n.- shift) [left right])] (and (n.= (n.+ shift left) left') (n.= (n.- shift right) right')))))) )))) diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux index ddb924273..61b9c43a1 100644 --- a/stdlib/source/test/lux/data/sum.lux +++ b/stdlib/source/test/lux/data/sum.lux @@ -60,14 +60,14 @@ (: (Or Nat Nat)) (/.either (n.+ shift) (n.- shift)) (n.= (n.- shift expected))))) - (_.cover [/.apply] + (_.cover [/.then] (and (|> (/.left expected) (: (Or Nat Nat)) - (/.apply (n.+ shift) (n.- shift)) + (/.then (n.+ shift) (n.- shift)) (case> (0 #0 actual) (n.= (n.+ shift expected) actual) _ false)) (|> (/.right expected) (: (Or Nat Nat)) - (/.apply (n.+ shift) (n.- shift)) + (/.then (n.+ shift) (n.- shift)) (case> (0 #1 actual) (n.= (n.- shift expected) actual) _ false)))) (do ! [size (\ ! map (n.% 5) random.nat) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index aa012a5ae..51849d1af 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -57,7 +57,7 @@ left (random.unicode 1) right (random.unicode 1) .let [full (\ /.monoid compose inner outer) - fake_index (dec 0)]] + fake_index (-- 0)]] (`` ($_ _.and (~~ (template [<affix> <predicate>] [(_.cover [<affix> <predicate>] @@ -83,7 +83,7 @@ [inner (random.unicode 1) outer (random.only (|>> (\ /.equivalence = inner) not) (random.unicode 1)) - .let [fake_index (dec 0)]] + .let [fake_index (-- 0)]] ($_ _.and (_.cover [/.contains?] (let [full (\ /.monoid compose inner outer)] @@ -146,9 +146,9 @@ (\ /.equivalence = /.new_line /.line_feed)) ))) (do {! random.monad} - [size (\ ! map (|>> (n.% 10) inc) random.nat) + [size (\ ! map (|>> (n.% 10) ++) random.nat) characters (random.set /.hash size (random.ascii/alpha 1)) - .let [sample (|> characters set.list /.joined)] + .let [sample (|> characters set.list /.together)] expected (\ ! map (n.% size) random.nat)] (_.cover [/.char] (case (/.char expected sample) @@ -182,7 +182,7 @@ characters (random.set /.hash size (random.ascii/alpha 1)) separator (random.only (|>> (set.member? characters) not) (random.ascii/alpha 1)) - .let [with_no_separator (|> characters set.list /.joined)] + .let [with_no_separator (|> characters set.list /.together)] static (random.ascii/alpha 1) .let [dynamic (random.only (|>> (\ /.equivalence = static) not) (random.ascii/alpha 1))] @@ -192,9 +192,9 @@ lower (random.ascii/lower 1) upper (random.ascii/upper 1)] ($_ _.and - (_.cover [/.joined] + (_.cover [/.together] (n.= (set.size characters) - (/.size (/.joined (set.list characters))))) + (/.size (/.together (set.list characters))))) (_.cover [/.interposed /.all_split_by] (and (|> (set.list characters) (/.interposed separator) @@ -202,7 +202,7 @@ (set.of_list /.hash) (\ set.equivalence = characters)) (\ /.equivalence = - (/.joined (set.list characters)) + (/.together (set.list characters)) (/.interposed "" (set.list characters))))) (_.cover [/.replaced/1] (\ /.equivalence = @@ -285,7 +285,7 @@ sampleL (random.unicode sizeL) sampleR (random.unicode sizeR) middle (random.unicode 1) - .let [sample (/.joined (list sampleL sampleR)) + .let [sample (/.together (list sampleL sampleR)) (^open "/\.") /.equivalence]] ($_ _.and (_.cover [/.split_at] @@ -293,7 +293,7 @@ (case> (#.Right [_l _r]) (and (/\= sampleL _l) (/\= sampleR _r) - (/\= sample (/.joined (list _l _r)))) + (/\= sample (/.together (list _l _r)))) _ #0))) @@ -323,8 +323,8 @@ .let [part_gen (|> (random.text normal_char_gen sizeP) (random.only (|>> (/.contains? sep1) not)))] parts (random.list sizeL part_gen) - .let [sample1 (/.joined (list.interposed sep1 parts)) - sample2 (/.joined (list.interposed sep2 parts)) + .let [sample1 (/.together (list.interposed sep1 parts)) + sample2 (/.together (list.interposed sep2 parts)) (^open "/\.") /.equivalence]] (_.cover [/.replaced] (/\= sample2 diff --git a/stdlib/source/test/lux/data/text/buffer.lux b/stdlib/source/test/lux/data/text/buffer.lux index 393a20779..7d502d2fb 100644 --- a/stdlib/source/test/lux/data/text/buffer.lux +++ b/stdlib/source/test/lux/data/text/buffer.lux @@ -17,7 +17,7 @@ (def: part (Random Text) (do {! random.monad} - [size (\ ! map (|>> (n.% 10) inc) random.nat)] + [size (\ ! map (|>> (n.% 10) ++) random.nat)] (random.ascii/alpha size))) (def: .public test @@ -31,14 +31,14 @@ ($_ _.and (_.cover [/.empty] (n.= 0(/.size /.empty))) - (_.cover [/.size /.append] + (_.cover [/.size /.then] (n.= (text.size left) - (/.size (/.append left /.empty)))) + (/.size (/.then left /.empty)))) (_.cover [/.text] (text\= (format left mid right) (|> /.empty - (/.append left) - (/.append mid) - (/.append right) + (/.then left) + (/.then mid) + (/.then right) /.text))) )))) diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux index 46dba6ded..432e98257 100644 --- a/stdlib/source/test/lux/data/text/encoding.lux +++ b/stdlib/source/test/lux/data/text/encoding.lux @@ -190,7 +190,7 @@ <encodings>)] (def: all_encodings - (list.joined (list <named>))) + (list.together (list <named>))) (def: unique_encodings (list\fold (function (_ encoding set) diff --git a/stdlib/source/test/lux/data/text/escape.lux b/stdlib/source/test/lux/data/text/escape.lux index dcb562a3e..707a06996 100644 --- a/stdlib/source/test/lux/data/text/escape.lux +++ b/stdlib/source/test/lux/data/text/escape.lux @@ -44,15 +44,15 @@ (def: over_range (Random Char) - (..range (hex "FFFF") (inc (debug.private /.ascii_top)))) + (..range (hex "FFFF") (++ (debug.private /.ascii_top)))) (def: in_range (Random Char) - (..range (inc (debug.private /.ascii_top)) (debug.private /.ascii_bottom))) + (..range (++ (debug.private /.ascii_top)) (debug.private /.ascii_bottom))) (def: ascii_range (Random Char) - (..range (inc (debug.private /.ascii_top)) 0)) + (..range (++ (debug.private /.ascii_top)) 0)) (def: valid_sigils (Set Char) diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index db419c3dc..926a56446 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -157,7 +157,7 @@ [(def: <definition> Test (`` (_.cover [(~~ (template.spliced <part>))] - (let [all (list.joined (list <named>)) + (let [all (list.together (list <named>)) unique (set.of_list /.hash all)] (n.= (list.size all) (set.size unique))))))] @@ -173,7 +173,7 @@ [.let [top_start (hex "AC00") top_end (hex "D7AF") end_range (n.- top_start top_end)] - start (\ ! map (|>> (n.% top_start) inc) random.nat) + start (\ ! map (|>> (n.% top_start) ++) random.nat) end (\ ! map (|>> (n.% end_range) (n.+ top_start)) random.nat) .let [additional (n.- start end) sample (/.block start additional) @@ -199,12 +199,12 @@ (n.= end (/.end sample))) (_.cover [/.size] - (n.= (inc additional) + (n.= (++ additional) (/.size sample))) (_.cover [/.within?] (and (/.within? sample inside) - (not (/.within? sample (dec (/.start sample)))) - (not (/.within? sample (inc (/.end sample)))))) + (not (/.within? sample (-- (/.start sample)))) + (not (/.within? sample (++ (/.end sample)))))) (~~ (template [<definition> <part>] [<definition>] diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux index 84ebef798..b0be9c914 100644 --- a/stdlib/source/test/lux/data/text/unicode/set.lux +++ b/stdlib/source/test/lux/data/text/unicode/set.lux @@ -80,8 +80,8 @@ end (/.end <set>)]] (_.cover [<set>] (and (/.member? <set> char) - (not (/.member? <set> (dec start))) - (not (/.member? <set> (inc end))))))] + (not (/.member? <set> (-- start))) + (not (/.member? <set> (++ end))))))] [/.ascii] [/.ascii/alpha] diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux index 72417f5c5..6efd24021 100644 --- a/stdlib/source/test/lux/documentation.lux +++ b/stdlib/source/test/lux/documentation.lux @@ -54,19 +54,19 @@ (_.cover [/.default] (let [definition (`` (/.default (~~ (template.identifier [.._] [g!default]))))] (and (|> definition - (get@ #/.definition) + (value@ #/.definition) (text\= (template.text [g!default]))) (|> definition - (get@ #/.documentation) + (value@ #/.documentation) md.markdown (text\= "") not)))) (_.cover [/.documentation:] (and (|> ..documentation: - (get@ #/.definition) + (value@ #/.definition) (text\= (template.text [/.documentation:]))) (|> ..documentation: - (get@ #/.documentation) + (value@ #/.documentation) md.markdown (text.contains? 'definition_description')))) )) @@ -87,12 +87,12 @@ (/.documentation super)) (text.contains? (template.text ['super_description']) (/.documentation super)) - (text.contains? (md.markdown (get@ #/.documentation ..documentation:)) + (text.contains? (md.markdown (value@ #/.documentation ..documentation:)) (/.documentation super))))) )) (_.cover [/.unqualified_identifier] (`` (and (~~ (template [<example>] - [(<| (text.contains? (get@ #exception.label /.unqualified_identifier)) + [(<| (text.contains? (value@ #exception.label /.unqualified_identifier)) macro_error <example>)] diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index 55c812d72..41a794c4e 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -110,24 +110,24 @@ idx (|> random.nat (\ ! map (n.% size))) value (\ ! map (|>> (:as java/lang/Long)) random.int)] ($_ _.and - (_.cover [/.array /.array_length] + (_.cover [/.array /.length] (|> size (/.array java/lang/Long) - /.array_length + /.length (n.= size))) - (_.cover [/.array_write /.array_read] + (_.cover [/.write! /.read!] (|> (/.array java/lang/Long size) - (/.array_write idx value) - (/.array_read idx) + (/.write! idx value) + (/.read! idx) (:as Int) (i.= (:as Int value)))) (_.cover [/.cannot_convert_to_jvm_type] (let [array (:as (Array Nothing) (array.empty 1))] (|> array - /.array_length + /.length ..macro_error - (text.contains? (get@ #exception.label /.cannot_convert_to_jvm_type)))))))) + (text.contains? (value@ #exception.label /.cannot_convert_to_jvm_type)))))))) (def: for_miscellaneous Test @@ -198,7 +198,7 @@ [/.Character /.char character character\=] )) (_.cover [/.cannot_cast_to_non_object] - (text.contains? (get@ #exception.label /.cannot_cast_to_non_object) + (text.contains? (value@ #exception.label /.cannot_cast_to_non_object) (macro_error (/.:as boolean (: /.Boolean boolean))))) (_.cover [/.:as] (|> string diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux index 9ca7d80b3..701828389 100644 --- a/stdlib/source/test/lux/ffi.old.lux +++ b/stdlib/source/test/lux/ffi.old.lux @@ -160,12 +160,12 @@ idx (|> random.nat (\ ! map (n.% size))) value random.int] ($_ _.and - (_.cover [/.array /.array_length] - (n.= size (/.array_length (/.array java/lang/Long size)))) - (_.cover [/.array_write /.array_read] + (_.cover [/.array /.length] + (n.= size (/.length (/.array java/lang/Long size)))) + (_.cover [/.write! /.read!] (|> (/.array java/lang/Long size) - (/.array_write idx value) - (/.array_read idx) + (/.write! idx value) + (/.read! idx) (i.= value))) ))) diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index 29389ae9f..e6ded5090 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -189,7 +189,7 @@ (List Bundle) [Nat (Set a)])) (list\fold (function (_ bundle [amount set]) - [(n.+ amount (get@ #amount bundle)) + [(n.+ amount (value@ #amount bundle)) (set.union set (lens bundle))]) [0 (set.empty hash)] territories)) @@ -198,11 +198,11 @@ Test (|> ..languages list.reversed - (list\map (get@ #test)) + (list\map (value@ #test)) (list\fold _.and (`` ($_ _.and (~~ (template [<lens> <tag> <hash>] - [(let [[amount set] (..aggregate (get@ <tag>) <hash> ..languages)] + [(let [[amount set] (..aggregate (value@ <tag>) <hash> ..languages)] (_.cover [<lens>] (n.= amount (set.size set))))] @@ -278,8 +278,8 @@ (def: .public random (Random /.Language) (let [options (|> ..languages - (list\map (|>> (get@ #languages) set.list)) - list.joined)] + (list\map (|>> (value@ #languages) set.list)) + list.together)] (do {! random.monad} [choice (\ ! map (n.% (list.size options)) random.nat)] diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index fa7aff326..d25308c49 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -144,7 +144,7 @@ (List Bundle) [Nat (Set a)])) (list\fold (function (_ bundle [amount set]) - [(n.+ amount (get@ #amount bundle)) + [(n.+ amount (value@ #amount bundle)) (set.union set (lens bundle))]) [0 (set.empty hash)] territories)) @@ -153,11 +153,11 @@ Test (|> ..territories list.reversed - (list\map (get@ #test)) + (list\map (value@ #test)) (list\fold _.and (`` ($_ _.and (~~ (template [<lens> <tag> <hash>] - [(let [[amount set] (..aggregate (get@ <tag>) <hash> ..territories)] + [(let [[amount set] (..aggregate (value@ <tag>) <hash> ..territories)] (_.cover [<lens>] (n.= amount (set.size set))))] @@ -204,8 +204,8 @@ (def: .public random (Random /.Territory) (let [options (|> ..territories - (list\map (|>> (get@ #territories) set.list)) - list.joined)] + (list\map (|>> (value@ #territories) set.list)) + list.together)] (do {! random.monad} [choice (\ ! map (n.% (list.size options)) random.nat)] diff --git a/stdlib/source/test/lux/macro/local.lux b/stdlib/source/test/lux/macro/local.lux index 1ab20df9a..c097f7676 100644 --- a/stdlib/source/test/lux/macro/local.lux +++ b/stdlib/source/test/lux/macro/local.lux @@ -52,9 +52,9 @@ [module short] (meta.normal name) _ (if pre_remove (let [remove_macro! (: (-> .Module .Module) - (update@ #.definitions (plist.lacks short)))] + (revised@ #.definitions (plist.lacks short)))] (function (_ lux) - (#try.Success [(update@ #.modules (plist.revised module remove_macro!) lux) + (#try.Success [(revised@ #.modules (plist.revised module remove_macro!) lux) []]))) (in []))] (let [pre_expansion (` (let [(~ g!output) (~ body)] diff --git a/stdlib/source/test/lux/macro/syntax/check.lux b/stdlib/source/test/lux/macro/syntax/check.lux index f9cbab99e..c2bfd9896 100644 --- a/stdlib/source/test/lux/macro/syntax/check.lux +++ b/stdlib/source/test/lux/macro/syntax/check.lux @@ -44,5 +44,5 @@ false (#try.Success check) - (and (code\= type (get@ #/.type check)) - (code\= value (get@ #/.value check))))))))) + (and (code\= type (value@ #/.type check)) + (code\= value (value@ #/.value check))))))))) diff --git a/stdlib/source/test/lux/macro/syntax/definition.lux b/stdlib/source/test/lux/macro/syntax/definition.lux index ae7d5d3e5..11074fbc7 100644 --- a/stdlib/source/test/lux/macro/syntax/definition.lux +++ b/stdlib/source/test/lux/macro/syntax/definition.lux @@ -76,7 +76,7 @@ (#try.Success actual) (\ /.equivalence = expected actual))) (_.cover [/.typed] - (let [expected (set@ #/.value (#.Left [type untyped_value]) expected)] + (let [expected (with@ #/.value (#.Left [type untyped_value]) expected)] (case (<code>.result (/.typed compiler) (list (/.format expected))) (#try.Failure error) @@ -85,7 +85,7 @@ (#try.Success actual) (\ /.equivalence = expected actual)))) (_.cover [/.lacks_type!] - (let [expected (set@ #/.value (#.Right untyped_value) expected)] + (let [expected (with@ #/.value (#.Right untyped_value) expected)] (case (<code>.result (/.typed compiler) (list (/.format expected))) (#try.Failure error) diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index f1bbc7fa6..8aeb528f5 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -92,7 +92,7 @@ (do {! random.monad} [.let [~= (f.approximately? ..margin_of_error)] sample (\ ! map (f.* +10.0) random.safe_frac) - power (\ ! map (|>> (n.% 10) inc n.frac) random.nat)] + power (\ ! map (|>> (n.% 10) ++ n.frac) random.nat)] ($_ _.and (_.cover [/.exp /.log] (|> sample /.exp /.log (f.approximately? +0.000000000000001 sample))) @@ -160,7 +160,7 @@ (~= (f.opposite tau/4) (/.atan/2 +0.0 (f.opposite (f.abs y)))) (f.not_a_number? (/.atan/2 +0.0 +0.0)))))) (do {! random.monad} - [of (\ ! map (|>> (n.% 10) inc) random.nat)] + [of (\ ! map (|>> (n.% 10) ++) random.nat)] (_.cover [/.factorial] (and (n.= 1 (/.factorial 0)) (|> (/.factorial of) (n.% of) (n.= 0))))) diff --git a/stdlib/source/test/lux/math/logic/continuous.lux b/stdlib/source/test/lux/math/logic/continuous.lux index a49e5c7d8..cd168fc4c 100644 --- a/stdlib/source/test/lux/math/logic/continuous.lux +++ b/stdlib/source/test/lux/math/logic/continuous.lux @@ -31,10 +31,10 @@ (_.cover [/.true /.false] (let [true=max! - (r.= /.false (inc /.true)) + (r.= /.false (++ /.true)) false=min! - (r.= /.true (dec /.false))] + (r.= /.true (-- /.false))] (and true=max! false=min!))) (_.cover [/.or] diff --git a/stdlib/source/test/lux/math/modulus.lux b/stdlib/source/test/lux/math/modulus.lux index f1e731975..ae3bbb8e1 100644 --- a/stdlib/source/test/lux/math/modulus.lux +++ b/stdlib/source/test/lux/math/modulus.lux @@ -63,6 +63,6 @@ (/.literal <divisor>)))) (_.cover [/.congruent?] (and (/.congruent? modulus dividend dividend) - (or (not (/.congruent? modulus dividend (inc dividend))) + (or (not (/.congruent? modulus dividend (++ dividend))) (i.= +1 (/.divisor modulus))))) )))) diff --git a/stdlib/source/test/lux/math/number/complex.lux b/stdlib/source/test/lux/math/number/complex.lux index 77cafc155..70706538d 100644 --- a/stdlib/source/test/lux/math/number/complex.lux +++ b/stdlib/source/test/lux/math/number/complex.lux @@ -43,8 +43,8 @@ (def: angle (Random /.Complex) (\ random.monad map - (|>> (update@ #/.real (f.% +1.0)) - (update@ #/.imaginary (f.% +1.0))) + (|>> (revised@ #/.real (f.% +1.0)) + (revised@ #/.imaginary (f.% +1.0))) ..random)) (def: construction @@ -55,11 +55,11 @@ ($_ _.and (_.cover [/.complex] (and (let [r+i (/.complex real imaginary)] - (and (f.= real (get@ #/.real r+i)) - (f.= imaginary (get@ #/.imaginary r+i)))) + (and (f.= real (value@ #/.real r+i)) + (f.= imaginary (value@ #/.imaginary r+i)))) (let [r+i (/.complex real)] - (and (f.= real (get@ #/.real r+i)) - (f.= +0.0 (get@ #/.imaginary r+i)))))) + (and (f.= real (value@ #/.real r+i)) + (f.= +0.0 (value@ #/.imaginary r+i)))))) (_.cover [/.approximately?] (/.approximately? ..margin_of_error (/.complex real imaginary) @@ -135,18 +135,18 @@ (_.cover [/.+] (let [z (/.+ y x)] (and (/.= z - (/.complex (f.+ (get@ #/.real y) - (get@ #/.real x)) - (f.+ (get@ #/.imaginary y) - (get@ #/.imaginary x))))))) + (/.complex (f.+ (value@ #/.real y) + (value@ #/.real x)) + (f.+ (value@ #/.imaginary y) + (value@ #/.imaginary x))))))) (_.cover [/.-] (let [normal! (let [z (/.- y x)] (and (/.= z - (/.complex (f.- (get@ #/.real y) - (get@ #/.real x)) - (f.- (get@ #/.imaginary y) - (get@ #/.imaginary x)))))) + (/.complex (f.- (value@ #/.real y) + (value@ #/.real x)) + (f.- (value@ #/.imaginary y) + (value@ #/.imaginary x)))))) inverse! (and (|> x (/.+ y) (/.- y) (/.approximately? ..margin_of_error x)) @@ -161,8 +161,8 @@ (let [rem (/.% y x) quotient (|> x (/.- rem) (/./ y)) floored (|> quotient - (update@ #/.real math.floor) - (update@ #/.imaginary math.floor))] + (revised@ #/.real math.floor) + (revised@ #/.imaginary math.floor))] (/.approximately? +0.000000000001 x (|> quotient (/.* y) (/.+ rem))))) @@ -175,10 +175,10 @@ ($_ _.and (_.cover [/.conjugate] (let [cx (/.conjugate x)] - (and (f.= (get@ #/.real x) - (get@ #/.real cx)) - (f.= (f.opposite (get@ #/.imaginary x)) - (get@ #/.imaginary cx))))) + (and (f.= (value@ #/.real x) + (value@ #/.real cx)) + (f.= (f.opposite (value@ #/.imaginary x)) + (value@ #/.imaginary cx))))) (_.cover [/.reciprocal] (let [reciprocal! (|> x (/.* (/.reciprocal x)) (/.approximately? ..margin_of_error /.+one)) diff --git a/stdlib/source/test/lux/math/number/i16.lux b/stdlib/source/test/lux/math/number/i16.lux index f82250048..807a58886 100644 --- a/stdlib/source/test/lux/math/number/i16.lux +++ b/stdlib/source/test/lux/math/number/i16.lux @@ -23,10 +23,10 @@ (<| (_.covering /._) (_.for [/.I16]) (do {! random.monad} - [.let [limit (|> (dec /.width) + [.let [limit (|> (-- /.width) //i64.mask .int - inc)] + ++)] expected (\ ! map (i.% limit) random.int)] ($_ _.and (_.for [/.equivalence] diff --git a/stdlib/source/test/lux/math/number/i32.lux b/stdlib/source/test/lux/math/number/i32.lux index a4c503bf7..06b2458e9 100644 --- a/stdlib/source/test/lux/math/number/i32.lux +++ b/stdlib/source/test/lux/math/number/i32.lux @@ -23,10 +23,10 @@ (<| (_.covering /._) (_.for [/.I32]) (do {! random.monad} - [.let [limit (|> (dec /.width) + [.let [limit (|> (-- /.width) //i64.mask .int - inc)] + ++)] expected (\ ! map (i.% limit) random.int)] ($_ _.and (_.for [/.equivalence] diff --git a/stdlib/source/test/lux/math/number/i64.lux b/stdlib/source/test/lux/math/number/i64.lux index d8e47745b..ac82addce 100644 --- a/stdlib/source/test/lux/math/number/i64.lux +++ b/stdlib/source/test/lux/math/number/i64.lux @@ -48,7 +48,7 @@ [pattern random.nat] ($_ _.and (do ! - [idx (\ ! map (|>> (n.% (dec /.width)) inc) random.nat)] + [idx (\ ! map (|>> (n.% (-- /.width)) ++) random.nat)] (_.cover [/.left_shifted /.right_shifted] (let [nullity! (and (\= pattern (/.left_shifted 0 pattern)) @@ -85,7 +85,7 @@ idempotency! (\= (/.and mask pattern) (/.and mask (/.and mask pattern))) - limit (inc (.nat mask)) + limit (++ (.nat mask)) limit! (if (n.< limit pattern) (\= pattern (/.and mask pattern)) (n.< limit (/.and mask pattern))) @@ -130,10 +130,10 @@ (#.Some sub) (do {! random.monad} - [.let [limit (|> (dec (\ sub width)) + [.let [limit (|> (-- (\ sub width)) /.mask .int - inc)] + ++)] expected (\ ! map (i.% limit) random.int) .let [random (: (All [size] (-> (-> I64 (I64 size)) (Random (I64 size)))) @@ -199,8 +199,8 @@ (_.cover [/.ones] (let [zero&one! (if (/.one? idx pattern) - (n.= (dec (/.ones pattern)) (/.ones (/.zero idx pattern))) - (n.= (inc (/.ones pattern)) (/.ones (/.one idx pattern)))) + (n.= (-- (/.ones pattern)) (/.ones (/.zero idx pattern))) + (n.= (++ (/.ones pattern)) (/.ones (/.one idx pattern)))) complementarity! (n.= /.width diff --git a/stdlib/source/test/lux/math/number/i8.lux b/stdlib/source/test/lux/math/number/i8.lux index 2764f93ec..7d753733d 100644 --- a/stdlib/source/test/lux/math/number/i8.lux +++ b/stdlib/source/test/lux/math/number/i8.lux @@ -23,10 +23,10 @@ (<| (_.covering /._) (_.for [/.I8]) (do {! random.monad} - [.let [limit (|> (dec /.width) + [.let [limit (|> (-- /.width) //i64.mask .int - inc)] + ++)] expected (\ ! map (i.% limit) random.int)] ($_ _.and (_.for [/.equivalence] diff --git a/stdlib/source/test/lux/math/number/int.lux b/stdlib/source/test/lux/math/number/int.lux index 6fba4351a..3c7cb47be 100644 --- a/stdlib/source/test/lux/math/number/int.lux +++ b/stdlib/source/test/lux/math/number/int.lux @@ -192,7 +192,7 @@ idempotency! (/.= pattern (/.right_shifted i64.width pattern)) - sign_mask (i64.left_shifted (dec i64.width) 1) + sign_mask (i64.left_shifted (-- i64.width) 1) mantissa_mask (i64.not sign_mask) sign_preservation! diff --git a/stdlib/source/test/lux/math/number/nat.lux b/stdlib/source/test/lux/math/number/nat.lux index d6e64603e..bf4a7eb40 100644 --- a/stdlib/source/test/lux/math/number/nat.lux +++ b/stdlib/source/test/lux/math/number/nat.lux @@ -104,7 +104,7 @@ (/.= rem (/.% left right))))) )) (do {! random.monad} - [.let [random (\ ! map (|>> (/.% 1,000) inc) random.nat)] + [.let [random (\ ! map (|>> (/.% 1,000) ++) random.nat)] left random right random] ($_ _.and diff --git a/stdlib/source/test/lux/math/number/rev.lux b/stdlib/source/test/lux/math/number/rev.lux index b0d857464..fdb68b72c 100644 --- a/stdlib/source/test/lux/math/number/rev.lux +++ b/stdlib/source/test/lux/math/number/rev.lux @@ -99,7 +99,7 @@ divisor/0 divisor divisor/1 (random.only (|>> (/.= divisor/0) not) divisor) - scale (\ ! map (|>> (n.% 10) inc) + scale (\ ! map (|>> (n.% 10) ++) random.nat)] ($_ _.and (_.cover [/./] diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 5c84f9c38..a56457c9c 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -320,7 +320,7 @@ (/.result expected_lux) (!expect (^multi (#try.Success [actual_pre actual_post]) (and (n.= expected_seed actual_pre) - (n.= (inc expected_seed) actual_post)))))) + (n.= (++ expected_seed) actual_post)))))) (_.cover [/.location] (|> /.location (/.result expected_lux) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index ae4685790..2a21207d4 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -1019,13 +1019,13 @@ random.nat)] dimensions size sizesH size - sizesT (random.list (dec dimensions) size) + sizesT (random.list (-- dimensions) size) .let [type (loop [dimensions dimensions type (: (Type Object) ..$Object)] (case dimensions 0 type - _ (recur (dec dimensions) (/type.array type))))]] + _ (recur (-- dimensions) (/type.array type))))]] (<| (_.lifted "MULTIANEWARRAY") (..bytecode (|>> (:as Nat) (n.= sizesH))) (do {! /.monad} @@ -1051,13 +1051,13 @@ (-> (Primitive a) (Primitive z) (Bytecode Any) (-> a z) (-> z Any Bit) (Random Bit))) (function (_ from to instruction convert test) (do random.monad - [input (get@ #random from) + [input (value@ #random from) .let [expected (convert input)]] (..bytecode (test expected) (do /.monad - [_ ((get@ #literal from) input) + [_ ((value@ #literal from) input) _ instruction] - (get@ #wrap to)))))) + (value@ #wrap to)))))) int::= (!::= java/lang/Integer "jvm ieq" "jvm int =") long::= (!::= java/lang/Long "jvm leq" "jvm long =") float::= (!::= java/lang/Float "jvm feq" "jvm float =") @@ -1321,10 +1321,10 @@ (do random.monad [class_name ..class_name primitive_method_name (random.ascii/upper 10) - .let [primitive_method_type (/type.method [(list) (list) (get@ #unboxed primitive) (list)])] + .let [primitive_method_type (/type.method [(list) (list) (value@ #unboxed primitive) (list)])] object_method_name (|> (random.ascii/upper 10) (random.only (|>> (text\= primitive_method_name) not))) - expected (get@ #random primitive) + expected (value@ #random primitive) .let [$Self (/type.class class_name (list))]] (in (case (do try.monad [class (/class.class /version.v6_0 /class.public @@ -1337,11 +1337,11 @@ primitive_method_type (list) (#.Some (do /.monad - [_ ((get@ #literal primitive) expected)] + [_ ((value@ #literal primitive) expected)] return))) (/method.method ..method_modifier object_method_name - (/type.method [(list) (list) (get@ #boxed primitive) (list)]) + (/type.method [(list) (list) (value@ #boxed primitive) (list)]) (list) (#.Some (do /.monad [_ (/.invokestatic $Self primitive_method_name primitive_method_type) @@ -1351,7 +1351,7 @@ (#.Some substitute) (substitute expected)) - _ (get@ #wrap primitive)] + _ (value@ #wrap primitive)] /.areturn)))) (row.row)) .let [bytecode (format.result /class.writer class) diff --git a/stdlib/source/test/lux/test.lux b/stdlib/source/test/lux/test.lux index eef7b91e7..e51623e28 100644 --- a/stdlib/source/test/lux/test.lux +++ b/stdlib/source/test/lux/test.lux @@ -25,8 +25,8 @@ (-> Text Text Nat Nat [/.Tally Text] Bit) (and (text.contains? expected_message/0 message) (text.contains? expected_message/1 message) - (n.= successes (get@ #/.successes tally)) - (n.= failures (get@ #/.failures tally)))) + (n.= successes (value@ #/.successes tally)) + (n.= failures (value@ #/.failures tally)))) (def: assertion /.Test @@ -41,10 +41,10 @@ (/.cover' [/.assertion /.Tally] (and (text.ends_with? expected_message/0 success_message) (text.ends_with? expected_message/0 failure_message) - (and (n.= 1 (get@ #/.successes success_tally)) - (n.= 0 (get@ #/.failures success_tally))) - (and (n.= 0 (get@ #/.successes failure_tally)) - (n.= 1 (get@ #/.failures failure_tally))))))) + (and (n.= 1 (value@ #/.successes success_tally)) + (n.= 0 (value@ #/.failures success_tally))) + (and (n.= 0 (value@ #/.successes failure_tally)) + (n.= 1 (value@ #/.failures failure_tally))))))) (in (do async.monad [tt (/.and' (/.assertion expected_message/0 true) (/.assertion expected_message/1 true)) @@ -82,10 +82,10 @@ [[pre_tally pre_message] pre [post_tally post_message] post] (/.cover' [/.seed] - (and (and (n.= 1 (get@ #/.successes pre_tally)) - (n.= 0 (get@ #/.failures pre_tally))) - (and (n.= 1 (get@ #/.successes post_tally)) - (n.= 0 (get@ #/.failures post_tally))))))))) + (and (and (n.= 1 (value@ #/.successes pre_tally)) + (n.= 0 (value@ #/.failures pre_tally))) + (and (n.= 1 (value@ #/.successes post_tally)) + (n.= 0 (value@ #/.failures post_tally))))))))) (def: times /.Test @@ -95,32 +95,32 @@ (in (do async.monad [[tally error] times_assertion] (/.cover' [/.must_try_test_at_least_once] - (and (text.contains? (get@ #exception.label /.must_try_test_at_least_once) error) - (n.= 0 (get@ #/.successes tally)) - (n.= 1 (get@ #/.failures tally))))))) + (and (text.contains? (value@ #exception.label /.must_try_test_at_least_once) error) + (n.= 0 (value@ #/.successes tally)) + (n.= 1 (value@ #/.failures tally))))))) (do {! random.monad} - [expected (\ ! map (|>> (n.% 10) inc) random.nat) + [expected (\ ! map (|>> (n.% 10) ++) random.nat) .let [counter (: (Atom Nat) (atom.atom 0))] times_assertion (<| (/.times expected) (do ! [_ (in []) - .let [_ (io.run! (atom.update! inc counter))]] + .let [_ (io.run! (atom.update! ++ counter))]] (/.test "" true)))] (in (do async.monad [[tally error] times_assertion actual (async.future (atom.read! counter))] (/.cover' [/.times] (and (n.= expected actual) - (n.= 1 (get@ #/.successes tally)) - (n.= 0 (get@ #/.failures tally))))))) + (n.= 1 (value@ #/.successes tally)) + (n.= 0 (value@ #/.failures tally))))))) )) (def: in_parallel /.Test ($_ /.and (do {! random.monad} - [expected (\ ! map (|>> (n.% 10) inc) random.nat) + [expected (\ ! map (|>> (n.% 10) ++) random.nat) .let [counter (: (Atom Nat) (atom.atom 0))] assertion (<| /.in_parallel @@ -128,17 +128,17 @@ (: /.Test) (do ! [_ (in []) - .let [_ (io.run! (atom.update! inc counter))]] + .let [_ (io.run! (atom.update! ++ counter))]] (/.test "" true)))] (in (do async.monad [[tally error] assertion actual (async.future (atom.read! counter))] (/.cover' [/.in_parallel] (and (n.= expected actual) - (n.= expected (get@ #/.successes tally)) - (n.= 0 (get@ #/.failures tally))))))) + (n.= expected (value@ #/.successes tally)) + (n.= 0 (value@ #/.failures tally))))))) (do {! random.monad} - [expected (\ ! map (|>> (n.% 10) inc) random.nat) + [expected (\ ! map (|>> (n.% 10) ++) random.nat) .let [counter (: (Atom Nat) (atom.atom 0))] assertion (<| /.in_parallel @@ -147,16 +147,16 @@ (do ! [_ (in []) .let [_ (undefined) - _ (io.run! (atom.update! inc counter))]] + _ (io.run! (atom.update! ++ counter))]] (/.test "" true)))] (in (do async.monad [[tally error] assertion actual (async.future (atom.read! counter))] (/.cover' [/.error_during_execution] - (let [correct_error! (text.contains? (get@ #exception.label /.error_during_execution) error) + (let [correct_error! (text.contains? (value@ #exception.label /.error_during_execution) error) no_complete_run! (n.= 0 actual) - no_successes! (n.= 0 (get@ #/.successes tally)) - ran_all_tests! (n.= expected (get@ #/.failures tally))] + no_successes! (n.= 0 (value@ #/.successes tally)) + ran_all_tests! (n.= expected (value@ #/.failures tally))] (and correct_error! no_complete_run! no_successes! @@ -176,10 +176,10 @@ [[not_covering _] not_covering [covering _] covering] (/.cover' [/.covering] - (and (and (set.empty? (get@ #/.expected_coverage not_covering)) - (set.empty? (get@ #/.actual_coverage not_covering))) - (and (not (set.empty? (get@ #/.expected_coverage covering))) - (set.empty? (get@ #/.actual_coverage covering)))))))) + (and (and (set.empty? (value@ #/.expected_coverage not_covering)) + (set.empty? (value@ #/.actual_coverage not_covering))) + (and (not (set.empty? (value@ #/.expected_coverage covering))) + (set.empty? (value@ #/.actual_coverage covering)))))))) (do random.monad [not_covering (/.covering .._ (/.test "" true)) covering (/.covering .._ (/.cover [..dummy_target] true))] @@ -187,10 +187,10 @@ [[not_covering _] not_covering [covering _] covering] (/.cover' [/.cover] - (and (and (not (set.empty? (get@ #/.expected_coverage not_covering))) - (not (set.member? (get@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) - (and (not (set.empty? (get@ #/.expected_coverage covering))) - (set.member? (get@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) + (and (and (not (set.empty? (value@ #/.expected_coverage not_covering))) + (not (set.member? (value@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) + (and (not (set.empty? (value@ #/.expected_coverage covering))) + (set.member? (value@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) (do random.monad [not_covering (/.covering .._ (/.test "" true)) covering (/.covering .._ (in (/.cover' [..dummy_target] true)))] @@ -198,10 +198,10 @@ [[not_covering _] not_covering [covering _] covering] (/.cover' [/.cover'] - (and (and (not (set.empty? (get@ #/.expected_coverage not_covering))) - (not (set.member? (get@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) - (and (not (set.empty? (get@ #/.expected_coverage covering))) - (set.member? (get@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) + (and (and (not (set.empty? (value@ #/.expected_coverage not_covering))) + (not (set.member? (value@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) + (and (not (set.empty? (value@ #/.expected_coverage covering))) + (set.member? (value@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) (do random.monad [not_covering (/.covering .._ (/.test "" true)) covering (/.covering .._ (/.for [..dummy_target] (/.test "" true)))] @@ -209,10 +209,10 @@ [[not_covering _] not_covering [covering _] covering] (/.cover' [/.for] - (and (and (not (set.empty? (get@ #/.expected_coverage not_covering))) - (not (set.member? (get@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) - (and (not (set.empty? (get@ #/.expected_coverage covering))) - (set.member? (get@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) + (and (and (not (set.empty? (value@ #/.expected_coverage not_covering))) + (not (set.member? (value@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) + (and (not (set.empty? (value@ #/.expected_coverage covering))) + (set.member? (value@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) )) (def: .public test @@ -239,10 +239,10 @@ (/.cover' [/.test] (and (text.ends_with? expected_message/0 success_message) (text.ends_with? expected_message/0 failure_message) - (and (n.= 1 (get@ #/.successes success_tally)) - (n.= 0 (get@ #/.failures success_tally))) - (and (n.= 0 (get@ #/.successes failure_tally)) - (n.= 1 (get@ #/.failures failure_tally)))))))) + (and (n.= 1 (value@ #/.successes success_tally)) + (n.= 0 (value@ #/.failures success_tally))) + (and (n.= 0 (value@ #/.successes failure_tally)) + (n.= 1 (value@ #/.failures failure_tally)))))))) (do ! [tt (/.and (/.test expected_message/0 true) (/.test expected_message/1 true)) @@ -273,18 +273,18 @@ (text.contains? expected_message/0 success_message)) (and (text.contains? expected_context failure_message) (text.contains? expected_message/0 failure_message)) - (and (n.= 1 (get@ #/.successes success_tally)) - (n.= 0 (get@ #/.failures success_tally))) - (and (n.= 0 (get@ #/.successes failure_tally)) - (n.= 1 (get@ #/.failures failure_tally)))))))) + (and (n.= 1 (value@ #/.successes success_tally)) + (n.= 0 (value@ #/.failures success_tally))) + (and (n.= 0 (value@ #/.successes failure_tally)) + (n.= 1 (value@ #/.failures failure_tally)))))))) (do ! [failure_assertion (/.failure expected_message/0)] (in (do async.monad [[failure_tally failure_message] failure_assertion] (/.cover' [/.failure] (and (text.contains? expected_message/0 failure_message) - (and (n.= 0 (get@ #/.successes failure_tally)) - (n.= 1 (get@ #/.failures failure_tally)))))))) + (and (n.= 0 (value@ #/.successes failure_tally)) + (n.= 1 (value@ #/.failures failure_tally)))))))) (do ! [success_assertion (/.lifted expected_message/0 (in true)) failure_assertion (/.lifted expected_message/0 (in false))] @@ -294,10 +294,10 @@ (/.cover' [/.lifted] (and (text.contains? expected_message/0 success_message) (text.contains? expected_message/0 failure_message) - (and (n.= 1 (get@ #/.successes success_tally)) - (n.= 0 (get@ #/.failures success_tally))) - (and (n.= 0 (get@ #/.successes failure_tally)) - (n.= 1 (get@ #/.failures failure_tally)))))))) + (and (n.= 1 (value@ #/.successes success_tally)) + (n.= 0 (value@ #/.failures success_tally))) + (and (n.= 0 (value@ #/.successes failure_tally)) + (n.= 1 (value@ #/.failures failure_tally)))))))) ..times ..in_parallel ..coverage diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux index 872e7f2ce..70bb0a93e 100644 --- a/stdlib/source/test/lux/time/date.lux +++ b/stdlib/source/test/lux/time/date.lux @@ -77,7 +77,7 @@ (try\map (\ /.equivalence = expected)) (try.else false)))) (do {! random.monad} - [year (\ ! map (|>> (n.% 10,000) inc) + [year (\ ! map (|>> (n.% 10,000) ++) random.nat) month (\ ! map (|>> (n.% 10) (n.+ 13)) random.nat) diff --git a/stdlib/source/test/lux/time/month.lux b/stdlib/source/test/lux/time/month.lux index 18d56c088..77a0a9702 100644 --- a/stdlib/source/test/lux/time/month.lux +++ b/stdlib/source/test/lux/time/month.lux @@ -31,7 +31,7 @@ (Random /.Month) (let [december (/.number #/.December)] (|> random.nat - (\ random.monad map (|>> (n.% december) inc)) + (\ random.monad map (|>> (n.% december) ++)) (random.one (|>> /.by_number try.maybe))))) (def: .public test diff --git a/stdlib/source/test/lux/time/year.lux b/stdlib/source/test/lux/time/year.lux index 513b1b92d..b43fb99eb 100644 --- a/stdlib/source/test/lux/time/year.lux +++ b/stdlib/source/test/lux/time/year.lux @@ -91,7 +91,7 @@ (and (i.= +1 (/.leaps leap)) (i.= (.int (n./ /.leap /.century)) (/.leaps century)) - (i.= (inc (i.* +4 (dec (/.leaps century)))) + (i.= (++ (i.* +4 (-- (/.leaps century)))) (/.leaps era)))) )) ))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux index aa4443cdb..92acc8672 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -179,7 +179,7 @@ (_.test "Can analyse exhaustive pattern-matching." (|> (analyse_pm exhaustive_branchesC) _structure.check_succeeds)) - (let [non_exhaustive_branchesC (list.first (dec (list.size exhaustive_branchesC)) + (let [non_exhaustive_branchesC (list.first (-- (list.size exhaustive_branchesC)) exhaustive_branchesC)] (_.test "Will reject non-exhaustive pattern-matching." (|> (analyse_pm non_exhaustive_branchesC) @@ -188,7 +188,7 @@ [redundant_patterns (exhaustive_branches false variantTC inputC) redundancy_idx (|> r.nat (\ ! map (n.% (list.size redundant_patterns)))) .let [redundant_branchesC (<| (list!map (branch outputC)) - list.joined + list.together (list (list.first redundancy_idx redundant_patterns) (list (maybe.trusted (list.item redundancy_idx redundant_patterns))) (list.after redundancy_idx redundant_patterns)))]] @@ -199,10 +199,10 @@ [[heterogeneousT heterogeneousC] (r.only (|>> product.left (check.subsumes? outputT) not) _primitive.primitive) heterogeneous_idx (|> r.nat (\ ! map (n.% (list.size exhaustive_patterns)))) - .let [heterogeneous_branchesC (list.joined (list (list.first heterogeneous_idx exhaustive_branchesC) - (list (let [[_pattern _body] (maybe.trusted (list.item heterogeneous_idx exhaustive_branchesC))] - [_pattern heterogeneousC])) - (list.after (inc heterogeneous_idx) exhaustive_branchesC)))]] + .let [heterogeneous_branchesC (list.together (list (list.first heterogeneous_idx exhaustive_branchesC) + (list (let [[_pattern _body] (maybe.trusted (list.item heterogeneous_idx exhaustive_branchesC))] + [_pattern heterogeneousC])) + (list.after (++ heterogeneous_idx) exhaustive_branchesC)))]] (_.test "Will reject pattern-matching if the bodies of the branches do not all have the same type." (|> (analyse_pm heterogeneous_branchesC) _structure.check_fails))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux index 42b1e366c..b0feacead 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -92,12 +92,12 @@ partialT (type.function (list.after partial_args inputsT) outputT) varT (#.Parameter 1) polyT (<| (type.univ_q 1) - (type.function (list.joined (list (list.first var_idx inputsT) - (list varT) - (list.after (inc var_idx) inputsT)))) + (type.function (list.together (list (list.first var_idx inputsT) + (list varT) + (list.after (++ var_idx) inputsT)))) varT) poly_inputT (maybe.trusted (list.item var_idx inputsT)) - partial_poly_inputsT (list.after (inc var_idx) inputsT) + partial_poly_inputsT (list.after (++ var_idx) inputsT) partial_polyT1 (<| (type.function partial_poly_inputsT) poly_inputT) partial_polyT2 (<| (type.univ_q 1) @@ -116,8 +116,8 @@ (|> (/.apply _primitive.phase inputsC polyT dummy_function archive.empty (' [])) (check_apply poly_inputT full_args))) (_.test "Polymorphic partial application propagates found type-vars." - (|> (/.apply _primitive.phase (list.first (inc var_idx) inputsC) polyT dummy_function archive.empty (' [])) - (check_apply partial_polyT1 (inc var_idx)))) + (|> (/.apply _primitive.phase (list.first (++ var_idx) inputsC) polyT dummy_function archive.empty (' [])) + (check_apply partial_polyT1 (++ var_idx)))) (_.test "Polymorphic partial application preserves quantification for type-vars." (|> (/.apply _primitive.phase (list.first var_idx inputsC) polyT dummy_function archive.empty (' [])) (check_apply partial_polyT2 var_idx))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux index d27b85baf..1b8939368 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -1,6 +1,7 @@ (.module: [lux #* - [abstract ["." monad (#+ do)]] + [abstract + ["." monad (#+ do)]] [data ["%" text/format (#+ format)] ["." name]] @@ -54,12 +55,12 @@ (def: (check_sum' tag size variant) (-> Tag Nat (Variant Analysis) Bit) - (let [expected//right? (n.= (dec size) tag) + (let [expected//right? (n.= (-- size) tag) expected//lefts (if expected//right? - (dec tag) + (-- tag) tag) - actual//right? (get@ #////analysis.right? variant) - actual//lefts (get@ #////analysis.lefts variant)] + actual//right? (value@ #////analysis.right? variant) + actual//lefts (value@ #////analysis.lefts variant)] (and (n.= expected//lefts actual//lefts) (bit\= expected//right? @@ -121,14 +122,14 @@ [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) choice (|> r.nat (\ ! map (n.% size))) primitives (r.list size _primitive.primitive) - +choice (|> r.nat (\ ! map (n.% (inc size)))) + +choice (|> r.nat (\ ! map (n.% (++ size)))) [_ +valueC] _primitive.primitive .let [variantT (type.variant (list\map product.left primitives)) [valueT valueC] (maybe.trusted (list.item choice primitives)) - +size (inc size) - +primitives (list.joined (list (list.first choice primitives) - (list [(#.Parameter 1) +valueC]) - (list.after choice primitives))) + +size (++ size) + +primitives (list.together (list (list.first choice primitives) + (list [(#.Parameter 1) +valueC]) + (list.after choice primitives))) [+valueT +valueC] (maybe.trusted (list.item +choice +primitives)) +variantT (type.variant (list\map product.left +primitives))]] (<| (_.context (%.name (name_of /.sum))) @@ -176,9 +177,9 @@ [_ +valueC] _primitive.primitive .let [tupleT (type.tuple (list\map product.left primitives)) [singletonT singletonC] (|> primitives (list.item choice) maybe.trusted) - +primitives (list.joined (list (list.first choice primitives) - (list [(#.Parameter 1) +valueC]) - (list.after choice primitives))) + +primitives (list.together (list (list.first choice primitives) + (list [(#.Parameter 1) +valueC]) + (list.after choice primitives))) +tupleT (type.tuple (list\map product.left +primitives))]] (<| (_.context (%.name (name_of /.product))) ($_ _.and @@ -243,9 +244,9 @@ [choiceT choiceC] (maybe.trusted (list.item choice primitives)) [other_choiceT other_choiceC] (maybe.trusted (list.item other_choice primitives)) monoT (type.variant primitivesT) - polyT (|> (type.variant (list.joined (list (list.first choice primitivesT) - (list varT) - (list.after (inc choice) primitivesT)))) + polyT (|> (type.variant (list.together (list (list.first choice primitivesT) + (list varT) + (list.after (++ choice) primitivesT)))) (type.univ_q 1)) choice_tag (maybe.trusted (list.item choice tags)) other_choice_tag (maybe.trusted (list.item other_choice tags))]] @@ -288,9 +289,9 @@ primitivesC (list\map product.right primitives) monoT (#.Named [module_name type_name] (type.tuple primitivesT)) recordC (list.zipped/2 tagsC primitivesC) - polyT (|> (type.tuple (list.joined (list (list.first choice primitivesT) - (list varT) - (list.after (inc choice) primitivesT)))) + polyT (|> (type.tuple (list.together (list (list.first choice primitivesT) + (list varT) + (list.after (++ choice) primitivesT)))) (type.univ_q 1) (#.Named [module_name type_name]))]] (<| (_.context (%.name (name_of /.record))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 224349569..b634c0115 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -119,7 +119,7 @@ (def: random_path (Random (analysis.Tuple synthesis.Member)) (do {! random.monad} - [size_1 (|> random.nat (\ ! map (|>> (n.% 10) inc)))] + [size_1 (|> random.nat (\ ! map (|>> (n.% 10) ++)))] (random.list size_1 ..random_member))) (def: (get_pattern path) @@ -136,7 +136,7 @@ (#.Right lefts) (analysis.pattern/tuple - (list\compose (list.repeated (inc lefts) (analysis.pattern/unit)) + (list\compose (list.repeated (++ lefts) (analysis.pattern/unit)) (list inner))))) (#analysis.Bind @member) (list.reversed path)) @@ -290,7 +290,7 @@ branch (: (-> Nat Bit Text Frac Branch) (function (_ lefts right? value body) {#analysis.when (if right? - (analysis.pattern/tuple (list\compose (list.repeated (inc lefts) (analysis.pattern/unit)) + (analysis.pattern/tuple (list\compose (list.repeated (++ lefts) (analysis.pattern/unit)) (list (analysis.pattern/text value)))) (analysis.pattern/tuple ($_ list\compose (list.repeated lefts (analysis.pattern/unit)) @@ -299,7 +299,7 @@ #analysis.then (analysis.frac body)}))]] (in [(list\fold (function (_ left right) (#synthesis.Alt left right)) - (path (inc mid_size) true value/last body/last) + (path (++ mid_size) true value/last body/last) (|> (list.zipped/2 value/mid body/mid) (#.Item [value/first body/first]) list.enumeration @@ -310,8 +310,8 @@ (list\compose (|> (list.zipped/2 value/mid body/mid) list.enumeration (list\map (function (_ [lefts' [value body]]) - (branch (inc lefts') false value body)))) - (list (branch (inc mid_size) true value/last body/last)))]]))) + (branch (++ lefts') false value body)))) + (list (branch (++ mid_size) true value/last body/last)))]]))) (def: random_complex ($_ random.either diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 692a2fab9..a25bd787c 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -146,7 +146,7 @@ (def: (random_variable arity output?) (-> Arity Scenario) (do {! random.monad} - [register (\ ! map (|>> (n.% arity) inc) random.nat)] + [register (\ ! map (|>> (n.% arity) ++) random.nat)] (in [(not (n.= 0 register)) (synthesis.variable/local register) (if (n.= arity register) @@ -194,20 +194,20 @@ (synthesis.path/then expected_output)) (synthesis.path/seq (synthesis.path/text text_test) (synthesis.path/then expected_output)) - (synthesis.path/seq (synthesis.path/bind (inc arity)) + (synthesis.path/seq (synthesis.path/bind (++ arity)) (synthesis.path/then expected_output)) ($_ synthesis.path/seq (synthesis.path/side side|member) - (synthesis.path/bind (inc arity)) + (synthesis.path/bind (++ arity)) (synthesis.path/then expected_output)) (if right? ($_ synthesis.path/seq (synthesis.path/member side|member) - (synthesis.path/bind (inc arity)) + (synthesis.path/bind (++ arity)) (synthesis.path/then expected_output)) ($_ synthesis.path/seq (synthesis.path/member side|member) - (synthesis.path/bind (inc arity)) + (synthesis.path/bind (++ arity)) synthesis.path/pop (synthesis.path/then expected_output))))]) (#analysis.Case actual_input @@ -243,7 +243,7 @@ (in [(and loop?_input loop?_output) (synthesis.branch/let [expected_input - (inc arity) + (++ arity) expected_output]) (#analysis.Case actual_input [{#analysis.when (#analysis.Bind 2) @@ -323,7 +323,7 @@ true (list\map product.left resets)) (synthesis.loop/scope - {#synthesis.start (inc arity) + {#synthesis.start (++ arity) #synthesis.inits (list\map (|>> product.right product.left) resets) #synthesis.iteration expected_output}) (analysis.apply [(..n_abstraction arity actual_output) @@ -342,7 +342,7 @@ Scenario (do {! random.monad} [[loop?_output expected_output actual_output] (..random_nat output?) - arity (|> random.nat (\ ! map (|>> (n.% 5) inc))) + arity (|> random.nat (\ ! map (|>> (n.% 5) ++))) .let [environment ($_ list\compose (list\map (|>> #variable.Foreign) (list.indices arity)) @@ -362,7 +362,7 @@ (-> Scenario Scenario) (do {! random.monad} [[loop?_abstraction expected_abstraction actual_abstraction] (..random_nat output?) - arity (|> random.nat (\ ! map (|>> (n.% 5) inc))) + arity (|> random.nat (\ ! map (|>> (n.% 5) ++))) inputs (random.list arity (random_value false))] (in [(list\fold (function (_ new old) (and new old)) @@ -418,7 +418,7 @@ (def: random_abstraction (Random [Synthesis Analysis]) (do {! random.monad} - [arity (|> random.nat (\ ! map (|>> (n.% 5) inc))) + [arity (|> random.nat (\ ! map (|>> (n.% 5) ++))) [loop? expected_body actual_body] (random_body arity true)] (in [(..n_function loop? arity expected_body) (..n_abstraction arity actual_body)]))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index 9aa7bdfe9..41dff47e9 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -55,7 +55,7 @@ (def: (variable offset arity next) (Scenario Variable) (let [local (do {! random.monad} - [register (\ ! map (|>> (n.% arity) inc) random.nat)] + [register (\ ! map (|>> (n.% arity) ++) random.nat)] (in [next [(#variable.Local (/.register_optimization offset register)) (#variable.Local register)]]))] @@ -139,7 +139,7 @@ [//.path/side] [//.path/member] )) - (random\in [(inc next) + (random\in [(++ next) [(//.path/bind (/.register_optimization offset next)) (//.path/bind next)]]) )))) @@ -182,7 +182,7 @@ ($_ random.either (do {! random.monad} [[next [recordE recordA]] (..reference offset arity next) - path_length (\ ! map (|>> (n.% 5) inc) random.nat) + path_length (\ ! map (|>> (n.% 5) ++) random.nat) path (random.list path_length random_member)] (in [next [(//.branch/get [path recordE]) @@ -267,7 +267,7 @@ ($_ _.and (do {! random.monad} [expected_offset (\ ! map (|>> (n.% 5) (n.+ 2)) random.nat) - arity (\ ! map (|>> (n.% 5) inc) random.nat) + arity (\ ! map (|>> (n.% 5) ++) random.nat) expected_inits (|> random.nat (\ ! map (|>> .i64 //.i64)) (random.list arity)) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux index a7fa786fb..014a77ac2 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux @@ -1,6 +1,7 @@ (.module: [lux #* - [abstract ["." monad (#+ do)]] + [abstract + ["." monad (#+ do)]] [data ["%" text/format (#+ format)] ["." name]] @@ -37,9 +38,9 @@ (do {! r.monad} [size (|> r.nat (\ ! map (|>> (n.% 10) (n.+ 2)))) tagA (|> r.nat (\ ! map (n.% size))) - .let [right? (n.= (dec size) tagA) + .let [right? (n.= (-- size) tagA) lefts (if right? - (dec tagA) + (-- tagA) tagA)] memberA //primitive.primitive] (_.test "Can synthesize variants." @@ -47,9 +48,9 @@ (//.phase archive.empty) (phase.result [///bundle.empty ////synthesis.init]) (case> (^ (#try.Success (////synthesis.variant [leftsS right?S valueS]))) - (let [tagS (if right?S (inc leftsS) leftsS)] + (let [tagS (if right?S (++ leftsS) leftsS)] (and (n.= tagA tagS) - (|> tagS (n.= (dec size)) (bit\= right?S)) + (|> tagS (n.= (-- size)) (bit\= right?S)) (//primitive.corresponds? memberA valueS))) _ diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 2678f8f77..10a6ca270 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -70,9 +70,9 @@ (do ! [let? random.bit [expected_input actual_input] (..primitive_scenario context) - .let [fake_register (n.+ (get@ #redundants context) - (dictionary.size (get@ #necessary context)))] - [expected_output actual_output] (scenario (update@ #redundants inc context))] + .let [fake_register (n.+ (value@ #redundants context) + (dictionary.size (value@ #necessary context)))] + [expected_output actual_output] (scenario (revised@ #redundants ++ context))] (in [(synthesis.branch/case [expected_input (#synthesis.Seq #synthesis.Pop (#synthesis.Then expected_output))]) @@ -95,7 +95,7 @@ (def: (tuple_scenario context) (Scenario Synthesis) - (let [registers (dictionary.entries (get@ #necessary context))] + (let [registers (dictionary.entries (value@ #necessary context))] (\ random.monad in [(synthesis.tuple (list\map (|>> product.left synthesis.variable/local) registers)) (synthesis.tuple (list\map (|>> product.right synthesis.variable/local) registers))]))) @@ -110,10 +110,10 @@ (do random.monad [_ (in []) [expected_input actual_input] (scenario context) - .let [real_register (dictionary.size (get@ #necessary context)) - fake_register (n.+ (get@ #redundants context) - (dictionary.size (get@ #necessary context)))] - [expected_output actual_output] (scenario (update@ #necessary (dictionary.has real_register fake_register) context))] + .let [real_register (dictionary.size (value@ #necessary context)) + fake_register (n.+ (value@ #redundants context) + (dictionary.size (value@ #necessary context)))] + [expected_output actual_output] (scenario (revised@ #necessary (dictionary.has real_register fake_register) context))] (in [(synthesis.branch/let [expected_input real_register expected_output]) (synthesis.branch/let [actual_input fake_register actual_output])]))) @@ -143,7 +143,7 @@ (def: (get_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do {! random.monad} - [length (\ ! map (|>> (n.% 5) inc) random.nat) + [length (\ ! map (|>> (n.% 5) ++) random.nat) path (random.list length ..random_member) [expected_record actual_record] (scenario context)] (in [(synthesis.branch/get [path expected_record]) @@ -166,10 +166,10 @@ (#synthesis.Then actual_then))])) (do {! random.monad} [_ (in []) - .let [real_register (dictionary.size (get@ #necessary context)) - fake_register (n.+ (get@ #redundants context) - (dictionary.size (get@ #necessary context)))] - [expected_then actual_then] (scenario (update@ #necessary (dictionary.has real_register fake_register) context))] + .let [real_register (dictionary.size (value@ #necessary context)) + fake_register (n.+ (value@ #redundants context) + (dictionary.size (value@ #necessary context)))] + [expected_then actual_then] (scenario (revised@ #necessary (dictionary.has real_register fake_register) context))] (in [(#synthesis.Seq (#synthesis.Bind real_register) (#synthesis.Seq #synthesis.Pop (#synthesis.Then expected_then))) @@ -238,19 +238,19 @@ (-> (Scenario Synthesis) (Scenario Synthesis)) (do {! random.monad} [_ (in []) - .let [real_start (dictionary.size (get@ #necessary context)) - fake_start (n.+ (get@ #redundants context) + .let [real_start (dictionary.size (value@ #necessary context)) + fake_start (n.+ (value@ #redundants context) real_start)] inits (random.list ..scope_arity (scenario context)) - [expected_iteration actual_iteration] (scenario (update@ #necessary - (function (_ necessary) - (list\fold (function (_ [idx _] context) - (dictionary.has (n.+ real_start idx) - (n.+ fake_start idx) - context)) - necessary - (list.enumeration inits))) - context))] + [expected_iteration actual_iteration] (scenario (revised@ #necessary + (function (_ necessary) + (list\fold (function (_ [idx _] context) + (dictionary.has (n.+ real_start idx) + (n.+ fake_start idx) + context)) + necessary + (list.enumeration inits))) + context))] (in [(synthesis.loop/scope [real_start (list\map product.left inits) expected_iteration]) (synthesis.loop/scope [fake_start (list\map product.right inits) actual_iteration])]))) @@ -273,7 +273,7 @@ (-> (Scenario Synthesis) (Scenario Synthesis)) (do {! random.monad} [_ (in []) - .let [registers (dictionary.entries (get@ #necessary context)) + .let [registers (dictionary.entries (value@ #necessary context)) expected_environment (list\map (|>> product.left #variable.Local) registers) actual_environment (list\map (|>> product.right #variable.Local) registers)] [expected_body actual_body] (..primitive_scenario context)] diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index 8c135b590..65920eca9 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -45,27 +45,32 @@ (Random Name) (random.and ..short ..short)) -(def: .public (random parameters) +(def: (random' parameters) (-> Nat (Random Type)) (random.rec (function (_ recur) (let [pairG (random.and recur recur) - quantifiedG (random.and (random\in (list)) recur) un_parameterized (: (Random Type) ($_ random.either - (random\map (|>> #.Primitive) (random.and ..short (random\in (list)))) + (random\map (|>> #.Primitive) (random.and ..short (random.list 0 recur))) + (random\map (|>> #.Primitive) (random.and ..short (random.list 1 recur))) + (random\map (|>> #.Primitive) (random.and ..short (random.list 2 recur))) (random\map (|>> #.Sum) pairG) (random\map (|>> #.Product) pairG) (random\map (|>> #.Function) pairG) - (random\map (|>> #.UnivQ) quantifiedG) - (random\map (|>> #.ExQ) quantifiedG) - (random\map (|>> #.Apply) pairG) - (random\map (|>> #.Named) (random.and ..name recur)) ))] (case parameters 0 un_parameterized - _ (random.either un_parameterized - (random\map (|>> (n.% parameters) #.Parameter) random.nat))))))) + _ (|> random.nat + (random\map (|>> (n.% parameters) #.Parameter)) + (random.either un_parameterized))))))) + +(def: .public (random parameters) + (-> Nat (Random Type)) + ($_ random.either + (random\map (/.univ_q parameters) (random' parameters)) + (random\map (/.ex_q parameters) (random' parameters)) + )) (def: .public test Test @@ -98,7 +103,7 @@ _ #1))) (list.repeated size) - (monad.seq !)) + (monad.all !)) .let [(^open "/\.") /.equivalence (^open "list\.") (list.equivalence /.equivalence)]] (`` ($_ _.and @@ -123,7 +128,7 @@ (case> #.None #1 _ #0)))) (do {! random.monad} [size (|> random.nat (\ ! map (n.% 3))) - members (monad.seq ! (list.repeated size (..random 0))) + members (monad.all ! (list.repeated size (..random 0))) extra (|> (..random 0) (random.only (function (_ type) (case type @@ -144,7 +149,7 @@ (n.= (list.size members) (list.size tparams)))) )) (do {! random.monad} - [size (|> random.nat (\ ! map (|>> (n.% 3) inc))) + [size (|> random.nat (\ ! map (|>> (n.% 3) ++))) body_type (|> (..random 0) (random.only (function (_ type) (case type @@ -170,7 +175,7 @@ (|> body_type (/.ex_q size) /.quantified?))) ))) (do {! random.monad} - [depth (|> random.nat (\ ! map (|>> (n.% 3) inc))) + [depth (|> random.nat (\ ! map (|>> (n.% 3) ++))) element_type (|> (..random 0) (random.only (function (_ type) (case type diff --git a/stdlib/source/test/lux/type/abstract.lux b/stdlib/source/test/lux/type/abstract.lux index 6275647d0..f8fe3c6a3 100644 --- a/stdlib/source/test/lux/type/abstract.lux +++ b/stdlib/source/test/lux/type/abstract.lux @@ -28,7 +28,7 @@ [(syntax: (<syntax> []) (do meta.monad [frame <meta>] - (in (list (code.text (get@ #/.name frame))))))] + (in (list (code.text (value@ #/.name frame))))))] [current /.current] [specific (/.specific (template.text [g!Foo]))] diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index 1875d4fc8..d148e9fdc 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -43,7 +43,7 @@ (random.rec (function (_ recur) (let [pairG (random.and recur recur) - quantifiedG (random.and (random\in (list)) (type' (inc num_vars))) + quantifiedG (random.and (random\in (list)) (type' (++ num_vars))) random_pair (random.either (random.either (random\map (|>> #.Sum) pairG) (random\map (|>> #.Product) pairG)) (random.either (random\map (|>> #.Function) pairG) @@ -52,7 +52,7 @@ (random\map (|>> #.Ex) random.nat))] (case num_vars 0 random_id - _ (random.either (random\map (|>> (n.% num_vars) (n.* 2) inc #.Parameter) random.nat) + _ (random.either (random\map (|>> (n.% num_vars) (n.* 2) ++ #.Parameter) random.nat) random_id))) random_quantified (random.either (random\map (|>> #.UnivQ) quantifiedG) (random\map (|>> #.ExQ) quantifiedG))] @@ -220,10 +220,10 @@ (do random.monad [nominal (random.ascii/upper 10) .let [expected (#.Primitive nominal (list))]] - (_.cover [/.read] + (_.cover [/.read'] (and (|> (do /.monad [[var_id var_type] /.var] - (/.read var_id)) + (/.read' var_id)) (/.result /.fresh_context) (case> (#try.Success #.None) true _ false)) @@ -231,14 +231,14 @@ [[var_id var/0] /.var [_ var/1] /.var _ (/.check var/0 var/1)] - (/.read var_id)) + (/.read' var_id)) (/.result /.fresh_context) (case> (#try.Success #.None) true _ false)) (|> (do /.monad [[var_id var_type] /.var _ (/.bind expected var_id)] - (/.read var_id)) + (/.read' var_id)) (/.result /.fresh_context) (case> (#try.Success (#.Some actual)) (same? expected actual) @@ -248,12 +248,12 @@ (do random.monad [nominal (random.ascii/upper 10) .let [expected (#.Primitive nominal (list))]] - (_.cover [/.read!] + (_.cover [/.read] (case (/.result /.fresh_context (do /.monad [[var_id var_type] /.var _ (/.bind expected var_id)] - (/.read! var_id))) + (/.read var_id))) (#try.Success actual) (same? expected actual) @@ -266,7 +266,7 @@ (case (/.result /.fresh_context (do /.monad [[var_id var_type] /.var] - (/.read! var_id))) + (/.read var_id))) (#try.Failure error) (exception.match? /.unbound_type_var error) @@ -278,9 +278,9 @@ Test ($_ _.and (_.cover [/.fresh_context] - (and (n.= 0 (get@ #.var_counter /.fresh_context)) - (n.= 0 (get@ #.ex_counter /.fresh_context)) - (list.empty? (get@ #.var_bindings /.fresh_context)))) + (and (n.= 0 (value@ #.var_counter /.fresh_context)) + (n.= 0 (value@ #.ex_counter /.fresh_context)) + (list.empty? (value@ #.var_bindings /.fresh_context)))) (_.cover [/.context] (and (case (/.result /.fresh_context /.context) (#try.Success actual) @@ -293,9 +293,9 @@ [_ /.var] /.context)) (#try.Success actual) - (and (n.= 1 (get@ #.var_counter actual)) - (n.= 0 (get@ #.ex_counter actual)) - (n.= 1 (list.size (get@ #.var_bindings actual)))) + (and (n.= 1 (value@ #.var_counter actual)) + (n.= 0 (value@ #.ex_counter actual)) + (n.= 1 (list.size (value@ #.var_bindings actual)))) (#try.Failure error) false))) @@ -305,9 +305,9 @@ [_ /.existential] /.context)) (#try.Success actual) - (and (n.= 0 (get@ #.var_counter actual)) - (n.= 1 (get@ #.ex_counter actual)) - (n.= 0 (list.size (get@ #.var_bindings actual)))) + (and (n.= 0 (value@ #.var_counter actual)) + (n.= 1 (value@ #.ex_counter actual)) + (n.= 0 (list.size (value@ #.var_bindings actual)))) (#try.Failure error) false)) @@ -703,7 +703,7 @@ (-> Nat (Random Type)) (do random.monad [primitive (random.ascii/upper 3) - parameters (random.list parameters (primitive_type (dec parameters)))] + parameters (random.list parameters (primitive_type (-- parameters)))] (in (#.Primitive primitive parameters)))) (def: clean_type diff --git a/stdlib/source/test/lux/type/implicit.lux b/stdlib/source/test/lux/type/implicit.lux index d032f19c5..f50bd57e7 100644 --- a/stdlib/source/test/lux/type/implicit.lux +++ b/stdlib/source/test/lux/type/implicit.lux @@ -39,8 +39,8 @@ (let [(^open "list\.") (list.equivalence n.equivalence)] (and (bit\= (\ n.equivalence = left right) (/.\\ = left right)) - (list\= (\ list.functor map inc (enum.range n.enum start end)) - (/.\\ map inc (enum.range n.enum start end))))) + (list\= (\ list.functor map ++ (enum.range n.enum start end)) + (/.\\ map ++ (enum.range n.enum start end))))) second_order! (/.\\ = diff --git a/stdlib/source/test/lux/type/refinement.lux b/stdlib/source/test/lux/type/refinement.lux index cf69e9243..5942e2a84 100644 --- a/stdlib/source/test/lux/type/refinement.lux +++ b/stdlib/source/test/lux/type/refinement.lux @@ -32,7 +32,7 @@ modulus (\ ! map (|>> (n.% 10) (n.+ 2)) random.nat) .let [predicate (: (Predicate Nat) (|>> (n.% modulus) (n.= 0)))] - total_raws (\ ! map (|>> (n.% 20) inc) random.nat) + total_raws (\ ! map (|>> (n.% 20) ++) random.nat) raws (random.list total_raws random.nat)] ($_ _.and (_.for [/.Refiner] @@ -60,9 +60,9 @@ (maybe\map (|>> /.value (n.= (n.+ modulus modulus)))) (maybe.else false)) (|> (/.refiner predicate modulus) - (maybe\map (/.lifted (n.+ (inc modulus)))) + (maybe\map (/.lifted (n.+ (++ modulus)))) maybe\join - (maybe\map (|>> /.value (n.= (n.+ modulus (inc modulus))))) + (maybe\map (|>> /.value (n.= (n.+ modulus (++ modulus))))) (maybe.else false) not))) (_.cover [/.only] diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux index 0bbff685f..0e7369716 100644 --- a/stdlib/source/test/lux/world/file/watch.lux +++ b/stdlib/source/test/lux/world/file/watch.lux @@ -118,7 +118,7 @@ (def: (after_modification! fs watcher data expected_path) (-> (//.System Async) (/.Watcher Async) Binary //.Path (Async (Try Bit))) (do (try.with async.monad) - [_ (async.delayed 1 (#try.Success "Delay to make sure the over_write time-stamp always changes.")) + [_ (async.after 1 (#try.Success "Delay to make sure the over_write time-stamp always changes.")) _ (\ fs write data expected_path) poll/2 (\ watcher poll []) poll/2' (\ watcher poll [])] diff --git a/stdlib/source/test/lux/world/input/keyboard.lux b/stdlib/source/test/lux/world/input/keyboard.lux index 67ce892fe..865a66a9d 100644 --- a/stdlib/source/test/lux/world/input/keyboard.lux +++ b/stdlib/source/test/lux/world/input/keyboard.lux @@ -112,13 +112,13 @@ /.f24]])] (def: listing (List /.Key) - (list.joined (`` (list (~~ (template [<definition> <keys>] - [((: (-> Any (List /.Key)) - (function (_ _) - (`` (list (~~ (template.spliced <keys>)))))) - [])] - - <groups>)))))) + (list.together (`` (list (~~ (template [<definition> <keys>] + [((: (-> Any (List /.Key)) + (function (_ _) + (`` (list (~~ (template.spliced <keys>)))))) + [])] + + <groups>)))))) (def: catalogue (Set /.Key) @@ -160,8 +160,8 @@ [key ..random .let [sample (<function> key)]] (_.cover [<function>] - (and (bit\= <pressed?> (get@ #/.pressed? sample)) - (n.= key (get@ #/.input sample)))))] + (and (bit\= <pressed?> (value@ #/.pressed? sample)) + (n.= key (value@ #/.input sample)))))] [#0 /.release] [#1 /.press] diff --git a/stdlib/source/test/lux/world/net/http/client.lux b/stdlib/source/test/lux/world/net/http/client.lux index 24ece9d1e..c9b3f12c9 100644 --- a/stdlib/source/test/lux/world/net/http/client.lux +++ b/stdlib/source/test/lux/world/net/http/client.lux @@ -70,7 +70,7 @@ (|> (<definition> "" //.empty #.None mock) (do> try.monad [io.run!] - [product.right (get@ #//.body) (function.apply #.None) io.run!] + [product.right (value@ #//.body) (function.on #.None) io.run!] [product.right (\ utf8.codec decode)] [(\ nat.decimal decode)] [(nat.= <expected>) in]) diff --git a/stdlib/source/test/lux/world/net/http/status.lux b/stdlib/source/test/lux/world/net/http/status.lux index 84cbd6355..c93f5b083 100644 --- a/stdlib/source/test/lux/world/net/http/status.lux +++ b/stdlib/source/test/lux/world/net/http/status.lux @@ -84,13 +84,13 @@ /.network_authentication_required]])] (def: all (List //.Status) - (list.joined (`` (list (~~ (template [<category> <status+>] - [((: (-> Any (List //.Status)) - (function (_ _) - (`` (list (~~ (template.spliced <status+>)))))) - 123)] - - <categories>)))))) + (list.together (`` (list (~~ (template [<category> <status+>] + [((: (-> Any (List //.Status)) + (function (_ _) + (`` (list (~~ (template.spliced <status+>)))))) + 123)] + + <categories>)))))) (def: unique (Set //.Status) diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/program.lux index 879d1f60f..6f5784daf 100644 --- a/stdlib/source/test/lux/world/program.lux +++ b/stdlib/source/test/lux/world/program.lux @@ -42,7 +42,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [env_size (\ ! map (|>> (n.% 10) inc) random.nat) + [env_size (\ ! map (|>> (n.% 10) ++) random.nat) environment (..environment env_size) home ..path directory ..path |