diff --git a/documentation/bookmark/compilation/target/c++.md b/documentation/bookmark/compilation/target/c++.md index 088802cc8f..1853c0e74a 100644 --- a/documentation/bookmark/compilation/target/c++.md +++ b/documentation/bookmark/compilation/target/c++.md @@ -21,6 +21,7 @@ # Reference +0. [InstantC](https://gitlab.com/jlinhoff/instantc) 0. [Lightning Talk: Writing a Better std::move - Jonathan Müller - CppCon 2023](https://www.youtube.com/watch?v=hvnl6T2MnUk) 0. [CppCon 2018: Tom Poole “Why and How to Roll Your Own std::function Implementation”](https://www.youtube.com/watch?v=VY83afAJUIg) 0. [Writing custom C++20 coroutine systems](https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/coroutines-c++20/) diff --git a/documentation/bookmark/compilation/target/c.md b/documentation/bookmark/compilation/target/c.md index 2e4d681ea1..0d19a213ed 100644 --- a/documentation/bookmark/compilation/target/c.md +++ b/documentation/bookmark/compilation/target/c.md @@ -1,5 +1,6 @@ # Reference +0. [InstantC](https://gitlab.com/jlinhoff/instantc) 0. [Can you use a class in C?](https://thasso.xyz/2023/08/11/can-you-use-a-class-in-c/) 0. [Few lesser known tricks, quirks and features of C](https://jorengarenar.github.io/blog/less-known-c) 0. [Portability and the C Language](https://en.wikibooks.org/wiki/Portability_and_the_C_Language) diff --git a/documentation/bookmark/compilation/target/wasm__web_assembly.md b/documentation/bookmark/compilation/target/wasm__web_assembly.md index 50cf802568..d6be39bd4c 100644 --- a/documentation/bookmark/compilation/target/wasm__web_assembly.md +++ b/documentation/bookmark/compilation/target/wasm__web_assembly.md @@ -16,7 +16,6 @@ # Exemplar -0. []() 0. [Announcing GraalWasm — a WebAssembly engine in GraalVM](https://medium.com/graalvm/announcing-graalwasm-a-webassembly-engine-in-graalvm-25cd0400a7f2) 0. [Towards a WebAssembly standalone runtime on GraalVM](https://dl.acm.org/citation.cfm?id=3362780) 0. https://github.com/vvanders/wasm_lua @@ -25,6 +24,7 @@ # Reference +0. [GraalWasm: A high-performance embeddable WebAssembly runtime for Java](https://www.graalvm.org/webassembly/) 0. [Awesome WebAssembly runtimes](https://github.com/jcbhmr/awesome-webassembly-runtimes) 0. [Chicory Runtime](https://github.com/dylibso/chicory) 0. [A zero dependency Wasm runtime for the JVM](https://www.javaadvent.com/2023/12/chicory-wasm-jvm.html) diff --git a/documentation/bookmark/investing.md b/documentation/bookmark/investing.md index 1329cb7e33..2f9dee672b 100644 --- a/documentation/bookmark/investing.md +++ b/documentation/bookmark/investing.md @@ -1,5 +1,6 @@ # Reference +0. [The Ultimate Investors List of Lists: Venture Capital funds, Family Offices, Accelerators, CVCs, and Angel Investors](https://thevccorner.substack.com/p/the-ultimate-investor-list-of-lists) 0. [3 Investing Patterns That You Should Know](https://behavioralvalueinvestor.substack.com/p/3-investing-patterns-that-you-should) 0. [Predictably Bad Investments: Evidence from Venture Capitalists](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4135861) 0. [Launch YC: The Launchpad for YC Startups](https://www.ycombinator.com/blog/launch-yc-the-launchpad-for-yc-startups) diff --git a/documentation/bookmark/play/game/mechanic/luck.md b/documentation/bookmark/play/game/mechanic/luck.md new file mode 100644 index 0000000000..756609d50f --- /dev/null +++ b/documentation/bookmark/play/game/mechanic/luck.md @@ -0,0 +1,4 @@ +# Reference + +0. [What Makes A Good Luck Mechanic?](https://youtu.be/4cmGSMDOrfc) + diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index fa20bcdc14..c7be45f5e2 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -67,7 +67,9 @@ ["[1]" ruby]]]] ["[0]" world ["[0]" file] - ["[1]/[0]" environment]]]] + ["[1]/[0]" environment]] + [aspect + ["[0]" view]]]] [program ["/" compositor]]) @@ -911,7 +913,7 @@ [info source provenance current_module modules scopes type_context expected seed eval]))) _ - (exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs])) + (exception.except ..invaid_phase_application [(view.of list.stack partial_application) inputs])) (list) {try.#Success (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) @@ -934,7 +936,7 @@ input/0))) _ - (exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs])) + (exception.except ..invaid_phase_application [(view.of list.stack partial_application) inputs])) (list input/0 input/1) (when partial_application @@ -949,7 +951,7 @@ input/1))) _ - (exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs])) + (exception.except ..invaid_phase_application [(view.of list.stack partial_application) inputs])) (list input/0 input/1 input/2) (when partial_application @@ -960,10 +962,10 @@ input/2))) _ - (exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs])) + (exception.except ..invaid_phase_application [(view.of list.stack partial_application) inputs])) _ - (exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs])))))] + (exception.except ..invaid_phase_application [(view.of list.stack partial_application) inputs])))))] (org/jruby/RubyProc::newProc [(!ruby_runtime) block ..proc_type]))) (the phase_wrapper diff --git a/stdlib/source/injection/lux/data/text.lux b/stdlib/source/injection/lux/data/text.lux index 5548dcfca8..858aa40a76 100644 --- a/stdlib/source/injection/lux/data/text.lux +++ b/stdlib/source/injection/lux/data/text.lux @@ -25,7 +25,9 @@ [arithmetic ["[0]" modular]]] [macro - ["[0]" template]]]]) + ["[0]" template]] + [aspect + ["[0]" view]]]]) (template.with [ ] [(the .public @@ -36,8 +38,7 @@ [integer Integer (by integer.base_10 as)] [revolution Revolution (by revolution.base_10 as)] [decimal Decimal (by decimal.base_10 as)] - [text Text text.as_text]] - ) + [text Text text.as_text]]) (template.with [,name] [(the .public ,name @@ -52,8 +53,7 @@ [[degree] [per_cent] [per_mille] - [per_myriad]] - ) + [per_myriad]]) (template.with [ ,] [(`` (template.with [ ] @@ -61,8 +61,7 @@ (Injection ) (by as))] - , - ))] + ,))] [[Natural [[natural_02 natural.base_02] @@ -83,8 +82,7 @@ [[decimal_02 decimal.base_02] [decimal_08 decimal.base_08] [decimal_10 decimal.base_10] - [decimal_16 decimal.base_16]]]] - ) + [decimal_16 decimal.base_16]]]]) (the .public (padded padding as) (-> Natural (Injection Natural) @@ -104,7 +102,7 @@ (for_any (_ it) (-> (Injection it) (Injection (Stack it)))) - (|>> list.of_stack + (|>> (view.of list.stack) (list#each (|>> as (.text " "))) text.together (text.enclosed ["(stack" ")"]))) diff --git a/stdlib/source/library/lux/aspect/view.lux b/stdlib/source/library/lux/aspect/view.lux index 6fb475ebfb..98db7ce523 100644 --- a/stdlib/source/library/lux/aspect/view.lux +++ b/stdlib/source/library/lux/aspect/view.lux @@ -4,8 +4,7 @@ ... [Profunctor Optics: Modular Data Accessors](https://arxiv.org/abs/1703.10857) (.using [library - [lux (.except macro - as) + [lux (.except macro as with) [abstract [functor ["[0]" pro]]] @@ -16,10 +15,6 @@ (<| (.in_module# .prelude) .template#macro)) -(the with_template - (<| (.in_module# .prelude) - .with_template)) - (the Of' (macro (_ context context' analogy analogy') @@ -61,6 +56,10 @@ [#of of #as as]) +(the with_template + (<| (.in_module# .prelude) + .with_template)) + (with_template [,name ,type ,tag] [(the .public ,name (for_any (_ context analogy) @@ -69,8 +68,7 @@ (.its ,tag))] [[of Of #of] - [as As #as]] - ) + [as As #as]]) (the .public identity (for_any (_ it) @@ -97,7 +95,7 @@ (for_any (_ context context' analogy analogy') (-> (View' context context' analogy analogy') (Aspect context context' analogy analogy'))) - (<| (with pro_functor) + (<| (.with pro_functor) (each /#as /#of))) (the .public (of_aspect =>) @@ -108,3 +106,12 @@ (=> [..functor] [#of function.identity #as function.identity])) + +(the .public (with it change) + (for_any (_ context analogy) + (-> (View context analogy) + (-> (Change analogy) + (Change context)))) + (|>> (as it) + change + (of it))) diff --git a/stdlib/source/library/lux/compiler/default/platform.lux b/stdlib/source/library/lux/compiler/default/platform.lux index 507d26cc75..a4f7003509 100644 --- a/stdlib/source/library/lux/compiler/default/platform.lux +++ b/stdlib/source/library/lux/compiler/default/platform.lux @@ -39,7 +39,9 @@ ["[1]/[0]" module]] [world ["[0]" file (.only Path)] - ["[0]" console]]]] + ["[0]" console]] + [aspect + ["[0]" view]]]] ["[0]" // ["[1][0]" init] ["/[1]" // (.only) @@ -724,7 +726,7 @@ compilation_sources (its context.#host_module_extension context) module)] - (loop (again [customs (list.as_stack all_customs)]) + (loop (again [customs (view.as list.stack all_customs)]) (when customs {.#Empty} ((..lux_compiler import context platform compilation_sources configuration compiler (compiler input)) diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/coverage.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/coverage.lux index f3ca69bbb5..29a0c67b12 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/coverage.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/coverage.lux @@ -36,7 +36,9 @@ [macro ["^" pattern] ["[0]" template] - ["[0]" expansion]]]] + ["[0]" expansion]] + [aspect + ["[0]" view]]]] ["[0]" // ["[1][0]" simple] ["[1][0]" complex] @@ -134,8 +136,8 @@ (and (n.= (stack.size flatR) (stack.size flatS)) (list.every? (function (_ [coverageR coverageS]) (= coverageR coverageS)) - (list.zipped_2 (list.of_stack flatR) - (list.of_stack flatS))))) + (list.zipped_2 (view.of list.stack flatR) + (view.of list.stack flatS))))) _ false))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux index 81f303d98e..22faf39f2e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux @@ -29,7 +29,9 @@ ["[0]" check]] ["[0]" meta (.only) ["[0]" code] - ["[0]" module]]]] + ["[0]" module]] + [aspect + ["[0]" view]]]] ["/" // (.only Operation Phase) ["[1][0]" type] [// @@ -99,7 +101,7 @@ (Operation Nothing)) (do phase.monad [here module.current_name] - (/.except ..cannot_infer [here inference (list.of_stack arguments)]))) + (/.except ..cannot_infer [here inference (view.of list.stack arguments)]))) ... Type-inference works by applying some (potentially quantified) type ... to a sequence of values. @@ -249,11 +251,11 @@ (|> it type.flat_variant (list.after lefts) - list.as_stack + (view.as list.stack) (pipe.when {.#Top head tail} (let [case (if right? - (type.variant (list.of_stack tail)) + (type.variant (view.of list.stack tail)) head)] (-> (if (n.= 0 depth) case diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/scope.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/scope.lux index 404e0961b2..c78a4d793e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/scope.lux @@ -21,7 +21,9 @@ ["[0]" property]] ["[0]" stack (.use "[1]#[0]" functor mix monoid)]]] [compiler - ["@[0]" type]]]] + ["@[0]" type]] + [aspect + ["[0]" view]]]] ["/" // (.only Environment Operation Phase) [// ["[0]" phase] @@ -63,7 +65,9 @@ (-> Text @type.Scope (Maybe [@type.Type Variable])) (loop (again [idx 0 - mappings (list.as_stack (its [@type.#captured @type.#mappings] scope))]) + mappings (|> scope + (its [@type.#captured @type.#mappings]) + (view.as list.stack))]) (when mappings {.#Top [_name [_source_type _source_ref]] mappings'} (if (text.= name _name) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis.lux index 964c974f5e..4a51c1e641 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis.lux @@ -29,7 +29,9 @@ ["[0]" binding] ["[0]" provenance] ["[0]" code] - ["[0]" module]]]] + ["[0]" module]] + [aspect + ["[0]" view]]]] ["[0]" / ["[1][0]" simple] ["[1][0]" complex] @@ -169,7 +171,7 @@ {#Macro name macro} (do ! - [expansion (/macro.single_expansion expander name macro (list.of_stack argsC+))] + [expansion (/macro.single_expansion expander name macro (view.of list.stack argsC+))] (analysis archive expansion)) {#Extension abstraction} @@ -177,7 +179,7 @@ [lux //.state] (extension.reification extender lux analysis archive - .Analysis abstraction (list.of_stack argsC+) + .Analysis abstraction (view.of list.stack argsC+) (|>>) (function (_ _) {.#None})))))])) @@ -206,7 +208,7 @@ (/reference.reference extender analysis archive quoted_module it) {@type.#Form _ elems} - (when (list.as_stack elems) + (when (view.as list.stack elems) (stack.partial functionC argsC+) (..reification extender expander analysis archive functionC argsC+) @@ -214,15 +216,15 @@ failure) {@type.#Variant _ elems} - (when (list.as_stack elems) + (when (view.as list.stack elems) (stack.partial {@type.#Name _ tag} values) - (..variant_analysis analysis archive tag (list.of_stack values)) + (..variant_analysis analysis archive tag (view.of list.stack values)) (stack.partial {@type.#Bit _ right?} values) - (..sum_analysis analysis archive 0 right? (list.of_stack values)) + (..sum_analysis analysis archive 0 right? (view.of list.stack values)) (stack.partial {@type.#Natural _ lefts} {@type.#Bit _ right?} values) - (..sum_analysis analysis archive lefts right? (list.of_stack values)) + (..sum_analysis analysis archive lefts right? (view.of list.stack values)) _ failure) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/complex.lux index acc9aec60f..c45cc5f931 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/complex.lux @@ -39,7 +39,9 @@ ["[0]" binding (.only) ["[0]" local]]] [function - [predicate (.only Predicate)]]]] + [predicate (.only Predicate)]] + [aspect + ["[0]" view]]]] ["[0]" // ["[1][0]" simple] [/// @@ -218,10 +220,10 @@ (Operation /.Term)) (<| (do [! phase.monad] [@ meta.provenance]) - (by ! each (|>> list.of_stack (/.tuple @))) + (by ! each (|>> (view.of list.stack) (/.tuple @))) (is (Operation (Stack /.Term))) - (loop (again [membersT+ (list.as_stack (type.flat_tuple expectedT)) - membersC+ (list.as_stack members)]) + (loop (again [membersT+ (view.as list.stack (type.flat_tuple expectedT)) + membersC+ (view.as list.stack members)]) (when [membersT+ membersC+] [{.#Top memberT {.#Empty}} {.#Top memberC {.#Empty}}] (<| (by ! each (|>> stack)) @@ -231,10 +233,10 @@ [{.#Top memberT {.#Empty}} _] (<| (/type.expecting memberT) (by ! each (|>> stack)) - (analyse archive (code.tuple (list.of_stack membersC+)))) + (analyse archive (code.tuple (view.of list.stack membersC+)))) [_ {.#Top memberC {.#Empty}}] - (<| (/type.expecting (type.tuple (list.of_stack membersT+))) + (<| (/type.expecting (type.tuple (view.of list.stack membersT+))) (by ! each (|>> stack) (analyse archive memberC))) [{.#Top memberT membersT+'} {.#Top memberC membersC+'}] @@ -328,7 +330,7 @@ (the .public (normal pattern_matching? record) (-> Bit (List @type.Code) (Operation (Maybe (Stack [Name @type.Code])))) - (loop (again [input (list.as_stack record) + (loop (again [input (view.as list.stack record) output (is (Stack [Name @type.Code]) {.#Empty})]) (when input @@ -399,7 +401,7 @@ (the sorted_record (Change (Stack [@type.Label @type.Code])) - (|>> list.of_stack + (|>> (view.of list.stack) (list.sorted (function (_ left right) (when [left right] [[[{.#Some [leftsL right?L familyL]} typeL] valueL] @@ -410,7 +412,7 @@ _ false))) - list.as_stack)) + (view.as list.stack))) ... Lux already possesses the means to analyse tuples, so ... re-implementing the same functionality for records makes no sense. @@ -430,9 +432,9 @@ (do ! [.let [record (sorted_record record)] here module.current_name - _ (phase.assertion ..cannot_order_record [here (` ..same_record?) (list.of_stack original_record)] + _ (phase.assertion ..cannot_order_record [here (` ..same_record?) (view.of list.stack original_record)] (same_record? record)) - _ (phase.assertion ..cannot_order_record [here (` ..complete_record?) (list.of_stack original_record)] + _ (phase.assertion ..cannot_order_record [here (` ..complete_record?) (view.of list.stack original_record)] (complete_record? record))] (pure (<| try.maybe (do try.monad @@ -515,7 +517,7 @@ [inferenceT (/inference.record record_size recordT) [inferredT membersA] (/inference.general archive analyse inferenceT membersC) @ meta.provenance] - (pure (/.tuple @ (list.of_stack membersA)))) + (pure (/.tuple @ (view.of list.stack membersA)))) _ - (..product analyse archive (list.of_stack membersC)))))))))) + (..product analyse archive (view.of list.stack membersC)))))))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/function.lux index f37d78f314..1ac86d178f 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/function.lux @@ -27,7 +27,9 @@ ["[0]" code] ["[0]" module]] [compiler - ["@[0]" type]]]] + ["@[0]" type]] + [aspect + ["[0]" view]]]] [//// ["[0]" phase (.use "[1]#[0]" functor)] ["/" analysis (.only Operation Phase) @@ -52,7 +54,7 @@ (list ["Function type" (type.as_text :function:)] ["Function" (code.relative module functionC)] ["Arguments" (|> arguments - list.of_stack + (view.of list.stack) list.enumeration (list#each (.function (_ [idx argC]) (text (%.natural idx) " " (code.relative module argC)))) @@ -145,5 +147,5 @@ (do phase.monad [here module.current_name] (|> (/inference.general archive analyse :function: argsC+) - (phase#each (|>> product.right list.of_stack [functionA] /.reified)) + (phase#each (|>> product.right (view.of list.stack) [functionA] /.reified)) (/.with_exception ..cannot_reify [here :function: functionC argsC+])))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux index f975b8b13d..64e1beb8c6 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux @@ -32,7 +32,9 @@ ["[0]" binding] ["[0]" code] ["[0]" label] - ["[0]" module]]]] + ["[0]" module]] + [aspect + ["[0]" view]]]] ["[0]" // ["[1][0]" complex] [/// @@ -81,7 +83,7 @@ (exception.report (.list ["Input" (code.relative module input)] ["Branches" (|> branches - list.of_stack + (view.of list.stack) (list#each (function (_ [slot value]) (.list slot value))) list#conjoint @@ -244,7 +246,7 @@ [[@ex_var+ :input:'] (/type.check (..tuple :input:))] (.when :input:' (type.Product _ _) - (let [matches (loop (again [types (list.as_stack (type.flat_tuple :input:')) + (let [matches (loop (again [types (view.as list.stack (type.flat_tuple :input:')) patterns sub_patterns output (is (Stack [Type @type.Code]) {.#Empty})]) @@ -256,10 +258,10 @@ {.#Top [headT headP] output} [remainingT {.#Top headP {.#Empty}}] - {.#Top [(type.tuple (list.of_stack remainingT)) headP] output} + {.#Top [(type.tuple (view.of list.stack remainingT)) headP] output} [{.#Top headT {.#Empty}} remainingP] - {.#Top [headT (code.tuple (list.of_stack remainingP))] output} + {.#Top [headT (code.tuple (view.of list.stack remainingP))] output} [{.#Top headT tailT} {.#Top headP tailP}] (again tailT tailP {.#Top [headT headP] output}) @@ -284,13 +286,13 @@ (pure [(stack) nextA])) matches) _ (/type.check (stack.each' check.monad check.forget! @ex_var+))] - (pure [(/pattern.tuple (list.of_stack memberP+)) + (pure [(/pattern.tuple (view.of list.stack memberP+)) thenA]))) _ (do ! [here module.current_name] - (/.except ..mismatch [here :input:' (code.tuple (list.of_stack sub_patterns))]))))) + (/.except ..mismatch [here :input:' (code.tuple (view.of list.stack sub_patterns))]))))) (the name_of_type_of_list (its @type.#name @type.list)) @@ -321,13 +323,13 @@ (pure [(stack) nextA])) (stack.reversed sub_patterns)) _ (/type.check (stack.each' check.monad check.forget! @ex_var+))] - (pure [(/pattern.list (list.of_stack sub_patterns)) + (pure [(/pattern.list (view.of list.stack sub_patterns)) thenA])) _ (do ! [here module.current_name] - (/.except ..mismatch [here type_of_input (` (.list# (,* (list.of_stack sub_patterns))))]))))) + (/.except ..mismatch [here type_of_input (` (.list# (,* (view.of list.stack sub_patterns))))]))))) (every (Analysis it) (-> Type @type.Code (Operation it) @@ -357,7 +359,7 @@ (n.= (-- size_sum) idx)) (type.variant (list.after (-- size_sum) flat_sum)) caseT) - (code.tuple (list.of_stack values)) + (code.tuple (view.of list.stack values)) next) _ (/type.check (stack.each' check.monad check.forget! @ex_var+))] (pure [(/pattern.variant [lefts right? testP]) @@ -458,10 +460,10 @@ (..tuple_pattern_analysis pattern_analysis :input: members next))) {.#None} - (..tuple_pattern_analysis pattern_analysis :input: (list.as_stack sub_patterns) next)))) + (..tuple_pattern_analysis pattern_analysis :input: (view.as list.stack sub_patterns) next)))) {@type.#Form provenance every_item} - (.when (list.as_stack every_item) + (.when (view.as list.stack every_item) (stack.partial {@type.#Name provenance [.prelude extension.list]} sub_patterns) (/.with_provenance provenance (..analysis_of_list pattern_analysis :input: sub_patterns next)) @@ -470,7 +472,7 @@ failure) {@type.#Variant provenance every_item} - (.when (list.as_stack every_item) + (.when (view.as list.stack every_item) (stack.partial {@type.#Bit _ right?} values) (anonymous_variant pattern_analysis :input: pattern next @@ -496,7 +498,7 @@ (pattern_analysis :input: (code.variant (.list (code.natural lefts) (code.bit right?) - (code.tuple (list.of_stack values)))) + (code.tuple (view.of list.stack values)))) next))) _ @@ -531,7 +533,7 @@ {try.#Failure error} (/.failure error)) @ meta.provenance] - (pure [@ {/.#When inputA [outputH (list.of_stack outputT)]}])) + (pure [@ {/.#When inputA [outputH (view.of list.stack outputT)]}])) {.#Empty} (/.except ..empty_branches []))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux index 729f01d3d0..68bd3088e2 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -72,7 +72,9 @@ ["[0]" signature] ["[0]" projection] ["[0]" alias (.only Aliasing)] - ["[0]T" lux (.only Mapping)]]]]]] + ["[0]T" lux (.only Mapping)]]]] + [aspect + ["[0]" view]]]] ["[0]" // ["[1][0]" lux (.only custom with)] ["/[1]" // (.only) @@ -1612,14 +1614,14 @@ .let [method_type (its #method method_candidate)] _ (phase.assertion ..deprecated_method [class method method_type] (not (its #deprecated? method_candidate))) - [outputT argsA] (inference.general archive analyse method_type (list.as_stack (list#each product.right argsTC))) + [outputT argsA] (inference.general archive analyse method_type (view.as list.stack (list#each product.right argsTC))) outputJT (check_return outputT) @ meta.provenance] (pure [@ {analysis.#Extension [.prelude (text extension_name "|translation")] (list#composite (list (analysis.text @ (..signature (jvm.class (list) class))) (analysis.text @ method) (analysis.text @ (..signature outputJT))) - (decorate_inputs @ argsT (list.of_stack argsA)))}])))])) + (decorate_inputs @ argsT (view.of list.stack argsA)))}])))])) (the (invoke::virtual class_loader) (-> java/lang/ClassLoader @@ -1634,7 +1636,7 @@ .let [method_type (its #method method_candidate)] _ (phase.assertion ..deprecated_method [class method method_type] (not (its #deprecated? method_candidate))) - [outputT allA] (inference.general archive analyse method_type (stack.partial objectC (list.as_stack (list#each product.right argsTC)))) + [outputT allA] (inference.general archive analyse method_type (stack.partial objectC (view.as list.stack (list#each product.right argsTC)))) .let [[objectA argsA] (when allA {.#Top objectA argsA} [objectA argsA] @@ -1648,7 +1650,7 @@ (analysis.text @ method) (analysis.text @ (..signature outputJT)) objectA) - (decorate_inputs @ argsT (list.of_stack argsA)))}])))])) + (decorate_inputs @ argsT (view.of list.stack argsA)))}])))])) (the (invoke::special class_loader) (-> java/lang/ClassLoader @@ -1663,7 +1665,7 @@ .let [method_type (its #method method_candidate)] _ (phase.assertion ..deprecated_method [class method method_type] (not (its #deprecated? method_candidate))) - [outputT allA] (inference.general archive analyse method_type (stack.partial objectC (list.as_stack (list#each product.right argsTC)))) + [outputT allA] (inference.general archive analyse method_type (stack.partial objectC (view.as list.stack (list#each product.right argsTC)))) .let [[objectA argsA] (when allA {.#Top objectA argsA} [objectA argsA] @@ -1677,7 +1679,7 @@ (analysis.text @ method) (analysis.text @ (..signature outputJT)) objectA) - (decorate_inputs @ argsT (list.of_stack argsA)))}])))])) + (decorate_inputs @ argsT (view.of list.stack argsA)))}])))])) (the (invoke::interface class_loader) (-> java/lang/ClassLoader @@ -1698,7 +1700,7 @@ .let [method_type (its #method method_candidate)] _ (phase.assertion ..deprecated_method [class_name method method_type] (not (its #deprecated? method_candidate))) - [outputT allA] (inference.general archive analyse method_type (stack.partial objectC (list.as_stack (list#each product.right argsTC)))) + [outputT allA] (inference.general archive analyse method_type (stack.partial objectC (view.as list.stack (list#each product.right argsTC)))) .let [[objectA argsA] (when allA {.#Top objectA argsA} [objectA argsA] @@ -1712,7 +1714,7 @@ (analysis.text @ method) (analysis.text @ (..signature outputJT)) objectA) - (decorate_inputs @ argsT (list.of_stack argsA)))}])))])) + (decorate_inputs @ argsT (view.of list.stack argsA)))}])))])) (the (invoke::constructor class_loader) (-> java/lang/ClassLoader @@ -1727,11 +1729,11 @@ .let [method_type (its #method method_candidate)] _ (phase.assertion ..deprecated_method [class ..constructor_method method_type] (not (its #deprecated? method_candidate))) - [outputT argsA] (inference.general archive analyse method_type (list.as_stack (list#each product.right argsTC))) + [outputT argsA] (inference.general archive analyse method_type (view.as list.stack (list#each product.right argsTC))) @ meta.provenance] (pure [@ {analysis.#Extension [.prelude (text extension_name "|translation")] (list#composite (list (analysis.text @ (..signature (jvm.class (list) class)))) - (decorate_inputs @ argsT (list.of_stack argsA)))}])))])) + (decorate_inputs @ argsT (view.of list.stack argsA)))}])))])) (the (with_member class_loader) (-> java/lang/ClassLoader diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux index 6cdf4192ed..338c172910 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux @@ -37,7 +37,9 @@ [module ["[0]" import]] ["[0]" code (.only) - ["?[1]" \\projection]]]]] + ["?[1]" \\projection]]] + [aspect + ["[0]" view]]]] ["[0]" /// (.only) [/// ["[0]" phase (.only) @@ -352,7 +354,7 @@ [(?.and ?list.any (?.many (?.and ?list.any ?list.any))) (.function (_ extension_name analysis archive [input branches]) - (when.when (list.as_stack branches) analysis archive input))])) + (when.when (view.as list.stack branches) analysis archive input))])) (the function Handler diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/lua/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/lua/common.lux index 82a8782c14..d7c781a21d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/lua/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/lua/common.lux @@ -26,7 +26,9 @@ [meta [archive (.only Archive)]] ["[0]" extension (.only) - ["[1]/[0]" lux]]]]] + ["[1]/[0]" lux]]] + [aspect + ["[0]" view]]]] [///// ["//" extension] [translation @@ -147,7 +149,7 @@ (function (_ phase archive [input else conditionals]) (|> conditionals (list#each (function (_ [chars branch]) - {synthesis.#Seq (when (list.as_stack chars) + {synthesis.#Seq (when (view.as list.stack chars) {.#Empty} {synthesis.#Pop} @@ -156,7 +158,7 @@ [head {synthesis.#Pop}] (list#each (function (_ char) [char {synthesis.#Pop}]) - (list.of_stack tail))}) + (view.of list.stack tail))}) {synthesis.#Then branch}})) list.reversed (list#mix (function (_ pre post) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/php/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/php/common.lux index b16ba204e3..7f5bfad386 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/php/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/php/common.lux @@ -20,7 +20,9 @@ [macro ["[0]" template]] [target - ["_" php]]]] + ["_" php]] + [aspect + ["[0]" view]]]] ["[0]" //// ["/" bundle] ["/[1]" // @@ -74,10 +76,10 @@ (stack#each (|>> product.right synthesis.path/then //when.dependencies)) (stack.partial (//when.dependencies (synthesis.path/then else))) stack.together - list.of_stack + (view.of list.stack) (set.of_list _.hash) set.as_list - list.as_stack) + (view.as list.stack)) @expression (_.constant (reference.artifact [context_module context_artifact])) declaration (_.define_function @expression (stack.partial (_.parameter @input) (stack#each _.reference foreigns)) (stack#mix (function (_ [test then] else) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/loop.lux index c4c5b42515..f8488f539e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/loop.lux @@ -18,7 +18,9 @@ [/64 ["n" natural]]]] [target - ["_" php (.only Var Label)]]]] + ["_" php (.only Var Label)]] + [aspect + ["[0]" view]]]] ["[0]" // [runtime (.only Operation Phase Phase! Expression Statement)] ["[1][0]" when] @@ -92,7 +94,7 @@ referenced_variables (is (-> Synthesis (Set Var)) (|>> synthesis.path/then //when.dependencies - list.of_stack + (view.of list.stack) (set.of_list _.hash))) [declaration instantiation] (is [Statement _.Expression] (when (|> (list#each referenced_variables initsS+) diff --git a/stdlib/source/library/lux/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/compiler/language/lux/syntax.lux index b8e8c3779c..ab42038760 100644 --- a/stdlib/source/library/lux/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/compiler/language/lux/syntax.lux @@ -69,7 +69,9 @@ ["[0]" fraction] ["[0]" rational]]]] [compiler - ["@[0]" type]]]]) + ["@[0]" type]] + [aspect + ["[0]" view]]]]) (the declaration_name (syntax.macro (_ [[name parameters] (.form (<>.and ?list.any (<>.some ?list.any)))]) @@ -716,7 +718,7 @@ (..failure source' error) (if (same? error) - (..success source' { where (list.reversed (list.of_stack composite))}) + (..success source' { where (list.reversed (view.of list.stack composite))}) (..failure source' error)))))] ... Form and tuple syntax is mostly the same, differing only in the diff --git a/stdlib/source/library/lux/compiler/meta/io/archive.lux b/stdlib/source/library/lux/compiler/meta/io/archive.lux index 50966ed612..32fdc935fd 100644 --- a/stdlib/source/library/lux/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/compiler/meta/io/archive.lux @@ -32,7 +32,9 @@ [world ["[0]" file]] [compiler - ["@[0]" type]]]] + ["@[0]" type]] + [aspect + ["[0]" view]]]] ["[0]" // (.only) ["[1][0]" context] ["/[1]" // (.only) @@ -111,7 +113,7 @@ (Try [(Document @type.Module) Output]))) (do [! try.monad] [[definitions output] (is (Try [Definitions Output]) - (loop (again [input (list.as_stack (sequence.as_list expected)) + (loop (again [input (view.as list.stack (sequence.as_list expected)) definitions (is Definitions (dictionary.empty text.hash)) output (is Output sequence.empty)]) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index d3a37f751a..af47ff8f60 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -9,15 +9,14 @@ [equivalence (.only Equivalence)] [hash (.only Hash)] [monoid (.only Monoid)]] - [error + ["[0]" error (.only) ["[0]" try (.only Try)] ["[0]" exception (.only Exception)]] [data [text ["%" \\injection]] [collection - ["[0]" array - [\\unsafe (.only)]]]] + ["[0]" array]]] [math [number ["[0]" /64 (.only) @@ -40,7 +39,7 @@ (the .public limit Natural - (/64.<< 31 1)) + array.limit) (the .public empty (-> Natural @@ -58,19 +57,13 @@ (again (++ index) ($ (/.bits_08 index it) output)) output)))) -(exception.the .public (index_out_of_bounds [size index]) - (Exception [Natural Index]) - (exception.report - (list ["Size" (%.natural size)] - ["Index" (%.natural index)]))) - (template.with [ ] [(the .public ( index it) (-> Index Binary (Try I64)) (if (n.< (/.size it) (|> index )) {try.#Success ( index it)} - (exception.except ..index_out_of_bounds [(/.size it) index])))] + {try.#Failure error.not_valid}))] [[bits_08 /.bits_08 (|>)] [bits_16 /.bits_16 (n.+ 1)] @@ -83,7 +76,7 @@ (Try Binary)) (if (n.< (/.size it) (|> index )) {try.#Success ( index value it)} - (exception.except ..index_out_of_bounds [(/.size it) index])))] + {try.#Failure error.not_valid}))] [[has_08! /.has_08! (|>)] [has_16! /.has_16! (n.+ 1)] diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 40712e69cc..b6e06a89cf 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -43,7 +43,7 @@ (the .public limit Natural - (/64.<< 31 1)) + (-- (/64.<< 31 1))) (the .public empty (-> Natural diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index eca08caade..b75ba4a0c1 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -11,7 +11,7 @@ [functor (.only Functor)]] [control ["[0]" maybe]] - [error + ["[0]" error (.only) ["[0]" try (.only Try)] ["[0]" exception]] [data @@ -26,8 +26,6 @@ ["n" natural]]]] [macro ["^" pattern]] - [meta - ["[0]" provenance]] [function [predicate (.only Predicate)]]]]) @@ -529,11 +527,6 @@ {#Collisions _hash (array#lacks idx _colls)})) )) -(the .public unknown_value - Error - (provenance.with (provenance.here) - "Unknown value.")) - (the (node#value level hash key hash_of_key node) (for_any (_ key value) (-> Level Hash_Code key (Hash key) (Node key value) @@ -543,7 +536,7 @@ {#Hierarchy _size hierarchy} (let [index (level_index level hash)] (if (array.lacks? index hierarchy) - {try.#Failure ..unknown_value} + {try.#Failure error.not_known} (node#value (level_up level) hash key hash_of_key (array.item index hierarchy)))) ... For #Base nodes, check the leaves, and recursively check the branches. @@ -557,15 +550,15 @@ {.#Right [key' val']} (if (by hash_of_key = key key') {try.#Success val'} - {try.#Failure ..unknown_value})) - {try.#Failure ..unknown_value})) + {try.#Failure error.not_known})) + {try.#Failure error.not_known})) ... For #Collisions nodes, do a linear scan of all the known KV-pairs. {#Collisions _hash _colls} (|> _colls (array.example (|>> product.left (by hash_of_key = key))) (by maybe.monad each product.right) - (try.of_maybe ..unknown_value)))) + (try.of_maybe error.not_known)))) (the (node#size node) (for_any (_ key value) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 087adc3610..0ddb8143da 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -24,7 +24,7 @@ ["[0]" expansion] ["[0]" template]]]]) -(error.the invariant_violation) +(error.the violation_of_invariant) (every Color (Variant @@ -169,7 +169,7 @@ ))] [[blackened #Red #Black self] - [reddened #Black #Red (halt! ..invariant_violation)]]) + [reddened #Black #Red (halt! ..violation_of_invariant)]]) (the (with_left addition center) (for_any (_ key value) @@ -389,8 +389,7 @@ (by maybe.functor each reddened (its #right right)))}) _ - (halt! ..invariant_violation)) - )) + (halt! ..violation_of_invariant)))) (the (without_right key value ?left ?right) (for_any (_ key value) @@ -420,8 +419,7 @@ {.#Some (black key value (its #right left>>right) ?right)}) _ - (halt! ..invariant_violation) - ))) + (halt! ..violation_of_invariant)))) (the (prepended ?left ?right) (for_any (_ key value) diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index cd5f005eba..4392c97ec1 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -3,7 +3,7 @@ (.using [library - [lux (.except only all static has revised when macro as) + [lux (.except only all static has revised when macro as stack) [abstract [equivalence (.only Equivalence)] [hash (.only Hash)] @@ -22,7 +22,9 @@ [math [number [/64 - ["n" natural]]]]]] + ["n" natural]]]] + [aspect + ["[0]" view (.only View)]]]] [// ["[0]" stack] [array @@ -220,8 +222,11 @@ (the .public (each' (open "/#[0]") on it) (for_any (_ ! before after) - (-> (Monad !) (-> before (! after)) (List before) - (! (List after)))) + (-> (Monad !) + (-> before + (! after)) + (-> (List before) + (! (List after))))) (let [limit (.list_size# it) value (/.empty limit)] (loop (next [position 0]) @@ -469,8 +474,6 @@ [[any? 0b or] [every? 1b and]]) -(error.the .public no_one) - (the .public (one check it) (for_any (_ input output) (-> (-> input (Maybe output)) (List input) @@ -484,7 +487,7 @@ {.#Some it} {try.#Success it}) - {try.#Failure ..no_one})))) + {try.#Failure error.not_valid})))) (the .public (one' monad check it) (for_any (_ context input output) @@ -502,7 +505,7 @@ {.#Some it} (pure {try.#Success it}))) - (by monad pure {try.#Failure ..no_one}))))) + (by monad pure {try.#Failure error.not_valid}))))) (the .public (member? = context candidate) (for_any (_ it) @@ -540,7 +543,7 @@ (/.empty new_size) (..as it)))))) -(the .public (of_stack it) +(the (of_stack it) (for_any (_ it) (-> (Stack it) (List it))) @@ -554,7 +557,7 @@ it) (..of value)))) -(the .public as_stack +(the as_stack (for_any (_ it) (-> (List it) (Stack it))) @@ -563,6 +566,12 @@ {.#Top head tail}) {.#Empty}))) +(the .public stack + (for_any (_ it) + (View (List it) + (Stack it))) + (view.new ..of_stack ..as_stack)) + (the .public (split position it) (for_any (_ it) (-> Natural (List it) @@ -629,7 +638,7 @@ (in_range < first (-- less)) (in_range < (++ more) last)))))) -(the .public (in_range < first last it) +(the (in_range < first last it) Order (.when (n.- first last) 0 it @@ -663,6 +672,14 @@ [(only satisfies? it) (only (predicate.not satisfies?) it)]) +(the (expansion by it) + (for_any (_ it) + (-> Natural + (Change (.Array it)))) + (let [size (/.size it)] + (|> (/.empty (n.+ by size)) + (/.copy! size 0 it 0)))) + (the (clone it) (for_any (_ it) (Change (.Array it))) @@ -674,13 +691,23 @@ (for_any (_ it) (-> Natural it (Change (List it)))) - (if (n.< (.list_size# it) index) - (|> it - ..as - ..clone - (/.has! index value) - ..of) - it)) + (let [limit (.list_size# it)] + (if (n.< limit index) + (|> it + ..as + ..clone + (/.has! index value) + ..of) + + (n.= limit index) + (|> it + ..as + (..expansion 1) + (/.has! index value) + ..of) + + ... else + it))) (the .public (revised index change it) (for_any (_ it) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index b345aa230a..63ef4b8c75 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -3,7 +3,7 @@ (.using [library - [lux (.except) + [lux (.except list) [abstract [equivalence (.only Equivalence)] [functor (.only Functor)]] @@ -17,8 +17,8 @@ [number [/64 ["n" natural]]]] - [meta - ["[0]" provenance]]]]) + [aspect + ["[0]" view (.only View)]]]]) (every .public (Queue it) (Record @@ -30,20 +30,26 @@ [#front (stack) #rear (stack)]) -(the .public (of_list it) +(the (of_list it) (for_any (_ it) (-> (List it) (Queue it))) - [#front (list.as_stack it) + [#front (view.as list.stack it) #rear (stack)]) -(the .public (as_list queue) +(the (as_list queue) (for_any (_ it) (-> (Queue it) (List it))) (let [(open "/[0]") queue] - (list#composite (list.of_stack /#front) - (list.reversed (list.of_stack /#rear))))) + (list#composite (view.of list.stack /#front) + (list.reversed (view.of list.stack /#rear))))) + +(the .public list + (for_any (_ it) + (View (Queue it) + (List it))) + (view.new ..of_list ..as_list)) (the .public front (for_any (_ it) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index 1007064973..59e20c90ce 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -9,7 +9,7 @@ [monad (.only do)]] [control ["[0]" maybe]] - [error + ["[0]" error (.only) ["[0]" try (.only Try)]] [data [collection @@ -19,8 +19,6 @@ [number [/64 ["n" natural (.use "[1]#[0]" interval)]]]] - [meta - ["[0]" provenance]] [type (.only by_example) ["[0]" nominal]]]]) @@ -53,16 +51,11 @@ nominal.of (as (-> (Queue Any) Queue)))) - (the .public it_is_empty - Error - (provenance.with (provenance.here) - "Empty.")) - (the .public (front queue) (for_any (_ it) (-> (Queue it) (Maybe it))) - (<| (try.of_maybe ..it_is_empty) + (<| (try.of_maybe error.empty) (do maybe.monad [tree (nominal.as queue)] (tree.one (n.= (tree.tag tree)) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index e77ade0ca7..ce4bb11df2 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -10,7 +10,7 @@ [hash (.only Hash)] [monad (.only Monad do)] ["[0]" functor (.only Functor)]] - [error (.only error) + ["[0]" error (.only) ["[0]" try (.only Try)]] [function [predicate (.only Predicate)] @@ -98,9 +98,6 @@ (let [[ys' xs'] (split_when' predicate {.#Empty} xs)] [(reversed ys') xs'])) -(the .public no_one - (..error "No one value to be found.")) - (the .public (one check xs) (for_any (_ input output) (-> (-> input (Maybe output)) @@ -115,7 +112,7 @@ {try.#Success it}) end - {try.#Failure ..no_one})) + {try.#Failure error.no_instance})) (the .public (example predicate xs) (for_any (_ it) @@ -149,11 +146,7 @@ ))] [[any? 0b or] - [every? 1b and]] - ) - -(the .public no_item - (..error "The stack lacks a value at that index.")) + [every? 1b and]]) (the .public (item i xs) (for_any (_ it) @@ -166,7 +159,7 @@ _ (item (-- i) xs')) end - {try.#Failure ..no_item})) + {try.#Failure error.not_valid})) (the .public (equivalence //) (for_any (_ it) @@ -244,9 +237,6 @@ end false)) -(the .public is_empty - (..error "Empty.")) - (with_template [ ] [(the .public ( it) (for_any (_ it) @@ -257,17 +247,18 @@ {try.#Success } end - {try.#Failure ..is_empty}))] + {try.#Failure error.empty}))] [[top it] - [pop (Stack it)]] - ) + [pop (Stack it)]]) (the .public (each' monad f) (for_any (_ ! before after) (-> (Monad !) - (-> before (! after)) - (-> (Stack before) (! (Stack after))))) + (-> before + (! after)) + (-> (Stack before) + (! (Stack after))))) (let [(open "/#[0]") monad] (function (again xs) (.when xs diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 71d3c4c6a5..34af1903b1 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -44,8 +44,7 @@ (its )))] [[tag #tag tag] - [root #root (Either it [(Tree @ tag it) (Tree @ tag it)])]] - ) + [root #root (Either it [(Tree @ tag it) (Tree @ tag it)])]]) (the .public (builder monoid) (for_any (_ tag) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index e8c503c3c6..c6adad326e 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -19,7 +19,9 @@ ["[0]" list (.use "[1]#[0]" functor monoid)] ["[0]" stack (.use "[1]#[0]" functor monoid)]]] [macro - ["[0]" template]]]] + ["[0]" template]] + [aspect + ["[0]" view]]]] ["[0]" // (.only Tree) (.use "[1]#[0]" functor)]) (every (Family Zipper it) @@ -111,13 +113,11 @@ _ false)) -(error.the .public cannot_move) - (the .public (down zipper) (for_any (_ it) (-> (Zipper it) (Try (Zipper it)))) - (when (list.as_stack (..children zipper)) + (when (view.as list.stack (..children zipper)) {.#Top head tail} {try.#Success [#family {.#Some [#parent (has [#node //.#children] (list) zipper) @@ -126,20 +126,20 @@ #node head]} {.#Empty} - {try.#Failure ..cannot_move})) + {try.#Failure error.not_valid})) (the .public (up zipper) (for_any (_ it) (-> (Zipper it) (Try (Zipper it)))) - (<| (try.of_maybe ..cannot_move) + (<| (try.of_maybe error.not_valid) (do maybe.monad [family (its #family zipper)] (pure (let [(open "_[0]") family] (has [#node //.#children] - (list#composite (list.reversed (list.of_stack _#lefts)) - (list.of_stack {.#Top (its #node zipper) - _#rights})) + (list#composite (list.reversed (view.of list.stack _#lefts)) + (view.of list.stack {.#Top (its #node zipper) + _#rights})) _#parent)))))) (template.with [ ] @@ -162,10 +162,10 @@ #node next])} {.#Empty} - {try.#Failure ..cannot_move}) + {try.#Failure error.not_valid}) {.#None} - {try.#Failure ..cannot_move})) + {try.#Failure error.not_valid})) (the .public ( zipper) (for_any (_ it) @@ -187,10 +187,10 @@ #node last])} {.#Empty} - {try.#Failure ..cannot_move}) + {try.#Failure error.not_valid}) {.#None} - {try.#Failure ..cannot_move}))] + {try.#Failure error.not_valid}))] [[right rightmost #rights #lefts] [left leftmost #lefts #rights]]) @@ -288,19 +288,17 @@ (|>> (list#composite (list (//.leaf value)))) zipper)) -(error.the .public cannot_remove) - (the .public (remove zipper) (for_any (_ it) (-> (Zipper it) (Try (Zipper it)))) - (<| (try.of_maybe ..cannot_remove) + (<| (try.of_maybe error.not_valid) (do maybe.monad [family (its #family zipper)] (pure (when (its #lefts family) {.#Empty} (has [#node //.#children] - (list.of_stack (its #rights family)) + (view.of list.stack (its #rights family)) (its #parent family)) {.#Top next side} @@ -310,8 +308,6 @@ {.#Some})) (has #node next))))))) -(error.the .public cannot_insert) - (template.with [ ] [(the .public ( value zipper) (for_any (_ it) @@ -324,7 +320,7 @@ zipper)} {.#None} - {try.#Failure ..cannot_insert}))] + {try.#Failure error.not_valid}))] [[insert_left #lefts] [insert_right #rights]]) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 87375717b1..a5cf8d2ee5 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -31,7 +31,9 @@ ["[0]" meta (.only) ["[0]" module] ["[0]" code (.only) - ["<[1]>" \\projection]]]]] + ["<[1]>" \\projection]]] + [aspect + ["[0]" view]]]] ["[0]" // (.only) ["%" \\injection]]) @@ -354,7 +356,7 @@ (` (do <>.monad [.let [(, 'total) ""] (,* steps)] - ((, (' pure)) [(, 'total) (,* (list.reversed (list.of_stack names)))])))]) + ((, (' pure)) [(, 'total) (,* (list.reversed (view.of list.stack names)))])))]) )) (the (alternative lexer) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 12b449a630..e4bb1857a8 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -51,7 +51,9 @@ [language [lux [translation - ["[0]" script]]]]]]]) + ["[0]" script]]]]] + [aspect + ["[0]" view]]]]) (for .jvm (these (import java/lang/String @@ -486,7 +488,7 @@ [membersR+ (.variant (<>.many representation))] (pure (function (_ variantV) (let [[lefts right? sub_repr] (loop (again [lefts 0 - representations (list.as_stack membersR+) + representations (view.as list.stack membersR+) variantV variantV]) (when representations {.#Top leftR {.#Top rightR extraR+}} @@ -512,7 +514,7 @@ (do <>.monad [membersR+ (.tuple (<>.many representation))] (pure (function (_ tupleV) - (let [tuple_body (loop (again [representations (list.as_stack membersR+) + (let [tuple_body (loop (again [representations (view.as list.stack membersR+) tupleV tupleV]) (when representations {.#Empty} @@ -611,7 +613,7 @@ [provenance meta.provenance locals local.all .let [environment (|> locals - list.of_stack + (view.of list.stack) list#conjoint ... The list is reversed to make sure that, when building the dictionary, ... later bindings overshadow earlier ones if they have the same name. diff --git a/stdlib/source/library/lux/error.lux b/stdlib/source/library/lux/error.lux index d890ffd412..eff4856bf5 100644 --- a/stdlib/source/library/lux/error.lux +++ b/stdlib/source/library/lux/error.lux @@ -33,3 +33,4 @@ (the .public not_valid) (the .public not_known) (the .public empty) +(the .public no_instance) diff --git a/stdlib/source/library/lux/function/poly/morph/implicit.lux b/stdlib/source/library/lux/function/poly/morph/implicit.lux index 117c4d7a4a..32cde81f36 100644 --- a/stdlib/source/library/lux/function/poly/morph/implicit.lux +++ b/stdlib/source/library/lux/function/poly/morph/implicit.lux @@ -39,7 +39,9 @@ [module ["[0]" import]] ["[0]" code (.only) - ["<[1]>" \\projection]]]]]) + ["<[1]>" \\projection]]] + [aspect + ["[0]" view]]]]) (the (type_var id env) (-> Natural Type_Context @@ -182,7 +184,7 @@ (do meta.monad [local_batches local.all .let [total_locals (|> local_batches - list.of_stack + (view.of list.stack) list#conjoint (list.mix (function (_ [name type] table) (try.else table (dictionary.has' name type table))) diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index b842a383d3..74eea1e157 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -33,7 +33,9 @@ ["[0]" analysis (.only Operation Phase) ["[0]A" type]]]] [meta - [archive (.only Archive)]]]]] + [archive (.only Archive)]]] + [aspect + ["[0]" view]]]] [/ ["[0]" random] [number @@ -137,7 +139,7 @@ operands) _ (typeA.inference :it:) :it: (typeA.check (check.identity (list) $it))] - (when (list.as_stack (list.reversed operands)) + (when (view.as list.stack (list.reversed operands)) (stack single) (pure single) @@ -160,7 +162,7 @@ (,, (template.with [ <0> <+>] [(check.< :it:) - (..composite phase archive (` <+>) last (list.of_stack prevs))] + (..composite phase archive (` <+>) last (view.of list.stack prevs))] ')) diff --git a/stdlib/source/library/lux/math/number/big/rational.lux b/stdlib/source/library/lux/math/number/big/rational.lux index 550b939732..1a99ad9386 100644 --- a/stdlib/source/library/lux/math/number/big/rational.lux +++ b/stdlib/source/library/lux/math/number/big/rational.lux @@ -51,6 +51,12 @@ (pure (list (` (..normal [..#numerator (, numerator) ..#denominator (, (maybe.else (` natural.one) ?denominator))])))))) +(the .public (small it) + (-> /.Number + ..Number) + (new (integer.small (its /.#numerator it)) + (natural.small (its /.#denominator it)))) + (the .public (random digits) (-> Natural (Random ..Number)) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index 463c081a22..051a3d04d7 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -32,7 +32,9 @@ ["f" fraction] ["c" complex]]]] [macro - ["[0]" template]]]]) + ["[0]" template]] + [aspect + ["[0]" view]]]]) (every .public (PRNG state) (-> state @@ -104,8 +106,7 @@ [[natural Natural .natural] [integer Integer .integer] - [revolution Revolution .revolution]] - ) + [revolution Revolution .revolution]]) (the .public decimal (Random Decimal) @@ -164,8 +165,7 @@ [alpha_numeric unicode.alpha_numeric] [numeric unicode.numeric] [upper_cased unicode.upper_case] - [lower_cased unicode.lower_case]] - ) + [lower_cased unicode.lower_case]]) (template.with [ ] [(the .public @@ -176,8 +176,7 @@ (pure ( left right))))] [[fraction f.Fraction f.new ..natural] - [complex c.Complex c.complex ..unit_decimal]] - ) + [complex c.Complex c.complex ..unit_decimal]]) (the .public (and left right) (for_any (_ left right) @@ -272,8 +271,7 @@ (..list size item)))] [[array Array list.as_array] - [queue Queue queue.of_list]] - ) + [queue Queue (view.of queue.list)]]) (the .public (set hash size value_gen) (for_any (_ it) diff --git a/stdlib/source/library/lux/physics/energy.lux b/stdlib/source/library/lux/physics/energy.lux index 5a6c2de27a..fc22cbabe4 100644 --- a/stdlib/source/library/lux/physics/energy.lux +++ b/stdlib/source/library/lux/physics/energy.lux @@ -195,6 +195,11 @@ Torque) (decimal.x radius (/2.magnitude force))) +(the .public (torque' position force) + (-> /2.Vector Force + Torque) + (/2.x position force)) + ... https://en.wikipedia.org/wiki/Moment_of_inertia (every .public Moment_of_Inertia Scalar) @@ -223,3 +228,17 @@ (-> Torque /2/circle.Velocity Power) (decimal.x torque velocity)) + +... https://en.wikipedia.org/wiki/Angular_momentum +(every .public Angular_Momentum + Scalar) + +(the .public (angular_momentum position linear_momentum) + (-> /2.Vector Momentum + Angular_Momentum) + (/2.x position linear_momentum)) + +(the .public (angular_momentum' moment_of_inertia velocity) + (-> Moment_of_Inertia /2/circle.Velocity + Angular_Momentum) + (decimal.x moment_of_inertia velocity)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 00686a8483..bba82336d8 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -34,7 +34,9 @@ ["[0]" template] ["[0]" expansion]] [type - ["[0]" nominal]]]] + ["[0]" nominal]] + [aspect + ["[0]" view]]]] ["[0]" // ["[0]" jump (.only Jump)] ["[1][0]" address (.only Address)] @@ -643,7 +645,7 @@ _ (binary.has_32! offset (/32.as maximum) binary)] (loop (again [offset (n.+ (n/16.as ..integer_size) offset) afterwards (is (Stack jump.Big) - (stack.partial at_minimum (list.as_stack afterwards)))]) + (stack.partial at_minimum (view.as list.stack afterwards)))]) (when afterwards {.#Empty} binary @@ -699,7 +701,7 @@ offset (n.+ (n/16.as ..big_jump_size) offset) _ (binary.has_32! offset amount_of_cases binary)] (loop (again [offset (n.+ (n/16.as ..integer_size) offset) - cases (list.as_stack cases)]) + cases (view.as list.stack cases)]) (when cases {.#Empty} binary diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index 0b3d1533fc..a9f1859510 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -39,7 +39,9 @@ ["[0]" code (.only) ["?[1]" \\projection (.only Projection)]]] [compiler - ["@[0]" type]]]]) + ["@[0]" type]] + [aspect + ["[0]" view]]]]) (every .public Variable Natural) @@ -186,7 +188,7 @@ [{.#Quantification env body} (text "(" " " (|> env - list.of_stack + (view.of list.stack) (list#each (.function (_ [abstraction argument]) (text "[" (as_text' name_format abstraction) " " (as_text' name_format argument) @@ -252,7 +254,7 @@ \n " Parameter: " (bit.as_text parameter) \n " Index: " (n#as idx) \n "Environment: " (|> env - list.of_stack + (view.of list.stack) list.enumeration (list#each (.function (_ [index [abstraction argument]]) (text (n#as index) @@ -372,10 +374,11 @@ {.#Quantification quantification env body} (` {.#Quantification (, (code.bit quantification)) - (.stack (,* (list.of_stack (stack#each (.function (_ [abstraction argument]) - (` [(, (code abstraction)) - (, (code argument))])) - env)))) + (.stack (,* (|> env + (stack#each (.function (_ [abstraction argument]) + (` [(, (code abstraction)) + (, (code argument))]))) + (view.of list.stack)))) (, (code body))}) ))) @@ -401,7 +404,9 @@ [(the .public ( types) (-> (List Type) Type) - (when (list.as_stack (list.reversed types)) + (when (|> types + list.reversed + (view.as list.stack)) (.stack) diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 4923be7dae..2184d6e72a 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -32,7 +32,9 @@ ["n" natural (.use "[1]#[0]" base_10)]]]] [macro ["^" pattern] - ["[0]" template]]]] + ["[0]" template]] + [aspect + ["[0]" view]]]] ["[0]" // (.only) ["[0]" environment (.only Environment)]]) @@ -238,7 +240,7 @@ [.let [forbidden (|> aliases (set.of_list n.hash) (set.has @)) - permitted (|> (list.of_stack existing) + permitted (|> (view.of list.stack existing) (set.of_list n.hash) (set.difference forbidden))]] (when (list.item 0 (set.as_list permitted)) @@ -402,8 +404,8 @@ [ringE (..ring idE) ringA (..ring idA)] (if (by set.equivalence = - (set.of_list n.hash (list.of_stack ringE)) - (set.of_list n.hash (list.of_stack ringA))) + (set.of_list n.hash (view.of list.stack ringE)) + (set.of_list n.hash (view.of list.stack ringA))) (pure hypotheses) ... Fuse 2 rings (do ! diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 803cf20fd6..2ee5514f08 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -41,7 +41,9 @@ ["[0]" expansion]] [time ["[0]" instant (.only Instant)] - ["[0]" duration]]]]))) + ["[0]" duration]] + [aspect + ["[0]" view]]]]))) (every .public Path Text) @@ -708,7 +710,7 @@ output (loop (again [input (|> children (list.of_array {.#None}) (list#each (|>> (text path ..ruby_delimiter))) - list.as_stack) + (view.as list.stack)) output (is (Stack ..Path) (stack))]) (when input @@ -722,7 +724,7 @@ {.#Top head output} output))))) _ (Dir::close [] self)] - (pure (list.of_stack output))))] + (pure (view.of list.stack output))))] [[directory_files RubyFile::file?] [sub_directories RubyFile::directory?]])) @@ -994,7 +996,7 @@ (-> Text Path Memory (Try [Text Memory_File])) (loop (again [directory memory - trail (list.as_stack (text.all_split_by delimiter path))]) + trail (view.as list.stack (text.all_split_by delimiter path))]) (when trail {.#Top head tail} (when (dictionary.value head directory) @@ -1019,7 +1021,7 @@ (-> Text Path Instant Binary Memory (Try Memory)) (loop (again [directory memory - trail (list.as_stack (text.all_split_by / path))]) + trail (view.as list.stack (text.all_split_by / path))]) (when trail {.#Top head tail} (when (dictionary.value head directory) @@ -1059,7 +1061,7 @@ (-> Text Path Memory (Try Memory)) (loop (again [directory memory - trail (list.as_stack (text.all_split_by / path))]) + trail (view.as list.stack (text.all_split_by / path))]) (when trail {.#Top head tail} (when (dictionary.value head directory) @@ -1110,7 +1112,7 @@ (-> Text Path Memory (Try Memory)) (loop (again [directory memory - trail (list.as_stack (text.all_split_by / path))]) + trail (view.as list.stack (text.all_split_by / path))]) (when trail {.#Top head tail} (when (dictionary.value head directory) @@ -1139,7 +1141,7 @@ (-> Text Path Memory (Try Memory)) (loop (again [directory memory - trail (list.as_stack (text.all_split_by / path))]) + trail (view.as list.stack (text.all_split_by / path))]) (when trail {.#Empty} {try.#Success directory} @@ -1323,9 +1325,9 @@ (! (Try Any)))) (let [rooted? (text.starts_with? (by fs delimiter) path) segments (text.all_split_by (by fs delimiter) path)] - (when (list.as_stack (if rooted? - (list.after 1 segments) - segments)) + (when (view.as list.stack (if rooted? + (list.after 1 segments) + segments)) {.#Empty} (by monad pure (exception.except ..cannot_make_directory [path])) diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 545cbfe8f2..ec32ce070a 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -45,7 +45,9 @@ ["[0]" console (.only Console)] [net [uri - ["[0]" path]]]]]] + ["[0]" path]]]] + [aspect + ["[0]" view]]]] ["[0]" /// ["[1]" profile] ["[1][0]" action] @@ -157,8 +159,8 @@ text.equivalence) (the (< left right) - (loop (again [left (list.as_stack (text.all_split_by ..version_delimiter left)) - right (list.as_stack (text.all_split_by ..version_delimiter right))]) + (loop (again [left (view.as list.stack (text.all_split_by ..version_delimiter left)) + right (view.as list.stack (text.all_split_by ..version_delimiter right))]) (when [left right] [{.#Top leftH leftT} {.#Top rightH rightT}] (if (text.= leftH rightH) diff --git a/stdlib/source/projection/lux/data/format/json.lux b/stdlib/source/projection/lux/data/format/json.lux index cb50f4422e..274cd0e830 100644 --- a/stdlib/source/projection/lux/data/format/json.lux +++ b/stdlib/source/projection/lux/data/format/json.lux @@ -25,7 +25,9 @@ [macro ["[0]" template]] [meta - ["[0]" code]]]] + ["[0]" code]] + [aspect + ["[0]" view]]]] [\\library ["[0]" / (.only JSON)]]) @@ -35,7 +37,7 @@ (exception.the .public (unconsumed_input input) (Exception (Stack JSON)) (exception.report - (list ["Input" (exception.listing /.as_text (list.of_stack input))]))) + (list ["Input" (exception.listing /.as_text (view.of list.stack input))]))) (exception.the .public empty_input) @@ -139,7 +141,7 @@ [head ..any] (when head {/.#Array values} - (when (//.value (list.as_stack values) projection) + (when (//.value (view.as list.stack values) projection) {try.#Success [remainder output]} (when remainder {.#Empty} @@ -167,7 +169,7 @@ (list#each (function (_ [key value]) (list {/.#String key} value))) list#conjoint - list.as_stack) + (view.as list.stack)) projection) {try.#Failure error} (//.failure error) diff --git a/stdlib/source/projection/lux/data/format/xml.lux b/stdlib/source/projection/lux/data/format/xml.lux index a9596cefea..faac0ca5bd 100644 --- a/stdlib/source/projection/lux/data/format/xml.lux +++ b/stdlib/source/projection/lux/data/format/xml.lux @@ -17,7 +17,9 @@ ["[0]" list] ["[0]" dictionary]]] [meta - ["[0]" name]]]] + ["[0]" name]] + [aspect + ["[0]" view]]]] [\\library ["[0]" / (.only Attribute Attrs Tag XML)]]) @@ -48,12 +50,12 @@ (for_any (_ it) (-> (Projection it) Attrs (List XML) (Try it))) - (when (//.value [attrs (list.as_stack documents)] projection) + (when (//.value [attrs (view.as list.stack documents)] projection) {try.#Success [[attrs' (stack)] output]} {try.#Success output} {try.#Success [[attrs' remaining] output]} - (exception.except ..unconsumed_inputs [(list.of_stack remaining)]) + (exception.except ..unconsumed_inputs [(view.of list.stack remaining)]) {try.#Failure error} {try.#Failure error})) diff --git a/stdlib/source/projection/lux/program.lux b/stdlib/source/projection/lux/program.lux index 4f5a76c007..3e300138dd 100644 --- a/stdlib/source/projection/lux/program.lux +++ b/stdlib/source/projection/lux/program.lux @@ -13,7 +13,9 @@ ["[0]" text (.only) ["%" \\injection]] [collection - ["[0]" list]]]]]) + ["[0]" list]]] + [aspect + ["[0]" view]]]]) (every .public (Projection it) (//.Projection (Stack Text) @@ -30,7 +32,7 @@ {try.#Success output} _ - {try.#Failure (text "Remaining CLI inputs: " (text.interposed " " (list.of_stack remaining)))}) + {try.#Failure (text "Remaining CLI inputs: " (text.interposed " " (view.of list.stack remaining)))}) {try.#Failure try} {try.#Failure try})) diff --git a/stdlib/source/test/lux/abstract/enum.lux b/stdlib/source/test/lux/abstract/enum.lux index 095cbf94eb..8a9e21a1f0 100644 --- a/stdlib/source/test/lux/abstract/enum.lux +++ b/stdlib/source/test/lux/abstract/enum.lux @@ -20,7 +20,9 @@ [/64 ["n" natural]]]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view]]]] [\\library ["[0]" /]]) @@ -44,14 +46,14 @@ can_be_backwards? (by (list.equivalence n.equivalence) = (/.range n.enum start end) (list.reversed (/.range n.enum end start))) - every_element_is_a_successor? (when (list.as_stack range) + every_element_is_a_successor? (when (view.as list.stack range) {.#Top head tail} (|> (list#mix (function (_ next [verdict prev]) [(and verdict (n.= next (by n.enum succ prev))) next]) [true head] - (list.of_stack tail)) + (view.of list.stack tail)) product.left) {.#Empty} diff --git a/stdlib/source/test/lux/aspect.lux b/stdlib/source/test/lux/aspect.lux index ea001ad3b9..9023a5edf3 100644 --- a/stdlib/source/test/lux/aspect.lux +++ b/stdlib/source/test/lux/aspect.lux @@ -48,8 +48,8 @@ (the list_as_stack (for_any (_ it) (view.View (List it) (Stack it))) - (view.new list.of_stack - list.as_stack)) + (view.new (view.of list.stack) + (view.as list.stack))) (the whole (case.Case Decimal Integer) diff --git a/stdlib/source/test/lux/aspect/view.lux b/stdlib/source/test/lux/aspect/view.lux index eb68733663..0816e466dc 100644 --- a/stdlib/source/test/lux/aspect/view.lux +++ b/stdlib/source/test/lux/aspect/view.lux @@ -30,7 +30,7 @@ alternative_0 random_alternative alternative_1 random_alternative] - (<| (_.for [/.new]) + (<| (_.for [/.View /.new]) (all _.and (_.coverage [/.as] (and (bit.= (by equivalence_of_it = it_0 it_1) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/test/lux/compiler/language/lux/phase/analysis/complex.lux index e9d91e7a05..4016366abc 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/analysis/complex.lux @@ -37,7 +37,9 @@ ["[0]" configuration ["$[1]" \\test]]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view]]]] [\\library ["[0]" / (.only) ["/[1]" // (.only) @@ -114,8 +116,8 @@ true [{.#Tuple _ expected} (//analysis.tuple actual)] - (let [expected (list.of_stack expected) - actual (list.of_stack actual)] + (let [expected (view.of list.stack expected) + actual (view.of list.stack actual)] (and (n.= (list.size expected) (list.size actual)) (list.every? (function (_ [expected actual]) @@ -152,7 +154,7 @@ (try.else [Any (' [])]))]] (all _.and (_.coverage [/.sum] - (let [variantT (type.variant (list.as_stack (list#each product.left types/*,terms/*))) + (let [variantT (type.variant (view.as list.stack (list#each product.left types/*,terms/*))) sum? (is (-> Type Natural Bit Code Bit) (function (_ type lefts right? code) (|> (do //phase.monad @@ -234,7 +236,7 @@ (random.set text.hash arity) (by ! each set.as_list)) .let [module (product.left name) - sumT (type.variant (list.as_stack (list#each product.left types/*,terms/*))) + sumT (type.variant (view.as list.stack (list#each product.left types/*,terms/*))) variantT {.#Named name sumT} [tagT tagC] (|> types/*,terms/* (list.item tag) @@ -305,7 +307,7 @@ [type/1 term/1] ..simple_parameter [type/2 term/2] ..simple_parameter .let [module (product.left name) - productT (type.tuple (list.as_stack (list#each product.left types/*,terms/*))) + productT (type.tuple (view.as list.stack (list#each product.left types/*,terms/*))) expected (list#each product.right types/*,terms/*)]] (all _.and (_.coverage [/.product] @@ -317,7 +319,7 @@ (//type.expecting type))] (pure (when analysis (//analysis.tuple actual) - (let [actual (list.of_stack actual)] + (let [actual (view.of list.stack actual)] (and (n.= (list.size expected) (list.size actual)) (list.every? (function (_ [expected actual]) @@ -344,7 +346,7 @@ (//type.expecting varT))] (pure (when analysis (//analysis.tuple actual) - (let [actual (list.of_stack actual)] + (let [actual (view.of list.stack actual)] (and (n.= (list.size expected) (list.size actual)) (list.every? (function (_ [expected actual]) @@ -364,7 +366,7 @@ //type.inferring)] (pure (when analysis (//analysis.tuple actual) - (let [actual (list.of_stack actual)] + (let [actual (view.of list.stack actual)] (and (n.= (list.size expected) (list.size actual)) (list.every? (function (_ [expected actual]) @@ -462,7 +464,7 @@ .let [slots/0 (set.as_list slots/0) slots/1 (set.as_list slots/1) module (product.left name) - :record: {.#Named name (type.tuple (list.as_stack (list#each product.left types/*,terms/*)))} + :record: {.#Named name (type.tuple (view.as list.stack (list#each product.left types/*,terms/*)))} tuple (list#each product.right types/*,terms/*) local_record (|> tuple (list.zipped_2 (list#each (|>> [""] code.name) slots/0)) diff --git a/stdlib/source/test/lux/compiler/language/lux/synthesis.lux b/stdlib/source/test/lux/compiler/language/lux/synthesis.lux index 328b5c0b70..ec82031739 100644 --- a/stdlib/source/test/lux/compiler/language/lux/synthesis.lux +++ b/stdlib/source/test/lux/compiler/language/lux/synthesis.lux @@ -43,7 +43,9 @@ [test ["_" property (.only Test)]] [type - ["[0]" check]]]] + ["[0]" check]] + [aspect + ["[0]" view]]]] [\\library ["[0]" /]] ["[0]" \\projection] @@ -77,7 +79,7 @@ ... (|> ..random_variable ... (by ! each (|>> /.variable)) ... (random.stack size) -... (by ! each list.of_stack)))) +... (by ! each (view.of list.stack))))) ... (the simple ... Test diff --git a/stdlib/source/test/lux/compiler/meta/cli.lux b/stdlib/source/test/lux/compiler/meta/cli.lux index 2ae4c45cf4..fe809c0c83 100644 --- a/stdlib/source/test/lux/compiler/meta/cli.lux +++ b/stdlib/source/test/lux/compiler/meta/cli.lux @@ -29,7 +29,9 @@ ["[0]" program ["<[1]>" \\projection]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view]]]] [\\library ["[0]" / (.only) ["[1][0]" compiler (.only Compiler)]]] @@ -72,7 +74,7 @@ (,, (template.with [ ] [(_.coverage [] (|> /.service - (.value (list.as_stack (list#composite (list "build") compilation'))) + (.value (view.as list.stack (list#composite (list "build") compilation'))) (try#each (|>> (pipe.when {/.#Compilation it} (|> it @@ -94,7 +96,7 @@ (_.coverage [/.Interpretation] (`` (and (,, (template.with [ ] [(|> /.service - (.value (list.as_stack (list#composite (list "repl") compilation'))) + (.value (view.as list.stack (list#composite (list "repl") compilation'))) (try#each (|>> (pipe.when {/.#Interpretation it} (|> it @@ -115,7 +117,7 @@ (_.coverage [/.Export] (`` (and (,, (template.with [ ] [(|> /.service - (.value (list.as_stack (list#composite (list "export") export))) + (.value (view.as list.stack (list#composite (list "export") export))) (try#each (|>> (pipe.when {/.#Export it} (|> it diff --git a/stdlib/source/test/lux/control/maybe.lux b/stdlib/source/test/lux/control/maybe.lux index 0170d14c4d..e73bf3f10e 100644 --- a/stdlib/source/test/lux/control/maybe.lux +++ b/stdlib/source/test/lux/control/maybe.lux @@ -19,7 +19,9 @@ ["[0]" io (.use "[1]#[0]" monad)] ["[0]" pipe]] [data - ["[0]" text]] + ["[0]" text] + [collection + ["[0]" list]]] [math ["[0]" random (.only Random)] [number @@ -103,4 +105,12 @@ {.#None} false)))) + (do random.monad + [expected random.natural] + (_.coverage [/.as_list] + (with (list.equivalence n.equivalence) + (and (= (list) + (/.as_list {.#None})) + (= (list expected) + (/.as_list {.#Some expected})))))) ))) diff --git a/stdlib/source/test/lux/control/stream.lux b/stdlib/source/test/lux/control/stream.lux index f52e0799b9..ab63b5c292 100644 --- a/stdlib/source/test/lux/control/stream.lux +++ b/stdlib/source/test/lux/control/stream.lux @@ -102,4 +102,17 @@ (by (sequence.equivalence natural.equivalence) = (sequence _1 _2 _2)))) + (_.coverage [/.next] + (and (when (/.next (by /.monad pure _0)) + {.#Left it} + (same? _0 it) + + else + false) + (when (/.next (/.one _0)) + {.#Right [head tail]} + (same? _0 head) + + else + false))) ))) diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 5468ad6e77..c052af0511 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -19,7 +19,7 @@ [control ["[0]" pipe] ["[0]" maybe]] - [error + ["[0]" error (.only) ["[0]" try (.only Try)] ["[0]" exception (.only Exception)]] [function @@ -34,8 +34,7 @@ ["[0]" list (.use "[1]#[0]" functor)] ["[0]" sequence] ["[0]" set] - [array - [\\unsafe (.only)]]]] + ["[0]" array]]] [logic ["[0]" bit]] [math @@ -49,7 +48,8 @@ [macro ["^" pattern] ["[0]" template]] - ["[0]" type] + ["[0]" type (.only) + ["[1]/[0]" check]] [meta ["[0]" static] ["[0]" name] @@ -58,7 +58,9 @@ ["[0]" instant] ["[0]" duration]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view]]]] [\\library ["[0]" / (.only) ["!" \\unsafe] @@ -451,9 +453,9 @@ (by random.monad pure output))))) (the (throws? exception try) - (for_any (_ e a) - (-> (Exception e) (Try a) - Bit)) + (for_any (_ exception it) + (-> (Exception exception) + (Predicate (Try it)))) (when try {try.#Failure error} (exception.is? exception error) @@ -461,6 +463,17 @@ {try.#Success _} false)) +(the (throws?' expected try) + (for_any (_ it) + (-> Error + (Predicate (Try it)))) + (when try + {try.#Failure error} + (same? expected error) + + {try.#Success _} + false)) + (the (binary_io power read write value) (-> Natural (-> Natural /.Binary (Try Natural)) (-> Natural Natural /.Binary (Try Any)) Natural Bit) (let [bytes (/64.<< power 1) @@ -476,8 +489,8 @@ post (read 0 binary)] (pure (and (n.= 0 pre) (n.= capped_value post))))) - (throws? /.index_out_of_bounds (read 1 binary)) - (throws? /.index_out_of_bounds (write 1 value binary))))) + (throws?' error.not_valid (read 1 binary)) + (throws?' error.not_valid (write 1 value binary))))) (the as_stack (-> /.Binary (Stack Natural)) @@ -530,7 +543,7 @@ idxs (is (Stack Natural) (when length 0 (stack) - _ (list.as_stack (enum.range n.enum 0 (-- length))))) + _ (view.as list.stack (enum.range n.enum 0 (-- length))))) reader (function (_ binary idx) (!.bits_08 idx binary))] (and (n.= length (!.size random_slice)) @@ -579,22 +592,25 @@ (/.empty size))) (_.coverage [/.size] (|> (/.empty size) /.size (n.= size))) - (_.for [/.index_out_of_bounds] - (all _.and - (_.coverage [/.bits_08 /.has_08!] - (..binary_io 0 /.bits_08 /.has_08! value)) - (_.coverage [/.bits_16 /.has_16!] - (..binary_io 1 /.bits_16 /.has_16! value)) - (_.coverage [/.bits_32 /.has_32!] - (..binary_io 2 /.bits_32 /.has_32! value)) - (_.coverage [/.bits_64 /.has_64!] - (..binary_io 3 /.bits_64 /.has_64! value)))) + (all _.and + (_.coverage [/.Index !.Index] + (type/check.< !.Index /.Index)) + (_.coverage [/.limit] + (same? array.limit /.limit)) + (_.coverage [/.bits_08 /.has_08!] + (..binary_io 0 /.bits_08 /.has_08! value)) + (_.coverage [/.bits_16 /.has_16!] + (..binary_io 1 /.bits_16 /.has_16! value)) + (_.coverage [/.bits_32 /.has_32!] + (..binary_io 2 /.bits_32 /.has_32! value)) + (_.coverage [/.bits_64 /.has_64!] + (..binary_io 3 /.bits_64 /.has_64! value))) (_.coverage [/.slice] (let [random_slice (try.trusted (/.slice offset length sample)) idxs (is (Stack Natural) (when length 0 (stack) - _ (list.as_stack (enum.range n.enum 0 (-- length))))) + _ (view.as list.stack (enum.range n.enum 0 (-- length))))) reader (function (_ binary idx) (/.bits_08 idx binary))] (and (n.= length (/.size random_slice)) diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index 19f58c74ce..eb11bf8bca 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -336,6 +336,8 @@ (/.empty size))))) (<| (_.for [/.Index]) (all _.and + (_.coverage [/.limit] + (not (n.= n.zero /.limit))) (_.coverage [/.item /.has!] (let [the_array (|> (/.empty 2) (is (Array Natural)) diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index cd52a35707..dac6c654f1 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -5,10 +5,23 @@ [library [lux (.except) [abstract - [monad (.only do)] - ["[0]" equivalence]] - [error - ["[0]" try (.use "[1]#[0]" functor)]] + ["[0]" monad (.only do) + ["[1]T" \\test]] + ["[0]" functor + ["[1]T" \\test]] + ["[0]" monoid + ["[1]T" \\test]] + ["[0]" equivalence + ["[1]T" \\test]] + ["[0]" hash + ["[1]T" \\test]]] + [function + [poly + [type + ["[0]" mix + ["[1]T" \\test]]]]] + ["[0]" error (.only) + ["[0]" try (.only Try) (.use "[1]#[0]" functor)]] [data ["[0]" any] ["[0]" product] @@ -16,7 +29,8 @@ ["%" \\injection]] [collection ["[0]" set] - ["[0]" stack]]] + ["[0]" stack] + ["[0]" array]]] [logic ["[0]" bit]] [math @@ -27,8 +41,12 @@ [test ["_" property (.only Test)]] [aspect + ["[0]" view (.only) + ["[1]T" \\test]] ["[0]" case (.only) - ["[1]T" \\test]]]]] + ["[1]T" \\test]]] + [control + ["[0]" pure (.only Pure)]]]] [\\library ["[0]" /]] ["[0]" \\projection] @@ -64,6 +82,7 @@ (the .public test Test (<| (_.covering /._) + (with (/.equivalence n.equivalence)) (do [! random.monad] [expected_size (by ! each (|>> (n.% 100) ++) random.natural) .let [within_range (by ! each (n.% (++ expected_size)) random.natural)] @@ -72,14 +91,39 @@ .let [random_list (is (Random (List Natural)) (|> random.natural (random.set n.hash expected_size) - (by ! each set.as_list))) - /#= (by (/.equivalence n.equivalence) =)] + (by ! each set.as_list)))] expected_list random_list - alternative_list (random.only (|>> (/#= expected_list) not) + alternative_list (random.only (|>> (= expected_list) not) random_list) expected_value (random.only (|>> (/.member? n.= expected_list) not) - random.natural)]) + random.natural) + arbitrary_member (by ! each (n.% expected_size) random.natural) + difference random.natural]) (all _.and + (_.for [/.equivalence] + (equivalenceT.spec (/.equivalence n.equivalence) random_list)) + (_.for [/.hash] + (|> random.natural + (by random.monad each (by /.monad pure)) + (hashT.spec (/.hash n.hash)))) + (_.for [/.monoid] + (monoidT.spec (/.equivalence n.equivalence) /.monoid random_list)) + (_.for [/.mix] + (mixT.spec (by /.monad pure) /.equivalence /.mix)) + (_.for [/.functor] + (functorT.spec (by /.monad pure) /.equivalence /.functor)) + (_.for [/.monad] + (monadT.spec (by /.monad pure) /.equivalence /.monad)) + (_.for [/.stack] + (do [! random.monad] + [size (by ! each (n.% 10) random.natural)] + (viewT.specification /.stack + (/.equivalence n.equivalence) + (stack.equivalence n.equivalence) + + (random.list size random.natural) + (random.stack size random.natural)))) + (_.coverage [/.size] (n.= expected_size (/.size expected_list))) @@ -92,7 +136,7 @@ (and (|> expected_list /.reversed /.reversed - (/#= expected_list)) + (= expected_list)) (bit.= (n.< 2 (/.size expected_list)) (by (/.equivalence n.equivalence) = expected_list @@ -103,14 +147,9 @@ [before' after'] (/.split cut_off expected_list)] (and (n.= cut_off (/.size before)) (n.= (n.- cut_off expected_size) (/.size after)) - (/#= expected_list (by /.monoid composite before after)) - (/#= before before') - (/#= after after')))) - (_.coverage [/.as_stack /.of_stack] - (|> expected_list - /.as_stack - /.of_stack - (/#= expected_list))) + (= expected_list (by /.monoid composite before after)) + (= before before') + (= after after')))) (_.coverage [/.repeated /.every?] (let [it (/.repeated expected_size expected_value)] (and (n.= expected_size (/.size it)) @@ -123,9 +162,9 @@ (bit.= (n.> 0 expected_additions) (and (/.any? (n.= expected_value) it) (/.member? n.= it expected_value))) - (/#= expected_list (/.only (|>> (n.= expected_value) not) it)) - (/#= (/.repeated expected_additions expected_value) - (/.only (n.= expected_value) it))))) + (= expected_list (/.only (|>> (n.= expected_value) not) it)) + (= (/.repeated expected_additions expected_value) + (/.only (n.= expected_value) it))))) (_.coverage [/.item /.dynamic] (let [[actual_size copy] (/.dynamic (function (_ index) (do try.monad @@ -133,37 +172,37 @@ (pure [(++ index) it]))) 0)] (and (n.= expected_size actual_size) - (/#= expected_list copy)))) + (= expected_list copy)))) (_.coverage [/.indices /.static] (let [[actual_size expected_indices] (/.static expected_size (function (_ index) [(++ index) index]) 0)] (and (n.= expected_size actual_size) - (/#= expected_indices - (/.indices expected_size))))) + (= expected_indices + (/.indices expected_size))))) (_.coverage [/.enumeration] (let [it (/.enumeration expected_list)] - (and (/#= (/.indices expected_size) - (by /.functor each product.left it)) - (/#= expected_list - (by /.functor each product.right it))))) + (and (= (/.indices expected_size) + (by /.functor each product.left it)) + (= expected_list + (by /.functor each product.right it))))) (_.coverage [/.zipped_2] (by (/.equivalence (product.equivalence n.equivalence n.equivalence)) = (/.zipped_2 (/.indices expected_size) expected_list) (/.enumeration expected_list))) (_.coverage [/.as_text] - (bit.= (/#= expected_list - alternative_list) + (bit.= (= expected_list + alternative_list) (text.= (/.as_text %.natural expected_list) (/.as_text %.natural alternative_list)))) (_.coverage [/.sub] (let [it (/.sub size_of_complete_segment expected_list)] (when size_of_complete_segment - 0 (by (/.equivalence /#=) = /.empty it) + 0 (by (/.equivalence =) = /.empty it) _ (and (/.every? (|>> /.size (n.<= size_of_complete_segment)) it) - (/#= expected_list (by /.monad conjoint it)))))) + (= expected_list (by /.monad conjoint it)))))) (_.coverage [/.sorted] (let [less_up_to_more (/.sorted n.< expected_list) more_up_to_less (/.sorted n.> expected_list)] @@ -171,7 +210,7 @@ (/.size less_up_to_more)) (set.= (set.of_list n.hash expected_list) (set.of_list n.hash less_up_to_more)) - (when (/.as_stack less_up_to_more) + (when (view.as /.stack less_up_to_more) {.#Empty} true @@ -182,8 +221,159 @@ more]) [true reference] terms))) - (/#= less_up_to_more - (/.reversed more_up_to_less))))) + (= less_up_to_more + (/.reversed more_up_to_less))))) + (_.coverage [/.has] + (let [can_change! + (|> expected_list + (/.has arbitrary_member expected_value) + (.list_item# arbitrary_member) + (same? expected_value)) + + can_expand! + (let [expansion (/.has expected_size expected_value expected_list)] + (and (|> expansion + (.list_item# expected_size) + (same? expected_value)) + (n.= (++ expected_size) (/.size expansion)))) + + cannot_over_expand! + (|> expected_list + (/.has (++ expected_size) expected_value) + (= expected_list))] + (and can_change! + can_expand! + cannot_over_expand!))) + (_.coverage [/.lacks] + (let [inverse_of_has! + (|> expected_list + (/.has expected_size expected_value) + (/.lacks expected_size) + (= expected_list)) + + at_any_position! + (= (with /.monoid + (composite (/.first arbitrary_member expected_list) + (/.after (++ arbitrary_member) expected_list))) + (/.lacks arbitrary_member expected_list)) + + cannot_over_reduce! + (|> expected_list + (/.has (++ expected_size) expected_value) + (= expected_list))] + (and inverse_of_has! + at_any_position! + cannot_over_reduce!))) + (_.coverage [/.revised] + (with n.equivalence + (= (|> expected_list + (.list_item# arbitrary_member) + (n.+ difference)) + (|> expected_list + (/.revised arbitrary_member (n.+ difference)) + (.list_item# arbitrary_member))))) + (_.coverage [/.when] + (and (= (list) + (/.when false expected_list)) + (= expected_list + (/.when true expected_list)))) + (_.coverage [/.example] + (with (try.equivalence n.equivalence) + (and (= {try.#Failure error.not_valid} + (/.example (same? expected_value) expected_list)) + (= {try.#Success expected_value} + (/.example (same? expected_value) + (/.has 0 expected_value expected_list)))))) + (_.coverage [/.one] + (let [choice (is (-> Natural + (Maybe Natural)) + (function (_ it) + (if (same? expected_value it) + {.#Some (++ expected_value)} + {.#None})))] + (with (try.equivalence n.equivalence) + (and (= {try.#Failure error.not_valid} + (/.one choice expected_list)) + (= {try.#Success (++ expected_value)} + (/.one choice + (/.has 0 expected_value expected_list))))))) + (_.coverage [/.only'] + (and (= (/.only n.even? expected_list) + (is (Pure (List Natural)) + (/.only' pure.monad n.even? expected_list))) + (= (/.only n.odd? expected_list) + (is (Pure (List Natural)) + (/.only' pure.monad n.odd? expected_list))))) + (_.coverage [/.mix'] + (with n.equivalence + (= (/.mix n.- 0 expected_list) + (is (Pure Natural) + (/.mix' pure.monad + (function (_ next total) + (by pure.monad pure (n.- next total))) + 0 + expected_list))))) + (_.coverage [/.one'] + (let [choice (is (-> Natural + (Maybe Natural)) + (function (_ it) + (if (same? expected_value it) + {.#Some (++ expected_value)} + {.#None})))] + (with (try.equivalence n.equivalence) + (and (= (/.one choice expected_list) + (is (Pure (Try Natural)) + (/.one' pure.monad choice expected_list))) + (let [expected_list (/.has 0 expected_value expected_list)] + (= (/.one choice expected_list) + (is (Pure (Try Natural)) + (/.one' pure.monad choice expected_list)))))))) + (_.coverage [/.each'] + (= (by /.functor each (n.+ difference) expected_list) + (is (Pure (List Natural)) + (/.each' pure.monad + (|>> (n.+ difference) + (by pure.monad pure)) + expected_list)))) + (_.coverage [/.complete] + (with pure.monad + (= (is (Pure (List Natural)) + (pure expected_list)) + (is (Pure (List Natural)) + (|> expected_list + (by /.functor each pure) + (/.complete pure.monad)))))) + (_.coverage [/.all] + (= (/.only n.even? expected_list) + (/.all (function (_ it) + (if (n.even? it) + {.#Some it} + {.#None})) + expected_list))) + (_.coverage [/.of_array] + (and (|> (array.empty expected_size) + (/.of_array {.#None}) + (= (list))) + (|> (array.empty expected_size) + (/.of_array {.#Some expected_value}) + (= (/.repeated expected_size expected_value))))) + (_.coverage [/.as_array] + (|> expected_list + /.as_array + (/.of_array {.#None}) + (= expected_list))) + (_.coverage [/.partition] + (let [[every_even every_odd] (/.partition n.even? expected_list)] + (and (= (/.only n.even? expected_list) + every_even) + (= (/.only n.odd? expected_list) + every_odd)))) + (_.coverage [/.every_mix] + (= (by /.functor each + (function (_ size) + (/.mix n.+ 0 (/.first size expected_list))) + (/.indices (++ (/.size expected_list)))) + (/.every_mix n.+ 0 expected_list))) ..\\projection /property.test diff --git a/stdlib/source/test/lux/data/collection/list/property.lux b/stdlib/source/test/lux/data/collection/list/property.lux index 20a6147fbb..31760a28c9 100644 --- a/stdlib/source/test/lux/data/collection/list/property.lux +++ b/stdlib/source/test/lux/data/collection/list/property.lux @@ -9,6 +9,8 @@ ["[0]" equivalence ["[1]T" \\test]] ["[0]" monoid + ["[1]T" \\test]] + ["[0]" functor ["[1]T" \\test]]] [control ["[0]" maybe (.use "[1]#[0]" monad)]] @@ -61,6 +63,8 @@ (monoidT.spec (/.equivalence n.equivalence) /.monoid (..random 10 (random.lower_cased 1) random.natural))) + (_.for [/.functor] + (functorT.spec (|>> [extra_key] list) /.equivalence /.functor)) (_.coverage [/.size] (n.= size (/.size sample))) diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index e428100617..d28b2d1e34 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -24,13 +24,17 @@ [/64 ["n" natural]]]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view (.only) + ["[1]T" \\test]]]]] [\\library ["[0]" /]]) (the injection (Injection /.Queue) - (|>> list /.of_list)) + (|>> list + (view.of /.list))) (the .public test Test @@ -43,12 +47,21 @@ non_member (random.only (|>> (set.member? members) not) random.natural) .let [members (set.as_list members) - sample (/.of_list members)]] + sample (view.of /.list members)]] (all _.and (_.for [/.equivalence] (equivalenceT.spec (/.equivalence n.equivalence) (random.queue size random.natural))) (_.for [/.functor] (functorT.spec ..injection /.equivalence /.functor)) + (_.for [/.list] + (do [! random.monad] + [size (by ! each (n.% 10) random.natural)] + (viewT.specification /.list + (/.equivalence n.equivalence) + (list.equivalence n.equivalence) + + (random.queue size random.natural) + (random.list size random.natural)))) (_.coverage [/.size] (n.= size (/.size sample))) @@ -66,7 +79,7 @@ (and empty_is_empty! all_empty_queues_look_the_same!))) (_.coverage [/.front] - (when [(list.as_stack members) (/.front sample)] + (when [(view.as list.stack members) (/.front sample)] [{.#Top head tail} {try.#Success first}] (n.= head first) @@ -78,7 +91,7 @@ (_.coverage [/.member?] (let [every_member_is_identified! (list.every? (/.member? n.equivalence sample) - (/.as_list sample)) + (view.as /.list sample)) non_member_is_not_identified! (not (/.member? n.equivalence sample non_member))] @@ -95,13 +108,13 @@ has_expected_order! (by (list.equivalence n.equivalence) = - (list#composite (/.as_list sample) (list non_member)) - (/.as_list pushed))] + (list#composite (view.as /.list sample) (list non_member)) + (view.as /.list pushed))] (and size_increases! new_member_is_identified! has_expected_order!))) (_.coverage [/.next] - (when (list.as_stack members) + (when (view.as list.stack members) {.#Top target expected} (let [popped (/.next sample) @@ -114,8 +127,8 @@ has_expected_order! (by (list.equivalence n.equivalence) = - (list.of_stack expected) - (/.as_list popped))] + (view.of list.stack expected) + (view.as /.list popped))] (and size_decreases! popped_member_is_not_identified! has_expected_order!)) diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux index b1f4de52ee..2270ba56e0 100644 --- a/stdlib/source/test/lux/data/collection/stack.lux +++ b/stdlib/source/test/lux/data/collection/stack.lux @@ -46,7 +46,9 @@ [macro ["[0]" template]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view]]]] [\\library ["[0]" /]]) @@ -61,7 +63,7 @@ [size ..bounded_size] (|> random.natural (random.set n.hash size) - (by ! each (|>> set.as_list list.as_stack))))) + (by ! each (|>> set.as_list (view.as list.stack)))))) (the signatures Test @@ -85,7 +87,7 @@ (do [! random.monad] [size ..bounded_size .let [(open "/#[0]") (/.equivalence n.equivalence)] - sample (by ! each (|>> set.as_list list.as_stack) (random.set n.hash size random.natural))] + sample (by ! each (|>> set.as_list (view.as list.stack)) (random.set n.hash size random.natural))] (all _.and (_.coverage [/.size] (n.= size (/.size sample))) @@ -124,7 +126,7 @@ {try.#Failure _} false)) - (list.enumeration (list.of_stack sample)))) + (list.enumeration (view.of list.stack sample)))) ))) (the slice diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux index 0fef541435..808e54c33a 100644 --- a/stdlib/source/test/lux/data/collection/tree/finger.lux +++ b/stdlib/source/test/lux/data/collection/tree/finger.lux @@ -43,7 +43,8 @@ expected_left random.natural expected_right random.natural] (all _.and - (_.coverage [/.Builder /.builder] + (_.coverage [/.Builder /.builder + /.leaf /.branch] (exec (/.builder text.monoid) true)) (_.coverage [/.tag] diff --git a/stdlib/source/test/lux/error.lux b/stdlib/source/test/lux/error.lux index 57a2424baf..d3f8ced1b1 100644 --- a/stdlib/source/test/lux/error.lux +++ b/stdlib/source/test/lux/error.lux @@ -36,7 +36,8 @@ ,standard (these /.not_valid /.not_known - /.empty)] + /.empty + /.no_instance)] (these (the ,local (/.error (template.text [,id]))) diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux index 843f668cd8..6895d01b38 100644 --- a/stdlib/source/test/lux/macro.lux +++ b/stdlib/source/test/lux/macro.lux @@ -28,7 +28,9 @@ ["[0]" code (.only) ["<[1]>" \\projection]]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view]]]] [\\library ["[0]" / (.only) ["^" pattern] @@ -188,7 +190,7 @@ (the sum (macro (_ tokens) - (loop (again [tokens (list.as_stack tokens) + (loop (again [tokens (view.as list.stack tokens) output 0]) (when tokens {.#Empty} diff --git a/stdlib/source/test/lux/math/number/64/rational.lux b/stdlib/source/test/lux/math/number/64/rational.lux index 1fdaf330ff..6b6a0bbbd7 100644 --- a/stdlib/source/test/lux/math/number/64/rational.lux +++ b/stdlib/source/test/lux/math/number/64/rational.lux @@ -40,8 +40,11 @@ ["n" natural] ["i" integer] ["d" decimal] - [/// - ["[0]" unit]]]]]) + [// + ["[0]" big + ["[1]" rational]] + [// + ["[0]" unit]]]]]]) (the .public random (Random /.Rational) @@ -156,13 +159,14 @@ (and (/.= expected (/.x /.positive_one expected)) (/.= expected (/./ /.positive_one expected)))) (_.coverage [/.smallest] - (or (not (/.< /.smallest (/.absolute expected))) + (or (not (big.< (big.small /.smallest) + (big.small (/.absolute expected)))) (/.= /.zero expected))) (_.coverage [/.most_positive] - (or (not (/.> /.most_positive expected)) + (or (not (big.> (big.small /.most_positive) (big.small expected))) (/.= /.infinity expected))) (_.coverage [/.most_negative] - (not (/.< /.most_negative expected))) + (not (big.< (big.small /.most_negative) (big.small expected)))) (_.coverage [/.infinity] (and (/.= /.infinity (/./ /.zero /.positive_one)) diff --git a/stdlib/source/test/lux/meta/binding/local.lux b/stdlib/source/test/lux/meta/binding/local.lux index 856579afca..f62b6bfb52 100644 --- a/stdlib/source/test/lux/meta/binding/local.lux +++ b/stdlib/source/test/lux/meta/binding/local.lux @@ -23,7 +23,9 @@ [meta ["[0]" provenance]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view]]]] [\\library ["[0]" / (.only) ["//[1]" ///]]]) @@ -35,7 +37,7 @@ [current_module (random.upper_cased 1) [name_0 name_1 name_2 name_3 name_4] (|> (random.upper_cased 1) (random.set text.hash 5) - (by ! each (|>> set.as_list list.as_stack)) + (by ! each (|>> set.as_list (view.as list.stack))) (random.one (function (_ values) (when values (stack name_0 name_1 name_2 name_3 name_4) diff --git a/stdlib/source/test/lux/meta/label.lux b/stdlib/source/test/lux/meta/label.lux index 770196f5a0..580b0c9ef8 100644 --- a/stdlib/source/test/lux/meta/label.lux +++ b/stdlib/source/test/lux/meta/label.lux @@ -32,7 +32,9 @@ [language [lux ["[0]" analysis] - ["[0]" phase]]]]]] + ["[0]" phase]]]] + [aspect + ["[0]" view]]]] [\\library ["[0]" / (.only) ["[0]" // (.use "[1]#[0]" functor) @@ -172,7 +174,7 @@ (|> (random.lower_cased size) (random.only (|>> (text.= head) not)) (random.set text.hash 3) - (by ! each (|>> set.as_list list.as_stack)) + (by ! each (|>> set.as_list (view.as list.stack))) (random.and (pure head))))))] tags_0 (random_labels 5) tags_1 (random_labels 6) @@ -211,11 +213,11 @@ (-- index) index)))] (|> {.#Top tags_0} - list.of_stack + (view.of list.stack) list.enumeration (list#each (function (_ [index proper]) [proper [true {.#Definition [.Tag - (|> [{.#Some [(lefts index) (right? index) (list.of_stack cohort)]} type_0] + (|> [{.#Some [(lefts index) (right? index) (view.of list.stack cohort)]} type_0] (as (-> Label .Tag)))]}]])))) (let [cohort (is (Stack Name) (stack#each (|>> [label_module]) @@ -228,11 +230,11 @@ (-- index) index)))] (|> {.#Top tags_1} - list.of_stack + (view.of list.stack) list.enumeration (list#each (function (_ [index proper]) [proper [true {.#Definition [.Slot - (|> [{.#Some [(lefts index) (right? index) (list.of_stack cohort)]} type_1] + (|> [{.#Some [(lefts index) (right? index) (view.of list.stack cohort)]} type_1] (as (-> Label .Slot)))]}]]))))) .#imports (list) .#module_state {.#Active}]]) @@ -252,7 +254,7 @@ (|> (/.every_slot label_module) (//.value expected_lux) (try#each (by equivalence = (list [(list#each (|>> [label_module]) - (list.of_stack {.#Top tags_1})) + (view.of list.stack {.#Top tags_1})) type_1]))) (try.else false)))) ))) diff --git a/stdlib/source/test/lux/program.lux b/stdlib/source/test/lux/program.lux index 7018619975..0da4394276 100644 --- a/stdlib/source/test/lux/program.lux +++ b/stdlib/source/test/lux/program.lux @@ -28,7 +28,9 @@ ["[0]" code ["<[1]>" \\projection]]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)]] + [aspect + ["[0]" view]]]] ["[0]" \\projection] [\\library ["[0]" /]]) @@ -78,7 +80,7 @@ (_.coverage [\\projection.somewhere] (|> (|> (\\projection.somewhere (\\projection.this expected)) (<>.before (<>.some \\projection.any))) - (\\projection.value (list.as_stack (all list#composite pre_ignore (list expected) post_ignore))) + (\\projection.value (view.as list.stack (all list#composite pre_ignore (list expected) post_ignore))) (!expect {try.#Success _}))) (_.coverage [\\projection.named] (|> (\\projection.named dummy \\projection.any) @@ -109,8 +111,9 @@ (let [(open "list#[0]") (list.equivalence text.equivalence)] (and (let [outcome ((is /.Program (/.program all_arguments - (io.io (list.of_stack all_arguments)))) - (list.as_stack inputs))] + (io.io (is (List Text) + (view.of list.stack all_arguments))))) + (view.as list.stack inputs))] (list#= inputs (as (-> Any (List Text)) (io.value outcome)))) (let [outcome ((is /.Program @@ -120,13 +123,13 @@ arg/3 \\projection.any arg/4 \\projection.any] (io.io (list arg/4 arg/3 arg/2 arg/1 arg/0)))) - (list.as_stack inputs))] + (view.as list.stack inputs))] (list#= (list.reversed inputs) (as (-> Any (List Text)) (io.value outcome)))) (let [outcome ((is /.Program (/.program [all_arguments (<>.many \\projection.any)] (io.io all_arguments))) - (list.as_stack inputs))] + (view.as list.stack inputs))] (list#= inputs (as (-> Any (List Text)) (io.value outcome)))) (when (try ((is /.Program @@ -135,7 +138,7 @@ arg/2 \\projection.any arg/3 \\projection.any] (io.io []))) - (list.as_stack inputs))) + (view.as list.stack inputs))) {try.#Success _} false