From 46c9158b2f4b6f390150c111afb1854b0f9705e4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 15 May 2024 20:09:16 -0400 Subject: [PATCH] Adapting to new `List` type (part 19). --- .../compiler/meta/cache/dependency/module.lux | 37 ++--- .../library/lux/compiler/meta/cache/purge.lux | 23 ++- stdlib/source/library/lux/control/maybe.lux | 53 +++--- stdlib/source/library/lux/control/pattern.lux | 25 ++- .../library/lux/data/collection/list.lux | 32 ++-- .../library/lux/data/collection/sequence.lux | 17 -- .../lux/data/collection/stack/property.lux | 156 ------------------ stdlib/source/library/lux/data/sum.lux | 44 +++-- stdlib/source/library/lux/documentation.lux | 34 ++-- .../library/lux/finance/market/ticker.lux | 2 +- stdlib/source/library/lux/macro/template.lux | 1 - stdlib/source/library/lux/meta/label.lux | 64 +++---- stdlib/source/library/lux/type/implicit.lux | 21 ++- stdlib/source/library/lux/type/object.lux | 3 +- .../compiler/meta/cache/dependency/module.lux | 8 +- .../test/lux/compiler/meta/cache/purge.lux | 26 +-- stdlib/source/test/lux/control/maybe.lux | 10 +- stdlib/source/test/lux/control/pattern.lux | 12 +- stdlib/source/test/lux/data/collection.lux | 14 +- .../lux/data/collection/stack/property.lux | 105 ------------ stdlib/source/test/lux/data/sum.lux | 42 ++--- .../source/test/lux/finance/market/ticker.lux | 2 +- stdlib/source/test/lux/meta/label.lux | 12 +- 23 files changed, 212 insertions(+), 531 deletions(-) delete mode 100644 stdlib/source/library/lux/data/collection/stack/property.lux delete mode 100644 stdlib/source/test/lux/data/collection/stack/property.lux diff --git a/stdlib/source/library/lux/compiler/meta/cache/dependency/module.lux b/stdlib/source/library/lux/compiler/meta/cache/dependency/module.lux index 88d1c38cb1..ebbf91117d 100644 --- a/stdlib/source/library/lux/compiler/meta/cache/dependency/module.lux +++ b/stdlib/source/library/lux/compiler/meta/cache/dependency/module.lux @@ -16,7 +16,6 @@ ["[0]" text] [collection ["[0]" list (.use "[1]#[0]" functor mix)] - ["[0]" stack (.use "[1]#[0]" functor mix)] ["[0]" dictionary (.only Dictionary)] ["[0]" set (.only Set)]]]]] [//// @@ -42,9 +41,8 @@ (the .public modules (-> Graph - (Stack descriptor.Module)) - (|>> dictionary.keys - list.as_stack)) + (List descriptor.Module)) + dictionary.keys) (every .public Dependency (Record @@ -52,11 +50,11 @@ #imports Ancestry])) (the .public graph - (-> (Stack Dependency) + (-> (List Dependency) Graph) - (stack#mix (function (_ [module imports] graph) - (dictionary.has module imports graph)) - ..empty)) + (list#mix (function (_ [module imports] graph) + (dictionary.has module imports graph)) + ..empty)) (the (ancestry archive) (-> Archive @@ -75,9 +73,9 @@ ancestry (memo.open memo)] (list#mix (function (_ module memory) (if (dictionary.key? memory module) - memory - (let [[memory _] (ancestry [memory module])] - memory))) + memory + (let [[memory _] (ancestry [memory module])] + memory))) ..empty (archive.archived archive)))) @@ -90,7 +88,7 @@ (set.member? target_ancestry source))) (every .public (Order it) - (Stack [descriptor.Module [module.ID (archive.Entry it)]])) + (List [descriptor.Module [module.ID (archive.Entry it)]])) (the .public (load_order key archive) (for_any (_ it) @@ -100,11 +98,10 @@ (|> ancestry dictionary.keys (list.sorted (..dependency? ancestry)) - list.as_stack - (stack.each' try.monad - (function (_ module) - (do try.monad - [module_id (archive.id module archive) - entry (archive.find module archive) - document (document.marked? key (its [archive.#module module.#document] entry))] - (in [module [module_id (has [archive.#module module.#document] document entry)]]))))))) + (list.each' try.monad + (function (_ module) + (do try.monad + [module_id (archive.id module archive) + entry (archive.find module archive) + document (document.marked? key (its [archive.#module module.#document] entry))] + (in [module [module_id (has [archive.#module module.#document] document entry)]]))))))) diff --git a/stdlib/source/library/lux/compiler/meta/cache/purge.lux b/stdlib/source/library/lux/compiler/meta/cache/purge.lux index e76a6baf89..604843a319 100644 --- a/stdlib/source/library/lux/compiler/meta/cache/purge.lux +++ b/stdlib/source/library/lux/compiler/meta/cache/purge.lux @@ -67,23 +67,22 @@ Purge) (|>> (list.all (function (_ [valid? module_name @module _]) (if valid? - {.#None} - {.#Some [module_name @module]}))) + {.#None} + {.#Some [module_name @module]}))) (dictionary.of_list text.hash))) -(the .public (purge caches load_order) +(the .public (purge caches) (-> (List Cache) (dependency.Order Any) Purge) (list#mix (function (_ [module_name [@module entry]] purge) (let [purged? (is (Predicate descriptor.Module) (dictionary.key? purge))] (if (purged? module_name) - purge - (if (|> entry - (its [archive.#module module.#descriptor descriptor.#references]) - set.as_list - (list.any? purged?)) - (dictionary.has module_name @module purge) - purge)))) - (..initial caches) - (list.of_stack load_order))) + purge + (if (|> entry + (its [archive.#module module.#descriptor descriptor.#references]) + set.as_list + (list.any? purged?)) + (dictionary.has module_name @module purge) + purge)))) + (..initial caches))) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index d845ca18ca..e5e28bf1ea 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -3,7 +3,7 @@ (.using [library - [lux (.except stack with when or) + [lux (.except with when or macro) [abstract [monoid (.only Monoid)] [equivalence (.only Equivalence)] @@ -11,7 +11,7 @@ [functor (.only Functor)] [monad (.only Monad do)]]]]) -(the template#macro (.in_module# .prelude .template#macro)) +(the macro (.in_module# .prelude .template#macro)) ... (every (Maybe it) ... (Variant @@ -130,14 +130,13 @@ (by monad each (by ..monad in))) (the .public else - (template#macro - (_ ,else ,maybe) - [(.when ,maybe - {.#Some 'it} - 'it + (macro (_ ,else ,maybe) + [(.when ,maybe + {.#Some 'it} + 'it - {.#None} - ,else)])) + {.#None} + ,else)])) (the .public trusted (for_any (_ it) @@ -145,18 +144,6 @@ it)) (|>> (..else (undefined)))) -(the .public (stack value) - (for_any (_ it) - (-> (Maybe it) - (Stack it))) - (.when value - {.#Some value} - (.stack value) - - ... {.#None} - _ - (.stack))) - (the .public (as_list value) (for_any (_ it) (-> (Maybe it) @@ -169,18 +156,16 @@ (list))) (the .public when - (template#macro - (_ ) - [(if - - {.#None})])) + (macro (_ ) + [(if + + {.#None})])) (the .public or - (template#macro - (_ ,left ,right) - [(.when ,left - {.#Some 'it} - {.#Some 'it} - - {.#None} - ,right)])) + (macro (_ ,left ,right) + [(.when ,left + {.#Some 'it} + {.#Some 'it} + + {.#None} + ,right)])) diff --git a/stdlib/source/library/lux/control/pattern.lux b/stdlib/source/library/lux/control/pattern.lux index 10d4e28776..10dcf4ba7c 100644 --- a/stdlib/source/library/lux/control/pattern.lux +++ b/stdlib/source/library/lux/control/pattern.lux @@ -21,7 +21,7 @@ ["[0]" bit] ["[0]" text] [collection - [stack + ["[0]" list (.only) ["[0]" property]]]] [math [number @@ -226,18 +226,17 @@ (the .public (item pattern) (for_any (_ it number outer inner value) (-> (Pattern number it outer inner value) - (Pattern number (Stack it) outer inner value))) + (Pattern number (List it) outer inner value))) (let [[number match] pattern] [number - (function (again input) - (.when input - {.#Empty} - ..failure - - {.#Top head tail} - (..try (match head) - (function (_ then else stack) - ((again tail) then else stack)))))])) + (function (_ input) + (let [size (.list_size# input)] + (loop (item [address 0]) + (if (natural.< size address) + (..try (match (.list_item# address input)) + (function (_ then else stack) + ((item (++ address)) then else stack))) + ..failure))))])) (every .public (Static it) (for_any (_ value arity) @@ -294,14 +293,14 @@ (the .public (has key) (-> Text - (Dynamic property.Stack)) + (Dynamic property.List)) (..item (..pair (..text key) ..variable))) (the .public (first predicate) (for_any (_ it) (-> (Predicate it) - (Dynamic Stack it))) + (Dynamic List it))) (..item (..and (..is predicate) ..variable))) diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index bf035c4107..acb140cfb3 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -367,20 +367,6 @@ {.#Some default} (of_full_array default it))) -(the .public (all check it) - (for_any (_ _0 _1) - (-> (-> _0 (Maybe _1)) (List _0) - (List _1))) - (..mix (function (_ item it) - (.when (check item) - {.#Some item} - (by ..monoid composite it (list item)) - - {.#None} - it)) - ..empty - it)) - (the .public (zipped_2 _0 _1) (for_any (_ _0 _1) (-> (List _0) (List _1) @@ -462,6 +448,24 @@ ..abstraction [state])))))) +(the .public (all value it) + (for_any (_ _0 _1) + (-> (-> _0 (Maybe _1)) + (-> (List _0) + (List _1)))) + (let [size (.list_size# it) + [_ it] (dynamic (function (item address) + (if (n.< size address) + (when (value (.list_item# address it)) + {.#Some item} + {.#Some [(++ address) item]} + + none + (item (++ address))) + {.#None})) + 0)] + it)) + (with_template' [,name ,identity ,composite] [(the .public (,name ? it) (for_any (_ it) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 298096c8c6..628f4d1e2c 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -27,7 +27,6 @@ [collection ["[0]" list (.use "[1]#[0]" mix functor monoid) ["?[1]" \\projection]] - ["[0]" stack (.use "[1]#[0]" mix functor monoid)] ["[0]" array ["[1]" \\unsafe (.only Array)]]]] [math @@ -203,22 +202,6 @@ {.#Some}) ))) -(the (node#stack node) - (for_any (_ it) - (-> (Node it) - (Stack it))) - (when node - {#Base base} - (array.as_stack {.#None} base) - - {#Hierarchy hierarchy} - (|> hierarchy - (array.as_stack {.#None}) - stack.reversed - (stack#mix (function (_ sub acc) - (stack#composite (node#stack sub) acc)) - {.#Empty})))) - (every .public (Sequence it) (Record [#level Level diff --git a/stdlib/source/library/lux/data/collection/stack/property.lux b/stdlib/source/library/lux/data/collection/stack/property.lux deleted file mode 100644 index f88204118d..0000000000 --- a/stdlib/source/library/lux/data/collection/stack/property.lux +++ /dev/null @@ -1,156 +0,0 @@ -... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -(.using - [library - [lux (.except Stack has revised) - [abstract - [equivalence (.only Equivalence)] - [monoid (.only Monoid)]] - [control - ["[0]" maybe (.use "[1]#[0]" functor)]] - [error - ["[0]" try (.only Try)]] - [data - ["[0]" product] - ["[0]" text] - [collection - ["[0]" stack (.use "[1]#[0]" functor mix)]]] - [math - [number - ["n" natural]]] - [meta - ["[0]" provenance]]]]) - -(the with_template' (.in_module# .prelude .with_template)) - -... https://en.wikipedia.org/wiki/Property_list -(every .public (Stack it) - (.Stack [Text it])) - -(the .public empty - Stack - {.#Empty}) - -(the .public size - (for_any (_ it) - (-> (Stack it) - Natural)) - stack.size) - -(the .public empty? - (for_any (_ it) - (-> (Stack it) - Bit)) - (|>> ..size - (n.= 0))) - -(the .public unknown_value - Error - (provenance.with (provenance.here) - "Unknown value.")) - -(the .public (value key properties) - (for_any (_ it) - (-> Text (Stack it) - (Try it))) - (when properties - {.#Top [k' v'] properties'} - (if (text.= key k') - {try.#Success v'} - (value key properties')) - - {.#Empty} - {try.#Failure ..unknown_value})) - -(with_template' [ ] - [(the .public - (for_any (_ it) - (-> (Stack it) - (.Stack ))) - (stack#each ))] - - [keys Text product.left] - [values it product.right] - ) - -(the .public (contains? key properties) - (for_any (_ it) - (-> Text (Stack it) - Bit)) - (when (..value key properties) - {try.#Success _} - true - - failure - false)) - -(the .public (has key val properties) - (for_any (_ it) - (-> Text it (Stack it) - (Stack it))) - (when properties - {.#Top [k' v'] properties'} - (if (text.= key k') - {.#Top [key val] - properties'} - {.#Top [k' v'] - (has key val properties')}) - - end - (stack [key val]))) - -(the .public (revised key f properties) - (for_any (_ it) - (-> Text (-> it it) (Stack it) - (Stack it))) - (when properties - {.#Top [k' v'] properties'} - (if (text.= key k') - {.#Top [k' (f v')] properties'} - {.#Top [k' v'] (revised key f properties')}) - - end - end)) - -(the .public (lacks key properties) - (for_any (_ it) - (-> Text (Stack it) - (Stack it))) - (when properties - {.#Top [k' v'] properties'} - (if (text.= key k') - properties' - {.#Top [k' v'] - (lacks key properties')}) - - end - end)) - -(the .public (equivalence (open "/#[0]")) - (for_any (_ it) - (-> (Equivalence it) - (Equivalence (Stack it)))) - (implementation - (the (= expected actual) - (and (n.= (stack.size expected) - (stack.size actual)) - (stack.every? (function (_ [key val]) - (|> expected - (..value key) - (maybe#each (/#= val)) - (maybe.else false))) - actual))))) - -(the .public monoid - (for_any (_ it) - (Monoid (Stack it))) - (implementation - (the identity - ..empty) - - (the (composite left right) - (stack#mix (function (_ [key val] it) - (..has key val it)) - right - left)))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 7c79796b0e..edbb740165 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -9,7 +9,7 @@ [hash (.only Hash)]] [data [collection - ["[0]" stack (.use "[1]#[0]" mix)]]] + ["[0]" list]]] [macro ["[0]" template]]]]) @@ -41,34 +41,28 @@ {#1 r} {#1 (on_right r)}))) (template.with [ ] - [(the .public ( it) - (for_any (_ t0 t1) (-> (Stack (Or t0 t1)) (Stack ))) - ... TODO: Use the more obvious implementation once "tail recursion modulo cons" is added to the compiler. - (stack#mix (function (_ head tail) - (when head - { head} - (stack.partial head tail) + [(the .public + (for_any (_ left right) + (-> (List (Or left right)) + (List ))) + (list.all (function (_ it) + (when it + { it} + {.#Some it} - _ - tail)) - (stack) - (stack.reversed it)))] + _ + {.#None}))))] - [#0 t0 lefts] - [#1 t1 rights] + [#0 left lefts] + [#1 right rights] ) -(the .public (partition xs) - (for_any (_ a b) (-> (Stack (Or a b)) [(Stack a) (Stack b)])) - (when xs - {.#Empty} - [{.#Empty} {.#Empty}] - - {.#Top x xs'} - (let [[lefts rights] (partition xs')] - (when x - {#0 x'} [{.#Top x' lefts} rights] - {#1 x'} [lefts {.#Top x' rights}])))) +(the .public (partition it) + (for_any (_ left right) + (-> (List (Or left right)) + [(List left) (List right)])) + [(..lefts it) + (..rights it)]) (the .public (equivalence left right) (for_any (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r)))) diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 19f199c0dc..699ece267f 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -848,23 +848,23 @@ (the .public (markdown it) (-> (Stack Documentation) Text) - (let [with_modules (stack#mix (function (_ doc it) - (if (dictionary.key? it (its #module doc)) - it - (dictionary.has (its #module doc) [doc (stack)] it))) - (is (Dictionary Text [Module (Stack Definition)]) - (dictionary.empty text.hash)) - (sum.rights it)) - with_definitions (stack#mix (function (_ doc it) - (let [module (name.module (its #global doc))] - (if (dictionary.key? it module) - (dictionary.revised module - (function (_ [module defs]) - [module (stack.partial doc defs)]) - it) - it))) - with_modules - (sum.lefts it)) + (let [with_modules (list#mix (function (_ doc it) + (if (dictionary.key? it (its #module doc)) + it + (dictionary.has (its #module doc) [doc (stack)] it))) + (is (Dictionary Text [Module (Stack Definition)]) + (dictionary.empty text.hash)) + (sum.rights (list.of_stack it))) + with_definitions (list#mix (function (_ doc it) + (let [module (name.module (its #global doc))] + (if (dictionary.key? it module) + (dictionary.revised module + (function (_ [module defs]) + [module (stack.partial doc defs)]) + it) + it))) + with_modules + (sum.lefts (list.of_stack it))) dependers (|> with_modules dictionary.entries (list#each (function (_ [name [module definitons]]) diff --git a/stdlib/source/library/lux/finance/market/ticker.lux b/stdlib/source/library/lux/finance/market/ticker.lux index 4a496379ba..8f2734e3a1 100644 --- a/stdlib/source/library/lux/finance/market/ticker.lux +++ b/stdlib/source/library/lux/finance/market/ticker.lux @@ -14,4 +14,4 @@ ... https://en.wikipedia.org/wiki/Ticker_tape (every .public (Tape $) - (Stack (Session $))) + (List (Session $))) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index 867504b5d0..73cbc14f8b 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -16,7 +16,6 @@ [collection ["[0]" list (.use "[1]#[0]" monad) ["?[1]" \\projection]] - ["[0]" stack (.use "[1]#[0]" monad)] ["[0]" dictionary (.only Dictionary)]]] [math [number diff --git a/stdlib/source/library/lux/meta/label.lux b/stdlib/source/library/lux/meta/label.lux index 48ccea1a63..4bb0fc2c78 100644 --- a/stdlib/source/library/lux/meta/label.lux +++ b/stdlib/source/library/lux/meta/label.lux @@ -12,7 +12,6 @@ [data ["[0]" text (.only)] [collection - ["[0]" stack (.use "[1]#[0]" mix)] ["[0]" list (.use "[1]#[0]" mix) ["[0]" property]]]] [macro @@ -26,6 +25,10 @@ ["[0]" binding] ["[0]" name (.use "[1]#[0]" absolute)]]) +(the (visible? exported? referenced_module this_module) + (or exported? + (text.= referenced_module this_module))) + (template.with [,singular ,type] [(expansion.let [,unknown (template.name ["unknown_" ,singular]) ,cannot_access (template.name ["cannot_access_" ,singular]) @@ -58,8 +61,7 @@ [this_module_name _] module.current] (when (property.value (name.proper it) (its .#definitions module)) {try.#Success [exported? {.#Definition [def_type def_value]}]} - (if (.or (text.= this_module_name (name.module it)) - exported?) + (if (visible? exported? (name.module it) this_module_name) (if (type.= ,type def_type) (in (as (-> Any Label) def_value)) (//.of_try (exception.except ,not_a [it]))) @@ -113,35 +115,35 @@ [slot .Slot] ) -(the .public (tag_stacks module) +(the .public (every_slot module) (-> module.Name - (Meta (Stack [(List Name) Type]))) + (Meta (List [(List Name) Type]))) (do //.monad [=module (module.by_name module) [this_module_name _] module.current] - (in (list.as_stack (property.values - (list#mix (function (_ [proper [exported? global]] output) - (when global - {.#Definition [type value]} - (if (and (type.= .Slot type) - (or exported? - (text.= this_module_name module))) - (let [[label type] (as (-> Any Label) value)] - (when label - {.#Some [lefts right? family]} - (when (list.item 0 family) - {try.#Success [_ proper]} - (property.has proper [family type] output) - - {try.#Failure _} - (property.has proper [(list [module proper]) type] output)) - - {.#None} - (property.has proper [(list [module proper]) type] output))) - output) - - _ - output)) - (is (property.List [(List Name) Type]) - (list)) - (its .#definitions =module))))))) + (in (property.values + (list#mix (function (_ [proper [exported? global]] output) + (when global + {.#Definition [type value]} + (if (and (type.= .Slot type) + (visible? exported? module this_module_name)) + (let [[label type] (as (-> Any Label) value)] + (expansion.let [,singleton (these (property.has proper [(list [module proper]) type] output))] + (when label + {.#Some [lefts right? family]} + (when (list.item 0 family) + {try.#Success [_ proper]} + (property.has proper [family type] output) + + {try.#Failure _} + ,singleton) + + {.#None} + ,singleton))) + output) + + _ + output)) + (is (property.List [(List Name) Type]) + (list)) + (its .#definitions =module)))))) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index a17aa78a73..4fe8bab51b 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -111,23 +111,22 @@ (do [! meta.monad] [[this_module_name _] module.current imp_mods (import.all this_module_name) - tag_stacks (list.each' ! label.tag_stacks imp_mods) - .let [tag_stacks (|> tag_stacks - list.as_stack - stack#conjoint - (stack#each (|>> product.left list.as_stack)) - stack#conjoint) - candidates (stack.only (|>> product.right (text.= simple_name)) - tag_stacks)]] + every_slot (list.each' ! label.every_slot imp_mods) + .let [every_slot (|> every_slot + list#conjoint + (list#each product.left) + list#conjoint) + candidates (list.only (|>> product.right (text.= simple_name)) + every_slot)]] (when candidates - {.#Empty} + (list) (meta.failure (text "Unknown slot: " (name.as_text member))) - {.#Top winner {.#Empty}} + (list winner) (in winner) _ - (meta.failure (text "Too many candidate slots: " (%.stack name.as_text candidates)))))) + (meta.failure (text "Too many candidate slots: " (list.as_text name.as_text candidates)))))) _ (by meta.monad in member))) diff --git a/stdlib/source/library/lux/type/object.lux b/stdlib/source/library/lux/type/object.lux index 282cc78102..c03aca61d0 100644 --- a/stdlib/source/library/lux/type/object.lux +++ b/stdlib/source/library/lux/type/object.lux @@ -17,8 +17,7 @@ ["[0]" product] [collection ["[0]" list (.use "[1]#[0]" monad) - ["?[1]" \\projection]] - ["[0]" stack (.use "[1]#[0]" monad)]]] + ["?[1]" \\projection]]]] ["[0]" macro (.only) ["[0]" template (.only with_locals)] ["[0]" syntax (.only) diff --git a/stdlib/source/test/lux/compiler/meta/cache/dependency/module.lux b/stdlib/source/test/lux/compiler/meta/cache/dependency/module.lux index 703ebbb60c..d3db0db60c 100644 --- a/stdlib/source/test/lux/compiler/meta/cache/dependency/module.lux +++ b/stdlib/source/test/lux/compiler/meta/cache/dependency/module.lux @@ -43,7 +43,6 @@ (dictionary.has module/1 /.fresh) (dictionary.has module/2 /.fresh) /.modules - list.of_stack (set.of_list text.hash))] (set.= expected actual))) )) @@ -52,11 +51,10 @@ (all _.and (_.coverage [/.graph] (let [expected (set.of_list text.hash (list module/0 module/1 module/2)) - actual (|> (/.graph (stack [module/0 /.fresh] - [module/1 /.fresh] - [module/2 /.fresh])) + actual (|> (/.graph (list [module/0 /.fresh] + [module/1 /.fresh] + [module/2 /.fresh])) /.modules - list.of_stack (set.of_list text.hash))] (set.= expected actual))) )) diff --git a/stdlib/source/test/lux/compiler/meta/cache/purge.lux b/stdlib/source/test/lux/compiler/meta/cache/purge.lux index 101d61a908..84d39e2b0f 100644 --- a/stdlib/source/test/lux/compiler/meta/cache/purge.lux +++ b/stdlib/source/test/lux/compiler/meta/cache/purge.lux @@ -78,12 +78,12 @@ (_.for [/.Purge] (all _.and (_.coverage [/.purge] - (and (dictionary.empty? (/.purge (list) (stack))) + (and (dictionary.empty? (/.purge (list) (list))) (let [order (is (dependency.Order Natural) - (stack [name/0 id/0 - [archive.#module module/0 - archive.#output (sequence.sequence) - archive.#registry registry.empty]]))] + (list [name/0 id/0 + [archive.#module module/0 + archive.#output (sequence.sequence) + archive.#registry registry.empty]]))] (and (let [cache (is (List /.Cache) (list [true name/0 id/0 module/0 registry.empty]))] (dictionary.empty? (/.purge cache order))) @@ -91,14 +91,14 @@ (list [false name/0 id/0 module/0 registry.empty]))] (dictionary.key? (/.purge cache order) name/0)))) (let [order (is (dependency.Order Natural) - (stack [name/0 id/0 - [archive.#module module/0 - archive.#output (sequence.sequence) - archive.#registry registry.empty]] - [name/1 id/1 - [archive.#module module/1 - archive.#output (sequence.sequence) - archive.#registry registry.empty]]))] + (list [name/0 id/0 + [archive.#module module/0 + archive.#output (sequence.sequence) + archive.#registry registry.empty]] + [name/1 id/1 + [archive.#module module/1 + archive.#output (sequence.sequence) + archive.#registry registry.empty]]))] (and (let [cache (is (List /.Cache) (list [true name/0 id/0 module/0 registry.empty] [true name/1 id/1 module/1 registry.empty])) diff --git a/stdlib/source/test/lux/control/maybe.lux b/stdlib/source/test/lux/control/maybe.lux index bbe9a161b2..d6bd55f32f 100644 --- a/stdlib/source/test/lux/control/maybe.lux +++ b/stdlib/source/test/lux/control/maybe.lux @@ -19,9 +19,7 @@ ["[0]" io (.use "[1]#[0]" monad)] ["[0]" pipe]] [data - ["[0]" text] - [collection - ["[0]" stack]]] + ["[0]" text]] [math ["[0]" random (.only Random)] [number @@ -80,12 +78,6 @@ [value random.natural] (_.coverage [/.trusted] (same? value (/.trusted {.#Some value})))) - (do random.monad - [value random.natural] - (_.coverage [/.stack] - (by (stack.equivalence n.equivalence) = - (stack value) - (/.stack {.#Some value})))) (do random.monad [expected random.natural .let [(open "/#[0]") (/.equivalence n.equivalence)]] diff --git a/stdlib/source/test/lux/control/pattern.lux b/stdlib/source/test/lux/control/pattern.lux index c6b6794cbb..8b8b975af6 100644 --- a/stdlib/source/test/lux/control/pattern.lux +++ b/stdlib/source/test/lux/control/pattern.lux @@ -29,9 +29,9 @@ true) (/.clause /.any false))] - (and (/.when (stack expected_integer other_integer) clause) - (/.when (stack other_integer expected_integer) clause) - (not (/.when (stack other_integer other_integer) clause))))) + (and (/.when (list expected_integer other_integer) clause) + (/.when (list other_integer expected_integer) clause) + (not (/.when (list other_integer other_integer) clause))))) (_.for [/.Static] (all _.and (_.coverage [/.any] @@ -60,9 +60,9 @@ (same? expected_integer)) (/.clause /.any false))] - (and (/.when (stack expected_integer other_integer) clause) - (/.when (stack other_integer expected_integer) clause) - (not (/.when (stack other_integer other_integer) clause))))) + (and (/.when (list expected_integer other_integer) clause) + (/.when (list other_integer expected_integer) clause) + (not (/.when (list other_integer other_integer) clause))))) )) (_.coverage [/.when] (<| (/.when [other_integer expected_integer]) diff --git a/stdlib/source/test/lux/data/collection.lux b/stdlib/source/test/lux/data/collection.lux index 354ba3613b..d6d1aa223c 100644 --- a/stdlib/source/test/lux/data/collection.lux +++ b/stdlib/source/test/lux/data/collection.lux @@ -3,7 +3,7 @@ (.using [library - [lux (.except stack) + [lux (.except) [test ["_" property (.only Test)]]]] ["[0]" / @@ -12,8 +12,7 @@ ["[1][0]" sequence] ["[1][0]" stream] ["[1][0]" list] - ["[1][0]" stack (.only) - ["[1]/[0]" property]] + ["[1][0]" stack] ["[1][0]" dictionary (.only) ["[1]/[0]" ordered]] ["[1][0]" queue (.only) @@ -25,13 +24,6 @@ ["[1]/[0]" finger] ["[1]/[0]" zipper]]]) -(the stack - Test - (all _.and - /stack.test - /stack/property.test - )) - (the dictionary Test (all _.and @@ -70,7 +62,7 @@ /sequence.test /stream.test /list.test - ..stack + /stack.test ..dictionary ..queue ..set diff --git a/stdlib/source/test/lux/data/collection/stack/property.lux b/stdlib/source/test/lux/data/collection/stack/property.lux deleted file mode 100644 index 3dbb1ebc1d..0000000000 --- a/stdlib/source/test/lux/data/collection/stack/property.lux +++ /dev/null @@ -1,105 +0,0 @@ -... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -(.using - [library - [lux (.except) - [abstract - [monad (.only do)] - ["[0]" equivalence - ["[1]T" \\test]] - ["[0]" monoid - ["[1]T" \\test]]] - [control - ["[0]" maybe (.use "[1]#[0]" monad)]] - [data - ["[0]" bit] - ["[0]" text] - [collection - ["[0]" set] - ["[0]" list] - ["[0]" stack]]] - [math - ["[0]" random (.only Random)] - [number - ["n" natural]]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" /]]) - -(the .public (random size gen_key gen_value) - (for_any (_ v) - (-> Natural (Random Text) (Random v) - (Random (/.Stack v)))) - (do random.monad - [keys (random.set text.hash size gen_key) - values (random.list size gen_value)] - (in (list.as_stack (list.zipped_2 (set.as_list keys) - values))))) - -(the .public test - Test - (<| (_.covering /._) - (_.for [/.Stack]) - (do [! random.monad] - [.let [gen_key (random.alphabetic 10)] - size (by ! each (n.% 100) random.natural) - sample (..random size gen_key random.natural) - - .let [keys (|> sample /.keys list.of_stack (set.of_list text.hash))] - extra_key (random.only (|>> (set.member? keys) not) - gen_key) - extra_value random.natural - shift random.natural] - (all _.and - (_.for [/.equivalence] - (equivalenceT.spec (/.equivalence n.equivalence) - (..random size gen_key random.natural))) - (_.for [/.monoid] - (monoidT.spec (/.equivalence n.equivalence) - /.monoid - (..random 10 (random.lower_cased 1) random.natural))) - - (_.coverage [/.size] - (n.= size (/.size sample))) - (_.coverage [/.empty?] - (bit.= (n.= 0 (/.size sample)) - (/.empty? sample))) - (_.coverage [/.empty] - (/.empty? /.empty)) - (_.coverage [/.keys /.values] - (by (/.equivalence n.equivalence) = - sample - (list.as_stack (list.zipped_2 (list.of_stack (/.keys sample)) - (list.of_stack (/.values sample)))))) - (_.coverage [/.contains?] - (and (stack.every? (function (_ key) - (/.contains? key sample)) - (/.keys sample)) - (not (/.contains? extra_key sample)))) - (_.coverage [/.has] - (let [sample+ (/.has extra_key extra_value sample)] - (and (not (/.contains? extra_key sample)) - (/.contains? extra_key sample+) - (n.= (++ (/.size sample)) - (/.size sample+))))) - (_.coverage [/.value] - (|> sample - (/.has extra_key extra_value) - (/.value extra_key) - (maybe#each (n.= extra_value)) - (maybe.else false))) - (_.coverage [/.revised] - (|> sample - (/.has extra_key extra_value) - (/.revised extra_key (n.+ shift)) - (/.value extra_key) - (maybe#each (n.= (n.+ shift extra_value))) - (maybe.else false))) - (_.coverage [/.lacks] - (|> sample - (/.has extra_key extra_value) - (/.lacks extra_key) - (by (/.equivalence n.equivalence) = sample))) - )))) diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux index 3c1cc62ae1..d2444c8d30 100644 --- a/stdlib/source/test/lux/data/sum.lux +++ b/stdlib/source/test/lux/data/sum.lux @@ -15,7 +15,7 @@ [data ["[0]" text] [collection - ["[0]" stack (.use "[1]#[0]" functor)]]] + ["[0]" list (.use "[1]#[0]" functor)]]] [math ["[0]" random] [number @@ -73,39 +73,39 @@ (pipe.when {#1 actual} (n.= (n.- shift expected) actual) _ false)))) (do ! [size (by ! each (n.% 5) random.natural) - expected (random.stack size random.natural)] + expected (random.list size random.natural)] (all _.and (_.coverage [/.lefts] - (let [actual (is (Stack (Or Natural Natural)) - (stack#each /.left expected))] - (and (by (stack.equivalence n.equivalence) = + (let [actual (is (List (Or Natural Natural)) + (list#each /.left expected))] + (and (by (list.equivalence n.equivalence) = expected (/.lefts actual)) - (by (stack.equivalence n.equivalence) = - (stack) + (by (list.equivalence n.equivalence) = + (list) (/.rights actual))))) (_.coverage [/.rights] - (let [actual (is (Stack (Or Natural Natural)) - (stack#each /.right expected))] - (and (by (stack.equivalence n.equivalence) = + (let [actual (is (List (Or Natural Natural)) + (list#each /.right expected))] + (and (by (list.equivalence n.equivalence) = expected (/.rights actual)) - (by (stack.equivalence n.equivalence) = - (stack) + (by (list.equivalence n.equivalence) = + (list) (/.lefts actual))))) (_.coverage [/.partition] (let [[lefts rights] (|> expected - (stack#each (function (_ value) - (if (n.even? value) - (/.left value) - (/.right value)))) - (is (Stack (Or Natural Natural))) + (list#each (function (_ value) + (if (n.even? value) + (/.left value) + (/.right value)))) + (is (List (Or Natural Natural))) /.partition)] - (and (by (stack.equivalence n.equivalence) = - (stack.only n.even? expected) + (and (by (list.equivalence n.equivalence) = + (list.only n.even? expected) lefts) - (by (stack.equivalence n.equivalence) = - (stack.only (|>> n.even? not) expected) + (by (list.equivalence n.equivalence) = + (list.only (|>> n.even? not) expected) rights)))) )) )))) diff --git a/stdlib/source/test/lux/finance/market/ticker.lux b/stdlib/source/test/lux/finance/market/ticker.lux index cad0389e9d..95d4056f0b 100644 --- a/stdlib/source/test/lux/finance/market/ticker.lux +++ b/stdlib/source/test/lux/finance/market/ticker.lux @@ -24,5 +24,5 @@ (_.coverage [/.Symbol] (check.< /.Symbol Text)) (_.coverage [/.Tape] - (check.< /.Tape Stack)) + (check.< /.Tape List)) ))) diff --git a/stdlib/source/test/lux/meta/label.lux b/stdlib/source/test/lux/meta/label.lux index 66c6ca7cb3..13f0c99c12 100644 --- a/stdlib/source/test/lux/meta/label.lux +++ b/stdlib/source/test/lux/meta/label.lux @@ -192,16 +192,16 @@ .#seed 0 .#eval (as_expected [])])]] (all _.and - (_.coverage [/.tag_stacks] - (let [equivalence (stack.equivalence + (_.coverage [/.every_slot] + (let [equivalence (list.equivalence (product.equivalence (list.equivalence name.equivalence) type.equivalence))] - (|> (/.tag_stacks label_module) + (|> (/.every_slot label_module) (//.value expected_lux) - (try#each (by equivalence = (stack [(list#each (|>> [label_module]) - (list.of_stack {.#Top tags_1})) - type_1]))) + (try#each (by equivalence = (list [(list#each (|>> [label_module]) + (list.of_stack {.#Top tags_1})) + type_1]))) (try.else false)))) )))