From a02af15128c389f04d08717e8ed149a099ad0618 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 6 Mar 2024 13:02:41 -0400 Subject: [PATCH] Adapting to new `List` type (part 2). --- lux-cl/source/program.lux | 2 +- lux-lua/source/program.lux | 4 +- lux-php/source/program.lux | 2 +- lux-python/source/program.lux | 4 +- lux-r/source/program.lux | 2 +- lux-ruby/source/program.lux | 12 +- stdlib/source/library/lux/abstract/monad.lux | 65 -- .../library/lux/compiler/default/init.lux | 42 +- .../library/lux/compiler/default/platform.lux | 27 +- .../source/library/lux/compiler/extension.lux | 29 + .../library/lux/compiler/extension/lux.lux | 19 + .../lux/compiler/language/lux/analysis.lux | 4 +- .../language/lux/analysis/complex.lux | 37 +- .../language/lux/analysis/coverage.lux | 69 +- .../language/lux/analysis/inference.lux | 4 +- .../compiler/language/lux/analysis/module.lux | 2 +- .../language/lux/analysis/pattern.lux | 22 +- .../compiler/language/lux/analysis/type.lux | 4 +- .../language/lux/phase/analysis/complex.lux | 14 +- .../language/lux/phase/analysis/when.lux | 126 +++- .../language/lux/phase/declaration.lux | 2 +- .../lux/phase/extension/analysis/js.lux | 10 +- .../lux/phase/extension/analysis/jvm.lux | 625 +++++++++--------- .../lux/phase/extension/analysis/lua.lux | 8 +- .../lux/phase/extension/analysis/lux.lux | 190 +++--- .../lux/phase/extension/analysis/php.lux | 10 +- .../lux/phase/extension/analysis/python.lux | 8 +- .../lux/phase/extension/analysis/r.lux | 4 +- .../lux/phase/extension/analysis/ruby.lux | 8 +- .../lux/phase/extension/declaration/jvm.lux | 22 +- .../lux/phase/extension/declaration/lux.lux | 18 +- .../lux/phase/extension/synthesis/lux.lux | 45 +- .../extension/translation/c++/common.lux | 4 +- .../translation/common_lisp/common.lux | 6 +- .../phase/extension/translation/js/common.lux | 16 +- .../phase/extension/translation/js/host.lux | 14 +- .../extension/translation/jvm/common.lux | 65 +- .../phase/extension/translation/jvm/host.lux | 39 +- .../extension/translation/lua/common.lux | 4 +- .../phase/extension/translation/lua/host.lux | 14 +- .../extension/translation/php/common.lux | 28 +- .../phase/extension/translation/php/host.lux | 10 +- .../extension/translation/python/common.lux | 28 +- .../extension/translation/python/host.lux | 12 +- .../phase/extension/translation/r/common.lux | 6 +- .../phase/extension/translation/r/host.lux | 4 +- .../extension/translation/ruby/common.lux | 28 +- .../phase/extension/translation/ruby/host.lux | 8 +- .../compiler/language/lux/phase/synthesis.lux | 17 +- .../language/lux/phase/synthesis/function.lux | 50 +- .../language/lux/phase/synthesis/loop.lux | 50 +- .../language/lux/phase/synthesis/variable.lux | 39 +- .../language/lux/phase/synthesis/when.lux | 32 +- .../lux/phase/translation/c++/complex.lux | 4 +- .../lux/phase/translation/c++/function.lux | 4 +- .../lux/phase/translation/c++/runtime.lux | 2 +- .../phase/translation/c++/statement/loop.lux | 6 +- .../phase/translation/c++/statement/when.lux | 12 +- .../lux/phase/translation/c++/when.lux | 18 +- .../common_lisp/extension/common.lux | 2 +- .../translation/common_lisp/function.lux | 6 +- .../phase/translation/common_lisp/loop.lux | 6 +- .../phase/translation/common_lisp/runtime.lux | 6 +- .../translation/common_lisp/structure.lux | 4 +- .../phase/translation/common_lisp/when.lux | 16 +- .../lux/phase/translation/extension.lux | 9 +- .../lux/phase/translation/js/function.lux | 8 +- .../lux/phase/translation/js/loop.lux | 6 +- .../lux/phase/translation/js/runtime.lux | 6 +- .../lux/phase/translation/js/structure.lux | 4 +- .../lux/phase/translation/js/when.lux | 52 +- .../lux/phase/translation/jvm/complex.lux | 20 +- .../lux/phase/translation/jvm/function.lux | 26 +- .../jvm/function/field/variable/partial.lux | 4 +- .../translation/jvm/function/method/apply.lux | 14 +- .../translation/jvm/function/method/init.lux | 6 +- .../lux/phase/translation/jvm/loop.lux | 36 +- .../lux/phase/translation/jvm/runtime.lux | 4 +- .../lux/phase/translation/jvm/when.lux | 67 +- .../lux/phase/translation/lua/function.lux | 8 +- .../lux/phase/translation/lua/loop.lux | 6 +- .../lux/phase/translation/lua/runtime.lux | 6 +- .../lux/phase/translation/lua/structure.lux | 4 +- .../lux/phase/translation/lua/when.lux | 36 +- .../translation/php/extension/common.lux | 2 - .../lux/phase/translation/php/function.lux | 6 +- .../lux/phase/translation/php/loop.lux | 6 +- .../lux/phase/translation/php/runtime.lux | 6 +- .../lux/phase/translation/php/structure.lux | 4 +- .../lux/phase/translation/php/when.lux | 16 +- .../lux/phase/translation/python/function.lux | 8 +- .../lux/phase/translation/python/loop.lux | 8 +- .../lux/phase/translation/python/runtime.lux | 6 +- .../phase/translation/python/structure.lux | 4 +- .../lux/phase/translation/python/when.lux | 24 +- .../lux/phase/translation/r/function.lux | 6 +- .../language/lux/phase/translation/r/loop.lux | 6 +- .../lux/phase/translation/r/runtime.lux | 6 +- .../lux/phase/translation/r/structure.lux | 4 +- .../lux/phase/translation/ruby/function.lux | 6 +- .../lux/phase/translation/ruby/loop.lux | 6 +- .../lux/phase/translation/ruby/runtime.lux | 6 +- .../lux/phase/translation/ruby/structure.lux | 4 +- .../lux/phase/translation/ruby/when.lux | 48 +- .../lux/compiler/language/lux/program.lux | 14 +- .../lux/compiler/language/lux/synthesis.lux | 56 +- .../language/lux/synthesis/access.lux | 17 +- .../language/lux/synthesis/access/item.lux | 33 + .../meta/cache/dependency/artifact.lux | 9 +- .../compiler/meta/cache/dependency/module.lux | 18 +- .../lux/compiler/meta/cache/module.lux | 10 +- .../library/lux/compiler/meta/cache/purge.lux | 4 +- .../library/lux/compiler/meta/export.lux | 2 +- .../library/lux/compiler/meta/import.lux | 42 +- .../library/lux/compiler/meta/io/archive.lux | 91 ++- .../library/lux/compiler/meta/io/context.lux | 41 +- .../lux/compiler/meta/packager/jvm.lux | 28 +- .../lux/compiler/meta/packager/ruby.lux | 32 +- .../lux/compiler/meta/packager/script.lux | 29 +- .../source/library/lux/concurrency/event.lux | 4 +- stdlib/source/library/lux/concurrency/frp.lux | 2 +- .../source/library/lux/concurrency/future.lux | 10 +- .../library/lux/concurrency/incremental.lux | 4 +- stdlib/source/library/lux/concurrency/stm.lux | 24 +- .../library/lux/concurrency/structured.lux | 6 +- .../source/library/lux/concurrency/thread.lux | 2 +- .../library/lux/control/concatenative.lux | 4 +- stdlib/source/library/lux/control/maybe.lux | 4 +- stdlib/source/library/lux/control/region.lux | 5 +- stdlib/source/library/lux/control/scope.lux | 4 +- .../library/lux/control/scope/dynamic.lux | 14 +- stdlib/source/library/lux/control/writer.lux | 4 +- .../library/lux/data/collection/list.lux | 93 ++- .../library/lux/data/collection/set/multi.lux | 2 +- .../library/lux/data/collection/stack.lux | 70 +- .../source/library/lux/data/format/json.lux | 14 +- stdlib/source/library/lux/debug.lux | 12 +- stdlib/source/library/lux/error/exception.lux | 16 +- stdlib/source/library/lux/error/try.lux | 5 +- stdlib/source/library/lux/ffi.jvm.lux | 44 +- stdlib/source/library/lux/ffi.lux | 50 +- stdlib/source/library/lux/ffi/export.js.lux | 8 +- stdlib/source/library/lux/ffi/export.lua.lux | 8 +- stdlib/source/library/lux/ffi/export.py.lux | 8 +- stdlib/source/library/lux/ffi/export.rb.lux | 8 +- stdlib/source/library/lux/function/inline.lux | 6 +- stdlib/source/library/lux/function/mutual.lux | 12 +- stdlib/source/library/lux/function/named.lux | 12 +- .../lux/function/polymorphism/subject.lux | 14 +- stdlib/source/library/lux/macro.lux | 8 +- stdlib/source/library/lux/macro/expansion.lux | 14 +- stdlib/source/library/lux/macro/local.lux | 20 +- stdlib/source/library/lux/macro/pattern.lux | 8 +- stdlib/source/library/lux/macro/syntax.lux | 32 +- stdlib/source/library/lux/macro/template.lux | 6 +- stdlib/source/library/lux/math.lux | 12 +- stdlib/source/library/lux/math/random.lux | 3 +- stdlib/source/library/lux/meta/extension.lux | 3 +- stdlib/source/library/lux/meta/global.lux | 4 +- .../library/lux/target/jvm/bytecode.lux | 10 +- .../source/library/lux/target/jvm/class.lux | 21 +- .../source/library/lux/target/jvm/field.lux | 2 +- .../source/library/lux/target/jvm/method.lux | 4 +- .../library/lux/target/jvm/reflection.lux | 4 +- .../library/lux/target/jvm/type/alias.lux | 4 +- .../library/lux/target/jvm/type/lux.lux | 7 +- stdlib/source/library/lux/test/benchmark.lux | 4 +- stdlib/source/library/lux/type.lux | 4 +- stdlib/source/library/lux/type/brand.lux | 4 +- stdlib/source/library/lux/type/check.lux | 30 +- stdlib/source/library/lux/type/function.lux | 14 +- stdlib/source/library/lux/type/implicit.lux | 18 +- stdlib/source/library/lux/type/linear.lux | 21 +- stdlib/source/library/lux/type/poly.lux | 6 +- stdlib/source/library/lux/type/record.lux | 28 +- stdlib/source/library/lux/type/row.lux | 54 +- .../source/library/lux/world/environment.lux | 8 +- stdlib/source/library/lux/world/file.lux | 24 +- .../source/library/lux/world/file/watch.lux | 30 +- .../library/lux/world/net/http/client.lux | 8 +- .../library/lux/world/net/http/header.lux | 24 +- .../library/lux/world/net/http/server.lux | 3 +- .../source/program/aedifex/command/auto.lux | 8 +- .../source/program/aedifex/command/clean.lux | 6 +- .../aedifex/command/deploy/release.lux | 14 +- .../program/aedifex/dependency/deployment.lux | 6 +- stdlib/source/program/aedifex/input.lux | 5 +- stdlib/source/program/aedifex/project.lux | 6 +- stdlib/source/program/compositor.lux | 13 +- .../projection/lux/data/format/json.lux | 4 +- stdlib/source/projection/lux/meta/code.lux | 4 +- stdlib/source/projection/lux/type.lux | 6 +- stdlib/source/test/aedifex/command/clean.lux | 6 +- stdlib/source/test/aedifex/command/deploy.lux | 20 +- .../source/test/aedifex/command/install.lux | 14 +- stdlib/source/test/aedifex/repository.lux | 2 +- stdlib/source/test/lux/abstract/monad.lux | 29 - .../source/test/lux/abstract/monad/free.lux | 3 +- .../test/lux/abstract/monad/indexed.lux | 2 +- stdlib/source/test/lux/compiler.lux | 4 +- stdlib/source/test/lux/compiler/extension.lux | 45 ++ .../test/lux/compiler/extension/lux.lux | 38 ++ .../source/test/lux/compiler/language/lux.lux | 9 +- .../language/lux/analysis/coverage.lux | 4 +- .../compiler/language/lux/analysis/module.lux | 2 +- .../compiler/language/lux/phase/extension.lux | 4 +- .../lux/phase/extension/analysis/lux.lux | 2 +- .../language/lux/phase/synthesis/function.lux | 2 +- .../lux/phase/synthesis/primitive.lux | 3 +- .../lux/phase/synthesis/structure.lux | 2 +- .../language/lux/phase/synthesis/variable.lux | 2 +- .../language/lux/phase/synthesis/when.lux | 2 +- .../lux/phase/translation/jvm/complex.lux | 6 +- .../lux/phase/translation/jvm/function.lux | 16 +- .../translation/jvm/function/abstract.lux | 2 +- .../jvm/function/field/variable/count.lux | 8 +- .../jvm/function/field/variable/foreign.lux | 4 +- .../jvm/function/field/variable/partial.lux | 2 +- .../translation/jvm/function/method/apply.lux | 6 +- .../jvm/function/method/implementation.lux | 2 +- .../translation/jvm/function/method/reset.lux | 4 +- .../lux/phase/translation/jvm/loop.lux | 10 +- .../lux/phase/translation/jvm/reference.lux | 12 +- .../lux/phase/translation/jvm/when.lux | 54 +- .../lux/compiler/language/lux/synthesis.lux | 354 +++++----- .../language/lux/synthesis/access.lux | 4 +- .../language/lux/synthesis/access/item.lux | 46 ++ .../language/lux/synthesis/access/member.lux | 2 +- .../language/lux/synthesis/access/side.lux | 2 +- stdlib/source/test/lux/concurrency/event.lux | 6 +- .../source/test/lux/concurrency/semaphore.lux | 12 +- stdlib/source/test/lux/concurrency/stm.lux | 2 +- .../test/lux/concurrency/structured.lux | 2 +- stdlib/source/test/lux/control/region.lux | 19 +- stdlib/source/test/lux/data/binary.lux | 6 +- .../lux/data/collection/queue/priority.lux | 18 +- stdlib/source/test/lux/meta/extension.lux | 22 +- stdlib/source/test/lux/target/jvm.lux | 4 +- stdlib/source/test/lux/type.lux | 6 +- stdlib/source/test/lux/type/check.lux | 30 +- stdlib/source/test/lux/type/quotient.lux | 2 +- stdlib/source/test/lux/type/record.lux | 2 +- stdlib/source/test/lux/world/file.lux | 6 +- .../source/test/lux/world/net/http/cookie.lux | 2 +- 244 files changed, 2622 insertions(+), 2159 deletions(-) create mode 100644 stdlib/source/library/lux/compiler/extension.lux create mode 100644 stdlib/source/library/lux/compiler/extension/lux.lux create mode 100644 stdlib/source/library/lux/compiler/language/lux/synthesis/access/item.lux create mode 100644 stdlib/source/test/lux/compiler/extension.lux create mode 100644 stdlib/source/test/lux/compiler/extension/lux.lux create mode 100644 stdlib/source/test/lux/compiler/language/lux/synthesis/access/item.lux diff --git a/lux-cl/source/program.lux b/lux-cl/source/program.lux index fd15478bea..e19898faa8 100644 --- a/lux-cl/source/program.lux +++ b/lux-cl/source/program.lux @@ -7,7 +7,7 @@ ["[0]" ffi] ["[0]" debug] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" pipe] ["[0]" maybe] diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index c977235095..7f21ba10a8 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -7,7 +7,7 @@ [program (.only program)] ["[0]" ffi] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe] ["[0]" io (.only IO io)]] @@ -290,7 +290,7 @@ (-> (-> Any java/lang/Object) net/sandius/rembulan/runtime/LuaFunction (Stack java/lang/Object) Any Any) (<| try.trusted (do [! try.monad] - [input/* (monad.each ! ..read parameters)] + [input/* (stack.each' ! ..read parameters)] (loop (again [lux_function abstraction input/* input/*]) (`` (`` (when input/* diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux index 7d4b30785e..5a5b0ce0d7 100644 --- a/lux-php/source/program.lux +++ b/lux-php/source/program.lux @@ -8,7 +8,7 @@ ["[0]" ffi] ["[0]" debug] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [control diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index 10c5e3fb01..15aab7f20d 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -8,7 +8,7 @@ ["[0]" ffi (.only import)] ["[0]" debug] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [control @@ -274,7 +274,7 @@ org/python/core/PyObject (try.trusted (do [! try.monad] - [inputs (monad.each ! ..read (array.stack {.#None} inputs))] + [inputs (stack.each' ! ..read (array.stack {.#None} inputs))] (in (loop (again [it it inputs inputs]) (`` (`` (when inputs diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux index aa6bd714d8..16a4368298 100644 --- a/lux-r/source/program.lux +++ b/lux-r/source/program.lux @@ -7,7 +7,7 @@ ["[0]" ffi] ["[0]" debug] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [control diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 4ede0b3778..22a619953c 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -8,15 +8,15 @@ ["[0]" debug] ["[0]" ffi (.only import)] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [control ["[0]" maybe] ["[0]" io (.only IO io)]] - [error - ["[0]" try (.only Try)] - ["[0]" exception (.only Exception)]] + [error + ["[0]" try (.only Try)] + ["[0]" exception (.only Exception)]] [data ["[0]" text (.use "[1]#[0]" hash) ["%" \\injection] @@ -404,7 +404,7 @@ stack.indices (stack#each (function (_ index) (ffi.read! index args))) - (monad.each ! (|>> (ffi.is java/lang/Object) ..read))) + (stack.each' ! (|>> (ffi.is java/lang/Object) ..read))) output (when args (stack arg/0) (in ((as (-> Any java/lang/Object) value) @@ -862,7 +862,7 @@ (do [! try.monad] [inputs (|> inputs (array.stack {.#None}) - (monad.each ! (|>> (ffi.is java/lang/Object) ..read)))]) + (stack.each' ! (|>> (ffi.is java/lang/Object) ..read)))]) (when inputs ... It seems that org/jruby/runtime/Block::call can misbehave when getting called with a Lux state value. (stack info source provenance current_module modules scopes type_context expected seed scope_type_vars extensions eval host) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index b1c011cb45..0caf09bb45 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -135,71 +135,6 @@ (|>> (by monad each f) (by monad conjoint))) -(the .public (all monad) - (for_any (_ ! it) - (-> (Monad !) (Stack (! it)) - (! (Stack it)))) - (let [(open "/#[0]") monad] - (function (again xs) - (when xs - {.#Empty} - (/#in {.#Empty}) - - {.#Top x xs'} - (|> x - (/#each (function (_ _x) - (/#each (|>> {.#Top _x}) (again xs')))) - /#conjoint))))) - -(the .public (each monad f) - (for_any (_ ! before after) - (-> (Monad !) (-> before (! after)) (Stack before) - (! (Stack after)))) - (let [(open "/#[0]") monad] - (function (again xs) - (when xs - {.#Empty} - (/#in {.#Empty}) - - {.#Top x xs'} - (|> (f x) - (/#each (function (_ _x) - (/#each (|>> {.#Top _x}) (again xs')))) - /#conjoint))))) - -(the .public (only monad f) - (for_any (_ ! it) - (-> (Monad !) (-> it (! Bit)) (Stack it) - (! (Stack it)))) - (let [(open "/#[0]") monad] - (function (again xs) - (when xs - {.#Empty} - (/#in {.#Empty}) - - {.#Top head xs'} - (|> (f head) - (/#each (function (_ verdict) - (/#each (function (_ tail) - (if verdict - {.#Top head tail} - tail)) - (again xs')))) - /#conjoint))))) - -(the .public (mix monad f init xs) - (for_any (_ ! part whole) - (-> (Monad !) (-> part whole (! whole)) whole (Stack part) - (! whole))) - (when xs - {.#Empty} - (by monad in init) - - {.#Top x xs'} - (do monad - [init' (f x init)] - (mix monad f init' xs')))) - (the .public deferred (macro (_ tokens) (when tokens diff --git a/stdlib/source/library/lux/compiler/default/init.lux b/stdlib/source/library/lux/compiler/default/init.lux index 609c323745..ef740130ce 100644 --- a/stdlib/source/library/lux/compiler/default/init.lux +++ b/stdlib/source/library/lux/compiler/default/init.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try (.only Try)] ["[0]" exception]] @@ -109,10 +109,10 @@ (do [! phase.monad] [_ (|> bundle dictionary.entries - (monad.each ! - (function (_ [name handler]) - (///declaration.of_analysis - (moduleA.override_definition [.prelude name] [true {.#Default [.Analysis handler]}])))))] + (stack.each' ! + (function (_ [name handler]) + (///declaration.of_analysis + (moduleA.override_definition [.prelude name] [true {.#Default [.Analysis handler]}])))))] (in []))) (the (with_synthesis_defaults bundle) @@ -121,10 +121,10 @@ (do [! phase.monad] [_ (|> bundle dictionary.entries - (monad.each ! - (function (_ [name handler]) - (///declaration.of_analysis - (moduleA.override_definition [.prelude name] [true {.#Default [.Synthesis handler]}])))))] + (stack.each' ! + (function (_ [name handler]) + (///declaration.of_analysis + (moduleA.override_definition [.prelude name] [true {.#Default [.Synthesis handler]}])))))] (in []))) (the (with_translation_defaults bundle) @@ -134,10 +134,10 @@ (do [! phase.monad] [_ (|> bundle dictionary.entries - (monad.each ! - (function (_ [name handler]) - (///declaration.of_analysis - (moduleA.override_definition [.prelude name] [true {.#Default [.Translation handler]}])))))] + (stack.each' ! + (function (_ [name handler]) + (///declaration.of_analysis + (moduleA.override_definition [.prelude name] [true {.#Default [.Translation handler]}])))))] (in []))) (the (with_declaration_defaults bundle) @@ -147,12 +147,12 @@ (do [! phase.monad] [_ (|> bundle dictionary.entries - (monad.each ! - (function (_ [name handler]) - (do ! - [_ (///declaration.of_analysis - (moduleA.override_definition [.prelude name] [true {.#Default [.Declaration handler]}]))] - (in [])))))] + (stack.each' ! + (function (_ [name handler]) + (do ! + [_ (///declaration.of_analysis + (moduleA.override_definition [.prelude name] [true {.#Default [.Declaration handler]}]))] + (in [])))))] (in []))) (every .public (Extensions anchor expression declaration) @@ -192,7 +192,7 @@ _ (with_defaults module all_extensions)] (///declaration.of_analysis (do [! phase.monad] - [_ (monad.each ! moduleA.import dependencies) + [_ (stack.each' ! moduleA.import dependencies) .let [source (///analysis.source (its ///.#module input) (its ///.#code input))] _ (///analysis.set_source_code source)] (in [source [///translation.empty_buffer @@ -370,7 +370,7 @@ (///translation.set_registry temporary_registry)) _ (|> requirements (its ///declaration.#referrals) - (monad.each ! (execute! archive))) + (stack.each' ! (execute! archive))) temporary_payload (..get_current_payload extender)] (..iteration wrapper archive extender expander module source temporary_payload (..module_aliases analysis_module))))))]}])) )))))]))))) diff --git a/stdlib/source/library/lux/compiler/default/platform.lux b/stdlib/source/library/lux/compiler/default/platform.lux index 57044d5abf..c2d39e7006 100644 --- a/stdlib/source/library/lux/compiler/default/platform.lux +++ b/stdlib/source/library/lux/compiler/default/platform.lux @@ -7,8 +7,7 @@ #host) ["[0]" debug] [abstract - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [concurrency ["[0]" future (.only Future Resolver) (.use "[1]#[0]" monad)] ["[0]" stm (.only Var STM)]] @@ -131,12 +130,12 @@ (its archive.#output) sequence.as_stack (stack.sub 128) - (monad.each ! (monad.each ! write_artifact!)) + (stack.each' ! (stack.each' ! write_artifact!)) (is (Action (Stack (Stack Any))))) (|> entry (its archive.#output) sequence.as_stack - (monad.each ..monad write_artifact!) + (stack.each' ..monad write_artifact!) (is (Action (Stack Any))))) document (by future.monad in (document.marked? key (its [archive.#module moduleM.#document] entry)))] @@ -487,14 +486,14 @@ (-> Archive (Stack ) (Try ))) (do [! try.monad] - [modules (monad.each ! (function (_ module) - (do ! - [entry (archive.find module archive) - lux_module (|> entry - (its [archive.#module moduleM.#document]) - (document.content $.key))] - (in [module lux_module]))) - (archive.archived archive)) + [modules (stack.each' ! (function (_ module) + (do ! + [entry (archive.find module archive) + lux_module (|> entry + (its [archive.#module moduleM.#document]) + (document.content $.key))] + (in [module lux_module]))) + (archive.archived archive)) .let [additions (|> modules (stack#each product.left) (set.of_stack text.hash)) @@ -561,7 +560,7 @@ (do [! future.monad] [attempts (|> new_dependencies (stack#each (import! customs module)) - (monad.all !)) + (stack.all' !)) .let [[failures successes] (sum.partition attempts)]] (in {try.#Success [(|> successes (stack#each product.left) @@ -802,6 +801,6 @@ (future#in (|> custom lux_compiler (function.on parameters)))))) - (monad.all !))] + (stack.all' !))] (import! customs descriptor.runtime program_module)))) ))))) diff --git a/stdlib/source/library/lux/compiler/extension.lux b/stdlib/source/library/lux/compiler/extension.lux new file mode 100644 index 0000000000..62ffd1d388 --- /dev/null +++ b/stdlib/source/library/lux/compiler/extension.lux @@ -0,0 +1,29 @@ +... 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 Name name) + [data + ["[0]" text]]]]) + +(the suffix + "#") + +(every .public Name + Text) + +(the .public name + (-> Text + Name) + (text.suffix ..suffix)) + +(the .public synthesis + (-> Name + Name) + (text.suffix "|synthesis")) + +(the .public translation + (-> Name + Name) + (text.suffix "|translation")) diff --git a/stdlib/source/library/lux/compiler/extension/lux.lux b/stdlib/source/library/lux/compiler/extension/lux.lux new file mode 100644 index 0000000000..9ae37ab826 --- /dev/null +++ b/stdlib/source/library/lux/compiler/extension/lux.lux @@ -0,0 +1,19 @@ +... 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 list) + [macro + ["[0]" template]]]] + ["[0]" //]) + +(template.with [,name] + [(the .public ,name + //.Name + (let [[_ proper] (name ,name)] + (//.name proper)))] + + [list] + [text_composite] + ) diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/compiler/language/lux/analysis.lux index f7f5f6c5a8..0975239f1d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis.lux @@ -164,8 +164,8 @@ (every .public (Reification c) [c (List c)]) -(the .public no_op - (template.macro (no_op @ value) +(the .public coercion + (template.macro (_ @ value) [(|> 1 {variable.#Local} {reference.#Variable} diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/complex.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/complex.lux index 7b494668b9..0d4937109b 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/complex.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/complex.lux @@ -18,43 +18,48 @@ [number ["n" natural]]]]]) -(every .public (Variant a) +(every .public (Variant it) (Record [#lefts Natural #right? Bit - #value a])) + #value it])) -(every .public (Tuple a) - (List a)) +(every .public (Tuple it) + (List it)) -(every .public (Complex a) +(every .public (Complex it) (.Variant - {#Variant (Variant a)} - {#Tuple (Tuple a)})) + {#Variant (Variant it)} + {#Tuple (Tuple it)})) (every .public Tag Natural) (the .public (tag right? lefts) - (-> Bit Natural Tag) + (-> Bit Natural + Tag) (if right? (++ lefts) lefts)) (the .public (lefts right? tag) - (-> Bit Tag Natural) + (-> Bit Tag + Natural) (if right? (-- tag) tag)) (the .public (choice multiplicity pick) - (-> Natural Tag [Natural Bit]) + (-> Natural Tag + [Natural Bit]) (let [right? (n.= (-- multiplicity) pick)] [(..lefts right? pick) right?])) (the .public (equivalence (open "/#[0]")) - (for_any (_ a) (-> (Equivalence a) (Equivalence (Complex a)))) + (for_any (_ it) + (-> (Equivalence it) + (Equivalence (Complex it)))) (implementation (the (= expected actual) (when [expected actual] @@ -71,7 +76,9 @@ false)))) (the .public (hash super) - (for_any (_ a) (-> (Hash a) (Hash (Complex a)))) + (for_any (_ it) + (-> (Hash it) + (Hash (Complex it)))) (implementation (the equivalence (..equivalence (by super equivalence))) @@ -95,7 +102,11 @@ (text.Injection (Complex it)))) (when it {#Variant [lefts right? it]} - (text "{" (%.natural lefts) " " (bit.as_text right?) " " (%it it) "}") + (text "{" + (%.natural lefts) + " " (bit.as_text right?) + " " (%it it) + "}") {#Tuple it} (|> it 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 6a8494775c..3985730ffa 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/coverage.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/coverage.lux @@ -7,7 +7,7 @@ #Bit #Natural #Integer #Revolution #Decimal #Text #Variant) [abstract [equivalence (.only Equivalence)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe (.use "[1]#[0]" monoid monad)]] [error @@ -212,17 +212,38 @@ {.#Top lastP prevsP+} (do [! try.monad] [lastC (coverage lastP)] - (monad.mix ! - (function (_ leftP rightC) - (do ! - [leftC (coverage leftP)] - (when rightC - {#Exhaustive} - (in leftC) - - _ - (in {#Seq leftC rightC})))) - lastC prevsP+))) + (stack.mix' ! + (function (_ leftP rightC) + (do ! + [leftC (coverage leftP)] + (when rightC + {#Exhaustive} + (in leftC) + + _ + (in {#Seq leftC rightC})))) + lastC prevsP+))) + + {//pattern.#List membersP+} + (when (list.as_stack (list.reversed membersP+)) + {.#Empty} + {try.#Success {#Exhaustive}} + + {.#Top lastP prevsP+} + (do [! try.monad] + [lastC (coverage lastP)] + (stack.mix' ! + (function (_ leftP rightC) + (do ! + [leftC (coverage leftP)] + (when rightC + {#Exhaustive} + (in leftC) + + _ + (in {#Seq leftC rightC})))) + lastC + prevsP+))) ... Variant patterns can be shown to be exhaustive if all the possible ... cases are handled exhaustively. @@ -320,18 +341,18 @@ ... else (do [! try.monad] - [casesM (monad.mix ! - (function (_ [tagA coverageA] casesSF') - (when (dictionary.value tagA casesSF') - {try.#Success coverageSF} - (do ! - [coverageM (composite coverageA coverageSF)] - (in (dictionary.has tagA coverageM casesSF'))) - - {try.#Failure _} - (in (dictionary.has tagA coverageA casesSF')))) - casesSF - (dictionary.entries casesA))] + [casesM (stack.mix' ! + (function (_ [tagA coverageA] casesSF') + (when (dictionary.value tagA casesSF') + {try.#Success coverageSF} + (do ! + [coverageM (composite coverageA coverageSF)] + (in (dictionary.has tagA coverageM casesSF'))) + + {try.#Failure _} + (in (dictionary.has tagA coverageA casesSF')))) + casesSF + (dictionary.entries casesA))] (in (if (and (n.= (n.minor addition_cases so_far_cases) (dictionary.size casesM)) (stack.every? ..exhaustive? (dictionary.values casesM))) 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 4a91afebea..3f694996b5 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux @@ -5,7 +5,7 @@ [library [lux (.except variant tuple record) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" pipe] ["[0]" maybe]] @@ -185,7 +185,7 @@ ... (do ! ... [:inference: (/type.check ... (do [! check.monad] - ... [quantifications (monad.mix ! (function (_ @variable level) + ... [quantifications (stack.mix' ! (function (_ @variable level) ... (do ! ... [:variable: (check.try (check.identity variables @variable))] ... (when :variable: diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/module.lux index 3cd7d771d5..48afa1c601 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/module.lux @@ -5,7 +5,7 @@ [library [lux (.except with alias) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" pipe]] [error diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/pattern.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/pattern.lux index d7fc21bb71..7ceecf2b77 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/pattern.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/pattern.lux @@ -5,12 +5,14 @@ [library [lux (.except Pattern text natural integer revolution - variant tuple) + variant tuple list) [abstract [equivalence (.only Equivalence)]] [data ["[0]" text (.only) - ["%" \\injection]]] + ["%" \\injection]] + [collection + ["[0]" list]]] [math [number ["n" natural]]] @@ -29,6 +31,7 @@ (.Variant {#Simple Simple} {#Complex (Complex Pattern)} + {#List (List Pattern)} {#Bind Register}))) (the .public equivalence @@ -42,6 +45,9 @@ [{#Complex expected} {#Complex actual}] (by (//complex.equivalence =) = expected actual) + [{#List expected} {#List actual}] + (by (list.equivalence =) = expected actual) + [{#Bind expected} {#Bind actual}] (n.= expected actual) @@ -59,21 +65,29 @@ {#Complex it} (//complex.as_text as_text it) + + {#List it} + (list.as_text as_text it) {#Bind it} (//variable.as_text {//variable.#Local it}))) (template.with [ ] [(the .public - (template.macro ( content) + (template.macro (_ it) [(.<| {..#Complex} - content)]))] + it)]))] [variant {//complex.#Variant}] [tuple {//complex.#Tuple}] ) +(the .public list + (template.macro (_ it) + [(.<| {..#List} + it)])) + (the .public unit (template.macro (unit) [{..#Simple {//simple.#Unit}}])) diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/type.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/type.lux index a4c841da34..04498afcc6 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/type.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/type.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] ["[0]" function] @@ -94,7 +94,7 @@ ... new_vars (|> post ... (its .#var_bindings) ... (stack.all new!))] - ... _ (monad.each ! (function (_ @new) + ... _ (stack.each' ! (function (_ @new) ... (do ! ... [:new: (check.try (check.identity new_vars @new))] ... (when :new: 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 2abdcc55ec..29535963af 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 @@ -6,7 +6,7 @@ [lux (.except Tag variant tuple record) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe] ["[0]" state]] @@ -266,7 +266,7 @@ _ ... Must infer... (do ! - [membersTA (monad.each ! (|>> (analyse archive) /type.inferring) membersC) + [membersTA (stack.each' ! (|>> (analyse archive) /type.inferring) membersC) _ (/type.check (check.check expectedT (type.tuple (stack#each product.left membersTA)))) @ meta.provenance] @@ -410,11 +410,11 @@ (Operation (Maybe [Natural (Stack Code) Type]))) (do [! phase.monad] [record (<| meta.try - (monad.each ! (function (_ [slot value]) - (do ! - [slot (..slot slot)] - (in [slot value]))) - original_record))] + (stack.each' ! (function (_ [slot value]) + (do ! + [slot (..slot slot)] + (in [slot value]))) + original_record))] (when record {try.#Success record} (do ! 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 cfbc54bc12..beef1a3eae 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 @@ -4,9 +4,9 @@ (.using [library [lux (.except Pattern Analysis - when tuple) + when tuple list) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe]] [error @@ -42,7 +42,10 @@ ["[1][0]" pattern (.only Pattern)] ["[1][0]" type] ["[1][0]" scope] - ["[1][0]" coverage (.only Coverage)]]]]) + ["[1][0]" coverage (.only Coverage)]] + [/// + ["[0]" extension + ["[1]" lux]]]]]) (exception.the .public (mismatch [module type pattern]) (Exception [Text Type Code]) @@ -66,6 +69,11 @@ (exception.report (stack ["Type" (type.as_text type)]))) +(exception.the .public (not_a_list type) + (Exception Type) + (exception.report + (stack ["Type" (type.as_text type)]))) + (exception.the .public (non_exhaustive [module input branches coverage]) (Exception [Text Code (Stack [Code Code]) Coverage]) (exception.report @@ -158,6 +166,61 @@ _ (by check.monad in [(stack) (..quantified envs :it:)])))) +(the .public (list type) + (-> Type + (Check [(Stack type.Variable) Type])) + (loop (list [envs (is (Stack (Stack Type)) + (stack)) + type type]) + (.when type + {.#Variable id} + (do check.monad + [?type (phase.try (check.type id))] + (.when ?type + {try.#Success type} + (list envs type) + + _ + (check.except ..not_a_list type))) + + {.#Named name type} + (list envs type) + + {.#Universal env type} + (list {.#Top env envs} type) + + {.#Existential _} + (do check.monad + [[@head type_of_head] check.var + [tail type] (list envs (maybe.trusted (type.applied (stack type_of_head) type)))] + (in [(stack.partial @head tail) type])) + + {.#Reification _} + (do [! check.monad] + [.let [[:abstraction: :parameters:] (type.flat_application type)] + :abstraction: (.when :abstraction: + {.#Variable @abstraction} + (do ! + [?:abstraction: (phase.try (check.type @abstraction))] + (.when ?:abstraction: + {try.#Success :abstraction:} + (in :abstraction:) + + _ + (check.except ..not_a_list type))) + + _ + (in :abstraction:))] + (.when (type.applied :parameters: :abstraction:) + {.#Some type} + (list envs type) + + {.#None} + (check.except ..not_a_list type))) + + _ + (by check.monad in [(stack) (..quantified envs type)])))) + (the (simple_pattern_analysis type :input: provenance output next) (for_any (_ a) (-> Type Type Provenance Pattern (Operation a) (Operation [Pattern a]))) (/.with_provenance provenance @@ -210,7 +273,7 @@ [nextA next] (in [(stack) nextA])) matches) - _ (/type.check (monad.each check.monad check.forget! @ex_var+))] + _ (/type.check (stack.each' check.monad check.forget! @ex_var+))] (in [(/pattern.tuple (list.of_stack memberP+)) thenA]))) @@ -219,6 +282,37 @@ [[here _] module.current] (/.except ..mismatch [here :input:' (code.tuple sub_patterns)]))))) +(the (list_pattern_analysis pattern_analysis type_of_input sub_patterns next) + (for_any (_ it) + (-> (-> Type Code (Operation it) (Operation [Pattern it])) + Type (Stack Code) (Operation it) (Operation [Pattern it]))) + (do [! phase.monad] + [[@ex_var+ type_of_input] (/type.check (..list type_of_input))] + (.when type_of_input + {.#Nominal list.type (.stack type_of_item)} + (do ! + [[sub_patterns thenA] (stack#mix (is (for_any (_ it) + (-> Code (Operation [(Stack Pattern) it]) + (Operation [(Stack Pattern) it]))) + (function (_ item then) + (do ! + [[head [tail thenA]] ((as (for_any (_ a) (-> Type Code (Operation a) (Operation [Pattern a]))) + pattern_analysis) + type_of_input item then)] + (in [(stack.partial head tail) thenA])))) + (do ! + [nextA next] + (in [(stack) nextA])) + (stack.reversed sub_patterns)) + _ (/type.check (stack.each' check.monad check.forget! @ex_var+))] + (in [(/pattern.list (list.of_stack sub_patterns)) + thenA])) + + _ + (do ! + [[here _] module.current] + (/.except ..mismatch [here type_of_input (` (.list# (,* sub_patterns)))]))))) + (every (Analysis it) (-> Type Code (Operation it) (Operation [Pattern it]))) @@ -249,7 +343,7 @@ (` [(,* values)]) next) (pattern_analysis caseT (` [(,* values)]) next)) - _ (/type.check (monad.each check.monad check.forget! @ex_var+))] + _ (/type.check (stack.each' check.monad check.forget! @ex_var+))] (in [(/pattern.variant [lefts right? testP]) nextA])) @@ -262,7 +356,7 @@ it (pattern_analysis (maybe.trusted (type.applied (stack exT) :input:')) pattern next) - _ (/type.check (monad.each check.monad check.forget! @ex_var+))] + _ (/type.check (stack.each' check.monad check.forget! @ex_var+))] (in it)) _ @@ -270,6 +364,10 @@ [[here _] module.current] (/.except ..mismatch [here :input:' pattern])))))) +(the list_pattern + (template.macro (_ ,@ ,it) + [[,@ {.#Form (stack.partial [,@ {.#Name [.prelude extension.list]}] ,it)}]])) + ... This function handles several concerns at once, but it must be that ... way because those concerns are interleaved when doing ... pattern-matching and they cannot be separated. @@ -346,6 +444,10 @@ {.#None} (..tuple_pattern_analysis pattern_analysis :input: sub_patterns next)))) + (..list_pattern provenance sub_patterns) + (/.with_provenance provenance + (..list_pattern_analysis pattern_analysis :input: sub_patterns next)) + [provenance {.#Variant (stack.partial [_ {.#Bit right?}] values)}] (anonymous_variant pattern_analysis :input: pattern next @@ -384,13 +486,13 @@ [[:input: inputA] (<| /type.inferring (analyse archive inputC)) outputH (pattern_analysis :input: patternH (analyse archive bodyH)) - outputT (monad.each ! - (function (_ [patternT bodyT]) - (pattern_analysis :input: patternT (analyse archive bodyT))) - branchesT) + outputT (stack.each' ! + (function (_ [patternT bodyT]) + (pattern_analysis :input: patternT (analyse archive bodyT))) + branchesT) outputHC (|> outputH product.left /coverage.coverage /.of_try) - outputTC (monad.each ! (|>> product.left /coverage.coverage /.of_try) outputT) - _ (.when (monad.mix try.monad /coverage.composite outputHC outputTC) + outputTC (stack.each' ! (|>> product.left /coverage.coverage /.of_try) outputT) + _ (.when (stack.mix' try.monad /coverage.composite outputHC outputTC) {try.#Success coverage} (do ! [[here _] module.current] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux b/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux index 304c61bd39..15bdd0a819 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try] ["[0]" exception (.only Exception)]] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/js.lux index 800c058b7f..404676045c 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/js.lux @@ -6,8 +6,8 @@ [lux (.except) ["[0]" ffi] [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [collection ["[0]" array] @@ -139,7 +139,7 @@ (do [! phase.monad] [constructorA (analysis/type.expecting Any (phase archive constructorC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference .Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) @@ -167,7 +167,7 @@ (do [! phase.monad] [objectA (analysis/type.expecting Any (phase archive objectC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference .Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) @@ -207,7 +207,7 @@ (do [! phase.monad] [abstractionA (analysis/type.expecting Any (phase archive abstractionC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) 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 ba66157a69..98fd1e8519 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 @@ -5,11 +5,11 @@ [library [lux (.except Type Module Declaration Integer Double #Default #Variable - type) + type with) ["[0]" ffi (.only import)] [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control ["|" pipe] ["[0]" maybe]] @@ -72,7 +72,7 @@ ["[0]" alias (.only Aliasing)] ["[0]T" lux (.only Mapping)]]]]]] ["[0]" // - ["[1][0]" lux (.only custom install)] + ["[1][0]" lux (.only custom with)] ["/[1]" // (.only) ["/[1]" // [translation @@ -336,29 +336,29 @@ (the with_conversion_extensions (-> Bundle Bundle) - (|>> (install "jvm_conversion_double_to_float#" (//lux.unary ..double ..float)) - (install "jvm_conversion_double_to_int#" (//lux.unary ..double ..int)) - (install "jvm_conversion_double_to_long#" (//lux.unary ..double ..long)) - (install "jvm_conversion_float_to_double#" (//lux.unary ..float ..double)) - (install "jvm_conversion_float_to_int#" (//lux.unary ..float ..int)) - (install "jvm_conversion_float_to_long#" (//lux.unary ..float ..long)) - (install "jvm_conversion_int_to_byte#" (//lux.unary ..int ..byte)) - (install "jvm_conversion_int_to_char#" (//lux.unary ..int ..char)) - (install "jvm_conversion_int_to_double#" (//lux.unary ..int ..double)) - (install "jvm_conversion_int_to_float#" (//lux.unary ..int ..float)) - (install "jvm_conversion_int_to_long#" (//lux.unary ..int ..long)) - (install "jvm_conversion_int_to_short#" (//lux.unary ..int ..short)) - (install "jvm_conversion_long_to_double#" (//lux.unary ..long ..double)) - (install "jvm_conversion_long_to_float#" (//lux.unary ..long ..float)) - (install "jvm_conversion_long_to_int#" (//lux.unary ..long ..int)) - (install "jvm_conversion_long_to_short#" (//lux.unary ..long ..short)) - (install "jvm_conversion_long_to_byte#" (//lux.unary ..long ..byte)) - (install "jvm_conversion_char_to_byte#" (//lux.unary ..char ..byte)) - (install "jvm_conversion_char_to_short#" (//lux.unary ..char ..short)) - (install "jvm_conversion_char_to_int#" (//lux.unary ..char ..int)) - (install "jvm_conversion_char_to_long#" (//lux.unary ..char ..long)) - (install "jvm_conversion_byte_to_long#" (//lux.unary ..byte ..long)) - (install "jvm_conversion_short_to_long#" (//lux.unary ..short ..long)) + (|>> (with "jvm_conversion_double_to_float#" (//lux.unary ..double ..float)) + (with "jvm_conversion_double_to_int#" (//lux.unary ..double ..int)) + (with "jvm_conversion_double_to_long#" (//lux.unary ..double ..long)) + (with "jvm_conversion_float_to_double#" (//lux.unary ..float ..double)) + (with "jvm_conversion_float_to_int#" (//lux.unary ..float ..int)) + (with "jvm_conversion_float_to_long#" (//lux.unary ..float ..long)) + (with "jvm_conversion_int_to_byte#" (//lux.unary ..int ..byte)) + (with "jvm_conversion_int_to_char#" (//lux.unary ..int ..char)) + (with "jvm_conversion_int_to_double#" (//lux.unary ..int ..double)) + (with "jvm_conversion_int_to_float#" (//lux.unary ..int ..float)) + (with "jvm_conversion_int_to_long#" (//lux.unary ..int ..long)) + (with "jvm_conversion_int_to_short#" (//lux.unary ..int ..short)) + (with "jvm_conversion_long_to_double#" (//lux.unary ..long ..double)) + (with "jvm_conversion_long_to_float#" (//lux.unary ..long ..float)) + (with "jvm_conversion_long_to_int#" (//lux.unary ..long ..int)) + (with "jvm_conversion_long_to_short#" (//lux.unary ..long ..short)) + (with "jvm_conversion_long_to_byte#" (//lux.unary ..long ..byte)) + (with "jvm_conversion_char_to_byte#" (//lux.unary ..char ..byte)) + (with "jvm_conversion_char_to_short#" (//lux.unary ..char ..short)) + (with "jvm_conversion_char_to_int#" (//lux.unary ..char ..int)) + (with "jvm_conversion_char_to_long#" (//lux.unary ..char ..long)) + (with "jvm_conversion_byte_to_long#" (//lux.unary ..byte ..long)) + (with "jvm_conversion_short_to_long#" (//lux.unary ..short ..long)) )) (template.with [ ] @@ -366,19 +366,19 @@ (-> Bundle Bundle) (let [type (reflection.reflection )] - (|>> (install (text "jvm_" type "_" "+" "#") (//lux.binary )) - (install (text "jvm_" type "_" "-" "#") (//lux.binary )) - (install (text "jvm_" type "_" "*" "#") (//lux.binary )) - (install (text "jvm_" type "_" "/" "#") (//lux.binary )) - (install (text "jvm_" type "_" "%" "#") (//lux.binary )) - (install (text "jvm_" type "_" "=" "#") (//lux.binary Bit)) - (install (text "jvm_" type "_" "<" "#") (//lux.binary Bit)) - (install (text "jvm_" type "_" "and" "#") (//lux.binary )) - (install (text "jvm_" type "_" "or" "#") (//lux.binary )) - (install (text "jvm_" type "_" "xor" "#") (//lux.binary )) - (install (text "jvm_" type "_" "shl" "#") (//lux.binary ..int )) - (install (text "jvm_" type "_" "shr" "#") (//lux.binary ..int )) - (install (text "jvm_" type "_" "ushr" "#") (//lux.binary ..int )) + (|>> (with (text "jvm_" type "_" "+" "#") (//lux.binary )) + (with (text "jvm_" type "_" "-" "#") (//lux.binary )) + (with (text "jvm_" type "_" "*" "#") (//lux.binary )) + (with (text "jvm_" type "_" "/" "#") (//lux.binary )) + (with (text "jvm_" type "_" "%" "#") (//lux.binary )) + (with (text "jvm_" type "_" "=" "#") (//lux.binary Bit)) + (with (text "jvm_" type "_" "<" "#") (//lux.binary Bit)) + (with (text "jvm_" type "_" "and" "#") (//lux.binary )) + (with (text "jvm_" type "_" "or" "#") (//lux.binary )) + (with (text "jvm_" type "_" "xor" "#") (//lux.binary )) + (with (text "jvm_" type "_" "shl" "#") (//lux.binary ..int )) + (with (text "jvm_" type "_" "shr" "#") (//lux.binary ..int )) + (with (text "jvm_" type "_" "ushr" "#") (//lux.binary ..int )) )))] [with_int_extensions reflection.int ..int] @@ -390,13 +390,13 @@ (-> Bundle Bundle) (let [type (reflection.reflection )] - (|>> (install (text "jvm_" type "_" "+" "#") (//lux.binary )) - (install (text "jvm_" type "_" "-" "#") (//lux.binary )) - (install (text "jvm_" type "_" "*" "#") (//lux.binary )) - (install (text "jvm_" type "_" "/" "#") (//lux.binary )) - (install (text "jvm_" type "_" "%" "#") (//lux.binary )) - (install (text "jvm_" type "_" "=" "#") (//lux.binary Bit)) - (install (text "jvm_" type "_" "<" "#") (//lux.binary Bit)) + (|>> (with (text "jvm_" type "_" "+" "#") (//lux.binary )) + (with (text "jvm_" type "_" "-" "#") (//lux.binary )) + (with (text "jvm_" type "_" "*" "#") (//lux.binary )) + (with (text "jvm_" type "_" "/" "#") (//lux.binary )) + (with (text "jvm_" type "_" "%" "#") (//lux.binary )) + (with (text "jvm_" type "_" "=" "#") (//lux.binary Bit)) + (with (text "jvm_" type "_" "<" "#") (//lux.binary Bit)) )))] [with_float_extensions reflection.float ..float] @@ -407,8 +407,8 @@ (-> Bundle Bundle) (let [type (reflection.reflection reflection.char)] - (|>> (install (text "jvm_" type "_" "=" "#") (//lux.binary ..char ..char Bit)) - (install (text "jvm_" type "_" "<" "#") (//lux.binary ..char ..char Bit)) + (|>> (with (text "jvm_" type "_" "=" "#") (//lux.binary ..char ..char Bit)) + (with (text "jvm_" type "_" "<" "#") (//lux.binary ..char ..char Bit)) ))) (the .public boxes @@ -457,17 +457,17 @@ {try.#Failure _} (do [! phase.monad] [parametersJT (is (Operation (Stack (Type Parameter))) - (monad.each ! - (function (_ parameterT) - (do phase.monad - [parameterJT (jvm_type parameterT)] - (when (projection.parameter? parameterJT) - {.#Some parameterJT} - (in parameterJT) - - {.#None} - (analysis.except ..non_parameter parameterT)))) - parametersT))] + (stack.each' ! + (function (_ parameterT) + (do phase.monad + [parameterJT (jvm_type parameterT)] + (when (projection.parameter? parameterJT) + {.#Some parameterJT} + (in parameterJT) + + {.#None} + (analysis.except ..non_parameter parameterT)))) + parametersT))] (in (jvm.class parametersJT class)))) {.#Opaque _} @@ -671,7 +671,7 @@ {.#Nominal name parameters} (do [! phase.monad] - [parameters (monad.each ! check_parameter parameters)] + [parameters (stack.each' ! check_parameter parameters)] (phase#in (jvm.class parameters name))) {.#Named name anonymous} @@ -824,45 +824,45 @@ (the with_array_extensions (-> Bundle Bundle) - (|>> (install (text "jvm_" "array_" "length_" (reflection.reflection reflection.boolean) "#") (primitive_array_length_handler jvm.boolean)) - (install (text "jvm_" "array_" "length_" (reflection.reflection reflection.byte) "#") (primitive_array_length_handler jvm.byte)) - (install (text "jvm_" "array_" "length_" (reflection.reflection reflection.short) "#") (primitive_array_length_handler jvm.short)) - (install (text "jvm_" "array_" "length_" (reflection.reflection reflection.int) "#") (primitive_array_length_handler jvm.int)) - (install (text "jvm_" "array_" "length_" (reflection.reflection reflection.long) "#") (primitive_array_length_handler jvm.long)) - (install (text "jvm_" "array_" "length_" (reflection.reflection reflection.float) "#") (primitive_array_length_handler jvm.float)) - (install (text "jvm_" "array_" "length_" (reflection.reflection reflection.double) "#") (primitive_array_length_handler jvm.double)) - (install (text "jvm_" "array_" "length_" (reflection.reflection reflection.char) "#") (primitive_array_length_handler jvm.char)) - (install (text "jvm_" "array_" "length_" "object" "#") array::length::object) - - (install (text "jvm_" "array_" "new_" (reflection.reflection reflection.boolean) "#") (new_primitive_array_handler jvm.boolean)) - (install (text "jvm_" "array_" "new_" (reflection.reflection reflection.byte) "#") (new_primitive_array_handler jvm.byte)) - (install (text "jvm_" "array_" "new_" (reflection.reflection reflection.short) "#") (new_primitive_array_handler jvm.short)) - (install (text "jvm_" "array_" "new_" (reflection.reflection reflection.int) "#") (new_primitive_array_handler jvm.int)) - (install (text "jvm_" "array_" "new_" (reflection.reflection reflection.long) "#") (new_primitive_array_handler jvm.long)) - (install (text "jvm_" "array_" "new_" (reflection.reflection reflection.float) "#") (new_primitive_array_handler jvm.float)) - (install (text "jvm_" "array_" "new_" (reflection.reflection reflection.double) "#") (new_primitive_array_handler jvm.double)) - (install (text "jvm_" "array_" "new_" (reflection.reflection reflection.char) "#") (new_primitive_array_handler jvm.char)) - (install (text "jvm_" "array_" "new_" "object" "#") array::new::object) - - (install (text "jvm_" "array_" "read_" (reflection.reflection reflection.boolean) "#") (read_primitive_array_handler ..boolean jvm.boolean)) - (install (text "jvm_" "array_" "read_" (reflection.reflection reflection.byte) "#") (read_primitive_array_handler ..byte jvm.byte)) - (install (text "jvm_" "array_" "read_" (reflection.reflection reflection.short) "#") (read_primitive_array_handler ..short jvm.short)) - (install (text "jvm_" "array_" "read_" (reflection.reflection reflection.int) "#") (read_primitive_array_handler ..int jvm.int)) - (install (text "jvm_" "array_" "read_" (reflection.reflection reflection.long) "#") (read_primitive_array_handler ..long jvm.long)) - (install (text "jvm_" "array_" "read_" (reflection.reflection reflection.float) "#") (read_primitive_array_handler ..float jvm.float)) - (install (text "jvm_" "array_" "read_" (reflection.reflection reflection.double) "#") (read_primitive_array_handler ..double jvm.double)) - (install (text "jvm_" "array_" "read_" (reflection.reflection reflection.char) "#") (read_primitive_array_handler ..char jvm.char)) - (install (text "jvm_" "array_" "read_" "object" "#") array::read::object) - - (install (text "jvm_" "array_" "write_" (reflection.reflection reflection.boolean) "#") (write_primitive_array_handler ..boolean jvm.boolean)) - (install (text "jvm_" "array_" "write_" (reflection.reflection reflection.byte) "#") (write_primitive_array_handler ..byte jvm.byte)) - (install (text "jvm_" "array_" "write_" (reflection.reflection reflection.short) "#") (write_primitive_array_handler ..short jvm.short)) - (install (text "jvm_" "array_" "write_" (reflection.reflection reflection.int) "#") (write_primitive_array_handler ..int jvm.int)) - (install (text "jvm_" "array_" "write_" (reflection.reflection reflection.long) "#") (write_primitive_array_handler ..long jvm.long)) - (install (text "jvm_" "array_" "write_" (reflection.reflection reflection.float) "#") (write_primitive_array_handler ..float jvm.float)) - (install (text "jvm_" "array_" "write_" (reflection.reflection reflection.double) "#") (write_primitive_array_handler ..double jvm.double)) - (install (text "jvm_" "array_" "write_" (reflection.reflection reflection.char) "#") (write_primitive_array_handler ..char jvm.char)) - (install (text "jvm_" "array_" "write_" "object" "#") array::write::object) + (|>> (with (text "jvm_" "array_" "length_" (reflection.reflection reflection.boolean) "#") (primitive_array_length_handler jvm.boolean)) + (with (text "jvm_" "array_" "length_" (reflection.reflection reflection.byte) "#") (primitive_array_length_handler jvm.byte)) + (with (text "jvm_" "array_" "length_" (reflection.reflection reflection.short) "#") (primitive_array_length_handler jvm.short)) + (with (text "jvm_" "array_" "length_" (reflection.reflection reflection.int) "#") (primitive_array_length_handler jvm.int)) + (with (text "jvm_" "array_" "length_" (reflection.reflection reflection.long) "#") (primitive_array_length_handler jvm.long)) + (with (text "jvm_" "array_" "length_" (reflection.reflection reflection.float) "#") (primitive_array_length_handler jvm.float)) + (with (text "jvm_" "array_" "length_" (reflection.reflection reflection.double) "#") (primitive_array_length_handler jvm.double)) + (with (text "jvm_" "array_" "length_" (reflection.reflection reflection.char) "#") (primitive_array_length_handler jvm.char)) + (with (text "jvm_" "array_" "length_" "object" "#") array::length::object) + + (with (text "jvm_" "array_" "new_" (reflection.reflection reflection.boolean) "#") (new_primitive_array_handler jvm.boolean)) + (with (text "jvm_" "array_" "new_" (reflection.reflection reflection.byte) "#") (new_primitive_array_handler jvm.byte)) + (with (text "jvm_" "array_" "new_" (reflection.reflection reflection.short) "#") (new_primitive_array_handler jvm.short)) + (with (text "jvm_" "array_" "new_" (reflection.reflection reflection.int) "#") (new_primitive_array_handler jvm.int)) + (with (text "jvm_" "array_" "new_" (reflection.reflection reflection.long) "#") (new_primitive_array_handler jvm.long)) + (with (text "jvm_" "array_" "new_" (reflection.reflection reflection.float) "#") (new_primitive_array_handler jvm.float)) + (with (text "jvm_" "array_" "new_" (reflection.reflection reflection.double) "#") (new_primitive_array_handler jvm.double)) + (with (text "jvm_" "array_" "new_" (reflection.reflection reflection.char) "#") (new_primitive_array_handler jvm.char)) + (with (text "jvm_" "array_" "new_" "object" "#") array::new::object) + + (with (text "jvm_" "array_" "read_" (reflection.reflection reflection.boolean) "#") (read_primitive_array_handler ..boolean jvm.boolean)) + (with (text "jvm_" "array_" "read_" (reflection.reflection reflection.byte) "#") (read_primitive_array_handler ..byte jvm.byte)) + (with (text "jvm_" "array_" "read_" (reflection.reflection reflection.short) "#") (read_primitive_array_handler ..short jvm.short)) + (with (text "jvm_" "array_" "read_" (reflection.reflection reflection.int) "#") (read_primitive_array_handler ..int jvm.int)) + (with (text "jvm_" "array_" "read_" (reflection.reflection reflection.long) "#") (read_primitive_array_handler ..long jvm.long)) + (with (text "jvm_" "array_" "read_" (reflection.reflection reflection.float) "#") (read_primitive_array_handler ..float jvm.float)) + (with (text "jvm_" "array_" "read_" (reflection.reflection reflection.double) "#") (read_primitive_array_handler ..double jvm.double)) + (with (text "jvm_" "array_" "read_" (reflection.reflection reflection.char) "#") (read_primitive_array_handler ..char jvm.char)) + (with (text "jvm_" "array_" "read_" "object" "#") array::read::object) + + (with (text "jvm_" "array_" "write_" (reflection.reflection reflection.boolean) "#") (write_primitive_array_handler ..boolean jvm.boolean)) + (with (text "jvm_" "array_" "write_" (reflection.reflection reflection.byte) "#") (write_primitive_array_handler ..byte jvm.byte)) + (with (text "jvm_" "array_" "write_" (reflection.reflection reflection.short) "#") (write_primitive_array_handler ..short jvm.short)) + (with (text "jvm_" "array_" "write_" (reflection.reflection reflection.int) "#") (write_primitive_array_handler ..int jvm.int)) + (with (text "jvm_" "array_" "write_" (reflection.reflection reflection.long) "#") (write_primitive_array_handler ..long jvm.long)) + (with (text "jvm_" "array_" "write_" (reflection.reflection reflection.float) "#") (write_primitive_array_handler ..float jvm.float)) + (with (text "jvm_" "array_" "write_" (reflection.reflection reflection.double) "#") (write_primitive_array_handler ..double jvm.double)) + (with (text "jvm_" "array_" "write_" (reflection.reflection reflection.char) "#") (write_primitive_array_handler ..char jvm.char)) + (with (text "jvm_" "array_" "write_" "object" "#") array::write::object) )) (the object::null @@ -965,27 +965,27 @@ (do [! phase.monad] [from_class (phase.of_try (reflection!.load class_loader from_name)) mapping (phase.of_try (reflection!.correspond from_class fromT))] - (monad.each ! - (function (_ superJT) - (do ! - [superJT (phase.of_try (reflection!.type superJT)) - .let [super_name (..reflection superJT)] - super_class (phase.of_try (reflection!.load class_loader super_name)) - superT (reflection_type mapping superJT)] - (in [[super_name superT] - (ffi.of_boolean (java/lang/Class::isAssignableFrom [super_class] to_class))]))) - (when (java/lang/Class::getGenericSuperclass [] from_class) - {.#Some super} - (stack.partial super (array.stack {.#None} (java/lang/Class::getGenericInterfaces [] from_class))) - - {.#None} - (if (|> from_class - (java/lang/Class::getModifiers []) - [] java/lang/reflect/Modifier::isInterface - ffi.of_boolean) - {.#Top (as java/lang/reflect/Type (ffi.class_for java/lang/Object)) - (array.stack {.#None} (java/lang/Class::getGenericInterfaces [] from_class))} - (array.stack {.#None} (java/lang/Class::getGenericInterfaces [] from_class))))))) + (stack.each' ! + (function (_ superJT) + (do ! + [superJT (phase.of_try (reflection!.type superJT)) + .let [super_name (..reflection superJT)] + super_class (phase.of_try (reflection!.load class_loader super_name)) + superT (reflection_type mapping superJT)] + (in [[super_name superT] + (ffi.of_boolean (java/lang/Class::isAssignableFrom [super_class] to_class))]))) + (when (java/lang/Class::getGenericSuperclass [] from_class) + {.#Some super} + (stack.partial super (array.stack {.#None} (java/lang/Class::getGenericInterfaces [] from_class))) + + {.#None} + (if (|> from_class + (java/lang/Class::getModifiers []) + [] java/lang/reflect/Modifier::isInterface + ffi.of_boolean) + {.#Top (as java/lang/reflect/Type (ffi.class_for java/lang/Object)) + (array.stack {.#None} (java/lang/Class::getGenericInterfaces [] from_class))} + (array.stack {.#None} (java/lang/Class::getGenericInterfaces [] from_class))))))) (the (object::cast class_loader) (-> java/lang/ClassLoader @@ -1063,13 +1063,13 @@ (the (with_object_extensions class_loader) (-> java/lang/ClassLoader (-> Bundle Bundle)) - (|>> (install (text "jvm_" "object_" "null" "#") object::null) - (install (text "jvm_" "object_" "null?" "#") object::null?) - (install (text "jvm_" "object_" "synchronized" "#") object::synchronized) - (install (text "jvm_" "object_" "throw" "#") (object::throw class_loader)) - (install (text "jvm_" "object_" "class" "#") (object::class class_loader)) - (install (text "jvm_" "object_" "instance?" "#") (object::instance? class_loader)) - (install (text "jvm_" "object_" "cast" "#") (object::cast class_loader)) + (|>> (with (text "jvm_" "object_" "null" "#") object::null) + (with (text "jvm_" "object_" "null?" "#") object::null?) + (with (text "jvm_" "object_" "synchronized" "#") object::synchronized) + (with (text "jvm_" "object_" "throw" "#") (object::throw class_loader)) + (with (text "jvm_" "object_" "class" "#") (object::class class_loader)) + (with (text "jvm_" "object_" "instance?" "#") (object::instance? class_loader)) + (with (text "jvm_" "object_" "cast" "#") (object::cast class_loader)) )) (the (get::static class_loader) @@ -1227,7 +1227,7 @@ [parameters (|> method (java/lang/reflect/Method::getGenericParameterTypes []) (array.stack {.#None}) - (monad.each try.monad reflection!.type) + (stack.each' try.monad reflection!.type) phase.of_try) .let [modifiers (java/lang/reflect/Method::getModifiers [] method) correct_class? (|> method @@ -1269,7 +1269,7 @@ [parameters (|> constructor (java/lang/reflect/Constructor::getGenericParameterTypes []) (array.stack {.#None}) - (monad.each try.monad reflection!.type) + (stack.each' try.monad reflection!.type) phase.of_try)] (in (and (ffi.of_boolean (|> constructor (java/lang/reflect/Constructor::getDeclaringClass []) @@ -1355,19 +1355,19 @@ [inputsT' (|> method (java/lang/reflect/Method::getGenericParameterTypes []) (array.stack {.#None}) - (monad.each ! (|>> reflection!.type phase.of_try))) - inputsT (monad.each ! (..reflection_type mapping) inputsT') + (stack.each' ! (|>> reflection!.type phase.of_try))) + inputsT (stack.each' ! (..reflection_type mapping) inputsT') outputT' (|> method ..return_type phase.of_try) outputT (..reflection_return mapping outputT') .let [concrete_exceptions (..concrete_method_exceptions method)] - concrete_exceptions (monad.each ! (..reflection_type mapping) concrete_exceptions) + concrete_exceptions (stack.each' ! (..reflection_type mapping) concrete_exceptions) generic_exceptions (|> method (java/lang/reflect/Method::getGenericExceptionTypes []) (array.stack {.#None}) - (monad.each ! (|>> reflection!.type phase.of_try)) - (phase#each (monad.each ! (..reflection_type mapping))) + (stack.each' ! (|>> reflection!.type phase.of_try)) + (phase#each (stack.each' ! (..reflection_type mapping))) phase#conjoint) .let [methodT (<| (type.univ_q (dictionary.size mapping)) (type.function (when method_style @@ -1408,15 +1408,15 @@ [inputsT' (|> constructor (java/lang/reflect/Constructor::getGenericParameterTypes []) (array.stack {.#None}) - (monad.each ! (|>> reflection!.type phase.of_try))) - inputsT (monad.each ! (reflection_type mapping) inputsT') + (stack.each' ! (|>> reflection!.type phase.of_try))) + inputsT (stack.each' ! (reflection_type mapping) inputsT') .let [concrete_exceptions (..concrete_constructor_exceptions constructor)] - concrete_exceptions (monad.each ! (..reflection_type mapping) concrete_exceptions) + concrete_exceptions (stack.each' ! (..reflection_type mapping) concrete_exceptions) generic_exceptions (|> constructor (java/lang/reflect/Constructor::getGenericExceptionTypes []) (array.stack {.#None}) - (monad.each ! (|>> reflection!.type phase.of_try)) - (phase#each (monad.each ! (reflection_type mapping))) + (stack.each' ! (|>> reflection!.type phase.of_try)) + (phase#each (stack.each' ! (reflection_type mapping))) phase#conjoint) .let [objectT {.#Nominal (ffi.of_string (java/lang/Class::getName [] owner)) owner_tvarsT} @@ -1521,17 +1521,17 @@ (stack.only (|>> (java/lang/reflect/Method::getName []) ffi.of_string (text.= method_name))) - (monad.each ! (is (-> java/lang/reflect/Method (Operation Evaluation)) - (function (_ method) - (do ! - [.let [expected_method_tvars (method_type_variables method) - aliasing (dictionary.composite (..aliasing expected_class_tvars actual_class_tvars) - (..aliasing expected_method_tvars actual_method_tvars))] - passes? (check_method aliasing class method_name method_style inputsJT method)] - (by ! each (if passes? - (|>> {#Pass}) - (|>> {#Hint})) - (method_signature method_style method)))))))] + (stack.each' ! (is (-> java/lang/reflect/Method (Operation Evaluation)) + (function (_ method) + (do ! + [.let [expected_method_tvars (method_type_variables method) + aliasing (dictionary.composite (..aliasing expected_class_tvars actual_class_tvars) + (..aliasing expected_method_tvars actual_method_tvars))] + passes? (check_method aliasing class method_name method_style inputsJT method)] + (by ! each (if passes? + (|>> {#Pass}) + (|>> {#Hint})) + (method_signature method_style method)))))))] (when (stack.all pass candidates) {.#Top method {.#Empty}} (in method) @@ -1556,17 +1556,17 @@ candidates (|> class (java/lang/Class::getConstructors []) (array.stack {.#None}) - (monad.each ! (function (_ constructor) - (do ! - [.let [expected_method_tvars (constructor_type_variables constructor) - aliasing (dictionary.composite (..aliasing expected_class_tvars actual_class_tvars) - (..aliasing expected_method_tvars actual_method_tvars))] - passes? (check_constructor aliasing class inputsJT constructor)] - (by ! each - (if passes? - (|>> {#Pass}) - (|>> {#Hint})) - (constructor_signature constructor))))))] + (stack.each' ! (function (_ constructor) + (do ! + [.let [expected_method_tvars (constructor_type_variables constructor) + aliasing (dictionary.composite (..aliasing expected_class_tvars actual_class_tvars) + (..aliasing expected_method_tvars actual_method_tvars))] + passes? (check_constructor aliasing class inputsJT constructor)] + (by ! each + (if passes? + (|>> {#Pass}) + (|>> {#Hint})) + (constructor_signature constructor))))))] (when (stack.all pass candidates) {.#Top constructor {.#Empty}} (in constructor) @@ -1745,17 +1745,17 @@ (the (with_member_extensions class_loader) (-> java/lang/ClassLoader (-> Bundle Bundle)) - (|>> (install "jvm_member_get_static#" (get::static class_loader)) - (install "jvm_member_get_virtual#" (get::virtual class_loader)) + (|>> (with "jvm_member_get_static#" (get::static class_loader)) + (with "jvm_member_get_virtual#" (get::virtual class_loader)) - (install "jvm_member_put_static#" (put::static class_loader)) - (install "jvm_member_put_virtual#" (put::virtual class_loader)) + (with "jvm_member_put_static#" (put::static class_loader)) + (with "jvm_member_put_virtual#" (put::virtual class_loader)) - (install "jvm_member_invoke_static#" (invoke::static class_loader)) - (install "jvm_member_invoke_virtual#" (invoke::virtual class_loader)) - (install "jvm_member_invoke_special#" (invoke::special class_loader)) - (install "jvm_member_invoke_interface#" (invoke::interface class_loader)) - (install "jvm_member_invoke_constructor#" (invoke::constructor class_loader)) + (with "jvm_member_invoke_static#" (invoke::static class_loader)) + (with "jvm_member_invoke_virtual#" (invoke::virtual class_loader)) + (with "jvm_member_invoke_special#" (invoke::special class_loader)) + (with "jvm_member_invoke_interface#" (invoke::interface class_loader)) + (with "jvm_member_invoke_constructor#" (invoke::constructor class_loader)) )) (.every .public (Annotation_Parameter a) @@ -1823,30 +1823,30 @@ (predicate.or (|>> [] java/lang/reflect/Modifier::isPublic ffi.of_boolean) (|>> [] java/lang/reflect/Modifier::isProtected ffi.of_boolean)))) - (monad.each try.monad - (function (_ method) - (do [! try.monad] - [.let [type_variables (|> method - (java/lang/reflect/Method::getTypeParameters []) - (array.stack {.#None}) - (stack#each (|>> (java/lang/reflect/TypeVariable::getName []) - ffi.of_string - jvm.var)))] - inputs (|> method - (java/lang/reflect/Method::getGenericParameterTypes []) - (array.stack {.#None}) - (monad.each ! reflection!.type)) - return (..return_type method) - .let [concrete_exceptions (..concrete_method_exceptions method)] - generic_exceptions (|> method - (java/lang/reflect/Method::getGenericExceptionTypes []) - (array.stack {.#None}) - (monad.each ! reflection!.class))] - (in [type - (ffi.of_string (java/lang/reflect/Method::getName [] method)) - (jvm.method [type_variables inputs return (if (stack.empty? generic_exceptions) - concrete_exceptions - generic_exceptions)])]))))))] + (stack.each' try.monad + (function (_ method) + (do [! try.monad] + [.let [type_variables (|> method + (java/lang/reflect/Method::getTypeParameters []) + (array.stack {.#None}) + (stack#each (|>> (java/lang/reflect/TypeVariable::getName []) + ffi.of_string + jvm.var)))] + inputs (|> method + (java/lang/reflect/Method::getGenericParameterTypes []) + (array.stack {.#None}) + (stack.each' ! reflection!.type)) + return (..return_type method) + .let [concrete_exceptions (..concrete_method_exceptions method)] + generic_exceptions (|> method + (java/lang/reflect/Method::getGenericExceptionTypes []) + (array.stack {.#None}) + (stack.each' ! reflection!.class))] + (in [type + (ffi.of_string (java/lang/reflect/Method::getName [] method)) + (jvm.method [type_variables inputs return (if (stack.empty? generic_exceptions) + concrete_exceptions + generic_exceptions)])]))))))] [abstract_methods (stack.only (|>> (java/lang/reflect/Method::getModifiers []) [] java/lang/reflect/Modifier::isAbstract @@ -1863,12 +1863,12 @@ [(the ( class_loader) (-> java/lang/ClassLoader (Stack (Type Class)) (Try (Stack [(Type Class) Text (Type Method)]))) - (|>> (monad.each try.monad (function (_ type) - (|> type - ..reflection - (reflection!.load class_loader) - (try#each (|>> [type]))))) - (try#each (monad.each try.monad )) + (|>> (stack.each' try.monad (function (_ type) + (|> type + ..reflection + (reflection!.load class_loader) + (try#each (|>> [type]))))) + (try#each (stack.each' try.monad )) try#conjoint (try#each stack#conjoint)))] @@ -1934,11 +1934,11 @@ (the .public parameter_types (-> (Stack (Type Var)) (Check (Stack [(Type Var) .Type]))) - (monad.each check.monad - (function (_ parameterJ) - (do check.monad - [[_ parameterT] check.existential] - (in [parameterJ parameterT]))))) + (stack.each' check.monad + (function (_ parameterJ) + (do check.monad + [[_ parameterT] check.existential] + (in [parameterJ parameterT]))))) (.every .public (Abstract_Method a) [Text @@ -1984,15 +1984,15 @@ (let [[method_name visibility annotations vars arguments return exceptions] method] (do [! phase.monad] [mapping (typeA.check (method_mapping luxT.fresh vars)) - annotationsA (monad.each ! (function (_ [name parameters]) - (do ! - [parametersA (monad.each ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) + annotationsA (stack.each' ! (function (_ [name parameters]) + (do ! + [parametersA (stack.each' ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) @ meta.provenance] (in (analysis.tuple @ (list (analysis.text @ ..abstract_tag) (analysis.text @ method_name) @@ -2047,6 +2047,9 @@ {complex.#Tuple it} {complex.#Tuple (list#each with_fake_parameter#pattern it)})} + + {pattern.#List it} + {pattern.#List (list#each with_fake_parameter#pattern it)} {pattern.#Bind it} {pattern.#Bind (++ it)})) @@ -2151,28 +2154,28 @@ self_name arguments super_arguments body] method] (do [! phase.monad] [mapping (typeA.check (method_mapping mapping vars)) - annotationsA (monad.each ! (function (_ [name parameters]) - (do ! - [parametersA (monad.each ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) - super_arguments (monad.each ! (function (_ [jvmT super_argC]) - (do ! - [luxT (reflection_type mapping jvmT) - super_argA (<| (typeA.expecting luxT) - (analyse archive super_argC))] - (in [jvmT super_argA]))) - super_arguments) - arguments' (monad.each ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + annotationsA (stack.each' ! (function (_ [name parameters]) + (do ! + [parametersA (stack.each' ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) + super_arguments (stack.each' ! (function (_ [jvmT super_argC]) + (do ! + [luxT (reflection_type mapping jvmT) + super_argA (<| (typeA.expecting luxT) + (analyse archive super_argC))] + (in [jvmT super_argA]))) + super_arguments) + arguments' (stack.each' ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) [scope bodyA] (|> arguments' {.#Top [self_name selfT]} stack.reversed @@ -2261,22 +2264,22 @@ body] method] (do [! phase.monad] [mapping (typeA.check (method_mapping mapping vars)) - annotationsA (monad.each ! (function (_ [name parameters]) - (do ! - [parametersA (monad.each ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) + annotationsA (stack.each' ! (function (_ [name parameters]) + (do ! + [parametersA (stack.each' ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) :return: (boxed_reflection_return mapping return) - arguments' (monad.each ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + arguments' (stack.each' ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) [scope bodyA] (|> arguments' {.#Top [self_name selfT]} stack.reversed @@ -2342,22 +2345,22 @@ body] method] (do [! phase.monad] [mapping (typeA.check (method_mapping mapping vars)) - annotationsA (monad.each ! (function (_ [name parameters]) - (do ! - [parametersA (monad.each ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) + annotationsA (stack.each' ! (function (_ [name parameters]) + (do ! + [parametersA (stack.each' ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) :return: (boxed_reflection_return mapping return) - arguments' (monad.each ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + arguments' (stack.each' ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) [scope bodyA] (|> arguments' stack.reversed (stack#mix scope.with_local (analyse archive body)) @@ -2439,11 +2442,11 @@ (if (n.= expected_count actual_count) (do [! phase.monad] [parent_parameters (|> parent_parameters - (monad.each maybe.monad projection.var?) + (stack.each' maybe.monad projection.var?) (try.of_maybe "Not all parameters are type variables.") phase.of_try)] (|> super_parameters - (monad.each ! (..reflection_type mapping)) + (stack.each' ! (..reflection_type mapping)) (by ! each (|>> (stack.zipped_2 parent_parameters))))) (phase.of_try (exception.except ..mismatched_super_parameters [parent_name expected_count actual_count])))) @@ -2470,21 +2473,21 @@ (do [! phase.monad] [mapping (..with_override_mapping supers parent_type mapping) mapping (typeA.check (method_mapping mapping vars)) - annotationsA (monad.each ! (function (_ [name parameters]) - (do ! - [parametersA (monad.each ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) - arguments' (monad.each ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + annotationsA (stack.each' ! (function (_ [name parameters]) + (do ! + [parametersA (stack.each' ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) + arguments' (stack.each' ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) :return: (boxed_reflection_return mapping return) [scope bodyA] (|> arguments' {.#Top [self_name selfT]} @@ -2574,19 +2577,19 @@ (do [! phase.monad] [required_abstract_methods (phase.of_try (all_abstract_methods class_loader supers)) available_methods (phase.of_try (all_methods class_loader supers)) - overriden_methods (monad.each ! (function (_ [parent_type method_name - strict_fp? annotations type_vars - self_name arguments return exceptions - body]) - (do ! - [aliasing (super_aliasing class_loader parent_type)] - (in (|> (jvm.method [type_vars - (stack#each product.right arguments) - return - exceptions]) - (alias.method aliasing) - [parent_type method_name])))) - methods) + overriden_methods (stack.each' ! (function (_ [parent_type method_name + strict_fp? annotations type_vars + self_name arguments return exceptions + body]) + (do ! + [aliasing (super_aliasing class_loader parent_type)] + (in (|> (jvm.method [type_vars + (stack#each product.right arguments) + return + exceptions]) + (alias.method aliasing) + [parent_type method_name])))) + methods) .let [missing_abstract_methods (mismatched_methods overriden_methods required_abstract_methods) invalid_overriden_methods (mismatched_methods available_methods overriden_methods)] _ (phase.assertion ..missing_abstract_methods [required_abstract_methods overriden_methods] @@ -2763,7 +2766,7 @@ (_.aload 0) (|> constructor_arguments (stack#each (|>> product.left ..mock_value)) - (monad.all _.monad)) + (stack.all' _.monad)) (|> (jvm.method [(stack) (stack#each product.left constructor_arguments) jvm.void (stack)]) (_.invokespecial super ..constructor_name)) _.return @@ -2850,7 +2853,7 @@ methods]) (do [! phase.monad] [_ (..ensure_fresh_class! class_loader (..reflection super_class)) - _ (monad.each ! (|>> ..reflection (..ensure_fresh_class! class_loader)) super_interfaces) + _ (stack.each' ! (|>> ..reflection (..ensure_fresh_class! class_loader)) super_interfaces) self_name (do meta.monad [[where _] module.current @@ -2869,20 +2872,20 @@ mapping (typeA.check (..class_mapping parameters)) super_classT (typeA.check (luxT.check (luxT.class mapping) (..signature super_class))) - super_interfaceT+ (typeA.check (monad.each check.monad - (|>> ..signature (luxT.check (luxT.class mapping))) - super_interfaces)) + super_interfaceT+ (typeA.check (stack.each' check.monad + (|>> ..signature (luxT.check (luxT.class mapping))) + super_interfaces)) _ (typeA.inference selfT) - constructor_argsA+ (monad.each ! (function (_ [type term]) - (do ! - [argT (reflection_type mapping type) - termA (<| (typeA.expecting argT) - (analyse archive term))] - (in [type termA]))) - constructor_args) + constructor_argsA+ (stack.each' ! (function (_ [type term]) + (do ! + [argT (reflection_type mapping type) + termA (<| (typeA.expecting argT) + (analyse archive term))] + (in [type termA]))) + constructor_args) .let [supers {.#Top super_class super_interfaces}] _ (..require_complete_method_concretion class_loader supers methods) - methodsA (monad.each ! (analyse_overriden_method analyse archive selfT mapping supers) methods) + methodsA (stack.each' ! (analyse_overriden_method analyse archive selfT mapping supers) methods) @ meta.provenance] (in [@ {analysis.#Extension [.prelude (text extension_name "|translation")] (list (class_analysis @ super_class) @@ -2893,7 +2896,7 @@ (the (with_class_extensions class_loader host) (-> java/lang/ClassLoader runtime.Host (-> Bundle Bundle)) - (install (text "jvm_" "class_" "anonymous" "#") (class::anonymous class_loader host))) + (with (text "jvm_" "class_" "anonymous" "#") (class::anonymous class_loader host))) (the .public (bundle class_loader host) (-> java/lang/ClassLoader runtime.Host diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lua.lux index 44a2115f18..bea243ed36 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lua.lux @@ -6,8 +6,8 @@ [lux (.except) ["[0]" ffi] [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [collection ["[0]" array] @@ -167,7 +167,7 @@ (do [! phase.monad] [objectA (analysis/type.expecting ..Object (phase archive objectC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference .Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) @@ -226,7 +226,7 @@ (do [! phase.monad] [abstractionA (analysis/type.expecting ..Function (phase archive abstractionC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) 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 960d6ab054..f314222bbd 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 @@ -3,10 +3,10 @@ (.using [library - [lux (.except global local when function) + [lux (.except global local when function with) [abstract - ["?" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection]] [control ["[0]" maybe]] [error @@ -39,8 +39,6 @@ ["[0]" code ["?[1]" \\projection (.only Projection)]]]]] ["[0]" /// (.only) - ["[0]" synthesis - ["[1]" lux]] ["/[1]" // [// ["[0]" phase (.only) @@ -54,13 +52,15 @@ [/// ["[0]" reference] [meta - [archive (.only Archive)]]]]]]) + [archive (.only Archive)]] + ["[0]" extension (.only) + ["[1]/[0]" lux]]]]]]) (the .public (custom [syntax handler] extension_name) (for_any (_ of) (-> [(Projection of) - (-> Text Phase Archive of (Operation analysis.Term))] - (-> Text Handler))) + (-> extension.Name Phase Archive of (Operation analysis.Term))] + (-> extension.Name Handler))) (.function (_ analysis archive args) (.when (?code.value syntax (list.as_stack args)) {try.#Success inputs} @@ -70,13 +70,13 @@ (phase.failure error)))) (the .public translation - (-> Text + (-> extension.Name Name) - (|>> (text.suffix "|translation") + (|>> extension.translation [.prelude])) -(the .public (install name anonymous) - (-> Text (-> Text Handler) +(the .public (with name anonymous) + (-> extension.Name (-> extension.Name Handler) (-> Bundle Bundle)) (dictionary.has name (anonymous name))) @@ -87,54 +87,54 @@ ["Actual" (%.natural actual)]))) (the (simple inputsT+ outputT extension_name) - (-> (Stack Type) Type (-> Text Handler)) + (-> (Stack Type) Type (-> extension.Name Handler)) (let [num_expected (stack.size inputsT+)] (.function (_ analysis archive args) (let [num_actual (list.size args)] (if (n.= num_expected num_actual) (do [! phase.monad] [_ (typeA.inference outputT) - argsA (monad.each ! - (.function (_ [argT argC]) - (<| (typeA.expecting argT) - (analysis archive argC))) - (stack.zipped_2 inputsT+ (list.as_stack args))) + argsA (stack.each' ! + (.function (_ [argT argC]) + (<| (typeA.expecting argT) + (analysis archive argC))) + (stack.zipped_2 inputsT+ (list.as_stack args))) @ meta.provenance] (in [@ {analysis.#Extension (..translation extension_name) (list.of_stack argsA)}])) (analysis.except ..incorrect_arity [num_expected num_actual])))))) (the .public (nullary valueT) (-> Type - (-> Text Handler)) + (-> extension.Name Handler)) (simple (stack) valueT)) (the .public (unary inputT outputT) (-> Type Type - (-> Text Handler)) + (-> extension.Name Handler)) (simple (stack inputT) outputT)) (the .public (binary subjectT paramT outputT) (-> Type Type Type - (-> Text Handler)) + (-> extension.Name Handler)) (simple (stack subjectT paramT) outputT)) (the .public (trinary subjectT param0T param1T outputT) (-> Type Type Type Type - (-> Text Handler)) + (-> extension.Name Handler)) (simple (stack subjectT param0T param1T) outputT)) -(the .public (variadic input output next extension_name) - (-> Type Type (-> Text Text) - (-> Text Handler)) +(the .public (variadic next input output extension_name) + (-> (-> extension.Name extension.Name) Type Type + (-> extension.Name Handler)) (.function (_ analysis archive args) (do [! phase.monad] [_ (typeA.inference output) - argsA (monad.each ! + argsA (list.each' ! (|>> (analysis archive) (typeA.expecting input)) - (list.as_stack args)) + args) @ meta.provenance] - (in [@ {analysis.#Extension [.prelude (next extension_name)] (list.of_stack argsA)}])))) + (in [@ {analysis.#Extension [.prelude (next extension_name)] argsA}])))) ... TODO: Get rid of this ASAP (these @@ -152,7 +152,7 @@ _ (?.failure (exception.error ..character_text_must_be_size_1 [raw]))))) (the lux::syntax_char_case! - (-> Text Handler) + (-> extension.Name Handler) (..custom [(all ?.and ?code.any @@ -164,12 +164,12 @@ [input (<| (typeA.expecting Character) (phase archive input)) expectedT meta.expected_type - conditionals (monad.each ! (.function (_ [cases branch]) - (do ! - [branch (<| (typeA.expecting expectedT) - (phase archive branch))] - (in [cases branch]))) - conditionals) + conditionals (stack.each' ! (.function (_ [cases branch]) + (do ! + [branch (<| (typeA.expecting expectedT) + (phase archive branch))] + (in [cases branch]))) + conditionals) else (<| (typeA.expecting expectedT) (phase archive else)) @ meta.provenance] @@ -185,7 +185,7 @@ ... .is?# represents reference/pointer equality. (the (lux::is? extension_name) - (-> Text Handler) + (-> extension.Name Handler) (.function (_ analysis archive args) (<| typeA.with_var (.function (_ [@var :var:])) @@ -194,7 +194,7 @@ ... .try# provides a unified way to interact with the host platform's runtime error-handling facilities. (the lux::try - (-> Text Handler) + (-> extension.Name Handler) (..custom [?code.any (.function (_ extension_name analysis archive opC) @@ -212,7 +212,7 @@ (the .public (in_module#_extension eval) (-> Eval - (-> Text Handler)) + (-> extension.Name Handler)) (..custom [(?.and ?code.any ?code.any) (.function (_ extension_name analysis archive [module 'expression]) @@ -225,7 +225,7 @@ (the .public (is#_extension eval) (-> Eval - (-> Text Handler)) + (-> extension.Name Handler)) (..custom [(?.and ?code.any ?code.any) (.function (_ extension_name analysis archive [typeC valueC]) @@ -238,7 +238,7 @@ (the .public (as#_extension eval) (-> Eval - (-> Text Handler)) + (-> extension.Name Handler)) (..custom [(?.and ?code.any ?code.any) (.function (_ extension_name analysis archive [typeC valueC]) @@ -251,7 +251,7 @@ (the (caster input output) (-> Type Type - (-> Text Handler)) + (-> extension.Name Handler)) (..custom [?code.any (.function (_ extension_name phase archive valueC) @@ -289,7 +289,7 @@ (analysis.except ///.defaults_cannot_be_referenced [name]))) (the .public global - (-> Text Handler) + (-> extension.Name Handler) (..custom [(?.and ?code.text ?code.global) (.function (_ extension_name phase archive [quoted_module def_name]) @@ -326,7 +326,7 @@ (stack ["Name" (%.text name)]))) (the .public local - (-> Text Handler) + (-> extension.Name Handler) (..custom [?code.local (.function (_ extension_name phase archive [it]) @@ -343,7 +343,7 @@ (analysis.except ..unknown_local [it]))))])) (the universe - (-> Text Handler) + (-> extension.Name Handler) (..custom [?code.end (.function (_ extension_name phase archive []) @@ -353,7 +353,7 @@ (in (analysis.natural @ (++ (.universe#))))))])) (the when - (-> Text Handler) + (-> extension.Name Handler) (..custom [(?.and ?code.any (?.many (?.and ?code.any ?code.any))) @@ -361,7 +361,7 @@ (when.when phase branches archive input))])) (the function - (-> Text Handler) + (-> extension.Name Handler) (..custom [(all ?.and ?code.local @@ -372,7 +372,7 @@ (template.with [,name ,type ,normal ,numerator_projection ,numerator_analysis] [(the ,name - (-> Text Handler) + (-> extension.Name Handler) (..custom [(all ?.and ,numerator_projection @@ -392,24 +392,24 @@ (the with_basic_extensions (-> Bundle Bundle) - (|>> (install "is_type#" (..caster .Type .Type)) - (install "is?#" lux::is?) - (install "try#" lux::try) - (install "when_char#" lux::syntax_char_case!) - (install "local#" ..local) - (install "global#" ..global) - (install "universe#" ..universe) - (install "when#" ..when) - (install "function#" ..function) - - (install fraction.extension ..fraction) - (install rational.extension ..rational))) + (|>> (with "is_type#" (..caster .Type .Type)) + (with "is?#" lux::is?) + (with "try#" lux::try) + (with "when_char#" lux::syntax_char_case!) + (with "local#" ..local) + (with "global#" ..global) + (with "universe#" ..universe) + (with "when#" ..when) + (with "function#" ..function) + + (with fraction.extension ..fraction) + (with rational.extension ..rational))) (the with_io_extensions (-> Bundle Bundle) - (|>> (install "log!#" (unary Text Any)) - (install "error#" (unary Text Nothing)))) + (|>> (with "log!#" (unary Text Any)) + (with "error#" (unary Text Nothing)))) (the Any_I64 (type (I64 Any))) @@ -417,54 +417,54 @@ (the with_i64_extensions (-> Bundle Bundle) - (|>> (install "i64_and#" (binary Any_I64 Any_I64 I64)) - (install "i64_or#" (binary Any_I64 Any_I64 I64)) - (install "i64_xor#" (binary Any_I64 Any_I64 I64)) - (install "i64_left#" (binary Natural Any_I64 I64)) - (install "i64_right#" (binary Natural Any_I64 I64)) + (|>> (with "i64_and#" (binary Any_I64 Any_I64 I64)) + (with "i64_or#" (binary Any_I64 Any_I64 I64)) + (with "i64_xor#" (binary Any_I64 Any_I64 I64)) + (with "i64_left#" (binary Natural Any_I64 I64)) + (with "i64_right#" (binary Natural Any_I64 I64)) - (install "i64_=#" (binary Any_I64 Any_I64 Bit)) - (install "i64_+#" (binary Any_I64 Any_I64 I64)) - (install "i64_-#" (binary Any_I64 Any_I64 I64)))) + (with "i64_=#" (binary Any_I64 Any_I64 Bit)) + (with "i64_+#" (binary Any_I64 Any_I64 I64)) + (with "i64_-#" (binary Any_I64 Any_I64 I64)))) (the with_integer_extensions (-> Bundle Bundle) - (|>> (install "int_<#" (binary Integer Integer Bit)) - (install "int_*#" (binary Integer Integer Integer)) - (install "int_/#" (binary Integer Integer Integer)) - (install "int_%#" (binary Integer Integer Integer)) + (|>> (with "int_<#" (binary Integer Integer Bit)) + (with "int_*#" (binary Integer Integer Integer)) + (with "int_/#" (binary Integer Integer Integer)) + (with "int_%#" (binary Integer Integer Integer)) - (install "int_f64#" (unary Integer Decimal)) - (install "int_char#" (unary Integer Text)))) + (with "int_f64#" (unary Integer Decimal)) + (with "int_char#" (unary Integer Text)))) (the with_decimal_extensions (-> Bundle Bundle) - (|>> (install "f64_+#" (binary Decimal Decimal Decimal)) - (install "f64_-#" (binary Decimal Decimal Decimal)) - (install "f64_*#" (binary Decimal Decimal Decimal)) - (install "f64_/#" (binary Decimal Decimal Decimal)) - (install "f64_%#" (binary Decimal Decimal Decimal)) - (install "f64_=#" (binary Decimal Decimal Bit)) - (install "f64_<#" (binary Decimal Decimal Bit)) + (|>> (with "f64_+#" (binary Decimal Decimal Decimal)) + (with "f64_-#" (binary Decimal Decimal Decimal)) + (with "f64_*#" (binary Decimal Decimal Decimal)) + (with "f64_/#" (binary Decimal Decimal Decimal)) + (with "f64_%#" (binary Decimal Decimal Decimal)) + (with "f64_=#" (binary Decimal Decimal Bit)) + (with "f64_<#" (binary Decimal Decimal Bit)) - (install "f64_int#" (unary Decimal Integer)))) + (with "f64_int#" (unary Decimal Integer)))) (the with_text_extensions (-> Bundle Bundle) - (|>> (install "text_=#" (binary Text Text Bit)) - (install "text_<#" (binary Text Text Bit)) - (install "text_composite#" (variadic Text Text synthesis.synthesis)) - (install "text_index#" (trinary Natural Text Text (type (Maybe Natural)))) - (install "text_size#" (unary Text Natural)) - (install "text_char#" (binary Natural Text Natural)) - (install "text_clip#" (trinary Natural Natural Text Text)) + (|>> (with "text_=#" (binary Text Text Bit)) + (with "text_<#" (binary Text Text Bit)) + (with "text_composite#" (variadic extension.synthesis Text Text)) + (with "text_index#" (trinary Natural Text Text (type (Maybe Natural)))) + (with "text_size#" (unary Text Natural)) + (with "text_char#" (binary Natural Text Natural)) + (with "text_clip#" (trinary Natural Natural Text Text)) )) (the lux::list - (-> Text Handler) + (-> extension.Name Handler) (..custom [(?.some ?code.any) (.function (_ extension_name analysis archive elements) @@ -472,9 +472,9 @@ (.function (_ [_ of])) (do [! phase.monad] [_ (typeA.inference (type (List of))) - elements (monad.each ! (|>> (analysis archive) - (typeA.expecting of)) - elements) + elements (stack.each' ! (|>> (analysis archive) + (typeA.expecting of)) + elements) @ meta.provenance] (in (|> elements list.of_stack @@ -484,7 +484,7 @@ (the with_list_extensions (-> Bundle Bundle) - (|>> (install "list#" ..lux::list) + (|>> (with extension/lux.list ..lux::list) )) (the .public bundle diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/php.lux index 1d0698aeb3..57c915799d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/php.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/php.lux @@ -6,8 +6,8 @@ [lux (.except Analysis) ["[0]" ffi] [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [collection ["[0]" array (.only Array)] @@ -133,7 +133,7 @@ [(all <>.and .text (<>.some .any)) (function (_ extension phase archive [constructor inputsC]) (do [! phase.monad] - [inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + [inputsA (stack.each' ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in {analysis.#Extension extension (stack.partial (analysis.text constructor) inputsA)})))])) @@ -157,7 +157,7 @@ (do [! phase.monad] [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in {analysis.#Extension extension (stack.partial (analysis.text methodC) objectA @@ -191,7 +191,7 @@ (do [! phase.monad] [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in {analysis.#Extension extension (stack.partial abstractionA inputsA)})))])) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/python.lux index 727659e5db..9937e19713 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/python.lux @@ -6,8 +6,8 @@ [lux (.except) ["[0]" ffi] [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [collection ["[0]" array] @@ -168,7 +168,7 @@ (do [! phase.monad] [objectA (analysis/type.expecting ..Object (phase archive objectC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference .Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) @@ -214,7 +214,7 @@ (do [! phase.monad] [abstractionA (analysis/type.expecting ..Function (phase archive abstractionC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/r.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/r.lux index 57429bd850..5882e8ab05 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/r.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/r.lux @@ -6,8 +6,8 @@ [lux (.except Analysis) ["[0]" ffi] [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [collection ["[0]" array (.only Array)] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/ruby.lux index dadc358696..b5eb7b4ea6 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -6,8 +6,8 @@ [lux (.except) ["[0]" ffi] [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [collection ["[0]" array] @@ -165,7 +165,7 @@ (do [! phase.monad] [objectA (<| (analysis/type.expecting ..Object) (phase archive objectC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference .Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) @@ -200,7 +200,7 @@ (do [! phase.monad] [abstractionA (<| (analysis/type.expecting ..Function) (phase archive abstractionC)) - inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) + inputsA (stack.each' ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) _ (analysis/type.inference Any) @ meta.provenance] (in [@ {analysis.#Extension (/.translation extension) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux index 7319726c0e..86c37dbb5d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux @@ -7,8 +7,8 @@ #Variable) ["[0]" ffi (.only import)] [abstract - ["<>" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection (.use "[1]#[0]" monad)]] [control ["[0]" pipe]] [error @@ -481,8 +481,8 @@ _ bodyS)]) declaration.of_translation (do [! phase.monad] - [constructor_argumentsG (monad.each ! (|>> product.right (translate archive)) - constructor_argumentsS) + [constructor_argumentsG (stack.each' ! (|>> product.right (translate archive)) + constructor_argumentsS) bodyG (translate archive bodyS) .let [[super_vars super_name] (projection.read_class super_class) super_constructorT (type.method [(stack) @@ -787,7 +787,7 @@ (_.aload 0) (|> constructor_arguments (stack#each (|>> product.left ..mock_value)) - (monad.all _.monad)) + (stack.all' _.monad)) (|> (type.method [(stack) (stack#each product.left constructor_arguments) type.void (stack)]) (_.invokespecial super ..constructor_name)) _.return @@ -921,12 +921,12 @@ parameters) selfT {.#Nominal name (stack#each product.right parameters)}] state phase.state - methods (monad.each ! (let [analysis_state (its [declaration.#analysis declaration.#state] state)] - (..method_definition archive super interfaces [mapping selfT] - [(its [declaration.#analysis declaration.#phase] state) - ((its [declaration.#synthesis declaration.#phase] state) analysis_state) - ((its [declaration.#translation declaration.#phase] state) analysis_state)])) - methods) + methods (stack.each' ! (let [analysis_state (its [declaration.#analysis declaration.#state] state)] + (..method_definition archive super interfaces [mapping selfT] + [(its [declaration.#analysis declaration.#phase] state) + ((its [declaration.#synthesis declaration.#phase] state) analysis_state) + ((its [declaration.#translation declaration.#phase] state) analysis_state)])) + methods) .let [all_dependencies (cache.all (stack#each product.left methods))] bytecode (<| (by ! each (\\injection.value class.as_binary)) phase.of_try diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux index 14893f762a..f38935e5e2 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control [io (.only IO)] ["[0]" maybe (.use "[1]#[0]" functor)]] @@ -241,13 +241,13 @@ (function (_ phase archive imports) (do [! phase.monad] [_ (/////declaration.of_analysis - (monad.each ! (function (_ [module alias]) - (do ! - [_ (moduleA.import module)] - (when alias - "" (in []) - _ (moduleA.alias alias module)))) - imports))] + (stack.each' ! (function (_ [module alias]) + (do ! + [_ (moduleA.import module)] + (when alias + "" (in []) + _ (moduleA.alias alias module)))) + imports))] (in [/////declaration.#imports imports /////declaration.#referrals (stack)])))])) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/synthesis/lux.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/synthesis/lux.lux index 4485929684..7031e09253 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/synthesis/lux.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/synthesis/lux.lux @@ -3,11 +3,10 @@ (.using [library - [lux (.except) + [lux (.except with) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data - ["[0]" text] [collection ["[0]" list (.use "[1]#[0]" monad)] ["[0]" dictionary]]] @@ -19,22 +18,15 @@ ["[0]" /// (.only) [/// ["[0]" phase] - ["[0]" synthesis (.only Handler Bundle)]]]) + ["[0]" synthesis (.only Handler Bundle)] + [/// + ["[0]" extension (.only) + ["[1]/[0]" lux]]]]]) -(the .public synthesis - (-> Text - Text) - (|>> (text.suffix "|synthesis"))) - -(the translation - (-> Text - Text) - (text.replaced (synthesis "") "|translation")) - -(the .public (install name anonymous) - (-> Text (-> Text Handler) +(the .public (with name anonymous) + (-> extension.Name (-> extension.Name Handler) (-> Bundle Bundle)) - (dictionary.has name (anonymous name))) + (dictionary.has (extension.synthesis name) (anonymous name))) (the (flat_text_composite expected) (-> Name (List synthesis.Term) @@ -50,22 +42,21 @@ (list it)))) list#conjoint)) -(the (text::composite self) - (-> Text +(the (text_composite name) + (-> extension.Name Handler) - (let [translation [.prelude (translation self)]] + (let [name [.prelude (extension.translation name)]] (function (_ synthesis archive parts) (do [! phase.monad] - [parts (monad.each ! (synthesis archive) (list.as_stack parts))] - (in [provenance.dummy {synthesis.#Extension translation (flat_text_composite translation (list.of_stack parts))}]))))) + [parts (list.each' ! (synthesis archive) parts)] + (in [provenance.dummy {synthesis.#Extension name (flat_text_composite name parts)}]))))) (the .public bundle Bundle (`` (|> ///.empty - (,, (template.with [ ] - [(..install (let [[_ proper] (name )] - (synthesis proper)) - )] + (,, (template.with [,name] + [(..with (template.name [extension/lux._] [,name]) + (template.name [.._] [,name]))] - [.text_composite# ..text::composite] + [..text_composite] ))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/c++/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/c++/common.lux index 939e78c94e..c39c53635e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/c++/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/c++/common.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control ["|" pipe]] [error diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/common_lisp/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/common_lisp/common.lux index aa289acec8..d1eb62392d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/common_lisp/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/common_lisp/common.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [error ["[0]" try]] ["[0]" function] @@ -57,7 +57,7 @@ ... inputG (phase archive input) ... elseG (phase archive else) ... conditionalsG (is (Operation (Stack [_.Expression _.Expression])) -... (monad.each ! (function (_ [chars branch]) +... (stack.each' ! (function (_ [chars branch]) ... (do ! ... [branchG (phase archive branch)] ... (in [(|> chars (stack#each (|>> .integer _.int (_.=/2 @input))) _.or) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/js/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/js/common.lux index d57475126c..ddbd910d45 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/js/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/js/common.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control ["|" pipe]] [error @@ -190,12 +190,12 @@ else! (..statement phase archive else) conditionals! (is (Operation (Stack [(Stack Literal) _.Statement])) - (monad.each ! (function (_ [chars branch]) - (do ! - [branch! (..statement phase archive branch)] - (in [(stack#each (|>> .integer _.int) chars) - branch!]))) - conditionals))] + (stack.each' ! (function (_ [chars branch]) + (do ! + [branch! (..statement phase archive branch)] + (in [(stack#each (|>> .integer _.int) chars) + branch!]))) + conditionals))] ... (in (_.apply (_.closure (stack) ... (_.switch (_.its //runtime.i64_low_field inputG) ... conditionals! diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/js/host.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/js/host.lux index db8f4ff64a..4ead422054 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/js/host.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/js/host.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data [collection @@ -68,7 +68,7 @@ (function (_ phase archive [constructorS inputsS]) (do [! phase.monad] [constructorG (phase archive constructorS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.new constructorG inputsG))))])) (the object::get @@ -87,7 +87,7 @@ (function (_ phase archive [methodS objectS inputsS]) (do [! phase.monad] [objectG (phase archive objectS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template.with [ ] @@ -123,7 +123,7 @@ (function (_ phase archive [abstractionS inputsS]) (do [! phase.monad] [abstractionG (phase archive abstractionS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.apply abstractionG inputsG))))])) (the js::function @@ -135,8 +135,8 @@ .let [variable (is (-> Text (Operation Var)) (|>> translation.name (by ! each _.var)))] - 'inputs (monad.each ! (function (_ _) (variable "input")) - (stack.repeated (.natural arity) [])) + 'inputs (stack.each' ! (function (_ _) (variable "input")) + (stack.repeated (.natural arity) [])) 'abstraction (variable "abstraction")] (in (_.closure 'inputs (all _.then diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/common.lux index 2c6b05933e..7390d3ce9f 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/common.lux @@ -5,8 +5,8 @@ [library [lux (.except Type Label) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control ["|" pipe]] [error @@ -31,8 +31,8 @@ ["[0]" signed (.only S4)]] ["[0]" type (.only Type) [category (.only Primitive Class)]]]]]] - ["[0]" ///// - ["[0]" extension] + [///// + ["//" extension] [translation [extension (.only Nullary Unary Binary Trinary Variadic nullary unary binary trinary variadic)] @@ -48,7 +48,9 @@ ["<[1]>" \\projection (.only Projection)]] [/// [meta - [archive (.only Archive)]]]]]) + [archive (.only Archive)]] + ["[0]" extension (.only) + ["[1]/[0]" lux]]]]]) (the .public (custom [projection handler]) (for_any (_ it) @@ -115,24 +117,24 @@ elseG (phase archive elseS) conditionalsG+ (is (Operation (Stack [(Stack [S4 Label]) (Bytecode Any)])) - (monad.each ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch) - @branch ///runtime.forge_label] - (in [(stack#each (function (_ char) - [(try.trusted (signed.s4 (.integer char))) @branch]) - chars) - (all _.composite - (_.set_label @branch) - branchG - (_.when_continuous (_.goto @end)))]))) - conditionalsS)) + (stack.each' ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch) + @branch ///runtime.forge_label] + (in [(stack#each (function (_ char) + [(try.trusted (signed.s4 (.integer char))) @branch]) + chars) + (all _.composite + (_.set_label @branch) + branchG + (_.when_continuous (_.goto @end)))]))) + conditionalsS)) .let [table (|> conditionalsG+ (stack#each product.left) stack#conjoint) conditionalsG (|> conditionalsG+ (stack#each product.right) - (monad.all _.monad))]] + (stack.all' _.monad))]] (in (do _.monad [@else _.new_label] (all _.composite @@ -378,17 +380,17 @@ parts (do [! _.monad] [_ (_.int (i/32.of +0)) - _ (monad.each ! (is (-> (Bytecode Any) - (Bytecode Any)) - (function (_ it) - (all _.composite - (add_part! it) - update_size! - ))) - (stack.reversed parts)) + _ (stack.each' ! (is (-> (Bytecode Any) + (Bytecode Any)) + (function (_ it) + (all _.composite + (add_part! it) + update_size! + ))) + (stack.reversed parts)) _ new_StringBuilder - _ (monad.each ! (function.constant compose_part!) - parts)] + _ (stack.each' ! (function.constant compose_part!) + parts)] (_.invokevirtual $StringBuilder "toString" (type.method [(stack) (stack) ..$String (stack)]))) )))) @@ -474,17 +476,18 @@ (_.int (i/32.of (.integer where))) what _.aastore))) - (monad.all _.monad)))) + (stack.all' _.monad)))) (the with_list_extensions (-> Bundle Bundle) - (|>> (dictionary.has "list#|translation" (variadic ..lux::list)) + (|>> (dictionary.has (extension.translation extension/lux.list) + (variadic ..lux::list)) )) (the .public bundle Bundle - (|> extension.empty + (|> //.empty with_basic_extensions with_io_extensions with_text_extensions diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/host.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/host.lux index 663369a5d8..9b545ecdae 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/host.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/jvm/host.lux @@ -5,8 +5,8 @@ [library [lux (.except Type) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control ["[0]" maybe (.use "[1]#[0]" functor)]] [error @@ -760,9 +760,9 @@ [(all <>.and ..class .text ..return (<>.some ..input)) (function (_ translate archive [class method outputT inputsTS]) (do [! phase.monad] - [inputsTG (monad.each ! (translate_input translate archive) inputsTS)] + [inputsTG (stack.each' ! (translate_input translate archive) inputsTS)] (in (all _.composite - (monad.each _.monad product.right inputsTG) + (stack.each' _.monad product.right inputsTG) (_.invokestatic class method (type.method [(stack) (stack#each product.left inputsTG) outputT (stack)])) (prepare_output outputT)))))])) @@ -774,13 +774,13 @@ (function (_ translate archive [class method outputT objectS inputsTS]) (do [! phase.monad] [objectG (translate archive objectS) - inputsTG (monad.each ! (translate_input translate archive) inputsTS)] + inputsTG (stack.each' ! (translate_input translate archive) inputsTS)] (in (all _.composite objectG (if (_.checkcast class) (_#in [])) - (monad.each _.monad product.right inputsTG) + (stack.each' _.monad product.right inputsTG) ( class method (type.method [(stack) (stack#each product.left inputsTG) outputT (stack)])) (prepare_output outputT)))))]))] @@ -795,11 +795,11 @@ [(all <>.and ..class (<>.some ..input)) (function (_ translate archive [class inputsTS]) (do [! phase.monad] - [inputsTG (monad.each ! (translate_input translate archive) inputsTS)] + [inputsTG (stack.each' ! (translate_input translate archive) inputsTS)] (in (all _.composite (_.new class) _.dup - (monad.each _.monad product.right inputsTG) + (stack.each' _.monad product.right inputsTG) (_.invokespecial class "" (type.method [(stack) (stack#each product.left inputsTG) type.void (stack)]))))))])) (the with_member_extensions @@ -863,7 +863,8 @@ (function (again it) (`` (when it (^.or {synthesis.#Pop} - {synthesis.#Access _}) + {synthesis.#Access _} + {synthesis.#List size}) it {synthesis.#Bind it} @@ -1011,7 +1012,8 @@ [synthesis.#Pop] [synthesis.#Bind] - [synthesis.#Access])) + [synthesis.#Access] + [synthesis.#List])) {synthesis.#Bit_Fork when then else} {synthesis.#Bit_Fork when (again then) (maybe#each again else)} @@ -1116,8 +1118,7 @@ store_captured! (|> env list.size list.indices - list.as_stack - (monad.each _.monad (.function (_ register) + (list.each' _.monad (.function (_ register) (all _.composite (_.aload 0) (_.aload (n.+ inputs_offset (++ register))) @@ -1136,7 +1137,7 @@ (-> Phase Archive (Type category.Class) (Environment synthesis.Term) (Stack (Typed (Bytecode Any))) (Operation (Bytecode Any))) (do [! phase.monad] - [captureG+ (monad.each ! (translate archive) (list.as_stack env))] + [captureG+ (list.each' ! (translate archive) env)] (in (all _.composite (_.new class) _.dup @@ -1144,7 +1145,7 @@ (stack#each product.right) stack.reversed (stack#mix _.composite (_#in []))) - (monad.all _.monad captureG+) + (list.all' _.monad captureG+) (_.invokespecial class "" (anonymous_init_method env inputsTI)))))) (the (returnG returnT) @@ -1198,12 +1199,12 @@ (-> Archive (Stack Input) (Stack [(Environment synthesis.Term) (/.Overriden_Method synthesis.Term)]) (Operation (Set unit.ID))) (do [! phase.monad] - [all_input_dependencies (monad.each ! (|>> product.right (cache/artifact.dependencies archive)) inputsTS) + [all_input_dependencies (stack.each' ! (|>> product.right (cache/artifact.dependencies archive)) inputsTS) all_closure_dependencies (|> overriden_methods (stack#each (|>> product.left list.as_stack)) stack.together - (monad.each ! (cache/artifact.dependencies archive))) - all_method_dependencies (monad.each ! (|>> product.right (method_dependencies archive)) overriden_methods)] + (stack.each' ! (cache/artifact.dependencies archive))) + all_method_dependencies (stack.each' ! (|>> product.right (method_dependencies archive)) overriden_methods)] (in (cache/artifact.all (all stack#composite all_input_dependencies all_closure_dependencies @@ -1343,10 +1344,10 @@ class (type.class (stack) anonymous_class_name) total_environment (list.of_stack (..total_environment overriden_methods)) global_mapping (..global_mapping total_environment)] - inputsTI (monad.each ! (translate_input translate archive) inputsTS) + inputsTI (stack.each' ! (translate_input translate archive) inputsTS) methods! (|> overriden_methods (stack#each (normalized_method global_mapping)) - (monad.each ! (method_definition translate archive artifact_id))) + (stack.each' ! (method_definition translate archive artifact_id))) bytecode (<| (by ! each (\\injection.value class.as_binary)) phase.of_try (class.class version.v6_0 (all modifier#composite class.public class.final) 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 6c939ca78f..557bb80c8b 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 @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control ["|" pipe]] [error diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/lua/host.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/lua/host.lux index f53d79fead..ce91fd097d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/lua/host.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/lua/host.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data [collection @@ -78,7 +78,7 @@ (function (_ phase archive [methodS objectS inputsS]) (do [! phase.monad] [objectG (phase archive objectS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template.with [ ] @@ -139,7 +139,7 @@ (function (_ phase archive [abstractionS inputsS]) (do [! phase.monad] [abstractionG (phase archive abstractionS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) (the lua::power @@ -167,9 +167,9 @@ .let [variable (is (-> Text (Operation Var)) (|>> translation.name (by ! each _.var)))] - 'inputs (monad.each ! (function (_ _) - (variable "input")) - (stack.repeated (.natural arity) []))] + 'inputs (stack.each' ! (function (_ _) + (variable "input")) + (stack.repeated (.natural arity) []))] (in (<| (_.closure 'inputs) _.return (when (.natural arity) 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 b7a9925632..0aa51e604a 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 @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [error ["[0]" try]] ["[0]" function] @@ -57,18 +57,18 @@ (phase archive else)) @input (by ! each _.var (translation.name "input")) conditionalsG (is (Operation (Stack [_.Expression _.Expression])) - (monad.each ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars - (stack#each (|>> .integer _.int (_.=== @input))) - (stack#mix (function (_ clause total) - (if (same? _.null total) - clause - (_.or clause total))) - _.null)) - branchG]))) - conditionals)) + (stack.each' ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars + (stack#each (|>> .integer _.int (_.=== @input))) + (stack#mix (function (_ clause total) + (if (same? _.null total) + clause + (_.or clause total))) + _.null)) + branchG]))) + conditionals)) .let [foreigns (|> conditionals (stack#each (|>> product.right synthesis.path/then //when.dependencies)) (stack.partial (//when.dependencies (synthesis.path/then else))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/php/host.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/php/host.lux index 5fc0cb71a4..1d3526eb42 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/php/host.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/php/host.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data [collection @@ -67,7 +67,7 @@ [(all <>.and .text (<>.some .any)) (function (_ extension phase archive [constructor inputsS]) (do [! ////////phase.monad] - [inputsG (monad.each ! (phase archive) inputsS)] + [inputsG (stack.each' ! (phase archive) inputsS)] (in (_.new (_.constant constructor) inputsG))))])) (the object::get @@ -86,7 +86,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do [! ////////phase.monad] [objectG (phase archive objectS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template.with [ ] @@ -119,7 +119,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do [! ////////phase.monad] [abstractionG (phase archive abstractionS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) (the php::pack diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/python/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/python/common.lux index 1f9a826417..94fca481d2 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/python/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/python/common.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control ["|" pipe]] [error @@ -144,18 +144,18 @@ @input (by ! each _.var (translation.name "input")) conditionals! (is (Operation (Stack [_.Expression _.Statement])) - (monad.each ! (function (_ [chars branch]) - (do ! - [branch! (..statement phase archive branch)] - (in [(|> chars - (stack#each (|>> .integer _.int (_.= @input))) - (stack#mix (function (_ clause total) - (if (same? _.none total) - clause - (_.or clause total))) - _.none)) - branch!]))) - conditionals)) + (stack.each' ! (function (_ [chars branch]) + (do ! + [branch! (..statement phase archive branch)] + (in [(|> chars + (stack#each (|>> .integer _.int (_.= @input))) + (stack#mix (function (_ clause total) + (if (same? _.none total) + clause + (_.or clause total))) + _.none)) + branch!]))) + conditionals)) ... .let [dependencies (//case.dependencies (stack#mix (function (_ right left) ... (synthesis.path/seq left right)) ... (synthesis.path/then input) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/python/host.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/python/host.lux index a7254bd4d7..5c91c6eec3 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/python/host.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/python/host.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data [collection @@ -80,7 +80,7 @@ (function (_ phase archive [methodS objectS inputsS]) (do [! phase.monad] [objectG (phase archive objectS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.do methodS (list.of_stack inputsG) objectG))))])) (template.with [ ] @@ -124,7 +124,7 @@ (function (_ phase archive [abstractionS inputsS]) (do [! phase.monad] [abstractionG (phase archive abstractionS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.apply (list.of_stack inputsG) abstractionG))))])) (the python::function @@ -136,8 +136,8 @@ .let [variable (is (-> Text (Operation SVar)) (|>> translation.name (by ! each _.var)))] - 'inputs (monad.each ! (function (_ _) (variable "input")) - (stack.repeated (.natural arity) []))] + 'inputs (stack.each' ! (function (_ _) (variable "input")) + (stack.repeated (.natural arity) []))] (in (_.lambda (list.of_stack 'inputs) (when (.natural arity) 0 (_.apply (list //runtime.unit) abstractionG) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/r/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/r/common.lux index f0d4ab1531..2aea12f832 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/r/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/r/common.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [error ["[0]" try]] ["[0]" function] @@ -56,7 +56,7 @@ ... ... inputG (phase archive input) ... ... elseG (phase archive else) ... ... conditionalsG (is (Operation (Stack [_.Expression _.Expression])) -... ... (monad.each ! (function (_ [chars branch]) +... ... (stack.each' ! (function (_ [chars branch]) ... ... (do ! ... ... [branchG (phase archive branch)] ... ... (in [(|> chars (stack#each (|>> .integer _.int (_.=/2 @input))) _.or) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/r/host.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/r/host.lux index 6a597d83f3..b2306b2a9e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/r/host.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/r/host.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data [collection diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/ruby/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/ruby/common.lux index a2d9812265..7712d2e501 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/ruby/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/ruby/common.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [control ["|" pipe]] [error @@ -148,18 +148,18 @@ else! (statement phase archive else) @input (by ! each _.local (translation.name "input")) conditionals! (is (Operation (Stack [_.Expression _.Statement])) - (monad.each ! (function (_ [chars branch]) - (do ! - [branch! (statement phase archive branch)] - (in [(|> chars - (stack#each (|>> .integer _.int (_.= @input))) - (stack#mix (function (_ clause total) - (if (same? _.nil total) - clause - (_.or clause total))) - _.nil)) - branch!]))) - conditionals)) + (stack.each' ! (function (_ [chars branch]) + (do ! + [branch! (statement phase archive branch)] + (in [(|> chars + (stack#each (|>> .integer _.int (_.= @input))) + (stack#mix (function (_ clause total) + (if (same? _.nil total) + clause + (_.or clause total))) + _.nil)) + branch!]))) + conditionals)) ... .let [closure (_.lambda {.#None} (stack @input) ... (stack#mix (function (_ [test then] else) ... (_.if test (_.return then) else)) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/ruby/host.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/ruby/host.lux index aee2ad93b7..d14cd44c15 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/ruby/host.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/translation/ruby/host.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["?" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection]] ["[0]" function] [data [collection @@ -76,7 +76,7 @@ (function (_ phase archive [methodS objectS inputsS]) (do [! phase.monad] [objectG (phase archive objectS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.do methodS inputsG {.#None} objectG))))])) (template.with [ ] @@ -106,7 +106,7 @@ (function (_ phase archive [abstractionS inputsS]) (do [! phase.monad] [abstractionG (phase archive abstractionS) - inputsG (monad.each ! (phase archive) inputsS)] + inputsG (stack.each' ! (phase archive) inputsS)] (in (_.apply inputsG {.#None} abstractionG))))])) (the ruby::import diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis.lux index c067cf8347..91b5f1c67c 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" pipe]] [data @@ -83,17 +83,15 @@ {///complex.#Tuple tuple} (|> tuple - list.as_stack - (monad.each phase.monad (phase archive)) - (phase#each (|>> list.of_stack (/.tuple @)))))) + (list.each' phase.monad (phase archive)) + (phase#each (|>> (/.tuple @)))))) [@ {analysis.#When inputA branchesAB+}] (/.with_currying? false (/when.synthesize @ phase branchesAB+ archive inputA)) - ... TO DO: Un-comment - ... (analysis.no_op @ value) - ... (phase archive value) + (analysis.coercion @ value) + (phase archive value) [@ {analysis.#Reification _}] (/.with_currying? false @@ -107,9 +105,8 @@ (|>>) (function (_ _) {.#Some (|> parameters - list.as_stack - (monad.each phase.monad (phase archive)) - (phase#each (|>> list.of_stack [name] {/.#Extension} [@])))})) + (list.each' phase.monad (phase archive)) + (phase#each (|>> [name] {/.#Extension} [@])))})) ))) (the .public (phase extender lux archive analysis) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/function.lux index d559cece38..4470d6ca07 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/function.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" enum]] [control ["[0]" pipe] @@ -17,8 +17,7 @@ [text ["%" \\injection]] [collection - ["[0]" list (.use "[1]#[0]" functor monoid)] - ["[0]" stack (.use "[1]#[0]" functor monoid)]]] + ["[0]" list (.use "[1]#[0]" functor monoid)]]] [math [number ["n" natural]]] @@ -55,8 +54,7 @@ (let [[funcA argsA] (analysis.reification exprA)] (do [! phase.monad] [funcS (phase archive funcA) - argsS (monad.each ! (phase archive) (list.as_stack argsA)) - .let [argsS (list.of_stack argsS)]] + argsS (list.each' ! (phase archive) argsA)] (expansion.let [ (these (/.reification @ [funcS argsS]))] (when funcS (/.abstraction @ functionS) @@ -129,12 +127,12 @@ [{ [[test then] elses]} (do [! phase.monad] [then (grow_path grow then) - elses (monad.each ! (function (_ [else_test else_then]) + elses (list.each' ! (function (_ [else_test else_then]) (do ! [else_then (grow_path grow else_then)] (in [else_test else_then]))) - (list.as_stack elses))] - (in { [[test then] (list.of_stack elses)]}))] + elses)] + (in { [[test then] elses]}))] [/.#I64_Fork] [/.#F64_Fork] @@ -161,9 +159,8 @@ {analysis/complex.#Tuple membersS+} (|> membersS+ - list.as_stack - (monad.each phase.monad (grow environment)) - (phase#each (|>> list.of_stack (/.tuple @))))) + (list.each' phase.monad (grow environment)) + (phase#each (|>> (/.tuple @))))) (..self_reference @) (phase#in (/.reification @ [expression (list (/.local @ 1))])) @@ -193,35 +190,33 @@ (when loop {/.#Tail_Recursion [start initsS+ iterationS]} (do [! phase.monad] - [initsS+' (monad.each ! (grow environment) (list.as_stack initsS+)) + [initsS+' (list.each' ! (grow environment) initsS+) iterationS' (grow environment iterationS)] - (in (/.tail_recursion @ [(++ start) (list.of_stack initsS+') iterationS']))) + (in (/.tail_recursion @ [(++ start) initsS+' iterationS']))) {/.#Tail_Iteration argumentsS+} (|> argumentsS+ - list.as_stack - (monad.each phase.monad (grow environment)) - (phase#each (|>> list.of_stack (/.tail_iteration @))))) + (list.each' phase.monad (grow environment)) + (phase#each (|>> (/.tail_iteration @))))) {/.#Function function} (when function {/.#Abstraction [_env _arity _body]} (do [! phase.monad] - [_env' (monad.each ! + [_env' (list.each' ! (|>> (pipe.when [@ {/.#Reference {////reference.#Variable {////reference/variable.#Foreign register}}}] (..find_foreign environment register) captured (grow environment captured))) - (list.as_stack _env))] - (in (/.abstraction @ [(list.of_stack _env') _arity _body]))) + _env)] + (in (/.abstraction @ [_env' _arity _body]))) {/.#Reification funcS argsS+} (do [! phase.monad] [funcS (grow environment funcS) - argsS+ (monad.each ! (grow environment) (list.as_stack argsS+)) - .let [argsS+ (list.of_stack argsS+)]] + argsS+ (list.each' ! (grow environment) argsS+)] (in (/.reification @ (when funcS (/.reification @ [(..self_reference @) pre_argsS+]) [(..self_reference @) @@ -233,9 +228,8 @@ [@ {/.#Extension name argumentsS+}] (|> argumentsS+ - list.as_stack - (monad.each phase.monad (grow environment)) - (phase#each (|>> list.of_stack {/.#Extension name} [@]))) + (list.each' phase.monad (grow environment)) + (phase#each (|>> {/.#Extension name} [@]))) [@ {/.#Simple _}] (phase#in expression))) @@ -244,7 +238,7 @@ (-> Provenance Phase (Environment analysis.Term) Phase) (do [! phase.monad] - [environment (monad.each ! (phase archive) (list.as_stack environment)) + [environment (list.each' ! (phase archive) environment) bodyS (/.with_currying? true (/.with_locals 2 (phase archive bodyA))) @@ -254,12 +248,12 @@ (|> bodyS' (grow env') (by ! each (function (_ body) - [/.#environment (list.of_stack environment) + [/.#environment environment /.#arity (++ down_arity') /.#body body]))) _ - (in [/.#environment (list.of_stack environment) + (in [/.#environment environment /.#arity 1 /.#body bodyS]))) currying? /.currying?] @@ -268,7 +262,7 @@ abstraction (when (//loop.optimization false 1 (list) abstraction) {.#Some it} - [/.#environment (list.of_stack environment) + [/.#environment environment /.#arity (its /.#arity abstraction) /.#body (/.tail_recursion @ it)] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/loop.lux index 3908a0be96..bd255edf99 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/loop.lux @@ -5,13 +5,12 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe (.use "[1]#[0]" monad)]] [data [collection - ["[0]" list (.use "[1]#[0]" monoid)] - ["[0]" stack]]] + ["[0]" list (.use "[1]#[0]" monoid)]]] [math [number ["n" natural]]] @@ -71,12 +70,12 @@ [{ [[test then] elses]} (do [! maybe.monad] [then (again then) - elses (monad.each ! (function (_ [else_test else_then]) + elses (list.each' ! (function (_ [else_test else_then]) (do ! [else_then (again else_then)] (in [else_test else_then]))) - (list.as_stack elses))] - (in { [[test then] (list.of_stack elses)]}))] + elses)] + (in { [[test then] elses]}))] [/.#I64_Fork] [/.#F64_Fork] @@ -110,9 +109,8 @@ {analysis/complex.#Tuple tuple} (|> tuple - list.as_stack - (monad.each maybe.monad (again false)) - (maybe#each (|>> list.of_stack (/.tuple @))))) + (list.each' maybe.monad (again false)) + (maybe#each (|>> (/.tuple @))))) [@ {/.#Reference reference}] (when reference @@ -142,35 +140,33 @@ (do [! maybe.monad] [inits (|> it (its /.#inits) - list.as_stack - (monad.each ! (again false))) + (list.each' ! (again false))) iteration (again return? (its /.#iteration it))] (in (/.tail_recursion @ [/.#start (|> it (its /.#start) (register_optimization offset)) - /.#inits (list.of_stack inits) + /.#inits inits /.#iteration iteration]))) (/.tail_iteration @ args) (|> args - list.as_stack - (monad.each maybe.monad (again false)) - (maybe#each (|>> list.of_stack (/.tail_iteration @)))) + (list.each' maybe.monad (again false)) + (maybe#each (|>> (/.tail_iteration @)))) (/.abstraction @ [environment arity body]) (do [! maybe.monad] - [environment (monad.each ! (again false) (list.as_stack environment))] - (in (/.abstraction @ [(list.of_stack environment) arity body]))) + [environment (list.each' ! (again false) environment)] + (in (/.abstraction @ [environment arity body]))) (/.reification @ [abstraction arguments]) (do [! maybe.monad] - [arguments (monad.each ! (again false) (list.as_stack arguments))] + [arguments (list.each' ! (again false) arguments)] (expansion.let [ (these (do ! [abstraction (again false abstraction)] - (in (/.reification @ [abstraction (list.of_stack arguments)]))))] + (in (/.reification @ [abstraction arguments]))))] (when abstraction [@ {/.#Reference {reference.#Variable (variable.self)}}] (if (and return? - (n.= arity (stack.size arguments))) - (in (/.tail_iteration @ (list.of_stack arguments))) + (n.= arity (list.size arguments))) + (in (/.tail_iteration @ arguments)) (if true_loop? {.#None} )) @@ -186,7 +182,7 @@ else (list.item 1 parameters) input (again false input) - matches (monad.each ! + matches (list.each' ! (is (-> /.Term (Maybe /.Term)) (function (_ match) @@ -202,17 +198,15 @@ _ (again false match)))) - (list.as_stack (list.after 2 parameters))) + (list.after 2 parameters)) else (again return? else)] - (in [@ {/.#Extension [[.prelude "when_char#|translation"] (list#composite (list input else) - (list.of_stack matches))]}])) + (in [@ {/.#Extension [[.prelude "when_char#|translation"] (list#composite (list input else) matches)]}])) {.#None}) [@ {/.#Extension [name args]}] (|> args - list.as_stack - (monad.each maybe.monad (again false)) - (maybe#each (|>> list.of_stack [name] {/.#Extension} [@])))))) + (list.each' maybe.monad (again false)) + (maybe#each (|>> [name] {/.#Extension} [@])))))) (the .public (optimization true_loop? offset inits functionS) (-> Bit Register (List /.Term) Abstraction diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/variable.lux index 381881696a..3e3c41e080 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/variable.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe (.use "[1]#[0]" functor)]] [error @@ -61,19 +61,24 @@ {/.#Seq {/.#Bind (..prune redundant register)} (again post)}) - (^.or {/.#Seq {/.#Access {/access.#Member member}} - {/.#Seq {/.#Bind register} - post}} - ... This alternative form should never occur in practice. - ... Yet, it is "technically" possible to construct it. - {/.#Seq {/.#Seq {/.#Access {/access.#Member member}} - {/.#Bind register}} - post}) - (if (n.= redundant register) - (again post) - {/.#Seq {/.#Access {/access.#Member member}} - {/.#Seq {/.#Bind (..prune redundant register)} - (again post)}}) + (,, (template.with [,access] + [(^.or {/.#Seq {/.#Access ,access} + {/.#Seq {/.#Bind register} + post}} + ... This alternative form should never occur in practice. + ... Yet, it is "technically" possible to construct it. + {/.#Seq {/.#Seq {/.#Access ,access} + {/.#Bind register}} + post}) + (if (n.= redundant register) + (again post) + {/.#Seq {/.#Access ,access} + {/.#Seq {/.#Bind (..prune redundant register)} + (again post)}})] + + [{/access.#Member member}] + [{/access.#Item position}] + )) (,, (template.with [] [{ left right} @@ -97,7 +102,8 @@ [/.#Text_Fork])) (^.or {/.#Pop} - {/.#Access _}) + {/.#Access _} + {/.#List size}) path {/.#Bind register} @@ -247,7 +253,8 @@ (function (again [redundancy path]) (`` (when path (^.or {/.#Pop} - {/.#Access _}) + {/.#Access _} + {/.#List size}) {try.#Success [redundancy path]} diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/when.lux index bc16c04b8d..da42f68819 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/synthesis/when.lux @@ -6,7 +6,7 @@ [lux (.except Pattern) [abstract [equivalence (.only Equivalence)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" pipe] ["[0]" maybe (.use "[1]#[0]" functor)]] @@ -18,7 +18,7 @@ ["[0]" text] [collection ["[0]" list (.use "[1]#[0]" functor mix monoid)] - ["[0]" stack (.use "[1]#[0]" functor mix monoid)] + ["[0]" stack (.use "[1]#[0]" mix)] ["[0]" set (.only Set)]]] [math [number @@ -113,6 +113,27 @@ nextC)))) thenC (list.reversed (list.enumeration tuple)))) + + {///pattern.#List it} + (let [size (list.size it) + last (-- size)] + (|> (list#mix (function (_ [position item] nextC) + (.when item + {///pattern.#Simple {///simple.#Unit}} + nextC + + _ + (let [end? (and end? + (n.= last position))] + (<| (phase#each (|>> {/.#Seq {/.#Access {/access.#Item position}}})) + (path' item end?) + (pipe.if [(pipe.new (not end?) [])] + [(phase#each ..clean_up)] + []) + nextC)))) + thenC + (list.reversed (list.enumeration it))) + (phase#each (|>> {/.#Seq {/.#List size}})))) )) (the (path archive synthesize pattern bodyA) @@ -228,8 +249,8 @@ (Operation /.Term)) (do [! phase.monad] [headSP (path archive synthesize headP headA) - tailSP+ (monad.each ! (product.uncurried (path archive synthesize)) (list.as_stack tailPA+))] - (in (/.when @ [input (list#mix weave headSP (list.of_stack tailSP+))])))) + tailSP+ (list.each' ! (product.uncurried (path archive synthesize)) tailPA+)] + (in (/.when @ [input (list#mix weave headSP tailSP+)])))) (the !masking (template.macro (_ <@> ) @@ -296,7 +317,8 @@ path_storage ..empty]) (when path (^.or {/.#Pop} - {/.#Access Access}) + {/.#Access Access} + {/.#List size}) path_storage (/.path/bind register) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/complex.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/complex.lux index a51c6c9c0e..a27146c234 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/complex.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/complex.lux @@ -6,7 +6,7 @@ [lux (.except Variant Tuple variant tuple) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [target ["_" c++]]]] [// @@ -37,5 +37,5 @@ _ (|> values - (monad.each ! (next archive)) + (stack.each' ! (next archive)) (by ! each runtime.tuple))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/function.lux index 62b739e42b..af853f4f02 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/function.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data [collection ["[0]" stack (.use "[1]#[0]" functor mix)]]] @@ -30,7 +30,7 @@ (runtime.Expression Reification) (do [! phase.monad] [abstraction (expression archive abstraction) - arguments (monad.each ! (expression archive) arguments)] + arguments (stack.each' ! (expression archive) arguments)] (in (runtime.on arguments abstraction)))) (the .public (abstraction statement expression archive [environment arity body]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/runtime.lux index 40b564fb77..489342965b 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/runtime.lux @@ -7,7 +7,7 @@ Bit I64 F64 Text Variant Tuple variant tuple function false true left right) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] [text diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/statement/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/statement/loop.lux index 585387431b..8761833709 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/statement/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/statement/loop.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data [text ["%" \\injection]] @@ -88,7 +88,7 @@ _ (do [! phase.monad] [@scope (by ! each ..@scope translation.next) - initialization (monad.each ! (expression archive) initialization) + initialization (stack.each' ! (expression archive) initialization) body (translation.with_anchor [start @scope] (statement expression archive body)) $iteration_parameters (by ! each ..$iteration_parameters translation.next)] @@ -103,7 +103,7 @@ ... (runtime.Expression Stack) ... (do [! phase.monad] ... [[offset @scope] translation.anchor -... it (monad.each ! (expression archive) it) +... it (stack.each' ! (expression archive) it) ... $iteration_parameters (by ! each ..$iteration_parameters translation.next)] ... (in (..setup $iteration_parameters ... false offset it diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/statement/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/statement/when.lux index 5247dda1aa..408933666d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/statement/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/statement/when.lux @@ -5,7 +5,7 @@ [library [lux (.except if let exec when local) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data [collection ["[0]" stack (.use "[1]#[0]" mix)]] @@ -239,11 +239,11 @@ [{ item} (do ! [it ..local - clauses (monad.each ! (function (_ [match then]) - (by ! each - (|>> [(<=> ( match) it)]) - (next @failure then))) - {.#Top item})] + clauses (stack.each' ! (function (_ [match then]) + (by ! each + (|>> [(<=> ( match) it)]) + (next @failure then))) + {.#Top item})] (in (_.block (all _.then (_.constant it (|> (runtime.peek road) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/when.lux index 4cc4f3520b..0f36f510d8 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/c++/when.lux @@ -6,7 +6,7 @@ [lux (.except Type Label if let exec when local its) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data [collection ["[0]" stack (.use "[1]#[0]" mix)] @@ -49,14 +49,14 @@ (do [! phase.monad] [.let [[tail body] (synthesis.flat_let (.its synthesis.#expression it)) context (.its synthesis.#context it)] - bindings (monad.each ! (function (_ [binding value]) - (do ! - [value (next archive value)] - (in (_.constant (reference.local binding) - runtime.value_type - value)))) - (stack.partial context - tail)) + bindings (stack.each' ! (function (_ [binding value]) + (do ! + [value (next archive value)] + (in (_.constant (reference.local binding) + runtime.value_type + value)))) + (stack.partial context + tail)) body (next archive body)] (in (_.on (stack) (_.lambda (.when context diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/extension/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/extension/common.lux index 200dd0104c..6dee8fe194 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/extension/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/extension/common.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] ["[0]" function] [data ["[0]" product] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/function.lux index ce3ada96a8..b481ec82fe 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/function.lux @@ -5,7 +5,7 @@ [library [lux (.except function) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control pipe] [data @@ -36,7 +36,7 @@ (Expression (Application Synthesis)) (do [! ///////phase.monad] [functionG (expression archive functionS) - argsG+ (monad.each ! (expression archive) argsS+)] + argsG+ (stack.each' ! (expression archive) argsS+)] (in (_.funcall/+ [functionG argsG+])))) (the capture @@ -69,7 +69,7 @@ [function_name bodyG] (/////translation.with_new_context archive (/////translation.with_anchor [@scope 1] (expression archive bodyS))) - closureG+ (monad.each ! (expression archive) environment) + closureG+ (stack.each' ! (expression archive) environment) .let [@curried (_.var "curried") @missing (_.var "missing") arityG (|> arity .integer _.int) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/loop.lux index 50fb0125a8..878038f980 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/loop.lux @@ -5,7 +5,7 @@ [library [lux (.except Scope) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] [text @@ -47,7 +47,7 @@ (do [! ///////phase.monad] [@scope (by ! each (|>> %.natural (text "loop_scope") _.tag) /////translation.next) @output (by ! each (|>> %.natural (text "loop_output") _.var) /////translation.next) - initsG+ (monad.each ! (expression archive) initsS+) + initsG+ (stack.each' ! (expression archive) initsS+) bodyG (/////translation.with_anchor [@scope start] (expression archive bodyS))] ... TODO: There is a bug in the way the variables are updated. Do a _.multiple_value_setq instead. @@ -65,7 +65,7 @@ (Expression (Stack Synthesis)) (do [! ///////phase.monad] [[tag offset] /////translation.anchor - argsO+ (monad.each ! (expression archive) argsS+) + argsO+ (stack.each' ! (expression archive) argsS+) .let [bindings (|> argsO+ stack.enumeration (stack#each (|>> product.left (n.+ offset) //when.register)) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/runtime.lux index 594a975c85..ff59c8a7e9 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/runtime.lux @@ -5,8 +5,8 @@ [library [lux (.except the) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data ["[0]" product] @@ -96,7 +96,7 @@ (syntax.macro (_ [vars (.tuple (<>.some .local)) body .any]) (do [! meta.monad] - [ids (monad.all ! (stack.repeated (stack.size vars) meta.seed))] + [ids (stack.all' ! (stack.repeated (stack.size vars) meta.seed))] (in (stack (` (let [(,* (|> vars (stack.zipped_2 ids) (stack#each (function (_ [id var]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/structure.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/structure.lux index f62db27059..c923c2125c 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/structure.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/structure.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [target ["_" common_lisp]]]] ["[0]" // @@ -28,7 +28,7 @@ _ (|> elemsS+ - (monad.each ///////phase.monad (expression archive)) + (stack.each' ///////phase.monad (expression archive)) (///////phase#each _.vector/*)))) (the .public (variant expression archive [lefts right? valueS]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/when.lux index a101987689..31af031545 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/common_lisp/when.lux @@ -5,7 +5,7 @@ [library [lux (.except when let if) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" text (.only) ["%" \\injection]] @@ -178,13 +178,13 @@ (,, (template.with [ <=>] [{ item} (do [! ///////phase.monad] - [clauses (monad.each ! (function (_ [match then]) - (do ! - [then! (again [$output @done @fail then])] - (in [(<=> [(|> match ) - ..peek]) - then!]))) - {.#Top item})] + [clauses (stack.each' ! (function (_ [match then]) + (do ! + [then! (again [$output @done @fail then])] + (in [(<=> [(|> match ) + ..peek]) + then!]))) + {.#Top item})] (in (stack#mix (function (_ [when then] else) (_.if when then else)) (_.go @fail) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/extension.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/extension.lux index b6a2ed0a2b..5fd9e564ce 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/extension.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/extension.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" exception (.only Exception)]] [data @@ -46,7 +46,7 @@ (syntax.macro (_ [arity .natural]) (with_names ['_ 'extension 'phase 'archive 'inputs 'anchor 'expression 'declaration] (do [! meta.monad] - ['input+ (monad.all ! (stack.repeated arity (macro.name "input")))] + ['input+ (stack.all' ! (stack.repeated arity (macro.name "input")))] (in (stack (` (is (for_any ((, '_) (, 'anchor) (, 'expression) (, 'declaration)) (-> ((Arity (, (code.natural arity))) (, 'expression)) (translation.Handler (, 'anchor) (, 'expression) (, 'declaration)))) @@ -86,6 +86,5 @@ (function (_ phase archive inputsS) (let [! phase.monad] (|> inputsS - list.as_stack - (monad.each ! (phase archive)) - (by ! each extension))))) + (list.each' ! (phase archive)) + (by ! each (|>> list.as_stack extension)))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/function.lux index 4df97bedf5..38e9c14272 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/function.lux @@ -5,7 +5,7 @@ [library [lux (.except function) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] ["[0]" text] @@ -73,7 +73,7 @@ (the (arbitrary_reification' expression archive [abstraction parameters]) (Expression [//runtime.Value (Stack synthesis.Term)]) (do [! phase.monad] - [parameters (monad.each ! (expression archive) parameters)] + [parameters (stack.each' ! (expression archive) parameters)] (in (_.apply abstraction parameters)))) (the (arbitrary_reification expression archive [abstraction parameters]) @@ -85,7 +85,7 @@ (the (exact_reification expression archive [abstraction arity parameters]) (Expression [unit.ID Arity (Stack synthesis.Term)]) (do [! phase.monad] - [parameters (monad.each ! (expression archive) parameters)] + [parameters (stack.each' ! (expression archive) parameters)] (in (_.apply (_.var (///reference.artifact (..procedure_id abstraction))) {.#Top (_.var (///reference.artifact abstraction)) parameters})))) @@ -148,7 +148,7 @@ (-> Phase! (Expression (analysis.Abstraction synthesis.Term))) (do [! phase.monad] [dependencies (cache.dependencies archive bodyS) - environment (monad.each ! (expression archive) environment) + environment (stack.each' ! (expression archive) environment) [abstraction_id @scope body!] (let [abstraction (<| (translation.with_new_context archive dependencies) (do ! [scope (by ! each ..@scope diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/loop.lux index eb12ab4e59..9cb272aa44 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/loop.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] ["[0]" text (.only) @@ -74,7 +74,7 @@ _ (do [! phase.monad] [@tail_recursion (by ! each ..@tail_recursion /////translation.next) - initsO+ (monad.each ! (expression archive) initsS+) + initsO+ (stack.each' ! (expression archive) initsS+) body! (/////translation.with_anchor [start @tail_recursion] (statement expression archive bodyS)) $iteration (by ! each ..$iteration /////translation.next)] @@ -103,7 +103,7 @@ (Statement (Stack synthesis.Term)) (do [! phase.monad] [[offset @tail_recursion] /////translation.anchor - it (monad.each ! (expression archive) it) + it (stack.each' ! (expression archive) it) $iteration (by ! each ..$iteration /////translation.next)] (in (..setup $iteration false offset diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/runtime.lux index c32f5b91d5..87a0e678ab 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/runtime.lux @@ -7,8 +7,8 @@ i64 variant the) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data ["[0]" product] @@ -108,7 +108,7 @@ (syntax.macro (_ [vars (.tuple (<>.some .local)) body .any]) (do [! meta.monad] - [ids (monad.all ! (stack.repeated (stack.size vars) meta.seed))] + [ids (stack.all' ! (stack.repeated (stack.size vars) meta.seed))] (in (stack (` (let [(,* (|> vars (stack.zipped_2 ids) (stack#each (function (_ [id var]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/structure.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/structure.lux index c752cf84d8..85cad304c5 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/structure.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/structure.lux @@ -6,7 +6,7 @@ [lux (.except Variant Tuple variant tuple) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [target ["_" js]]]] ["[0]" // @@ -29,7 +29,7 @@ _ (do [! phase.monad] - [elemsT+ (monad.each ! (translate archive) elemsS+)] + [elemsT+ (stack.each' ! (translate archive) elemsS+)] (in (_.array elemsT+))))) (the .public (variant translate archive [lefts right? valueS]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/when.lux index e478fa10d0..a5ab05c652 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/js/when.lux @@ -6,7 +6,7 @@ [lux (.except when exec let if its or and) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe]] [data @@ -69,11 +69,11 @@ (Expression synthesis.Let) (do [! phase.monad] [.let [[tail body] (synthesis.flat_let body)] - bindings (monad.each ! (function (_ [binding value]) - (phase#each (_.define (..register binding)) - (next archive value))) - (stack.partial [head_binding head_value] - tail)) + bindings (stack.each' ! (function (_ [binding value]) + (phase#each (_.define (..register binding)) + (next archive value))) + (stack.partial [head_binding head_value] + tail)) body (next archive body)] ... (in (stack#mix _., body (stack.reversed bindings))) (in (_.apply (<| (_.closure (stack)) @@ -291,13 +291,13 @@ {synthesis.#I64_Fork item} (do [! phase.monad] ['input (phase#each _.var (translation.name "input")) - clauses (monad.each ! (function (_ [when then]) - (do ! - [then! (again then)] - (in [(//runtime.i64::= (//primitive.i64 when) - 'input) - then!]))) - {.#Top item})] + clauses (stack.each' ! (function (_ [when then]) + (do ! + [then! (again then)] + (in [(//runtime.i64::= (//primitive.i64 when) + 'input) + then!]))) + {.#Top item})] (in (all _.then (_.define 'input ..peek_cursor) (stack#mix (function (_ [when then] else) @@ -308,9 +308,9 @@ (,, (template.with [ ] [{ item} (do [! phase.monad] - [cases (monad.each ! (function (_ [match then]) - (by ! each (|>> [(stack ( match))]) (again then))) - {.#Top item})] + [cases (stack.each' ! (function (_ [match then]) + (by ! each (|>> [(stack ( match))]) (again then))) + {.#Top item})] (in (_.switch ..peek_cursor (stack.reversed cases) {.#Some ..fail_pm!})))] @@ -407,10 +407,10 @@ (Statement [synthesis.Term (Stack [,type synthesis.Term]) synthesis.Term]) (do [! phase.monad] [input (expression archive input) - clauses (monad.each ! (function (_ [match then]) - (by ! each (|>> [(stack (,injection match))]) - (statement expression archive then))) - clauses) + clauses (stack.each' ! (function (_ [match then]) + (by ! each (|>> [(stack (,injection match))]) + (statement expression archive then))) + clauses) else (statement expression archive else)] (in (_.switch input (stack.reversed clauses) @@ -434,9 +434,9 @@ (do [! phase.monad] [input (expression archive input) 'input (phase#each _.var (translation.name "input")) - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [when]) (statement expression archive then))) - clauses) + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [when]) (statement expression archive then))) + clauses) else (statement expression archive else)] (in (all _.then (_.define 'input input) @@ -453,9 +453,9 @@ (do [! phase.monad] [input (expression archive input) 'input (phase#each _.var (translation.name "input")) - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [when]) (expression archive then))) - clauses) + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [when]) (expression archive then))) + clauses) else (expression archive else)] (in (_.apply (<| (_.closure (stack 'input)) _.return diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/complex.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/complex.lux index bc95635121..384bd9aae5 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/complex.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/complex.lux @@ -6,7 +6,7 @@ [lux (.except Variant Tuple variant tuple) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] [data @@ -89,15 +89,15 @@ (do [! phase.monad] [membersI (|> membersS stack.enumeration - (monad.each ! (function (_ [idx member]) - (do ! - [memberI (phase archive member)] - (in (do _.monad - [_ _.dup - _ (_.int (i/32.of (.integer idx))) - _ memberI] - _.aastore))))))] + (stack.each' ! (function (_ [idx member]) + (do ! + [memberI (phase archive member)] + (in (do _.monad + [_ _.dup + _ (_.int (i/32.of (.integer idx))) + _ memberI] + _.aastore))))))] (in (do [! _.monad] [_ (_.int (i/32.of (.integer (stack.size membersS)))) _ (_.anewarray //type.value)] - (monad.all ! membersI)))))) + (stack.all' ! membersI)))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function.lux index 71bf2d7e90..a222e6312d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function.lux @@ -6,7 +6,7 @@ [lux (.except Type Label with) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] [data @@ -94,8 +94,8 @@ (stack (/implementation.method classT arity @begin body) (/apply.method classT environment arity @begin 1)))))] (do [! phase.monad] - [environment (monad.each ! (expression archive) (list.as_stack environment))] - (in [fields methods (/init.instance classT (list.of_stack environment) arity)])))) + [environment (list.each' ! (expression archive) environment)] + (in [fields methods (/init.instance classT environment arity)])))) (the modifier (Modifier Class) @@ -141,18 +141,18 @@ (the (arbitrary_reification' expression archive [abstraction parameters]) (Expression [(Bytecode Any) (List synthesis.Term)]) (do [! phase.monad] - [parameters (monad.each ! (expression archive) (list.as_stack parameters))] + [parameters (stack.each' ! (expression archive) (list.as_stack parameters))] (in (all _.composite abstraction (|> parameters (stack.sub /arity.maximum) - (monad.each _.monad - (function (_ batchG) - (all _.composite - (_.checkcast /abstract.class) - (monad.all _.monad batchG) - (_.invokevirtual /abstract.class //runtime.apply::name (//runtime.apply::type (stack.size batchG))) - )))) + (stack.each' _.monad + (function (_ batchG) + (all _.composite + (_.checkcast /abstract.class) + (stack.all' _.monad batchG) + (_.invokevirtual /abstract.class //runtime.apply::name (//runtime.apply::type (stack.size batchG))) + )))) )))) (the (arbitrary_reification expression archive [abstraction parameters]) @@ -166,10 +166,10 @@ (do [! phase.monad] [.let [:abstraction: (type.class (stack) (//runtime.class_name @abstraction))] abstraction (//reference.constant archive $abstraction) - parameters (monad.each ! (expression archive) (list.as_stack parameters))] + parameters (list.each' ! (expression archive) parameters)] (in (all _.composite abstraction - (monad.all _.monad parameters) + (list.all' _.monad parameters) (/implementation.call :abstraction: arity) )))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux index 98ff4699e7..0328bf41c4 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux @@ -4,8 +4,6 @@ (.using [library [lux (.except Type) - [abstract - ["[0]" monad]] [data [collection ["[0]" stack (.use "[1]#[0]" functor)]]] @@ -38,7 +36,7 @@ (all _.composite (|> _.aconst_null (stack.repeated amount) - (monad.all _.monad)) + (stack.all' _.monad)) (_#in []))) (the .public (get class register) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux index 8404c744c8..de7b4c98fd 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux @@ -5,7 +5,7 @@ [library [lux (.except Type Label) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] [data @@ -65,7 +65,7 @@ (all _.composite (|> amount stack.indices - (monad.each _.monad (|>> (n.+ offset) _.aload))) + (stack.each' _.monad (|>> (n.+ offset) _.aload))) (_#in []) )) @@ -105,14 +105,14 @@ @labelsH _.new_label @labelsT (|> _.new_label (stack.repeated (-- num_partials)) - (monad.all _.monad)) + (stack.all' _.monad)) .let [cases (|> (stack#composite {.#Top [@labelsH @labelsT]} (stack @default)) stack.enumeration (stack#each (function (_ [stage @case]) (let [current_partials (|> (stack.indices stage) (stack#each (///partial.get class)) - (monad.all _.monad)) + (stack.all' _.monad)) already_partial? (n.> 0 stage) exact_match? (i.= over_extent (.integer stage)) has_less_than_necessary? (i.< over_extent (.integer stage)) @@ -135,10 +135,10 @@ (let [environment_size (list.size environment) current_environment (|> (stack.indices environment_size) (stack#each (///foreign.get class)) - (monad.all _.monad)) + (stack.all' _.monad)) missing_partials (|> _.aconst_null (stack.repeated (|> num_partials (n.- apply_arity) (n.- stage))) - (monad.all _.monad))] + (stack.all' _.monad))] (all _.composite (_.new class) _.dup @@ -163,7 +163,7 @@ (//implementation.call class function_arity) (apply (n.+ ..this_offset arity_inputs) additional_inputs) _.areturn))))))) - (monad.all _.monad))]] + (stack.all' _.monad))]] (all _.composite ////reference.this ///count.value diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/init.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/init.lux index 452ccbdfa8..2da2e36a94 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/function/method/init.lux @@ -4,8 +4,6 @@ (.using [library [lux (.except Type type name) - [abstract - ["[0]" monad]] [error ["[0]" try]] [data @@ -89,7 +87,7 @@ (stack#each (function (_ register) (put register (_.aload (offset register))))) - (monad.all _.monad))) + (stack.all' _.monad))) (the .public (method class environment arity) (-> (Type Class) (Environment synthesis.Term) Arity @@ -117,6 +115,6 @@ (all _.composite (_.new class) _.dup - (monad.all _.monad (list.as_stack environment)) + (stack.all' _.monad (list.as_stack environment)) (///partial.new arity) (_.invokespecial class ..name (..type (list.size environment) arity)))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/loop.lux index 1dd14ffcb8..5a885910e3 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/loop.lux @@ -5,13 +5,12 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] ["[0]" function] [data ["[0]" product] [collection - ["[0]" list (.use "[1]#[0]" functor)] - ["[0]" stack (.use "[1]#[0]" functor)]]] + ["[0]" list (.use "[1]#[0]" functor)]]] [math [number ["n" natural]]] @@ -50,8 +49,7 @@ list.enumeration (list#each (function (_ [index updateS]) [(n.+ offset index) updateS])) - list.as_stack - (monad.each ! (function (_ [register updateS]) + (list.each' ! (function (_ [register updateS]) (if (invariant? register updateS) (in [..no_op ..no_op]) @@ -69,31 +67,31 @@ ... will refer to the new value of X, instead of the old value, as ... should be the case. (|> updatesG - (stack#each product.left) - (monad.all _.monad)) + (list#each product.left) + (list.all' _.monad)) (|> updatesG - stack.reversed - (stack#each product.right) - (monad.all _.monad)) + list.reversed + (list#each product.right) + (list.all' _.monad)) (_.goto @begin))))) (the .public (tail_recursion next archive [offset initsS+ iterationS]) (Expression [Natural (List synthesis.Term) synthesis.Term]) (do [! phase.monad] [@begin //runtime.forge_label - initsI+ (monad.each ! (next archive) (list.as_stack initsS+)) + initsI+ (list.each' ! (next archive) initsS+) iterationG (translation.with_anchor [@begin offset] (next archive iterationS)) - .let [initializationG (stack#each (function (_ [index initG]) - [initG (_.astore (n.+ offset index))]) - (stack.enumeration initsI+))]] + .let [initializationG (list#each (function (_ [index initG]) + [initG (_.astore (n.+ offset index))]) + (list.enumeration initsI+))]] (in (all _.composite (|> initializationG - (stack#each product.left) - (monad.all _.monad)) + (list#each product.left) + (list.all' _.monad)) (|> initializationG - stack.reversed - (stack#each product.right) - (monad.all _.monad)) + list.reversed + (list#each product.right) + (list.all' _.monad)) (_.set_label @begin) iterationG)))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux index 806e821191..b2ae176a79 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux @@ -6,7 +6,7 @@ [lux (.except Type Definition Label Declaration when false true try variant) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" enum]] [error ["[0]" try]] @@ -580,7 +580,7 @@ {.#Some (let [previous_inputs (|> arity stack.indices - (monad.each _.monad _.aload))] + (stack.each' _.monad _.aload))] (all _.composite previous_inputs (_.invokevirtual //function.class ..apply::name (..apply::type (-- arity))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/when.lux index 0894ba0804..f774f1d862 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/when.lux @@ -7,11 +7,10 @@ let exec when its if or and) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data [collection - ["[0]" list (.use "[1]#[0]" mix)] - ["[0]" stack (.use "[1]#[0]" mix)]]] + ["[0]" list (.use "[1]#[0]" mix monoid)]]] [math [number ["n" natural] @@ -131,7 +130,7 @@ Label (Fork Path) (Operation (Bytecode Any))) (do [! phase.monad] - [fork! (monad.mix ! (function (_ [test thenP] else!) + [fork! (list.mix' ! (function (_ [test thenP] else!) (do ! [then! (again thenP)] (in (do _.monad @@ -148,7 +147,7 @@ (all _.composite (_.goto @else)) - (stack.reversed {.#Top [head (list.as_stack tail)]}))] + (list.reversed (list#composite (list head) tail)))] (in (all _.composite ..peek @@ -241,6 +240,22 @@ [synthesis.member/left ..left_projection] [synthesis.member/right ..right_projection])) + + {synthesis.#List size} + (in (all _.composite + ..peek + (_.checkcast //type.list) + _.arraylength + (..int size) + (_.if_icmpne @else))) + + (synthesis.item index) + (in (all _.composite + ..peek + (_.checkcast //type.list) + (..int index) + _.aaload + //runtime.push)) {synthesis.#Seq leftP rightP} (do phase.monad @@ -371,36 +386,36 @@ (Expression [synthesis.Term (List [,type synthesis.Term]) synthesis.Term]) (do [! phase.monad] [input (expression archive input) - cases (monad.each ! (function (_ [when then]) + cases (list.each' ! (function (_ [when then]) (by ! each (|>> [when]) (expression archive then))) - (list.as_stack cases)) + cases) else (expression archive else)] (in (do [! _.monad] [@end _.new_label] (all _.composite input ,un_box - (stack#mix (function (_ [when then] else) - (do [! _.monad] - [@else _.new_label] - (all _.composite - ,dup - (,literal when) - ,comparison - (,if @else) - ,pop - then - (_.when_continuous (_.goto @end)) - (_.set_label @else) - else))) - (all _.composite - ,pop - else - (<| (_.when_acknowledged @end) - (_.set_label @end))) - (stack.reversed cases)))))))] + (list#mix (function (_ [when then] else) + (do [! _.monad] + [@else _.new_label] + (all _.composite + ,dup + (,literal when) + ,comparison + (,if @else) + ,pop + then + (_.when_continuous (_.goto @end)) + (_.set_label @else) + else))) + (all _.composite + ,pop + else + (<| (_.when_acknowledged @end) + (_.set_label @end))) + (list.reversed cases)))))))] [when_i64 I64 (//value.primitive type.long) //primitive.i64' _.dup2 _.pop2 _.lcmp _.ifne] [when_f64 F64 (//value.primitive type.double) //primitive.f64' _.dup2 _.pop2 _.dcmpl _.ifne] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/function.lux index 33012411cd..33863c98b4 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/function.lux @@ -5,7 +5,7 @@ [library [lux (.except function) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] ["[0]" text] @@ -73,7 +73,7 @@ (the (arbitrary_reification' expression archive [abstraction parameters]) (Expression [//runtime.Value (Stack synthesis.Term)]) (do [! phase.monad] - [parameters (monad.each ! (expression archive) parameters)] + [parameters (stack.each' ! (expression archive) parameters)] (in (_.apply parameters abstraction)))) (the (arbitrary_reification expression archive [abstraction parameters]) @@ -85,7 +85,7 @@ (the (exact_reification expression archive [abstraction arity parameters]) (Expression [unit.ID Arity (Stack synthesis.Term)]) (do [! phase.monad] - [parameters (monad.each ! (expression archive) parameters)] + [parameters (stack.each' ! (expression archive) parameters)] (in (_.apply {.#Top (_.var (///reference.artifact abstraction)) parameters} (_.var (///reference.artifact (..procedure_id abstraction))))))) @@ -143,7 +143,7 @@ (-> Phase! (Expression (analysis.Abstraction synthesis.Term))) (do [! phase.monad] [dependencies (cache.dependencies archive bodyS) - environment (monad.each ! (expression archive) environment) + environment (stack.each' ! (expression archive) environment) [abstraction_id @scope body!] (let [abstraction (<| (translation.with_new_context archive dependencies) (do ! [@scope (by ! each ..@scope diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/loop.lux index a92cdc15d5..92a55f076a 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/loop.lux @@ -5,7 +5,7 @@ [library [lux (.except Label) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] [text @@ -68,7 +68,7 @@ _ (do [! phase.monad] [@tail_recursion (by ! each ..@tail_recursion /////translation.next) - initsO+ (monad.each ! (expression archive) initsS+) + initsO+ (stack.each' ! (expression archive) initsS+) body! (/////translation.with_anchor [start @tail_recursion] (statement expression archive bodyS))] (in [initsO+ @@ -123,5 +123,5 @@ (Statement (Stack synthesis.Term)) (do [! phase.monad] [[offset @tail_recursion] /////translation.anchor - it (monad.each ! (expression archive) it)] + it (stack.each' ! (expression archive) it)] (in (..setup false offset it false (_.go_to @tail_recursion))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/runtime.lux index 6b4af766c5..9da68400e4 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/runtime.lux @@ -7,8 +7,8 @@ variant the) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data ["[0]" product] @@ -133,7 +133,7 @@ (syntax.macro (_ [vars (.tuple (<>.some .local)) body .any]) (do [! meta.monad] - [ids (monad.all ! (stack.repeated (stack.size vars) meta.seed))] + [ids (stack.all' ! (stack.repeated (stack.size vars) meta.seed))] (in (stack (` (let [(,* (|> vars (stack.zipped_2 ids) (stack#each (function (_ [id var]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/structure.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/structure.lux index d4d039c75b..3ddd94df47 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/structure.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/structure.lux @@ -6,7 +6,7 @@ [lux (.except Tuple Variant tuple variant) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [target ["_" lua]]]] ["[0]" // @@ -29,7 +29,7 @@ _ (|> elemsS+ - (monad.each phase.monad (phase archive)) + (stack.each' phase.monad (phase archive)) (phase#each _.array)))) (the .public (variant phase archive [lefts right? valueS]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/when.lux index ef6691cf3d..1afa6c78a0 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/lua/when.lux @@ -6,7 +6,7 @@ [lux (.except when exec let if its or and) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" text] [collection @@ -52,8 +52,8 @@ (Expression synthesis.Exec) (do [! phase.monad] [.let [[tail after] (synthesis.flat_exec (.its synthesis.#exec_after it))] - all_before (monad.each ! (next archive) - (stack.partial (.its synthesis.#exec_before it) tail)) + all_before (stack.each' ! (next archive) + (stack.partial (.its synthesis.#exec_before it) tail)) after (next archive after)] (in (_.item (_.int +2) (_.array (stack (_.array all_before) @@ -73,11 +73,11 @@ (Expression synthesis.Let) (do [! phase.monad] [.let [[tail body] (synthesis.flat_let body)] - bindings (monad.each ! (function (_ [binding value]) - (phase#each (_.local/1 (..register binding)) - (next archive value))) - (stack.partial [head_binding head_value] - tail)) + bindings (stack.each' ! (function (_ [binding value]) + (phase#each (_.local/1 (..register binding)) + (next archive value))) + (stack.partial [head_binding head_value] + tail)) body (next archive body)] ... TODO: Find some way to do 'let' without paying the price of the closure. (in (<| (_.apply (stack)) @@ -233,13 +233,13 @@ [{ item} (do [! phase.monad] ['input (phase#each _.var (/////translation.name "input")) - clauses (monad.each ! (function (_ [match then]) - (do ! - [then! (again then)] - (in [(_.= ( match) - 'input) - then!]))) - {.#Top item})] + clauses (stack.each' ! (function (_ [match then]) + (do ! + [then! (again then)] + (in [(_.= ( match) + 'input) + then!]))) + {.#Top item})] (in (all _.then (_.local/1 'input ..peek) (stack#mix (function (_ [when then!] else!) @@ -371,9 +371,9 @@ (do [! phase.monad] [input (expression archive input) 'input (phase#each _.var (/////translation.name "input")) - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [when]) (statement expression archive then))) - clauses) + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [when]) (statement expression archive then))) + clauses) else (statement expression archive else)] (in (all _.then (_.local/1 'input input) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/extension/common.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/extension/common.lux index 10b2e9f2cf..d8fc576e61 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/extension/common.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/extension/common.lux @@ -4,8 +4,6 @@ (.using [library [lux (.except) - [abstract - ["[0]" monad (.only do)]] ["[0]" function] [data ["[0]" product] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/function.lux index 8c2f190515..0e6c1d1614 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/function.lux @@ -6,7 +6,7 @@ [lux (.except Global function) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control pipe] [data @@ -37,7 +37,7 @@ (Expression (Application Synthesis)) (do [! ///////phase.monad] [functionG (expression archive functionS) - argsG+ (monad.each ! (expression archive) argsS+)] + argsG+ (stack.each' ! (expression archive) argsS+)] (in (_.apply' argsG+ functionG)))) (the capture @@ -82,7 +82,7 @@ (/////translation.context archive))] (/////translation.with_anchor [1 @scope] (statement expression archive bodyS)))) - closureG+ (monad.each ! (expression archive) environment) + closureG+ (stack.each' ! (expression archive) environment) .let [@curried (_.var "curried") arityG (|> arity .integer _.int) @num_args (_.var "num_args") 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 3fdf9b93c6..d7c8f0cbdd 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 @@ -5,7 +5,7 @@ [library [lux (.except Scope) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] ["[0]" text (.only) @@ -62,7 +62,7 @@ _ (do [! ///////phase.monad] [@scope (by ! each ..@scope /////translation.next) - initsO+ (monad.each ! (expression archive) initsS+) + initsO+ (stack.each' ! (expression archive) initsS+) body! (/////translation.with_anchor [start @scope] (statement expression archive bodyS))] (in (..setup start initsO+ @@ -117,7 +117,7 @@ (Statement (Stack Synthesis)) (do [! ///////phase.monad] [[offset @scope] /////translation.anchor - argsO+ (monad.each ! (expression archive) argsS+)] + argsO+ (stack.each' ! (expression archive) argsS+)] (in (all _.then (_.set! @temp (_.array/* argsO+)) (..setup offset diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/runtime.lux index 7acfe91437..dffe8f7c04 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/runtime.lux @@ -5,8 +5,8 @@ [library [lux (.except the) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data ["[0]" product] @@ -81,7 +81,7 @@ (syntax.macro (_ [vars (.tuple (<>.some .local)) body .any]) (do [! meta.monad] - [ids (monad.all ! (stack.repeated (stack.size vars) meta.seed))] + [ids (stack.all' ! (stack.repeated (stack.size vars) meta.seed))] (in (stack (` (let [(,* (|> vars (stack.zipped_2 ids) (stack#each (function (_ [id var]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/structure.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/structure.lux index 4f160d8330..9e8e9eb013 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/structure.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/structure.lux @@ -4,8 +4,6 @@ (.using [library [lux (.except) - [abstract - ["[0]" monad (.only do)]] [data [collection ["[0]" stack]]] @@ -32,7 +30,7 @@ _ (let [size (_.int (.integer (stack.size elemsS+)))] (|> elemsS+ - (monad.each ///////phase.monad (expression archive)) + (stack.each' ///////phase.monad (expression archive)) (///////phase#each (|>> _.array/* (//runtime.tuple//make size))))))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/when.lux index 73a803771a..4177f2d17f 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/php/when.lux @@ -5,7 +5,7 @@ [library [lux (.except when let if) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] ["[0]" text] @@ -197,13 +197,13 @@ (,, (template.with [ ] [{ item} (do [! ///////phase.monad] - [clauses (monad.each ! (function (_ [match then]) - (do ! - [then! (again then)] - (in [(_.=== (|> match ) - ..peek) - then!]))) - {.#Top item})] + [clauses (stack.each' ! (function (_ [match then]) + (do ! + [then! (again then)] + (in [(_.=== (|> match ) + ..peek) + then!]))) + {.#Top item})] (in (_.cond clauses ..fail!)))] [/////synthesis.#I64_Fork //primitive.i64] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/function.lux index b4ca578d4b..aedbf2e938 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/function.lux @@ -5,7 +5,7 @@ [library [lux (.except function) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] [collection @@ -69,7 +69,7 @@ (the (arbitrary_reification' expression archive [abstraction parameters]) (Expression [//runtime.Value (Stack synthesis.Term)]) (do [! phase.monad] - [parameters (monad.each ! (expression archive) parameters)] + [parameters (stack.each' ! (expression archive) parameters)] (in (_.apply (list.of_stack parameters) abstraction)))) (the (arbitrary_reification expression archive [abstraction parameters]) @@ -81,7 +81,7 @@ (the (exact_reification expression archive [abstraction arity parameters]) (Expression [unit.ID Arity (Stack synthesis.Term)]) (do [! phase.monad] - [parameters (monad.each ! (expression archive) parameters)] + [parameters (stack.each' ! (expression archive) parameters)] (in (_.apply (list.of_stack {.#Top (_.var (///reference.artifact abstraction)) parameters}) (_.var (///reference.artifact (..procedure_id abstraction))))))) @@ -145,7 +145,7 @@ (-> Phase! (Expression synthesis.Abstraction)) (do [! phase.monad] [dependencies (cache.dependencies archive bodyS) - environment (monad.each ! (expression archive) environment) + environment (stack.each' ! (expression archive) environment) [abstraction_id body!] (let [abstraction (<| (translation.with_new_context archive dependencies) (translation.with_anchor 1) (statement expression archive) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/loop.lux index 1edfa09abe..f491f34b1e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/loop.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] [collection @@ -64,7 +64,7 @@ ... true loop _ (do [! phase.monad] - [initsO+ (monad.each ! (expression archive) initsS+) + [initsO+ (stack.each' ! (expression archive) initsS+) body! (/////translation.with_anchor start (statement expression archive bodyS))] (in (<| (..setup start initsO+) @@ -83,7 +83,7 @@ _ (do [! phase.monad] [dependencies (cache.dependencies archive bodyS) - initsO+ (monad.each ! (expression archive) initsS+) + initsO+ (stack.each' ! (expression archive) initsS+) [[loop_module loop_artifact] body!] (/////translation.with_new_context archive dependencies (/////translation.with_anchor start (statement expression archive bodyS))) @@ -119,6 +119,6 @@ (Statement (Stack synthesis.Term)) (do [! phase.monad] [offset /////translation.anchor - it (monad.each ! (expression archive) it)] + it (stack.each' ! (expression archive) it)] (in (..setup offset it _.continue)))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/runtime.lux index 7e0b5a0653..d8c59f5140 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/runtime.lux @@ -7,8 +7,8 @@ ++ variant the) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data ["[0]" product] @@ -139,7 +139,7 @@ (syntax.macro (_ [vars (.tuple (<>.some .local)) body .any]) (do [! meta.monad] - [ids (monad.all ! (stack.repeated (stack.size vars) meta.seed))] + [ids (stack.all' ! (stack.repeated (stack.size vars) meta.seed))] (in (stack (` (let [(,* (|> vars (stack.zipped_2 ids) (stack#each (function (_ [id var]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/structure.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/structure.lux index 6a41575577..84c0502d67 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/structure.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/structure.lux @@ -6,7 +6,7 @@ [lux (.except Variant Tuple variant tuple) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data [collection ["[0]" list]]] @@ -32,7 +32,7 @@ _ (|> elemsS+ - (monad.each phase.monad (translate archive)) + (stack.each' phase.monad (translate archive)) (phase#each (|>> list.of_stack _.list))))) (the .public (variant translate archive [lefts right? valueS]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/when.lux index d429a8776e..8df728a0c9 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/python/when.lux @@ -6,7 +6,7 @@ [lux (.except when exec let if its or and) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" text (.only) ["%" \\injection]] @@ -80,8 +80,8 @@ (Expression synthesis.Exec) (do [! phase.monad] [.let [[tail after] (synthesis.flat_exec (.its synthesis.#exec_after it))] - all_before (monad.each ! (next archive) - (stack.partial (.its synthesis.#exec_before it) tail)) + all_before (stack.each' ! (next archive) + (stack.partial (.its synthesis.#exec_before it) tail)) after (next archive after)] (in (_.item (_.int +1) (_.tuple (list (_.tuple (list.of_stack all_before)) @@ -240,9 +240,9 @@ [{ item} (do [! phase.monad] ['input (phase#each _.var (/////translation.name "input")) - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [when]) (again then))) - {.#Top item})] + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [when]) (again then))) + {.#Top item})] (in (all _.then (_.set (list 'input) ..peek) (stack#mix (function (_ [when then] else) @@ -407,9 +407,9 @@ (do [! phase.monad] [input (expression archive input) 'input (phase#each _.var (/////translation.name "input")) - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [when]) (statement expression archive then))) - clauses) + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [when]) (statement expression archive then))) + clauses) else (statement expression archive else)] (in (all _.then (_.set (list 'input) input) @@ -426,9 +426,9 @@ (do [! phase.monad] [input (expression archive input) 'input (phase#each _.var (/////translation.name "input")) - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [when]) (expression archive then))) - clauses) + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [when]) (expression archive then))) + clauses) else (expression archive else)] (in (|> (stack#mix (function (_ [when then] else) (_.? (_.= (,injection when) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/function.lux index 9049ca5787..8fb793c085 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/function.lux @@ -5,7 +5,7 @@ [library [lux (.except function) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control pipe] [data @@ -39,7 +39,7 @@ (Expression (Application Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) - argsO+ (monad.each ! (expression archive) argsS+)] + argsO+ (stack.each' ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) (the (with_closure function_id $function inits function_definition) @@ -83,7 +83,7 @@ (/////translation.context archive))] (/////translation.with_anchor $self (expression archive bodyS)))) - closureO+ (monad.each ! (expression archive) environment) + closureO+ (stack.each' ! (expression archive) environment) .let [arityO (|> arity .integer _.int) $num_args (_.var "num_args") $self (_.var (///reference.artifact [function_module function_artifact])) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/loop.lux index 2294a6c942..12b3ac24f0 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/loop.lux @@ -5,7 +5,7 @@ [library [lux (.except Scope) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] [collection @@ -45,7 +45,7 @@ _ (do [! ///////phase.monad] [$scope (by ! each _.var (/////translation.name "loop_scope")) - initsO+ (monad.each ! (expression archive) initsS+) + initsO+ (stack.each' ! (expression archive) initsS+) bodyO (/////translation.with_anchor $scope (expression archive bodyS))] (in (_.block @@ -62,5 +62,5 @@ (Expression (Stack Synthesis)) (do [! ///////phase.monad] [$scope /////translation.anchor - argsO+ (monad.each ! (expression archive) argsS+)] + argsO+ (stack.each' ! (expression archive) argsS+)] (in (_.apply argsO+ $scope)))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/runtime.lux index 663e83ad92..65c91782aa 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/runtime.lux @@ -6,8 +6,8 @@ [lux (.except ++ i64 the) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data ["[0]" product] @@ -85,7 +85,7 @@ (syntax.macro (_ [vars (.tuple (<>.some .local)) body .any]) (do [! meta.monad] - [ids (monad.all ! (stack.repeated (stack.size vars) meta.seed))] + [ids (stack.all' ! (stack.repeated (stack.size vars) meta.seed))] (in (stack (` (let [(,* (|> vars (stack.zipped_2 ids) (stack#each (function (_ [id var]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/structure.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/structure.lux index 3e7b26da87..a7a5e083be 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/structure.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/r/structure.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [target ["_" r]]]] ["[0]" // @@ -28,7 +28,7 @@ _ (|> elemsS+ - (monad.each ///////phase.monad (expression archive)) + (stack.each' ///////phase.monad (expression archive)) (///////phase#each _.list)))) (the .public (variant expression archive [lefts right? valueS]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/function.lux index cba3a2203f..f853db7e9e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/function.lux @@ -5,7 +5,7 @@ [library [lux (.except function) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] [collection @@ -36,7 +36,7 @@ (Expression synthesis.Reification) (do [! phase.monad] [functionO (expression archive functionS) - argsO+ (monad.each ! (expression archive) argsS+)] + argsO+ (stack.each' ! (expression archive) argsS+)] (in (_.apply_lambda argsO+ functionO)))) (the .public capture @@ -71,7 +71,7 @@ [[function_module function_artifact] body!] (/////translation.with_new_context archive dependencies (/////translation.with_anchor 1 (statement expression archive bodyS))) - closureO+ (monad.each ! (expression archive) environment) + closureO+ (stack.each' ! (expression archive) environment) .let [function_name (///reference.artifact [function_module function_artifact]) @curried (_.local "curried") arityO (|> arity .integer _.int) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/loop.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/loop.lux index 5b30819ed0..d7001b936d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/loop.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/loop.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] ["[0]" text] @@ -57,7 +57,7 @@ ... true loop _ (do [! phase.monad] - [initsO+ (monad.each ! (expression archive) initsS+) + [initsO+ (stack.each' ! (expression archive) initsS+) body! (/////translation.with_anchor start (statement expression archive bodyS))] (in (<| (..setup start initsO+) @@ -84,6 +84,6 @@ (Statement (Stack synthesis.Term)) (do [! phase.monad] [offset /////translation.anchor - it (monad.each ! (expression archive) it)] + it (stack.each' ! (expression archive) it)] (in (..setup offset it _.next)))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/runtime.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/runtime.lux index 0adc2c1bd1..1bf006ac32 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/runtime.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/runtime.lux @@ -7,8 +7,8 @@ i64 variant the) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] ["[0]" function] [data ["[0]" product] @@ -92,7 +92,7 @@ (syntax.macro (_ [vars (.tuple (<>.some .local)) body .any]) (do [! meta.monad] - [ids (monad.all ! (stack.repeated (stack.size vars) meta.seed))] + [ids (stack.all' ! (stack.repeated (stack.size vars) meta.seed))] (in (stack (` (let [(,* (|> vars (stack.zipped_2 ids) (stack#each (function (_ [id var]) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/structure.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/structure.lux index f9baa45582..12925e43a6 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/structure.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/structure.lux @@ -6,7 +6,7 @@ [lux (.except Variant Tuple variant tuple) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [target ["_" ruby]]]] ["[0]" // @@ -34,5 +34,5 @@ _ (|> elemsS+ - (monad.each phase.monad (translate archive)) + (stack.each' phase.monad (translate archive)) (phase#each _.array)))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/when.lux index 4a450af6dc..28217bf57e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/translation/ruby/when.lux @@ -7,7 +7,7 @@ when exec let if its or and) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" text (.only) ["%" \\injection]] @@ -61,8 +61,8 @@ (Expression synthesis.Exec) (do [! phase.monad] [.let [[tail after] (synthesis.flat_exec (.its synthesis.#exec_after it))] - all_before (monad.each ! (next archive) - (stack.partial (.its synthesis.#exec_before it) tail)) + all_before (stack.each' ! (next archive) + (stack.partial (.its synthesis.#exec_before it) tail)) after (next archive after)] (in (|> (_.array (stack (_.array all_before) after)) @@ -83,12 +83,12 @@ (Expression synthesis.Let) (do [! phase.monad] [.let [[tail body] (synthesis.flat_let body)] - bindings (monad.each ! (function (_ [binding value]) - (phase#each (|>> (_.set (stack (..register binding))) - _.;) - (next archive value))) - (stack.partial [head_binding head_value] - tail)) + bindings (stack.each' ! (function (_ [binding value]) + (phase#each (|>> (_.set (stack (..register binding))) + _.;) + (next archive value))) + (stack.partial [head_binding head_value] + tail)) body (next archive body)] ... (in (|> (_.array (stack#composite bindings ... (stack body))) @@ -261,10 +261,10 @@ (,, (template.with [ ] [{ item} (do [! phase.monad] - [clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [( when)]) - (again then))) - {.#Top item})] + [clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [( when)]) + (again then))) + {.#Top item})] (in (_.case ..peek (stack.reversed clauses) ..fail!)))] ... [synthesis.#I64_Fork //primitive.i64] @@ -274,10 +274,10 @@ {synthesis.#I64_Fork item} (do [! phase.monad] ['input (..name "input") - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [(//primitive.i64 when)]) - (again then))) - {.#Top item})] + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [(//primitive.i64 when)]) + (again then))) + {.#Top item})] (in (all _.then (_.; (_.set (stack 'input) ..peek)) (stack#mix (function (_ [when then] else) @@ -410,9 +410,9 @@ (Statement [synthesis.Term (Stack [,type synthesis.Term]) synthesis.Term]) (do [! phase.monad] [input (expression archive input) - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [(,injection when)]) (statement expression archive then))) - clauses) + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [(,injection when)]) (statement expression archive then))) + clauses) else (statement expression archive else)] (in (_.case input (stack.reversed clauses) else)))) @@ -434,10 +434,10 @@ (do [! phase.monad] [input (expression archive input) 'input (..name "input") - clauses (monad.each ! (function (_ [when then]) - (by ! each (|>> [(//primitive.i64 when)]) - (statement expression archive then))) - clauses) + clauses (stack.each' ! (function (_ [when then]) + (by ! each (|>> [(//primitive.i64 when)]) + (statement expression archive then))) + clauses) else (statement expression archive else)] (in (all _.then (_.; (_.set (stack 'input) input)) diff --git a/stdlib/source/library/lux/compiler/language/lux/program.lux b/stdlib/source/library/lux/compiler/language/lux/program.lux index 92a921c05c..c8405e1f1b 100644 --- a/stdlib/source/library/lux/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/compiler/language/lux/program.lux @@ -5,7 +5,7 @@ [library [lux (.except name) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe]] [error @@ -44,12 +44,12 @@ (do [! try.monad] [registries (|> archive archive.archived - (monad.each ! - (function (_ module) - (do ! - [id (archive.id module archive) - [_module output registry] (archive.find module archive)] - (in [[module id] registry])))))] + (stack.each' ! + (function (_ module) + (do ! + [id (archive.id module archive) + [_module output registry] (archive.find module archive)] + (in [[module id] registry])))))] (when (stack.one (function (_ [[module module_id] registry]) (do maybe.monad [id (registry.id ..name registry)] diff --git a/stdlib/source/library/lux/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/compiler/language/lux/synthesis.lux index d03c2d3094..afb06f30ea 100644 --- a/stdlib/source/library/lux/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/compiler/language/lux/synthesis.lux @@ -11,7 +11,7 @@ [abstract [equivalence (.only Equivalence)] [hash (.only Hash)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe]] [data @@ -86,6 +86,7 @@ {#I64_Fork (Fork I64 (Path' it))} {#F64_Fork (Fork F64 (Path' it))} {#Text_Fork (Fork Text (Path' it))} + {#List Natural} {#Seq (Path' it) (Path' it)} {#Alt (Path' it) (Path' it)} {#Then it})) @@ -176,7 +177,7 @@ (template.with [ ] [(the .public - (template.macro ( lefts right?) + (template.macro (_ lefts right?) [(.<| {..#Access} {} [ lefts @@ -186,9 +187,15 @@ [member /access.#Member /member.#lefts /member.#right?] ) +(the .public item + (template.macro (_ index) + [(.<| {..#Access} + {/access.#Item} + index)])) + (template.with [ ] [(the .public - (template.macro ( lefts) + (template.macro (_ lefts) [( lefts )]))] [..side #0 side/left] @@ -347,6 +354,9 @@ {#Bind register} (.text "(@ " (%.natural register) ")") + + {#List it} + (list.as_text %.natural (list it)) {#Alt left right} (.text "(| " (%path' %then left) " " (%path' %then right) ")") @@ -364,19 +374,8 @@ {#Simple it} (/simple.as_text it) - {#Structure structure} - (.when structure - {analysis/complex.#Variant [lefts right? content]} - (|> (as_text content) - (.text (%.natural lefts) " " (bit.as_text right?) " ") - (text.enclosed ["{" "}"])) - - {analysis/complex.#Tuple members} - (|> members - (list#each as_text) - list.as_stack - (text.interposed " ") - (text.enclosed ["[" "]"]))) + {#Structure it} + (analysis/complex.as_text as_text it) {#Reference reference} (reference.as_text reference) @@ -520,17 +519,20 @@ [13 #F64_Fork d.hash] [17 #Text_Fork text.hash])) + {#List it} + (n.* 19 (by n.hash hash it)) + (,, (template.with [ ] [{ fork} (.let [again_hash (path'_hash super) fork_hash (product.hash again_hash again_hash)] (n.* (by fork_hash hash fork)))] - [19 #Alt] - [23 #Seq])) + [23 #Alt] + [29 #Seq])) {#Then body} - (n.* 29 (by super hash body)) + (n.* 31 (by super hash body)) ))))) (the (when_equivalence (open "/#[0]")) @@ -817,14 +819,14 @@ {#Alt {,path head tail} {#Then else}} (do [! maybe.monad] - [cases (monad.each ! (function (_ road) - (.when (.its #then road) - {#Then then} - {.#Some [(.its #when road) then]} - - _ - {.#None})) - (stack.partial head (list.as_stack tail)))] + [cases (stack.each' ! (function (_ road) + (.when (.its #then road) + {#Then then} + {.#Some [(.its #when road) then]} + + _ + {.#None})) + (stack.partial head (list.as_stack tail)))] (in [input (list.of_stack cases) else])) _ diff --git a/stdlib/source/library/lux/compiler/language/lux/synthesis/access.lux b/stdlib/source/library/lux/compiler/language/lux/synthesis/access.lux index 1b5c0ac910..9df20d4a4d 100644 --- a/stdlib/source/library/lux/compiler/language/lux/synthesis/access.lux +++ b/stdlib/source/library/lux/compiler/language/lux/synthesis/access.lux @@ -10,15 +10,20 @@ [data ["[0]" sum] [text (.only Injection) - ["%" \\injection]]]]] + ["%" \\injection]]] + [math + [number + ["[0]" natural]]]]] ["[0]" / ["[1][0]" side (.only Side)] - ["[1][0]" member (.only Member)]]) + ["[1][0]" member (.only Member)] + ["[1][0]" item (.only Item)]]) (every .public Access (Variant {#Side Side} - {#Member Member})) + {#Member Member} + {#Item Item})) (the .public (as_text it) (Injection Access) @@ -27,13 +32,17 @@ (/side.as_text it) {#Member it} - (/member.as_text it))) + (/member.as_text it) + + {#Item it} + (/item.as_text it))) (the .public hash (Hash Access) (all sum.hash /side.hash /member.hash + /item.hash )) (the .public equivalence diff --git a/stdlib/source/library/lux/compiler/language/lux/synthesis/access/item.lux b/stdlib/source/library/lux/compiler/language/lux/synthesis/access/item.lux new file mode 100644 index 0000000000..3cdc9f6555 --- /dev/null +++ b/stdlib/source/library/lux/compiler/language/lux/synthesis/access/item.lux @@ -0,0 +1,33 @@ +... 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 + [equivalence (.only Equivalence)] + [hash (.only Hash)]] + [data + ["[0]" text (.only) + ["%" \\injection]]] + [math + [number + ["[0]" natural]]]]]) + +(every .public Item + Natural) + +(the .public (as_text it) + (text.Injection Item) + (text "(" (%.natural it) ")")) + +(the .public hash + (Hash Item) + natural.hash) + +(the .public equivalence + (Equivalence Item) + (by ..hash equivalence)) + +(alias [=] + ..equivalence) diff --git a/stdlib/source/library/lux/compiler/meta/cache/dependency/artifact.lux b/stdlib/source/library/lux/compiler/meta/cache/dependency/artifact.lux index ada7b9702a..d0cd22084b 100644 --- a/stdlib/source/library/lux/compiler/meta/cache/dependency/artifact.lux +++ b/stdlib/source/library/lux/compiler/meta/cache/dependency/artifact.lux @@ -7,7 +7,7 @@ [lux (.except all) [abstract [hash (.only Hash)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] [data @@ -45,7 +45,8 @@ (`` (when path (^.or {synthesis.#Pop} {synthesis.#Access _} - {synthesis.#Bind _}) + {synthesis.#Bind _} + {synthesis.#List size}) (stack) (,, (template.with [] @@ -160,7 +161,7 @@ ..references (set.of_stack name.hash) set.stack - (monad.each ! (translation.remember archive)) + (stack.each' ! (translation.remember archive)) (by ! each (set.of_stack unit.hash))))) (the .public (path_dependencies archive value) @@ -172,7 +173,7 @@ (..path_references ..references) (set.of_stack name.hash) set.stack - (monad.each ! (translation.remember archive)) + (stack.each' ! (translation.remember archive)) (by ! each (set.of_stack unit.hash))))) (the .public all 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 f10c2d8899..35c3e87129 100644 --- a/stdlib/source/library/lux/compiler/meta/cache/dependency/module.lux +++ b/stdlib/source/library/lux/compiler/meta/cache/dependency/module.lux @@ -5,7 +5,7 @@ [library [lux (.except #module #imports) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" state]] [error @@ -68,7 +68,7 @@ {try.#Failure error} ..fresh)] - ancestors (monad.each ! again (set.stack parents))] + ancestors (stack.each' ! again (set.stack parents))] (in (stack#mix set.union parents ancestors))))) ancestry (memo.open memo)] (stack#mix (function (_ module memory) @@ -98,10 +98,10 @@ (|> ancestry dictionary.keys (stack.sorted (..dependency? ancestry)) - (monad.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)]]))))))) + (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)]]))))))) diff --git a/stdlib/source/library/lux/compiler/meta/cache/module.lux b/stdlib/source/library/lux/compiler/meta/cache/module.lux index a125a8606a..88636fe37b 100644 --- a/stdlib/source/library/lux/compiler/meta/cache/module.lux +++ b/stdlib/source/library/lux/compiler/meta/cache/module.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [control ["[0]" pipe]] [error @@ -109,8 +109,8 @@ (stack#each (function (_ file) [(file.name fs file) file])) (stack.only (|>> product.left (text.= ..file) not)) - (monad.each ! (function (_ [name path]) - (|> path - (by fs read) - (by ! each (|>> [name]))))))] + (stack.each' ! (function (_ [name path]) + (|> path + (by fs read) + (by ! each (|>> [name]))))))] (in (dictionary.of_stack text.hash pairs)))) diff --git a/stdlib/source/library/lux/compiler/meta/cache/purge.lux b/stdlib/source/library/lux/compiler/meta/cache/purge.lux index 60574e5174..2a8c92f73e 100644 --- a/stdlib/source/library/lux/compiler/meta/cache/purge.lux +++ b/stdlib/source/library/lux/compiler/meta/cache/purge.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [concurrency ["[0]" future (.only Future)]] [error @@ -48,7 +48,7 @@ [.let [cache (//module.path fs @module)] _ (|> cache (by fs directory_files) - (by ! each (monad.each ! (by fs delete))) + (by ! each (stack.each' ! (by fs delete))) (by ! conjoint))] (by fs delete cache))) diff --git a/stdlib/source/library/lux/compiler/meta/export.lux b/stdlib/source/library/lux/compiler/meta/export.lux index def1668948..3d2a73605e 100644 --- a/stdlib/source/library/lux/compiler/meta/export.lux +++ b/stdlib/source/library/lux/compiler/meta/export.lux @@ -5,7 +5,7 @@ [library [lux (.except Source) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future) (.use "[1]#[0]" functor)]] [error diff --git a/stdlib/source/library/lux/compiler/meta/import.lux b/stdlib/source/library/lux/compiler/meta/import.lux index dee851337e..88e90fba10 100644 --- a/stdlib/source/library/lux/compiler/meta/import.lux +++ b/stdlib/source/library/lux/compiler/meta/import.lux @@ -5,9 +5,8 @@ [library [lux (.except Module) [abstract - ["<>" projection] - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)] + ["<>" projection]] [concurrency ["[0]" future (.only Future)]] [error @@ -19,6 +18,7 @@ ["[0]" text (.only) ["%" \\injection]] [collection + ["[0]" stack] ["[0]" dictionary (.only Dictionary)] ["[0]" sequence]] [format @@ -52,26 +52,26 @@ (|>> (by ! each (.value tar.of_binary)) (by ! conjoint) (by ! each (|>> sequence.as_stack - (monad.mix ! (function (_ entry import) - (when entry - {tar.#Normal [path instant mode ownership content]} - (let [path (tar.from_path path)] - (when (dictionary.has' path (tar.data content) import) - {try.#Failure error} - (exception.except ..duplicate [library path]) + (stack.mix' ! (function (_ entry import) + (when entry + {tar.#Normal [path instant mode ownership content]} + (let [path (tar.from_path path)] + (when (dictionary.has' path (tar.data content) import) + {try.#Failure error} + (exception.except ..duplicate [library path]) - import' - import')) - - _ - (exception.except ..useless_tar_entry []))) - import))) + import' + import')) + + _ + (exception.except ..useless_tar_entry []))) + import))) (by ! conjoint))))))) (the .public (import system libraries) (-> (file.System Future) (Stack Library) (Action Import)) - (monad.mix (is (Monad Action) - (try.with future.monad)) - (..import_library system) - (dictionary.empty text.hash) - libraries)) + (stack.mix' (is (Monad Action) + (try.with future.monad)) + (..import_library system) + (dictionary.empty text.hash) + libraries)) diff --git a/stdlib/source/library/lux/compiler/meta/io/archive.lux b/stdlib/source/library/lux/compiler/meta/io/archive.lux index 20739efd7e..f23638692e 100644 --- a/stdlib/source/library/lux/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/compiler/meta/io/archive.lux @@ -6,8 +6,7 @@ [lux (.except) [abstract ["<>" projection] - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [concurrency ["[0]" future (.only Future) (.use "[1]#[0]" monad)]] [error (.only error) @@ -84,14 +83,14 @@ (-> Target Configuration Archive (Try .Lux)) (do [! try.monad] [modules (is (Try (Stack [descriptor.Module .Module])) - (monad.each ! (function (_ module) - (do ! - [entry (archive.find module archive) - content (|> entry - (its [archive.#module module.#document]) - (document.content $.key))] - (in [module content]))) - (archive.archived archive)))] + (stack.each' ! (function (_ module) + (do ! + [entry (archive.find module archive) + content (|> entry + (its [archive.#module module.#document]) + (document.content $.key))] + (in [module content]))) + (archive.archived archive)))] (in (has .#modules modules (fresh_analysis_state host configuration))))) (every Definitions @@ -154,24 +153,24 @@ {.#Empty} {try.#Success [definitions output]}))) content (document.content $.key document) - definitions (monad.each ! (function (_ [def_name [exported? def_global]]) - (when def_global - {.#Alias payload} - (in (stack [def_name [exported? def_global]])) - - {.#Definition [type _]} - (|> definitions - (dictionary.value def_name) - (try.of_maybe ..cannot_find_definition) - (by ! each (|>> [type] - {.#Definition} - [exported?] - [def_name] - (stack)))) + definitions (stack.each' ! (function (_ [def_name [exported? def_global]]) + (when def_global + {.#Alias payload} + (in (stack [def_name [exported? def_global]])) + + {.#Definition [type _]} + (|> definitions + (dictionary.value def_name) + (try.of_maybe ..cannot_find_definition) + (by ! each (|>> [type] + {.#Definition} + [exported?] + [def_name] + (stack)))) - {.#Default [type _]} - (in (stack)))) - (its .#definitions content))] + {.#Default [type _]} + (in (stack)))) + (its .#definitions content))] (in [(document.document $.key (has .#definitions (stack#conjoint definitions) content)) output]))) @@ -229,21 +228,21 @@ [... TODO: Stop needing to wrap this expression in an unnecessary "do" expression. it (|> archive archive.reservations - (monad.each ! (..valid_cache customs fs context import contexts)))] + (stack.each' ! (..valid_cache customs fs context import contexts)))] (in it))) (the (load_order archive pre_loaded_caches) (-> Archive (Stack Cache) (Try (dependency.Order .Module))) (|> pre_loaded_caches - (monad.mix try.monad - (function (_ [_ [module @module |module| registry]] archive) - (archive.has module - [archive.#module |module| - archive.#output (is Output sequence.empty) - archive.#registry registry] - archive)) - archive) + (stack.mix' try.monad + (function (_ [_ [module @module |module| registry]] archive) + (archive.has module + [archive.#module |module| + archive.#output (is Output sequence.empty) + archive.#registry registry] + archive)) + archive) (by try.monad each (dependency.load_order $.key)) (by try.monad conjoint))) @@ -256,10 +255,10 @@ [... TODO: Stop needing to wrap this expression in an unnecessary "do" expression. it (|> load_order (stack.only (|>> product.left (dictionary.key? purge) not)) - (monad.each ! (function (_ [module_name [@module entry]]) - (do ! - [entry (..load_definitions fs context @module host_environment entry)] - (in [module_name entry])))))] + (stack.each' ! (function (_ [module_name [@module entry]]) + (do ! + [entry (..load_definitions fs context @module host_environment entry)] + (in [module_name entry])))))] (in it))) (the (load_every_reserved_module customs configuration host_environment fs context import contexts archive) @@ -272,15 +271,15 @@ .let [purge (cache/purge.purge pre_loaded_caches load_order)] _ (|> purge dictionary.entries - (monad.each ! (|>> product.right (cache/purge.purge! fs)))) + (stack.each' ! (|>> product.right (cache/purge.purge! fs)))) loaded_caches (..loaded_caches host_environment fs context purge load_order)] (future#in (do [! try.monad] - [archive (monad.mix ! - (function (_ [module entry] archive) - (archive.has module entry archive)) - archive - loaded_caches) + [archive (stack.mix' ! + (function (_ [module entry] archive) + (archive.has module entry archive)) + archive + loaded_caches) analysis_state (..analysis_state (its context.#host context) configuration archive)] (in [archive analysis_state]))))) diff --git a/stdlib/source/library/lux/compiler/meta/io/context.lux b/stdlib/source/library/lux/compiler/meta/io/context.lux index 22e5dbab6e..4c576e5770 100644 --- a/stdlib/source/library/lux/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/compiler/meta/io/context.lux @@ -5,8 +5,7 @@ [library [lux (.except Module) [abstract - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [concurrency ["[0]" future (.only Future) (.use "[1]#[0]" monad)]] [control @@ -156,17 +155,17 @@ (do [! (try.with future.monad)] [enumeration (|> directory (by fs directory_files) - (by ! each (monad.mix ! (function (_ file enumeration) - (if (text.ends_with? ..lux_extension file) - (do ! - [source_code (by fs read file)] - (future#in (dictionary.has' (text.replaced_once context "" file) source_code enumeration))) - (in enumeration))) - enumeration)) + (by ! each (stack.mix' ! (function (_ file enumeration) + (if (text.ends_with? ..lux_extension file) + (do ! + [source_code (by fs read file)] + (future#in (dictionary.has' (text.replaced_once context "" file) source_code enumeration))) + (in enumeration))) + enumeration)) (by ! conjoint))] (|> directory (by fs sub_directories) - (by ! each (monad.mix ! (context_listing fs context) enumeration)) + (by ! each (stack.mix' ! (context_listing fs context) enumeration)) (by ! conjoint)))) (the Action @@ -189,14 +188,14 @@ (Action Enumeration)) (let [! (is (Monad Action) (try.with future.monad))] - (monad.mix ! - (function (_ context enumeration) - (do ! - [context (..canonical fs context)] - (..context_listing fs - (text context (by fs delimiter)) - context - enumeration))) - (is Enumeration - (dictionary.empty text.hash)) - contexts))) + (stack.mix' ! + (function (_ context enumeration) + (do ! + [context (..canonical fs context)] + (..context_listing fs + (text context (by fs delimiter)) + context + enumeration))) + (is Enumeration + (dictionary.empty text.hash)) + contexts))) diff --git a/stdlib/source/library/lux/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/compiler/meta/packager/jvm.lux index eed64f85e5..e9eae05442 100644 --- a/stdlib/source/library/lux/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/compiler/meta/packager/jvm.lux @@ -6,7 +6,7 @@ [lux (.except Module Definition) ["[0]" ffi (.only import to)] [abstract - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [control ["[0]" maybe (.use "[1]#[0]" functor)]] [error @@ -177,13 +177,13 @@ (-> Context (Set unit.ID) [module.ID Output] java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) (let [! try.monad] - (monad.mix try.monad - (function (_ [artifact custom content] sink) - (if (set.member? necessary_dependencies [module artifact]) - (..write_class static module artifact custom content sink) - (by ! in sink))) - sink - (sequence.as_stack output)))) + (stack.mix' try.monad + (function (_ [artifact custom content] sink) + (if (set.member? necessary_dependencies [module artifact]) + (..write_class static module artifact custom content sink) + (by ! in sink))) + sink + (sequence.as_stack output)))) (the (read_jar_entry_with_unknown_size input) (-> java/util/jar/JarInputStream [Natural Binary]) @@ -281,14 +281,14 @@ sink (|> order (stack#each (function (_ [module [module_id entry]]) [module_id (its archive.#output entry)])) - (monad.mix ! (..write_module static necessary_dependencies) - (java/util/jar/JarOutputStream::new [buffer (..manifest program)]))) + (stack.mix' ! (..write_module static necessary_dependencies) + (java/util/jar/JarOutputStream::new [buffer (..manifest program)]))) [entries duplicates sink] (|> host_dependencies dictionary.values - (monad.mix ! ..write_host_dependency - [(set.empty text.hash) - (set.empty text.hash) - sink])) + (stack.mix' ! ..write_host_dependency + [(set.empty text.hash) + (set.empty text.hash) + sink])) .let [_ (to sink (java/io/Flushable::flush []) (java/io/Closeable::close []))]] diff --git a/stdlib/source/library/lux/compiler/meta/packager/ruby.lux b/stdlib/source/library/lux/compiler/meta/packager/ruby.lux index 0c353ebc6b..7f0cb7ad5c 100644 --- a/stdlib/source/library/lux/compiler/meta/packager/ruby.lux +++ b/stdlib/source/library/lux/compiler/meta/packager/ruby.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try (.only Try)]] [data @@ -60,20 +60,20 @@ artifacts (do ! - [bundle (monad.mix ! - (function (_ [artifact custom_name content] so_far) - (|> content - (by utf8.binary of) - (by ! each - (|>> as_expected - (is declaration) - (sharing [declaration] - (is declaration - so_far)) - (_.then so_far))))) - (_.comment "Lux module" - (_.; (_.string ""))) - artifacts)] + [bundle (stack.mix' ! + (function (_ [artifact custom_name content] so_far) + (|> content + (by utf8.binary of) + (by ! each + (|>> as_expected + (is declaration) + (sharing [declaration] + (is declaration + so_far)) + (_.then so_far))))) + (_.comment "Lux module" + (_.; (_.string ""))) + artifacts)] (in {.#Some bundle}))))) (the module_file @@ -122,7 +122,7 @@ (do [! try.monad] [.let [necessary_dependencies (cache/artifact.necessary_dependencies archive)] order (cache/module.load_order $.key archive) - entries (monad.mix ! (..write_module (module_id_mapping order) necessary_dependencies) {.#Empty} order) + entries (stack.mix' ! (..write_module (module_id_mapping order) necessary_dependencies) {.#Empty} order) .let [included_modules (..included_modules entries) imports (|> order (stack.only (|>> product.right product.left (set.member? included_modules))) diff --git a/stdlib/source/library/lux/compiler/meta/packager/script.lux b/stdlib/source/library/lux/compiler/meta/packager/script.lux index 2297e0c77f..cce040338f 100644 --- a/stdlib/source/library/lux/compiler/meta/packager/script.lux +++ b/stdlib/source/library/lux/compiler/meta/packager/script.lux @@ -5,8 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [error ["[0]" try (.only Try)]] [data @@ -47,18 +46,18 @@ (if (set.member? necessary_dependencies [module_id artifact_id]) {.#Some content} {.#None}))) - (monad.mix try.monad - (function (_ content so_far) - (|> content - (by utf8.binary of) - (by try.monad each - (|>> as_expected - (is declaration) - (sharing [declaration] - (is declaration - so_far)) - (sequence so_far))))) - so_far))) + (stack.mix' try.monad + (function (_ content so_far) + (|> content + (by utf8.binary of) + (by try.monad each + (|>> as_expected + (is declaration) + (sharing [declaration] + (is declaration + so_far)) + (sequence so_far))))) + so_far))) (the .public (package header code sequence scope) (for_any (_ declaration) @@ -74,7 +73,7 @@ (|> order (stack#each (function (_ [module [module_id entry]]) [module_id (its archive.#output entry)])) - (monad.mix ! (..write_module necessary_dependencies sequence) header) + (stack.mix' ! (..write_module necessary_dependencies sequence) header) (by ! each (|>> scope code (by utf8.binary as) diff --git a/stdlib/source/library/lux/concurrency/event.lux b/stdlib/source/library/lux/concurrency/event.lux index 1c15eaecc1..8fc06d3ab1 100644 --- a/stdlib/source/library/lux/concurrency/event.lux +++ b/stdlib/source/library/lux/concurrency/event.lux @@ -6,7 +6,7 @@ [library [lux (.except loop) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" io (.only IO)]] [error @@ -105,7 +105,7 @@ swapped? (atom.compare_and_swap! started?,events [started? pending] state)] (if swapped? (do [! (try.with !)] - [_ (monad.each ! (|>> (its #what) (..execute! name) io.io) ready)] + [_ (stack.each' ! (|>> (its #what) (..execute! name) io.io) ready)] (again (n.+ (stack.size ready) events_processed))) (again events_processed)))))) (retry! [])))))))])) diff --git a/stdlib/source/library/lux/concurrency/frp.lux b/stdlib/source/library/lux/concurrency/frp.lux index d01f2fe6bc..69b5bc5685 100644 --- a/stdlib/source/library/lux/concurrency/frp.lux +++ b/stdlib/source/library/lux/concurrency/frp.lux @@ -7,7 +7,7 @@ [abstract [equivalence (.only Equivalence)] [functor (.only Functor)] - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [control ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" io (.only IO io)]] diff --git a/stdlib/source/library/lux/concurrency/future.lux b/stdlib/source/library/lux/concurrency/future.lux index 585029405e..c9e1151fb3 100644 --- a/stdlib/source/library/lux/concurrency/future.lux +++ b/stdlib/source/library/lux/concurrency/future.lux @@ -6,14 +6,16 @@ [lux (.except and or) [abstract [functor (.only Functor)] - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [control ["[0]" pipe] ["[0]" io (.only IO io)] ["[0]" maybe (.use "[1]#[0]" functor)]] ["[0]" function] [data - ["[0]" product]] + ["[0]" product] + [collection + ["[0]" stack]]] [macro ["^" pattern] ["[0]" expansion] @@ -60,8 +62,8 @@ [succeeded? (atom.compare_and_swap! old [{.#Some (variance.write value)} (stack)] future)] (if succeeded? (do ! - [_ (monad.each ! (function.on (variance.write value)) - _observers)] + [_ (stack.each' ! (function.on (variance.write value)) + _observers)] (in true)) (resolve value)))))))) diff --git a/stdlib/source/library/lux/concurrency/incremental.lux b/stdlib/source/library/lux/concurrency/incremental.lux index 42b4bf9884..b4685460c4 100644 --- a/stdlib/source/library/lux/concurrency/incremental.lux +++ b/stdlib/source/library/lux/concurrency/incremental.lux @@ -6,7 +6,7 @@ [lux (.except or and) [abstract [functor (.only Functor)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" io (.only IO) (.use "[1]#[0]" functor)]] ["[0]" function] @@ -145,7 +145,7 @@ ? (atom.compare_and_swap! old [value dependencies] it')] (if ? (do ! - [_ (monad.each ! (function.on value) dependencies)] + [_ (stack.each' ! (function.on value) dependencies)] (in [])) (mutate! value it)))) ) diff --git a/stdlib/source/library/lux/concurrency/stm.lux b/stdlib/source/library/lux/concurrency/stm.lux index a1e7b8a8ac..97b53d2afa 100644 --- a/stdlib/source/library/lux/concurrency/stm.lux +++ b/stdlib/source/library/lux/concurrency/stm.lux @@ -6,7 +6,7 @@ [lux (.except) [abstract [functor (.only Functor)] - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [control ["[0]" io (.only IO io)] ["[0]" maybe] @@ -67,16 +67,16 @@ succeeded? (atom.compare_and_swap! old [(variance.write new_value) observers] var')] (if succeeded? (do ! - [banned (monad.only ! (function (_ sink) - (do ! - [result (by sink feed (variance.write new_value))] - (in (when result - {try.#Success _} - false - - {try.#Failure _} - true)))) - observers) + [banned (stack.only' ! (function (_ sink) + (do ! + [result (by sink feed (variance.write new_value))] + (in (when result + {try.#Success _} + false + + {try.#Failure _} + true)))) + observers) _ (atom.update! (function (_ [value audience]) (|> audience (stack.only (function (_ it) @@ -266,7 +266,7 @@ [finished_tx value] (stm_proc fresh_tx)] (if (can_commit? finished_tx) (do [! io.monad] - [_ (monad.each ! ..commit_var! finished_tx)] + [_ (stack.each' ! ..commit_var! finished_tx)] (resolve value)) (..issue_commit! commit)))) diff --git a/stdlib/source/library/lux/concurrency/structured.lux b/stdlib/source/library/lux/concurrency/structured.lux index 32e8361558..0885fa8f35 100644 --- a/stdlib/source/library/lux/concurrency/structured.lux +++ b/stdlib/source/library/lux/concurrency/structured.lux @@ -7,13 +7,13 @@ or and) [abstract [functor (.only Functor)] - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [control ["[0]" maybe (.use "[1]#[0]" monad)] ["[0]" io (.only IO) (.use "[1]#[0]" monad)]] [data [collection + ["[0]" stack] ["[0]" dictionary (.only Dictionary)]]] [math [number @@ -250,7 +250,7 @@ close! (do [! io.monad] [... Cancel all pending tasks. [next pending] (atom.read! pending) - _ (monad.each ! cancel! (dictionary.values pending))] + _ (stack.each' ! cancel! (dictionary.values pending))] (resolve! {.#None})) scope (<| (nominal.abstraction Scope) [#pending pending diff --git a/stdlib/source/library/lux/concurrency/thread.lux b/stdlib/source/library/lux/concurrency/thread.lux index 47c6b4f42a..091fd82d8e 100644 --- a/stdlib/source/library/lux/concurrency/thread.lux +++ b/stdlib/source/library/lux/concurrency/thread.lux @@ -7,7 +7,7 @@ ["[0]" ffi] ["[0]" debug] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" io (.only IO io)]] [error diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index b79afd91b4..aa421a87c9 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -83,7 +83,9 @@ (syntax.macro (_ [arity (<>.only (n.> 0) .natural)]) (with_names ['_ 'func 'stack 'output] (monad.do [! meta.monad] - ['inputs (|> (macro.name "input") (stack.repeated arity) (monad.all !))] + ['inputs (|> (macro.name "input") + (stack.repeated arity) + (stack.all' !))] (in (.stack (` (is (for_any ((, '_) (,* 'inputs) (, 'output)) (-> (-> (,* 'inputs) (, 'output)) (=> [(,* 'inputs)] [(, 'output)]))) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 80d1505bad..e9791aaa2f 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -8,8 +8,8 @@ [monoid (.only Monoid)] [equivalence (.only Equivalence)] [hash (.only Hash)] - ["[0]" functor (.only Functor)] - ["[0]" monad (.only Monad do)]]]]) + [functor (.only Functor)] + [monad (.only Monad do)]]]]) (the template#macro (.in_module# .prelude .template#macro)) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index c48714d203..e25ef558db 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -17,7 +17,8 @@ ["[0]" stack (.use "[1]#[0]" mix)]]]]]) (every (Cleaner r !) - (-> r (! (Try Any)))) + (-> r + (! (Try Any)))) (every .public (Region r ! a) (-> [r (Stack (Cleaner r !))] @@ -59,7 +60,7 @@ (do [! monad] [[cleaners output] (computation [[] (stack)])] (|> cleaners - (monad.each ! (function (_ cleaner) (cleaner []))) + (stack.each' ! (function (_ cleaner) (cleaner []))) (by ! each (stack#mix clean output))))) (the .public (acquire! monad cleaner value) diff --git a/stdlib/source/library/lux/control/scope.lux b/stdlib/source/library/lux/control/scope.lux index 0533f7eebb..9b5b115e42 100644 --- a/stdlib/source/library/lux/control/scope.lux +++ b/stdlib/source/library/lux/control/scope.lux @@ -6,8 +6,8 @@ [lux (.except Scope local with) [abstract - ["[0]" functor (.only Functor)] - ["[0]" monad (.only Monad do)]]]]) + [functor (.only Functor)] + [monad (.only Monad do)]]]]) ... https://en.wikipedia.org/wiki/Scope_(computer_science) (every .public (Scope context it) diff --git a/stdlib/source/library/lux/control/scope/dynamic.lux b/stdlib/source/library/lux/control/scope/dynamic.lux index ef783497ed..f87d6bfa6f 100644 --- a/stdlib/source/library/lux/control/scope/dynamic.lux +++ b/stdlib/source/library/lux/control/scope/dynamic.lux @@ -7,8 +7,8 @@ let the) ["[0]" debug] [abstract - ["?" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection]] [control [scope (.only Scope)] ["[0]" maybe]] @@ -78,11 +78,11 @@ (syntax.macro (_ [bindings (?code.tuple (?.some (?.and ?code.name ?code.any))) term ?code.any]) (do [! meta.monad] - [bindings (monad.each ! (function (_ [name value]) - (do ! - [name (binding.normal name)] - (in [name value]))) - bindings)] + [bindings (stack.each' ! (function (_ [name value]) + (do ! + [name (binding.normal name)] + (in [name value]))) + bindings)] (in (stack (stack#mix (function (_ [name value] term) (.let ['name (code.name name)] (` ((debug.private ..let') diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index c285ce1825..3f5a78c8b9 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -6,8 +6,8 @@ [lux (.except with) [abstract [monoid (.only Monoid)] - ["[0]" functor (.only Functor)] - ["[0]" monad (.only Monad do)]]]]) + [functor (.only Functor)] + [monad (.only Monad do)]]]]) (every .public (Writer trace value) (Record diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 5510dd7c7a..c6a8ff51de 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) + [lux (.except type) [abstract [equivalence (.only Equivalence)] [hash (.only Hash)] @@ -14,15 +14,25 @@ [mix (.only Mix)]] [error (.only error) ["[0]" try (.only Try)]] + [data + ["[0]" text]] [function [predicate (.only Predicate)]] [math [number - ["n" natural]]]]] + ["n" natural]]] + [meta + ["[0]" name]] + [compiler + ["[0]" extension + ["[1]" lux]]]]] [// [array ["/" \\unsafe]]]) +(the .public type + "#List") + (the with_template' (.in_module# .prelude .with_template)) (the template#macro (.in_module# .prelude .template#macro)) @@ -209,3 +219,82 @@ (/.has! index index it) (next (++ index))) it))))) + +(the .public (all' (open "/#[0]") it) + (for_any (_ ! it) + (-> (Monad !) (List (! it)) + (! (List it)))) + (let [it (..reification it) + limit (/.size it) + value (/.empty limit)] + (loop (next [position 0]) + (if (n.< limit position) + (|> it + (/.item position) + (/#each (function (_ item) + (exec + (/.has! position item value) + (next (++ position))))) + /#conjoint) + (/#in (..abstraction value)))))) + +(the .public (each' (open "/#[0]") on it) + (for_any (_ ! before after) + (-> (Monad !) (-> before (! after)) (List before) + (! (List after)))) + (let [it (..reification it) + limit (/.size it) + value (/.empty limit)] + (loop (next [position 0]) + (if (n.< limit position) + (|> it + (/.item position) + on + (/#each (function (_ item) + (exec + (/.has! position item value) + (next (++ position))))) + /#conjoint) + (/#in (..abstraction value)))))) + +(the .public (mix' (open "/#[0]") on initial_state it) + (for_any (_ ! it state) + (-> (Monad !) (-> it state (! state)) state (List it) + (! state))) + (let [it (..reification it) + limit (/.size it)] + (loop (next [position 0 + state initial_state]) + (if (n.< limit position) + (|> (on (/.item position it) state) + (/#each (next (++ position))) + /#conjoint) + (/#in state))))) + +(the .public (repeated amount it) + (for_any (_ it) + (-> Natural it + (List it))) + (let [value (/.empty amount)] + (loop (next [position 0]) + (if (n.< amount position) + (exec + (/.has! position it value) + (next (++ position))) + (..abstraction value))))) + +(the prefix + (text "(" (by (name.relative "") as [.prelude extension.list]))) + +(the suffix + ")") + +(the .public (as_text as_text it) + (for_any (_ it) + (-> (text.Injection it) + (text.Injection (List it)))) + (|> (mix (function (_ item it) + (text it " " (as_text item))) + "" + it) + (text.enclosed [..prefix ..suffix]))) diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 4887310a9c..f05c1a3e91 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -145,7 +145,7 @@ (let [(^.let set [hash _]) (nominal.reification set)] (|> set dictionary.keys - (//.it_stack hash)))) + (//.of_stack hash)))) (the .public equivalence (for_any (_ it) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index b2d7cdf19e..d3afe0053a 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -642,6 +642,71 @@ (Stack it))) (by ..monad conjoint)) +(the .public (all' monad) + (for_any (_ ! it) + (-> (Monad !) (Stack (! it)) + (! (Stack it)))) + (let [(open "/#[0]") monad] + (function (again xs) + (.when xs + {.#Empty} + (/#in {.#Empty}) + + {.#Top x xs'} + (|> x + (/#each (function (_ _x) + (/#each (|>> {.#Top _x}) (again xs')))) + /#conjoint))))) + +(the .public (each' monad f) + (for_any (_ ! before after) + (-> (Monad !) (-> before (! after)) (Stack before) + (! (Stack after)))) + (let [(open "/#[0]") monad] + (function (again xs) + (.when xs + {.#Empty} + (/#in {.#Empty}) + + {.#Top x xs'} + (|> (f x) + (/#each (function (_ _x) + (/#each (|>> {.#Top _x}) (again xs')))) + /#conjoint))))) + +(the .public (only' monad f) + (for_any (_ ! it) + (-> (Monad !) (-> it (! Bit)) (Stack it) + (! (Stack it)))) + (let [(open "/#[0]") monad] + (function (again xs) + (.when xs + {.#Empty} + (/#in {.#Empty}) + + {.#Top head xs'} + (|> (f head) + (/#each (function (_ verdict) + (/#each (function (_ tail) + (if verdict + {.#Top head tail} + tail)) + (again xs')))) + /#conjoint))))) + +(the .public (mix' monad f init xs) + (for_any (_ ! part whole) + (-> (Monad !) (-> part whole (! whole)) whole (Stack part) + (! whole))) + (.when xs + {.#Empty} + (by monad in init) + + {.#Top x xs} + (do monad + [init (f x init)] + (mix' monad f init xs)))) + (the .public (with monad) (for_any (_ !) (-> (Monad !) @@ -653,12 +718,13 @@ ..functor)) (the in - (|>> (by ..monad in) (by monad in))) + (|>> (by ..monad in) + (by monad in))) (the (conjoint MlMla) (do [! monad] [lMla MlMla - lla (monad.all ! lMla)] + lla (..all' ! lMla)] (in (..together lla)))))) (the .public (lifted monad) diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index 5b45e28091..377884c5db 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -9,8 +9,8 @@ [abstract [equivalence (.only Equivalence)] [format (.only Format)] - ["<>" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection (.use "[1]#[0]" monad)]] [control ["[0]" pipe] ["[0]" maybe]] @@ -639,7 +639,7 @@ (the (of it) (when it {#Array it} - (monad.each try.monad (with item of) it) + (stack.each' try.monad (with item of) it) _ (exception.except ..cannot_project [it]))))) @@ -657,10 +657,10 @@ {#Object it} (|> it dictionary.entries - (monad.each try.monad (function (_ [key it]) - (do try.monad - [it (with value (of it))] - (in [key it])))) + (stack.each' try.monad (function (_ [key it]) + (do try.monad + [it (with value (of it))] + (in [key it])))) (try#each (dictionary.of_stack text.hash))) _ diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index b0994a9fb0..5d6e9c66e4 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -7,7 +7,7 @@ text private also i64 variant tuple) ["[0]" ffi (.only import)] [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["<>" projection]] [control ["[0]" pipe] @@ -638,11 +638,11 @@ in) _ - (monad.each ! (function (_ [name injection]) - (if (dictionary.key? environment name) - (in [name injection]) - (function.constant (exception.except ..unknown_local_binding [name])))) - targets)))] + (stack.each' ! (function (_ [name injection]) + (if (dictionary.key? environment name) + (in [name injection]) + (function.constant (exception.except ..unknown_local_binding [name])))) + targets)))] (in (stack (` (..log! (.text_composite# (, (code.text (.text (provenance.as_text provenance) \n))) (exception.report diff --git a/stdlib/source/library/lux/error/exception.lux b/stdlib/source/library/lux/error/exception.lux index ca0035ab8f..2ca5db293e 100644 --- a/stdlib/source/library/lux/error/exception.lux +++ b/stdlib/source/library/lux/error/exception.lux @@ -39,8 +39,8 @@ (text.starts_with? (its #label exception) error)) (.the .public (failure? exception it) - (for_any (_ it it) - (-> (Exception it) (Try it) + (for_any (_ exception it) + (-> (Exception exception) (Try it) Bit)) (.when it {//.#Failure error} @@ -50,8 +50,8 @@ false)) (.the .public (when exception then try) - (for_any (_ it it) - (-> (Exception it) (-> Text it) (Try it) + (for_any (_ exception it) + (-> (Exception exception) (-> Text it) (Try it) (Try it))) (.when try {//.#Failure error} @@ -84,8 +84,8 @@ ((its ..#constructor exception) message)) (.the .public (except exception message) - (for_any (_ signal it) - (-> (Exception signal) signal + (for_any (_ exception it) + (-> (Exception exception) exception (Try it))) {//.#Failure (..error exception message)}) @@ -189,8 +189,8 @@ error)) (.the .public (with exception message computation) - (for_any (_ signal it) - (-> (Exception signal) signal (Try it) + (for_any (_ exception it) + (-> (Exception exception) exception (Try it) (Try it))) (.when computation {//.#Failure error} diff --git a/stdlib/source/library/lux/error/try.lux b/stdlib/source/library/lux/error/try.lux index bf5521739f..199f51b81f 100644 --- a/stdlib/source/library/lux/error/try.lux +++ b/stdlib/source/library/lux/error/try.lux @@ -6,9 +6,8 @@ [lux (.except with when or as) [abstract [equivalence (.only Equivalence)] - ["[0]" functor (.only Functor)] - ["[0]" monad (.only Monad - do)]] + [functor (.only Functor)] + [monad (.only Monad do)]] [function [predicate (.only Predicate)]]]]) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index bffb76afe4..07de46d05f 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -6,8 +6,8 @@ [lux (.except Type Declaration Integer Double is as type) [abstract - ["?" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection (.use "[1]#[0]" monad)]] [control ["[0]" io] ["[0]" maybe]] @@ -1379,7 +1379,7 @@ fields (?.some (..field_decl^ class_vars)) methods (?.some (..method_def^ class_vars))]) (do meta.monad - [methods (monad.each ! (method_def$ full_class_name class_vars super fields methods) methods)] + [methods (stack.each' ! (method_def$ full_class_name class_vars super fields methods) methods)] (in (stack (` (.jvm_class# (, (declaration$ (jvm.declaration class_vars full_class_name))) (, (class$ super)) [(,* (stack#each class$ interfaces))] @@ -1409,7 +1409,7 @@ constructor_args (..constructor_args^ class_vars) methods (?.some ..overriden_method_def^)]) (do [! meta.monad] - [methods (monad.each ! (method_def$ "" (stack) super (stack) methods) methods)] + [methods (stack.each' ! (method_def$ "" (stack) super (stack) methods) methods)] (in (stack (` (.jvm_class_anonymous# [(,* (stack#each var$ class_vars))] (, (class$ super)) [(,* (stack#each class$ interfaces))] @@ -1514,12 +1514,12 @@ (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) (let [(open "[0]") commons] (do [! meta.monad] - [arg_inputs (monad.each ! - (.is (-> [Bit (Type Value)] (Meta [Bit Code])) - (function (_ [maybe? _]) - (with_names [arg_name] - (in [maybe? arg_name])))) - #import_member_args) + [arg_inputs (stack.each' ! + (.is (-> [Bit (Type Value)] (Meta [Bit Code])) + (function (_ [maybe? _]) + (with_names [arg_name] + (in [maybe? arg_name])))) + #import_member_args) .let [input_jvm_types (stack#each product.right #import_member_args) arg_types (stack#each (.is (-> [Bit (Type Value)] Code) (function (_ [maybe? arg]) @@ -1875,7 +1875,7 @@ [kind (class_kind declaration) =members (|> members (stack#each (|>> [import_format])) - (monad.each ! (member_import$ class_type_vars kind declaration)))] + (stack.each' ! (member_import$ class_type_vars kind declaration)))] (in (stack.partial (class_import$ declaration) (stack#conjoint =members)))))) (exception.the .public (cannot_convert_to_jvm_type type) @@ -1948,17 +1948,17 @@ ... else (by meta.monad each (function (_ parameters) (jvm.class parameters name)) (.is (Meta (Stack (Type Parameter))) - (monad.each meta.monad - (function (_ paramLT) - (do meta.monad - [paramJT (lux_type->jvm_type context paramLT)] - (when (projection.parameter? paramJT) - {.#Some paramJT} - (in paramJT) - - {.#None} - ))) - params))))) + (stack.each' meta.monad + (function (_ paramLT) + (do meta.monad + [paramJT (lux_type->jvm_type context paramLT)] + (when (projection.parameter? paramJT) + {.#Some paramJT} + (in paramJT) + + {.#None} + ))) + params))))) {.#Reification A F} (when (type.applied (stack A) F) diff --git a/stdlib/source/library/lux/ffi.lux b/stdlib/source/library/lux/ffi.lux index 9aaec80e09..00e3952e91 100644 --- a/stdlib/source/library/lux/ffi.lux +++ b/stdlib/source/library/lux/ffi.lux @@ -6,8 +6,8 @@ [lux (.except Alias Global Declaration Pattern Integer global function type_of undefined alias) [abstract - ["<>" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection (.use "[1]#[0]" monad)]] [control ["[0]" io] ["[0]" maybe (.use "[1]#[0]" functor)]] @@ -266,23 +266,23 @@ (is (-> archive Synthesis~ state (Try [state js.Expression])) (as_expected phase)))] - [state output] (monad.mix ! - (sharing [state] - (is state - state) - (is (-> [Synthesis~ Synthesis~] [state (Stack [Text js.Expression])] - (Try [state (Stack [Text js.Expression])])) - (.function (_ [key value] [state output]) - (when key - (text_synthesis @ key) - (do try.monad - [[state value] (phase archive value state)] - (in [state (stack.partial [key value] output)])) - - _ - (.undefined))))) - [state (stack)] - (pairs it))] + [state output] (stack.mix' ! + (sharing [state] + (is state + state) + (is (-> [Synthesis~ Synthesis~] [state (Stack [Text js.Expression])] + (Try [state (Stack [Text js.Expression])])) + (.function (_ [key value] [state output]) + (when key + (text_synthesis @ key) + (do try.monad + [[state value] (phase archive value state)] + (in [state (stack.partial [key value] output)])) + + _ + (.undefined))))) + [state (stack)] + (pairs it))] (in [state (js.object (stack.reversed output))]))) (analysis object|analysis @@ -296,12 +296,12 @@ (is (-> archive Code state (Try [state Analysis~])) (as_expected phase)))] - [state output] (monad.mix ! (.function (_ [key value] [state output]) - (do ! - [[state value] (phase archive (` (.is .Any (, value))) state)] - (in [state (stack.partial value (text_analysis key) output)]))) - [state (stack)] - it)] + [state output] (stack.mix' ! (.function (_ [key value] [state output]) + (do ! + [[state value] (phase archive (` (.is .Any (, value))) state)] + (in [state (stack.partial value (text_analysis key) output)]))) + [state (stack)] + it)] (in [state (extension_analysis (name ..object|translation) (stack.reversed output))]))) diff --git a/stdlib/source/library/lux/ffi/export.js.lux b/stdlib/source/library/lux/ffi/export.js.lux index 157de9e6e4..f019b180ab 100644 --- a/stdlib/source/library/lux/ffi/export.js.lux +++ b/stdlib/source/library/lux/ffi/export.js.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [text ["%" \\injection]] @@ -87,9 +87,9 @@ (syntax.macro (_ [exports (<>.many .any)]) (let [! meta.monad] (|> exports - (monad.each ! expansion.complete) + (stack.each' ! expansion.complete) (by ! each (|>> stack#conjoint - (monad.each ! ..definition))) + (stack.each' ! ..definition))) (by ! conjoint) (by ! each (stack#each (function (_ [name term]) (` (..export_one (, (code.text name)) (, term)))))))))) diff --git a/stdlib/source/library/lux/ffi/export.lua.lux b/stdlib/source/library/lux/ffi/export.lua.lux index 7a48d5216b..da84d82562 100644 --- a/stdlib/source/library/lux/ffi/export.lua.lux +++ b/stdlib/source/library/lux/ffi/export.lua.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [text ["%" \\injection]] @@ -103,9 +103,9 @@ (syntax.macro (_ [exports (<>.many .any)]) (let [! meta.monad] (|> exports - (monad.each ! expansion.complete) + (stack.each' ! expansion.complete) (by ! each (|>> stack#conjoint - (monad.each ! ..definition))) + (stack.each' ! ..definition))) (by ! conjoint) (by ! each (stack#each (function (_ [name term]) (` (export_one (, (code.text name)) (, term)))))))))) diff --git a/stdlib/source/library/lux/ffi/export.py.lux b/stdlib/source/library/lux/ffi/export.py.lux index 37f94a09fa..19af0e9b63 100644 --- a/stdlib/source/library/lux/ffi/export.py.lux +++ b/stdlib/source/library/lux/ffi/export.py.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [text ["%" \\injection]] @@ -81,9 +81,9 @@ (syntax.macro (_ [exports (<>.many .any)]) (let [! meta.monad] (|> exports - (monad.each ! expansion.complete) + (stack.each' ! expansion.complete) (by ! each (|>> stack#conjoint - (monad.each ! ..definition))) + (stack.each' ! ..definition))) (by ! conjoint) (by ! each (stack#each (function (_ [name term]) (` (..export_one (, (code.text name)) (, term)))))))))) diff --git a/stdlib/source/library/lux/ffi/export.rb.lux b/stdlib/source/library/lux/ffi/export.rb.lux index b07c4389f6..45324fa2e5 100644 --- a/stdlib/source/library/lux/ffi/export.rb.lux +++ b/stdlib/source/library/lux/ffi/export.rb.lux @@ -6,8 +6,8 @@ [lux (.except global Name name) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data ["[0]" text ["%" \\injection] @@ -131,9 +131,9 @@ (syntax.macro (_ [exports (<>.many .any)]) (let [! meta.monad] (|> exports - (monad.each ! expansion.complete) + (stack.each' ! expansion.complete) (by ! each (|>> stack#conjoint - (monad.each ! ..definition))) + (stack.each' ! ..definition))) (by ! conjoint) (by ! each (stack#each (function (_ [name term]) (` (export_one (,* (when name diff --git a/stdlib/source/library/lux/function/inline.lux b/stdlib/source/library/lux/function/inline.lux index 84464417a4..64eac353eb 100644 --- a/stdlib/source/library/lux/function/inline.lux +++ b/stdlib/source/library/lux/function/inline.lux @@ -6,8 +6,8 @@ [lux (.except Declaration macro) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [data [collection ["[0]" stack (.use "[1]#[0]" monad)]]] @@ -40,7 +40,7 @@ [[@ _] module.current 'parameters (|> (macro.name "parameter") (stack.repeated (stack.size parameters)) - (monad.all !)) + (stack.all' !)) .let [inlined (` ((.in_module# (, (code.text @)) (.is (, type) diff --git a/stdlib/source/library/lux/function/mutual.lux b/stdlib/source/library/lux/function/mutual.lux index f0661a78d2..7a7cb0bb47 100644 --- a/stdlib/source/library/lux/function/mutual.lux +++ b/stdlib/source/library/lux/function/mutual.lux @@ -6,8 +6,8 @@ [lux (.except Definition Declaration let macro the) [abstract - ["<>" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection (.use "[1]#[0]" monad)]] [error ["[0]" try (.only Try)]] [data @@ -70,8 +70,8 @@ (macro.with_names ['context 'output] (do [! meta.monad] [[here_name _] module.current - hidden_names (monad.each ! (//.constant (macro.name "mutual_function#")) - functions) + hidden_names (stack.each' ! (//.constant (macro.name "mutual_function#")) + functions) .let [definitions (stack#each (..mutual_definition hidden_names 'context) (stack.zipped_2 hidden_names functions)) @@ -123,8 +123,8 @@ (macro.with_names ['context 'output] (do [! meta.monad] [[here_name _] module.current - hidden_names (monad.each ! (//.constant (macro.name "mutual_function#")) - functions) + hidden_names (stack.each' ! (//.constant (macro.name "mutual_function#")) + functions) .let [definitions (stack#each (..mutual_definition hidden_names 'context) (stack.zipped_2 hidden_names (stack#each (its #mutual) functions))) diff --git a/stdlib/source/library/lux/function/named.lux b/stdlib/source/library/lux/function/named.lux index 99dcd15294..89457b79db 100644 --- a/stdlib/source/library/lux/function/named.lux +++ b/stdlib/source/library/lux/function/named.lux @@ -6,8 +6,8 @@ [library [lux (.except the) [abstract - ["?" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection]] [error ["[0]" try] ["[0]" exception (.only Exception)]] @@ -66,10 +66,10 @@ (let [(, 'parameters) (dictionary.of_stack text.hash (, 'parameters))] (when (dictionary.size (, 'parameters)) (, (code.natural (stack.size parameters))) - (when (monad.each try.monad - (function ((, '_) (, 'it)) - (dictionary.value (, 'it) (, 'parameters))) - (stack (,* (stack#each code.text parameters)))) + (when (stack.each' try.monad + (function ((, '_) (, 'it)) + (dictionary.value (, 'it) (, 'parameters))) + (stack (,* (stack#each code.text parameters)))) {try.#Success (, 'parameters)} (by meta.monad (,' in) (stack (` ((, 'function) ((,' .,*) (, 'parameters)))))) diff --git a/stdlib/source/library/lux/function/polymorphism/subject.lux b/stdlib/source/library/lux/function/polymorphism/subject.lux index 8bbfd854dc..1af68d5738 100644 --- a/stdlib/source/library/lux/function/polymorphism/subject.lux +++ b/stdlib/source/library/lux/function/polymorphism/subject.lux @@ -7,8 +7,8 @@ let the) ["[0]" debug] [abstract - ["?" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection]] [control ["[0]" scope (.only Scope)] ["[0]" maybe (.use "[1]#[0]" functor)]] @@ -87,11 +87,11 @@ (syntax.macro (_ [bindings (?code.tuple (?.some (?.and ?code.name ?code.any))) term ?code.any]) (do [! meta.monad] - [bindings (monad.each ! (function (_ [name value]) - (do ! - [name (binding.normal name)] - (in [name value]))) - bindings)] + [bindings (stack.each' ! (function (_ [name value]) + (do ! + [name (binding.normal name)] + (in [name value]))) + bindings)] (in (stack (stack#mix (function (_ [name value] term) (.let ['name (code.name name)] (` ((debug.private ..let') diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index c0ff0345e9..07ebe9e584 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -5,7 +5,7 @@ [library [lux (.except local name function macro) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" text] [collection @@ -44,7 +44,7 @@ (when tokens (stack [_ {.#Tuple names}] body) (do [! meta.monad] - [name_names (monad.each ! ..local names) + [name_names (stack.each' ! ..local names) .let [name_defs (stack#conjoint (stack#each (is (-> Text (Stack Code)) (.function (_ name) (stack (code.name ["" name]) @@ -70,7 +70,7 @@ _ (do [! meta.monad] [after (|> before - (monad.each ! /expansion.single) + (stack.each' ! /expansion.single) (by ! each stack#conjoint))] (again (-- times) after)))) @@ -81,7 +81,7 @@ (.macro (_ it) (let [! meta.monad] (|> it - (monad.each ! /expansion.complete) + (stack.each' ! /expansion.complete) (by ! each stack#conjoint))))) (the .public function diff --git a/stdlib/source/library/lux/macro/expansion.lux b/stdlib/source/library/lux/macro/expansion.lux index b990d58641..d66877c98e 100644 --- a/stdlib/source/library/lux/macro/expansion.lux +++ b/stdlib/source/library/lux/macro/expansion.lux @@ -5,7 +5,7 @@ [library [lux (.except local name function let) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] [data @@ -49,7 +49,7 @@ (do [! meta.monad] [top_level_complete ((as Macro' macro) args)] (|> top_level_complete - (monad.each meta.monad complete) + (stack.each' meta.monad complete) (by ! each stack#conjoint))) {try.#Failure _} @@ -69,28 +69,28 @@ {try.#Success macro} (do meta.monad [complete ((as Macro' macro) args) - complete' (monad.each meta.monad total complete)] + complete' (stack.each' meta.monad total complete)] (in (stack#conjoint complete'))) {try.#Failure _} (do meta.monad - [parts' (monad.each meta.monad total (stack.partial (code.name name) args))] + [parts' (stack.each' meta.monad total (stack.partial (code.name name) args))] (in (stack (code.form (stack#conjoint parts'))))))) [_ {.#Form {.#Top [harg targs]}}] (do meta.monad [harg+ (total harg) - targs+ (monad.each meta.monad total targs)] + targs+ (stack.each' meta.monad total targs)] (in (stack (code.form (stack#composite harg+ (stack#conjoint (is (Stack (Stack Code)) targs+))))))) [_ {.#Variant members}] (do meta.monad - [members' (monad.each meta.monad total members)] + [members' (stack.each' meta.monad total members)] (in (stack (code.variant (stack#conjoint members'))))) [_ {.#Tuple members}] (do meta.monad - [members' (monad.each meta.monad total members)] + [members' (stack.each' meta.monad total members)] (in (stack (code.tuple (stack#conjoint members'))))) _ diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index 1fe1e927f0..bffd6b2f31 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -5,8 +5,8 @@ [library [lux (.except with let) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [error ["[0]" try (.only Try)] ["[0]" exception (.only Exception)]] @@ -107,7 +107,7 @@ (//.macro (function (_ _) (do [! meta.monad] - [_ (monad.each ! ..pop_one macros) + [_ (stack.each' ! ..pop_one macros) _ (..pop_one self) compiler meta.compiler_state] (in (when (its .#expected compiler) @@ -121,7 +121,7 @@ (-> (Stack [Name Macro]) (Meta Code)) (do meta.monad - [_ (monad.each meta.monad ..push_one macros) + [_ (stack.each' meta.monad ..push_one macros) seed meta.seed 'pop (//.name "pop") _ (.let ['pop (is Name @@ -148,12 +148,12 @@ body .any]) (do [! meta.monad] [[here _] module.current - locals (monad.each ! (function (_ [name value]) - (|> value - (meta.eval .Macro) - (by ! each (|>> (as .Macro) - [[here name]])))) - locals) + locals (stack.each' ! (function (_ [name value]) + (|> value + (meta.eval .Macro) + (by ! each (|>> (as .Macro) + [[here name]])))) + locals) expression? (is (Meta Bit) (function (_ lux) {try.#Success [lux (when (its .#expected lux) diff --git a/stdlib/source/library/lux/macro/pattern.lux b/stdlib/source/library/lux/macro/pattern.lux index f0760038b0..1db5bed5a4 100644 --- a/stdlib/source/library/lux/macro/pattern.lux +++ b/stdlib/source/library/lux/macro/pattern.lux @@ -8,7 +8,7 @@ or let |> ` , ,*) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe]] [error @@ -112,7 +112,7 @@ {.#Top init extras} (do meta.monad - [extras' (monad.each meta.monad ..level extras)] + [extras' (stack.each' meta.monad ..level extras)] (in [init extras'])))) (the (multiG '_ [[init_pattern levels] body]) @@ -218,7 +218,7 @@ (-> Code Code (-> Code (Meta Code)) (-> (Stack Code) (Meta Code))) (expansion.let [ (do meta.monad - [=elems (monad.each meta.monad untemplated_pattern elems)] + [=elems (stack.each' meta.monad untemplated_pattern elems)] (in (.` [(., 'meta) {(., ) (., (untemplated_stack =elems))}])))] (when (stack.reversed elems) {.#Top [_ {.#Form {.#Top [_ {.#Name global}] parameters}}] @@ -229,7 +229,7 @@ {try.#Success micro} (do meta.monad [output (..one_expansion ((//.function micro) parameters)) - =inits (monad.each meta.monad untemplated_pattern (stack.reversed inits))] + =inits (stack.each' meta.monad untemplated_pattern (stack.reversed inits))] (in (.` [(., 'meta) {(., ) (., (untemplated_partial_stack output =inits))}]))) {try.#Failure error} diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index d1e9a1f38e..85f8532fea 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -5,8 +5,8 @@ [library [lux (.except macro) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [error ["[0]" try]] [data @@ -61,22 +61,22 @@ (do [! meta.monad] [vars+projections (when (stack.pairs args) {try.#Success args} - (monad.each ! - (is (-> [Code Code] (Meta [Code Code])) - (function (_ [var projection]) - (expansion.let [ (in [var - (` (..self_documenting (' (, var)) - (, projection)))])] - (when var - [_ {.#Name ["" _]}] - + (stack.each' ! + (is (-> [Code Code] (Meta [Code Code])) + (function (_ [var projection]) + (expansion.let [ (in [var + (` (..self_documenting (' (, var)) + (, projection)))])] + (when var + [_ {.#Name ["" _]}] + - [_ {.#Name _}] - (in [var projection]) + [_ {.#Name _}] + (in [var projection]) - _ - )))) - args) + _ + )))) + args) _ (meta.failure .bindings_must_be_pairs)) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index 77bb23cd01..c9fd52331d 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -5,8 +5,8 @@ [library [lux (.except text let local name macro with) [abstract - ["<>" projection (.use "[1]#[0]" functor)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection (.use "[1]#[0]" functor)]] [error ["[0]" try (.only Try)] ["[0]" exception (.only Exception)]] @@ -53,7 +53,7 @@ (do [! meta.monad] ['locals (|> locals (stack#each //.name) - (monad.all !))] + (stack.all' !))] (in (stack (` (expansion.let [(,* (|> (stack.zipped_2 locals 'locals) (stack#each (function (_ [alias name]) (stack (code.local alias) name))) diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 9cb024bee4..11f0ff8226 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [error ["[0]" exception (.only Exception)]] [data @@ -54,7 +54,7 @@ (when <+> [_ {.#Name [.prelude $]}] (phase#in (stack#mix (function (_ left right) - [provenance.dummy {analysis.#Extension [.prelude $] (stack left right)}]) + [provenance.dummy {analysis.#Extension [.prelude $] (list left right)}]) last prevs)) @@ -63,7 +63,7 @@ [[_ $] (typeA.inferring (phase archive <+>))] (in (stack#mix (function (_ left right) - (analysis.reified [$ (stack left right)])) + (analysis.reified [$ (list left right)])) last prevs))))) @@ -133,8 +133,8 @@ (<| typeA.with_var (function (_ [$it :it:])) (do [! phase.monad] - [operands (monad.each ! (|>> (phase archive) (typeA.expecting :it:)) - operands) + [operands (stack.each' ! (|>> (phase archive) (typeA.expecting :it:)) + operands) _ (typeA.inference :it:) :it: (typeA.check (check.identity (stack) $it))] (when (stack.reversed operands) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index 14c7f1d27d..3c01d743f4 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -8,8 +8,7 @@ [abstract [hash (.only Hash)] [functor (.only Functor)] - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [control ["[0]" state (.only State)]] [error diff --git a/stdlib/source/library/lux/meta/extension.lux b/stdlib/source/library/lux/meta/extension.lux index f792416cbb..854b51739e 100644 --- a/stdlib/source/library/lux/meta/extension.lux +++ b/stdlib/source/library/lux/meta/extension.lux @@ -10,6 +10,7 @@ [data ["[0]" product] [collection + ["[0]" list] ["[0]" stack (.use "[1]#[0]" functor)]]] [macro (.only with_names) ["[0]" syntax] @@ -71,7 +72,7 @@ [(,* inputs) (, '_) ] (.by <>.monad (,' in) (, body))) - (, 'inputs)) + (list.as_stack (, 'inputs))) {.#Right (, '_)} (, '_) diff --git a/stdlib/source/library/lux/meta/global.lux b/stdlib/source/library/lux/meta/global.lux index 49f93679a5..0275662c6d 100644 --- a/stdlib/source/library/lux/meta/global.lux +++ b/stdlib/source/library/lux/meta/global.lux @@ -5,8 +5,8 @@ [library [lux (.except with) [abstract - ["?" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection]] [control ["[0]" maybe]] [data diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 61c1de2373..733ef49582 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -1038,13 +1038,13 @@ [@default (address default) @at_minimum (address at_minimum)] (|> afterwards - (monad.each ! address) + (stack.each' ! address) (by ! each (|>> [@default @at_minimum])))) {try.#Success [@default @at_minimum @afterwards]} (<| (try|do >default (try#each ..big_jump (..jump @from @default))) (try|do >at_minimum (try#each ..big_jump (..jump @from @at_minimum))) - (try|do >afterwards (monad.each try.monad (|>> (..jump @from) (try#each ..big_jump)) - @afterwards)) + (try|do >afterwards (stack.each' try.monad (|>> (..jump @from) (try#each ..big_jump)) + @afterwards)) (try|in [..no_exceptions (bytecode minimum >default [>at_minimum >afterwards])])) failure @@ -1080,12 +1080,12 @@ (when (do [! try.monad] [@default (address default)] (|> cases - (monad.each ! (|>> product.right address)) + (stack.each' ! (|>> product.right address)) (by ! each (|>> [@default])))) {try.#Success [@default @cases]} (<| (try|do >default (try#each ..big_jump (..jump @from @default))) (try|do >cases (|> @cases - (monad.each try.monad (|>> (..jump @from) (try#each ..big_jump))) + (stack.each' try.monad (|>> (..jump @from) (try#each ..big_jump))) (try#each (|>> (stack.zipped_2 (stack#each product.left cases)))))) (try|in [..no_exceptions (bytecode >default >cases)])) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index e75597a1a9..dfea1f2fa5 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -7,7 +7,7 @@ public private) [abstract [equivalence (.only Equivalence)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" state]] [error @@ -17,6 +17,7 @@ ["[0]" binary ["[1]F" \\injection (.only Injection) (.use "[1]#[0]" monoid)]] [collection + ["[0]" stack] ["[0]" sequence (.only Sequence)]]] [macro ["[0]" template]]]] @@ -91,12 +92,12 @@ [@this (//pool.class this) @super (//pool.class super) @interfaces (is (Resource (Sequence (Index class.Class))) - (monad.mix ! (function (_ interface @interfaces) - (do ! - [@interface (//pool.class interface)] - (in (sequence.suffix @interface @interfaces)))) - sequence.empty - interfaces))] + (stack.mix' ! (function (_ interface @interfaces) + (do ! + [@interface (//pool.class interface)] + (in (sequence.suffix @interface @interfaces)))) + sequence.empty + interfaces))] (in [@this @super @interfaces]))) (the .public (class version modifier @@ -113,9 +114,9 @@ (<| (state.value' //pool.empty) (do [! //pool.monad] [classes (install_classes this super interfaces) - fields (monad.all ! fields) - methods (monad.all ! methods) - attributes (monad.all ! attributes) + fields (stack.all' ! fields) + methods (stack.all' ! methods) + attributes (stack.all' ! attributes) @signature (when signature {.#Some signature} (by ! each (|>> {.#Some}) (//attribute.signature signature)) diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux index 5560f0c5ae..df3f28d27e 100644 --- a/stdlib/source/library/lux/target/jvm/field.lux +++ b/stdlib/source/library/lux/target/jvm/field.lux @@ -7,7 +7,7 @@ static public private) [abstract [equivalence (.only Equivalence)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["[0]" product] ["[0]" binary diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index d9a16a7c40..841c89edce 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -7,7 +7,7 @@ static public private) [abstract [equivalence (.only Equivalence)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] [data @@ -68,7 +68,7 @@ attributes (|> (if with_signature? (stack.partial (//attribute.signature (//type.signature type)) attributes) attributes) - (monad.all !) + (stack.all' !) (by ! each sequence.of_stack)) attributes (when code {.#Some code} diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index c589b1a53e..3b71c61c8b 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -6,7 +6,7 @@ [lux (.except type) ["[0]" ffi (.only import)] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try (.only Try) (.use "[1]#[0]" functor)] ["[0]" exception (.only Exception)]] @@ -177,7 +177,7 @@ (|> reflection' (java/lang/reflect/ParameterizedType::getActualTypeArguments []) (array.stack {.#None}) - (monad.each ! parameter) + (stack.each' ! parameter) (by ! each (function (_ parameters) (|> raw' (as (java/lang/Class java/lang/Object)) diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 859cd5ac57..1aacdbf429 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -5,8 +5,8 @@ [library [lux (.except Type) [abstract - ["<>" projection (.only)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [error ["[0]" try]] [data diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index ac25b54578..c56f818289 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -5,8 +5,8 @@ [library [lux (.except type) [abstract - ["<>" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection (.use "[1]#[0]" monad)]] [error ["[0]" try] ["[0]" exception (.only Exception)]] @@ -17,6 +17,7 @@ ["<[1]>" \\projection (.only Projection)]] [collection ["[0]" array] + ["[0]" stack] ["[0]" dictionary (.only Dictionary)]]] [macro ["[0]" template]] @@ -141,7 +142,7 @@ (<>.before (.this //signature.parameters_end)) (<>.else (stack)))] (in (do [! check.monad] - [parameters (monad.all ! parameters)] + [parameters (stack.all' ! parameters)] (in {.#Nominal name parameters})))) (<>.after (.this //descriptor.class_prefix)) (<>.before (.this //descriptor.class_suffix)))) diff --git a/stdlib/source/library/lux/test/benchmark.lux b/stdlib/source/library/lux/test/benchmark.lux index a4bce218dc..b07023af97 100644 --- a/stdlib/source/library/lux/test/benchmark.lux +++ b/stdlib/source/library/lux/test/benchmark.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" order]] [control ["[0]" io (.only IO) (.use "[1]#[0]" monad)]] @@ -56,7 +56,7 @@ _ (do [! io.monad] [durations (|> subject (stack.repeated times) - (monad.each ! ..time))] + (stack.each' ! ..time))] (in [#times times #minimum (stack#mix (order.minor duration.order) ..maximum_duration durations) #maximum (stack#mix (order.major duration.order) ..minimum_duration durations) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index 5a2f80b815..d57a9079df 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -7,8 +7,8 @@ [abstract [equivalence (.only Equivalence)] [format (.only Format)] - ["?" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)] + ["?" projection (.use "[1]#[0]" monad)]] [control ["[0]" maybe]] [error diff --git a/stdlib/source/library/lux/type/brand.lux b/stdlib/source/library/lux/type/brand.lux index 1c17d9cb94..9fda9f0698 100644 --- a/stdlib/source/library/lux/type/brand.lux +++ b/stdlib/source/library/lux/type/brand.lux @@ -5,7 +5,7 @@ [library [lux (.except static) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data [collection ["[0]" stack]]] @@ -21,7 +21,7 @@ [macro.with_names ['_ '0] 'parameters (|> (macro.name "parameter_") (stack.repeated arity) - (monad.all !))] + (stack.all' !))] (in (stack (` (is (for_some ((, '_) (, '0)) (-> Any (for_any ((, '_) (,* 'parameters)) diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 809d02fa1d..c98208aaa4 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -7,7 +7,7 @@ [abstract [equivalence (.only Equivalence)] [functor (.only Functor)] - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [control ["[0]" maybe]] [error @@ -362,9 +362,9 @@ (do [! ..monad] [ring (..ring id) _ (..assertion "" (n.> 1 (stack.size ring))) - _ (monad.each ! (function (_ variable) - (..changed variable (environment.bound type))) - ring)] + _ (stack.each' ! (function (_ variable) + (..changed variable (environment.bound type))) + ring)] then) (do ..monad [?bound (..binding id)] @@ -430,21 +430,21 @@ (in hypotheses) ... Fuse 2 rings (do ! - [_ (monad.mix ! (function (_ interpose to) - (do ! - [_ (..three interpose to idE)] - (in interpose))) - targetE - ringA)] + [_ (stack.mix' ! (function (_ interpose to) + (do ! + [_ (..three interpose to idE)] + (in interpose))) + targetE + ringA)] (in hypotheses)))) (,, (template.with [ ] [ (do ! [ring (..ring ) - _ (monad.each ! (function (_ variable) - (..changed variable (environment.bound ))) - ring)] + _ (stack.each' ! (function (_ variable) + (..changed variable (environment.bound ))) + ring)] (in hypotheses))] [[{.#Variable _} _] idE atype] @@ -747,7 +747,7 @@ (`` (when inputT {.#Nominal name paramsT+} (|> paramsT+ - (monad.each ..monad (clean aliases)) + (stack.each' ..monad (clean aliases)) (/#each (|>> {.#Nominal name}))) (^.or {.#Parameter _} @@ -797,7 +797,7 @@ (,, (template.with [] [{ envT+ unquantifiedT} (do [! ..monad] - [envT+' (monad.each ! (clean aliases) envT+) + [envT+' (stack.each' ! (clean aliases) envT+) unquantifiedT' (clean aliases unquantifiedT)] (in { envT+' unquantifiedT'}))] diff --git a/stdlib/source/library/lux/type/function.lux b/stdlib/source/library/lux/type/function.lux index f8ba790264..3b8fadc9bb 100644 --- a/stdlib/source/library/lux/type/function.lux +++ b/stdlib/source/library/lux/type/function.lux @@ -5,10 +5,12 @@ [library [lux (.except) [abstract - ["?" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection]] [data - ["[0]" product]] + ["[0]" product] + [collection + ["[0]" stack]]] [macro ["[0]" syntax]] ["[0]" meta (.use "[1]#[0]" functor) @@ -28,9 +30,9 @@ (Meta [(Stack Type) Type])) (do [! meta.monad] [[it _] (binding.export it) - parameters (monad.each ! (|>> (meta.eval Type) - (by ! each (|>> (.as Type)))) - parameters) + parameters (stack.each' ! (|>> (meta.eval Type) + (by ! each (|>> (.as Type)))) + parameters) it (when (//.applied parameters it) {.#Some it} (in it) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 4fc2556bf9..7b6016fa62 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -5,8 +5,8 @@ [library [lux (.except with) [abstract + [monad (.only do)] ["<>" projection] - ["[0]" monad (.only do)] ["[0]" equivalence]] [control ["[0]" maybe]] @@ -108,7 +108,7 @@ (do [! meta.monad] [[this_module_name _] module.current imp_mods (import.all this_module_name) - tag_stacks (monad.each ! label.tag_stacks imp_mods) + tag_stacks (stack.each' ! label.tag_stacks imp_mods) .let [tag_stacks (|> tag_stacks stack#conjoint (stack#each product.left) stack#conjoint) candidates (stack.only (|>> product.right (text.= simple_name)) tag_stacks)]] @@ -202,7 +202,7 @@ (do [! meta.monad] [[this_module_name _] module.current imported_modules (import.all this_module_name) - accessible_definitions (monad.each ! binding.resolved_globals imported_modules)] + accessible_definitions (stack.each' ! binding.resolved_globals imported_modules)] (in (stack#mix (function (_ [imported_module definitions] tail) (available_definitions sig_type imported_module this_module_name definitions tail)) {.#Empty} @@ -249,7 +249,7 @@ (-> Type (Stack Type) Type (Check [])) (do check.monad - [actual_output (monad.mix check.monad ..on_argument member_type input_types)] + [actual_output (stack.mix' check.monad ..on_argument member_type input_types)] (check.check expected_output actual_output))) (every Instance @@ -272,7 +272,7 @@ .let [[deps alt_type] (//.flat_function alt_type)] _ (check.check dep alt_type) context' check.context - =deps (monad.each ! (provision compiler context') deps)] + =deps (stack.each' ! (provision compiler context') deps)] (in =deps))) {.#Left error} (stack) @@ -325,7 +325,7 @@ member_type (member_type member_idx alt_type) _ (ensure_function_application! member_type input_types output_type) context' check.context - =deps (monad.each ! (provision sig_type compiler context') deps)] + =deps (stack.each' ! (provision sig_type compiler context') deps)] (in =deps))) {.#Left error} (stack) @@ -382,7 +382,7 @@ {.#Left [args _]} (do [! meta.monad] [[member_idx sig_type] (..implicit_member member) - input_types (monad.each ! ..implicit_type args) + input_types (stack.each' ! ..implicit_type args) output_type meta.expected_type chosen_ones (alternatives sig_type member_idx input_types output_type)] (when chosen_ones @@ -405,7 +405,7 @@ (do [! meta.monad] [labels (|> (macro.name "'parameter") (stack.repeated (stack.size args)) - (monad.all !))] + (stack.all' !))] (in (stack (` (let [(,* (|> args (stack.zipped_2 labels) (stack#each ..pair_stack) stack#conjoint))] (..any (, (code.name member)) (,* labels))))))) ))) @@ -415,7 +415,7 @@ (Meta (Stack Code))) (|> (macro.name "'implicit") (stack.repeated amount) - (monad.all meta.monad))) + (stack.all' meta.monad))) (the .public with (syntax.macro (_ [implementations (.tuple (<>.many .any)) diff --git a/stdlib/source/library/lux/type/linear.lux b/stdlib/source/library/lux/type/linear.lux index 67b61aa0d0..2722ac5668 100644 --- a/stdlib/source/library/lux/type/linear.lux +++ b/stdlib/source/library/lux/type/linear.lux @@ -6,8 +6,7 @@ [lux (.except) [abstract ["<>" projection] - ["[0]" monad (.only Monad - do) + ["[0]" monad (.only Monad do) ["[0]" indexed]]] [control ["[0]" maybe]] @@ -144,14 +143,14 @@ {.#Top head tail} (do [! meta.monad] [.let [max_idx (stack#mix n.major head tail)] - 'inputs (<| (monad.all !) (stack.repeated (++ max_idx)) (macro.name "input")) - .let ['outputs (|> (monad.mix maybe.monad - (function (_ from to) - (do maybe.monad - [input (stack.item from 'inputs)] - (in (sequence.suffix input to)))) - (is (Sequence Code) sequence.empty) - swaps) + 'inputs (<| (stack.all' !) (stack.repeated (++ max_idx)) (macro.name "input")) + .let ['outputs (|> (stack.mix' maybe.monad + (function (_ from to) + (do maybe.monad + [input (stack.item from 'inputs)] + (in (sequence.suffix input to)))) + (is (Sequence Code) sequence.empty) + swaps) maybe.trusted sequence.as_stack) 'inputsT+ (stack#each (|>> (,) (..Key ..Commutative) (`)) 'inputs) @@ -180,7 +179,7 @@ (do [! meta.monad] ['keys (|> (macro.name "keys") (stack.repeated amount) - (monad.all !))] + (stack.all' !))] (in (stack (` (is (for_any ((, '_) (, '!) (,* 'keys) (, 'context)) (-> (monad.Monad (, '!)) (Procedure (, '!) diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index 744e728427..4b895c6ec6 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -10,8 +10,8 @@ [library [lux (.except has with macro) [abstract - ["<>" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection (.use "[1]#[0]" monad)]] [control ["[0]" maybe]] [error (.only error) @@ -163,7 +163,7 @@ Complex) {#Flat (function (_ code parts) (do [! try.monad] - [parts (monad.each ! code parts)] + [parts (stack.each' ! code parts)] (in (` ((, (its #on_whole it)) (all (, (its #on_both it)) (,* (stack#each (function (_ part) diff --git a/stdlib/source/library/lux/type/record.lux b/stdlib/source/library/lux/type/record.lux index b927fee9c7..5777f69d2a 100644 --- a/stdlib/source/library/lux/type/record.lux +++ b/stdlib/source/library/lux/type/record.lux @@ -5,8 +5,8 @@ [library [lux (.except only except) [abstract - ["?" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection]] [error ["[0]" try (.only Try)]] ["[0]" function (.only) @@ -39,9 +39,9 @@ [full_label (binding.normal label) label (meta.or (label.tag full_label) (label.slot full_label)) - parameters (monad.each ! (|>> (meta.eval Type) - (by ! each (|>> (.as Type)))) - parameters) + parameters (stack.each' ! (|>> (meta.eval Type) + (by ! each (|>> (.as Type)))) + parameters) .let [[flat context it] (when label {.#Left [context it]} [//.flat_variant context it] @@ -97,14 +97,14 @@ (Meta [(Stack Type) [Label (Stack Label)]])) (do [! meta.monad] [head (label.slot head) - tail (monad.each ! label.slot tail) + tail (stack.each' ! label.slot tail) .let [general_type (product.right head)] _ (if (stack.every? (|>> product.right (by //.equivalence = general_type)) tail) (in []) (meta.failure ..slots_belong_to_different_types)) - parameters (monad.each ! (|>> (meta.eval Type) - (by ! each (|>> (.as Type)))) - parameters) + parameters (stack.each' ! (|>> (meta.eval Type) + (by ! each (|>> (.as Type)))) + parameters) it (when (//.applied parameters general_type) {.#Some it} (in it) @@ -138,9 +138,9 @@ subset (meta.of_try (do [! try.monad] [head (..slot_index head) - tail (monad.each ! ..slot_index tail)] + tail (stack.each' ! ..slot_index tail)] (|> (stack.partial head tail) - (monad.each ! ((function.flipped stack.item) specialized_type)))))] + (stack.each' ! ((function.flipped stack.item) specialized_type)))))] (in (stack (as_type (//.tuple subset))))))) (the .public except @@ -151,7 +151,7 @@ excluded (meta.of_try (do [! try.monad] [head (..slot_index head) - tail (monad.each ! ..slot_index tail)] + tail (stack.each' ! ..slot_index tail)] (in (stack.partial head tail)))) .let [excluded? (is (Predicate Natural) (function (_ index) @@ -165,6 +165,6 @@ stack.indices (stack.only (predicate.not excluded?)))] subset (meta.of_try - (monad.each try.monad ((function.flipped stack.item) specialized_type) - included))] + (stack.each' try.monad ((function.flipped stack.item) specialized_type) + included))] (in (stack (as_type (//.tuple subset))))))) diff --git a/stdlib/source/library/lux/type/row.lux b/stdlib/source/library/lux/type/row.lux index 0728f60d71..6f08a1a1e6 100644 --- a/stdlib/source/library/lux/type/row.lux +++ b/stdlib/source/library/lux/type/row.lux @@ -7,8 +7,8 @@ [lux (.except Slot macro type its has revised record) [abstract - ["?" projection (.use "[1]#[0]" monad)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["?" projection (.use "[1]#[0]" monad)]] [control ["[0]" maybe (.use "[1]#[0]" monad)]] [error @@ -116,11 +116,11 @@ (do [! meta.monad] [.let [parameters (stack#each code.local parameters)] name' (macro.name name) - slots' (monad.each ! (function (_ [slot type]) - (do ! - [slot' (macro.name slot)] - (in [slot' type]))) - slots) + slots' (stack.each' ! (function (_ [slot type]) + (do ! + [slot' (macro.name slot)] + (in [slot' type]))) + slots) :super: (when super {.#Some super} (do ! @@ -193,14 +193,14 @@ (the .public row (syntax.macro (_ [slots (?code.tuple (?.many (?.and ?code.name ?code.any)))]) (do [! meta.monad] - [record (monad.each ! (function (_ [slot value]) - (do ! - [slot (by_name slot) - path ((macro.function slot) (stack)) - .let [nesting (n.- 2 (stack.size path)) - slot (maybe.trusted (stack.last path))]] - (in [nesting [slot value]]))) - slots) + [record (stack.each' ! (function (_ [slot value]) + (do ! + [slot (by_name slot) + path ((macro.function slot) (stack)) + .let [nesting (n.- 2 (stack.size path)) + slot (maybe.trusted (stack.last path))]] + (in [nesting [slot value]]))) + slots) .let [levels (stack#mix (function (_ [nesting slot,value] levels) (dictionary.revised' nesting (stack) @@ -209,16 +209,16 @@ (is (Dictionary Natural (Stack [Code Code])) (dictionary.empty n.hash)) record)] - row (monad.mix ! (function (_ level extra) - (when (dictionary.value level levels) - {try.#Success record} - (in (` [..#content [(,* (un_paired record))] - ..#extra (, extra)])) - - failure - (meta.of_try (exception.except ..missing_level [level])))) - (` []) - (|> (dictionary.size levels) - stack.indices - stack.reversed))] + row (stack.mix' ! (function (_ level extra) + (when (dictionary.value level levels) + {try.#Success record} + (in (` [..#content [(,* (un_paired record))] + ..#extra (, extra)])) + + failure + (meta.of_try (exception.except ..missing_level [level])))) + (` []) + (|> (dictionary.size levels) + stack.indices + stack.reversed))] (in (stack row))))) diff --git a/stdlib/source/library/lux/world/environment.lux b/stdlib/source/library/lux/world/environment.lux index 07c6d5cdcd..48ba8bdf62 100644 --- a/stdlib/source/library/lux/world/environment.lux +++ b/stdlib/source/library/lux/world/environment.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [concurrency ["[0]" atom] ["[0]" future (.only Future)]] @@ -60,9 +60,9 @@ (for_any (_ !) (-> (Monad !) (Environment !) (! \\projection.Environment))) (do [! monad] [variables (by environment available_variables []) - entries (monad.each ! (function (_ name) - (by ! each (|>> [name]) (by environment variable name))) - variables)] + entries (stack.each' ! (function (_ name) + (by ! each (|>> [name]) (by environment variable name))) + variables)] (in (|> entries (stack.all (function (_ [name value]) (when value diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 08911493bb..29f8cfbc97 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -6,7 +6,7 @@ [lux (.except Error open tuple name) [abstract - ["[0]" monad (.only Monad do)]] + [monad (.only Monad do)]] [concurrency ["[0]" future (.only Future)] ["[0]" stm (.only Var STM)]] @@ -246,10 +246,10 @@ {.#Some children} (|> children (array.stack {.#None}) - (monad.only ! (|>> ( []) - (by ! each (|>> ffi.of_boolean)))) - (by ! each (monad.each ! (|>> (java/io/File::getAbsolutePath []) - (by ! each (|>> ffi.of_string))))) + (stack.only' ! (|>> ( []) + (by ! each (|>> ffi.of_boolean)))) + (by ! each (stack.each' ! (|>> (java/io/File::getAbsolutePath []) + (by ! each (|>> ffi.of_string))))) (by ! conjoint)) {.#None} @@ -441,11 +441,11 @@ (|> subs (array.stack {.#None}) (stack#each (|>> (text path js_delimiter))) - (monad.each ! (function (_ sub) - (by ! each (|>> ( []) [sub]) - (with_future write! (Try Stats) - (Fs::stat [sub (..value_callback write!)] - node_fs))))) + (stack.each' ! (function (_ sub) + (by ! each (|>> ( []) [sub]) + (with_future write! (Try Stats) + (Fs::stat [sub (..value_callback write!)] + node_fs))))) (by ! each (|>> (stack.only product.right) (stack#each product.left))))))] @@ -589,8 +589,8 @@ os::listdir (by ! each (|>> (array.stack {.#None}) (stack#each (|>> (text path ..python_delimiter))) - (monad.each ! (function (_ sub) - (by ! each (|>> [sub]) ( [sub])))) + (stack.each' ! (function (_ sub) + (by ! each (|>> [sub]) ( [sub])))) (by ! each (|>> (stack.only product.right) (stack#each product.left))))) (by ! conjoint))))] diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 118971c4e6..d4a00d6cd2 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -6,7 +6,7 @@ [lux (.except all and) ["[0]" ffi (.only import)] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)] ["[0]" stm (.only STM Var)]] @@ -140,25 +140,25 @@ (Future (Try File_Tracker))) (do [! (try.with future.monad)] [files (by fs directory_files directory)] - (monad.mix ! - (function (_ file tracker) - (do ! - [last_modified (by fs last_modified file)] - (in (dictionary.has file last_modified tracker)))) - (is File_Tracker - (dictionary.empty text.hash)) - files))) + (stack.mix' ! + (function (_ file tracker) + (do ! + [last_modified (by fs last_modified file)] + (in (dictionary.has file last_modified tracker)))) + (is File_Tracker + (dictionary.empty text.hash)) + files))) (the (available_files fs directory) (-> (//.System Future) //.Path (Future (Try (Stack [//.Path Instant])))) (do [! (try.with future.monad)] [files (by fs directory_files directory)] - (monad.each ! (function (_ file) - (|> file - (by fs last_modified) - (by ! each (|>> [file])))) - files))) + (stack.each' ! (function (_ file) + (|> file + (by fs last_modified) + (by ! each (|>> [file])))) + files))) (the (available_directory_changes fs [directory [the_concern file_tracker]]) (-> (//.System Future) [//.Path [Concern File_Tracker]] @@ -249,7 +249,7 @@ (do [! (try.with future.monad)] [changes (|> @tracker dictionary.entries - (monad.each ! (..available_directory_changes fs))) + (stack.each' ! (..available_directory_changes fs))) _ (do future.monad [_ (stm.commit! (stm.write (|> changes (stack#each product.left) diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 2ecb4098ce..f9b9067798 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -6,7 +6,7 @@ [lux (.except) ["[0]" ffi] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [control @@ -211,9 +211,9 @@ [connection (|> url ffi.as_string [] java/net/URL::new (java/net/URL::openConnection [])) .let [connection (as java/net/HttpURLConnection connection)] _ (java/net/HttpURLConnection::setRequestMethod [(ffi.as_string (..method_name method))] connection) - _ (monad.each ! (function (_ [name value]) - (java/net/URLConnection::setRequestProperty [(ffi.as_string name) (ffi.as_string value)] connection)) - (dictionary.entries headers)) + _ (stack.each' ! (function (_ [name value]) + (java/net/URLConnection::setRequestProperty [(ffi.as_string name) (ffi.as_string value)] connection)) + (dictionary.entries headers)) _ (when data {.#Some data} (do ! diff --git a/stdlib/source/library/lux/world/net/http/header.lux b/stdlib/source/library/lux/world/net/http/header.lux index 282fe0eb64..d99935e226 100644 --- a/stdlib/source/library/lux/world/net/http/header.lux +++ b/stdlib/source/library/lux/world/net/http/header.lux @@ -5,7 +5,7 @@ [library [lux (.except has) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" pipe]] [error @@ -105,14 +105,14 @@ _ (text previous ..delimiter )))) "")) #out (|>> (text.all_split_by ..delimiter) - (monad.mix try.monad - (function (_ cookie jar) - (when (text.split_by ..assignment cookie) - {.#Some [name value]} - (do try.monad - [name (uri.of_text name)] - (in (dictionary.has name value jar))) - - {.#None} - (try#in jar))) - cookie.empty))]) + (stack.mix' try.monad + (function (_ cookie jar) + (when (text.split_by ..assignment cookie) + {.#Some [name value]} + (do try.monad + [name (uri.of_text name)] + (in (dictionary.has name value jar))) + + {.#None} + (try#in jar))) + cookie.empty))]) diff --git a/stdlib/source/library/lux/world/net/http/server.lux b/stdlib/source/library/lux/world/net/http/server.lux index 17326335b7..1ece61c242 100644 --- a/stdlib/source/library/lux/world/net/http/server.lux +++ b/stdlib/source/library/lux/world/net/http/server.lux @@ -5,8 +5,7 @@ [library [lux (.except or static text) [abstract - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [control ["[0]" maybe]] [error diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 2dfbf706ed..2d4aad70a9 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [error @@ -36,7 +36,7 @@ (|> path (by fs sub_directories) (by ! each (|>> (try.else (stack)) - (monad.each ! (targets fs)))) + (stack.each' ! (targets fs)))) (by ! conjoint) (by ! each (|>> stack.together (stack.partial path)))))) @@ -60,10 +60,10 @@ [targets (|> profile (its ///.#sources) set.stack - (monad.each ! (..targets fs)) + (stack.each' ! (..targets fs)) (by ! each stack.together))] (do [! ///action.monad] - [_ (monad.each ! (by watcher start watch.modification) targets) + [_ (stack.each' ! (by watcher start watch.modification) targets) _ ] (loop (again [_ []]) (do ! diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux index 5301ae8558..3dd6eec6e4 100644 --- a/stdlib/source/program/aedifex/command/clean.lux +++ b/stdlib/source/program/aedifex/command/clean.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [error @@ -26,7 +26,7 @@ (do [! ///action.monad] [_ (|> root (by fs directory_files) - (by ! each (monad.each ! (by fs delete))) + (by ! each (stack.each' ! (by fs delete))) (by ! conjoint))] (in []))) @@ -46,7 +46,7 @@ [_ (..clean_files! fs root) _ (|> root (by fs sub_directories) - (by ! each (monad.each ! again)) + (by ! each (stack.each' ! again)) (by ! conjoint))] (by fs delete root))) (by ! in [])))] diff --git a/stdlib/source/program/aedifex/command/deploy/release.lux b/stdlib/source/program/aedifex/command/deploy/release.lux index 783b445832..1f57a9ae9f 100644 --- a/stdlib/source/program/aedifex/command/deploy/release.lux +++ b/stdlib/source/program/aedifex/command/deploy/release.lux @@ -6,7 +6,7 @@ [lux (.except) ["[0]" ffi (.only import)] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [control @@ -174,10 +174,10 @@ exit (is (Future (Try shell.Exit)) (by process await [])) .let [$artifact (////artifact.uri (its ////artifact.#version artifact) artifact)] - _ (monad.each ! (release_signed_artifact! local remote) - (stack (..signed (..pom $artifact)) - (..signed (..tar $artifact)) - (..signed (..jar $artifact)) - (..signed (..javadoc $artifact)) - (..signed (..sources $artifact))))] + _ (stack.each' ! (release_signed_artifact! local remote) + (stack (..signed (..pom $artifact)) + (..signed (..tar $artifact)) + (..signed (..jar $artifact)) + (..signed (..javadoc $artifact)) + (..signed (..sources $artifact))))] (in []))) diff --git a/stdlib/source/program/aedifex/dependency/deployment.lux b/stdlib/source/program/aedifex/dependency/deployment.lux index efa2439365..ba665a9ea4 100644 --- a/stdlib/source/program/aedifex/dependency/deployment.lux +++ b/stdlib/source/program/aedifex/dependency/deployment.lux @@ -6,7 +6,7 @@ [lux (.except all) [abstract [format (.only Format)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)]] [error @@ -151,6 +151,6 @@ (-> (Repository Future) Resolution (Future (Try (Set Artifact)))) (let [! (try.with future.monad)] (|> (dictionary.entries resolution) - (monad.each ! (function (_ [dependency package]) - (..one repository dependency package))) + (stack.each' ! (function (_ [dependency package]) + (..one repository dependency package))) (by ! each (set.of_stack ///artifact.hash))))) diff --git a/stdlib/source/program/aedifex/input.lux b/stdlib/source/program/aedifex/input.lux index de76d2a10a..006d92c94c 100644 --- a/stdlib/source/program/aedifex/input.lux +++ b/stdlib/source/program/aedifex/input.lux @@ -5,8 +5,7 @@ [library [lux (.except Name) [abstract - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [algorithm ["[0]" mix]] [control @@ -66,5 +65,5 @@ (do [! try.monad] [it it it (..project_of it) - it (monad.each ! (//project.profile it) (stack.partial //profile.default profiles))] + it (stack.each' ! (//project.profile it) (stack.partial //profile.default profiles))] (in (mix.with_monoid //profile.monoid stack.mix it))))))) diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux index 572b00c780..e458600c25 100644 --- a/stdlib/source/program/aedifex/project.lux +++ b/stdlib/source/program/aedifex/project.lux @@ -7,7 +7,7 @@ [abstract [equivalence (.only Equivalence)] [monoid (.only Monoid)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try (.only Try)] ["[0]" exception (.only Exception)]] @@ -69,8 +69,8 @@ failure! (do [! try.monad] - [parents (monad.each ! (profile' (set.has name lineage) project) - (its //.#parents profile))] + [parents (stack.each' ! (profile' (set.has name lineage) project) + (its //.#parents profile))] (in (stack#mix (function (_ parent child) (by //.monoid composite child parent)) (has //.#parents (stack) profile) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index f57134c3a7..087b8e1327 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -6,8 +6,7 @@ [lux (.except Module) ["[0]" debug] [abstract - ["[0]" monad (.only Monad - do)]] + [monad (.only Monad do)]] [concurrency ["[0]" future (.only Future) (.use "[1]#[0]" monad)]] [control @@ -123,9 +122,9 @@ {.#Right content} (do [! (try.with future.monad)] [_ (by fs make_directory package) - _ (monad.each ! (function (_ [name content]) - (by fs write (file.rooted fs package name) content)) - content)] + _ (stack.each' ! (function (_ [name content]) + (by fs write (file.rooted fs package name) content)) + content)] (in []))) {try.#Failure error} @@ -243,8 +242,8 @@ (do [! ..monad] [files (by fs directory_files root) subs (by fs sub_directories root) - files (monad.each ! (cache_tar_entry fs) files) - subs (monad.each ! again subs)] + files (stack.each' ! (cache_tar_entry fs) files) + subs (stack.each' ! again subs)] (in (stack#mix sequence#composite (sequence.of_stack files) subs))))) diff --git a/stdlib/source/projection/lux/data/format/json.lux b/stdlib/source/projection/lux/data/format/json.lux index b9a501343d..e6cd280d9f 100644 --- a/stdlib/source/projection/lux/data/format/json.lux +++ b/stdlib/source/projection/lux/data/format/json.lux @@ -5,8 +5,8 @@ [library [lux (.except) [abstract - ["//" projection (.use "[1]#[0]" functor)] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["//" projection (.use "[1]#[0]" functor)]] [error ["[0]" try (.only Try)] ["[0]" exception (.only Exception)]] diff --git a/stdlib/source/projection/lux/meta/code.lux b/stdlib/source/projection/lux/meta/code.lux index 831e86d98a..e7138f976e 100644 --- a/stdlib/source/projection/lux/meta/code.lux +++ b/stdlib/source/projection/lux/meta/code.lux @@ -5,8 +5,8 @@ [library [lux (.except text natural integer revolution local not name local global variant tuple) [abstract - ["//" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["//" projection]] [error ["[0]" try (.only Try)]] [data diff --git a/stdlib/source/projection/lux/type.lux b/stdlib/source/projection/lux/type.lux index 0114dc3792..fb9c1f1171 100644 --- a/stdlib/source/projection/lux/type.lux +++ b/stdlib/source/projection/lux/type.lux @@ -5,8 +5,8 @@ [library [lux (.except function local variant tuple) [abstract - ["//" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["//" projection]] [error ["[0]" try (.only Try)] ["[0]" exception (.only Exception)]] @@ -369,6 +369,6 @@ _ (local (stack funcT) (..this_parameter 0)) allC (let [allT (stack.partial funcT argsT)] (|> allT - (monad.each ! (function.constant ..parameter)) + (stack.each' ! (function.constant ..parameter)) (local allT)))] (in (` ((,* allC)))))) diff --git a/stdlib/source/test/aedifex/command/clean.lux b/stdlib/source/test/aedifex/command/clean.lux index abb53512e1..1aab32476e 100644 --- a/stdlib/source/test/aedifex/command/clean.lux +++ b/stdlib/source/test/aedifex/command/clean.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try (.only Try)]] [concurrency @@ -63,7 +63,7 @@ (do [! (try.with future.monad)] [_ (is (Future (Try Any)) (file.make_directories future.monad fs path)) - _ (monad.each ! (..create_file! fs) files)] + _ (stack.each' ! (..create_file! fs) files)] (in []))) (the (directory_exists? fs) @@ -81,7 +81,7 @@ files_exist? (is (Action (Stack Bit)) (|> files (stack#each product.left) - (monad.each ///action.monad (..file_exists? fs))))] + (stack.each' ///action.monad (..file_exists? fs))))] (in (and directory_exists? (stack.every? (|>>) files_exist?))))) diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index bf281e3291..8810ca96c5 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe]] [error @@ -66,15 +66,15 @@ (the (execute [environment working_directory command arguments]) (do [! ///action.monad] [files (by fs directory_files working_directory) - _ (monad.each ! - (function (_ file) - (do ! - [_ (is (Future (Try Any)) - (file.copy future.monad fs - file - (text file ".asc")))] - (in []))) - files)] + _ (stack.each' ! + (function (_ file) + (do ! + [_ (is (Future (Try Any)) + (file.copy future.monad fs + file + (text file ".asc")))] + (in []))) + files)] (<| in (is (Process Future)) (implementation diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index 285fde0bb9..f2057ccc21 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try (.only Try) (.use "[1]#[0]" functor)] ["[0]" exception]] @@ -49,12 +49,12 @@ ! ///action.monad] (|> sources set.stack - (monad.each ! (function (_ head) - (do ! - [_ (is (Future (Try Any)) - (file.make_directories future.monad fs head))] - (is (Future (Try Any)) - (file.make_file future.monad fs (binary.empty 0) (text head / head ".lux"))))))))) + (stack.each' ! (function (_ head) + (do ! + [_ (is (Future (Try Any)) + (file.make_directories future.monad fs head))] + (is (Future (Try Any)) + (file.make_file future.monad fs (binary.empty 0) (text head / head ".lux"))))))))) (the (execute! program fs sample) (-> (Environment Future) (file.System Future) ///.Profile (Future (Try Text))) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index 315e1b233e..f67ec0ba32 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -7,7 +7,7 @@ [abstract [equivalence (.only Equivalence)] [hash (.only Hash)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" io]] [error diff --git a/stdlib/source/test/lux/abstract/monad.lux b/stdlib/source/test/lux/abstract/monad.lux index ca26688227..c2566e8f91 100644 --- a/stdlib/source/test/lux/abstract/monad.lux +++ b/stdlib/source/test/lux/abstract/monad.lux @@ -85,35 +85,6 @@ (/.then pure.monad (|>> ++ (by pure.monad in)) (by pure.monad in mono))))) - (_.coverage [/.all] - (by (stack.equivalence n.equivalence) = - (stack#each ++ poly) - (|> poly - (stack#each (|>> ++ (by pure.monad in))) - (is (Stack (Pure Natural))) - (/.all pure.monad) - (is (Pure (Stack Natural)))))) - (_.coverage [/.each] - (by (stack.equivalence n.equivalence) = - (stack#each ++ poly) - (|> poly - (/.each pure.monad (|>> ++ (by pure.monad in))) - (is (Pure (Stack Natural)))))) - (_.coverage [/.only] - (by (stack.equivalence n.equivalence) = - (stack.only n.even? poly) - (|> poly - (/.only pure.monad (|>> n.even? (by pure.monad in))) - (is (Pure (Stack Natural)))))) - (_.coverage [/.mix] - (n.= (stack#mix n.+ 0 poly) - (|> poly - (/.mix pure.monad - (function (_ part whole) - (by pure.monad in - (n.+ part whole))) - 0) - (is (Pure Natural))))) (_.coverage [/.deferred] (|> (let [output (is (Atom Text) (atom.atom ""))] diff --git a/stdlib/source/test/lux/abstract/monad/free.lux b/stdlib/source/test/lux/abstract/monad/free.lux index 8ef359eaff..4ce95c6c80 100644 --- a/stdlib/source/test/lux/abstract/monad/free.lux +++ b/stdlib/source/test/lux/abstract/monad/free.lux @@ -6,8 +6,7 @@ [lux (.except) [abstract [functor (.only Functor)] - ["[0]" monad (.only Monad - do)] + [monad (.only Monad do)] ["[0]" functor ["[1]T" \\test (.only Injection Comparison)]]] [data diff --git a/stdlib/source/test/lux/abstract/monad/indexed.lux b/stdlib/source/test/lux/abstract/monad/indexed.lux index 1f65eeb4e7..1db9919eb4 100644 --- a/stdlib/source/test/lux/abstract/monad/indexed.lux +++ b/stdlib/source/test/lux/abstract/monad/indexed.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [math ["[0]" random] [number diff --git a/stdlib/source/test/lux/compiler.lux b/stdlib/source/test/lux/compiler.lux index f47977e2d3..7c4eddb1af 100644 --- a/stdlib/source/test/lux/compiler.lux +++ b/stdlib/source/test/lux/compiler.lux @@ -18,7 +18,8 @@ ["[1][0]" reference] ["[1][0]" language ["[1]/[0]" lux]] - ["[1][0]" meta]]) + ["[1][0]" meta] + ["[1][0]" extension]]) (the .public test Test @@ -36,4 +37,5 @@ /language/lux.test /meta.test + /extension.test ))) diff --git a/stdlib/source/test/lux/compiler/extension.lux b/stdlib/source/test/lux/compiler/extension.lux new file mode 100644 index 0000000000..8c17b69013 --- /dev/null +++ b/stdlib/source/test/lux/compiler/extension.lux @@ -0,0 +1,45 @@ +... 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)]] + [data + ["[0]" bit] + ["[0]" text (.only) + ["%" \\injection]]] + [math + ["[0]" random (.only Random)] + [number + ["n" natural]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]] + ["[0]" / + ["[1][0]" lux]]) + +(the .public test + Test + (<| (_.covering /._) + (_.for [/.Name]) + (do [! random.monad] + [raw_0 (by ! each %.natural random.natural) + raw_1 (by ! each %.natural random.natural)]) + (all _.and + (_.coverage [/.name] + (and (not (text.= raw_0 (/.name raw_0))) + (bit.= (text.= raw_0 raw_1) + (text.= (/.name raw_0) (/.name raw_1))))) + (_.coverage [/.synthesis /.translation] + (not (or (text.= (/.synthesis (/.name raw_0)) + (/.name raw_0)) + (text.= (/.translation (/.name raw_0)) + (/.name raw_0)) + (text.= (/.translation (/.name raw_0)) + (/.synthesis (/.name raw_0)))))) + + /lux.test + ))) diff --git a/stdlib/source/test/lux/compiler/extension/lux.lux b/stdlib/source/test/lux/compiler/extension/lux.lux new file mode 100644 index 0000000000..ff03d554a5 --- /dev/null +++ b/stdlib/source/test/lux/compiler/extension/lux.lux @@ -0,0 +1,38 @@ +... 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)]] + [data + ["[0]" text] + [collection + ["[0]" stack] + ["[0]" set]]] + [macro + ["[0]" expansion]] + [math + ["[0]" random] + [number + ["n" natural]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(the .public test + Test + (<| (_.covering /._) + (do [! random.monad] + []) + (all _.and + (expansion.let [,*options (these /.list + /.text_composite)] + (_.coverage [,*options] + (let [options (stack ,*options) + uniques (set.of_stack text.hash options)] + (n.= (stack.size options) + (set.size uniques))))) + ))) diff --git a/stdlib/source/test/lux/compiler/language/lux.lux b/stdlib/source/test/lux/compiler/language/lux.lux index 288700e4a5..4979b31957 100644 --- a/stdlib/source/test/lux/compiler/language/lux.lux +++ b/stdlib/source/test/lux/compiler/language/lux.lux @@ -41,13 +41,13 @@ ["[0]" / ["[1][0]" syntax] ... ["[1][0]" analysis] - ... ["[1][0]" synthesis] + ["[1][0]" synthesis] + ["[1][0]" translation] ["[1][0]" phase ... ["[1][0]" extension] ... ["[1][0]" analysis] ... ["[1][0]" synthesis] - ] - ["[1][0]" translation]]) + ]]) (the any_equivalence (Equivalence Any) @@ -140,6 +140,7 @@ (same? version.latest (its signature.#version it))))) /syntax.test - /phase.test + /synthesis.test /translation.test + /phase.test ))) diff --git a/stdlib/source/test/lux/compiler/language/lux/analysis/coverage.lux b/stdlib/source/test/lux/compiler/language/lux/analysis/coverage.lux index 11c0bc327d..512722a4a5 100644 --- a/stdlib/source/test/lux/compiler/language/lux/analysis/coverage.lux +++ b/stdlib/source/test/lux/compiler/language/lux/analysis/coverage.lux @@ -5,7 +5,7 @@ [library [lux (.except Pattern) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]]] [control @@ -68,7 +68,7 @@ whens (random.set n.hash whens ..random_tag)] (|> whens set.stack - (monad.each ! (function (_ when) (by ! each (|>> [when]) again))) + (stack.each' ! (function (_ when) (by ! each (|>> [when]) again))) (by ! each (dictionary.of_stack n.hash)))) ) (random.and again again) diff --git a/stdlib/source/test/lux/compiler/language/lux/analysis/module.lux b/stdlib/source/test/lux/compiler/language/lux/analysis/module.lux index 0ec89549a8..cc1923b601 100644 --- a/stdlib/source/test/lux/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/test/lux/compiler/language/lux/analysis/module.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" pipe]] [error diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/extension.lux b/stdlib/source/test/lux/compiler/language/lux/phase/extension.lux index 50b20cc833..e6f8de621c 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/extension.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]] ["[0]" hash @@ -169,7 +169,7 @@ (function (_ @self phase archive inputs) (let [! phase.monad] (|> inputs - (monad.each ! (phase archive)) + (stack.each' ! (phase archive)) (by ! each (stack#mix n.+ 0))))))] (|> (do phase.monad [_ (/.install extender extension handler)] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/compiler/language/lux/phase/extension/analysis/lux.lux index ca614d790e..7911615489 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/extension/analysis/lux.lux @@ -5,7 +5,7 @@ [library [lux (.except i64 integer) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] ["r" math/random (.only Random)] [control [io (.only IO)] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/function.lux index 789b2084ba..e99f6b6a63 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/function.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] [data diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/primitive.lux b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/primitive.lux index b059e2a0bd..2ed5eddb92 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/primitive.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/primitive.lux @@ -4,7 +4,8 @@ (.using [library [lux (.except primitive) - [abstract ["[0]" monad (.only do)]] + [abstract + [monad (.only do)]] [control ["[0]" pipe]] [error diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/structure.lux b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/structure.lux index a0f72a93c3..f9b2d00997 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/structure.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/structure.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [data ["%" text/injection]] ["r" math/random (.only Random)] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/variable.lux index ac8ca8d434..667b6d1ad3 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/variable.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [error ["[0]" try]] [data diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/when.lux b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/when.lux index 54fd5f676f..f9296d7bee 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/when.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/synthesis/when.lux @@ -6,7 +6,7 @@ [lux (.except) [abstract [hash (.only Hash)] - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" pipe]] [error diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/complex.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/complex.lux index 13b12a2ff2..a2c6184ca1 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/complex.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/complex.lux @@ -120,9 +120,9 @@ (do phase.monad [_ (translation.set_buffer translation.empty_buffer) it (/.tuple phase archive.empty - (stack (synthesis.bit provenance.dummy expected_bit) - (synthesis.i64 provenance.dummy expected_i64) - (synthesis.text provenance.dummy expected_text)))] + (list (synthesis.bit provenance.dummy expected_bit) + (synthesis.i64 provenance.dummy expected_i64) + (synthesis.text provenance.dummy expected_text)))] (in (when (by host evaluate [{.#None} it]) {try.#Success actual} (let [[actual_bit actual_i64 actual_text] (as Tuple/3 actual)] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function.lux index 479790754f..2abd05823b 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function.lux @@ -13,7 +13,7 @@ ["[0]" function] [data [collection - ["[0]" stack]]] + ["[0]" list]]] [math ["[0]" random (.only Random)] [number @@ -81,7 +81,7 @@ (do phase.monad [_ (translation.set_buffer translation.empty_buffer) it (/.abstraction next archive - [(stack) 1 (synthesis.i64 @ expected_i64)])] + [(list) 1 (synthesis.i64 @ expected_i64)])] (in (|> it [{.#None}] (by host evaluate) @@ -102,8 +102,8 @@ (do phase.monad [_ (translation.set_buffer translation.empty_buffer) it (/.reification next archive - [(synthesis.abstraction @ [(stack) arity (synthesis.i64 @ expected_i64)]) - (stack.repeated arity (synthesis.bit @ expected_bit))])] + [(synthesis.abstraction @ [(list) arity (synthesis.i64 @ expected_i64)]) + (list.repeated arity (synthesis.bit @ expected_bit))])] (in (|> it [{.#None}] (by host evaluate) @@ -126,20 +126,20 @@ inner_abstraction (is synthesis.Term (<| (synthesis.abstraction @) - [(stack) inner_arity + [(list) inner_arity (synthesis.i64 @ expected_i64)])) outer_abstraction (is synthesis.Term (<| (synthesis.abstraction @) - [(stack) outer_arity + [(list) outer_arity inner_abstraction])) outer_application (is synthesis.Term (<| (synthesis.reification @) [outer_abstraction - (stack.repeated outer_arity (synthesis.bit @ expected_bit))])) + (list.repeated outer_arity (synthesis.bit @ expected_bit))])) inner_application (is synthesis.Term (<| (synthesis.reification @) [outer_application - (stack.repeated inner_arity (synthesis.bit @ expected_bit))]))] + (list.repeated inner_arity (synthesis.bit @ expected_bit))]))] it (next archive inner_application)] (in (|> it [{.#None}] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/abstract.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/abstract.lux index 97ec33a906..6c84816f90 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/abstract.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/abstract.lux @@ -100,7 +100,7 @@ [_ (translation.set_buffer translation.empty_buffer) it (next archive (<| (synthesis.abstraction @) - [(stack) 1 (synthesis.i64 @ expected_i64)]))] + [(list) 1 (synthesis.i64 @ expected_i64)]))] (in (|> it [{.#None}] (by host evaluate) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/count.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/count.lux index e64b8994e8..c1a0ce2518 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/count.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/count.lux @@ -14,7 +14,7 @@ [data ["[0]" bit] [collection - ["[0]" stack]]] + ["[0]" list]]] [math ["[0]" random (.only Random)] [number @@ -95,7 +95,7 @@ (do phase.monad [_ (translation.set_buffer translation.empty_buffer) it (next archive (<| (synthesis.abstraction @) - [(stack) arity (synthesis.i64 @ expected_i64)]))] + [(list) arity (synthesis.i64 @ expected_i64)]))] (in (|> (all !.composite it /.value @@ -119,8 +119,8 @@ [_ (translation.set_buffer translation.empty_buffer) it (next archive (<| (synthesis.reification @) [(<| (synthesis.abstraction @) - [(stack) arity (synthesis.i64 @ expected_i64)]) - (stack.repeated partial_application (synthesis.bit @ expected_bit))]))] + [(list) arity (synthesis.i64 @ expected_i64)]) + (list.repeated partial_application (synthesis.bit @ expected_bit))]))] (in (|> (all !.composite it (!.checkcast abstract.class) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux index 7bd9d90971..ae6343d7b8 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux @@ -69,9 +69,9 @@ [_ (translation.set_buffer translation.empty_buffer) .let [term (is synthesis.Term (<| (synthesis.abstraction @) - [(stack) 1] + [(list) 1] (synthesis.abstraction @) - [(stack (synthesis.local @ 1)) 1] + [(list (synthesis.local @ 1)) 1] (synthesis.foreign @ 0)))] it (next archive term)] (in (|> it diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux index c3d0866312..5c214b7bfc 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/field/variable/partial.lux @@ -67,7 +67,7 @@ (do phase.monad [_ (translation.set_buffer translation.empty_buffer) it (next archive (<| (synthesis.abstraction @) - [(stack) 2] + [(list) 2] (synthesis.local @ 1)))] (in (|> it [{.#None}] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux index 761836031b..c919f77b6b 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/apply.lux @@ -62,9 +62,9 @@ [_ (translation.set_buffer translation.empty_buffer) parameter (next archive (synthesis.i64 @ expected_i64)) actual (next archive (<| (synthesis.reification @) - [(synthesis.abstraction @ [(stack) 2 (synthesis.local @ 1)]) - (stack (synthesis.i64 @ expected_i64) - (synthesis.i64 @ dummy_i64))]))] + [(synthesis.abstraction @ [(list) 2 (synthesis.local @ 1)]) + (list (synthesis.i64 @ expected_i64) + (synthesis.i64 @ dummy_i64))]))] (in (|> actual [{.#None}] (by host evaluate) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux index 6262d33522..00c1ece4d8 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux @@ -85,7 +85,7 @@ (do phase.monad [_ (translation.set_buffer translation.empty_buffer) parameter (next archive (synthesis.i64 @ expected_i64)) - function (next archive (synthesis.abstraction @ [(stack) 1 (synthesis.local @ 1)])) + function (next archive (synthesis.abstraction @ [(list) 1 (synthesis.local @ 1)])) it (|> function [{.#None}] (by host evaluate) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/reset.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/reset.lux index 0fdce335c8..9a138174f2 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/reset.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/function/method/reset.lux @@ -84,8 +84,8 @@ [_ (translation.set_buffer translation.empty_buffer) parameter (next archive (synthesis.i64 @ expected_i64)) partially_applied_function (next archive (<| (synthesis.reification @) - [(synthesis.abstraction @ [(stack) 2 (synthesis.local @ 1)]) - (stack (synthesis.i64 @ dummy_i64))])) + [(synthesis.abstraction @ [(list) 2 (synthesis.local @ 1)]) + (list (synthesis.i64 @ dummy_i64))])) it (|> partially_applied_function [{.#None}] (by host evaluate) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/loop.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/loop.lux index 20bc1df75b..e92fd28464 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/loop.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/loop.lux @@ -60,7 +60,7 @@ (do phase.monad [_ (translation.set_buffer translation.empty_buffer) it (/.tail_recursion next archive - [0 (stack) (synthesis.i64 @ expected_i64)])] + [0 (list) (synthesis.i64 @ expected_i64)])] (in (|> it [{.#None}] (by host evaluate) @@ -80,7 +80,7 @@ (do phase.monad [_ (translation.set_buffer translation.empty_buffer) it (/.tail_recursion next archive - [0 (stack (synthesis.i64 @ expected_i64)) (synthesis.local @ 0)])] + [0 (list (synthesis.i64 @ expected_i64)) (synthesis.local @ 0)])] (in (|> it [{.#None}] (by host evaluate) @@ -102,13 +102,13 @@ [_ (translation.set_buffer translation.empty_buffer) _ runtime.translation it (/.tail_recursion next archive - [0 (stack (synthesis.i64 @ dummy_i64)) + [0 (list (synthesis.i64 @ dummy_i64)) (<| (synthesis.when @) [synthesis.#input (synthesis.local @ 0) synthesis.#output {synthesis.#Alt {synthesis.#I64_Fork [[synthesis.#when dummy_i64 - synthesis.#then {synthesis.#Then (synthesis.tail_iteration @ (stack (synthesis.i64 @ expected_i64)))}] - (stack)]} + synthesis.#then {synthesis.#Then (synthesis.tail_iteration @ (list (synthesis.i64 @ expected_i64)))}] + (list)]} {synthesis.#Then (synthesis.local @ 0)}}])])] (in (|> it [{.#None}] diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/reference.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/reference.lux index 1faf6becdb..97c7c2277e 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/reference.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/reference.lux @@ -12,7 +12,7 @@ ["[0]" try (.use "[1]#[0]" functor)]] [data [collection - ["[0]" stack (.use "[1]#[0]" monoid)]]] + ["[0]" list (.use "[1]#[0]" monoid)]]] [math ["[0]" random (.only Random)] [number @@ -70,11 +70,11 @@ [_ (translation.set_buffer translation.empty_buffer) it (next archive (<| (synthesis.reification @) [(<| (synthesis.abstraction @) - [(stack) arity (synthesis.local @ local)]) - (all stack#composite - (stack.repeated before (synthesis.i64 @ dummy)) - (stack (synthesis.i64 @ expected)) - (stack.repeated after (synthesis.i64 @ dummy)))]))] + [(list) arity (synthesis.local @ local)]) + (all list#composite + (list.repeated before (synthesis.i64 @ dummy)) + (list (synthesis.i64 @ expected)) + (list.repeated after (synthesis.i64 @ dummy)))]))] (in (|> it [{.#None}] (by host evaluate) diff --git a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/when.lux b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/when.lux index 946e6ba775..3909658dfc 100644 --- a/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/when.lux +++ b/stdlib/source/test/lux/compiler/language/lux/phase/translation/jvm/when.lux @@ -12,7 +12,7 @@ ["[0]" try (.use "[1]#[0]" functor)]] [data [collection - ["[0]" stack (.use "[1]#[0]" monoid functor)]]] + ["[0]" list (.use "[1]#[0]" monoid functor)]]] [math ["[0]" random (.only Random)] [number @@ -177,33 +177,33 @@ .let [[_ host] (io.value host.host) state (is runtime.State (translation.state host module))] - .let [middle_tuple (all stack#composite - (stack.repeated left_siblings (synthesis.i64 @ dummy_i64)) - (stack (synthesis.i64 @ expected_i64)) - (stack.repeated right_siblings (synthesis.i64 @ dummy_i64))) + .let [middle_tuple (all list#composite + (list.repeated left_siblings (synthesis.i64 @ dummy_i64)) + (list (synthesis.i64 @ expected_i64)) + (list.repeated right_siblings (synthesis.i64 @ dummy_i64))) middle_access (is Member [left_siblings #0]) - right_tuple (all stack#composite - (stack.repeated left_siblings (synthesis.i64 @ dummy_i64)) - (stack (synthesis.i64 @ expected_i64))) + right_tuple (all list#composite + (list.repeated left_siblings (synthesis.i64 @ dummy_i64)) + (list (synthesis.i64 @ expected_i64))) right_access (is Member [(-- left_siblings) #1]) - [nested_tuple nested_access] (is [(Stack synthesis.Term) Member] + [nested_tuple nested_access] (is [(List synthesis.Term) Member] (if nested_choice [middle_tuple middle_access] [right_tuple right_access])) - nested_tuple (is (Stack synthesis.Term) - (all stack#composite - (stack.repeated right_siblings (synthesis.i64 @ dummy_i64)) - (stack (synthesis.tuple @ nested_tuple))))] + nested_tuple (is (List synthesis.Term) + (all list#composite + (list.repeated right_siblings (synthesis.i64 @ dummy_i64)) + (list (synthesis.tuple @ nested_tuple))))] middle! (<| (phase.value state) (do phase.monad [_ (translation.set_buffer translation.empty_buffer) _ runtime.translation it (/.its next archive - [(stack middle_access) + [(list middle_access) (synthesis.tuple @ middle_tuple)])] (in (|> it [{.#None}] @@ -216,7 +216,7 @@ [_ (translation.set_buffer translation.empty_buffer) _ runtime.translation it (/.its next archive - [(stack right_access) + [(list right_access) (synthesis.tuple @ right_tuple)])] (in (|> it [{.#None}] @@ -229,8 +229,8 @@ [_ (translation.set_buffer translation.empty_buffer) _ runtime.translation it (/.its next archive - [(stack [(-- right_siblings) #1] - nested_access) + [(list [(-- right_siblings) #1] + nested_access) (synthesis.tuple @ nested_tuple)])] (in (|> it [{.#None}] @@ -335,7 +335,7 @@ it (/.when next archive [(synthesis.i64 @ dummy_i64) {synthesis.#I64_Fork [[dummy_i64 {synthesis.#Then (synthesis.i64 @ expected_i64)}] - (stack)]}])] + (list)]}])] (in (|> it [{.#None}] (by host evaluate) @@ -349,7 +349,7 @@ it (/.when next archive [(synthesis.f64 @ expected_f64) {synthesis.#F64_Fork [[expected_f64 {synthesis.#Then (synthesis.i64 @ expected_i64)}] - (stack)]}])] + (list)]}])] (in (|> it [{.#None}] (by host evaluate) @@ -363,7 +363,7 @@ it (/.when next archive [(synthesis.text @ expected_text) {synthesis.#Text_Fork [[expected_text {synthesis.#Then (synthesis.i64 @ expected_i64)}] - (stack)]}])] + (list)]}])] (in (|> it [{.#None}] (by host evaluate) @@ -378,7 +378,7 @@ [(synthesis.i64 @ dummy_i64) {synthesis.#Alt {synthesis.#I64_Fork [[expected_i64 {synthesis.#Then (synthesis.i64 @ expected_i64)}] - (stack)]} + (list)]} {synthesis.#Then (synthesis.i64 @ expected_i64)}}])] (in (|> it [{.#None}] @@ -386,7 +386,7 @@ (try#each (|>> (as I64) (i64.= expected_i64))) (try.else false))))) - .let [access!|member (is (-> Member (Stack I64) + .let [access!|member (is (-> Member (List I64) Bit) (function (_ member tuple) (<| (try.else false) @@ -395,7 +395,7 @@ [_ (translation.set_buffer translation.empty_buffer) _ runtime.translation it (/.when next archive - [(synthesis.tuple @ (stack#each (|>> (synthesis.i64 @)) tuple)) + [(synthesis.tuple @ (list#each (|>> (synthesis.i64 @)) tuple)) {synthesis.#Seq {synthesis.#Access {access.#Member member}} {synthesis.#Seq @@ -428,10 +428,10 @@ (try#each (|>> (as I64) (i64.= expected_i64))) (try.else false))))))) - access! (and (access!|member [lefts false] (stack#composite (stack.repeated lefts dummy_i64) - (stack expected_i64 dummy_i64))) - (access!|member [lefts true] (stack#composite (stack.repeated lefts dummy_i64) - (stack dummy_i64 expected_i64))) + access! (and (access!|member [lefts false] (list#composite (list.repeated lefts dummy_i64) + (list expected_i64 dummy_i64))) + (access!|member [lefts true] (list#composite (list.repeated lefts dummy_i64) + (list dummy_i64 expected_i64))) (access!|side [lefts false]) (access!|side [lefts true]))]] diff --git a/stdlib/source/test/lux/compiler/language/lux/synthesis.lux b/stdlib/source/test/lux/compiler/language/lux/synthesis.lux index 175bdbd758..279a4ec372 100644 --- a/stdlib/source/test/lux/compiler/language/lux/synthesis.lux +++ b/stdlib/source/test/lux/compiler/language/lux/synthesis.lux @@ -14,6 +14,7 @@ ["[0]" bit] ["[0]" text] [collection + ["[0]" list (.use "[1]#[0]" functor)] ["[0]" stack (.use "[1]#[0]" functor)]]] [math ["[0]" random (.only Random)] @@ -25,196 +26,199 @@ ["^" pattern] ["[0]" template]] [meta - ["[0]" name] - [compiler - [reference (.only) - ["[0]" variable (.only Variable)]] - [language - [lux - [analysis (.only Environment)] - ["[0]" synthesis (.only Synthesis)]]]]] + ["[0]" name]] + [compiler + [reference (.only) + ["[0]" variable (.only Variable)]] + [language + [lux + [analysis (.only Environment)]]]] [test ["_" property (.only Test)]]]] + [\\library + ["[0]" /]] ["[0]" \\projection] ["[0]" / ["[1][0]" simple] ["[1][0]" access]]) -(the !expect - (template.macro (_ ) - [(when - - true - - _ - false)])) +... (the !expect +... (template.macro (_ ) +... [(when +... +... true -(the random_constant - (Random Name) - (random.and (random.unicode 1) - (random.unicode 1))) +... _ +... false)])) -(the random_variable - (Random Variable) - (random.or random.natural - random.natural)) +... (the random_constant +... (Random Name) +... (random.and (random.unicode 1) +... (random.unicode 1))) -(the random_environment - (Random (Environment Synthesis)) - (do [! random.monad] - [size (by ! each (n.% 5) random.natural)] - (|> ..random_variable - (by ! each (|>> synthesis.variable)) - (random.stack size)))) +... (the random_variable +... (Random Variable) +... (random.or random.natural +... random.natural)) -(the simple - Test - (`` (all _.and - (,, (template.with [ ] - [(do [! random.monad] - [expected - dummy (|> (random.only (|>> (by = expected) not)))] - (all _.and - (_.coverage [] - (|> (\\projection.value (stack ( expected))) - (!expect (^.multi {try.#Success actual} - (by = expected actual))))) - (_.coverage [] - (and (|> (\\projection.value ( expected) (stack ( expected))) - (!expect {try.#Success _})) - (|> (\\projection.value ( expected) (stack ( dummy))) - (!expect (^.multi {try.#Failure error} - (exception.is? \\projection.cannot_parse error)))))) - ))] +... (the random_environment +... (Random (Environment /.Term)) +... (do [! random.monad] +... [size (by ! each (n.% 5) random.natural)] +... (|> ..random_variable +... (by ! each (|>> /.variable)) +... (random.stack size) +... (by ! each list.of_stack)))) - [\\projection.bit \\projection.this_bit random.bit synthesis.bit bit.equivalence] - [\\projection.i64 \\projection.this_i64 random.i64 synthesis.i64 i64.equivalence] - [\\projection.f64 \\projection.this_f64 random.unit_decimal synthesis.f64 decimal.equivalence] - [\\projection.text \\projection.this_text (random.unicode 1) synthesis.text text.equivalence] - [\\projection.local \\projection.this_local random.natural synthesis.local n.equivalence] - [\\projection.foreign \\projection.this_foreign random.natural synthesis.foreign n.equivalence] - [\\projection.constant \\projection.this_constant ..random_constant synthesis.constant name.equivalence] - )) - ))) +... (the simple +... Test +... (`` (all _.and +... (,, (template.with [ ] +... [(do [! random.monad] +... [expected +... dummy (|> (random.only (|>> (by = expected) not)))] +... (all _.and +... (_.coverage [] +... (|> (\\projection.value (stack ( expected))) +... (!expect (^.multi {try.#Success actual} +... (by = expected actual))))) +... (_.coverage [] +... (and (|> (\\projection.value ( expected) (stack ( expected))) +... (!expect {try.#Success _})) +... (|> (\\projection.value ( expected) (stack ( dummy))) +... (!expect (^.multi {try.#Failure error} +... (exception.is? \\projection.cannot_parse error)))))) +... ))] -(the complex - Test - (all _.and - (do [! random.monad] - [expected_bit random.bit - expected_i64 random.i64 - expected_f64 random.unit_decimal - expected_text (random.unicode 1)] - (_.coverage [\\projection.tuple] - (and (|> (\\projection.value (\\projection.tuple (all <>.and \\projection.bit \\projection.i64 \\projection.f64 \\projection.text)) - (stack (synthesis.tuple (stack (synthesis.bit expected_bit) - (synthesis.i64 expected_i64) - (synthesis.f64 expected_f64) - (synthesis.text expected_text))))) - (!expect (^.multi {try.#Success [actual_bit actual_i64 actual_f64 actual_text]} - (and (by bit.equivalence = expected_bit actual_bit) - (by i64.equivalence = expected_i64 actual_i64) - (by decimal.equivalence = expected_f64 actual_f64) - (by text.equivalence = expected_text actual_text))))) - (|> (\\projection.value (\\projection.tuple (all <>.and \\projection.bit \\projection.i64 \\projection.f64 \\projection.text)) - (stack (synthesis.text expected_text))) - (!expect (^.multi {try.#Failure error} - (exception.is? \\projection.cannot_parse error))))))) - (do [! random.monad] - [arity random.natural - expected_environment ..random_environment - expected_body (random.unicode 1)] - (_.coverage [\\projection.function] - (and (|> (\\projection.value (\\projection.function arity \\projection.text) - (stack (synthesis.abstraction [expected_environment arity (synthesis.text expected_body)]))) - (!expect (^.multi {try.#Success [actual_environment actual_body]} - (and (by (stack.equivalence synthesis.equivalence) = - expected_environment - actual_environment) - (by text.equivalence = expected_body actual_body))))) - (|> (\\projection.value (\\projection.function arity \\projection.text) - (stack (synthesis.text expected_body))) - (!expect (^.multi {try.#Failure error} - (exception.is? \\projection.cannot_parse error))))))) - (do [! random.monad] - [arity random.natural - expected_environment ..random_environment - expected_body (random.unicode 1)] - (_.coverage [\\projection.wrong_arity] - (|> (\\projection.value (\\projection.function (++ arity) \\projection.text) - (stack (synthesis.abstraction [expected_environment arity (synthesis.text expected_body)]))) - (!expect (^.multi {try.#Failure error} - (exception.is? \\projection.wrong_arity error)))))) - (do [! random.monad] - [arity (by ! each (|>> (n.% 10) ++) random.natural) - expected_offset random.natural - expected_inits (random.stack arity random.bit) - expected_body (random.unicode 1)] - (_.coverage [\\projection.loop] - (and (|> (\\projection.value (\\projection.loop (<>.many \\projection.bit) \\projection.text) - (stack (synthesis.scope [expected_offset - (stack#each (|>> synthesis.bit) expected_inits) - (synthesis.text expected_body)]))) - (!expect (^.multi {try.#Success [actual_offset actual_inits actual_body]} - (and (by n.equivalence = expected_offset actual_offset) - (by (stack.equivalence bit.equivalence) = - expected_inits - actual_inits) - (by text.equivalence = expected_body actual_body))))) - (|> (\\projection.value (\\projection.loop (<>.many \\projection.bit) \\projection.text) - (stack (synthesis.text expected_body))) - (!expect (^.multi {try.#Failure error} - (exception.is? \\projection.cannot_parse error))))))) - )) +... [\\projection.bit \\projection.this_bit random.bit /.bit bit.equivalence] +... [\\projection.i64 \\projection.this_i64 random.i64 /.i64 i64.equivalence] +... [\\projection.f64 \\projection.this_f64 random.unit_decimal /.f64 decimal.equivalence] +... [\\projection.text \\projection.this_text (random.unicode 1) /.text text.equivalence] +... [\\projection.local \\projection.this_local random.natural /.local n.equivalence] +... [\\projection.foreign \\projection.this_foreign random.natural /.foreign n.equivalence] +... [\\projection.constant \\projection.this_constant ..random_constant /.constant name.equivalence] +... )) +... ))) -(the \\projection - Test - (<| (_.covering \\projection._) - (_.for [\\projection.Projection]) - (all _.and - (do [! random.monad] - [expected (by ! each (|>> synthesis.i64) random.i64)] - (_.coverage [\\projection.value \\projection.any] - (|> (\\projection.value \\projection.any (stack expected)) - (!expect (^.multi {try.#Success actual} - (by synthesis.equivalence = expected actual)))))) - (_.coverage [\\projection.empty_input] - (|> (\\projection.value \\projection.any (stack)) - (!expect (^.multi {try.#Failure error} - (exception.is? \\projection.empty_input error))))) - (do [! random.monad] - [expected (by ! each (|>> synthesis.i64) random.i64)] - (_.coverage [\\projection.unconsumed_input] - (|> (\\projection.value \\projection.any (stack expected expected)) - (!expect (^.multi {try.#Failure error} - (exception.is? \\projection.unconsumed_input error)))))) - (do [! random.monad] - [dummy (by ! each (|>> synthesis.i64) random.i64)] - (_.coverage [\\projection.end \\projection.expected_empty_input] - (and (|> (\\projection.value \\projection.end (stack)) - (!expect {try.#Success _})) - (|> (\\projection.value \\projection.end (stack dummy)) - (!expect (^.multi {try.#Failure error} - (exception.is? \\projection.expected_empty_input error))))))) - (do [! random.monad] - [dummy (by ! each (|>> synthesis.i64) random.i64)] - (_.coverage [\\projection.end?] - (and (|> (\\projection.value \\projection.end? (stack)) - (!expect {try.#Success .true})) - (|> (\\projection.value (<>.before \\projection.any \\projection.end?) (stack dummy)) - (!expect {try.#Success .false}))))) - (_.for [\\projection.cannot_parse] - (all _.and - ..simple - ..complex - )) - ))) +... (the complex +... Test +... (all _.and +... (do [! random.monad] +... [expected_bit random.bit +... expected_i64 random.i64 +... expected_f64 random.unit_decimal +... expected_text (random.unicode 1)] +... (_.coverage [\\projection.tuple] +... (and (|> (\\projection.value (\\projection.tuple (all <>.and \\projection.bit \\projection.i64 \\projection.f64 \\projection.text)) +... (stack (/.tuple (stack (/.bit expected_bit) +... (/.i64 expected_i64) +... (/.f64 expected_f64) +... (/.text expected_text))))) +... (!expect (^.multi {try.#Success [actual_bit actual_i64 actual_f64 actual_text]} +... (and (by bit.equivalence = expected_bit actual_bit) +... (by i64.equivalence = expected_i64 actual_i64) +... (by decimal.equivalence = expected_f64 actual_f64) +... (by text.equivalence = expected_text actual_text))))) +... (|> (\\projection.value (\\projection.tuple (all <>.and \\projection.bit \\projection.i64 \\projection.f64 \\projection.text)) +... (stack (/.text expected_text))) +... (!expect (^.multi {try.#Failure error} +... (exception.is? \\projection.cannot_parse error))))))) +... (do [! random.monad] +... [arity random.natural +... expected_environment ..random_environment +... expected_body (random.unicode 1)] +... (_.coverage [\\projection.function] +... (and (|> (\\projection.value (\\projection.function arity \\projection.text) +... (stack (/.abstraction [expected_environment arity (/.text expected_body)]))) +... (!expect (^.multi {try.#Success [actual_environment actual_body]} +... (and (by (stack.equivalence /.equivalence) = +... expected_environment +... actual_environment) +... (by text.equivalence = expected_body actual_body))))) +... (|> (\\projection.value (\\projection.function arity \\projection.text) +... (stack (/.text expected_body))) +... (!expect (^.multi {try.#Failure error} +... (exception.is? \\projection.cannot_parse error))))))) +... (do [! random.monad] +... [arity random.natural +... expected_environment ..random_environment +... expected_body (random.unicode 1)] +... (_.coverage [\\projection.wrong_arity] +... (|> (\\projection.value (\\projection.function (++ arity) \\projection.text) +... (stack (/.abstraction [expected_environment arity (/.text expected_body)]))) +... (!expect (^.multi {try.#Failure error} +... (exception.is? \\projection.wrong_arity error)))))) +... (do [! random.monad] +... [arity (by ! each (|>> (n.% 10) ++) random.natural) +... expected_offset random.natural +... expected_inits (random.stack arity random.bit) +... expected_body (random.unicode 1)] +... (_.coverage [\\projection.loop] +... (and (|> (\\projection.value (\\projection.loop (<>.many \\projection.bit) \\projection.text) +... (stack (/.scope [expected_offset +... (stack#each (|>> /.bit) expected_inits) +... (/.text expected_body)]))) +... (!expect (^.multi {try.#Success [actual_offset actual_inits actual_body]} +... (and (by n.equivalence = expected_offset actual_offset) +... (by (stack.equivalence bit.equivalence) = +... expected_inits +... actual_inits) +... (by text.equivalence = expected_body actual_body))))) +... (|> (\\projection.value (\\projection.loop (<>.many \\projection.bit) \\projection.text) +... (stack (/.text expected_body))) +... (!expect (^.multi {try.#Failure error} +... (exception.is? \\projection.cannot_parse error))))))) +... )) + +... (the \\projection +... Test +... (<| (_.covering \\projection._) +... (_.for [\\projection.Projection]) +... (all _.and +... (do [! random.monad] +... [expected (by ! each (|>> /.i64) random.i64)] +... (_.coverage [\\projection.value \\projection.any] +... (|> (\\projection.value \\projection.any (stack expected)) +... (!expect (^.multi {try.#Success actual} +... (by /.equivalence = expected actual)))))) +... (_.coverage [\\projection.empty_input] +... (|> (\\projection.value \\projection.any (stack)) +... (!expect (^.multi {try.#Failure error} +... (exception.is? \\projection.empty_input error))))) +... (do [! random.monad] +... [expected (by ! each (|>> /.i64) random.i64)] +... (_.coverage [\\projection.unconsumed_input] +... (|> (\\projection.value \\projection.any (stack expected expected)) +... (!expect (^.multi {try.#Failure error} +... (exception.is? \\projection.unconsumed_input error)))))) +... (do [! random.monad] +... [dummy (by ! each (|>> /.i64) random.i64)] +... (_.coverage [\\projection.end \\projection.expected_empty_input] +... (and (|> (\\projection.value \\projection.end (stack)) +... (!expect {try.#Success _})) +... (|> (\\projection.value \\projection.end (stack dummy)) +... (!expect (^.multi {try.#Failure error} +... (exception.is? \\projection.expected_empty_input error))))))) +... (do [! random.monad] +... [dummy (by ! each (|>> /.i64) random.i64)] +... (_.coverage [\\projection.end?] +... (and (|> (\\projection.value \\projection.end? (stack)) +... (!expect {try.#Success .true})) +... (|> (\\projection.value (<>.before \\projection.any \\projection.end?) (stack dummy)) +... (!expect {try.#Success .false}))))) +... (_.for [\\projection.cannot_parse] +... (all _.and +... ..simple +... ..complex +... )) +... ))) (the .public test Test - (all _.and - ..\\projection + (<| (_.covering /._) + (all _.and + ... ..\\projection - /simple.test - /access.test - )) + /simple.test + /access.test + ))) diff --git a/stdlib/source/test/lux/compiler/language/lux/synthesis/access.lux b/stdlib/source/test/lux/compiler/language/lux/synthesis/access.lux index bd186c8275..eb4f5e1ce8 100644 --- a/stdlib/source/test/lux/compiler/language/lux/synthesis/access.lux +++ b/stdlib/source/test/lux/compiler/language/lux/synthesis/access.lux @@ -8,11 +8,13 @@ ["_" property (.only Test)]]]] ["[0]" / ["[1][0]" side] - ["[1][0]" member]]) + ["[1][0]" member] + ["[1][0]" item]]) (the .public test Test (all _.and /side.test /member.test + /item.test )) diff --git a/stdlib/source/test/lux/compiler/language/lux/synthesis/access/item.lux b/stdlib/source/test/lux/compiler/language/lux/synthesis/access/item.lux new file mode 100644 index 0000000000..e5a1bde992 --- /dev/null +++ b/stdlib/source/test/lux/compiler/language/lux/synthesis/access/item.lux @@ -0,0 +1,46 @@ +... 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]" hash + ["[1]T" \\test]]] + [data + ["[0]" bit] + ["[0]" text]] + [meta + ["[0]" static]] + [math + ["[0]" random (.only Random)]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(the .public random + (Random /.Item) + random.natural) + +(the .public test + Test + (<| (_.covering /._) + (_.for [/.Item]) + (do [! random.monad] + [left ..random + right ..random] + (all _.and + (_.for [/.equivalence /.=] + (static.when (same? /.equivalence /.=) + (equivalenceT.spec /.equivalence ..random))) + (_.for [/.hash] + (hashT.spec /.hash ..random)) + + (_.coverage [/.as_text] + (bit.= (by /.equivalence = left right) + (text.= (/.as_text left) (/.as_text right)))) + )))) diff --git a/stdlib/source/test/lux/compiler/language/lux/synthesis/access/member.lux b/stdlib/source/test/lux/compiler/language/lux/synthesis/access/member.lux index 66549bbd3b..bcd9c6e1da 100644 --- a/stdlib/source/test/lux/compiler/language/lux/synthesis/access/member.lux +++ b/stdlib/source/test/lux/compiler/language/lux/synthesis/access/member.lux @@ -23,7 +23,7 @@ (the .public random (Random /.Member) (all random.and - random.nat + random.natural random.bit )) diff --git a/stdlib/source/test/lux/compiler/language/lux/synthesis/access/side.lux b/stdlib/source/test/lux/compiler/language/lux/synthesis/access/side.lux index 093d8faa3f..6d5bb8da8b 100644 --- a/stdlib/source/test/lux/compiler/language/lux/synthesis/access/side.lux +++ b/stdlib/source/test/lux/compiler/language/lux/synthesis/access/side.lux @@ -23,7 +23,7 @@ (the .public random (Random /.Side) (all random.and - random.nat + random.natural random.bit )) diff --git a/stdlib/source/test/lux/concurrency/event.lux b/stdlib/source/test/lux/concurrency/event.lux index e9156bcd62..3ed6a38a00 100644 --- a/stdlib/source/test/lux/concurrency/event.lux +++ b/stdlib/source/test/lux/concurrency/event.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" io]] [error @@ -38,7 +38,7 @@ (io.value (do [! io.monad] [_ (|> (in []) (stack.repeated expected_events) - (monad.each ! (schedule! 0))) + (stack.each' ! (schedule! 0))) events_processed value] (in (|> events_processed (try#each (n.= expected_events)) @@ -49,7 +49,7 @@ [_ (in [])] (schedule! 0 (in []))) (stack.repeated expected_events) - (monad.each ! (schedule! 0))) + (stack.each' ! (schedule! 0))) events_processed value] (in (|> events_processed (try#each (n.= (n.* 2 expected_events))) diff --git a/stdlib/source/test/lux/concurrency/semaphore.lux b/stdlib/source/test/lux/concurrency/semaphore.lux index ffbe7a2f74..7cb1d49b28 100644 --- a/stdlib/source/test/lux/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/concurrency/semaphore.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" enum]] [control ["[0]" io] @@ -58,7 +58,7 @@ [initial_open_positions (|> random.natural (by ! each (|>> (n.% 10) (n.major 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do [! future.monad] - [_ (monad.each ! /.wait! (stack.repeated initial_open_positions semaphore)) + [_ (stack.each' ! /.wait! (stack.repeated initial_open_positions semaphore)) it (future.within ..delay (/.wait! semaphore))] (unit.coverage [/.wait!] (when it @@ -71,7 +71,7 @@ [initial_open_positions (|> random.natural (by ! each (|>> (n.% 10) (n.major 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do [! future.monad] - [_ (monad.each ! /.wait! (stack.repeated initial_open_positions semaphore)) + [_ (stack.each' ! /.wait! (stack.repeated initial_open_positions semaphore)) .let [block (/.wait! semaphore)] result/0 (future.within ..delay block) open_positions (/.signal! semaphore) @@ -111,7 +111,7 @@ io.io future.soon (do [! io.monad] - [_ (<| (monad.all !) + [_ (<| (stack.all' !) (stack.repeated repetitions) (atom.update! (|>> (text "A")) resource))] (in []))) @@ -119,7 +119,7 @@ io.io future.soon (do [! io.monad] - [_ (<| (monad.all !) + [_ (<| (stack.all' !) (stack.repeated repetitions) (atom.update! (|>> (text "B")) resource))] (in [])))]] @@ -173,7 +173,7 @@ (exec (io.value (atom.update! (|>> (text suffix)) resource)) (waiter resource barrier id)))) - (monad.all !)) + (stack.all' !)) .let [outcome (io.value (atom.read! resource))]] (unit.coverage [/.barrier /.block!] (and (text.ends_with? expected_ending outcome) diff --git a/stdlib/source/test/lux/concurrency/stm.lux b/stdlib/source/test/lux/concurrency/stm.lux index 06c46f74bd..7785b08634 100644 --- a/stdlib/source/test/lux/concurrency/stm.lux +++ b/stdlib/source/test/lux/concurrency/stm.lux @@ -97,7 +97,7 @@ (do [! future.monad] [_ (|> (stack.repeated iterations_per_process []) (stack#each (function (_ _) (/.commit! (/.update ++ var)))) - (monad.all !)) + (stack.all' !)) cummulative (/.commit! (/.read var))] (unit.coverage [/.STM] (n.= iterations_per_process diff --git a/stdlib/source/test/lux/concurrency/structured.lux b/stdlib/source/test/lux/concurrency/structured.lux index d904238076..bc20323f6f 100644 --- a/stdlib/source/test/lux/concurrency/structured.lux +++ b/stdlib/source/test/lux/concurrency/structured.lux @@ -122,7 +122,7 @@ (future.future [])) scope (<| /.with_scope (function (_ scope)) - (monad.all /.monad) + (stack.all' /.monad) (stack#each (function (_ _) (/.schedule! scope long (function (_ it) diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index b0e5739da2..79e5c506ee 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -15,6 +15,9 @@ [error ["[0]" try (.only Try)] ["[0]" exception (.only Exception)]] + [data + [collection + ["[0]" stack]]] [math ["[0]" random] [number @@ -100,8 +103,8 @@ (in {try.#Success []})))] outcome (/.value ! (do [! (/.monad !)] - [_ (monad.each ! (/.acquire! //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups))] + [_ (stack.each' ! (/.acquire! //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups))] (in []))) actual_clean_ups (thread.read! clean_up_counter)] (in (and (..success? outcome) @@ -118,8 +121,8 @@ (in {try.#Success []})))] outcome (/.value ! (do [! (/.monad !)] - [_ (monad.each ! (/.acquire! //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups)) + [_ (stack.each' ! (/.acquire! //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups)) _ (/.failure //@ (exception.error ..oops []))] (in []))) actual_clean_ups (thread.read! clean_up_counter)] @@ -137,8 +140,8 @@ (in {try.#Success []})))] outcome (/.value ! (do [! (/.monad !)] - [_ (monad.each ! (/.acquire! //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups)) + [_ (stack.each' ! (/.acquire! //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups)) _ (/.except //@ ..oops [])] (in []))) actual_clean_ups (thread.read! clean_up_counter)] @@ -157,8 +160,8 @@ (exception.except ..oops [])))))] outcome (/.value ! (do [! (/.monad !)] - [_ (monad.each ! (/.acquire! //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups))] + [_ (stack.each' ! (/.acquire! //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups))] (in []))) actual_clean_ups (thread.read! clean_up_counter)] (in (and (or (n.= 0 expected_clean_ups) diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 71ceb8bed7..f47af39319 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -7,8 +7,8 @@ [ffi (.only)] [abstract [equivalence (.only Equivalence)] + [monad (.only do)] ["<>" projection] - ["[0]" monad (.only do)] ["[0]" enum] ["[0]" equivalence ["[1]T" \\test]] @@ -603,8 +603,8 @@ reader (function (_ binary idx) (/.bits_08 idx binary))] (and (n.= length (/.size random_slice)) - (when [(monad.each try.monad (|>> (n.+ offset) (reader sample)) idxs) - (monad.each try.monad (reader random_slice) idxs)] + (when [(stack.each' try.monad (|>> (n.+ offset) (reader sample)) idxs) + (stack.each' try.monad (reader random_slice) idxs)] [{try.#Success binary_vals} {try.#Success slice_vals}] (by (stack.equivalence n.equivalence) = binary_vals slice_vals) diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux index 05478e355f..8a9850f1a8 100644 --- a/stdlib/source/test/lux/data/collection/queue/priority.lux +++ b/stdlib/source/test/lux/data/collection/queue/priority.lux @@ -5,11 +5,13 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control ["[0]" maybe (.use "[1]#[0]" functor)]] [data - ["[0]" bit]] + ["[0]" bit] + [collection + ["[0]" stack]]] [math ["[0]" random (.only Random)] [number @@ -23,12 +25,12 @@ (-> Natural (Random (Queue Natural))) (do [! random.monad] [inputs (random.stack size random.natural)] - (monad.mix ! (function (_ head tail) - (do ! - [priority random.natural] - (in (/.end priority head tail)))) - /.empty - inputs))) + (stack.mix' ! (function (_ head tail) + (do ! + [priority random.natural] + (in (/.end priority head tail)))) + /.empty + inputs))) (the .public test Test diff --git a/stdlib/source/test/lux/meta/extension.lux b/stdlib/source/test/lux/meta/extension.lux index 54bd5f7d00..0b2d616adf 100644 --- a/stdlib/source/test/lux/meta/extension.lux +++ b/stdlib/source/test/lux/meta/extension.lux @@ -6,8 +6,8 @@ [lux (.except) ["[0]" debug] [abstract - ["<>" projection] - ["[0]" monad (.only do)]] + [monad (.only do)] + ["<>" projection]] [error ["[0]" try (.use "[1]#[0]" functor)]] [data @@ -18,6 +18,7 @@ ["%" \\injection]] [collection ["[0]" sequence] + ["[0]" list (.use "[1]#[0]" functor)] ["[0]" stack (.use "[1]#[0]" functor)]]] [math ["[0]" random] @@ -84,8 +85,8 @@ (analysis (_ phase archive [parameters (<>.some .any)]) (let [! phase.monad] (|> parameters - (monad.each ! (phase archive)) - (by ! each (|>> (is (Stack analysis.Term)) + (stack.each' ! (phase archive)) + (by ! each (|>> list.of_stack {analysis.#Extension (name ..my_synthesis|synthesis)} [provenance.dummy] (is analysis.Term))))))) @@ -101,8 +102,9 @@ (synthesis (_ phase archive [parameters (<>.some .any)]) (let [! phase.monad] (|> parameters - (monad.each ! (phase archive)) - (by ! each (|>> {synthesis.#Extension (name ..my_translation|translation)} + (stack.each' ! (phase archive)) + (by ! each (|>> list.of_stack + {synthesis.#Extension (name ..my_translation|translation)} [provenance.dummy] (is synthesis.Term))))))) @@ -111,8 +113,8 @@ (analysis (_ phase archive [parameters (<>.some .any)]) (let [! phase.monad] (|> parameters - (monad.each ! (phase archive)) - (by ! each (|>> (is (Stack analysis.Term)) + (stack.each' ! (phase archive)) + (by ! each (|>> list.of_stack {analysis.#Extension (name ..my_translation|synthesis)} [provenance.dummy] (is analysis.Term))))))) @@ -133,13 +135,13 @@ Synthesis (synthesis (_ phase archive []) (by phase.monad in (is synthesis.Term - [provenance.dummy {synthesis.#Extension (name ..dummy_translation|translation) (stack)}])))) + [provenance.dummy {synthesis.#Extension (name ..dummy_translation|translation) (list)}])))) (the dummy_translation Analysis (analysis (_ phase archive []) (by phase.monad in (is analysis.Term - [provenance.dummy {analysis.#Extension (name ..dummy_translation|synthesis) (stack)}])))) + [provenance.dummy {analysis.#Extension (name ..dummy_translation|synthesis) (list)}])))) ... Declaration (the my_declaration diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index b4796d1065..1e31c40825 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -987,8 +987,8 @@ (<| (..coverage [/.multianewarray /.arraylength]) (..bytecode (|>> (as Natural) (n.= sizesH))) (do [! /.monad] - [_ (monad.each ! (|>> (as java/lang/Long) ffi.long_to_int ..$Integer::literal) - {.#Top sizesH sizesT}) + [_ (stack.each' ! (|>> (as java/lang/Long) ffi.long_to_int ..$Integer::literal) + {.#Top sizesH sizesT}) _ (/.multianewarray type (|> dimensions unsigned.u1 try.trusted)) _ ?length] $Long::wrap)))) diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index a6ec7f7f79..3d89295237 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -5,8 +5,8 @@ [library [lux (.except name) [abstract + [monad (.only do)] ["<>" projection] - ["[0]" monad (.only do)] ["[0]" equivalence ["[1]T" \\test]]] [control @@ -429,7 +429,7 @@ _ true))) (stack.repeated size) - (monad.all !)) + (stack.all' !)) .let [(open "/#[0]") /.equivalence (open "stack#[0]") (stack.equivalence /.equivalence)]] (`` (all _.and @@ -459,7 +459,7 @@ false)))) (do [! random.monad] [size (|> random.natural (by ! each (n.% 3))) - members (monad.all ! (stack.repeated size (..random 0))) + members (stack.all' ! (stack.repeated size (..random 0))) extra (|> (..random 0) (random.only (function (_ type) (when type diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index 69607e6e68..82e515478f 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -341,17 +341,17 @@ (-> Natural (/.Check [Type (Stack Type) Type])) (do [! /.monad] [[id/head var/head] /.var - var/tail+ (monad.each ! (function (_ _) - (do ! - [[id/T var/tail] /.var] - (in var/tail))) - (stack.repeated tail_size /.var)) - var/last (monad.mix ! (function (_ var/next var/prev) - (do ! - [_ (/.check var/prev var/next)] - (in var/next))) - var/head - var/tail+) + var/tail+ (stack.each' ! (function (_ _) + (do ! + [[id/T var/tail] /.var] + (in var/tail))) + (stack.repeated tail_size /.var)) + var/last (stack.mix' ! (function (_ var/next var/prev) + (do ! + [_ (/.check var/prev var/next)] + (in var/next))) + var/head + var/tail+) _ (/.check var/last var/head)] (in [var/head var/tail+ var/last]))) @@ -364,8 +364,8 @@ (succeeds? (do [! /.monad] [[var/head var/tail+ var/last] (..build_ring tail_size) _ (/.check var/head nominal/0) - failures (monad.each ! (|>> (/.check nominal/1) ..verdict) (stack.partial var/head var/tail+)) - successes (monad.each ! (|>> (/.check nominal/0) ..verdict) (stack.partial var/head var/tail+))] + failures (stack.each' ! (|>> (/.check nominal/1) ..verdict) (stack.partial var/head var/tail+)) + successes (stack.each' ! (|>> (/.check nominal/0) ..verdict) (stack.partial var/head var/tail+))] (/.assertion "" (and (stack.every? (bit.= false) failures) (stack.every? (bit.= true) successes))))) @@ -377,8 +377,8 @@ _ (/.check var/head/0 nominal/0) .let [all_variables (stack#composite (stack.partial var/head/0 var/tail+/0) (stack.partial var/head/1 var/tail+/1))] - failures (monad.each ! (|>> (/.check nominal/1) ..verdict) all_variables) - successes (monad.each ! (|>> (/.check nominal/0) ..verdict) all_variables)] + failures (stack.each' ! (|>> (/.check nominal/1) ..verdict) all_variables) + successes (stack.each' ! (|>> (/.check nominal/0) ..verdict) all_variables)] (/.assertion "" (and (stack.every? (bit.= false) failures) (stack.every? (bit.= true) successes)))))] (and can_create_rings_of_variables! diff --git a/stdlib/source/test/lux/type/quotient.lux b/stdlib/source/test/lux/type/quotient.lux index e70993b8e6..9c44bf4678 100644 --- a/stdlib/source/test/lux/type/quotient.lux +++ b/stdlib/source/test/lux/type/quotient.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]]] [data diff --git a/stdlib/source/test/lux/type/record.lux b/stdlib/source/test/lux/type/record.lux index 7c09ae5599..17c189e400 100644 --- a/stdlib/source/test/lux/type/record.lux +++ b/stdlib/source/test/lux/type/record.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]]] [math diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux index c2f3fe62e0..f72f592034 100644 --- a/stdlib/source/test/lux/world/file.lux +++ b/stdlib/source/test/lux/world/file.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [concurrency ["[0]" future (.only Future)] ["[0]" atom (.only Atom)]] @@ -524,7 +524,7 @@ (when (dictionary.value @ disk') {try.#Success {.#Right children}} (|> children - (monad.only ! (..file? disk)) + (stack.only' ! (..file? disk)) (by ! each (|>> {try.#Success}))) failure @@ -535,7 +535,7 @@ (when (dictionary.value @ disk') {try.#Success {.#Right children}} (|> children - (monad.only ! (..directory? disk)) + (stack.only' ! (..directory? disk)) (by ! each (|>> {try.#Success}))) failure diff --git a/stdlib/source/test/lux/world/net/http/cookie.lux b/stdlib/source/test/lux/world/net/http/cookie.lux index 474f16ef0e..79ba4d6938 100644 --- a/stdlib/source/test/lux/world/net/http/cookie.lux +++ b/stdlib/source/test/lux/world/net/http/cookie.lux @@ -5,7 +5,7 @@ [library [lux (.except) [abstract - ["[0]" monad (.only do)] + [monad (.only do)] ["[0]" equivalence ["[1]T" \\test]]] [control