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 3815d4c44..6dd9d0e2a 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 @@ -10,12 +10,13 @@ ["<>" projection]] [data [collection - ["[0]" array] ["[0]" dictionary] ["[0]" list (.use "[1]#[0]" monoid) ["?[1]" \\projection]]]] ["[0]" type (.only) ["[0]" check]] + [compiler + ["@[0]" type]] ["[0]" meta (.only) ["[0]" code ["<[1]>" \\projection]]] @@ -30,108 +31,6 @@ ["[0]" analysis (.only Operation Phase Handler Bundle) ["[1]/[0]" type]]]]]) -(the array::new - (-> Text Handler) - (custom - [?list.any - (function (_ extension phase archive lengthC) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [lengthA (analysis/type.expecting Natural - (phase archive lengthC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list lengthA)}]))))])) - -(the array::length - (-> Text Handler) - (custom - [?list.any - (function (_ extension phase archive arrayC) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference Natural) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list arrayA)}]))))])) - -(the array::read - (-> Text Handler) - (custom - [(<>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference :read:) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA arrayA)}]))))])) - -(the array::write - (-> Text Handler) - (custom - [(all <>.and ?list.any ?list.any ?list.any) - (function (_ extension phase archive [indexC valueC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - valueA (analysis/type.expecting :write: - (phase archive valueC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA valueA arrayA)}]))))])) - -(the array::delete - (-> Text Handler) - (custom - [(all <>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA arrayA)}]))))])) - -(the with_array_extensions - (-> Bundle Bundle) - (|>> (/.with "js_array_new#" array::new) - (/.with "js_array_length#" array::length) - (/.with "js_array_read#" array::read) - (/.with "js_array_write#" array::write) - (/.with "js_array_delete#" array::delete) - )) - (the object::new (-> Text Handler) (custom @@ -249,7 +148,6 @@ (the .public bundle Bundle (|> extension.empty - with_array_extensions with_object_extensions (/.with "js_constant#" js::constant) 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 f01d6849a..00f989c0f 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 @@ -30,7 +30,6 @@ ["[0]" list (.use "[1]#[0]" mix monad monoid) ["?[1]" \\projection]] ["[0]" stack (.use "[1]#[0]" mix monad monoid)] - ["[0]" array] ["[0]" dictionary (.only Dictionary)] ["[0]" sequence]]] [math @@ -508,15 +507,15 @@ (..custom [?list.any (function (_ extension_name analyse archive [arrayC]) - (<| typeA.with_var (function (_ [@read :read:])) - typeA.with_var (function (_ [@write :write:])) + (<| typeA.with_var (function (_ [_ to_write])) + typeA.with_var (function (_ [_ to_read])) (do phase.monad [_ (typeA.inference ..int) - arrayA (<| (typeA.expecting (.type (array.Array' :read: :write:))) + arrayA (<| (typeA.expecting (@type.Array to_write to_read)) (analyse archive arrayC)) - :read: (typeA.check (check.clean (list) :read:)) - :write: (typeA.check (check.clean (list) :write:)) - arrayJT (jvm_array_type (.type (array.Array' :read: :write:))) + to_read (typeA.check (check.clean (list) to_read)) + to_write (typeA.check (check.clean (list) to_write)) + arrayJT (jvm_array_type (@type.Array to_write to_read)) @ meta.provenance] (in [@ {analysis.#Extension [.prelude (text extension_name "|translation")] (list (analysis.text @ (..signature arrayJT)) @@ -738,17 +737,17 @@ (..custom [(<>.and ?list.any ?list.any) (function (_ extension_name analyse archive [idxC arrayC]) - (<| typeA.with_var (function (_ [@read :read:])) - typeA.with_var (function (_ [@write :write:])) + (<| typeA.with_var (function (_ [_ to_write])) + typeA.with_var (function (_ [_ to_read])) (do phase.monad - [_ (typeA.inference :read:) - arrayA (<| (typeA.expecting (.type (array.Array' :read: :write:))) + [_ (typeA.inference to_read) + arrayA (<| (typeA.expecting (@type.Array to_write to_read)) (analyse archive arrayC)) idxA (<| (typeA.expecting ..int) (analyse archive idxC)) - :read: (typeA.check (check.clean (list) :read:)) - :write: (typeA.check (check.clean (list) :write:)) - arrayJT (jvm_array_type (.type (array.Array' :read: :write:))) + to_read (typeA.check (check.clean (list) to_read)) + to_write (typeA.check (check.clean (list) to_write)) + arrayJT (jvm_array_type (@type.Array to_write to_read)) @ meta.provenance] (in [@ {analysis.#Extension [.prelude (text extension_name "|translation")] (list (analysis.text @ (..signature arrayJT)) @@ -782,19 +781,19 @@ (..custom [(all <>.and ?list.any ?list.any ?list.any) (function (_ extension_name analyse archive [idxC valueC arrayC]) - (<| typeA.with_var (function (_ [@read :read:])) - typeA.with_var (function (_ [@write :write:])) + (<| typeA.with_var (function (_ [_ to_write])) + typeA.with_var (function (_ [_ to_read])) (do phase.monad - [_ (typeA.inference (.type (array.Array' :read: :write:))) - arrayA (<| (typeA.expecting (.type (array.Array' :read: :write:))) + [_ (typeA.inference (@type.Array to_write to_read)) + arrayA (<| (typeA.expecting (@type.Array to_write to_read)) (analyse archive arrayC)) idxA (<| (typeA.expecting ..int) (analyse archive idxC)) - valueA (<| (typeA.expecting :write:) + valueA (<| (typeA.expecting to_write) (analyse archive valueC)) - :read: (typeA.check (check.clean (list) :read:)) - :write: (typeA.check (check.clean (list) :write:)) - arrayJT (jvm_array_type (.type (array.Array' :read: :write:))) + to_read (typeA.check (check.clean (list) to_read)) + to_write (typeA.check (check.clean (list) to_write)) + arrayJT (jvm_array_type (@type.Array to_write to_read)) @ meta.provenance] (in [@ {analysis.#Extension [.prelude (text extension_name "|translation")] (list (analysis.text @ (..signature arrayJT)) 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 5e0f908c6..c0dfeee9f 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 @@ -44,108 +44,6 @@ (for .lua ffi.Function Any)) -(the array::new - (-> Text Handler) - (custom - [?list.any - (function (_ extension phase archive lengthC) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [lengthA (analysis/type.expecting Natural - (phase archive lengthC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list lengthA)}]))))])) - -(the array::length - (-> Text Handler) - (custom - [?list.any - (function (_ extension phase archive arrayC) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference Natural) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list arrayA)}]))))])) - -(the array::read - (-> Text Handler) - (custom - [(<>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference :read:) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA arrayA)}]))))])) - -(the array::write - (-> Text Handler) - (custom - [(all <>.and ?list.any ?list.any ?list.any) - (function (_ extension phase archive [indexC valueC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - valueA (analysis/type.expecting :write: - (phase archive valueC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA valueA arrayA)}]))))])) - -(the array::delete - (-> Text Handler) - (custom - [(all <>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA arrayA)}]))))])) - -(the with_array_extensions - (-> Bundle Bundle) - (|>> (/.with "lua_array_new#" array::new) - (/.with "lua_array_length#" array::length) - (/.with "lua_array_read#" array::read) - (/.with "lua_array_write#" array::write) - (/.with "lua_array_delete#" array::delete) - )) - (the object::get (-> Text Handler) (custom @@ -279,7 +177,6 @@ (the .public bundle Bundle (|> extension.empty - with_array_extensions with_object_extensions with_utf8_extensions 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 730021287..85ae5a3b6 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 @@ -10,7 +10,7 @@ ["<>" projection]] [data [collection - ["[0]" array (.only Array)] + [array (.only Array)] ["[0]" dictionary] ["[0]" stack] ["[0]" list @@ -33,90 +33,6 @@ [/// ["[0]" phase]]]]]]) -(the array::new - Handler - (custom - [?list.any - (function (_ extension phase archive lengthC) - (<| analysis/type.with_var - (function (_ [@var :var:])) - (do phase.monad - [lengthA (analysis/type.with_type Natural - (phase archive lengthC)) - _ (analysis/type.infer (type (Array :var:)))] - (in {analysis.#Extension extension (stack lengthA)}))))])) - -(the array::length - Handler - (custom - [?list.any - (function (_ extension phase archive arrayC) - (<| analysis/type.with_var - (function (_ [@var :var:])) - (do phase.monad - [arrayA (analysis/type.with_type (type (Array :var:)) - (phase archive arrayC)) - _ (analysis/type.infer Natural)] - (in {analysis.#Extension extension (stack arrayA)}))))])) - -(the array::read - Handler - (custom - [(<>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@var :var:])) - (do phase.monad - [indexA (analysis/type.with_type Natural - (phase archive indexC)) - arrayA (analysis/type.with_type (type (Array :var:)) - (phase archive arrayC)) - _ (analysis/type.infer :var:)] - (in {analysis.#Extension extension (stack indexA arrayA)}))))])) - -(the array::write - Handler - (custom - [(all <>.and ?list.any ?list.any ?list.any) - (function (_ extension phase archive [indexC valueC arrayC]) - (<| analysis/type.with_var - (function (_ [@var :var:])) - (do phase.monad - [indexA (analysis/type.with_type Natural - (phase archive indexC)) - valueA (analysis/type.with_type :var: - (phase archive valueC)) - arrayA (analysis/type.with_type (type (Array :var:)) - (phase archive arrayC)) - _ (analysis/type.infer (type (Array :var:)))] - (in {analysis.#Extension extension (stack indexA valueA arrayA)}))))])) - -(the array::delete - Handler - (custom - [(all <>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@var :var:])) - (do phase.monad - [indexA (analysis/type.with_type Natural - (phase archive indexC)) - arrayA (analysis/type.with_type (type (Array :var:)) - (phase archive arrayC)) - _ (analysis/type.infer (type (Array :var:)))] - (in {analysis.#Extension extension (stack indexA arrayA)}))))])) - -(the bundle::array - Bundle - (<| (bundle.prefix "array") - (|> bundle.empty - (bundle.install "new" array::new) - (bundle.install "length" array::length) - (bundle.install "read" array::read) - (bundle.install "write" array::write) - (bundle.install "delete" array::delete) - ))) - (the Null (for .php ffi.Null Any)) @@ -214,7 +130,6 @@ Bundle (<| (bundle.prefix "php") (|> bundle.empty - (dictionary.composite bundle::array) (dictionary.composite bundle::object) (bundle.install "constant" php::constant) 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 becfc1c11..519ad7a25 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 @@ -10,7 +10,6 @@ ["<>" projection]] [data [collection - ["[0]" array] ["[0]" dictionary] ["[0]" list (.use "[1]#[0]" monoid) ["?[1]" \\projection]]]] @@ -29,108 +28,6 @@ ["[0]" analysis (.only Operation Phase Handler Bundle) ["[1]/[0]" type]]]]]) -(the array::new - (-> Text Handler) - (custom - [?list.any - (function (_ extension phase archive lengthC) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [lengthA (analysis/type.expecting Natural - (phase archive lengthC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list lengthA)}]))))])) - -(the array::length - (-> Text Handler) - (custom - [?list.any - (function (_ extension phase archive arrayC) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference Natural) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list arrayA)}]))))])) - -(the array::read - (-> Text Handler) - (custom - [(<>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference :read:) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA arrayA)}]))))])) - -(the array::write - (-> Text Handler) - (custom - [(all <>.and ?list.any ?list.any ?list.any) - (function (_ extension phase archive [indexC valueC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - valueA (analysis/type.expecting :write: - (phase archive valueC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA valueA arrayA)}]))))])) - -(the array::delete - (-> Text Handler) - (custom - [(all <>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (analysis/type.expecting Natural - (phase archive indexC)) - arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) - (phase archive arrayC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA arrayA)}]))))])) - -(the with_array_extensions - (-> Bundle Bundle) - (|>> (/.with "python_array_new#" array::new) - (/.with "python_array_length#" array::length) - (/.with "python_array_read#" array::read) - (/.with "python_array_write#" array::write) - (/.with "python_array_delete#" array::delete) - )) - (the None (for .python ffi.None Any)) @@ -256,7 +153,6 @@ (the .public bundle Bundle (|> ///.empty - with_array_extensions with_object_extensions (/.with "python_constant#" python::constant) 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 a03ad00fe..222c203a5 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 @@ -10,7 +10,6 @@ ["<>" projection]] [data [collection - ["[0]" array] ["[0]" dictionary] ["[0]" list (.use "[1]#[0]" monoid) ["?[1]" \\projection]]]] @@ -30,108 +29,6 @@ ["[0]" analysis (.only Operation Phase Handler Bundle) ["[1]/[0]" type]]]]]) -(the array::new - (-> Text Handler) - (custom - [?list.any - (function (_ extension phase archive lengthC) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [lengthA (<| (analysis/type.expecting Natural) - (phase archive lengthC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list lengthA)}]))))])) - -(the array::length - (-> Text Handler) - (custom - [?list.any - (function (_ extension phase archive arrayC) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [arrayA (<| (analysis/type.expecting (type (array.Array' :read: :write:))) - (phase archive arrayC)) - _ (analysis/type.inference Natural) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list arrayA)}]))))])) - -(the array::read - (-> Text Handler) - (custom - [(<>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (<| (analysis/type.expecting Natural) - (phase archive indexC)) - arrayA (<| (analysis/type.expecting (type (array.Array' :read: :write:))) - (phase archive arrayC)) - _ (analysis/type.inference :read:) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA arrayA)}]))))])) - -(the array::write - (-> Text Handler) - (custom - [(all <>.and ?list.any ?list.any ?list.any) - (function (_ extension phase archive [indexC valueC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (<| (analysis/type.expecting Natural) - (phase archive indexC)) - valueA (<| (analysis/type.expecting :write:) - (phase archive valueC)) - arrayA (<| (analysis/type.expecting (type (array.Array' :read: :write:))) - (phase archive arrayC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA valueA arrayA)}]))))])) - -(the array::delete - (-> Text Handler) - (custom - [(all <>.and ?list.any ?list.any) - (function (_ extension phase archive [indexC arrayC]) - (<| analysis/type.with_var - (function (_ [@read :read:])) - analysis/type.with_var - (function (_ [@write :write:])) - (do phase.monad - [indexA (<| (analysis/type.expecting Natural) - (phase archive indexC)) - arrayA (<| (analysis/type.expecting (type (array.Array' :read: :write:))) - (phase archive arrayC)) - _ (analysis/type.inference (type (array.Array' :read: :write:))) - @ meta.provenance] - (in [@ {analysis.#Extension (/.translation extension) - (list indexA arrayA)}]))))])) - -(the with_array_extensions - (-> Bundle Bundle) - (|>> (/.with "ruby_array_new#" array::new) - (/.with "ruby_array_length#" array::length) - (/.with "ruby_array_read#" array::read) - (/.with "ruby_array_write#" array::write) - (/.with "ruby_array_delete#" array::delete) - )) - (the Nil (for .ruby ffi.Nil Any)) @@ -223,7 +120,6 @@ (the .public bundle Bundle (|> extension.empty - with_array_extensions with_object_extensions (/.with "ruby_constant#" ruby::constant) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 49ed0cb67..69d7d901f 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -53,14 +53,13 @@ (i64.left_shifted 31 1)) (the .public empty - (for_any (_ it) - (-> Natural - (Array it))) + (-> Natural + Array) (|>> /.empty)) (the .public size - (for_any (_ read write) - (-> (Array' read write) + (for_any (_ to_write to_read) + (-> (Array' to_write to_read) Natural)) (|>> /.size)) @@ -69,96 +68,95 @@ "Index out of bounds.")) (the .public (item index array) - (for_any (_ read write) - (-> Natural (Array' read write) - (Try read))) + (for_any (_ to_write to_read) + (-> Index (Array' to_write to_read) + (Try to_read))) (if (/.lacks? index array) {try.#Failure ..index_out_of_bounds} {try.#Success (/.item index array)})) (the .public (has! index value array) - (for_any (_ read write) - (-> Natural write (Array' read write) - (Array' read write))) + (for_any (_ to_write to_read) + (-> Index to_write + (Change (Array' to_write to_read)))) (/.has! index value array)) (the .public (lacks! index array) - (for_any (_ read write) - (-> Natural (Array' read write) - (Array' read write))) + (for_any (_ to_write to_read) + (-> Index + (Change (Array' to_write to_read)))) (/.lacks! index array)) (the .public (lacks? index array) - (for_any (_ read write) - (-> Natural (Array' read write) - Bit)) + (for_any (_ to_write to_read) + (-> Index + (Predicate (Array' to_write to_read)))) (/.lacks? index array)) (the .public (has? index array) - (for_any (_ read write) - (-> Natural (Array' read write) - Bit)) + (for_any (_ to_write to_read) + (-> Index + (Predicate (Array' to_write to_read)))) (/.has? index array)) (the .public (revised! index $ array) - (for_any (_ read write) - (-> Natural (-> read write) (Array' read write) - (Array' read write))) + (for_any (_ to_write to_read) + (-> Index (-> to_read to_write) + (Change (Array' to_write to_read)))) (/.revised! index $ array)) (the .public (upsert! index default transform array) - (for_any (_ read write) - (-> Natural read (-> read write) (Array' read write) - (Array' read write))) + (for_any (_ to_write to_read) + (-> Index to_read (-> to_read to_write) + (Change (Array' to_write to_read)))) (/.upsert! index default transform array)) (the .public (copy! length src_start src_array dest_start dest_array) - (for_any (_ read write) - (-> Natural Natural (Array' write Nothing) Natural (Array' read write) - (Array' read write))) + (for_any (_ to_write to_read any) + (-> Natural Index (Array' any to_write) Index + (Change (Array' to_write to_read)))) (/.copy! length src_start src_array dest_start dest_array)) (the .public occupancy - (for_any (_ read write) - (-> (Array' read write) + (for_any (_ to_write to_read) + (-> (Array' to_write to_read) Natural)) (|>> /.occupancy)) (the .public vacancy - (for_any (_ read write) - (-> (Array' read write) + (for_any (_ to_write to_read) + (-> (Array' to_write to_read) Natural)) (|>> /.vacancy)) (the .public (only! ? it) - (for_any (_ read write) - (-> (Predicate read) (Array' read write) - (Array' read write))) + (for_any (_ to_write to_read) + (-> (Predicate to_read) + (Change (Array' to_write to_read)))) (/.only! ? it)) (the .public (example ? it) - (for_any (_ read write) - (-> (Predicate read) (Array' read write) - (Try read))) + (for_any (_ to_write to_read) + (-> (Predicate to_read) (Array' to_write to_read) + (Try to_read))) (/.example ? it)) (the .public (example' ? it) - (for_any (_ read write) - (-> (-> Natural read Bit) (Array' read write) - (Try [Natural read]))) + (for_any (_ to_write to_read) + (-> (-> Index (Predicate to_read)) (Array' to_write to_read) + (Try [Index to_read]))) (/.example' ? it)) (the .public clone (for_any (_ it) - (-> (Array it) - (Array it))) + (Change (Array it))) (|>> /.clone)) (the .public (equivalence //) - (for_any (_ read) - (-> (Equivalence read) - (Equivalence (for_some (_ write) - (Array' read write))))) + (for_any (_ to_read) + (-> (Equivalence to_read) + (Equivalence (for_some (_ to_write) + (Array' to_write to_read))))) (implementation (the (= left/* right/*) (/.= // left/* right/*)))) @@ -173,8 +171,8 @@ (/.composite left/* right/*)))) (the .public mix - (Mix (for_any (_ read) - (Array' read Nothing))) + (for_any (_ to_write) + (Mix (Array' to_write))) (implementation (the (mix $ init it) (/.mix (function (_ index partial total) @@ -190,9 +188,9 @@ (with_template' [ ] [(the .public ( ? it) - (for_any (_ read write) - (-> (Predicate read) - (Predicate (Array' read write)))) + (for_any (_ to_write to_read) + (-> (Predicate to_read) + (Predicate (Array' to_write to_read)))) ( ? it))] [every? /.every?] @@ -200,9 +198,9 @@ ) (the .public (one ? it) - (for_any (_ read read' write) - (-> (-> read (Maybe read')) (Array' read write) - (Try read'))) + (for_any (_ to_write to_read to_read') + (-> (-> to_read (Maybe to_read')) (Array' to_write to_read) + (Try to_read'))) (/.one ? it)) (the .public of_stack @@ -212,7 +210,7 @@ (|>> /.of_stack)) (the .public (as_stack default it) - (for_any (_ read write) - (-> (Maybe read) (Array' read write) - (Stack read))) + (for_any (_ to_write to_read) + (-> (Maybe to_read) (Array' to_write to_read) + (Stack to_read))) (/.as_stack default it)) diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index ba27f4232..75eed06f2 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -430,12 +430,12 @@ (do ! [amount (by ! each (n.% (++ size)) random.natural)] (_.coverage [/.copy!] - (let [copy (is (Array Natural) - (/.empty size))] - (exec (/.copy! amount 0 the_array 0 copy) + (|> (/.empty size) + (is (Array Natural)) + (/.copy! amount 0 the_array 0) + (/.as_stack {.#None}) (by (stack.equivalence n.equivalence) = - (stack.first amount (/.as_stack {.#None} the_array)) - (/.as_stack {.#None} copy)))))) + (stack.first amount (/.as_stack {.#None} the_array)))))) (_.coverage [/.clone] (let [clone (/.clone the_array)] (and (not (same? the_array clone)) diff --git a/stdlib/source/unsafe/lux/data/collection/array.lux b/stdlib/source/unsafe/lux/data/collection/array.lux index 81e856689..5dd9544b7 100644 --- a/stdlib/source/unsafe/lux/data/collection/array.lux +++ b/stdlib/source/unsafe/lux/data/collection/array.lux @@ -22,10 +22,10 @@ (the name_of_type (.type_name# "array")) -(`` (every .public (Array' read write) +(`` (every .public (Array' to_write to_read) {.#Nominal (,, (static ..name_of_type)) - (list [(,, (static ..contra_variant)) write] - [(,, (static ..co_variant)) read])})) + (list [(,, (static ..contra_variant)) to_write] + [(,, (static ..co_variant)) to_read])})) (every .public (Array it) (Array' it it)) @@ -35,11 +35,9 @@ (the .public empty (macro (_ ,size) - [((.is (.for_any (_ it) - (.-> ..Index - (..Array it))) - (.function (_ size) - (.array# size))) + [((.is (.-> ..Index + ..Array) + (.|>> .array#)) ,size)])) (the .public size @@ -50,11 +48,23 @@ (macro (_ ,reference ,it) [(.int_<# (.integer ,reference) (.integer ,it))])) +(the n#after + (macro (_ ,offset ,it) + [(.i64_+# ,offset ,it)])) + +(`` (the n#next + (macro (_ ,it) + [(,, (n#after 1 ,it))]))) + +(the n#previous + (macro (_ ,it) + [(.i64_-# 1 ,it)])) + (`` (the .public has? (macro (_ ,index ,it) - [((.is (.for_any (_ read write) + [((.is (.for_any (_ to_write to_read) (.-> ..Index - (predicate.Predicate (..Array' read write)))) + (predicate.Predicate (..Array' to_write to_read)))) (.function (_ index it) (.and (,, (n#< (..size it) index)) (.array_has?# index it)))) @@ -78,9 +88,9 @@ (the .public revised! (macro (revised! <$> ) - [((.is (.for_any (_ read write) - (.-> ..Index (.-> read write) (..Array' read write) - (..Array' read write))) + [((.is (.for_any (_ to_write to_read) + (.-> ..Index (.-> to_read to_write) + (.Change (..Array' to_write to_read)))) (.function (revised! index $ array) (.if (..has? index array) (..has! index ($ (..item index array)) array) @@ -89,9 +99,9 @@ (the .public upsert! (macro (upsert! <$> ) - [((.is (.for_any (_ read write) - (.-> ..Index read (.-> read write) (..Array' read write) - (..Array' read write))) + [((.is (.for_any (_ to_write to_read) + (.-> ..Index to_read (.-> to_read to_write) + (.Change (..Array' to_write to_read)))) (.function (upsert! index default $ array) (..has! index ($ (.if (..has? index array) @@ -102,48 +112,48 @@ (`` (the .public copy! (macro (copy! ) - [((.is (.for_any (_ read write any) - (.-> ..Index ..Index (..Array' write any) ..Index (..Array' read write) - (..Array' read write))) + [((.is (.for_any (_ to_write to_read any) + (.-> ..Index ..Index (..Array' any to_write) ..Index + (.Change (..Array' to_write to_read)))) (.function (copy! length src_start src_array dest_start dest_array) (.loop (again [offset 0]) (.if (,, (n#< length offset)) (.exec - (.if (..has? (.i64_+# offset src_start) src_array) - (..has! (.i64_+# offset dest_start) - (..item (.i64_+# offset src_start) src_array) + (.if (..has? (,, (n#after offset src_start)) src_array) + (..has! (,, (n#after offset dest_start)) + (..item (,, (n#after offset src_start)) src_array) dest_array) - (..lacks! (.i64_+# offset dest_start) dest_array)) - (again (.i64_+# 1 offset))) + (..lacks! (,, (n#after offset dest_start)) dest_array)) + (again (,, (n#next offset)))) dest_array)))) )]))) (with_template [ ] [(`` (the .public (macro ( ) - [((.is (.for_any (_ read write) - (.-> (..Array' read write) + [((.is (.for_any (_ to_write to_read) + (.-> (..Array' to_write to_read) ..Index)) (.function (occupancy array) (.let [size (..size array)] (.loop (again [index 0 it 0]) (.if (,, (n#< size index)) - (again (.i64_+# 1 index) (.if (..has? index array) - - )) + (again (,, (n#next index)) (.if (..has? index array) + + )) it))))) )])))] - [occupancy it (.i64_+# 1 it)] - [vacancy (.i64_+# 1 it) it] + [occupancy it (,, (n#next it))] + [vacancy (,, (n#next it)) it] ) (`` (the .public only! (macro (only! ) - [((.is (.for_any (_ read write) - (.-> (.-> read .Bit) (..Array' read write) - (..Array' read write))) + [((.is (.for_any (_ to_write to_read) + (.-> (predicate.Predicate to_read) + (.Change (..Array' to_write to_read)))) (.function (only! ? it) (.let [size (..size it)] (.loop (again [index 0]) @@ -154,7 +164,7 @@ it (..lacks! index it)) it) - (again (.i64_+# 1 index))) + (again (,, (n#next index)))) it))))) )]))) @@ -164,8 +174,8 @@ (with_template [ ] [(`` (the .public (macro ( ) - [((.is (.for_any (_ read write) - (.-> (..Array' read write) + [((.is (.for_any (_ to_write to_read) + (.-> (..Array' to_write to_read) (try.Try ))) (.function ( ? it) (.let [size (..size it)] @@ -175,20 +185,19 @@ (.let [it (..item index it)] (.if {try.#Success } - (again (.i64_+# 1 index)))) - (again (.i64_+# 1 index))) + (again (,, (n#next index))))) + (again (,, (n#next index)))) {try.#Failure ..no_example}))))) )])))] - [example (.-> read .Bit) (? it) read it] - [example' (.-> ..Index read .Bit) (? index it) [..Index read] [index it]] + [example (predicate.Predicate to_read) (? it) to_read it] + [example' (.-> ..Index (predicate.Predicate to_read)) (? index it) [..Index to_read] [index it]] ) (the .public clone (macro (clone ) [((.is (.for_any (_ it) - (.-> (..Array it) - (..Array it))) + (.Change (..Array it))) (.function (clone it) (.let [size (..size it)] (..copy! size 0 it 0 (..empty size))))) @@ -196,9 +205,9 @@ (`` (the .public = (macro (= ) - [((.is (.for_any (_ read write_left write_right) - (.-> (equivalence.Equivalence read) - (.-> (..Array' read write_left) (..Array' read write_right) + [((.is (.for_any (_ any_left any_right to_read) + (.-> (equivalence.Equivalence to_read) + (.-> (..Array' any_left to_read) (..Array' any_right to_read) .Bit))) (.function (= //#= left/* right/*) (.let [size (..size left/*)] @@ -209,38 +218,38 @@ (.if (..has? index right/*) (.and (//#= (..item index left/*) (..item index right/*)) - (again (.i64_+# 1 index))) + (again (,, (n#next index)))) .false) (..lacks? index right/*)) true)))))) )]))) -(the .public composite - (macro (composite ) - [((.is (.for_any (_ it) - (.-> (..Array' it .Nothing) (..Array' it .Nothing) - (..Array it))) - (.function (composite left/* right/*) - (.let [|left| (..size left/*) - |right| (..size right/*)] - (.|> (..empty (.i64_+# |left| |right|)) - (..copy! |left| 0 left/* 0) - (..copy! |right| 0 right/* |left|))))) - )])) +(`` (the .public composite + (macro (composite ) + [((.is (.for_any (_ any_left any_right to_read) + (.-> (..Array' any_left to_read) (..Array' any_right to_read) + (..Array to_read))) + (.function (composite left/* right/*) + (.let [|left| (..size left/*) + |right| (..size right/*)] + (.|> (..empty (,, (n#after |left| |right|))) + (..copy! |left| 0 left/* 0) + (..copy! |right| 0 right/* |left|))))) + )]))) (`` (the .public mix (macro (mix <$> ) - [((.is (.for_any (_ read write state) - (.-> (.-> ..Index read state state) state (..Array' read write) + [((.is (.for_any (_ to_write to_read state) + (.-> (.-> ..Index to_read (.Change state)) state (..Array' to_write to_read) state)) (.function (mix $ init it) (.let [size (..size it)] (.loop (again [index 0 so_far init]) (.if (,, (n#< size index)) - (again (.i64_+# 1 index) (.if (..has? index it) - ($ index (..item index it) so_far) - so_far)) + (again (,, (n#next index)) (.if (..has? index it) + ($ index (..item index it) so_far) + so_far)) so_far))))) <$> )]))) @@ -257,17 +266,17 @@ (with_template [ ] [(`` (the .public (macro ( ) - [((.is (.for_any (_ read write) - (.-> (predicate.Predicate read) - (predicate.Predicate (..Array' read write)))) + [((.is (.for_any (_ to_write to_read) + (.-> (predicate.Predicate to_read) + (predicate.Predicate (..Array' to_write to_read)))) (.function ( ? it) (.let [size (..size it)] (.loop (again [index 0]) (.if (,, (n#< size index)) (.if (..has? index it) ( (? (..item index it)) - (again (.i64_+# 1 index))) - (again (.i64_+# 1 index))) + (again (,, (n#next index)))) + (again (,, (n#next index)))) ))))) )])))] @@ -280,14 +289,14 @@ (`` (the .public one (macro (one ) - [((.is (.for_any (_ read read' write) - (.-> (.-> read (.Maybe read')) (..Array' read write) - (try.Try read'))) + [((.is (.for_any (_ to_write to_read to_read') + (.-> (.-> to_read (.Maybe to_read')) (..Array' to_write to_read) + (try.Try to_read'))) (.function (one ? it) (.let [size (..size it)] (.loop (again [index 0]) (.if (,, (n#< size index)) - (<| (..expansion#let [ (again (.i64_+# 1 index))]) + (<| (..expansion#let [ (again (,, (n#next index)))]) (.if (..has? index it) (.when (? (..item index it)) {.#None} @@ -299,25 +308,25 @@ {try.#Failure ..no_one}))))) )]))) -(the .public of_stack - (macro (of_stack ) - [((.is (.for_any (_ it) - (.-> (.Stack it) - (..Array it))) - (.function (of_stack input) - (.let [size (stack.size input) - output (..empty size)] - (.loop (again [index 0 - input input]) - (.when input - {.#Empty} - output - - {.#Top head tail} - (.exec - (..has! index head output) - (again (.i64_+# 1 index) tail))))))) - )])) +(`` (the .public of_stack + (macro (of_stack ) + [((.is (.for_any (_ it) + (.-> (.Stack it) + (..Array it))) + (.function (of_stack input) + (.let [size (stack.size input) + output (..empty size)] + (.loop (again [index 0 + input input]) + (.when input + {.#Empty} + output + + {.#Top head tail} + (.exec + (..has! index head output) + (again (,, (n#next index)) tail))))))) + )]))) (the underflow ..Index @@ -325,15 +334,15 @@ (`` (the as_stack|-default (macro (_ ) - [((.is (.for_any (_ read write) - (.-> (.Stack read) (..Array' read write) - (.Stack read))) + [((.is (.for_any (_ to_write to_read) + (.-> (.Stack to_read) (..Array' to_write to_read) + (.Stack to_read))) (.function (_ empty array) - (.loop (again [index (.i64_-# 1 (..size array)) + (.loop (again [index (,, (n#previous (..size array))) output empty]) (.if (.i64_=# (,, (.static ..underflow)) index) output - (again (.i64_-# 1 index) + (again (,, (n#previous index)) (.if (..lacks? index array) output {.#Top (..item index array) output})))))) @@ -341,16 +350,16 @@ (`` (the as_stack|+default (macro (_ ) - [((.is (.for_any (_ read write) - (.-> read (..Array' read write) - (.Stack read))) + [((.is (.for_any (_ to_write to_read) + (.-> to_read (..Array' to_write to_read) + (.Stack to_read))) (.function (_ default array) - (.loop (again [index (.i64_-# 1 (..size array)) + (.loop (again [index (,, (n#previous (..size array))) output (`` (.is (.Stack (,, (.these (,, (.type_of default))))) {.#Empty}))]) (.if (.i64_=# (,, (.static ..underflow)) index) output - (again (.i64_-# 1 index) + (again (,, (n#previous index)) {.#Top (.if (..lacks? index array) default (..item index array)) @@ -359,9 +368,9 @@ (`` (the .public as_stack (macro (_ ) - [((.is (.for_any (_ read write) - (.-> (.Maybe read) (..Array' read write) - (.Stack read))) + [((.is (.for_any (_ to_write to_read) + (.-> (.Maybe to_read) (..Array' to_write to_read) + (.Stack to_read))) (.function (_ default array) (.when default {.#Some default}