diff options
Diffstat (limited to '')
557 files changed, 8048 insertions, 6579 deletions
diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux index ac01ef0f1..4365ea0eb 100644 --- a/stdlib/source/documentation/lux.lux +++ b/stdlib/source/documentation/lux.lux @@ -22,10 +22,10 @@ ["#." program] ["#." static] ["#." target] - ... ["#." test] - ... ["#." time] - ... ... ["#." tool] ... TODO: Documentation for this - ... ["#." type] + ["#." test] + ["#." time] + ... ["#." tool] ... TODO: Documentation for this + ["#." type] ... ["#." world] ... ["#." extension] ... ["#." target #_ @@ -49,7 +49,10 @@ /meta.documentation /program.documentation /static.documentation - /target.documentation])) + /target.documentation + /test.documentation + /time.documentation + /type.documentation])) (program: inputs (io.io (debug.log! ($.documentation ..documentation)))) diff --git a/stdlib/source/documentation/lux/abstract/monad.lux b/stdlib/source/documentation/lux/abstract/monad.lux index cdf12eedf..9b2772a52 100644 --- a/stdlib/source/documentation/lux/abstract/monad.lux +++ b/stdlib/source/documentation/lux/abstract/monad.lux @@ -29,9 +29,9 @@ "Run all the monadic values in the list and produce a list of the base values." [(all monad)]) -(documentation: /.map +(documentation: /.each "Apply a monadic function to all values in a list." - [(map monad function items)]) + [(each monad function items)]) (documentation: /.only "Filter the values in a list with a monadic function." @@ -49,7 +49,7 @@ ..do ..then ..all - ..map + ..each ..only ..mix] [/free.documentation])) diff --git a/stdlib/source/documentation/lux/abstract/monoid.lux b/stdlib/source/documentation/lux/abstract/monoid.lux index e9c7a590e..a8eb4b603 100644 --- a/stdlib/source/documentation/lux/abstract/monoid.lux +++ b/stdlib/source/documentation/lux/abstract/monoid.lux @@ -17,5 +17,5 @@ ($.module /._ "" [..Monoid - ($.default /.composite)] + ($.default /.and)] [])) diff --git a/stdlib/source/documentation/lux/data/collection.lux b/stdlib/source/documentation/lux/data/collection.lux index e96f59465..04470c5ca 100644 --- a/stdlib/source/documentation/lux/data/collection.lux +++ b/stdlib/source/documentation/lux/data/collection.lux @@ -15,14 +15,9 @@ ["#." queue] ["#." row] ["#." sequence] - ... ["#." stack] - ... ["#." set - ... ["#/." multi] - ... ["#/." ordered]] - ... ["#." tree - ... ["#/." finger] - ... ["#/." zipper]] - ]) + ["#." stack] + ["#." set] + ["#." tree]]) (.def: .public documentation (.List $.Module) @@ -34,7 +29,7 @@ /queue.documentation /row.documentation /sequence.documentation - ... /stack.documentation - ... /set.documentation - ... /tree.documentation + /stack.documentation + /set.documentation + /tree.documentation ))) diff --git a/stdlib/source/documentation/lux/data/collection/set.lux b/stdlib/source/documentation/lux/data/collection/set.lux new file mode 100644 index 000000000..2778305ec --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/set.lux @@ -0,0 +1,63 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." multi] + ["#." ordered]]) + +(documentation: /.has + "" + [(has elem set)]) + +(documentation: /.difference + "" + [(difference sub base)]) + +(documentation: /.intersection + "" + [(intersection filter base)]) + +(documentation: /.sub? + "" + [(sub? super sub)]) + +(documentation: /.super? + "" + [(super? sub super)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..has + ..difference + ..intersection + ..sub? + ..super? + ($.default /.Set) + ($.default /.member_hash) + ($.default /.empty) + ($.default /.size) + ($.default /.lacks) + ($.default /.member?) + ($.default /.list) + ($.default /.union) + ($.default /.equivalence) + ($.default /.hash) + ($.default /.monoid) + ($.default /.empty?) + ($.default /.of_list) + ($.default /.predicate)] + [/multi.documentation + /ordered.documentation])) diff --git a/stdlib/source/documentation/lux/data/collection/set/multi.lux b/stdlib/source/documentation/lux/data/collection/set/multi.lux new file mode 100644 index 000000000..6e38886dc --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/set/multi.lux @@ -0,0 +1,81 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Set + "A set that keeps track of repetition in its entries.") + +(documentation: /.has + "" + [(has multiplicity elem set)]) + +(documentation: /.lacks + "" + [(lacks multiplicity elem set)]) + +(documentation: /.multiplicity + "" + [(multiplicity set elem)]) + +(template [<name>] + [(documentation: <name> + "" + [(<name> parameter subject)])] + + [/.union] + [/.sum] + [/.intersection] + [/.difference] + ) + +(documentation: /.sub? + "Is 'subject' a sub-set of 'reference'?" + [(sub? reference subject)]) + +(documentation: /.support + "A set of the unique (non repeated) members." + [(support set)]) + +(documentation: /.member? + "" + [(member? set elem)]) + +(documentation: /.super? + "Is 'subject' a super-set of 'reference'?") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Set + ..has + ..lacks + ..multiplicity + ..union + ..sum + ..intersection + ..difference + ..sub? + ..support + ..member? + ..super? + ($.default /.empty) + ($.default /.size) + ($.default /.list) + ($.default /.equivalence) + ($.default /.hash) + ($.default /.empty?) + ($.default /.of_list) + ($.default /.of_set)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/set/ordered.lux b/stdlib/source/documentation/lux/data/collection/set/ordered.lux new file mode 100644 index 000000000..0ace59c12 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/set/ordered.lux @@ -0,0 +1,64 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Set + "A set with ordered entries.") + +(documentation: /.member? + "" + [(member? set elem)]) + +(documentation: /.has + "" + [(has elem set)]) + +(documentation: /.lacks + "" + [(lacks elem set)]) + +(documentation: /.difference + "" + [(difference param subject)]) + +(documentation: /.sub? + "Is 'sub' a sub-set of 'super'?" + [(sub? super sub)]) + +(documentation: /.super? + "Is 'super' a super-set of 'sub'?" + [(super? sub super)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Set + ..member? + ..has + ..lacks + ..difference + ..sub? + ..super? + ($.default /.empty) + ($.default /.min) + ($.default /.max) + ($.default /.size) + ($.default /.empty?) + ($.default /.list) + ($.default /.of_list) + ($.default /.union) + ($.default /.intersection) + ($.default /.equivalence)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/stack.lux b/stdlib/source/documentation/lux/data/collection/stack.lux new file mode 100644 index 000000000..c020db741 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/stack.lux @@ -0,0 +1,44 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Stack + "A first-in, last-out sequential data-structure.") + +(documentation: /.value + "Yields the top value in the stack, if any." + [(value stack)]) + +(documentation: /.next + "" + [(next stack)]) + +(documentation: /.top + "" + [(top value stack)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Stack + ..value + ..next + ..top + ($.default /.empty) + ($.default /.size) + ($.default /.empty?) + ($.default /.equivalence) + ($.default /.functor)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/tree.lux b/stdlib/source/documentation/lux/data/collection/tree.lux new file mode 100644 index 000000000..310073287 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/tree.lux @@ -0,0 +1,55 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." finger] + ["#." zipper]]) + +(documentation: /.Tree + "A generic tree data-structure.") + +(documentation: /.flat + "All the leaf values of the tree, in order." + [(flat tree)]) + +(documentation: /.leaf + "" + [(leaf value)]) + +(documentation: /.branch + "" + [(branch value children)]) + +(documentation: /.tree + "Tree literals." + [(: (Tree Nat) + (tree 12 + {34 {} + 56 {} + 78 {90 {}}}))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Tree + ..flat + ..leaf + ..branch + ..tree + ($.default /.equivalence) + ($.default /.functor) + ($.default /.mix)] + [/finger.documentation + /zipper.documentation])) diff --git a/stdlib/source/documentation/lux/data/collection/tree/finger.lux b/stdlib/source/documentation/lux/data/collection/tree/finger.lux new file mode 100644 index 000000000..683d98f51 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/tree/finger.lux @@ -0,0 +1,60 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Tree + "A finger tree.") + +(documentation: /.Builder + "A builder for finter tree structures.") + +(documentation: /.builder + "A new builder using the given monoid." + [(builder monoid)]) + +(documentation: /.value + "" + [(value tree)]) + +(documentation: /.tags + "" + [(tags tree)]) + +(documentation: /.values + "" + [(values tree)]) + +(documentation: /.one + "Finds one value that meets the predicate." + [(one predicate tree)]) + +(documentation: /.exists? + "Verifies that a value exists which meets the predicate." + [(exists? predicate tree)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Tree + ..Builder + ..builder + ..value + ..tags + ..values + ..one + ..exists? + ($.default /.tag) + ($.default /.root)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/tree/zipper.lux b/stdlib/source/documentation/lux/data/collection/tree/zipper.lux new file mode 100644 index 000000000..d67fb37bf --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/tree/zipper.lux @@ -0,0 +1,67 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Zipper + "Tree zippers, for easy navigation and editing of trees.") + +(documentation: /.set + "" + [(set value zipper)]) + +(documentation: /.update + "" + [(update transform zipper)]) + +(documentation: /.interpose + "" + [(interpose value zipper)]) + +(documentation: /.adopt + "" + [(adopt value zipper)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Zipper + ..set + ..update + ..interpose + ..adopt + ($.default /.equivalence) + ($.default /.zipper) + ($.default /.tree) + ($.default /.value) + ($.default /.leaf?) + ($.default /.branch?) + ($.default /.start?) + ($.default /.down) + ($.default /.up) + ($.default /.right) + ($.default /.rightmost) + ($.default /.left) + ($.default /.leftmost) + ($.default /.next) + ($.default /.previous) + ($.default /.end) + ($.default /.start) + ($.default /.end?) + ($.default /.remove) + ($.default /.insert_left) + ($.default /.insert_right) + ($.default /.functor) + ($.default /.comonad)] + [])) diff --git a/stdlib/source/documentation/lux/macro/syntax.lux b/stdlib/source/documentation/lux/macro/syntax.lux index b0e76e1a8..feb49c8e9 100644 --- a/stdlib/source/documentation/lux/macro/syntax.lux +++ b/stdlib/source/documentation/lux/macro/syntax.lux @@ -30,11 +30,11 @@ interfaces (tuple (some (super_class_decl^ imports class_vars))) constructor_args (constructor_args^ imports class_vars) methods (some (overriden_method_def^ imports))]) - (let [def_code ($_ text\compose "anon-class:" + (let [def_code ($_ text\composite "anon-class:" (spaced (list (super_class_decl$ (maybe.else object_super_class super)) - (with_brackets (spaced (list\map super_class_decl$ interfaces))) - (with_brackets (spaced (list\map constructor_arg$ constructor_args))) - (with_brackets (spaced (list\map (method_def$ id) methods))))))] + (with_brackets (spaced (list\each super_class_decl$ interfaces))) + (with_brackets (spaced (list\each constructor_arg$ constructor_args))) + (with_brackets (spaced (list\each (method_def$ id) methods))))))] (in (list (` ((~ (code.text def_code))))))))]) (.def: .public documentation diff --git a/stdlib/source/documentation/lux/math/logic.lux b/stdlib/source/documentation/lux/math/logic.lux index f5aaddfc3..35f21fbe7 100644 --- a/stdlib/source/documentation/lux/math/logic.lux +++ b/stdlib/source/documentation/lux/math/logic.lux @@ -13,6 +13,6 @@ (.def: .public documentation (.List $.Module) - ($_ list\compose + ($_ list\composite /continuous.documentation /fuzzy.documentation)) diff --git a/stdlib/source/documentation/lux/meta/annotation.lux b/stdlib/source/documentation/lux/meta/annotation.lux index 42582dad5..ba739e129 100644 --- a/stdlib/source/documentation/lux/meta/annotation.lux +++ b/stdlib/source/documentation/lux/meta/annotation.lux @@ -50,7 +50,6 @@ ($.default /.flagged?) ($.default /.implementation?) ($.default /.recursive_type?) - ($.default /.interface?) ($.default /.function_arguments) ($.default /.type_arguments)] [])) diff --git a/stdlib/source/documentation/lux/test.lux b/stdlib/source/documentation/lux/test.lux new file mode 100644 index 000000000..c241747c0 --- /dev/null +++ b/stdlib/source/documentation/lux/test.lux @@ -0,0 +1,126 @@ +(.module: + [library + [lux (#- and for) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Tally + "A record of successes and failures while executing tests.") + +(documentation: /.Assertion + "An asynchronous operation that yields test results.") + +(documentation: /.Test + "A test that relies on random data generation to thoroughly cover different scenarios.") + +(documentation: /.and' + "Sequencing combinator (for assertions)." + [(and' left right)]) + +(documentation: /.and + "Sequencing combinator." + [(and left right)]) + +(documentation: /.context + "Adds a contextual description to a test's documentation." + [(context description)]) + +(documentation: /.failure + "A failing test, with a given error message.") + +(documentation: /.assertion + "Check that a condition is #1, and fail with the given message otherwise." + [(assertion message condition)]) + +(documentation: /.test + "Check that a condition is #1, and fail with the given message otherwise." + [(test message condition)]) + +(documentation: /.lifted + "" + [(lifted message random)]) + +(documentation: /.Seed + "The seed value used for random testing (if that feature is used).") + +(documentation: /.seed + (format "Execute the given test with a specific seed value." + \n "This allows you to reproduce a failing test case as many times as you want while debugging.") + [(seed value test)]) + +(documentation: /.times + (format "Allows executing a test several times." + \n "By doing this, it's possible to thoroughly test code with many different scenarios." + \n "This assumes that random data generation is being used in tests instead of fixed/constant inputs.") + [(times amount test)]) + +(documentation: /.run! + (format "Executes a test, and exits the program with either a successful or a failing exit code." + \n "WARNING: This procedure is only meant to be used in (program: ...) forms.") + [(run! test)]) + +(template [<macro>] + [(documentation: <macro> + (format "Specifies a test as covering one or more definitions." + \n "Adds to the test tally information to track which definitions have been tested.") + [(<macro> [definition/0 definition/1 ,,, definition/N] + (: Bit + (some "computation")))])] + + [/.cover'] + [/.cover] + ) + +(documentation: /.for + (format "Specifies a context for tests as covering one or more definitions." + \n "Adds to the test tally information to track which definitions have been tested.") + [(for [definition/0 definition/1 ,,, definition/N] + (: Test + some_test))]) + +(documentation: /.covering + (format "Specifies the module being covered by a test." + \n "Adds tracking information to the tally to know which exported definitions in the module need to be covered.") + [(covering .._ + (: Test + some_test))]) + +(documentation: /.in_parallel + "Executes multiple tests in parallel (if the host platform supports it) to take advantage of multiple cores." + [(in_parallel tests)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "Tools for unit & property-based/generative testing." + [..Tally + ..Assertion + ..Test + ..and' + ..and + ..context + ..failure + ..assertion + ..test + ..lifted + ..Seed + ..seed + ..times + ..run! + ..cover' + ..cover + ..for + ..covering + ..in_parallel + ($.default /.must_try_test_at_least_once) + ($.default /.error_during_execution)] + [])) diff --git a/stdlib/source/documentation/lux/time.lux b/stdlib/source/documentation/lux/time.lux new file mode 100644 index 000000000..1960eec4b --- /dev/null +++ b/stdlib/source/documentation/lux/time.lux @@ -0,0 +1,87 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." date] + ["#." day] + ["#." duration] + ["#." instant] + ["#." month] + ["#." year]]) + +(template [<name> <doc>] + [(documentation: <name> + <doc>)] + + [/.milli_seconds "Number of milli-seconds in a second."] + [/.seconds "Number of seconds in a minute."] + [/.minutes "Number of minutes in an hour."] + [/.hours "Number of hours in an day."] + ) + +(documentation: /.Time + "Time is defined as milliseconds since the start of the day (00:00:00.000).") + +(documentation: /.midnight + "The instant corresponding to the start of the day: 00:00:00.000") + +(documentation: /.of_millis + "" + [(of_millis milli_seconds)]) + +(documentation: /.Clock + "A clock marking the specific hour, minute, second, and milli-second in a day.") + +(documentation: /.clock + "" + [(clock time)]) + +(documentation: /.time + "" + [(time clock)]) + +(documentation: /.codec + (format "Based on ISO 8601." + \n "For example: 21:14:51.827")) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..milli_seconds + ..seconds + ..minutes + ..hours + ..Time + ..midnight + ..of_millis + ..Clock + ..clock + ..time + ..codec + ($.default /.time_exceeds_a_day) + ($.default /.invalid_hour) + ($.default /.invalid_minute) + ($.default /.invalid_second) + ($.default /.millis) + ($.default /.equivalence) + ($.default /.order) + ($.default /.enum) + ($.default /.parser)] + [/date.documentation + /day.documentation + /duration.documentation + /instant.documentation + /month.documentation + /year.documentation])) diff --git a/stdlib/source/documentation/lux/time/date.lux b/stdlib/source/documentation/lux/time/date.lux new file mode 100644 index 000000000..ebb55be13 --- /dev/null +++ b/stdlib/source/documentation/lux/time/date.lux @@ -0,0 +1,46 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Date + "A date specified as a year/month/day triplet.") + +(documentation: /.date + "A date, within the allowed limits." + [(date year month day_of_month)]) + +(documentation: /.codec + (format "Based on ISO 8601." + \n "For example: 2017-01-15")) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Date + ..date + ..codec + ($.default /.invalid_day) + ($.default /.epoch) + ($.default /.year) + ($.default /.month) + ($.default /.day_of_month) + ($.default /.equivalence) + ($.default /.order) + ($.default /.invalid_month) + ($.default /.parser) + ($.default /.days) + ($.default /.of_days) + ($.default /.enum)] + [])) diff --git a/stdlib/source/documentation/lux/time/day.lux b/stdlib/source/documentation/lux/time/day.lux new file mode 100644 index 000000000..df87b2ea8 --- /dev/null +++ b/stdlib/source/documentation/lux/time/day.lux @@ -0,0 +1,37 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Day + "A day of the week.") + +(documentation: /.week + "All the days, ordered by when they come in a week.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Day + ..week + ($.default /.equivalence) + ($.default /.order) + ($.default /.enum) + ($.default /.not_a_day_of_the_week) + ($.default /.codec) + ($.default /.number) + ($.default /.invalid_day) + ($.default /.by_number) + ($.default /.hash)] + [])) diff --git a/stdlib/source/documentation/lux/time/duration.lux b/stdlib/source/documentation/lux/time/duration.lux new file mode 100644 index 000000000..be4cf82b4 --- /dev/null +++ b/stdlib/source/documentation/lux/time/duration.lux @@ -0,0 +1,54 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Duration + "Durations have a resolution of milli-seconds.") + +(documentation: /.difference + "" + [(difference from to)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Duration + ..difference + ($.default /.of_millis) + ($.default /.millis) + ($.default /.merged) + ($.default /.framed) + ($.default /.up) + ($.default /.down) + ($.default /.inverse) + ($.default /.ticks) + ($.default /.equivalence) + ($.default /.order) + ($.default /.positive?) + ($.default /.negative?) + ($.default /.neutral?) + ($.default /.empty) + ($.default /.milli_second) + ($.default /.second) + ($.default /.minute) + ($.default /.hour) + ($.default /.day) + ($.default /.week) + ($.default /.normal_year) + ($.default /.leap_year) + ($.default /.monoid) + ($.default /.codec) + ($.default /.enum)] + [])) diff --git a/stdlib/source/documentation/lux/time/instant.lux b/stdlib/source/documentation/lux/time/instant.lux new file mode 100644 index 000000000..6672c2329 --- /dev/null +++ b/stdlib/source/documentation/lux/time/instant.lux @@ -0,0 +1,70 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Instant + "Instant is defined as milli-seconds since the epoch.") + +(documentation: /.span + "" + [(span from to)]) + +(documentation: /.after + "" + [(after duration instant)]) + +(documentation: /.relative + "" + [(relative instant)]) + +(documentation: /.absolute + "" + [(absolute offset)]) + +(documentation: /.epoch + "The instant corresponding to 1970-01-01T00:00:00Z.") + +(documentation: /.codec + (format "Based on ISO 8601." + \n "For example: 2017-01-15T21:14:51.827Z")) + +(documentation: /.now + "Yields the current instant, as measured from the operating-system's clock.") + +(documentation: /.of_date_time + "" + [(of_date_time date time)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Instant + ..span + ..after + ..relative + ..absolute + ..epoch + ..codec + ..now + ..of_date_time + ($.default /.of_millis) + ($.default /.millis) + ($.default /.equivalence) + ($.default /.order) + ($.default /.enum) + ($.default /.date) + ($.default /.time) + ($.default /.day_of_week)] + [])) diff --git a/stdlib/source/documentation/lux/time/month.lux b/stdlib/source/documentation/lux/time/month.lux new file mode 100644 index 000000000..9c142401e --- /dev/null +++ b/stdlib/source/documentation/lux/time/month.lux @@ -0,0 +1,47 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Month + "A month of the year.") + +(documentation: /.days + "The amount of days of a month." + [(days month)]) + +(documentation: /.leap_year_days + "The amount of days of a month (in a leap year)." + [(leap_year_days month)]) + +(documentation: /.year + "All the months, ordered by when they come in a year.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Month + ..days + ..leap_year_days + ..year + ($.default /.equivalence) + ($.default /.number) + ($.default /.invalid_month) + ($.default /.by_number) + ($.default /.hash) + ($.default /.order) + ($.default /.enum) + ($.default /.not_a_month_of_the_year) + ($.default /.codec)] + [])) diff --git a/stdlib/source/documentation/lux/time/year.lux b/stdlib/source/documentation/lux/time/year.lux new file mode 100644 index 000000000..1949a750a --- /dev/null +++ b/stdlib/source/documentation/lux/time/year.lux @@ -0,0 +1,59 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Year + (format "A year in the gregorian calendar." + \n "Both negative (< 0) and positive (> 0) values are valid, but not 0." + \n "This is because the first year of the gregorian calendar was year 1.")) + +(documentation: /.year + "A valid year in the gregorian calendar, if possible." + [(year value)]) + +(documentation: /.days + "The amount of days in a typical year.") + +(documentation: /.Period + "An amount of years.") + +(documentation: /.leaps + "The number of leap years in a period of years." + [(leaps year)]) + +(documentation: /.codec + (format "Based on ISO 8601." + \n "For example: 2017")) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Year + ..year + ..days + ..Period + ..leaps + ..codec + ($.default /.there_is_no_year_0) + ($.default /.value) + ($.default /.epoch) + ($.default /.leap) + ($.default /.century) + ($.default /.era) + ($.default /.leap?) + ($.default /.parser) + ($.default /.equivalence) + ($.default /.order)] + [])) diff --git a/stdlib/source/documentation/lux/type.lux b/stdlib/source/documentation/lux/type.lux new file mode 100644 index 000000000..0ad9a5f51 --- /dev/null +++ b/stdlib/source/documentation/lux/type.lux @@ -0,0 +1,43 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." abstract] + ["#." check] + ["#." dynamic] + ["#." implicit] + ... ["#." poly] + ... ["#." quotient] + ... ["#." refinement] + ... ["#." resource] + ... ["#." unit] + ... ["#." variance] + ]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [] + [/abstract.documentation + /check.documentation + /dynamic.documentation + /implicit.documentation + ... /poly.documentation + ... /quotient.documentation + ... /refinement.documentation + ... /resource.documentation + ... /unit.documentation + ... /variance.documentation + ])) diff --git a/stdlib/source/documentation/lux/type/abstract.lux b/stdlib/source/documentation/lux/type/abstract.lux new file mode 100644 index 000000000..8b1bf10ca --- /dev/null +++ b/stdlib/source/documentation/lux/type/abstract.lux @@ -0,0 +1,150 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Frame + "Meta-data about an abstract/nominal type in a stack of them.") + +(documentation: /.current + "The currently-being-defined abstract/nominal type.") + +(documentation: /.specific + "A specific abstract/nominal type still being defined somewhere in the scope." + [(specific name)]) + +(template [<name> <from> <to>] + [(documentation: <name> + "Type-casting macro for abstract/nominal types." + [(: <to> + (<name> (: <from> value)))])] + + [/.:abstraction representation abstraction] + [/.:representation abstraction representation] + ) + +(documentation: /.abstract: + (format "Define abstract/nominal types which hide their representation details." + \n "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others.") + [(abstract: String + {} + + Text + + (def: (string value) + (-> Text String) + (:abstraction value)) + + (def: (text value) + (-> String Text) + (:representation value)))] + ["Type-parameters are optional." + (abstract: (Duplicate a) + {} + + [a a] + + (def: (duplicate value) + (All [a] (-> a (Duplicate a))) + (:abstraction [value value])))] + ["Definitions can be nested." + (abstract: (Single a) + {} + + a + + (def: (single value) + (All [a] (-> a (Single a))) + (:abstraction value)) + + (abstract: (Double a) + {} + + [a a] + + (def: (double value) + (All [a] (-> a (Double a))) + (:abstraction [value value])) + + (def: (single' value) + (All [a] (-> a (Single a))) + (:abstraction Single [value value])) + + (let [value 0123] + (same? value + (|> value + single' + (:representation Single) + double + :representation)))))] + ["Type-parameters do not necessarily have to be used in the representation type." + "If they are not used, they become phantom types and can be used to customize types without changing the representation." + (abstract: (JavaScript a) + {} + + Text + + (abstract: Expression {} Any) + (abstract: Statement {} Any) + + (def: (+ x y) + (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression)) + (:abstraction + (format "(" (:representation x) "+" (:representation y) ")"))) + + (def: (while test body) + (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement)) + (:abstraction + (format "while(" (:representation test) ") {" + (:representation body) + "}"))))]) + +(documentation: /.:transmutation + "Transmutes an abstract/nominal type's phantom types." + [(abstract: (JavaScript a) + {} + + Text + + (abstract: Expression {} Any) + (abstract: Statement {} Any) + + (def: (statement expression) + (-> (JavaScript Expression) (JavaScript Statement)) + (:transmutation expression)) + + (def: (statement' expression) + (-> (JavaScript Expression) (JavaScript Statement)) + (:transmutation JavaScript expression)))]) + +(documentation: /.^:representation + "Pattern-matching macro to easily extract a representation." + [(def: (computation abstraction) + (All [a] (-> (Abstract a) ???)) + (let [(^:representation value) abstraction] + (foo (bar (baz value)))))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Frame + ..current + ..specific + ..:abstraction + ..:representation + ..abstract: + ..:transmutation + ..^:representation + ($.default /.no_active_frames)] + [])) diff --git a/stdlib/source/documentation/lux/type/check.lux b/stdlib/source/documentation/lux/type/check.lux new file mode 100644 index 000000000..3264a87a3 --- /dev/null +++ b/stdlib/source/documentation/lux/type/check.lux @@ -0,0 +1,96 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Var + "The ID for a type-variable in a type-checking context.") + +(documentation: /.Check + "A type-checking computation which may fail or yield a value.") + +(documentation: /.result + "" + [(result context proc)]) + +(documentation: /.failure + "" + [(failure message)]) + +(documentation: /.assertion + "" + [(assertion message test)]) + +(documentation: /.except + "" + [(except exception message)]) + +(documentation: /.existential + "A brand-new existential type.") + +(documentation: /.bind + (format "Attemmpts to buy a type-variable." + \n "Fails if the variable has been bound already.") + [(bind type id)]) + +(documentation: /.var + "A brand-new (unbound) type-variable.") + +(documentation: /.fresh_context + "An empty/un-used type-checking context.") + +(documentation: /.check + "Type-check to ensure that the 'expected' type subsumes the 'actual' type." + [(check expected actual)]) + +(documentation: /.subsumes? + "A simple type-checking function that just returns a yes/no answer." + [(subsumes? expected actual)]) + +(documentation: /.context + "The current state of the type-checking context.") + +(documentation: /.clean + "Resolves every bound type-variable to yield a new type that is as resolved as possible." + [(clean inputT)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "Type-checking functionality." + [..Var + ..Check + ..result + ..failure + ..assertion + ..except + ..existential + ..bind + ..var + ..fresh_context + ..check + ..subsumes? + ..context + ..clean + ($.default /.unknown_type_var) + ($.default /.unbound_type_var) + ($.default /.invalid_type_application) + ($.default /.cannot_rebind_var) + ($.default /.type_check_failed) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.bound?) + ($.default /.read') + ($.default /.read)] + [])) diff --git a/stdlib/source/documentation/lux/type/dynamic.lux b/stdlib/source/documentation/lux/type/dynamic.lux new file mode 100644 index 000000000..2811fc92e --- /dev/null +++ b/stdlib/source/documentation/lux/type/dynamic.lux @@ -0,0 +1,38 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Dynamic + "A value coupled with its type, so it can be checked later.") + +(documentation: /.:dynamic + "" + [(: Dynamic + (:dynamic 123))]) + +(documentation: /.:static + "" + [(: (try.Try Nat) + (:static Nat (:dynamic 123)))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Dynamic + ..:dynamic + ..:static + ($.default /.wrong_type) + ($.default /.format)] + [])) diff --git a/stdlib/source/documentation/lux/type/implicit.lux b/stdlib/source/documentation/lux/type/implicit.lux new file mode 100644 index 000000000..fea6cbf44 --- /dev/null +++ b/stdlib/source/documentation/lux/type/implicit.lux @@ -0,0 +1,60 @@ +(.module: + [library + [lux (#- and) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.\\ + (format "Automatic implementation selection (for type-class style polymorphism)." + \n "This feature layers type-class style polymorphism on top of Lux's signatures and implementations." + \n "When calling a polymorphic function, or using a polymorphic constant," + \n "this macro will check the types of the arguments, and the expected type for the whole expression" + \n "and it will search in the local scope, the module's scope and the imports' scope" + \n "in order to find suitable implementations to satisfy those requirements." + \n "If a single alternative is found, that one will be used automatically." + \n "If no alternative is found, or if more than one alternative is found (ambiguity)" + \n "a compile-time error will be raised, to alert the user." + \n \n "Caveat emptor: You need to make sure to import the module of any implementation you want to use." + \n "Otherwise, this macro will not find it.") + ["Nat equivalence" + (\ number.equivalence = x y) + (\\ = x y)] + ["Can optionally add the prefix of the module where the signature was defined." + (\\ equivalence.= x y)] + ["(List Nat) equivalence" + (\\ = + (list.indices 10) + (list.indices 10))] + ["(Functor List) each" + (\\ each ++ (list.indices 10))]) + +(documentation: /.with + "Establish lexical bindings for implementations that will be prioritized over non-lexically-bound implementations." + [(with [n.addition] + (n.= (\ n.addition composite left right) + (\\ composite left right)))]) + +(documentation: /.implicit: + "Establish local definitions for implementations that will be prioritized over foreign definitions." + [(implicit: [n.multiplication]) + + (n.= (\ n.multiplication composite left right) + (\\ composite left right))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..\\ + ..with + ..implicit:] + [])) diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index ffe7daf46..9770f131c 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -837,7 +837,7 @@ _ (failure "Wrong syntax for let''")} tokens))) - (record$ #.End) + (record$ #End) #0) ("lux def" function'' @@ -874,7 +874,7 @@ _ (failure "Wrong syntax for function''")} tokens))) - (record$ #.End) + (record$ #End) #0) ("lux def" location_code @@ -959,7 +959,7 @@ _ (failure "Wrong syntax for def''")} tokens))) - (record$ #.End) + (record$ #End) #0) ("lux def" macro:' @@ -984,7 +984,7 @@ _ (failure "Wrong syntax for macro:'")} tokens))) - (record$ #.End) + (record$ #End) #0) (macro:' .public (comment tokens) @@ -1012,7 +1012,7 @@ (failure "Wrong syntax for $'")} tokens)) -(def:'' .private (list\map f xs) +(def:'' .private (list\each f xs) #End (#UnivQ #End (#UnivQ #End @@ -1023,7 +1023,7 @@ #End (#Item x xs') - (#Item (f x) (list\map f xs'))} + (#Item (f x) (list\each f xs'))} xs)) (def:'' .private Replacement_Environment @@ -1073,25 +1073,25 @@ (..replacement name reps)) [meta (#Form parts)] - [meta (#Form (list\map (with_replacements reps) parts))] + [meta (#Form (list\each (with_replacements reps) parts))] [meta (#Tuple members)] - [meta (#Tuple (list\map (with_replacements reps) members))] + [meta (#Tuple (list\each (with_replacements reps) members))] [meta (#Record slots)] - [meta (#Record (list\map ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) - (function'' [slot] - ({[k v] - [(with_replacements reps k) (with_replacements reps v)]} - slot))) - slots))] + [meta (#Record (list\each ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) + (function'' [slot] + ({[k v] + [(with_replacements reps k) (with_replacements reps v)]} + slot))) + slots))] _ syntax} syntax)) (def:'' .private (n/* param subject) - #.End + #End (#Function Nat (#Function Nat Nat)) ("lux type as" Nat ("lux i64 *" @@ -1102,20 +1102,20 @@ #End (#Function Code Code) ({[_ (#Tuple members)] - (tuple$ (list\map nested_quantification members)) + (tuple$ (list\each nested_quantification members)) [_ (#Record pairs)] - (record$ (list\map ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) - (function'' [pair] - (let'' [name val] pair - [name (nested_quantification val)]))) - pairs)) + (record$ (list\each ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) + (function'' [pair] + (let'' [name val] pair + [name (nested_quantification val)]))) + pairs)) [_ (#Form (#Item [_ (#Tag "library/lux" "Parameter")] (#Item [_ (#Nat idx)] #End)))] (form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ ("lux i64 +" 2 idx)) #End))) [_ (#Form members)] - (form$ (list\map nested_quantification members)) + (form$ (list\each nested_quantification members)) _ code} @@ -1173,7 +1173,7 @@ ("lux text concat" "(All [a] (-> a a))" __paragraph) ("lux text concat" ("lux text concat" "... A name can be provided, to specify a recursive type." __paragraph) - "(All List [a] (Variant Any [a (List a)]))"))))] + "(All List [a] (Union Any [a (List a)]))"))))] #End) (let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens) [self_name tokens] @@ -1315,15 +1315,15 @@ (failure "Wrong syntax for list&")} (list\reversed xs))) -(macro:' .public (Variant tokens) +(macro:' .public (Union tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "... Variant types:" __paragraph) + ("lux text concat" "... Union types:" __paragraph) ("lux text concat" - ("lux text concat" "(Variant Text Int Bit)" __paragraph) + ("lux text concat" "(Union Text Int Bit)" __paragraph) ("lux text concat" ("lux text concat" "... Nothing." __paragraph) - "(Variant)"))))] + "(Union)"))))] #End) ({#End (in_meta (list (identifier$ ["library/lux" "Nothing"]))) @@ -1413,10 +1413,10 @@ (def:''' .public Or (#Item [(tag$ ["library/lux" "doc"]) - (text$ "An alias for the Variant type constructor.")] + (text$ "An alias for the Union type constructor.")] #End) Macro - ..Variant) + ..Union) (def:''' .public And (#Item [(tag$ ["library/lux" "doc"]) @@ -1479,11 +1479,11 @@ (_ann (#Form (list (_ann (#Tag ["library/lux" "Item"])) token (untemplated_list tokens'))))} tokens)) -(def:''' .private (list\compose xs ys) +(def:''' .private (list\composite xs ys) #End (All [a] (-> ($' List a) ($' List a) ($' List a))) ({(#Item x xs') - (#Item x (list\compose xs' ys)) + (#Item x (list\composite xs' ys)) #End ys} @@ -1493,7 +1493,7 @@ #End (-> Code Code Code Code) ({[_ (#Form parts)] - (form$ (list\compose parts (list a1 a2))) + (form$ (list\composite parts (list a1 a2))) _ (form$ (list op a1 a2))} @@ -1511,10 +1511,10 @@ (text$ ("lux text concat" ("lux text concat" "... Left-association for the application of binary functions over variadic arguments." ..\n) ("lux text concat" - ("lux text concat" "(_$ text\compose ''Hello, '' name ''. How are you?'')" ..\n) + ("lux text concat" "(_$ text\composite ''Hello, '' name ''. How are you?'')" ..\n) ("lux text concat" ("lux text concat" "... =>" ..\n) - "(text\compose (text\compose ''Hello, '' name) ''. How are you?'')"))))] + "(text\composite (text\composite ''Hello, '' name) ''. How are you?'')"))))] #End) ({(#Item op tokens') ({(#Item first nexts) @@ -1533,10 +1533,10 @@ (text$ ("lux text concat" ("lux text concat" "... Right-association for the application of binary functions over variadic arguments." ..\n) ("lux text concat" - ("lux text concat" "($_ text\compose ''Hello, '' name ''. How are you?'')" ..\n) + ("lux text concat" "($_ text\composite ''Hello, '' name ''. How are you?'')" ..\n) ("lux text concat" ("lux text concat" "... =>" ..\n) - "(text\compose ''Hello, '' (text\compose name ''. How are you?''))"))))] + "(text\composite ''Hello, '' (text\composite name ''. How are you?''))"))))] #End) ({(#Item op tokens') ({(#Item last prevs) @@ -1629,7 +1629,7 @@ (failure "Wrong syntax for do")} tokens)) -(def:''' .private (monad\map m f xs) +(def:''' .private (monad\each m f xs) #End ... (All [m a b] ... (-> (Monad m) (-> a (m b)) (List a) (m (List b)))) @@ -1645,7 +1645,7 @@ (#Item x xs') (do m [y (f x) - ys (monad\map m f xs')] + ys (monad\each m f xs')] (in (#Item y ys)))} xs))) @@ -1702,7 +1702,7 @@ #None} plist)) -(def:''' .private (text\compose x y) +(def:''' .private (text\composite x y) #End (-> Text Text Text) ("lux text concat" x y)) @@ -1712,7 +1712,7 @@ (-> Name Text) (let' [[module name] full_name] ({"" name - _ ($_ text\compose module "." name)} + _ ($_ text\composite module "." name)} module))) (def:''' .private (global_identifier full_name state) @@ -1733,11 +1733,11 @@ constant) #None - (#Left ($_ text\compose "Unknown definition: " (name\encoded full_name)))} + (#Left ($_ text\composite "Unknown definition: " (name\encoded full_name)))} (plist\value name definitions)) #None - (#Left ($_ text\compose "Unknown module: " module " @ " (name\encoded full_name)))} + (#Left ($_ text\composite "Unknown module: " module " @ " (name\encoded full_name)))} (plist\value module modules)))) (def:''' .private (code_list expression) @@ -1771,7 +1771,7 @@ ({[_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] (let' [g!in-module (form$ (list (text$ "lux in-module") (text$ "library/lux") - (identifier$ ["library/lux" "list\compose"])))] + (identifier$ ["library/lux" "list\composite"])))] (in (form$ (list g!in-module (code_list spliced) rightO)))) _ @@ -1784,7 +1784,7 @@ (list\reversed elems)) #0 (do meta_monad - [=elems (monad\map meta_monad untemplated elems)] + [=elems (monad\each meta_monad untemplated elems)] (in (untemplated_list =elems)))} replace?)) @@ -1872,15 +1872,15 @@ [_ [_ (#Record fields)]] (do meta_monad - [=fields (monad\map meta_monad - ("lux type check" (-> (Tuple Code Code) ($' Meta Code)) - (function' [kv] - (let' [[k v] kv] - (do meta_monad - [=k (untemplated replace? subst k) - =v (untemplated replace? subst v)] - (in (tuple$ (list =k =v))))))) - fields)] + [=fields (monad\each meta_monad + ("lux type check" (-> (Tuple Code Code) ($' Meta Code)) + (function' [kv] + (let' [[k v] kv] + (do meta_monad + [=k (untemplated replace? subst k) + =v (untemplated replace? subst v)] + (in (tuple$ (list =k =v))))))) + fields)] (in (with_location (form$ (list (tag$ ["library/lux" "Record"]) (untemplated_list =fields))))))} [replace? token])) @@ -1965,17 +1965,17 @@ (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "... Piping macro." __paragraph - "(|> elems (list\map int\encoded) (interposed '' '') (mix text\compose ''''))" __paragraph + "(|> elems (list\each int\encoded) (interposed '' '') (mix text\composite ''''))" __paragraph "... =>" __paragraph - "(mix text\compose '''' (interposed '' '' (list\map int\encoded elems)))"))]) + "(mix text\composite '''' (interposed '' '' (list\each int\encoded elems)))"))]) ({(#Item [init apps]) (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [app acc] ({[_ (#Tuple parts)] - (tuple$ (list\compose parts (list acc))) + (tuple$ (list\composite parts (list acc))) [_ (#Form parts)] - (form$ (list\compose parts (list acc))) + (form$ (list\composite parts (list acc))) _ (` ((~ app) (~ acc)))} @@ -1991,17 +1991,17 @@ (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "... Reverse piping macro." __paragraph - "(<| (mix text\compose '''') (interposed '' '') (list\map int\encoded) elems)" __paragraph + "(<| (mix text\composite '''') (interposed '' '') (list\each int\encoded) elems)" __paragraph "... =>" __paragraph - "(mix text\compose '''' (interposed '' '' (list\map int\encoded elems)))"))]) + "(mix text\composite '''' (interposed '' '' (list\each int\encoded elems)))"))]) ({(#Item [init apps]) (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [app acc] ({[_ (#Tuple parts)] - (tuple$ (list\compose parts (list acc))) + (tuple$ (list\composite parts (list acc))) [_ (#Form parts)] - (form$ (list\compose parts (list acc))) + (form$ (list\composite parts (list acc))) _ (` ((~ app) (~ acc)))} @@ -2072,17 +2072,17 @@ (..replacement sname env)) [meta (#Tuple elems)] - [meta (#Tuple (list\map (realized_template env) elems))] + [meta (#Tuple (list\each (realized_template env) elems))] [meta (#Form elems)] - [meta (#Form (list\map (realized_template env) elems))] + [meta (#Form (list\each (realized_template env) elems))] [meta (#Record members)] - [meta (#Record (list\map ("lux type check" (-> (Tuple Code Code) (Tuple Code Code)) - (function' [kv] - (let' [[slot value] kv] - [(realized_template env slot) (realized_template env value)]))) - members))] + [meta (#Record (list\each ("lux type check" (-> (Tuple Code Code) (Tuple Code Code)) + (function' [kv] + (let' [[slot value] kv] + [(realized_template env slot) (realized_template env value)]))) + members))] _ template} @@ -2129,11 +2129,11 @@ #1 ("lux i64 =" reference sample))) -(def:''' .private (list\joined xs) +(def:''' .private (list\conjoint xs) #End (All [a] (-> ($' List ($' List a)) ($' List a))) - (list\mix list\compose #End (list\reversed xs))) + (list\mix list\composite #End (list\reversed xs))) (macro:' .public (template tokens) (list [(tag$ ["library/lux" "doc"]) @@ -2146,20 +2146,20 @@ ({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])]) ({[(#Some bindings') (#Some data')] (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) - (function' [env] (list\map (realized_template env) templates))) + (function' [env] (list\each (realized_template env) templates))) num_bindings (list\size bindings')] (if (every? (function' [size] ("lux i64 =" num_bindings size)) - (list\map list\size data')) + (list\each list\size data')) (|> data' - (list\map (function\composite apply (replacement_environment bindings'))) - list\joined + (list\each (function\composite apply (replacement_environment bindings'))) + list\conjoint in_meta) (failure "Irregular arguments tuples for template."))) _ (failure "Wrong syntax for template")} - [(monad\map maybe_monad identifier_short bindings) - (monad\map maybe_monad tuple_list data)]) + [(monad\each maybe_monad identifier_short bindings) + (monad\each maybe_monad tuple_list data)]) _ (failure "Wrong syntax for template")} @@ -2226,8 +2226,8 @@ (if ("lux i64 =" 0 input) output (recur (n// 10 input) - (text\compose (|> input (n/% 10) digit::format) - output)))))] + (text\composite (|> input (n/% 10) digit::format) + output)))))] (loop value ""))} value)) @@ -2249,10 +2249,10 @@ (("lux type check" (-> Int Text Text) (function' recur [input output] (if ("lux i64 =" +0 input) - (text\compose sign output) + (text\composite sign output) (recur ("lux i64 /" +10 input) - (text\compose (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) - output))))) + (text\composite (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) + output))))) (|> value ("lux i64 /" +10) int\abs) (|> value ("lux i64 %" +10) int\abs ("lux type as" Nat) digit::format))))) @@ -2386,8 +2386,8 @@ ({(#Some macro) (do meta_monad [top_level_expansion (("lux type as" Macro' macro) args) - recursive_expansion (monad\map meta_monad expansion top_level_expansion)] - (in (list\joined recursive_expansion))) + recursive_expansion (monad\each meta_monad expansion top_level_expansion)] + (in (list\conjoint recursive_expansion))) #None (in_meta (list token))} @@ -2407,53 +2407,112 @@ ({(#Some macro) (do meta_monad [expansion (("lux type as" Macro' macro) args) - expansion' (monad\map meta_monad full_expansion expansion)] - (in (list\joined expansion'))) + expansion' (monad\each meta_monad full_expansion expansion)] + (in (list\conjoint expansion'))) #None (do meta_monad - [args' (monad\map meta_monad full_expansion args)] - (in (list (form$ (#Item (identifier$ name) (list\joined args'))))))} + [args' (monad\each meta_monad full_expansion args)] + (in (list (form$ (#Item (identifier$ name) (list\conjoint args'))))))} ?macro)) [_ (#Form members)] (do meta_monad - [members' (monad\map meta_monad full_expansion members)] - (in (list (form$ (list\joined members'))))) + [members' (monad\each meta_monad full_expansion members)] + (in (list (form$ (list\conjoint members'))))) [_ (#Tuple members)] (do meta_monad - [members' (monad\map meta_monad full_expansion members)] - (in (list (tuple$ (list\joined members'))))) + [members' (monad\each meta_monad full_expansion members)] + (in (list (tuple$ (list\conjoint members'))))) [_ (#Record pairs)] (do meta_monad - [pairs' (monad\map meta_monad - (function' [kv] - (let' [[key val] kv] - (do meta_monad - [val' (full_expansion val)] - ({(#Item val'' #End) - (in_meta [key val'']) + [pairs' (monad\each meta_monad + (function' [kv] + (let' [[key val] kv] + (do meta_monad + [val' (full_expansion val)] + ({(#Item val'' #End) + (in_meta [key val'']) - _ - (failure "The value-part of a KV-pair in a record must macro-expand to a single Code.")} - val')))) - pairs)] + _ + (failure "The value-part of a KV-pair in a record must macro-expand to a single Code.")} + val')))) + pairs)] (in (list (record$ pairs')))) _ (in_meta (list syntax))} syntax)) +(def:''' .private (text\encoded original) + #End + (-> Text Text) + ($_ text\composite ..double_quote original ..double_quote)) + +(def:''' .private (code\encoded code) + #End + (-> Code Text) + ({[_ (#Bit value)] + (bit\encoded value) + + [_ (#Nat value)] + (nat\encoded value) + + [_ (#Int value)] + (int\encoded value) + + [_ (#Rev value)] + ("lux io error" "@code\encoded Undefined behavior.") + + [_ (#Frac value)] + (frac\encoded value) + + [_ (#Text value)] + (text\encoded value) + + [_ (#Identifier [module name])] + (if (text\= "" module) + name + ($_ text\composite module "." name)) + + [_ (#Tag [module name])] + (if (text\= "" module) + ($_ text\composite "#" name) + ($_ text\composite "#" module "." name)) + + [_ (#Form xs)] + ($_ text\composite "(" (|> xs + (list\each code\encoded) + (list\interposed " ") + list\reversed + (list\mix text\composite "")) ")") + + [_ (#Tuple xs)] + ($_ text\composite "[" (|> xs + (list\each code\encoded) + (list\interposed " ") + list\reversed + (list\mix text\composite "")) "]") + + [_ (#Record kvs)] + ($_ text\composite "{" (|> kvs + (list\each (function' [kv] ({[k v] ($_ text\composite (code\encoded k) " " (code\encoded v))} + kv))) + (list\interposed " ") + list\reversed + (list\mix text\composite "")) "}")} + code)) + (def:''' .private (normal_type type) #End (-> Code Code) ({[_ (#Form (#Item [_ (#Tag tag)] parts))] - (form$ (#Item [(tag$ tag) (list\map normal_type parts)])) + (form$ (#Item (tag$ tag) (list\each normal_type parts))) [_ (#Tuple members)] - (` (Tuple (~+ (list\map normal_type members)))) + (` (Tuple (~+ (list\each normal_type members)))) [_ (#Form (#Item [_ (#Text "lux in-module")] (#Item [_ (#Text module)] @@ -2468,8 +2527,8 @@ (list\mix ("lux type check" (-> Code Code Code) (function' [arg type_fn] (` (#.Apply (~ arg) (~ type_fn))))) (normal_type type_fn) - (list\map normal_type args)) - + (list\each normal_type args)) + _ type} type)) @@ -2484,7 +2543,7 @@ [type+ (full_expansion type)] ({(#Item type' #End) (in (list (normal_type type'))) - + _ (failure "The expansion of the type-syntax had to yield a single element.")} type+)) @@ -2534,60 +2593,6 @@ [product\left a x] [product\right b y]) -(def:''' .private (type_declaration type_codes) - #End - (-> ($' List Code) ($' Meta (Tuple Code ($' Maybe ($' List Text))))) - ({(#Item [_ (#Record pairs)] #End) - (do meta_monad - [members (monad\map meta_monad - (: (-> [Code Code] (Meta [Text Code])) - (function' [pair] - ({[[_ (#Tag "" member_name)] member_type] - (in_meta [member_name member_type]) - - _ - (failure "Wrong syntax for variant case.")} - pair))) - pairs)] - (in_meta [(` (Tuple (~+ (list\map product\right members)))) - (#Some (list\map product\left members))])) - - (#Item type #End) - ({[_ (#Tag "" member_name)] - (in_meta [(` .Any) (#Some (list member_name))]) - - [_ (#Form (#Item [_ (#Tag "" member_name)] member_types))] - (in_meta [(` (Tuple (~+ member_types))) (#Some (list member_name))]) - - _ - (in_meta [type #None])} - type) - - (#Item case cases) - (do meta_monad - [members (monad\map meta_monad - (: (-> Code (Meta [Text Code])) - (function' [case] - ({[_ (#Tag "" member_name)] - (in_meta [member_name (` .Any)]) - - [_ (#Form (#Item [_ (#Tag "" member_name)] (#Item member_type #End)))] - (in_meta [member_name member_type]) - - [_ (#Form (#Item [_ (#Tag "" member_name)] member_types))] - (in_meta [member_name (` (Tuple (~+ member_types)))]) - - _ - (failure "Wrong syntax for variant case.")} - case))) - (list& case cases))] - (in_meta [(` (..Variant (~+ (list\map product\right members)))) - (#Some (list\map product\left members))])) - - _ - (failure "Improper type-definition syntax")} - type_codes)) - (def:''' .private (identifier prefix state) #End (-> Text ($' Meta Code)) @@ -2601,7 +2606,7 @@ #seed ("lux i64 +" 1 seed) #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval} - (local_identifier$ ($_ text\compose "__gensym__" prefix (nat\encoded seed))))} + (local_identifier$ ($_ text\composite "__gensym__" prefix (nat\encoded seed))))} state)) (macro:' .public (Rec tokens) @@ -2681,63 +2686,6 @@ (failure "Wrong syntax for def'")} parts))) -(def:' .private (text\encoded original) - (-> Text Text) - ($_ text\compose ..double_quote original ..double_quote)) - -(def:' .private (code\encoded code) - (-> Code Text) - ({[_ (#Bit value)] - (bit\encoded value) - - [_ (#Nat value)] - (nat\encoded value) - - [_ (#Int value)] - (int\encoded value) - - [_ (#Rev value)] - ("lux io error" "@code\encoded Undefined behavior.") - - [_ (#Frac value)] - (frac\encoded value) - - [_ (#Text value)] - (text\encoded value) - - [_ (#Identifier [module name])] - (if (text\= "" module) - name - ($_ text\compose module "." name)) - - [_ (#Tag [module name])] - (if (text\= "" module) - ($_ text\compose "#" name) - ($_ text\compose "#" module "." name)) - - [_ (#Form xs)] - ($_ text\compose "(" (|> xs - (list\map code\encoded) - (list\interposed " ") - list\reversed - (list\mix text\compose "")) ")") - - [_ (#Tuple xs)] - ($_ text\compose "[" (|> xs - (list\map code\encoded) - (list\interposed " ") - list\reversed - (list\mix text\compose "")) "]") - - [_ (#Record kvs)] - ($_ text\compose "{" (|> kvs - (list\map (function' [kv] ({[k v] ($_ text\compose (code\encoded k) " " (code\encoded v))} - kv))) - (list\interposed " ") - list\reversed - (list\mix text\compose "")) "}")} - code)) - (def:' .private (expander branches) (-> (List Code) (Meta (List Code))) ({(#Item [_ (#Form (#Item [_ (#Identifier name)] args))] @@ -2764,11 +2712,11 @@ (do meta_monad [] (in (list))) _ - (failure ($_ text\compose "'lux.case' expects an even number of tokens: " (|> branches - (list\map code\encoded) - (list\interposed " ") - list\reversed - (list\mix text\compose ""))))} + (failure ($_ text\composite "'lux.case' expects an even number of tokens: " (|> branches + (list\each code\encoded) + (list\interposed " ") + list\reversed + (list\mix text\composite ""))))} branches)) (macro:' .public (case tokens) @@ -2838,9 +2786,9 @@ _ (let' [pairs (|> patterns - (list\map (function' [pattern] (list pattern body))) - (list\joined))] - (in_meta (list\compose pairs branches)))) + (list\each (function' [pattern] (list pattern body))) + (list\conjoint))] + (in_meta (list\composite pairs branches)))) _ (failure "Wrong syntax for ^or"))) @@ -2940,27 +2888,27 @@ [_ (#Tuple xs)] (|> xs - (list\map definition_annotation_value) + (list\each definition_annotation_value) untemplated_list (meta_code ["library/lux" "Tuple"])) [_ (#Record kvs)] (|> kvs - (list\map (: (-> [Code Code] Code) - (function (_ [k v]) - (` [(~ (definition_annotation_value k)) - (~ (definition_annotation_value v))])))) + (list\each (: (-> [Code Code] Code) + (function (_ [k v]) + (` [(~ (definition_annotation_value k)) + (~ (definition_annotation_value v))])))) untemplated_list (meta_code ["library/lux" "Record"])) )) (def:' .private (definition_annotations kvs) (-> (List [Code Code]) Code) - (untemplated_list (list\map (: (-> [Code Code] Code) - (function (_ [k v]) - (` [(~ (definition_annotation_value k)) - (~ (definition_annotation_value v))]))) - kvs))) + (untemplated_list (list\each (: (-> [Code Code] Code) + (function (_ [k v]) + (` [(~ (definition_annotation_value k)) + (~ (definition_annotation_value v))]))) + kvs))) (def:' .private (with_function_parameters parameters meta) (-> (List Code) Code Code) @@ -2970,21 +2918,21 @@ _ (` (#.Item [[(~ location_code) (#.Tag ["library/lux" "func_args"])] - [(~ location_code) (#.Tuple (.list (~+ (list\map (function (_ parameter) - (` [(~ location_code) (#.Text (~ (text$ (code\encoded parameter))))])) - parameters))))]] + [(~ location_code) (#.Tuple (.list (~+ (list\each (function (_ parameter) + (` [(~ location_code) (#.Text (~ (text$ (code\encoded parameter))))])) + parameters))))]] (~ meta))))) (def:' .private (with_type_args args) (-> (List Code) Code) - (` {#.type_args [(~+ (list\map (function (_ arg) (text$ (code\encoded arg))) - args))]})) + (` {#.type_args [(~+ (list\each (function (_ arg) (text$ (code\encoded arg))) + args))]})) (def:' .private (endP tokens) (-> (List Code) (Maybe Any)) (case tokens (^ (list)) - (#.Some []) + (#Some []) _ #None)) @@ -2996,7 +2944,7 @@ (#Some [tokens' code]) _ - #.None)) + #None)) (def:' .private (local_identifierP tokens) (-> (List Code) (Maybe [(List Code) Text])) @@ -3005,14 +2953,14 @@ (#Some [tokens' local_identifier]) _ - #.None)) + #None)) (template [<parser> <item_type> <item_parser>] [(def:' .private (<parser> tokens) (-> (List Code) (Maybe (List <item_type>))) (case tokens #End - (#.Some #End) + (#Some #End) _ (do maybe_monad @@ -3264,7 +3212,7 @@ _ (` ("lux macro" - (function ((~ name) (~+ (list\map local_identifier$ args))) (~ body))))) + (function ((~ name) (~+ (list\each local_identifier$ args))) (~ body))))) =annotations (definition_annotations annotations)] (in_meta (list (` ("lux def" (~ name) (~ body) @@ -3272,7 +3220,7 @@ (#Record (~ =annotations))] (~ export_policy)))))) - #.None + #None (failure "Wrong syntax for macro:"))) (def: (list\one f xs) @@ -3496,7 +3444,7 @@ (#Right state module) _ - (#Left ($_ text\compose "Unknown module: " name)))))) + (#Left ($_ text\composite "Unknown module: " name)))))) (def: (type_tag [module name]) (-> Name (Meta [Nat (List Name) Bit Type])) @@ -3508,7 +3456,7 @@ (in_meta output) _ - (failure (text\compose "Unknown tag: " (name\encoded [module name])))))) + (failure (text\composite "Unknown tag: " (name\encoded [module name])))))) (def: (record_slots type) (-> Type (Meta (Maybe [(List Name) (List Type)]))) @@ -3573,7 +3521,7 @@ " (= test subject)))" ..\n " ))"))} (do meta_monad - [tokens' (monad\map meta_monad expansion tokens) + [tokens' (monad\each meta_monad expansion tokens) struct_type ..expected_type tags+type (record_slots struct_type) tags (: (Meta (List Name)) @@ -3584,23 +3532,23 @@ _ (failure "No tags available for type."))) .let [tag_mappings (: (List [Text Code]) - (list\map (function (_ tag) [(product\right tag) (tag$ tag)]) - tags))] - members (monad\map meta_monad - (: (-> Code (Meta [Code Code])) - (function (_ token) - (case token - (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier "" tag_name)] value meta export_policy))]) - (case (plist\value tag_name tag_mappings) - (#Some tag) - (in [tag value]) + (list\each (function (_ tag) [(product\right tag) (tag$ tag)]) + tags))] + members (monad\each meta_monad + (: (-> Code (Meta [Code Code])) + (function (_ token) + (case token + (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier "" tag_name)] value meta export_policy))]) + (case (plist\value tag_name tag_mappings) + (#Some tag) + (in [tag value]) - _ - (failure (text\compose "Unknown implementation member: " tag_name))) + _ + (failure (text\composite "Unknown implementation member: " tag_name))) - _ - (failure "Invalid implementation member.")))) - (list\joined tokens'))] + _ + (failure "Invalid implementation member.")))) + (list\conjoint tokens'))] (in (list (record$ members))))) (def: (text\interposed separator parts) @@ -3611,7 +3559,7 @@ (#Item head tail) (list\mix (function (_ right left) - ($_ text\compose left separator right)) + ($_ text\composite left separator right)) head tail))) @@ -3695,6 +3643,83 @@ (All [a] (-> a a)) value) +(def: (everyP itP tokens) + (All [a] (-> (-> (List Code) (Maybe [(List Code) a])) + (-> (List Code) (Maybe (List a))))) + (case tokens + (#Item _) + (do maybe_monad + [% (itP tokens) + .let [[tokens' head] %] + tail (case tokens' + (#Item _) + (everyP itP tokens') + + #End + (in (list)))] + (in (list& head tail))) + + #End + (#Some (list)))) + +(def: (caseP tokens) + (-> (List Code) (Maybe [(List Code) [Text Code]])) + (case tokens + (^ (list& [_ (#Tag ["" niladic])] tokens')) + (#Some [tokens' [niladic (` .Any)]]) + + (^ (list& [_ (#Form (list& [_ (#Tag ["" polyadic])] caseT))] tokens')) + (#Some [tokens' [polyadic (` (..Tuple (~+ caseT)))]]) + + _ + #None)) + +(macro: .public (Variant tokens) + (case (everyP caseP tokens) + (#Some cases) + (in_meta (list (` (..Union (~+ (list\each product\right cases)))) + (tuple$ (list\each (function (_ case) + (text$ (product\left case))) + cases)))) + + #None + (failure "Wrong syntax for Variant"))) + +(def: (slotP tokens) + (-> (List Code) (Maybe [(List Code) [Text Code]])) + (case tokens + (^ (list& [_ (#Tag ["" slot])] type tokens')) + (#Some [tokens' [slot type]]) + + _ + #.None)) + +(def: un_paired + (-> (List [Code Code]) (List Code)) + (let [pair_list (: (-> [Code Code] (List Code)) + (function (_ [left right]) + (list left right)))] + (function (_ it) + (|> it + (list\each pair_list) + list\conjoint)))) + +(macro: .public (Record tokens) + (case tokens + (^ (list [_ (#Record record)])) + (case (everyP slotP (un_paired record)) + (#Some slots) + (in_meta (list (` (..Tuple (~+ (list\each product\right slots)))) + (tuple$ (list\each (function (_ slot) + (text$ (product\left slot))) + slots)))) + + #None + (failure "Wrong syntax for Record")) + + _ + (failure "Wrong syntax for Record"))) + (def: (recP tokens) (-> (List Code) [(List Code) Bit]) (case tokens @@ -3704,49 +3729,90 @@ _ [tokens #0])) -(def:' .private (typeP tokens) - (-> (List Code) (Maybe [Code Bit Text (List Text) (List [Code Code]) (List Code)])) - (|> (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - .let' [[tokens rec?] (recP tokens)] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - tokens (remainderP tokens)] - (in [export_policy rec? name parameters annotations tokens])) - ... (^ (list _export_policy _rec _declaration _annotations _body)) - ... (^ (list _export_policy _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [.let' [[tokens rec?] (recP tokens)] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - tokens (remainderP tokens)] - (in [(` ..private) rec? name parameters annotations tokens]))) - ... (^ (list _rec _declaration _annotations _body)) - ... (^ (list _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [.let' [[tokens rec?] (recP tokens)] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - tokens (remainderP tokens)] - (in [(` ..private) rec? name parameters #End tokens]))) - ... (^ (list _rec _declaration _body)) - ... (^ (list _declaration _body)) - (maybe\else' (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - .let' [[tokens rec?] (recP tokens)] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - tokens (remainderP tokens)] - (in [export_policy rec? name parameters #End tokens]))) - ... (^ (list _export_policy _rec _declaration _body)) - ... (^ (list _export_policy _declaration _body)) - )) +(def: (typeP tokens) + (-> (List Code) (Maybe [Code Bit Text (List Text) (List [Code Code]) Code])) + (|> (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + .let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [export_policy rec? name parameters annotations definition])) + ... (^ (list _export_policy _rec _declaration _annotations _body)) + ... (^ (list _export_policy _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [.let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [(` ..private) rec? name parameters annotations definition]))) + ... (^ (list _rec _declaration _annotations _body)) + ... (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [.let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [(` ..private) rec? name parameters #End definition]))) + ... (^ (list _rec _declaration _body)) + ... (^ (list _declaration _body)) + (maybe\else' (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + .let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [export_policy rec? name parameters #End definition]))) + ... (^ (list _export_policy _rec _declaration _body)) + ... (^ (list _export_policy _declaration _body)) + )) + +(def: (textP tokens) + (-> (List Code) (Maybe [(List Code) Text])) + (case tokens + (^ (list& [_ (#Text it)] tokens')) + (#Some [tokens' it]) + + _ + #None)) + +(def: (type_declaration it) + (-> Code (Meta (Tuple Code (Maybe (List Text))))) + ({[_ (#Form (#Item [_ (#Identifier declarer)] parameters))] + (do meta_monad + [declaration (single_expansion (form$ (list& (identifier$ declarer) parameters)))] + (case declaration + (^ (list type [_ (#Tuple tags)])) + (case (everyP textP tags) + (#Some tags) + (in_meta [type (#Some tags)]) + + #None + (failure "Improper type-definition syntax")) + + (^ (list type)) + (in_meta [it #None]) + + _ + (failure "Improper type-definition syntax"))) + + type + (in_meta [type #None])} + it)) (macro: .public (type: tokens) {#.doc (text$ ($_ "lux text concat" @@ -3759,53 +3825,53 @@ (#Some [export_policy rec? name args meta type_codes]) (do meta_monad [type+tags?? (..type_declaration type_codes) - module_name current_module_name] - (let [type_name (local_identifier$ name) - [type tags??] type+tags?? - type' (: (Maybe Code) - (if rec? - (if (empty? args) - (let [g!param (local_identifier$ "") - prime_name (local_identifier$ name) - type+ (with_replacements (list [name (` ((~ prime_name) .Nothing))]) - type)] - (#Some (` ((All (~ prime_name) [(~ g!param)] (~ type+)) - .Nothing)))) - #None) - (case args - #End - (#Some type) + module_name current_module_name + .let' [type_name (local_identifier$ name) + [type tags??] type+tags?? + type' (: (Maybe Code) + (if rec? + (if (empty? args) + (let [g!param (local_identifier$ "") + prime_name (local_identifier$ name) + type+ (with_replacements (list [name (` ((~ prime_name) .Nothing))]) + type)] + (#Some (` ((All (~ prime_name) [(~ g!param)] (~ type+)) + .Nothing)))) + #None) + (case args + #End + (#Some type) - _ - (#Some (` (.All (~ type_name) [(~+ (list\map local_identifier$ args))] (~ type))))))) - total_meta (let [meta (definition_annotations meta) - meta (if rec? - (` (#.Item (~ (flag_meta "type_rec?")) (~ meta))) - meta)] - (` [(~ location_code) - (#.Record (~ meta))]))] - (case type' - (#Some type'') - (let [typeC (` (#.Named [(~ (text$ module_name)) - (~ (text$ name))] - (.type (~ type''))))] - (in_meta (list (case tags?? - (#Some tags) - (` ("lux def type tagged" (~ type_name) - (~ typeC) - (~ total_meta) - [(~+ (list\map text$ tags))] - (~ export_policy))) - - _ - (` ("lux def" (~ type_name) - ("lux type check type" - (~ typeC)) - (~ total_meta) - (~ export_policy))))))) + _ + (#Some (` (.All (~ type_name) [(~+ (list\each local_identifier$ args))] (~ type))))))) + total_meta (let [meta (definition_annotations meta) + meta (if rec? + (` (#.Item (~ (flag_meta "type_rec?")) (~ meta))) + meta)] + (` [(~ location_code) + (#.Record (~ meta))]))]] + (case type' + (#Some type'') + (let [typeC (` (#.Named [(~ (text$ module_name)) + (~ (text$ name))] + (.type (~ type''))))] + (in_meta (list (case tags?? + (#Some tags) + (` ("lux def type tagged" (~ type_name) + (~ typeC) + (~ total_meta) + [(~+ (list\each text$ tags))] + (~ export_policy))) + + _ + (` ("lux def" (~ type_name) + ("lux type check type" + (~ typeC)) + (~ total_meta) + (~ export_policy))))))) - #None - (failure "Wrong syntax for type:")))) + #None + (failure "Wrong syntax for type:"))) #None (failure "Wrong syntax for type:"))) @@ -3843,32 +3909,34 @@ (case (interfaceP tokens) (#Some [export_policy name args annotations methods]) (do meta_monad - [methods' (monad\map meta_monad expansion methods) + [methods' (monad\each meta_monad expansion methods) members (: (Meta (List [Text Code])) - (monad\map meta_monad - (: (-> Code (Meta [Text Code])) - (function (_ token) - (case token - (^ [_ (#Form (list [_ (#Text "lux type check")] type [_ (#Identifier ["" name])]))]) - (in [name type]) - - _ - (failure "Interfaces require typed members!")))) - (list\joined methods'))) + (monad\each meta_monad + (: (-> Code (Meta [Text Code])) + (function (_ token) + (case token + (^ [_ (#Form (list [_ (#Text "lux type check")] type [_ (#Identifier ["" name])]))]) + (in [name type]) + + _ + (failure "Interfaces require typed members!")))) + (list\conjoint methods'))) .let [def_name (local_identifier$ name) - interface_type (record$ (list\map (: (-> [Text Code] [Code Code]) - (function (_ [module_name m_type]) - [(local_tag$ module_name) m_type])) - members)) - interface_annotations (merged_definition_annotations (` {#.interface? #1}) - (record$ annotations)) + interface_type (` (..Record + (~ (record$ (list\each (: (-> [Text Code] [Code Code]) + (function (_ [module_name m_type]) + [(local_tag$ module_name) m_type])) + members))))) usage (case args #End def_name _ - (` ((~ def_name) (~+ (list\map local_identifier$ args)))))]] - (in_meta (list (` (..type: (~ export_policy) (~ usage) (~ interface_annotations) (~ interface_type)))))) + (` ((~ def_name) (~+ (list\each local_identifier$ args)))))]] + (in_meta (list (` (..type: (~ export_policy) + (~ usage) + (~ (record$ annotations)) + (~ interface_type)))))) #None (failure "Wrong syntax for interface:"))) @@ -3886,36 +3954,39 @@ ) (type: Referrals - #All - (#Only (List Text)) - (#Exclude (List Text)) - #Ignore - #Nothing) + (Variant + #All + (#Only (List Text)) + (#Exclude (List Text)) + #Ignore + #Nothing)) (type: Openings [Text (List Text)]) (type: Refer - {#refer_defs Referrals - #refer_open (List Openings)}) + (Record + {#refer_defs Referrals + #refer_open (List Openings)})) (type: Importation - {#import_name Text - #import_alias (Maybe Text) - #import_refer Refer}) + (Record + {#import_name Text + #import_alias (Maybe Text) + #import_refer Refer})) (def: (referral_references defs) (-> (List Code) (Meta (List Text))) - (monad\map meta_monad - (: (-> Code (Meta Text)) - (function (_ def) - (case def - [_ (#Identifier ["" name])] - (in_meta name) + (monad\each meta_monad + (: (-> Code (Meta Text)) + (function (_ def) + (case def + [_ (#Identifier ["" name])] + (in_meta name) - _ - (failure "#only/#+ and #exclude/#- require identifiers.")))) - defs)) + _ + (failure "#only/#+ and #exclude/#- require identifiers.")))) + defs)) (def: (referrals_parser tokens) (-> (List Code) (Meta [Referrals (List Code)])) @@ -3946,27 +4017,27 @@ (def: (openings_parser parts) (-> (List Code) (Meta [(List Openings) (List Code)])) (case parts - #.End - (in_meta [#.End #.End]) + #End + (in_meta [#End #End]) (^ (list& [_ (#Form (list& [_ (#Text prefix)] structs))] parts')) (do meta_monad - [structs' (monad\map meta_monad - (function (_ struct) - (case struct - [_ (#Identifier ["" struct_name])] - (in_meta struct_name) - - _ - (failure "Expected all implementations of opening form to be identifiers."))) - structs) + [structs' (monad\each meta_monad + (function (_ struct) + (case struct + [_ (#Identifier ["" struct_name])] + (in_meta struct_name) + + _ + (failure "Expected all implementations of opening form to be identifiers."))) + structs) next+remainder (openings_parser parts')] (let [[next remainder] next+remainder] - (in_meta [(#.Item [prefix structs'] next) + (in_meta [(#Item [prefix structs'] next) remainder]))) _ - (in_meta [#.End parts]))) + (in_meta [#End parts]))) (def: (text\split_at' at x) (-> Nat Text [Text Text]) @@ -3986,10 +4057,10 @@ ((: (-> Text Text Text) (function (recur left right) (case (..text\split_by pattern right) - (#.Some [pre post]) + (#Some [pre post]) (recur ($_ "lux text concat" left pre replacement) post) - #.None + #None ("lux text concat" left right)))) "" template)) @@ -4013,23 +4084,23 @@ (-> Text Text Text) (case [(text\split_by ..module_separator hierarchy) (text\split_by ..parallel_hierarchy_sigil root)] - [(#.Some [_ hierarchy']) - (#.Some ["" root'])] + [(#Some [_ hierarchy']) + (#Some ["" root'])] (normal_parallel_path' hierarchy' root') _ (case root "" hierarchy - _ ($_ text\compose root ..module_separator hierarchy)))) + _ ($_ text\composite root ..module_separator hierarchy)))) (def: (normal_parallel_path hierarchy root) (-> Text Text (Maybe Text)) (case (text\split_by ..parallel_hierarchy_sigil root) - (#.Some ["" root']) - (#.Some (normal_parallel_path' hierarchy root')) + (#Some ["" root']) + (#Some (normal_parallel_path' hierarchy root')) _ - #.None)) + #None)) (def: (relative_ups relatives input) (-> Nat Text Nat) @@ -4071,7 +4142,7 @@ clean ("lux text clip" relatives (|> module "lux text size" ("lux i64 -" relatives)) module) output (case ("lux text size" clean) 0 prefix - _ ($_ text\compose prefix ..module_separator clean))] + _ ($_ text\composite prefix ..module_separator clean))] (in_meta output)) (failure ($_ "lux text concat" "Cannot climb the module hierarchy..." ..\n @@ -4081,78 +4152,78 @@ (def: (imports_parser nested? relative_root context_alias imports) (-> Bit Text Text (List Code) (Meta (List Importation))) (do meta_monad - [imports' (monad\map meta_monad - (: (-> Code (Meta (List Importation))) - (function (_ token) - (case token - ... Simple - [_ (#Identifier ["" module_name])] - (do meta_monad - [absolute_module_name (..absolute_module_name nested? relative_root module_name)] - (in (list {#import_name absolute_module_name - #import_alias #None - #import_refer {#refer_defs #All - #refer_open (list)}}))) - - ... Nested - (^ [_ (#Tuple (list& [_ (#Identifier ["" module_name])] extra))]) - (do meta_monad - [absolute_module_name (case (normal_parallel_path relative_root module_name) - (#.Some parallel_path) - (in parallel_path) - - #.None - (..absolute_module_name nested? relative_root module_name)) - referral+extra (referrals_parser extra) - .let [[referral extra] referral+extra] - openings+extra (openings_parser extra) - .let [[openings extra] openings+extra] - sub_imports (imports_parser #1 absolute_module_name context_alias extra)] - (in (case [referral openings] - [#Nothing #End] - sub_imports - - _ - (list& {#import_name absolute_module_name - #import_alias #None - #import_refer {#refer_defs referral - #refer_open openings}} - sub_imports)))) - - (^ [_ (#Tuple (list& [_ (#Text alias)] [_ (#Identifier ["" module_name])] extra))]) - (do meta_monad - [absolute_module_name (case (normal_parallel_path relative_root module_name) - (#.Some parallel_path) - (in parallel_path) - - #.None - (..absolute_module_name nested? relative_root module_name)) - referral+extra (referrals_parser extra) - .let [[referral extra] referral+extra] - openings+extra (openings_parser extra) - .let [[openings extra] openings+extra - module_alias (..module_alias context_alias module_name alias)] - sub_imports (imports_parser #1 absolute_module_name module_alias extra)] - (in (case [referral openings] - [#Ignore #End] - sub_imports - - _ - (list& {#import_name absolute_module_name - #import_alias (#Some module_alias) - #import_refer {#refer_defs referral - #refer_open openings}} - sub_imports)))) - - ... Unrecognized syntax. - _ - (do meta_monad - [current_module current_module_name] - (failure ($_ text\compose - "Wrong syntax for import @ " current_module - ..\n (code\encoded token))))))) - imports)] - (in (list\joined imports')))) + [imports' (monad\each meta_monad + (: (-> Code (Meta (List Importation))) + (function (_ token) + (case token + ... Simple + [_ (#Identifier ["" module_name])] + (do meta_monad + [absolute_module_name (..absolute_module_name nested? relative_root module_name)] + (in (list {#import_name absolute_module_name + #import_alias #None + #import_refer {#refer_defs #All + #refer_open (list)}}))) + + ... Nested + (^ [_ (#Tuple (list& [_ (#Identifier ["" module_name])] extra))]) + (do meta_monad + [absolute_module_name (case (normal_parallel_path relative_root module_name) + (#Some parallel_path) + (in parallel_path) + + #None + (..absolute_module_name nested? relative_root module_name)) + referral+extra (referrals_parser extra) + .let [[referral extra] referral+extra] + openings+extra (openings_parser extra) + .let [[openings extra] openings+extra] + sub_imports (imports_parser #1 absolute_module_name context_alias extra)] + (in (case [referral openings] + [#Nothing #End] + sub_imports + + _ + (list& {#import_name absolute_module_name + #import_alias #None + #import_refer {#refer_defs referral + #refer_open openings}} + sub_imports)))) + + (^ [_ (#Tuple (list& [_ (#Text alias)] [_ (#Identifier ["" module_name])] extra))]) + (do meta_monad + [absolute_module_name (case (normal_parallel_path relative_root module_name) + (#Some parallel_path) + (in parallel_path) + + #None + (..absolute_module_name nested? relative_root module_name)) + referral+extra (referrals_parser extra) + .let [[referral extra] referral+extra] + openings+extra (openings_parser extra) + .let [[openings extra] openings+extra + module_alias (..module_alias context_alias module_name alias)] + sub_imports (imports_parser #1 absolute_module_name module_alias extra)] + (in (case [referral openings] + [#Ignore #End] + sub_imports + + _ + (list& {#import_name absolute_module_name + #import_alias (#Some module_alias) + #import_refer {#refer_defs referral + #refer_open openings}} + sub_imports)))) + + ... Unrecognized syntax. + _ + (do meta_monad + [current_module current_module_name] + (failure ($_ text\composite + "Wrong syntax for import @ " current_module + ..\n (code\encoded token))))))) + imports)] + (in (list\conjoint imports')))) (def: (exported_definitions module state) (-> Text (Meta (List Text))) @@ -4164,23 +4235,23 @@ [current_module modules])] (case (plist\value module modules) (#Some =module) - (let [to_alias (list\map (: (-> [Text Global] - (List Text)) - (function (_ [name definition]) - (case definition - (#Left _) - (list) - - (#Right [exported? def_type def_meta def_value]) - (if exported? - (list name) - (list))))) - (let [{#module_hash _ #module_aliases _ #definitions definitions #imports _ #tags tags #types types #module_annotations _ #module_state _} =module] - definitions))] - (#Right state (list\joined to_alias))) + (let [to_alias (list\each (: (-> [Text Global] + (List Text)) + (function (_ [name definition]) + (case definition + (#Left _) + (list) + + (#Right [exported? def_type def_meta def_value]) + (if exported? + (list name) + (list))))) + (let [{#module_hash _ #module_aliases _ #definitions definitions #imports _ #tags tags #types types #module_annotations _ #module_state _} =module] + definitions))] + (#Right state (list\conjoint to_alias))) #None - (#Left ($_ text\compose + (#Left ($_ text\composite "Unknown module: " (text\encoded module) ..\n "Current module: " (case current_module (#Some current_module) @@ -4189,8 +4260,8 @@ #None "???") ..\n "Known modules: " (|> modules - (list\map (function (_ [name module]) - (text$ name))) + (list\each (function (_ [name module]) + (text$ name))) tuple$ code\encoded)))) )) @@ -4278,12 +4349,12 @@ #scope_type_vars scope_type_vars #eval _eval} state] (case (plist\value v_module modules) #None - (#Left (text\compose "Unknown definition: " (name\encoded name))) + (#Left (text\composite "Unknown definition: " (name\encoded name))) (#Some {#definitions definitions #module_hash _ #module_aliases _ #imports _ #tags tags #types types #module_annotations _ #module_state _}) (case (plist\value v_name definitions) #None - (#Left (text\compose "Unknown definition: " (name\encoded name))) + (#Left (text\composite "Unknown definition: " (name\encoded name))) (#Some definition) (case definition @@ -4321,13 +4392,13 @@ (#Right [compiler struct_type]) _ - (#Left ($_ text\compose "Unknown var: " (name\encoded full_name))))) + (#Left ($_ text\composite "Unknown var: " (name\encoded full_name))))) (case (definition_type full_name compiler) (#Some struct_type) (#Right [compiler struct_type]) _ - (#Left ($_ text\compose "Unknown var: " (name\encoded full_name)))))] + (#Left ($_ text\composite "Unknown var: " (name\encoded full_name)))))] (case temp (#Right [compiler (#Var type_id)]) (let [{#info _ #source _ #current_module _ #modules _ @@ -4369,37 +4440,37 @@ name _ - ($_ text\compose "(" name " " (|> params (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")")) + ($_ text\composite "(" name " " (|> params (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")")) (#Sum _) - ($_ text\compose "(Or " (|> (flat_variant type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")") + ($_ text\composite "(Or " (|> (flat_variant type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") (#Product _) - ($_ text\compose "[" (|> (flat_tuple type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) "]") + ($_ text\composite "[" (|> (flat_tuple type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) "]") (#Function _) - ($_ text\compose "(-> " (|> (flat_lambda type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")") + ($_ text\composite "(-> " (|> (flat_lambda type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") (#Parameter id) (nat\encoded id) (#Var id) - ($_ text\compose "⌈v:" (nat\encoded id) "⌋") + ($_ text\composite "⌈v:" (nat\encoded id) "⌋") (#Ex id) - ($_ text\compose "⟨e:" (nat\encoded id) "⟩") + ($_ text\composite "⟨e:" (nat\encoded id) "⟩") (#UnivQ env body) - ($_ text\compose "(All " (type\encoded body) ")") + ($_ text\composite "(All " (type\encoded body) ")") (#ExQ env body) - ($_ text\compose "(Ex " (type\encoded body) ")") + ($_ text\composite "(Ex " (type\encoded body) ")") (#Apply _) (let [[func args] (flat_application type)] - ($_ text\compose + ($_ text\composite "(" (type\encoded func) " " - (|> args (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) + (|> args (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")")) (#Named name _) @@ -4425,16 +4496,16 @@ struct_evidence (record_slots init_type)] (case struct_evidence #None - (failure (text\compose "Can only 'open' structs: " (type\encoded init_type))) + (failure (text\composite "Can only 'open' structs: " (type\encoded init_type))) (#Some tags&members) (do meta_monad [full_body ((: (-> Name [(List Name) (List Type)] Code (Meta Code)) (function (recur source [tags members] target) - (let [locals (list\map (function (_ [t_module t_name]) - ["" (..module_alias "" t_name alias)]) - tags) - pattern (tuple$ (list\map identifier$ locals))] + (let [locals (list\each (function (_ [t_module t_name]) + ["" (..module_alias "" t_name alias)]) + tags) + pattern (tuple$ (list\each identifier$ locals))] (do meta_monad [enhanced_target (monad\mix meta_monad (function (_ [m_local m_type] enhanced_target) @@ -4513,13 +4584,13 @@ g!output (..identifier "")] (case (interface_methods type) (#Some members) - (let [pattern (record$ (list\map (: (-> [Name [Nat Type]] [Code Code]) - (function (_ [[r_module r_name] [r_idx r_type]]) - [(tag$ [r_module r_name]) - (if ("lux i64 =" idx r_idx) - g!output - g!_)])) - (zipped/2 tags (enumeration members))))] + (let [pattern (record$ (list\each (: (-> [Name [Nat Type]] [Code Code]) + (function (_ [[r_module r_name] [r_idx r_type]]) + [(tag$ [r_module r_name]) + (if ("lux i64 =" idx r_idx) + g!output + g!_)])) + (zipped/2 tags (enumeration members))))] (in_meta (list (` ({(~ pattern) (~ g!output)} (~ record)))))) _ @@ -4549,26 +4620,26 @@ .let [g!output (local_identifier$ short) pattern (|> tags enumeration - (list\map (function (_ [tag_idx tag]) - (if ("lux i64 =" my_tag_index tag_idx) - g!output - g!_))) + (list\each (function (_ [tag_idx tag]) + (if ("lux i64 =" my_tag_index tag_idx) + g!output + g!_))) tuple$) source+ (` ({(~ pattern) (~ g!output)} (~ source)))]] (case output (#Some [tags' members']) (do meta_monad - [decls' (monad\map meta_monad - (: (-> [Nat Name Type] (Meta (List Code))) - (function (_ [sub_tag_index sname stype]) - (open_declaration alias tags' sub_tag_index sname source+ stype))) - (enumeration (zipped/2 tags' members')))] - (in_meta (list\joined decls'))) + [decls' (monad\each meta_monad + (: (-> [Nat Name Type] (Meta (List Code))) + (function (_ [sub_tag_index sname stype]) + (open_declaration alias tags' sub_tag_index sname source+ stype))) + (enumeration (zipped/2 tags' members')))] + (in_meta (list\conjoint decls'))) _ (in_meta (list (` ("lux def" (~ (local_identifier$ (..module_alias "" short alias))) (~ source+) - [(~ location_code) (#.Record #End)] + [(~ location_code) (#.Record #.End)] #0))))))) (macro: .public (open: tokens) @@ -4594,20 +4665,20 @@ (case output (#Some [tags members]) (do meta_monad - [decls' (monad\map meta_monad (: (-> [Nat Name Type] (Meta (List Code))) - (function (_ [tag_index sname stype]) - (open_declaration alias tags tag_index sname source stype))) - (enumeration (zipped/2 tags members)))] - (in_meta (list\joined decls'))) + [decls' (monad\each meta_monad (: (-> [Nat Name Type] (Meta (List Code))) + (function (_ [tag_index sname stype]) + (open_declaration alias tags tag_index sname source stype))) + (enumeration (zipped/2 tags members)))] + (in_meta (list\conjoint decls'))) _ - (failure (text\compose "Can only 'open:' structs: " (type\encoded struct_type))))) + (failure (text\composite "Can only 'open:' structs: " (type\encoded struct_type))))) _ (do meta_monad [g!struct (..identifier "struct")] (in_meta (list (` ("lux def" (~ g!struct) (~ struct) - [(~ location_code) (#.Record #End)] + [(~ location_code) (#.Record #.End)] #0)) (` (..open: (~ (text$ alias)) (~ g!struct))))))) @@ -4617,9 +4688,9 @@ (macro: .public (|>> tokens) {#.doc (text$ ($_ "lux text concat" "... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n - "(|>> (list\map int\encoded) (interposed '' '') (mix text\compose ''''))" ..\n + "(|>> (list\each int\encoded) (interposed '' '') (mix text\composite ''''))" ..\n "... =>" ..\n - "(function (_ <arg>) (mix text\compose '''' (interposed '' '' (list\map int\encoded <arg>))))"))} + "(function (_ <arg>) (mix text\composite '''' (interposed '' '' (list\each int\encoded <arg>))))"))} (do meta_monad [g!_ (..identifier "_") g!arg (..identifier "arg")] @@ -4628,9 +4699,9 @@ (macro: .public (<<| tokens) {#.doc (text$ ($_ "lux text concat" "... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n - "(<<| (mix text\compose '''') (interposed '' '') (list\map int\encoded))" ..\n + "(<<| (mix text\composite '''') (interposed '' '') (list\each int\encoded))" ..\n "... =>" ..\n - "(function (_ <arg>) (mix text\compose '''' (interposed '' '' (list\map int\encoded <arg>))))"))} + "(function (_ <arg>) (mix text\composite '''' (interposed '' '' (list\each int\encoded <arg>))))"))} (do meta_monad [g!_ (..identifier "_") g!arg (..identifier "arg")] @@ -4657,11 +4728,11 @@ #refer_open openings}) _ - (failure ($_ text\compose "Wrong syntax for refer @ " current_module + (failure ($_ text\composite "Wrong syntax for refer @ " current_module ..\n (|> options - (list\map code\encoded) + (list\each code\encoded) (list\interposed " ") - (list\mix text\compose ""))))))) + (list\mix text\composite ""))))))) (def: (referral_definitions module_name [r_defs r_opens]) (-> Text Refer (Meta (List Code))) @@ -4669,13 +4740,13 @@ [current_module current_module_name .let [test_referrals (: (-> Text (List Text) (List Text) (Meta (List Any))) (function (_ module_name all_defs referred_defs) - (monad\map meta_monad - (: (-> Text (Meta Any)) - (function (_ _def) - (if (is_member? all_defs _def) - (in_meta []) - (failure ($_ text\compose _def " is not defined in module " module_name " @ " current_module))))) - referred_defs)))] + (monad\each meta_monad + (: (-> Text (Meta Any)) + (function (_ _def) + (if (is_member? all_defs _def) + (in_meta []) + (failure ($_ text\composite _def " is not defined in module " module_name " @ " current_module))))) + referred_defs)))] defs' (case r_defs #All (exported_definitions module_name) @@ -4697,18 +4768,18 @@ #Nothing (in (list))) - .let [defs (list\map (: (-> Text Code) - (function (_ def) - (` ("lux def alias" (~ (local_identifier$ def)) (~ (identifier$ [module_name def])))))) - defs') + .let [defs (list\each (: (-> Text Code) + (function (_ def) + (` ("lux def alias" (~ (local_identifier$ def)) (~ (identifier$ [module_name def])))))) + defs') openings (|> r_opens - (list\map (: (-> Openings (List Code)) - (function (_ [alias structs]) - (list\map (function (_ name) - (` (open: (~ (text$ alias)) (~ (identifier$ [module_name name]))))) - structs)))) - list\joined)]] - (in (list\compose defs openings)))) + (list\each (: (-> Openings (List Code)) + (function (_ [alias structs]) + (list\each (function (_ name) + (` (open: (~ (text$ alias)) (~ (identifier$ [module_name name]))))) + structs)))) + list\conjoint)]] + (in (list\composite defs openings)))) (macro: (refer tokens) (case tokens @@ -4729,20 +4800,20 @@ (list (' #*)) (#Only defs) - (list (form$ (list& (' #+) (list\map local_identifier$ defs)))) + (list (form$ (list& (' #+) (list\each local_identifier$ defs)))) (#Exclude defs) - (list (form$ (list& (' #-) (list\map local_identifier$ defs)))) + (list (form$ (list& (' #-) (list\each local_identifier$ defs)))) #Ignore (list) #Nothing (list))) - openings (list\map (function (_ [alias structs]) - (form$ (list& (text$ (..replaced ..contextual_reference module_alias alias)) - (list\map local_identifier$ structs)))) - r_opens)] + openings (list\each (function (_ [alias structs]) + (form$ (list& (text$ (..replaced ..contextual_reference module_alias alias)) + (list\each local_identifier$ structs)))) + r_opens)] (` ((~! ..refer) (~ (text$ module_name)) (~+ localizations) (~+ openings))))) @@ -4776,14 +4847,14 @@ current_module current_module_name imports (imports_parser #0 current_module "" _imports) .let [=imports (|> imports - (list\map (: (-> Importation Code) - (function (_ [module_name m_alias =refer]) - (` [(~ (text$ module_name)) (~ (text$ (..else "" m_alias)))])))) + (list\each (: (-> Importation Code) + (function (_ [module_name m_alias =refer]) + (` [(~ (text$ module_name)) (~ (text$ (..else "" m_alias)))])))) tuple$) - =refers (list\map (: (-> Importation Code) - (function (_ [module_name m_alias =refer]) - (refer_code module_name m_alias =refer))) - imports) + =refers (list\each (: (-> Importation Code) + (function (_ [module_name m_alias =refer]) + (refer_code module_name m_alias =refer))) + imports) =module (` ("lux def module" [(~ location_code) (#.Record (~ (definition_annotations _meta)))] (~ =imports)))]] @@ -4826,25 +4897,25 @@ (case (interface_methods type) (#Some members) (do meta_monad - [pattern' (monad\map meta_monad - (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) - (function (_ [r_slot_name [r_idx r_type]]) - (do meta_monad - [g!slot (..identifier "")] - (in_meta [r_slot_name r_idx g!slot])))) - (zipped/2 tags (enumeration members)))] - (let [pattern (record$ (list\map (: (-> [Name Nat Code] [Code Code]) + [pattern' (monad\each meta_monad + (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) + (function (_ [r_slot_name [r_idx r_type]]) + (do meta_monad + [g!slot (..identifier "")] + (in_meta [r_slot_name r_idx g!slot])))) + (zipped/2 tags (enumeration members)))] + (let [pattern (record$ (list\each (: (-> [Name Nat Code] [Code Code]) + (function (_ [r_slot_name r_idx r_var]) + [(tag$ r_slot_name) + r_var])) + pattern')) + output (record$ (list\each (: (-> [Name Nat Code] [Code Code]) (function (_ [r_slot_name r_idx r_var]) [(tag$ r_slot_name) - r_var])) - pattern')) - output (record$ (list\map (: (-> [Name Nat Code] [Code Code]) - (function (_ [r_slot_name r_idx r_var]) - [(tag$ r_slot_name) - (if ("lux i64 =" idx r_idx) - value - r_var)])) - pattern'))] + (if ("lux i64 =" idx r_idx) + value + r_var)])) + pattern'))] (in_meta (list (` ({(~ pattern) (~ output)} (~ record))))))) _ @@ -4857,10 +4928,10 @@ _ (do meta_monad - [bindings (monad\map meta_monad - (: (-> Code (Meta Code)) - (function (_ _) (..identifier "temp"))) - slots) + [bindings (monad\each meta_monad + (: (-> Code (Meta Code)) + (function (_ _) (..identifier "temp"))) + slots) .let [pairs (zipped/2 slots bindings) update_expr (list\mix (: (-> [Code Code] Code Code) (function (_ [s b] v) @@ -4873,7 +4944,7 @@ (#Item (list new_binding old_record) accesses')])) [record (: (List (List Code)) #End)] pairs) - accesses (list\joined (list\reversed accesses'))]] + accesses (list\conjoint (list\reversed accesses'))]] (in (list (` (let [(~+ accesses)] (~ update_expr))))))) @@ -4915,25 +4986,25 @@ (case (interface_methods type) (#Some members) (do meta_monad - [pattern' (monad\map meta_monad - (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) - (function (_ [r_slot_name [r_idx r_type]]) - (do meta_monad - [g!slot (..identifier "")] - (in_meta [r_slot_name r_idx g!slot])))) - (zipped/2 tags (enumeration members)))] - (let [pattern (record$ (list\map (: (-> [Name Nat Code] [Code Code]) + [pattern' (monad\each meta_monad + (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) + (function (_ [r_slot_name [r_idx r_type]]) + (do meta_monad + [g!slot (..identifier "")] + (in_meta [r_slot_name r_idx g!slot])))) + (zipped/2 tags (enumeration members)))] + (let [pattern (record$ (list\each (: (-> [Name Nat Code] [Code Code]) + (function (_ [r_slot_name r_idx r_var]) + [(tag$ r_slot_name) + r_var])) + pattern')) + output (record$ (list\each (: (-> [Name Nat Code] [Code Code]) (function (_ [r_slot_name r_idx r_var]) [(tag$ r_slot_name) - r_var])) - pattern')) - output (record$ (list\map (: (-> [Name Nat Code] [Code Code]) - (function (_ [r_slot_name r_idx r_var]) - [(tag$ r_slot_name) - (if ("lux i64 =" idx r_idx) - (` ((~ fun) (~ r_var))) - r_var)])) - pattern'))] + (if ("lux i64 =" idx r_idx) + (` ((~ fun) (~ r_var))) + r_var)])) + pattern'))] (in_meta (list (` ({(~ pattern) (~ output)} (~ record))))))) _ @@ -4977,7 +5048,7 @@ " (-> (List Type) Type Type)" ..\n " (case type" ..\n " (#.Primitive name params)" ..\n - " (#.Primitive name (list\map (reduced env) params))" + " (#.Primitive name (list\each (reduced env) params))" __paragraph " (^template [<tag>]" ..\n " [(<tag> left right)" ..\n @@ -5012,20 +5083,20 @@ branches)) (case (: (Maybe (List Code)) (do maybe_monad - [bindings' (monad\map maybe_monad identifier_short bindings) - data' (monad\map maybe_monad tuple_list data)] + [bindings' (monad\each maybe_monad identifier_short bindings) + data' (monad\each maybe_monad tuple_list data)] (let [num_bindings (list\size bindings')] (if (every? (|>> ("lux i64 =" num_bindings)) - (list\map list\size data')) + (list\each list\size data')) (let [apply (: (-> Replacement_Environment (List Code)) - (function (_ env) (list\map (realized_template env) templates)))] + (function (_ env) (list\each (realized_template env) templates)))] (|> data' - (list\map (function\composite apply (replacement_environment bindings'))) - list\joined + (list\each (function\composite apply (replacement_environment bindings'))) + list\conjoint in)) #None)))) (#Some output) - (in_meta (list\compose output branches)) + (in_meta (list\composite output branches)) #None (failure "Wrong syntax for ^template")) @@ -5050,19 +5121,20 @@ (^template [<tag>] [[[_ _ column] (<tag> parts)] - (list\mix n/min column (list\map baseline_column parts))]) + (list\mix n/min column (list\each baseline_column parts))]) ([#Form] [#Tuple]) [[_ _ column] (#Record pairs)] (list\mix n/min column - (list\compose (list\map (|>> product\left baseline_column) pairs) - (list\map (|>> product\right baseline_column) pairs))) + (list\composite (list\each (|>> product\left baseline_column) pairs) + (list\each (|>> product\right baseline_column) pairs))) )) (type: Documentation_Fragment - (#Documentation_Comment Text) - (#Documentation_Example Code)) + (Variant + (#Documentation_Comment Text) + (#Documentation_Example Code))) (def: (documentation_fragment code) (-> Code Documentation_Fragment) @@ -5085,7 +5157,8 @@ (def: tag\encoded (-> Name Text) - (|>> name\encoded (text\compose "#"))) + (|>> name\encoded + (text\composite "#"))) (def: (repeated n x) (All [a] (-> Int a (List a))) @@ -5099,7 +5172,7 @@ (text\interposed "" (repeated (.int ("lux i64 -" old_column new_column)) " ")) (let [extra_lines (text\interposed "" (repeated (.int ("lux i64 -" old_line new_line)) ..\n)) space_padding (text\interposed "" (repeated (.int ("lux i64 -" baseline new_column)) " "))] - (text\compose extra_lines space_padding)))) + (text\composite extra_lines space_padding)))) (def: (text\size x) (-> Text Nat) @@ -5109,14 +5182,6 @@ (-> Location Text Location) [file line ("lux i64 +" column (text\size code_text))]) -(def: un_paired - (-> (List [Code Code]) (List Code)) - (let [pair_list (: (-> [Code Code] (List Code)) - (function (_ [left right]) - (list left right)))] - (|>> (list\map pair_list) - list\joined))) - (def: (example_documentation prev_location baseline example) (-> Location Nat Code [Location Text]) (case example @@ -5124,8 +5189,8 @@ [[new_location (<tag> value)] (let [as_text (<encoded> value)] [(updated_location new_location as_text) - (text\compose (location_padding baseline prev_location new_location) - as_text)])]) + (text\composite (location_padding baseline prev_location new_location) + as_text)])]) ([#Bit bit\encoded] [#Nat nat\encoded] [#Int int\encoded] @@ -5138,11 +5203,11 @@ [[group_location (<tag> parts)] (let [[group_location' parts_text] (list\mix (function (_ part [last_location text_accum]) (let [[part_location part_text] (example_documentation last_location baseline part)] - [part_location (text\compose text_accum part_text)])) + [part_location (text\composite text_accum part_text)])) [(revised@ #column ++ group_location) ""] (<prep> parts))] [(revised@ #column ++ group_location') - ($_ text\compose (location_padding baseline prev_location group_location) + ($_ text\composite (location_padding baseline prev_location group_location) <open> parts_text <close>)])]) @@ -5160,14 +5225,14 @@ (#Documentation_Comment comment) (|> comment (text\all_split_by ..\n) - (list\map (function (_ line) ($_ text\compose "... " line ..\n))) + (list\each (function (_ line) ($_ text\composite "... " line ..\n))) (text\interposed "")) (#Documentation_Example example) (let [baseline (baseline_column example) [location _] example - [_ text] (..example_documentation (with@ #.column baseline location) baseline example)] - (text\compose text __paragraph)))) + [_ text] (..example_documentation (with@ #column baseline location) baseline example)] + (text\composite text __paragraph)))) (macro: .public (example tokens) {#.doc (text$ ($_ "lux text concat" @@ -5183,7 +5248,7 @@ " x)))"))} (in_meta (list (` [(~ location_code) (#.Text (~ (|> tokens - (list\map (|>> ..documentation_fragment ..fragment_documentation)) + (list\each (|>> ..documentation_fragment ..fragment_documentation)) (text\interposed "") text$)))])))) @@ -5205,7 +5270,7 @@ (-> Type Code) (case type (#Primitive name params) - (` (#.Primitive (~ (text$ name)) (~ (untemplated_list (list\map type_code params))))) + (` (#.Primitive (~ (text$ name)) (~ (untemplated_list (list\each type_code params))))) (^template [<tag>] [(<tag> left right) @@ -5221,7 +5286,7 @@ (^template [<tag>] [(<tag> env type) - (let [env' (untemplated_list (list\map type_code env))] + (let [env' (untemplated_list (list\each type_code env))] (` (<tag> (~ env') (~ (type_code type)))))]) ([#.UnivQ] [#.ExQ]) @@ -5250,43 +5315,43 @@ x)))} (let [?params (case tokens (^ (list name [_ (#Tuple bindings)] body)) - (#.Some [name bindings body]) + (#Some [name bindings body]) (^ (list [_ (#Tuple bindings)] body)) - (#.Some [(local_identifier$ "recur") bindings body]) + (#Some [(local_identifier$ "recur") bindings body]) _ - #.None)] + #None)] (case ?params - (#.Some [name bindings body]) + (#Some [name bindings body]) (let [pairs (pairs bindings) - vars (list\map product\left pairs) - inits (list\map product\right pairs)] + vars (list\each product\left pairs) + inits (list\each product\right pairs)] (if (every? identifier? inits) (do meta_monad [inits' (: (Meta (List Name)) - (case (monad\map maybe_monad identifier_name inits) + (case (monad\each maybe_monad identifier_name inits) (#Some inits') (in_meta inits') #None (failure "Wrong syntax for loop"))) - init_types (monad\map meta_monad type_definition inits') + init_types (monad\each meta_monad type_definition inits') expected ..expected_type] (in_meta (list (` (("lux type check" - (-> (~+ (list\map type_code init_types)) + (-> (~+ (list\each type_code init_types)) (~ (type_code expected))) (function ((~ name) (~+ vars)) (~ body))) (~+ inits)))))) (do meta_monad - [aliases (monad\map meta_monad - (: (-> Code (Meta Code)) - (function (_ _) (..identifier ""))) - inits)] + [aliases (monad\each meta_monad + (: (-> Code (Meta Code)) + (function (_ _) (..identifier ""))) + inits)] (in_meta (list (` (let [(~+ (..interleaved aliases inits))] (.loop (~ name) [(~+ (..interleaved vars aliases))] (~ body))))))))) - #.None + #None (failure "Wrong syntax for loop")))) (macro: .public (^slots tokens) @@ -5301,7 +5366,7 @@ (case (: (Maybe [Name (List Name)]) (do maybe_monad [hslot (..tag_name hslot') - tslots (monad\map maybe_monad ..tag_name tslots')] + tslots (monad\each maybe_monad ..tag_name tslots')] (in [hslot tslots]))) (#Some slots) (in_meta slots) @@ -5310,21 +5375,21 @@ (failure "Wrong syntax for ^slots"))) .let [[hslot tslots] slots] hslot (..normal hslot) - tslots (monad\map meta_monad ..normal tslots) + tslots (monad\each meta_monad ..normal tslots) output (..type_tag hslot) g!_ (..identifier "_") .let [[idx tags exported? type] output - slot_pairings (list\map (: (-> Name [Text Code]) - (function (_ [module name]) - [name (local_identifier$ name)])) - (list& hslot tslots)) - pattern (record$ (list\map (: (-> Name [Code Code]) - (function (_ [module name]) - (let [tag (tag$ [module name])] - (case (plist\value name slot_pairings) - (#Some binding) [tag binding] - #None [tag g!_])))) - tags))]] + slot_pairings (list\each (: (-> Name [Text Code]) + (function (_ [module name]) + [name (local_identifier$ name)])) + (list& hslot tslots)) + pattern (record$ (list\each (: (-> Name [Code Code]) + (function (_ [module name]) + (let [tag (tag$ [module name])] + (case (plist\value name slot_pairings) + (#Some binding) [tag binding] + #None [tag g!_])))) + tags))]] (in_meta (list& pattern body branches))) _ @@ -5345,26 +5410,26 @@ (^template [<tag>] [[location (<tag> elems)] (do maybe_monad - [placements (monad\map maybe_monad (with_expansions' label tokens) elems)] - (in (list [location (<tag> (list\joined placements))])))]) + [placements (monad\each maybe_monad (with_expansions' label tokens) elems)] + (in (list [location (<tag> (list\conjoint placements))])))]) ([#Tuple] [#Form]) [location (#Record pairs)] (do maybe_monad - [=pairs (monad\map maybe_monad - (: (-> [Code Code] (Maybe [Code Code])) - (function (_ [slot value]) - (do maybe_monad - [slot' (with_expansions' label tokens slot) - value' (with_expansions' label tokens value)] - (case [slot' value'] - (^ [(list =slot) (list =value)]) - (in [=slot =value]) - - _ - #None)))) - pairs)] + [=pairs (monad\each maybe_monad + (: (-> [Code Code] (Maybe [Code Code])) + (function (_ [slot value]) + (do maybe_monad + [slot' (with_expansions' label tokens slot) + value' (with_expansions' label tokens value)] + (case [slot' value'] + (^ [(list =slot) (list =value)]) + (in [=slot =value]) + + _ + #None)))) + pairs)] (in (list [location (#Record =pairs)]))))) (macro: .public (with_expansions tokens) @@ -5448,7 +5513,7 @@ ["Text" Text text$]) _ - (failure (text\compose "Cannot anti-quote type: " (name\encoded name)))))) + (failure (text\composite "Cannot anti-quote type: " (name\encoded name)))))) (def: (static_literal token) (-> Code (Meta Code)) @@ -5463,20 +5528,20 @@ (^template [<tag>] [[meta (<tag> parts)] (do meta_monad - [=parts (monad\map meta_monad static_literal parts)] + [=parts (monad\each meta_monad static_literal parts)] (in [meta (<tag> =parts)]))]) ([#Form] [#Tuple]) [meta (#Record pairs)] (do meta_monad - [=pairs (monad\map meta_monad - (: (-> [Code Code] (Meta [Code Code])) - (function (_ [slot value]) - (do meta_monad - [=value (static_literal value)] - (in [slot =value])))) - pairs)] + [=pairs (monad\each meta_monad + (: (-> [Code Code] (Meta [Code Code])) + (function (_ [slot value]) + (do meta_monad + [=value (static_literal value)] + (in [slot =value])))) + pairs)] (in [meta (#Record =pairs)])) _ @@ -5537,14 +5602,14 @@ (#Item init extras) (do meta_monad - [extras' (monad\map meta_monad case_level^ extras)] + [extras' (monad\each meta_monad case_level^ extras)] (in [init extras'])))) (def: (multi_level_case$ g!_ [[init_pattern levels] body]) (-> Code [Multi_Level_Case Code] (List Code)) (let [inner_pattern_body (list\mix (function (_ [calculation pattern] success) (let [bind? (case pattern - [_ (#.Identifier _)] + [_ (#Identifier _)] #1 _ @@ -5565,28 +5630,28 @@ "Useful in situations where the result of a branch depends on further refinements on the values being matched." "For example:" (case (split (size static) uri) - (^multi (#.Some [chunk uri']) + (^multi (#Some [chunk uri']) {(text\= static chunk) #1}) (match_uri endpoint? parts' uri') _ - (#.Left (format "Static part " (%t static) " does not match URI: " uri))) + (#Left (format "Static part " (%t static) " does not match URI: " uri))) "Short-cuts can be taken when using bit tests." "The example above can be rewritten as..." (case (split (size static) uri) - (^multi (#.Some [chunk uri']) + (^multi (#Some [chunk uri']) (text\= static chunk)) (match_uri endpoint? parts' uri') _ - (#.Left (format "Static part " (%t static) " does not match URI: " uri))))} + (#Left (format "Static part " (%t static) " does not match URI: " uri))))} (case tokens (^ (list& [_meta (#Form levels)] body next_branches)) (do meta_monad [mlc (multi_level_case^ levels) .let [initial_bind? (case mlc - [[_ (#.Identifier _)] _] + [[_ (#Identifier _)] _] #1 _ @@ -5618,7 +5683,7 @@ (def: wrong_syntax_error (-> Name Text) (|>> name\encoded - (text\compose "Wrong syntax for "))) + (text\composite "Wrong syntax for "))) (macro: .public (name_of tokens) {#.doc (example "Given an identifier or a tag, gives back a 2 tuple with the module and name parts, both as Text." @@ -5662,7 +5727,7 @@ (in (list (` (#Ex (~ (nat$ var_id)))))) #None - (failure (text\compose "Indexed-type does not exist: " (nat\encoded idx))))) + (failure (text\composite "Indexed-type does not exist: " (nat\encoded idx))))) _ (failure (..wrong_syntax_error (name_of ..$))))) @@ -5785,36 +5850,36 @@ _ #None)) -(def:' .private (templateP tokens) - (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) (List Code)])) - (|> (do maybe_monad - [% (declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [export_policy name parameters annotations templates])) - ... (^ (list _export_policy _declaration _annotations _body)) - ... (^ (list _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [export_policy name parameters #End templates]))) - ... (^ (list _export_policy _declaration _body)) - (maybe\else' (do maybe_monad - [% (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [(` ..private) name parameters #End templates]))) - ... (^ (list _declaration _body)) - )) +(def: (templateP tokens) + (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) (List Code)])) + (|> (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [export_policy name parameters annotations templates])) + ... (^ (list _export_policy _declaration _annotations _body)) + ... (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [export_policy name parameters #End templates]))) + ... (^ (list _export_policy _declaration _body)) + (maybe\else' (do maybe_monad + [% (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [(` ..private) name parameters #End templates]))) + ... (^ (list _declaration _body)) + )) (macro: .public (template: tokens) {#.doc (example "Define macros in the style of template and ^template." @@ -5822,30 +5887,30 @@ (template: (square x) (* x x)))} (case (templateP tokens) - (#.Some [export_policy name args anns input_templates]) + (#Some [export_policy name args anns input_templates]) (do meta_monad [g!tokens (..identifier "tokens") g!compiler (..identifier "compiler") g!_ (..identifier "_") - .let [rep_env (list\map (function (_ arg) - [arg (` ((~' ~) (~ (local_identifier$ arg))))]) - args)] + .let [rep_env (list\each (function (_ arg) + [arg (` ((~' ~) (~ (local_identifier$ arg))))]) + args)] this_module current_module_name] (in (list (` (macro: (~ export_policy) ((~ (local_identifier$ name)) (~ g!tokens) (~ g!compiler)) (~ (record$ anns)) (case (~ g!tokens) - (^ (list (~+ (list\map local_identifier$ args)))) + (^ (list (~+ (list\each local_identifier$ args)))) (#.Right [(~ g!compiler) - (list (~+ (list\map (function (_ template) - (` (`' (~ (with_replacements rep_env - template))))) - input_templates)))]) + (list (~+ (list\each (function (_ template) + (` (`' (~ (with_replacements rep_env + template))))) + input_templates)))]) (~ g!_) (#.Left (~ (text$ (..wrong_syntax_error [this_module name])))))))))) - #.None + #None (failure (..wrong_syntax_error (name_of ..template:))))) (macro: .public (as_is tokens compiler) @@ -5896,12 +5961,12 @@ (in (:as ..Text value)) _ - (failure ($_ text\compose + (failure ($_ text\composite "Invalid target platform (must be a value of type Text): " (name\encoded identifier) " : " (..code\encoded (..type_code type)))))) _ - (failure ($_ text\compose + (failure ($_ text\composite "Invalid target platform syntax: " (..code\encoded choice) ..\n "Must be either a text literal or an identifier.")))) @@ -5910,10 +5975,10 @@ (case options #End (case default - #.None - (failure ($_ text\compose "No code for target platform: " target)) + #None + (failure ($_ text\composite "No code for target platform: " target)) - (#.Some default) + (#Some default) (in_meta (list default))) (#Item [key pick] options') @@ -5934,10 +5999,10 @@ [target ..target] (case tokens (^ (list [_ (#Record options)])) - (target_pick target options #.None) + (target_pick target options #None) (^ (list [_ (#Record options)] default)) - (target_pick target options (#.Some default)) + (target_pick target options (#Some default)) _ (failure (..wrong_syntax_error (name_of ..for)))))) @@ -5961,24 +6026,24 @@ (^template [<tag>] [[ann (<tag> parts)] (do meta_monad - [=parts (monad\map meta_monad embedded_expansions parts)] - (in [(list\mix list\compose (list) (list\map left =parts)) - [ann (<tag> (list\map right =parts))]]))]) + [=parts (monad\each meta_monad embedded_expansions parts)] + (in [(list\mix list\composite (list) (list\each left =parts)) + [ann (<tag> (list\each right =parts))]]))]) ([#Form] [#Tuple]) [ann (#Record kvs)] (do meta_monad - [=kvs (monad\map meta_monad - (function (_ [key val]) - (do meta_monad - [=key (embedded_expansions key) - =val (embedded_expansions val) - .let [[key_labels key_labelled] =key - [val_labels val_labelled] =val]] - (in [(list\compose key_labels val_labels) [key_labelled val_labelled]]))) - kvs)] - (in [(list\mix list\compose (list) (list\map left =kvs)) - [ann (#Record (list\map right =kvs))]])) + [=kvs (monad\each meta_monad + (function (_ [key val]) + (do meta_monad + [=key (embedded_expansions key) + =val (embedded_expansions val) + .let [[key_labels key_labelled] =key + [val_labels val_labelled] =val]] + (in [(list\composite key_labels val_labels) [key_labelled val_labelled]]))) + kvs)] + (in [(list\mix list\composite (list) (list\each left =kvs)) + [ann (#Record (list\each right =kvs))]])) _ (in_meta [(list) code]))) @@ -5994,8 +6059,8 @@ [=raw (..embedded_expansions raw) .let [[labels labelled] =raw]] (in (list (` (with_expansions [(~+ (|> labels - (list\map (function (_ [label expansion]) (list label expansion))) - list\joined))] + (list\each (function (_ [label expansion]) (list label expansion))) + list\conjoint))] (~ labelled)))))) _ @@ -6018,13 +6083,13 @@ (-> Code (-> Code (Meta Code)) (-> (List [Code Code]) (Meta Code))) (do meta_monad - [=fields (monad\map meta_monad - (function (_ [key value]) - (do meta_monad - [=key (untemplated_pattern key) - =value (untemplated_pattern value)] - (in (` [(~ =key) (~ =value)])))) - fields)] + [=fields (monad\each meta_monad + (function (_ [key value]) + (do meta_monad + [=key (untemplated_pattern key) + =value (untemplated_pattern value)] + (in (` [(~ =key) (~ =value)])))) + fields)] (in (` [(~ g!meta) (#.Record (~ (untemplated_list =fields)))])))) (template [<tag> <name>] @@ -6035,12 +6100,12 @@ (#Item [_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] inits) (do meta_monad - [=inits (monad\map meta_monad untemplated_pattern (list\reversed inits))] + [=inits (monad\each meta_monad untemplated_pattern (list\reversed inits))] (in (` [(~ g!meta) (<tag> (~ (untemplated_list& spliced =inits)))]))) _ (do meta_monad - [=elems (monad\map meta_monad untemplated_pattern elems)] + [=elems (monad\each meta_monad untemplated_pattern elems)] (in (` [(~ g!meta) (<tag> (~ (untemplated_list =elems)))])))))] [#.Tuple untemplated_tuple] @@ -6073,8 +6138,8 @@ (^template [<tag> <untemplated>] [[_ (<tag> elems)] (<untemplated> g!meta untemplated_pattern elems)]) - ([#.Tuple ..untemplated_tuple] - [#.Form ..untemplated_form]) + ([#Tuple ..untemplated_tuple] + [#Form ..untemplated_form]) [_ (#Record fields)] (..untemplated_record g!meta untemplated_pattern fields) @@ -6122,9 +6187,9 @@ (if (multiple? 2 (list\size bindings)) (in_meta (list (` (..with_expansions [(~+ (|> bindings ..pairs - (list\map (function (_ [localT valueT]) - (list localT (` (..as_is (~ valueT)))))) - (list\mix list\compose (list))))] + (list\each (function (_ [localT valueT]) + (list localT (` (..as_is (~ valueT)))))) + (list\mix list\composite (list))))] (~ bodyT))))) (..failure ":let requires an even number of parts")) diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 281dc7fc9..6de1b97d0 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -20,7 +20,7 @@ out) (: (All [a] (-> (w a) (w (w a)))) - split)) + disjoint)) (macro: .public (be tokens state) (case (: (Maybe [(Maybe Text) Code (List Code) Code]) @@ -39,11 +39,11 @@ identifier (: (-> Text Code) (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) g!_ (identifier "_") - g!map (identifier "map") - g!split (identifier "split") + g!each (identifier "each") + g!disjoint (identifier "disjoint") body' (list\mix (: (-> [Code Code] Code Code) (function (_ binding body') - (with_expansions [<default> (` (|> (~ value) (~ g!split) ((~ g!map) (function ((~ g!_) (~ var)) (~ body')))))] + (with_expansions [<default> (` (|> (~ value) (~ g!disjoint) ((~ g!each) (function ((~ g!_) (~ var)) (~ body')))))] (let [[var value] binding] (case var [_ (#.Identifier ["" _])] @@ -60,13 +60,13 @@ (#.Some name) (let [name [location.dummy (#.Identifier ["" name])]] (` ({(~ name) - ({[(~ g!map) (~' out) (~ g!split)] + ({[(~ g!each) (~' out) (~ g!disjoint)] (~ body')} (~ name))} (~ comonad)))) #.None - (` ({[(~ g!map) (~' out) (~ g!split)] + (` ({[(~ g!each) (~' out) (~ g!disjoint)] (~ body')} (~ comonad)))))])) (#.Left "'be' bindings must have an even number of parts.")) diff --git a/stdlib/source/library/lux/abstract/comonad/cofree.lux b/stdlib/source/library/lux/abstract/comonad/cofree.lux index c5d61dbb4..e7d9cea7f 100644 --- a/stdlib/source/library/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/library/lux/abstract/comonad/cofree.lux @@ -11,8 +11,8 @@ (implementation: .public (functor dsl) (All [F] (-> (Functor F) (Functor (CoFree F)))) - (def: (map f [head tail]) - [(f head) (\ dsl map (map f) tail)])) + (def: (each f [head tail]) + [(f head) (\ dsl each (each f) tail)])) (implementation: .public (comonad dsl) (All [F] (-> (Functor F) (CoMonad (CoFree F)))) @@ -22,6 +22,6 @@ (def: (out [head tail]) head) - (def: (split [head tail]) + (def: (disjoint [head tail]) [[head tail] - (\ dsl map split tail)])) + (\ dsl each disjoint tail)])) diff --git a/stdlib/source/library/lux/abstract/equivalence.lux b/stdlib/source/library/lux/abstract/equivalence.lux index 43598f09e..69f90bb06 100644 --- a/stdlib/source/library/lux/abstract/equivalence.lux +++ b/stdlib/source/library/lux/abstract/equivalence.lux @@ -18,7 +18,7 @@ (implementation: .public functor (contravariant.Functor Equivalence) - (def: (map f equivalence) + (def: (each f equivalence) (implementation (def: (= reference sample) (\ equivalence = (f reference) (f sample)))))) diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index 6f7053018..28e90dbb0 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -6,7 +6,7 @@ (: (All [a b] (-> (-> a b) (-> (f a) (f b)))) - map)) + each)) (type: .public (Fix f) (f (Fix f))) @@ -17,13 +17,13 @@ (def: .public (sum (^open "f\.") (^open "g\.")) (All [F G] (-> (Functor F) (Functor G) (Functor (..Or F G)))) (implementation - (def: (map f fa|ga) + (def: (each f fa|ga) (case fa|ga (#.Left fa) - (#.Left (f\map f fa)) + (#.Left (f\each f fa)) (#.Right ga) - (#.Right (g\map f ga)))))) + (#.Right (g\each f ga)))))) (type: .public (And f g) (All [a] (.And (f a) (g a)))) @@ -31,9 +31,9 @@ (def: .public (product (^open "f\.") (^open "g\.")) (All [F G] (-> (Functor F) (Functor G) (Functor (..And F G)))) (implementation - (def: (map f [fa ga]) - [(f\map f fa) - (g\map f ga)]))) + (def: (each f [fa ga]) + [(f\each f fa) + (g\each f ga)]))) (type: .public (Then f g) (All [a] (f (g a)))) @@ -41,5 +41,5 @@ (def: .public (composite (^open "f\.") (^open "g\.")) (All [F G] (-> (Functor F) (Functor G) (Functor (..Then F G)))) (implementation - (def: (map f fga) - (f\map (g\map f) fga)))) + (def: (each f fga) + (f\each (g\each f) fga)))) diff --git a/stdlib/source/library/lux/abstract/functor/contravariant.lux b/stdlib/source/library/lux/abstract/functor/contravariant.lux index 9c5fe673a..ac35b9360 100644 --- a/stdlib/source/library/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/library/lux/abstract/functor/contravariant.lux @@ -6,4 +6,4 @@ (: (All [a b] (-> (-> b a) (-> (f a) (f b)))) - map)) + each)) diff --git a/stdlib/source/library/lux/abstract/hash.lux b/stdlib/source/library/lux/abstract/hash.lux index 3180691f3..48816744a 100644 --- a/stdlib/source/library/lux/abstract/hash.lux +++ b/stdlib/source/library/lux/abstract/hash.lux @@ -15,10 +15,10 @@ (implementation: .public functor (contravariant.Functor Hash) - (def: (map f super) + (def: (each f super) (implementation (def: &equivalence - (\ equivalence.functor map f + (\ equivalence.functor each f (\ super &equivalence))) (def: hash diff --git a/stdlib/source/library/lux/abstract/mix.lux b/stdlib/source/library/lux/abstract/mix.lux index 0788f38d0..07bddfec0 100644 --- a/stdlib/source/library/lux/abstract/mix.lux +++ b/stdlib/source/library/lux/abstract/mix.lux @@ -13,4 +13,4 @@ (All [F a] (-> (Monoid a) (Mix F) (F a) a)) (let [(^open "/\.") monoid] - (mix /\compose /\identity value))) + (mix /\composite /\identity value))) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 85159e505..4a1abdc82 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -51,7 +51,7 @@ in) (: (All [a] (-> (m (m a)) (m a))) - join)) + conjoint)) (macro: .public (do tokens state) (case (: (Maybe [(Maybe Text) Code (List Code) Code]) @@ -70,11 +70,11 @@ identifier (: (-> Text Code) (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) g!_ (identifier "_") - g!map (identifier "map") - g!join (identifier "join") + g!each (identifier "each") + g!conjoint (identifier "conjoint") body' (list\mix (: (-> [Code Code] Code Code) (function (_ binding body') - (with_expansions [<default> (` (|> (~ value) ((~ g!map) (function ((~ g!_) (~ var)) (~ body'))) (~ g!join)))] + (with_expansions [<default> (` (|> (~ value) ((~ g!each) (function ((~ g!_) (~ var)) (~ body'))) (~ g!conjoint)))] (let [[var value] binding] (case var [_ (#.Identifier ["" _])] @@ -91,13 +91,13 @@ (#.Some name) (let [name [location.dummy (#.Identifier ["" name])]] (` ({(~ name) - ({[(~ g!map) (~' in) (~ g!join)] + ({[(~ g!each) (~' in) (~ g!conjoint)] (~ body')} (~ name))} (~ monad)))) #.None - (` ({[(~ g!map) (~' in) (~ g!join)] + (` ({[(~ g!each) (~' in) (~ g!conjoint)] (~ body')} (~ monad)))))])) (#.Left "'do' bindings must have an even number of parts.")) @@ -109,8 +109,8 @@ (All [! a b] (-> (Monad !) (-> a (! b)) (-> (! a) (! b)))) - (|>> (\ monad map f) - (\ monad join))) + (|>> (\ monad each f) + (\ monad conjoint))) (def: .public (all monad) (All [! a] @@ -124,11 +124,11 @@ (#.Item x xs') (|> x - (!\map (function (_ _x) - (!\map (|>> (#.Item _x)) (recur xs')))) - !\join))))) + (!\each (function (_ _x) + (!\each (|>> (#.Item _x)) (recur xs')))) + !\conjoint))))) -(def: .public (map monad f) +(def: .public (each monad f) (All [M a b] (-> (Monad M) (-> a (M b)) (List a) (M (List b)))) @@ -140,9 +140,9 @@ (#.Item x xs') (|> (f x) - (!\map (function (_ _x) - (!\map (|>> (#.Item _x)) (recur xs')))) - !\join))))) + (!\each (function (_ _x) + (!\each (|>> (#.Item _x)) (recur xs')))) + !\conjoint))))) (def: .public (only monad f) (All [! a b] @@ -156,13 +156,13 @@ (#.Item head xs') (|> (f head) - (!\map (function (_ verdict) - (!\map (function (_ tail) - (if verdict - (#.Item head tail) - tail)) - (recur xs')))) - !\join))))) + (!\each (function (_ verdict) + (!\each (function (_ tail) + (if verdict + (#.Item head tail) + tail)) + (recur xs')))) + !\conjoint))))) (def: .public (mix monad f init xs) (All [M a b] diff --git a/stdlib/source/library/lux/abstract/monad/free.lux b/stdlib/source/library/lux/abstract/monad/free.lux index 82b405ccc..101a23d87 100644 --- a/stdlib/source/library/lux/abstract/monad/free.lux +++ b/stdlib/source/library/lux/abstract/monad/free.lux @@ -7,19 +7,20 @@ [monad (#+ Monad)]]) (type: .public (Free F a) - (#Pure a) - (#Effect (F (Free F a)))) + (Variant + (#Pure a) + (#Effect (F (Free F a))))) (implementation: .public (functor dsl) (All [F] (-> (Functor F) (Functor (Free F)))) - (def: (map f ea) + (def: (each f ea) (case ea (#Pure a) (#Pure (f a)) (#Effect value) - (#Effect (\ dsl map (map f) value))))) + (#Effect (\ dsl each (each f) value))))) (implementation: .public (apply dsl) (All [F] (-> (Functor F) (Apply (Free F)))) @@ -33,12 +34,12 @@ (#Pure (f a)) [(#Pure f) (#Effect fa)] - (#Effect (\ dsl map - (\ (..functor dsl) map f) + (#Effect (\ dsl each + (\ (..functor dsl) each f) fa)) [(#Effect ff) _] - (#Effect (\ dsl map (on ea) ff)) + (#Effect (\ dsl each (on ea) ff)) ))) (implementation: .public (monad dsl) @@ -49,7 +50,7 @@ (def: (in a) (#Pure a)) - (def: (join efefa) + (def: (conjoint efefa) (case efefa (#Pure efa) (case efa @@ -60,7 +61,7 @@ (#Effect fa)) (#Effect fefa) - (#Effect (\ dsl map - (\ (monad dsl) join) + (#Effect (\ dsl each + (\ (monad dsl) conjoint) fefa)) ))) diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index f255f9727..ad06165f3 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -31,8 +31,9 @@ (<>.and <code>.any <code>.any)) (type: Context - (#Macro Name Code) - (#Binding Binding)) + (Variant + (#Macro Name Code) + (#Binding Binding))) (def: global_identifier (Parser Name) @@ -53,10 +54,10 @@ (def: named_monad (Parser [(Maybe Text) Code]) - (<>.either (<code>.record (<>.and (\ <>.monad map (|>> #.Some) + (<>.either (<code>.record (<>.and (\ <>.monad each (|>> #.Some) <code>.local_identifier) <code>.any)) - (\ <>.monad map (|>> [#.None]) + (\ <>.monad each (|>> [#.None]) <code>.any))) (syntax: .public (do [[?name monad] ..named_monad diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index 01dacde2e..6e8aff164 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -6,7 +6,7 @@ (: a identity) (: (-> a a a) - compose)) + composite)) (def: .public (and left right) (All [l r] (-> (Monoid l) (Monoid r) (Monoid [l r]))) @@ -14,6 +14,6 @@ (def: identity [(\ left identity) (\ right identity)]) - (def: (compose [lL rL] [lR rR]) - [(\ left compose lL lR) - (\ right compose rL rR)]))) + (def: (composite [lL rL] [lR rR]) + [(\ left composite lL lR) + (\ right composite rL rR)]))) diff --git a/stdlib/source/library/lux/abstract/order.lux b/stdlib/source/library/lux/abstract/order.lux index 279c3beb0..7f055199a 100644 --- a/stdlib/source/library/lux/abstract/order.lux +++ b/stdlib/source/library/lux/abstract/order.lux @@ -47,10 +47,10 @@ (implementation: .public functor (contravariant.Functor Order) - (def: (map f order) + (def: (each f order) (implementation (def: &equivalence - (\ equivalence.functor map f (\ order &equivalence))) + (\ equivalence.functor each f (\ order &equivalence))) (def: (< reference sample) (\ order < (f reference) (f sample)))))) diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux index 20101f7a9..5c5cde91b 100644 --- a/stdlib/source/library/lux/abstract/predicate.lux +++ b/stdlib/source/library/lux/abstract/predicate.lux @@ -31,7 +31,7 @@ (All [a] (Monoid (Predicate a))) (def: identity <identity>) - (def: compose <composition>))] + (def: composite <composition>))] [union ..none ..or] [intersection ..all ..and] @@ -57,5 +57,5 @@ (implementation: .public functor (contravariant.Functor Predicate) - (def: (map f fb) + (def: (each f fb) (|>> f fb))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index de474236a..9cc286c29 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -30,8 +30,9 @@ [Text Code]) (type: Stack - {#bottom (Maybe Nat) - #top (List Code)}) + (Record + {#bottom (Maybe Nat) + #top (List Code)})) (def: aliases^ (Parser (List Alias)) @@ -48,7 +49,7 @@ (Parser Stack) (<>.either (<>.and (<>.maybe bottom^) (<code>.tuple (<>.some <code>.any))) - (<>.and (|> bottom^ (<>\map (|>> #.Some))) + (<>.and (|> bottom^ (<>\each (|>> #.Some))) (<>\in (list))))) (def: (stack_mix tops bottom) @@ -68,7 +69,7 @@ _ (meta.failure (format "Cannot expand to more than a single AST/Code node:" text.new_line - (|> expansion (list\map %.code) (text.interposed " "))))))) + (|> expansion (list\each %.code) (text.interposed " "))))))) (syntax: .public (=> [aliases aliases^ inputs stack^ @@ -78,8 +79,8 @@ (code.replaced (code.local_identifier from) to pre)) aliased aliases))] - (case [(|> inputs (value@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`)))) - (|> outputs (value@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`))))] + (case [(|> inputs (value@ #bottom) (maybe\each (|>> code.nat (~) #.Parameter (`)))) + (|> outputs (value@ #bottom) (maybe\each (|>> code.nat (~) #.Parameter (`))))] [(#.Some bottomI) (#.Some bottomO)] (monad.do meta.monad [inputC (singleton (macro.full_expansion (stack_mix (value@ #top inputs) bottomI))) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 0e248ff9b..f7f5644d3 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -56,7 +56,7 @@ [current (async.value read)] (case current (#.Some [head tail]) - (\ ! map (|>> (#.Item head)) + (\ ! each (|>> (#.Item head)) (pending tail)) #.None @@ -65,9 +65,10 @@ (abstract: .public (Actor s) {} - {#obituary [(Async <Obituary>) - (Resolver <Obituary>)] - #mailbox (Atom <Mailbox>)} + (Record + {#obituary [(Async <Obituary>) + (Resolver <Obituary>)] + #mailbox (Atom <Mailbox>)}) (type: .public (Mail s) <Mail>) @@ -76,8 +77,9 @@ <Obituary>) (type: .public (Behavior o s) - {#on_init (-> o s) - #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))}) + (Record + {#on_init (-> o s) + #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))})) (def: .public (spawn! behavior init) (All [o s] (-> (Behavior o s) o (IO (Actor s)))) @@ -112,7 +114,7 @@ (let [[obituary _] (value@ #obituary (:representation actor))] (|> obituary async.value - (\ io.functor map + (\ io.functor each (|>> (case> #.None bit.yes @@ -263,7 +265,7 @@ (do meta.monad [g!type (macro.identifier (format name "_abstract_type")) .let [g!actor (code.local_identifier name) - g!vars (list\map code.local_identifier vars)]] + g!vars (list\each code.local_identifier vars)]] (in (list (` ((~! abstract:) (~ export_policy) ((~ g!type) (~+ g!vars)) {} @@ -288,11 +290,12 @@ (~ init))))))))) (type: Signature - {#vars (List Text) - #name Text - #inputs (List |input|.Input) - #state Text - #self Text}) + (Record + {#vars (List Text) + #name Text + #inputs (List |input|.Input) + #state Text + #self Text})) (def: signature^ (Parser Signature) @@ -326,9 +329,9 @@ .let [g!type (code.local_identifier (value@ #abstract.name actor_scope)) g!message (code.local_identifier (value@ #name signature)) g!actor_vars (value@ #abstract.type_vars actor_scope) - g!all_vars (|> signature (value@ #vars) (list\map code.local_identifier) (list\compose g!actor_vars)) - g!inputsC (|> signature (value@ #inputs) (list\map product.left)) - g!inputsT (|> signature (value@ #inputs) (list\map product.right)) + g!all_vars (|> signature (value@ #vars) (list\each code.local_identifier) (list\composite g!actor_vars)) + g!inputsC (|> signature (value@ #inputs) (list\each product.left)) + g!inputsT (|> signature (value@ #inputs) (list\each product.right)) g!state (|> signature (value@ #state) code.local_identifier) g!self (|> signature (value@ #self) code.local_identifier)]] (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) @@ -365,6 +368,6 @@ (if continue? (|> actor (..mail! (action event stop)) - (\ ! map try.maybe)) + (\ ! each try.maybe)) (in #.None)))) channel))) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index bdd852ffc..c996e1dcc 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -42,8 +42,8 @@ succeeded? (atom.compare_and_swap! old new async)] (if succeeded? (do ! - [_ (monad.map ! (function (_ f) (f value)) - _observers)] + [_ (monad.each ! (function (_ f) (f value)) + _observers)] (in #1)) (resolve value)))))))) @@ -60,7 +60,7 @@ (All [a] (-> (Async a) (IO (Maybe a)))) (|>> :representation atom.read! - (\ io.functor map product.left))) + (\ io.functor each product.left))) (def: .public (upon! f async) (All [a] (-> (-> a (IO Any)) (Async a) (IO Any))) @@ -83,7 +83,7 @@ (def: .public resolved? (All [a] (-> (Async a) (IO Bit))) (|>> ..value - (\ io.functor map + (\ io.functor each (|>> (case> #.None #0 @@ -93,7 +93,7 @@ (implementation: .public functor (Functor Async) - (def: (map f fa) + (def: (each f fa) (let [[fb resolve] (..async [])] (exec (io.run! (..upon! (|>> f resolve) fa)) @@ -119,7 +119,7 @@ (def: in ..resolved) - (def: (join mma) + (def: (conjoint mma) (let [[ma resolve] (async [])] (exec (io.run! (..upon! (..upon! resolve) mma)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index b6d9461f0..5be4a9059 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -95,4 +95,4 @@ (All [a] (-> a (Atom a) (IO a))) (|> atom (..update! (function.constant value)) - (io\map product.left))) + (io\each product.left))) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 1e447ef17..df0ef8160 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -85,11 +85,11 @@ (implementation: .public functor (Functor Channel) - (def: (map f) - (async\map - (maybe\map + (def: (each f) + (async\each + (maybe\each (function (_ [head tail]) - [(f head) (map f tail)]))))) + [(f head) (each f tail)]))))) (implementation: .public apply (Apply Channel) @@ -119,7 +119,7 @@ (def: (in a) (async.resolved (#.Some [a ..empty]))) - (def: (join mma) + (def: (conjoint mma) (let [[output sink] (channel [])] (exec (: (Async Any) @@ -185,9 +185,9 @@ (def: .public (of_async async) (All [a] (-> (Async a) (Channel a))) - (async\map (function (_ value) - (#.Some [value ..empty])) - async)) + (async\each (function (_ value) + (#.Some [value ..empty])) + async)) (def: .public (mix f init channel) (All [a b] @@ -276,7 +276,7 @@ [item channel] (case item (#.Some [head tail]) - (\ ! map (|>> (#.Item head)) + (\ ! each (|>> (#.Item head)) (list tail)) #.None diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index e2cdb2aca..8f2378d3d 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -25,9 +25,10 @@ ["." async (#+ Async Resolver)]]) (type: State - {#max_positions Nat - #open_positions Int - #waiting_list (Queue (Resolver Any))}) + (Record + {#max_positions Nat + #open_positions Int + #waiting_list (Queue (Resolver Any))})) (abstract: .public Semaphore {} @@ -130,10 +131,11 @@ (abstract: .public Barrier {} - {#limit Limit - #count (Atom Nat) - #start_turnstile Semaphore - #end_turnstile Semaphore} + (Record + {#limit Limit + #count (Atom Nat) + #start_turnstile Semaphore + #end_turnstile Semaphore}) (def: .public (barrier limit) (-> Limit Barrier) diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 5e9759bdb..cb6a1e702 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -52,16 +52,16 @@ succeeded? (atom.compare_and_swap! old [new_value observers] var')] (if succeeded? (do ! - [_ (monad.map ! (function (_ sink) - (do ! - [result (\ sink feed new_value)] - (case result - (#try.Success _) - (in []) - - (#try.Failure _) - (un_follow! sink var)))) - observers)] + [_ (monad.each ! (function (_ sink) + (do ! + [result (\ sink feed new_value)] + (case result + (#try.Success _) + (in []) + + (#try.Failure _) + (un_follow! sink var)))) + observers)] (in [])) (write! new_value var)))) @@ -76,9 +76,10 @@ ) (type: (Tx_Frame a) - {#var (Var a) - #original a - #current a}) + (Record + {#var (Var a) + #original a + #current a})) (type: Tx (List (Ex [a] (Tx_Frame a)))) @@ -92,8 +93,8 @@ (list.example (function (_ [_var _original _current]) (same? (:as (Var Any) var) (:as (Var Any) _var)))) - (\ maybe.monad map (function (_ [_var _original _current]) - _current)) + (\ maybe.monad each (function (_ [_var _original _current]) + _current)) :expected)) (def: .public (read var) @@ -141,7 +142,7 @@ (implementation: .public functor (Functor STM) - (def: (map f fa) + (def: (each f fa) (function (_ tx) (let [[tx' a] (fa tx)] [tx' (f a)])))) @@ -166,7 +167,7 @@ (function (_ tx) [tx a])) - (def: (join mma) + (def: (conjoint mma) (function (_ tx) (let [[tx' ma] (mma tx)] (ma tx'))))) @@ -233,7 +234,7 @@ [finished_tx value] (stm_proc fresh_tx)] (if (can_commit? finished_tx) (do {! io.monad} - [_ (monad.map ! ..commit_var! finished_tx)] + [_ (monad.each ! ..commit_var! finished_tx)] (resolve value)) (..issue_commit! commit)))) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 1011da5bb..d618d7270 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -59,9 +59,10 @@ ... Default (type: Thread - {#creation Nat - #delay Nat - #action (IO Any)}) + (Record + {#creation Nat + #delay Nat + #action (IO Any)})) )) (def: .public parallelism @@ -127,7 +128,7 @@ ... Default (do {! io.monad} - [now (\ ! map (|>> instant.millis .nat) instant.now) + [now (\ ! each (|>> instant.millis .nat) instant.now) _ (atom.update! (|>> (#.Item {#creation now #delay milli_seconds #action action})) @@ -156,7 +157,7 @@ _ (do ! - [now (\ ! map (|>> instant.millis .nat) instant.now) + [now (\ ! each (|>> instant.millis .nat) instant.now) .let [[ready pending] (list.partition (function (_ thread) (|> (value@ #creation thread) (n.+ (value@ #delay thread)) @@ -165,7 +166,7 @@ swapped? (atom.compare_and_swap! threads pending ..runner)] (if swapped? (do ! - [_ (monad.map ! (|>> (value@ #action) ..execute! io.io) ready)] + [_ (monad.each ! (|>> (value@ #action) ..execute! io.io) ready)] (recur [])) (panic! (exception.error ..cannot_continue_running_threads [])))) )))) diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index 15fdc16d1..f56d127c7 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -54,7 +54,7 @@ (implementation: .public functor (All [o] (Functor (All [i] (Cont i o)))) - (def: (map f fv) + (def: (each f fv) (function (_ k) (fv (function.composite k f))))) @@ -77,7 +77,7 @@ (def: (in value) (function (_ k) (k value))) - (def: (join ffa) + (def: (conjoint ffa) (function (_ k) (ffa (continued k))))) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index c59767584..cf00522fa 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -27,8 +27,9 @@ ["//" try (#+ Try)]]) (type: .public (Exception a) - {#label Text - #constructor (-> a Text)}) + (Record + {#label Text + #constructor (-> a Text)})) (def: .public (match? exception error) (All [e] (-> (Exception e) Text Bit)) @@ -93,16 +94,16 @@ (macro.with_identifiers [g!descriptor] (do meta.monad [current_module meta.current_module_name - .let [descriptor ($_ text\compose "{" current_module "." name "}" text.new_line) + .let [descriptor ($_ text\composite "{" current_module "." name "}" text.new_line) g!self (code.local_identifier name)]] (in (list (` (def: (~ export_policy) (~ g!self) - (All [(~+ (list\map |type_variable|.format t_vars))] - (..Exception [(~+ (list\map (value@ #|input|.type) inputs))])) + (All [(~+ (list\each |type_variable|.format t_vars))] + (..Exception [(~+ (list\each (value@ #|input|.type) inputs))])) (let [(~ g!descriptor) (~ (code.text descriptor))] {#..label (~ g!descriptor) - #..constructor (function ((~ g!self) [(~+ (list\map (value@ #|input|.binding) inputs))]) - ((~! text\compose) (~ g!descriptor) + #..constructor (function ((~ g!self) [(~+ (list\each (value@ #|input|.binding) inputs))]) + ((~! text\composite) (~ g!descriptor) (~ (maybe.else (' "") body))))})))))))) (def: (report' entries) @@ -116,7 +117,7 @@ (list.repeated (n.+ (text.size header_separator) largest_header_size)) text.together - (text\compose text.new_line)) + (text\composite text.new_line)) on_entry (: (-> [Text Text] Text) (function (_ [header message]) (let [padding (|> " " @@ -125,21 +126,21 @@ text.together)] (|> message (text.replaced text.new_line on_new_line) - ($_ text\compose padding header header_separator)))))] + ($_ text\composite padding header header_separator)))))] (case entries #.End "" (#.Item head tail) (list\mix (function (_ post pre) - ($_ text\compose pre text.new_line (on_entry post))) + ($_ text\composite pre text.new_line (on_entry post))) (on_entry head) tail)))) (syntax: .public (report [entries (<>.many (<code>.tuple (<>.and <code>.any <code>.any)))]) (in (list (` ((~! report') (list (~+ (|> entries - (list\map (function (_ [header message]) - (` [(~ header) (~ message)]))))))))))) + (list\each (function (_ [header message]) + (` [(~ header) (~ message)]))))))))))) (def: .public (listing format entries) (All [a] diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 11cc82e62..3bbcd1bce 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -31,4 +31,4 @@ (All [a] (Monoid (-> a a))) (def: identity ..identity) - (def: compose ..composite)) + (def: composite ..composite)) diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index 98009b21d..4f5013f77 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -31,7 +31,7 @@ (All [i o] (Monoid (Mixin i o))) (def: identity ..nothing) - (def: compose ..with)) + (def: composite ..with)) (def: .public (advice when then) (All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o))) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index dd647ce41..3d26dedd1 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -25,9 +25,10 @@ ["." //]) (type: Mutual - {#declaration Declaration - #type Code - #body Code}) + (Record + {#declaration Declaration + #type Code + #body Code})) (.def: mutual (Parser [Declaration Code Code]) @@ -68,35 +69,36 @@ (macro.with_identifiers [g!context g!output] (do {! meta.monad} [here_name meta.current_module_name - hidden_names (monad.map ! (//.constant (macro.identifier "mutual_function#")) - functions) - .let [definitions (list\map (..mutual_definition hidden_names g!context) - (list.zipped/2 hidden_names - functions)) - context_types (list\map (function (_ mutual) - (` (-> (~ g!context) (~ (value@ #type mutual))))) - functions) - user_names (list\map (|>> (value@ [#declaration #declaration.name]) code.local_identifier) - functions)] - g!pop (local.push (list\map (function (_ [g!name mutual]) - [[here_name (value@ [#declaration #declaration.name] mutual)] - (..macro g!context g!name)]) - (list.zipped/2 hidden_names - functions)))] + hidden_names (monad.each ! (//.constant (macro.identifier "mutual_function#")) + functions) + .let [definitions (list\each (..mutual_definition hidden_names g!context) + (list.zipped/2 hidden_names + functions)) + context_types (list\each (function (_ mutual) + (` (-> (~ g!context) (~ (value@ #type mutual))))) + functions) + user_names (list\each (|>> (value@ [#declaration #declaration.name]) code.local_identifier) + functions)] + g!pop (local.push (list\each (function (_ [g!name mutual]) + [[here_name (value@ [#declaration #declaration.name] mutual)] + (..macro g!context g!name)]) + (list.zipped/2 hidden_names + functions)))] (in (list (` (.let [(~ g!context) (: (Rec (~ g!context) [(~+ context_types)]) [(~+ definitions)]) [(~+ user_names)] (.let [[(~+ user_names)] (~ g!context)] - [(~+ (list\map (function (_ g!name) - (` ((~ g!name) (~ g!context)))) - user_names))]) + [(~+ (list\each (function (_ g!name) + (` ((~ g!name) (~ g!context)))) + user_names))]) (~ g!output) (~ body)] (exec (~ g!pop) (~ g!output)))))))))) (type: Definition - {#export_policy Code - #mutual Mutual}) + (Record + {#export_policy Code + #mutual Mutual})) (.def: definition (Parser Definition) @@ -119,37 +121,37 @@ (macro.with_identifiers [g!context g!output] (do {! meta.monad} [here_name meta.current_module_name - hidden_names (monad.map ! (//.constant (macro.identifier "mutual_function#")) - functions) - .let [definitions (list\map (..mutual_definition hidden_names g!context) - (list.zipped/2 hidden_names - (list\map (value@ #mutual) functions))) - context_types (list\map (function (_ mutual) - (` (-> (~ g!context) (~ (value@ [#mutual #type] mutual))))) - functions) - user_names (list\map (|>> (value@ [#mutual #declaration #declaration.name]) code.local_identifier) - functions)] - g!pop (local.push (list\map (function (_ [g!name mutual]) - [[here_name (value@ [#mutual #declaration #declaration.name] mutual)] - (..macro g!context g!name)]) - (list.zipped/2 hidden_names - functions)))] + hidden_names (monad.each ! (//.constant (macro.identifier "mutual_function#")) + functions) + .let [definitions (list\each (..mutual_definition hidden_names g!context) + (list.zipped/2 hidden_names + (list\each (value@ #mutual) functions))) + context_types (list\each (function (_ mutual) + (` (-> (~ g!context) (~ (value@ [#mutual #type] mutual))))) + functions) + user_names (list\each (|>> (value@ [#mutual #declaration #declaration.name]) code.local_identifier) + functions)] + g!pop (local.push (list\each (function (_ [g!name mutual]) + [[here_name (value@ [#mutual #declaration #declaration.name] mutual)] + (..macro g!context g!name)]) + (list.zipped/2 hidden_names + functions)))] (in (list& (` (.def: (~ g!context) - [(~+ (list\map (value@ [#mutual #type]) functions))] + [(~+ (list\each (value@ [#mutual #type]) functions))] (.let [(~ g!context) (: (Rec (~ g!context) [(~+ context_types)]) [(~+ definitions)]) [(~+ user_names)] (~ g!context)] - [(~+ (list\map (function (_ g!name) - (` ((~ g!name) (~ g!context)))) - user_names))]))) + [(~+ (list\each (function (_ g!name) + (` ((~ g!name) (~ g!context)))) + user_names))]))) g!pop - (list\map (function (_ mutual) - (.let [g!name (|> mutual (value@ [#mutual #declaration #declaration.name]) code.local_identifier)] - (` (.def: - (~ (value@ #export_policy mutual)) - (~ g!name) - (~ (value@ [#mutual #type] mutual)) - (.let [[(~+ user_names)] (~ g!context)] - (~ g!name)))))) - functions))))))) + (list\each (function (_ mutual) + (.let [g!name (|> mutual (value@ [#mutual #declaration #declaration.name]) code.local_identifier)] + (` (.def: + (~ (value@ #export_policy mutual)) + (~ g!name) + (~ (value@ [#mutual #type] mutual)) + (.let [[(~+ user_names)] (~ g!context)] + (~ g!name)))))) + functions))))))) diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 4666dfb8a..4f051e604 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -44,7 +44,7 @@ (implementation: .public functor (Functor IO) - (def: (map f) + (def: (each f) (|>> run!' f !io))) (implementation: .public apply @@ -60,7 +60,9 @@ (def: &functor ..functor) - (def: in (|>> !io)) + (def: in + (|>> !io)) - (def: join (|>> run!' run!' !io))) + (def: conjoint + (|>> run!' run!' !io))) ) diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index 58cf7a526..e12de5bb9 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -54,7 +54,7 @@ (implementation: .public functor (Functor Lazy) - (def: (map f fa) + (def: (each f fa) (lazy (f (value fa))))) (implementation: .public apply @@ -69,4 +69,4 @@ (def: &functor ..functor) (def: in (|>> lazy)) - (def: join value)) + (def: conjoint ..value)) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 854ef0402..6fbc4b294 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -20,7 +20,7 @@ (def: identity #.None) - (def: (compose mx my) + (def: (composite mx my) (case mx #.None my @@ -31,7 +31,7 @@ (implementation: .public functor (Functor Maybe) - (def: (map f ma) + (def: (each f ma) (case ma #.None #.None (#.Some a) (#.Some (f a))))) @@ -57,7 +57,7 @@ (def: (in x) (#.Some x)) - (def: (join mma) + (def: (conjoint mma) (case mma #.None #.None @@ -102,7 +102,7 @@ (def: in (|>> (\ ..monad in) (\ monad in))) - (def: (join MmMma) + (def: (conjoint MmMma) (do monad [mMma MmMma] (case mMma @@ -114,7 +114,7 @@ (def: .public (lifted monad) (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) - (\ monad map (\ ..monad in))) + (\ monad each (\ ..monad in))) (macro: .public (else tokens state) (case tokens diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 30c728cd2..4d32c8df6 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -22,7 +22,7 @@ (implementation: .public functor (All [s] (Functor (Parser s))) - (def: (map f ma) + (def: (each f ma) (function (_ input) (case (ma input) (#try.Failure msg) @@ -59,7 +59,7 @@ (function (_ input) (#try.Success [input x]))) - (def: (join mma) + (def: (conjoint mma) (function (_ input) (case (mma input) (#try.Failure msg) @@ -96,7 +96,7 @@ (-> (Parser s a) (Parser s b) (Parser s [a b]))) (do {! ..monad} [head first] - (\ ! map (|>> [head]) second))) + (\ ! each (|>> [head]) second))) (def: .public (or left right) (All [s a b] @@ -134,7 +134,7 @@ (#try.Success [input (list)]) (#try.Success [input' head]) - (..result (\ ..monad map (|>> (list& head)) + (..result (\ ..monad each (|>> (list& head)) (some parser)) input')))) @@ -143,7 +143,7 @@ (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) (..and parser) - (\ ..monad map (|>> #.Item)))) + (\ ..monad each (|>> #.Item)))) (def: .public (exactly amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) @@ -153,13 +153,13 @@ [x parser] (|> parser (exactly (-- amount)) - (\ ! map (|>> (#.Item x))))))) + (\ ! each (|>> (#.Item x))))))) (def: .public (at_least amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (do {! ..monad} [minimum (..exactly amount parser)] - (\ ! map (list\compose minimum) (..some parser)))) + (\ ! each (list\composite minimum) (..some parser)))) (def: .public (at_most amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) @@ -171,7 +171,7 @@ (#try.Success [input (list)]) (#try.Success [input' x]) - (..result (\ ..monad map (|>> (#.Item x)) + (..result (\ ..monad each (|>> (#.Item x)) (at_most (-- amount) parser)) input'))))) @@ -181,7 +181,7 @@ [minimum (..exactly minimum parser)] (case additional 0 (in minimum) - _ (\ ! map (list\compose minimum) + _ (\ ! each (list\composite minimum) (..at_most additional parser))))) (def: .public (separated_by separator parser) @@ -196,7 +196,7 @@ (|> parser (..and separator) ..some - (\ ! map (|>> (list\map product.right) (#.Item x))))))) + (\ ! each (|>> (list\each product.right) (#.Item x))))))) (def: .public (not parser) (All [s a] (-> (Parser s a) (Parser s Any))) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 42bffc310..27caea2af 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple nat int rev local) + [lux (#- Tuple Variant nat int rev local) [abstract [monad (#+ do)]] [control @@ -36,7 +36,7 @@ (-> (List Analysis) Text) (format text.new_line "Remaining input: " (|> asts - (list\map /.%analysis) + (list\each /.%analysis) (text.interposed " ")))) (exception: .public (cannot_parse {input (List Analysis)}) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 4fd9d15f5..220dd5ea2 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -99,7 +99,7 @@ (def: .public frac (Parser Frac) - (//\map frac.of_bits ..bits/64)) + (//\each frac.of_bits ..bits/64)) (exception: .public (invalid_tag {range Nat} {byte Nat}) (exception.report @@ -112,7 +112,7 @@ ..bits/8)] (`` (case flag (^template [<number> <tag> <parser>] - [<number> (\ ! map (|>> <tag>) <parser>)]) + [<number> (\ ! each (|>> <tag>) <parser>)]) ((~~ (template.spliced <case>+))) _ (//.lifted (exception.except ..invalid_tag [(~~ (template.amount <case>+)) flag])))))]) @@ -153,13 +153,13 @@ 0 (#try.Success [[offset binary] (/.empty 0)]) _ (|> binary (/.slice offset size) - (\ try.monad map (|>> [[(n.+ size offset) binary]])))))) + (\ try.monad each (|>> [[(n.+ size offset) binary]])))))) (template [<size> <name> <bits>] [(`` (def: .public <name> (Parser Binary) (do //.monad - [size (//\map .nat <bits>)] + [size (//\each .nat <bits>)] (..segment size))))] [08 binary/8 ..bits/8] diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index 1a3bbc5a7..9b83d835a 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -32,9 +32,9 @@ (def: remaining_inputs (-> (List Code) Text) - (|>> (list\map code.format) + (|>> (list\each code.format) (text.interposed " ") - ($_ text\compose text.new_line "Remaining input: "))) + ($_ text\composite text.new_line "Remaining input: "))) (def: .public any (Parser Code) @@ -47,7 +47,7 @@ (#try.Success [tokens' t])))) (template [<query> <check> <type> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))] + [(with_expansions [<failure> (as_is (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))] (def: .public <query> (Parser <type>) (function (_ tokens) @@ -87,14 +87,14 @@ (#.Item [token tokens']) (if (code\= code token) (#try.Success [tokens' []]) - (#try.Failure ($_ text\compose "Expected a " (code.format code) " but instead got " (code.format token) + (#try.Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) (remaining_inputs tokens)))) _ (#try.Failure "There are no tokens to parse!")))) (template [<query> <check> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))] + [(with_expansions [<failure> (as_is (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))] (def: .public <query> (Parser Text) (function (_ tokens) @@ -130,10 +130,10 @@ (#.Item [[_ (<tag> members)] tokens']) (case (p members) (#try.Success [#.End x]) (#try.Success [tokens' x]) - _ (#try.Failure ($_ text\compose "Parser was expected to fully consume " <desc> (remaining_inputs tokens)))) + _ (#try.Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens)))) _ - (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))))] + (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))))] [ form #.Form "form"] [tuple #.Tuple "tuple"] @@ -147,17 +147,17 @@ (#.Item [[_ (#.Record pairs)] tokens']) (case (p (un_paired pairs)) (#try.Success [#.End x]) (#try.Success [tokens' x]) - _ (#try.Failure ($_ text\compose "Parser was expected to fully consume record" (remaining_inputs tokens)))) + _ (#try.Failure ($_ text\composite "Parser was expected to fully consume record" (remaining_inputs tokens)))) _ - (#try.Failure ($_ text\compose "Cannot parse record" (remaining_inputs tokens)))))) + (#try.Failure ($_ text\composite "Cannot parse record" (remaining_inputs tokens)))))) (def: .public end! (Parser Any) (function (_ tokens) (case tokens #.End (#try.Success [tokens []]) - _ (#try.Failure ($_ text\compose "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) + _ (#try.Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) (def: .public end? (Parser Bit) @@ -179,9 +179,9 @@ _ (#try.Failure (|> unconsumed - (list\map code.format) + (list\each code.format) (text.interposed ", ") - (text\compose "Unconsumed inputs: ")))))) + (text\composite "Unconsumed inputs: ")))))) (def: .public (local inputs parser) (All [a] (-> (List Code) (Parser a) (Parser a))) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index f084a838d..fbb7335f5 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -41,4 +41,4 @@ (def: .public (result parser environment) (All [a] (-> (Parser a) Environment (Try a))) - (\ try.monad map product.right (parser environment))) + (\ try.monad each product.right (parser environment))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 1348b92b4..dcbda6f71 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -146,8 +146,8 @@ (#/.Object kvs) (case (|> kvs dictionary.entries - (list\map (function (_ [key value]) - (list (#/.String key) value))) + (list\each (function (_ [key value]) + (list (#/.String key) value))) list.together (//.result parser)) (#try.Failure error) @@ -195,4 +195,4 @@ (|>> (//.and ..string) //.some ..object - (//\map (dictionary.of_list text.hash)))) + (//\each (dictionary.of_list text.hash)))) diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index df28b3df1..d6c6fbeca 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple function loop i64 local) + [lux (#- Tuple Variant function loop i64 local) [abstract [monad (#+ do)]] [control diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index 0e9724a15..24a2f9e3c 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -31,8 +31,9 @@ (//.Parser [Offset Text])) (type: .public Slice - {#basis Offset - #distance Offset}) + (Record + {#basis Offset + #distance Offset})) (def: (remaining' offset tape) (-> Offset Text Text) @@ -161,7 +162,7 @@ (do //.monad [char any .let [char' (maybe.trusted (/.char 0 char))] - _ (//.assertion ($_ /\compose "Character is not within range: " (/.of_char bottom) "-" (/.of_char top)) + _ (//.assertion ($_ /\composite "Character is not within range: " (/.of_char bottom) "-" (/.of_char top)) (.and (n.>= bottom char') (n.<= top char')))] (in char))) @@ -265,7 +266,7 @@ (do //.monad [=left left =right right] - (in ($_ /\compose =left =right)))) + (in ($_ /\composite =left =right)))) (def: .public (and! left right) (-> (Parser Slice) (Parser Slice) (Parser Slice)) @@ -277,7 +278,7 @@ (template [<name> <base> <doc_modifier>] [(def: .public (<name> parser) (-> (Parser Text) (Parser Text)) - (|> parser <base> (\ //.monad map /.together)))] + (|> parser <base> (\ //.monad each /.together)))] [some //.some "some"] [many //.many "many"] @@ -297,7 +298,7 @@ (-> Nat (Parser Text) (Parser Text)) (|> parser (<base> amount) - (\ //.monad map /.together)))] + (\ //.monad each /.together)))] [exactly //.exactly "exactly"] [at_most //.at_most "at most"] @@ -319,7 +320,7 @@ (-> Nat Nat (Parser Text) (Parser Text)) (|> parser (//.between minimum additional) - (\ //.monad map /.together))) + (\ //.monad each /.together))) (def: .public (between! minimum additional parser) (-> Nat Nat (Parser Slice) (Parser Slice)) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 0b726282a..d51ebc152 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -54,7 +54,7 @@ (exception: .public (unconsumed_input {remaining (List Type)}) (exception.report ["Types" (|> remaining - (list\map (|>> %.type (format text.new_line "* "))) + (list\each (|>> %.type (format text.new_line "* "))) (text.interposed ""))])) (type: .public Env @@ -132,7 +132,7 @@ (def: (label idx) (-> Nat Code) - (code.local_identifier ($_ text\compose "label" text.tab (n\encoded idx)))) + (code.local_identifier ($_ text\composite "label" text.tab (n\encoded idx)))) (def: .public (with_extension type poly) (All [a] (-> Type (Parser a) (Parser [Code a]))) @@ -175,7 +175,7 @@ (All [a] (-> (Parser a) (Parser [Code (List Code) a]))) (do {! //.monad} [headT any - funcI (\ ! map dictionary.size ..env) + funcI (\ ! each dictionary.size ..env) [num_args non_poly] (local (list headT) ..polymorphic') env ..env .let [funcL (label funcI) @@ -194,7 +194,7 @@ partial_varI (++ partialI) partial_varL (label partial_varI) partialC (` ((~ funcL) (~+ (|> (list.indices num_args) - (list\map (|>> (n.* 2) ++ (n.+ funcI) label)) + (list\each (|>> (n.* 2) ++ (n.+ funcI) label)) list.reversed))))] (recur (++ current_arg) (|> env' @@ -344,6 +344,6 @@ _ (local (list funcT) (..parameter! 0)) allC (let [allT (list& funcT argsT)] (|> allT - (monad.map ! (function.constant ..parameter)) + (monad.each ! (function.constant ..parameter)) (local allT)))] (in (` ((~+ allC)))))) diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 2e982ad45..6be4241d0 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -108,7 +108,7 @@ (if (name\= expected actual) (|> children (..result' parser attrs') - (try\map (|>> [[attrs tail]]))) + (try\each (|>> [[attrs tail]]))) (exception.except ..wrong_tag [expected actual])))))) (def: .public any diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 8fda36325..760dfb143 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -104,11 +104,12 @@ prev <code>.any]) (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] - [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body)))) - paths))])))))) + [(~+ (list\each (function (_ body) (` (|> (~ g!temp) (~+ body)))) + paths))])))))) (syntax: .public (case> [branches (<>.many (<>.and <code>.any <code>.any)) prev <code>.any]) (in (list (` (case (~ prev) - (~+ (list\join (list\map (function (_ [pattern body]) (list pattern body)) - branches)))))))) + (~+ (|> branches + (list\each (function (_ [pattern body]) (list pattern body))) + list\conjoint))))))) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index 7d6462858..b5b6c3e6e 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -24,7 +24,7 @@ (implementation: .public functor (All [r] (Functor (Reader r))) - (def: (map f fa) + (def: (each f fa) (function (_ env) (f (fa env))))) @@ -45,7 +45,7 @@ (def: (in x) (function (_ env) x)) - (def: (join mma) + (def: (conjoint mma) (function (_ env) (mma env env)))) @@ -58,7 +58,7 @@ (def: in (|>> (\ monad in) (\ ..monad in))) - (def: (join eMeMa) + (def: (conjoint eMeMa) (function (_ env) (do monad [eMa (result env eMeMa)] diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 1ca544ca6..a8a30cfd2 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -58,8 +58,8 @@ (do {! monad} [[cleaners output] (computation [[] (list)])] (|> cleaners - (monad.map ! (function (_ cleaner) (cleaner []))) - (\ ! map (list\mix clean output))))) + (monad.each ! (function (_ cleaner) (cleaner []))) + (\ ! each (list\mix clean output))))) (def: .public (acquire! monad cleaner value) (All [! a] (-> (Monad !) (-> a (! (Try Any))) a @@ -74,10 +74,10 @@ (-> (Functor !) (All [r] (Functor (Region r !))))) - (def: (map f) + (def: (each f) (function (_ fa) (function (_ region+cleaners) - (\ super map + (\ super each (function (_ [cleaners' temp]) [cleaners' (case temp (#try.Success value) @@ -124,7 +124,7 @@ (function (_ [region cleaners]) (\ super in [cleaners (#try.Success value)]))) - (def: (join ffa) + (def: (conjoint ffa) (function (_ [region cleaners]) (do super [[cleaners efa] (ffa [region cleaners])] @@ -153,6 +153,6 @@ (-> (Monad !) (! a) (All [r] (Region r ! a)))) (function (_ [region cleaners]) - (\ monad map + (\ monad each (|>> #try.Success [cleaners]) operation))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index eaba75049..8ba79f6a7 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -36,8 +36,8 @@ (def: deadline (Parser Date) ($_ <>.either - (<>\map (|>> instant.of_millis instant.date) - <c>.int) + (<>\each (|>> instant.of_millis instant.date) + <c>.int) (do <>.monad [raw <c>.text] (case (\ date.codec decoded raw) diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index 45b2bd083..ec84db916 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -51,14 +51,14 @@ (do {! meta.monad} [this_module meta.current_module_name .let [[name vars] declaration] - g!brand (\ ! map (|>> %.code code.text) + g!brand (\ ! each (|>> %.code code.text) (macro.identifier (format (%.name [this_module name])))) .let [capability (` (..Capability (.primitive (~ g!brand)) (~ input) (~ output)))]] (in (list (` (type: (~ export_policy) (~ (|declaration|.format declaration)) (~ capability))) (` (def: (~ (code.local_identifier forger)) - (All [(~+ (list\map code.local_identifier vars))] + (All [(~+ (list\each code.local_identifier vars))] (-> (-> (~ input) (~ output)) (~ capability))) (~! ..capability))) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index 497e250ff..1087cf751 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -20,8 +20,9 @@ (-> (Policy brand value label) value)) (type: .public (Privilege brand label) - {#can_upgrade (Can_Upgrade brand label) - #can_downgrade (Can_Downgrade brand label)}) + (Record + {#can_upgrade (Can_Upgrade brand label) + #can_downgrade (Can_Downgrade brand label)})) (type: .public (Delegation brand from to) (All [value] @@ -58,7 +59,7 @@ (implementation: .public functor (:~ (..of_policy Functor)) - (def: (map f fa) + (def: (each f fa) (|> fa :representation f :abstraction))) (implementation: .public apply @@ -74,7 +75,7 @@ (def: &functor ..functor) (def: in (|>> :abstraction)) - (def: join (|>> :representation))) + (def: conjoint (|>> :representation))) ) (template [<brand> <value> <upgrade> <downgrade>] diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 586cb652c..4b3a64a08 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -42,7 +42,7 @@ (implementation: .public functor (All [s] (Functor (State s))) - (def: (map f ma) + (def: (each f ma) (function (_ state) (let [[state' a] (ma state)] [state' (f a)])))) @@ -67,7 +67,7 @@ (function (_ state) [state a])) - (def: (join mma) + (def: (conjoint mma) (function (_ state) (let [[state' ma] (mma state)] (ma state'))))) @@ -91,9 +91,9 @@ (implementation: (with//functor functor) (All [M s] (-> (Functor M) (Functor (All [a] (-> s (M [s a])))))) - (def: (map f sfa) + (def: (each f sfa) (function (_ state) - (\ functor map (function (_ [s a]) [s (f a)]) + (\ functor each (function (_ [s a]) [s (f a)]) (sfa state))))) (implementation: (with//apply monad) @@ -124,7 +124,7 @@ (function (_ state) (\ monad in [state a]))) - (def: (join sMsMa) + (def: (conjoint sMsMa) (function (_ state) (do monad [[state' sMa] (sMsMa state)] diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index 8366b2efc..a7acf841e 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -71,7 +71,7 @@ (implementation: .public functor (All [!] (Functor (Thread !))) - (def: (map f) + (def: (each f) (function (_ fa) (function (_ !) (f (fa !)))))) @@ -94,7 +94,7 @@ (function (_ !) value)) - (def: (join ffa) + (def: (conjoint ffa) (function (_ !) ((ffa !) !)))) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 2a1fce570..48ee21443 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -10,13 +10,14 @@ ["." location]]]]) (type: .public (Try a) - (#Failure Text) - (#Success a)) + (Variant + (#Failure Text) + (#Success a))) (implementation: .public functor (Functor Try) - (def: (map f ma) + (def: (each f ma) (case ma (#Failure msg) (#Failure msg) @@ -50,7 +51,7 @@ (def: (in a) (#Success a)) - (def: (join mma) + (def: (conjoint mma) (case mma (#Failure msg) (#Failure msg) @@ -69,7 +70,7 @@ (|>> (\ ..monad in) (\ monad in))) - (def: (join MeMea) + (def: (conjoint MeMea) (do monad [eMea MeMea] (case eMea @@ -81,7 +82,7 @@ (def: .public (lifted monad) (All [! a] (-> (Monad !) (-> (! a) (! (Try a))))) - (\ monad map (\ ..monad in))) + (\ monad each (\ ..monad in))) (implementation: .public (equivalence (^open "_\.")) (All [a] (-> (Equivalence a) (Equivalence (Try a)))) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index d42e57780..825700d8f 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -9,8 +9,9 @@ ["." monad (#+ Monad do)]]]]) (type: .public (Writer log value) - {#log log - #value value}) + (Record + {#log log + #value value})) (def: .public (write message) (All [log] (-> log (Writer log Any))) @@ -20,7 +21,7 @@ (All [l] (Functor (Writer l))) - (def: (map f fa) + (def: (each f fa) (let [[log datum] fa] [log (f datum)]))) @@ -33,7 +34,7 @@ (def: (on fa ff) (let [[log1 f] ff [log2 a] fa] - [(\ monoid compose log1 log2) (f a)]))) + [(\ monoid composite log1 log2) (f a)]))) (implementation: .public (monad monoid) (All [l] @@ -44,9 +45,9 @@ (def: in (|>> [(\ monoid identity)])) - (def: (join mma) + (def: (conjoint mma) (let [[log1 [log2 a]] mma] - [(\ monoid compose log1 log2) a]))) + [(\ monoid composite log1 log2) a]))) (implementation: .public (with monoid monad) (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a)))))) @@ -59,7 +60,7 @@ (let [writer (..monad monoid)] (|>> (\ writer in) (\ monad in)))) - (def: (join MlMla) + (def: (conjoint MlMla) (do monad [[l1 Mla] (for {@.old (: ((:parameter 1) (Writer (:parameter 0) ((:parameter 1) (Writer (:parameter 0) (:parameter 2))))) @@ -67,10 +68,10 @@ ... On new compiler MlMla) [l2 a] Mla] - (in [(\ monoid compose l1 l2) a])))) + (in [(\ monoid composite l1 l2) a])))) (def: .public (lifted monoid monad) (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) - (\ monad map (|>> [(\ monoid identity)]))) + (\ monad each (|>> [(\ monoid identity)]))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index 6028c1a68..ada9bc855 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -359,7 +359,7 @@ (def: identity (..empty 0)) - (def: (compose left right) + (def: (composite left right) (let [sizeL (!size left) sizeR (!size right) output (..empty (n.+ sizeL sizeR))] diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 38f7b5f8d..6efecceb7 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -40,7 +40,7 @@ (Monoid Bit) (def: identity <identity>) - (def: (compose x y) (<op> x y)))] + (def: (composite x y) (<op> x y)))] [disjunction #0 or] [conjunction #1 and] diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 4ec5d1612..3ae79571c 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -331,7 +331,7 @@ (def: identity (empty 0)) - (def: (compose xs ys) + (def: (composite xs ys) (let [sxs (size xs) sxy (size ys)] (|> (empty (n.+ sxy sxs)) @@ -341,7 +341,7 @@ (implementation: .public functor (Functor Array) - (def: (map f ma) + (def: (each f ma) (let [arr_size (size ma)] (if (n.= 0 arr_size) (empty arr_size) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index afc1cd356..e06983307 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -57,11 +57,12 @@ ... Nodes for the tree data-structure that organizes the data inside ... Dictionaries. (type: (Node k v) - (#Hierarchy Nat (Array (Node k v))) - (#Base Bit_Map - (Array (Either (Node k v) - [k v]))) - (#Collisions Hash_Code (Array [k v]))) + (Variant + (#Hierarchy Nat (Array (Node k v))) + (#Base Bit_Map + (Array (Either (Node k v) + [k v]))) + (#Collisions Hash_Code (Array [k v])))) ... #Hierarchy nodes are meant to point down only to lower-level nodes. (type: (Hierarchy k v) @@ -225,7 +226,7 @@ ... Produces the index of a KV-pair within a #Collisions node. (def: (collision_index key_hash key colls) (All [k v] (-> (Hash k) k (Collisions k v) (Maybe Index))) - (\ maybe.monad map product.left + (\ maybe.monad each product.left (array.example+ (function (_ idx [key' val']) (\ key_hash = key key')) colls))) @@ -509,7 +510,7 @@ ... For #Collisions nodes, do a linear scan of all the known KV-pairs. (#Collisions _hash _colls) - (\ maybe.monad map product.right + (\ maybe.monad each product.right (array.example (|>> product.left (\ key_hash = key)) _colls)) )) @@ -518,14 +519,14 @@ (All [k v] (-> (Node k v) Nat)) (case node (#Hierarchy _size hierarchy) - (array\mix n.+ 0 (array\map size' hierarchy)) + (array\mix n.+ 0 (array\each size' hierarchy)) (#Base _ base) - (array\mix n.+ 0 (array\map (function (_ sub_node') - (case sub_node' - (#.Left sub_node) (size' sub_node) - (#.Right _) 1)) - base)) + (array\mix n.+ 0 (array\each (function (_ sub_node') + (case sub_node' + (#.Left sub_node) (size' sub_node) + (#.Right _) 1)) + base)) (#Collisions hash colls) (array.size colls) @@ -535,7 +536,7 @@ (All [k v] (-> (Node k v) (List [k v]))) (case node (#Hierarchy _size hierarchy) - (array\mix (function (_ sub_node tail) (list\compose (entries' sub_node) tail)) + (array\mix (function (_ sub_node tail) (list\composite (entries' sub_node) tail)) #.End hierarchy) @@ -543,7 +544,7 @@ (array\mix (function (_ branch tail) (case branch (#.Left sub_node) - (list\compose (entries' sub_node) tail) + (list\composite (entries' sub_node) tail) (#.Right [key' val']) (#.Item [key' val'] tail))) @@ -556,8 +557,9 @@ colls))) (type: .public (Dictionary k v) - {#hash (Hash k) - #root (Node k v)}) + (Record + {#hash (Hash k) + #root (Node k v)})) (def: .public key_hash (All [k v] (-> (Dictionary k v) (Hash k))) @@ -701,28 +703,28 @@ (implementation: functor' (All [k] (Functor (Node k))) - (def: (map f fa) + (def: (each f fa) (case fa (#Hierarchy size hierarchy) - (#Hierarchy size (array\map (map f) hierarchy)) + (#Hierarchy size (array\each (each f) hierarchy)) (#Base bitmap base) - (#Base bitmap (array\map (function (_ either) - (case either - (#.Left fa') - (#.Left (map f fa')) - - (#.Right [k v]) - (#.Right [k (f v)]))) - base)) + (#Base bitmap (array\each (function (_ either) + (case either + (#.Left fa') + (#.Left (each f fa')) + + (#.Right [k v]) + (#.Right [k (f v)]))) + base)) (#Collisions hash collisions) - (#Collisions hash (array\map (function (_ [k v]) - [k (f v)]) - collisions))))) + (#Collisions hash (array\each (function (_ [k v]) + [k (f v)]) + collisions))))) (implementation: .public functor (All [k] (Functor (Dictionary k))) - (def: (map f fa) - (revised@ #root (\ ..functor' map f) fa))) + (def: (each f fa) + (revised@ #root (\ ..functor' each f) fa))) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 49d4068d5..ef9e53973 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -19,15 +19,17 @@ "Invariant violation") (type: Color - #Red - #Black) + (Variant + #Red + #Black)) (type: (Node k v) - {#color Color - #key k - #value v - #left (Maybe (Node k v)) - #right (Maybe (Node k v))}) + (Record + {#color Color + #key k + #value v + #left (Maybe (Node k v)) + #right (Maybe (Node k v))})) (template [<create> <color>] [(def: (<create> key value left right) @@ -43,8 +45,9 @@ ) (type: .public (Dictionary k v) - {#&order (Order k) - #root (Maybe (Node k v))}) + (Record + {#&order (Order k) + #root (Maybe (Node k v))})) (def: .public (empty order) (All [k v] (-> (Order k) (Dictionary k v))) @@ -352,7 +355,7 @@ (#.Some (right_balanced (value@ #key right) (value@ #value right) (value@ #right right>>left) - (\ maybe.functor map reddened (value@ #right right))))) + (\ maybe.functor each reddened (value@ #right right))))) _ (panic! error_message)) @@ -379,7 +382,7 @@ (value@ #value left>>right) (#.Some (left_balanced (value@ #key left) (value@ #value left) - (\ maybe.functor map reddened (value@ #left left)) + (\ maybe.functor each reddened (value@ #left left)) (value@ #left left>>right))) (#.Some (black key value (value@ #right left>>right) ?right))) @@ -547,7 +550,7 @@ (list) (#.Some node') - ($_ list\compose + ($_ list\composite (recur (value@ #left node')) (list <output>) (recur (value@ #right node'))))))] diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index e98a2c51b..df834ae4c 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -42,7 +42,7 @@ (template [<name> <type> <access>] [(def: .public <name> (All [a] (-> (PList a) (List <type>))) - (list\map <access>))] + (list\each <access>))] [keys Text product.left] [values a product.right] diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 98a3224e4..b40e94669 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -312,26 +312,26 @@ (All [a] (Monoid (List a))) (def: identity #.End) - (def: (compose xs ys) + (def: (composite xs ys) (case xs #.End ys (#.Item x xs') - (#.Item x (compose xs' ys))))) + (#.Item x (composite xs' ys))))) (open: "." ..monoid) (implementation: .public functor (Functor List) - (def: (map f ma) + (def: (each f ma) (case ma #.End #.End (#.Item a ma') - (#.Item (f a) (map f ma'))))) + (#.Item (f a) (each f ma'))))) (open: "." ..functor) @@ -348,7 +348,7 @@ (#.Item f ff') (|> ff' (on fa) - (compose (map f fa)))))) + (composite (each f fa)))))) (implementation: .public monad (Monad List) @@ -358,8 +358,8 @@ (def: (in a) (#.Item a #.End)) - (def: join - (|>> reversed (mix compose identity)))) + (def: conjoint + (|>> reversed (mix composite identity)))) (def: .public (sorted < xs) (All [a] (-> (-> a a Bit) (List a) (List a))) @@ -374,7 +374,7 @@ [pre (#.Item x' post)])) [(list) (list)] xs')] - ($_ compose (sorted < pre) (list x) (sorted < post))))) + ($_ composite (sorted < pre) (list x) (sorted < post))))) (def: .public (empty? xs) (All [a] (Predicate (List a))) @@ -447,27 +447,27 @@ (if (n.> 0 num_lists) (let [(^open ".") ..functor indices (..indices num_lists) - type_vars (: (List Code) (map (|>> nat\encoded identifier$) indices)) + type_vars (: (List Code) (each (|>> nat\encoded identifier$) indices)) zipped_type (` (All [(~+ type_vars)] - (-> (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) - type_vars)) + (-> (~+ (each (: (-> Code Code) (function (_ var) (` (List (~ var))))) + type_vars)) (List [(~+ type_vars)])))) vars+lists (|> indices - (map ++) - (map (function (_ idx) - (let [base (nat\encoded idx)] - [(identifier$ base) - (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (map (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) - vars+lists))]) + (each ++) + (each (function (_ idx) + (let [base (nat\encoded idx)] + [(identifier$ base) + (identifier$ ("lux text concat" base "'"))])))) + pattern (` [(~+ (each (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) + vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") - list_vars (map product.right vars+lists) + list_vars (each product.right vars+lists) code (` (: (~ zipped_type) (function ((~ g!step) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - (#.Item [(~+ (map product.left vars+lists))] + (#.Item [(~+ (each product.left vars+lists))] ((~ g!step) (~+ list_vars))) (~ g!blank) @@ -489,28 +489,28 @@ indices (..indices num_lists) g!return_type (identifier$ "0return_type0") g!func (identifier$ "0func0") - type_vars (: (List Code) (map (|>> nat\encoded identifier$) indices)) + type_vars (: (List Code) (each (|>> nat\encoded identifier$) indices)) zipped_type (` (All [(~+ type_vars) (~ g!return_type)] (-> (-> (~+ type_vars) (~ g!return_type)) - (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) - type_vars)) + (~+ (each (: (-> Code Code) (function (_ var) (` (List (~ var))))) + type_vars)) (List (~ g!return_type))))) vars+lists (|> indices - (map ++) - (map (function (_ idx) - (let [base (nat\encoded idx)] - [(identifier$ base) - (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (map (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) - vars+lists))]) + (each ++) + (each (function (_ idx) + (let [base (nat\encoded idx)] + [(identifier$ base) + (identifier$ ("lux text concat" base "'"))])))) + pattern (` [(~+ (each (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) + vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") - list_vars (map product.right vars+lists) + list_vars (each product.right vars+lists) code (` (: (~ zipped_type) (function ((~ g!step) (~ g!func) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - (#.Item ((~ g!func) (~+ (map product.left vars+lists))) + (#.Item ((~ g!func) (~+ (each product.left vars+lists))) ((~ g!step) (~ g!func) (~+ list_vars))) (~ g!blank) @@ -556,7 +556,7 @@ (def: .public together (All [a] (-> (List (List a)) (List a))) - (\ ..monad join)) + (\ ..monad conjoint)) (implementation: .public (with monad) (All [M] (-> (Monad M) (Monad (All [a] (M (List a)))))) @@ -568,7 +568,7 @@ (def: in (|>> (\ ..monad in) (\ monad in))) - (def: (join MlMla) + (def: (conjoint MlMla) (do {! monad} [lMla MlMla ... TODO: Remove this version ASAP and use one below. @@ -580,7 +580,7 @@ (def: .public (lifted monad) (All [M a] (-> (Monad M) (-> (M a) (M (List a))))) - (\ monad map (\ ..monad in))) + (\ monad each (\ ..monad in))) (def: .public (enumeration xs) (All [a] (-> (List a) (List [Nat a]))) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index e8caf83f7..ca41352b6 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -12,8 +12,9 @@ ["n" nat]]]]]) (type: .public (Queue a) - {#front (List a) - #rear (List a)}) + (Record + {#front (List a) + #rear (List a)})) (def: .public empty Queue @@ -28,7 +29,7 @@ (def: .public (list queue) (All [a] (-> (Queue a) (List a))) (let [(^slots [#front #rear]) queue] - (list\compose front (list.reversed rear)))) + (list\composite front (list.reversed rear)))) (def: .public front (All [a] (-> (Queue a) (Maybe a))) @@ -88,6 +89,6 @@ (implementation: .public functor (Functor Queue) - (def: (map f fa) - {#front (|> fa (value@ #front) (list\map f)) - #rear (|> fa (value@ #rear) (list\map f))})) + (def: (each f fa) + {#front (|> fa (value@ #front) (list\each f)) + #rear (|> fa (value@ #rear) (list\each f))})) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index d7a792cdc..6cba59b62 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -33,15 +33,21 @@ ["." i64]]]]]) (type: (Node a) - (#Base (Array a)) - (#Hierarchy (Array (Node a)))) + (Variant + (#Base (Array a)) + (#Hierarchy (Array (Node a))))) -(type: (Base a) (Array a)) -(type: (Hierarchy a) (Array (Node a))) +(type: (Base a) + (Array a)) -(type: Level Nat) +(type: (Hierarchy a) + (Array (Node a))) -(type: Index Nat) +(type: Level + Nat) + +(type: Index + Nat) (def: branching_exponent Nat @@ -179,14 +185,15 @@ (|> hierarchy array.list list.reversed - (list\mix (function (_ sub acc) (list\compose (list' sub) acc)) + (list\mix (function (_ sub acc) (list\composite (list' sub) acc)) #.End)))) (type: .public (Row a) - {#level Level - #size Nat - #root (Hierarchy a) - #tail (Base a)}) + (Record + {#level Level + #size Nat + #root (Hierarchy a) + #tail (Base a)})) (def: .public empty Row @@ -341,8 +348,8 @@ (def: .public (list row) (All [a] (-> (Row a) (List a))) - (list\compose (list' (#Hierarchy (value@ #root row))) - (list' (#Base (value@ #tail row))))) + (list\composite (list' (#Hierarchy (value@ #root row))) + (list' (#Base (value@ #tail row))))) (def: .public of_list (All [a] (-> (List a) (Row a))) @@ -413,28 +420,28 @@ (def: identity ..empty) - (def: (compose xs ys) + (def: (composite xs ys) (list\mix suffix xs (..list ys)))) (implementation: node_functor (Functor Node) - (def: (map f xs) + (def: (each f xs) (case xs (#Base base) - (#Base (array\map f base)) + (#Base (array\each f base)) (#Hierarchy hierarchy) - (#Hierarchy (array\map (map f) hierarchy))))) + (#Hierarchy (array\each (each f) hierarchy))))) (implementation: .public functor (Functor Row) - (def: (map f xs) + (def: (each f xs) {#level (value@ #level xs) #size (value@ #size xs) - #root (|> xs (value@ #root) (array\map (\ node_functor map f))) - #tail (|> xs (value@ #tail) (array\map f))})) + #root (|> xs (value@ #root) (array\each (\ node_functor each f))) + #tail (|> xs (value@ #tail) (array\each f))})) (implementation: .public apply (Apply Row) @@ -445,21 +452,22 @@ (let [(^open ".") ..functor (^open ".") ..mix (^open ".") ..monoid - results (map (function (_ f) (map f fa)) - ff)] - (mix compose identity results)))) + results (each (function (_ f) (each f fa)) + ff)] + (mix composite identity results)))) (implementation: .public monad (Monad Row) (def: &functor ..functor) - (def: in (|>> row)) + (def: in + (|>> row)) - (def: join + (def: conjoint (let [(^open ".") ..mix (^open ".") ..monoid] - (mix (function (_ post pre) (compose pre post)) identity)))) + (mix (function (_ post pre) (composite pre post)) identity)))) (def: .public reversed (All [a] (-> (Row a) (Row a))) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 2bed3b721..8efb47cce 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -112,9 +112,9 @@ (implementation: .public functor (Functor Sequence) - (def: (map f fa) + (def: (each f fa) (let [[head tail] (//.result fa)] - (//.pending [(f head) (map f tail)])))) + (//.pending [(f head) (each f tail)])))) (implementation: .public comonad (CoMonad Sequence) @@ -123,17 +123,18 @@ (def: out head) - (def: (split wa) + (def: (disjoint wa) (let [[head tail] (//.result wa)] - (//.pending [wa (split tail)])))) + (//.pending [wa (disjoint tail)])))) (syntax: .public (^sequence& [patterns (<code>.form (<>.many <code>.any)) body <code>.any branches (<>.some <code>.any)]) (with_identifiers [g!sequence] - (let [body+ (` (let [(~+ (list\join (list\map (function (_ pattern) - (list (` [(~ pattern) (~ g!sequence)]) - (` ((~! //.result) (~ g!sequence))))) - patterns)))] + (let [body+ (` (let [(~+ (|> patterns + (list\each (function (_ pattern) + (list (` [(~ pattern) (~ g!sequence)]) + (` ((~! //.result) (~ g!sequence)))))) + list\conjoint))] (~ body)))] (in (list& g!sequence body+ branches))))) diff --git a/stdlib/source/library/lux/data/collection/set.lux b/stdlib/source/library/lux/data/collection/set.lux index 00edc5a47..d9c18877b 100644 --- a/stdlib/source/library/lux/data/collection/set.lux +++ b/stdlib/source/library/lux/data/collection/set.lux @@ -82,7 +82,7 @@ (All [a] (-> (Hash a) (Monoid (Set a)))) (def: identity (..empty hash)) - (def: compose ..union)) + (def: composite ..union)) (def: .public empty? (All [a] (-> (Set a) Bit)) diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index f176dc46a..73964bc7a 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -19,7 +19,7 @@ ["." dictionary (#+ Dictionary)]]]) (abstract: .public (Set a) - {#.doc (example "A set that keeps track of repetition in its entries.")} + {} (Dictionary a Nat) @@ -63,13 +63,13 @@ (|>> :representation dictionary.entries (list\mix (function (_ [elem multiplicity] output) - (list\compose (list.repeated multiplicity elem) output)) + (list\composite (list.repeated multiplicity elem) output)) #.End))) - (template [<name> <compose>] + (template [<name> <composite>] [(def: .public (<name> parameter subject) (All [a] (-> (Set a) (Set a) (Set a))) - (:abstraction (dictionary.merged_with <compose> (:representation parameter) (:representation subject))))] + (:abstraction (dictionary.merged_with <composite> (:representation parameter) (:representation subject))))] [union n.max] [sum n.+] @@ -95,7 +95,6 @@ subject))) (def: .public (sub? reference subject) - {#.doc (example "Is 'subject' a sub-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (|> subject :representation @@ -106,7 +105,6 @@ (n.>= multiplicity)))))) (def: .public (support set) - {#.doc (example "A set of the unique (non repeated) members.")} (All [a] (-> (Set a) (//.Set a))) (let [(^@ set [hash _]) (:representation set)] (|> set @@ -157,6 +155,5 @@ (//.list subject))) (def: .public super? - {#.doc (example "Is 'subject' a super-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (function.flipped sub?)) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index d6d532d02..eeb66fa5e 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -13,7 +13,7 @@ abstract]]]) (abstract: .public (Set a) - {#.doc (example "A set with ordered entries.")} + {} (/.Dictionary a a) @@ -77,13 +77,11 @@ ) (def: .public (sub? super sub) - {#.doc (example "Is 'sub' a sub-set of 'super'?")} (All [a] (-> (Set a) (Set a) Bit)) (|> sub ..list (list.every? (..member? super)))) (def: .public (super? sub super) - {#.doc (example "Is 'super' a super-set of 'sub'?")} (All [a] (-> (Set a) (Set a) Bit)) (sub? super sub)) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index 2b9cbc2e4..549450cbd 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -11,7 +11,7 @@ abstract]]]) (abstract: .public (Stack a) - {#.doc (example "A first-in, last-out sequential data-structure.")} + {} (List a) @@ -28,7 +28,6 @@ (|>> :representation //.empty?)) (def: .public (value stack) - {#.doc (example "Yields the top value in the stack, if any.")} (All [a] (-> (Stack a) (Maybe a))) (case (:representation stack) #.End @@ -61,9 +60,9 @@ (implementation: .public functor (Functor Stack) - (def: (map f value) + (def: (each f value) (|> value :representation - (\ //.functor map f) + (\ //.functor each f) :abstraction))) ) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index bdf10e85b..d3222b959 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -17,17 +17,16 @@ ["." code]]]]) (type: .public (Tree a) - {#.doc (example "A generic tree data-structure.")} - {#value a - #children (List (Tree a))}) + (Record + {#value a + #children (List (Tree a))})) (def: .public (flat tree) - {#.doc (example "All the leaf values of the tree, in order.")} (All [a] (-> (Tree a) (List a))) (|> tree (value@ #children) - (list\map flat) - list\join + (list\each flat) + list\conjoint (#.Item (value@ #value tree)))) (def: .public (leaf value) @@ -55,15 +54,9 @@ (<>.and <code>.any))) (syntax: .public (tree [root tree^]) - {#.doc (example "Tree literals." - (: (Tree Nat) - (tree 12 - {34 {} - 56 {} - 78 {90 {}}})))} (in (list (` (~ (loop [[value children] root] (` {#value (~ value) - #children (list (~+ (list\map recur children)))}))))))) + #children (list (~+ (list\each recur children)))}))))))) (implementation: .public (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (Tree a)))) @@ -75,10 +68,10 @@ (implementation: .public functor (Functor Tree) - (def: (map f fa) + (def: (each f fa) {#value (f (value@ #value fa)) - #children (list\map (map f) - (value@ #children fa))})) + #children (list\each (each f) + (value@ #children fa))})) (implementation: .public mix (Mix Tree) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 588cb4e5a..b0dcece05 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -12,15 +12,15 @@ ... https://en.wikipedia.org/wiki/Finger_tree (abstract: .public (Tree @ t v) - {#.doc (example "A finger tree.")} + {} - {#monoid (Monoid t) - #tag t - #root (Or v - [(Tree @ t v) (Tree @ t v)])} + (Record + {#monoid (Monoid t) + #tag t + #root (Or v + [(Tree @ t v) (Tree @ t v)])}) (interface: .public (Builder @ t) - {#.doc (example "A builder for finter tree structures.")} (: (All [v] (-> t v (Tree @ t v))) leaf) @@ -40,7 +40,6 @@ ) (implementation: .public (builder monoid) - {#.doc (example "A new builder using the given monoid.")} (All [t] (Ex [@] (-> (Monoid t) (Builder @ t)))) (def: (leaf tag value) @@ -52,7 +51,7 @@ (def: (branch left right) (:abstraction {#monoid monoid - #tag (\ monoid compose (..tag left) (..tag right)) + #tag (\ monoid composite (..tag left) (..tag right)) #root (0 #1 [left right])}))) (def: .public (value tree) @@ -71,8 +70,8 @@ (list (value@ #tag (:representation tree))) (0 #1 [left right]) - (list\compose (tags left) - (tags right)))) + (list\composite (tags left) + (tags right)))) (def: .public (values tree) (All [@ t v] (-> (Tree @ t v) (List v))) @@ -81,11 +80,10 @@ (list value) (0 #1 [left right]) - (list\compose (values left) - (values right)))) + (list\composite (values left) + (values right)))) (def: .public (one predicate tree) - {#.doc (example "Finds one value that meets the predicate.")} (All [@ t v] (-> (Predicate t) (Tree @ t v) (Maybe v))) (let [[monoid tag root] (:representation tree)] (if (predicate tag) @@ -97,7 +95,7 @@ (#.Some value) (0 #1 [left right]) - (let [shifted_tag (tag//compose _tag (..tag left))] + (let [shifted_tag (tag//composite _tag (..tag left))] (if (predicate shifted_tag) (recur _tag (value@ #root (:representation left))) (recur shifted_tag (value@ #root (:representation right)))))))) @@ -105,7 +103,6 @@ ) (def: .public (exists? predicate tree) - {#.doc (example "Verifies that a value exists which meets the predicate.")} (All [@ t v] (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) (#.Some _) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index 1c99353bc..cec25e125 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -18,15 +18,16 @@ ["." // (#+ Tree) ("#\." functor)]) (type: (Family Zipper a) - {#parent (Zipper a) - #lefts (List (Tree a)) - #rights (List (Tree a))}) + (Record + {#parent (Zipper a) + #lefts (List (Tree a)) + #rights (List (Tree a))})) ... https://en.wikipedia.org/wiki/Zipper_(data_structure) (type: .public (Zipper a) - {#.doc "Tree zippers, for easy navigation and editing of trees."} - {#family (Maybe (Family Zipper a)) - #node (Tree a)}) + (Record + {#family (Maybe (Family Zipper a)) + #node (Tree a)})) (implementation: .public (equivalence super) (All [a] @@ -105,14 +106,14 @@ (for {@.old (revised@ #node (: (-> (Tree (:parameter 0)) (Tree (:parameter 0))) - (with@ #//.children (list\compose (list.reversed lefts) - (#.Item (value@ #node zipper) - rights)))) + (with@ #//.children (list\composite (list.reversed lefts) + (#.Item (value@ #node zipper) + rights)))) parent)} (with@ [#node #//.children] - (list\compose (list.reversed lefts) - (#.Item (value@ #node zipper) - rights)) + (list\composite (list.reversed lefts) + (#.Item (value@ #node zipper) + rights)) parent)))))) (template [<one> <all> <side> <op_side>] @@ -155,13 +156,13 @@ (#.Some (for {@.old {#family (#.Some (|> family (with@ <side> #.End) (revised@ <op_side> (|>> (#.Item (value@ #node zipper)) - (list\compose prevs))))) + (list\composite prevs))))) #node last}} (let [move (: (All [a] (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) (|>> (with@ <side> #.End) (revised@ <op_side> (|>> (#.Item (value@ #node zipper)) - (list\compose prevs))))))] + (list\composite prevs))))))] {#family (#.Some (move prevs zipper family)) #node last}))))))] @@ -291,13 +292,13 @@ (implementation: .public functor (Functor Zipper) - (def: (map f (^slots [#family #node])) - {#family (maybe\map (function (_ (^slots [#parent #lefts #rights])) - {#parent (map f parent) - #lefts (list\map (//\map f) lefts) - #rights (list\map (//\map f) rights)}) - family) - #node (//\map f node)})) + (def: (each f (^slots [#family #node])) + {#family (maybe\each (function (_ (^slots [#parent #lefts #rights])) + {#parent (each f parent) + #lefts (list\each (//\each f) lefts) + #rights (list\each (//\each f) rights)}) + family) + #node (//\each f node)})) (implementation: .public comonad (CoMonad Zipper) @@ -306,16 +307,16 @@ (def: out (value@ [#node #//.value])) - (def: (split (^slots [#family #node])) + (def: (disjoint (^slots [#family #node])) (let [tree_splitter (: (All [a] (-> (Tree a) (Tree (Zipper a)))) (function (tree_splitter tree) {#//.value (..zipper tree) #//.children (|> tree (value@ #//.children) - (list\map tree_splitter))}))] - {#family (maybe\map (function (_ (^slots [#parent #lefts #rights])) - {#parent (split parent) - #lefts (list\map tree_splitter lefts) - #rights (list\map tree_splitter rights)}) - family) + (list\each tree_splitter))}))] + {#family (maybe\each (function (_ (^slots [#parent #lefts #rights])) + {#parent (disjoint parent) + #lefts (list\each tree_splitter lefts) + #rights (list\each tree_splitter rights)}) + family) #node (tree_splitter node)}))) diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index fb67c971f..3cf8fa6d5 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -36,18 +36,20 @@ (|>> (f.* rgb_factor) f.int .nat)) (type: .public RGB - {#red Nat - #green Nat - #blue Nat}) + (Record + {#red Nat + #green Nat + #blue Nat})) (type: .public HSL [Frac Frac Frac]) (type: .public CMYK - {#cyan Frac - #magenta Frac - #yellow Frac - #key Frac}) + (Record + {#cyan Frac + #magenta Frac + #yellow Frac + #key Frac})) (type: .public HSB [Frac Frac Frac]) @@ -106,7 +108,7 @@ (def: identity ..black) - (def: (compose left right) + (def: (composite left right) (let [[lR lG lB] (:representation left) [rR rG rB] (:representation right)] (:abstraction {#red (n.max lR rR) @@ -129,7 +131,7 @@ (def: identity ..white) - (def: (compose left right) + (def: (composite left right) (let [[lR lG lB] (:representation (..complement left)) [rR rG rB] (:representation right)] (:abstraction {#red (n.min lR rR) @@ -395,23 +397,23 @@ Palette (let [[hue saturation brightness] (hsb color) spread (..normal spread)] - (list\map (function (_ idx) - (of_hsb [(|> idx ++ .int int.frac (f.* spread) (f.+ hue) ..normal) - saturation - brightness])) - (list.indices variations))))) + (list\each (function (_ idx) + (of_hsb [(|> idx ++ .int int.frac (f.* spread) (f.+ hue) ..normal) + saturation + brightness])) + (list.indices variations))))) (`` (def: .public (monochromatic spread variations color) Palette (let [[hue saturation brightness] (hsb color) spread (..normal spread)] (|> (list.indices variations) - (list\map (|>> ++ .int int.frac - (f.* spread) - (f.+ brightness) - ..normal - [hue saturation] - of_hsb)))))) + (list\each (|>> ++ .int int.frac + (f.* spread) + (f.+ brightness) + ..normal + [hue saturation] + of_hsb)))))) (type: .public Alpha Rev) @@ -429,5 +431,6 @@ rev\top) (type: .public Pigment - {#color Color - #alpha Alpha}) + (Record + {#color Color + #alpha Alpha})) diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index 85eb0534d..1e0ca5937 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -52,7 +52,7 @@ (def: identity ..no_op) - (def: (compose [sizeL mutL] [sizeR mutR]) + (def: (composite [sizeL mutL] [sizeR mutR]) [(n.+ sizeL sizeR) (|>> mutL mutR)])) @@ -101,7 +101,7 @@ (def: .public (and pre post) (All [a b] (-> (Writer a) (Writer b) (Writer [a b]))) (function (_ [preV postV]) - (\ ..monoid compose (pre preV) (post postV)))) + (\ ..monoid composite (pre preV) (post postV)))) (def: .public (rec body) (All [a] (-> (-> (Writer a) (Writer a)) (Writer a))) @@ -187,10 +187,10 @@ (|> value row.list (list.first capped_count) row.of_list)) (^open "specification\.") ..monoid [size mutation] (|> value - (row\map valueW) + (row\each valueW) (\ row.mix mix (function (_ post pre) - (specification\compose pre post)) + (specification\composite pre post)) specification\identity))] [(n.+ <size> size) (function (_ [offset binary]) diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index 75e886e0d..57a7d33de 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -65,8 +65,8 @@ ["font-style" (|> font (value@ #/font.style) (maybe.else /value.normal_style) /value.value)] ["font-weight" (|> font (value@ #/font.weight) (maybe.else /value.normal_weight) /value.value)] with_unicode) - (list\map (function (_ [property value]) - (format property ": " value ";"))) + (list\each (function (_ [property value]) + (format property ": " value ";"))) (text.interposed /style.separator) (text.enclosed ["{" "}"]) (format "@font-face") @@ -87,41 +87,42 @@ text.new_line) (type: .public Frame - {#when Percentage - #what Style}) + (Record + {#when Percentage + #what Style})) (def: .public (key_frames animation frames) (-> (Value Animation) (List Frame) (CSS Special)) (:abstraction (format "@keyframes " (/value.value animation) " {" (|> frames - (list\map (function (_ frame) - (format (/value.percentage (value@ #when frame)) " {" - (/style.inline (value@ #what frame)) - "}"))) + (list\each (function (_ frame) + (format (/value.percentage (value@ #when frame)) " {" + (/style.inline (value@ #what frame)) + "}"))) (text.interposed ..css_separator)) "}"))) - (template: (!compose <pre> <post>) + (template: (!composite <pre> <post>) (:abstraction (format (:representation <pre>) ..css_separator (:representation <post>)))) (def: .public (and pre post) (-> (CSS Any) (CSS Any) (CSS Any)) - (!compose pre post)) + (!composite pre post)) (def: .public (alter combinator selector css) (-> Combinator (Selector Any) (CSS Common) (CSS Common)) (|> css :representation (text.all_split_by ..css_separator) - (list\map (|>> (format (/selector.selector (|> selector (combinator (/selector.tag ""))))))) + (list\each (|>> (format (/selector.selector (|> selector (combinator (/selector.tag ""))))))) (text.interposed ..css_separator) :abstraction)) (def: .public (dependent combinator selector style inner) (-> Combinator (Selector Any) Style (CSS Common) (CSS Common)) - (!compose (..rule selector style) - (..alter combinator selector inner))) + (!composite (..rule selector style) + (..alter combinator selector inner))) (template [<name> <combinator>] [(def: .public <name> diff --git a/stdlib/source/library/lux/data/format/css/font.lux b/stdlib/source/library/lux/data/format/css/font.lux index 9149bf899..2ebe6644d 100644 --- a/stdlib/source/library/lux/data/format/css/font.lux +++ b/stdlib/source/library/lux/data/format/css/font.lux @@ -14,13 +14,15 @@ ["#." value (#+ Value Font_Stretch Font_Style Font_Weight)]]) (type: .public Unicode_Range - {#start Nat - #end Nat}) + (Record + {#start Nat + #end Nat})) (type: .public Font - {#family Text - #source URL - #stretch (Maybe (Value Font_Stretch)) - #style (Maybe (Value Font_Style)) - #weight (Maybe (Value Font_Weight)) - #unicode_range (Maybe Unicode_Range)}) + (Record + {#family Text + #source URL + #stretch (Maybe (Value Font_Stretch)) + #style (Maybe (Value Font_Style)) + #weight (Maybe (Value Font_Weight)) + #unicode_range (Maybe Unicode_Range)})) diff --git a/stdlib/source/library/lux/data/format/css/selector.lux b/stdlib/source/library/lux/data/format/css/selector.lux index 1bee5183d..a1f801779 100644 --- a/stdlib/source/library/lux/data/format/css/selector.lux +++ b/stdlib/source/library/lux/data/format/css/selector.lux @@ -181,8 +181,9 @@ ) (type: .public Formula - {#constant Int - #variable Int}) + (Record + {#constant Int + #variable Int})) (def: .public (formula input) (-> Formula Index) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index 54de6d97a..20b15f0eb 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -804,7 +804,7 @@ (def: .public (cubic_bezier p0 p1 p2 p3) (-> Frac Frac Frac Frac (Value Timing)) (|> (list p0 p1 p2 p3) - (list\map %number) + (list\each %number) (..apply "cubic-bezier"))) (template [<name> <brand>] @@ -972,7 +972,7 @@ (let [[now after] next] (..apply <function> (list& (:representation Angle angle) (with_hint now) - (list\map with_hint after)))))] + (list\each with_hint after)))))] [linear_gradient "linear-gradient"] [repeating_linear_gradient "repeating-linear-gradient"] @@ -1099,7 +1099,7 @@ [now after] next] (..apply <function> (list& (..shape shape) (with_hint now) - (list\map with_hint after)))))] + (list\each with_hint after)))))] [radial_gradient "radial-gradient"] [repeating_radial_gradient "repeating-radial-gradient"] @@ -1123,10 +1123,11 @@ :abstraction))) (type: .public Rectangle - {#top (Value Length) - #right (Value Length) - #bottom (Value Length) - #left (Value Length)}) + (Record + {#top (Value Length) + #right (Value Length) + #bottom (Value Length) + #left (Value Length)})) (def: .public (clip rectangle) (-> Rectangle (Value Clip)) @@ -1171,7 +1172,7 @@ (case options (#.Item _) (|> options - (list\map ..font_name) + (list\each ..font_name) (text.interposed ",") (:abstraction Value)) @@ -1210,10 +1211,10 @@ (-> (List (List (Maybe (Value Grid)))) (Value Grid_Template)) (let [empty (: (Value Grid) (:abstraction "."))] - (|>> (list\map (|>> (list\map (|>> (maybe.else empty) - :representation)) - (text.interposed ..grid_column_separator) - (text.enclosed ["'" "'"]))) + (|>> (list\each (|>> (list\each (|>> (maybe.else empty) + :representation)) + (text.interposed ..grid_column_separator) + (text.enclosed ["'" "'"]))) (text.interposed ..grid_row_separator) :abstraction))) @@ -1247,7 +1248,7 @@ (def: .public (quotes [left0 right0] [left1 right1]) (-> [Quote Quote] [Quote Quote] (Value Quotes)) (|> (list left0 right0 left1 right1) - (list\map (|>> ..quote_text %.text)) + (list\each (|>> ..quote_text %.text)) (text.interposed ..quote_separator) :abstraction)) @@ -1257,7 +1258,7 @@ [Frac Frac] (Value Transform)) (|> (list a b c d tx ty) - (list\map %number) + (list\each %number) (..apply "matrix"))) (def: .public (matrix_3d [a0 b0 c0 d0] [a1 b1 c1 d1] [a2 b2 c2 d2] [a3 b3 c3 d3]) @@ -1267,14 +1268,14 @@ [Frac Frac Frac Frac] (Value Transform)) (|> (list a0 b0 c0 d0 a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3) - (list\map %number) + (list\each %number) (..apply "matrix3d"))) (template [<name> <function> <input_types> <input_values>] [(`` (def: .public (<name> [(~~ (template.spliced <input_values>))]) (-> [(~~ (template.spliced <input_types>))] (Value Transform)) (|> (list (~~ (template.spliced <input_values>))) - (list\map %number) + (list\each %number) (..apply <function>))))] [translate_2d "translate" [Frac Frac] [x y]] @@ -1296,7 +1297,7 @@ [(`` (def: .public (<name> [(~~ (template.spliced <input_values>))]) (-> [(~~ (template.spliced <input_types>))] (Value Transform)) (|> (list (~~ (template.spliced <input_values>))) - (list\map ..angle) + (list\each ..angle) (..apply <function>))))] [rotate_2d "rotate" [Angle] [angle]] diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 5bb422c0d..ffd4ab75a 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -32,14 +32,16 @@ {#.doc "Attributes for an HTML tag."} (List [Text Text])) -(type: .public Script js.Statement) +(type: .public Script + js.Statement) (type: .public Target - #Blank - #Parent - #Self - #Top - (#Frame Text)) + (Variant + #Blank + #Parent + #Self + #Top + (#Frame Text))) (def: (target value) (-> Target Text) @@ -62,8 +64,8 @@ (def: attributes (-> Attributes Text) - (|>> (list\map (function (_ [key val]) - (format key "=" text.double_quote (..safe val) text.double_quote))) + (|>> (list\each (function (_ [key val]) + (format key "=" text.double_quote (..safe val) text.double_quote))) (text.interposed " "))) (def: (open tag attributes) @@ -190,7 +192,7 @@ (def: .public (script attributes inline) (-> Attributes (Maybe Script) Meta) (|> inline - (maybe\map js.code) + (maybe\each js.code) (maybe.else "") (..raw "script" attributes))) @@ -223,8 +225,9 @@ (..raw "svg" attributes))) (type: .public Coord - {#horizontal Nat - #vertical Nat}) + (Record + {#horizontal Nat + #vertical Nat})) (def: metric_separator ",") (def: coord_separator ",") @@ -234,18 +237,21 @@ (format (%.nat horizontal) ..metric_separator (%.nat vertical))) (type: .public Rectangle - {#start Coord - #end Coord}) + (Record + {#start Coord + #end Coord})) (type: .public Circle - {#center Coord - #radius Nat}) + (Record + {#center Coord + #radius Nat})) (type: .public Polygon - {#first Coord - #second Coord - #third Coord - #extra (List Coord)}) + (Record + {#first Coord + #second Coord + #third Coord + #extra (List Coord)})) (def: (%rectangle [start end]) (Format Rectangle) @@ -258,13 +264,14 @@ (def: (%polygon [first second third extra]) (Format Polygon) (|> (list& first second third extra) - (list\map %coord) + (list\each %coord) (text.interposed ..coord_separator))) (type: .public Shape - (#Rectangle Rectangle) - (#Circle Circle) - (#Polygon Polygon)) + (Variant + (#Rectangle Rectangle) + (#Circle Circle) + (#Polygon Polygon))) (template [<name> <shape> <type> <format>] [(def: (<name> attributes shape) @@ -290,11 +297,11 @@ (#Polygon polygon) (..polygon attributes polygon))) - (def: .public (map attributes areas for) + (def: .public (each attributes areas for) (-> Attributes (List [Attributes Shape]) Image Image) ($_ ..and for - (case (list\map (product.uncurried ..area) areas) + (case (list\each (product.uncurried ..area) areas) #.End (..empty "map" attributes) @@ -367,7 +374,8 @@ [iframe "iframe" Element] ) - (type: .public Phrase (-> Attributes Content Element)) + (type: .public Phrase + (-> Attributes Content Element)) (template [<name> <tag>] [(def: .public <name> @@ -455,11 +463,11 @@ (def: .public (description_list attributes descriptions) (-> Attributes (List [Content Element]) Element) - (case (list\map (function (_ [term description]) - ($_ ..and - (..term term) - (..description description))) - descriptions) + (case (list\each (function (_ [term description]) + ($_ ..and + (..term term) + (..description description))) + descriptions) #.End (..empty "dl" attributes) @@ -517,7 +525,7 @@ (def: .public (table attributes caption columns headers rows footer) (-> Attributes (Maybe Content) (Maybe Column) Header (List Cell) (Maybe Cell) Element) (let [head (..table_head (..table_row headers)) - content (case (list\map table_row rows) + content (case (list\each table_row rows) #.End head diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index bcfd44f80..6582b7402 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -41,12 +41,13 @@ ) (type: .public #rec JSON - (#Null Null) - (#Boolean Boolean) - (#Number Number) - (#String String) - (#Array (Row JSON)) - (#Object (Dictionary String JSON))) + (Variant + (#Null Null) + (#Boolean Boolean) + (#Number Number) + (#String String) + (#Array (Row JSON)) + (#Object (Dictionary String JSON)))) (template [<name> <type>] [(type: .public <name> @@ -80,19 +81,19 @@ (in (list (` (: JSON #..Null)))) [_ (#.Tuple members)] - (in (list (` (: JSON (#..Array ((~! row) (~+ (list\map wrapper members)))))))) + (in (list (` (: JSON (#..Array ((~! row) (~+ (list\each wrapper members)))))))) [_ (#.Record pairs)] (do {! ..monad} - [pairs' (monad.map ! - (function (_ [slot value]) - (case slot - [_ (#.Text key_name)] - (in (` [(~ (code.text key_name)) (~ (wrapper value))])) - - _ - (meta.failure "Wrong syntax for JSON object."))) - pairs)] + [pairs' (monad.each ! + (function (_ [slot value]) + (case slot + [_ (#.Text key_name)] + (in (` [(~ (code.text key_name)) (~ (wrapper value))])) + + _ + (meta.failure "Wrong syntax for JSON object."))) + pairs)] (in (list (` (: JSON (#..Object ((~! dictionary.of_list) (~! text.hash) (list (~+ pairs'))))))))) @@ -107,7 +108,7 @@ (#try.Success (dictionary.keys obj)) _ - (#try.Failure ($_ text\compose "Cannot get the fields of a non-object.")))) + (#try.Failure ($_ text\composite "Cannot get the fields of a non-object.")))) (def: .public (field key json) (-> String JSON (Try JSON)) @@ -118,10 +119,10 @@ (#try.Success value) #.None - (#try.Failure ($_ text\compose "Missing field '" key "' on object."))) + (#try.Failure ($_ text\composite "Missing field '" key "' on object."))) _ - (#try.Failure ($_ text\compose "Cannot get field '" key "' on a non-object.")))) + (#try.Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")))) (def: .public (has key value json) (-> String JSON JSON (Try JSON)) @@ -130,7 +131,7 @@ (#try.Success (#Object (dictionary.has key value obj))) _ - (#try.Failure ($_ text\compose "Cannot set field '" key "' on a non-object.")))) + (#try.Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")))) (template [<name> <tag> <type>] [(def: .public (<name> key json) @@ -140,7 +141,7 @@ (#try.Success value) (#try.Success _) - (#try.Failure ($_ text\compose "Wrong value type at key: " key)) + (#try.Failure ($_ text\composite "Wrong value type at key: " key)) (#try.Failure error) (#try.Failure error)))] @@ -216,7 +217,7 @@ (|> raw (text.split_at 1) maybe.trusted product.right)))))) (def: escape "\") -(def: escaped_dq (text\compose ..escape text.double_quote)) +(def: escaped_dq (text\composite ..escape text.double_quote)) (def: string_format (-> String Text) @@ -240,14 +241,14 @@ (def: (array_format format) (-> (-> JSON Text) (-> Array Text)) - (|>> (row\map format) + (|>> (row\each format) row.list (text.interposed ..value_separator) (text.enclosed [..array_start ..array_end]))) (def: (kv_format format [key value]) (-> (-> JSON Text) (-> [String JSON] Text)) - ($_ text\compose + ($_ text\composite (..string_format key) ..entry_separator (format value) @@ -256,7 +257,7 @@ (def: (object_format format) (-> (-> JSON Text) (-> Object Text)) (|>> dictionary.entries - (list\map (..kv_format format)) + (list\each (..kv_format format)) (text.interposed ..value_separator) (text.enclosed [..object_start ..object_end]))) @@ -326,8 +327,8 @@ [mark (<text>.one_of "eE") signed?' (<>.parses? (<text>.this "-")) offset (<text>.many <text>.decimal)] - (in ($_ text\compose mark (if signed?' "-" "") offset))))] - (case (f\decoded ($_ text\compose (if signed? "-" "") digits "." decimals exp)) + (in ($_ text\composite mark (if signed?' "-" "") offset))))] + (case (f\decoded ($_ text\composite (if signed? "-" "") digits "." decimals exp)) (#try.Failure message) (<>.failure message) @@ -347,7 +348,7 @@ (<>\in text.carriage_return)) (<>.after (<text>.this "\f") (<>\in text.form_feed)) - (<>.after (<text>.this (text\compose "\" text.double_quote)) + (<>.after (<text>.this (text\composite "\" text.double_quote)) (<>\in text.double_quote)) (<>.after (<text>.this "\\") (<>\in "\")))) @@ -357,13 +358,13 @@ (<| (<text>.enclosed [text.double_quote text.double_quote]) (loop [_ []]) (do {! <>.monad} - [chars (<text>.some (<text>.none_of (text\compose "\" text.double_quote))) + [chars (<text>.some (<text>.none_of (text\composite "\" text.double_quote))) stop <text>.next]) (if (text\= "\" stop) (do ! [escaped escaped_parser next_chars (recur [])] - (in ($_ text\compose chars escaped next_chars))) + (in ($_ text\composite chars escaped next_chars))) (in chars)))) (def: (kv_parser json_parser) diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index 11254a92c..fdbfd4b69 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -89,10 +89,10 @@ (def: (prefix with) (-> Text (-> Text Text)) (|>> (text.all_split_by text.new_line) - (list\map (function (_ line) - (if (text.empty? line) - line - (format with line)))) + (list\each (function (_ line) + (if (text.empty? line) + line + (format with line)))) (text.interposed text.new_line))) (def: indent @@ -109,36 +109,36 @@ (-> (List [(Markdown Span) (Maybe (Markdown Block))]) (Markdown Block)) (|>> list.enumeration - (list\map (function (_ [idx [summary detail]]) - (format "1. " (:representation summary) - (case detail - (#.Some detail) - (|> detail - :representation - ..indent - (text.enclosed [text.new_line text.new_line]) - (format text.new_line)) - - #.None - "")))) + (list\each (function (_ [idx [summary detail]]) + (format "1. " (:representation summary) + (case detail + (#.Some detail) + (|> detail + :representation + ..indent + (text.enclosed [text.new_line text.new_line]) + (format text.new_line)) + + #.None + "")))) (text.interposed text.new_line) ..block)) (def: .public bullet_list (-> (List [(Markdown Span) (Maybe (Markdown Block))]) (Markdown Block)) - (|>> (list\map (function (_ [summary detail]) - (format "* " (:representation summary) - (case detail - (#.Some detail) - (|> detail - :representation - ..indent - (text.enclosed [text.new_line text.new_line]) - (format text.new_line)) - - #.None - "")))) + (|>> (list\each (function (_ [summary detail]) + (format "* " (:representation summary) + (case detail + (#.Some detail) + (|> detail + :representation + ..indent + (text.enclosed [text.new_line text.new_line]) + (format text.new_line)) + + #.None + "")))) (text.interposed text.new_line) ..block)) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index f452a2693..745acf38d 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -332,7 +332,7 @@ _ (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end))] (<>.lifted - (\ try.monad map (|>> :abstraction) + (\ try.monad each (|>> :abstraction) (\ utf8.codec decoded string))))) ) @@ -518,7 +518,7 @@ (def: mode_parser (Parser Mode) (do {! <>.monad} - [value (\ ! map ..from_small ..small_parser)] + [value (\ ! each ..from_small ..small_parser)] (if (n.<= (:representation ..maximum_mode) value) (in (:abstraction value)) @@ -560,12 +560,14 @@ (..as_small 0)) (type: .public Owner - {#name Name - #id ID}) + (Record + {#name Name + #id ID})) (type: .public Ownership - {#user Owner - #group Owner}) + (Record + {#user Owner + #group Owner})) (type: .public File [Path Instant Mode Ownership Content]) @@ -576,10 +578,11 @@ (type: .public Contiguous File) (type: .public Entry - (#Normal ..Normal) - (#Symbolic_Link ..Symbolic_Link) - (#Directory ..Directory) - (#Contiguous ..Contiguous)) + (Variant + (#Normal ..Normal) + (#Symbolic_Link ..Symbolic_Link) + (#Directory ..Directory) + (#Contiguous ..Contiguous))) (type: Device Small) @@ -605,20 +608,21 @@ (n.* ..block_size))) (type: Header - {#path Path - #mode Mode - #user_id ID - #group_id ID - #size Big - #modification_time Big - #checksum Checksum - #link_flag Link_Flag - #link_name Path - #magic Magic - #user_name Name - #group_name Name - #major_device Device - #minor_device Device}) + (Record + {#path Path + #mode Mode + #user_id ID + #group_id ID + #size Big + #modification_time Big + #checksum Checksum + #link_flag Link_Flag + #link_name Path + #magic Magic + #user_name Name + #group_name Name + #major_device Device + #minor_device Device})) (def: header_writer' (Writer Header) @@ -739,11 +743,11 @@ (Writer Tar) (let [end_of_archive (binary.empty ..end_of_archive_size)] (function (_ tar) - (format\compose (row\mix (function (_ next total) - (format\compose total (..entry_writer next))) - format\identity - tar) - (format.segment ..end_of_archive_size end_of_archive))))) + (format\composite (row\mix (function (_ next total) + (format\composite total (..entry_writer next))) + format\identity + tar) + (format.segment ..end_of_archive_size end_of_archive))))) (exception: .public (wrong_checksum {expected Nat} {actual Nat}) (exception.report @@ -851,14 +855,14 @@ (def: entry_parser (Parser Entry) ($_ <>.either - (\ <>.monad map (|>> #..Normal) + (\ <>.monad each (|>> #..Normal) (<>.either (..file_parser ..normal) (..file_parser ..old_normal))) - (\ <>.monad map (|>> #..Symbolic_Link) + (\ <>.monad each (|>> #..Symbolic_Link) (..file_name_parser ..symbolic_link (value@ #link_name))) - (\ <>.monad map (|>> #..Directory) + (\ <>.monad each (|>> #..Directory) (..file_name_parser ..directory (value@ #path))) - (\ <>.monad map (|>> #..Contiguous) + (\ <>.monad each (|>> #..Contiguous) (..file_parser ..contiguous)))) ... It's safe to implement the parser this way because the range of values for Nat is 2^64 @@ -886,5 +890,5 @@ (def: .public parser (Parser Tar) (|> (<>.some entry_parser) - (\ <>.monad map row.of_list) + (\ <>.monad each row.of_list) (<>.before ..end_of_archive_parser))) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 064476a7f..ef2c8e19a 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -35,8 +35,9 @@ (dictionary.empty name.hash)) (type: .public #rec XML - (#Text Text) - (#Node Tag Attrs (List XML))) + (Variant + (#Text Text) + (#Node Tag Attrs (List XML)))) (def: namespace_separator ":") @@ -72,7 +73,7 @@ (def: xml_char^ (Parser Text) - (<>.either (<text>.none_of ($_ text\compose "<>&" text.double_quote)) + (<>.either (<text>.none_of ($_ text\composite "<>&" text.double_quote)) xml_escape_char^)) (def: xml_identifier @@ -82,7 +83,7 @@ <text>.alpha) tail (<text>.some (<>.either (<text>.one_of "_.-") <text>.alpha_num))] - (in ($_ text\compose head tail)))) + (in ($_ text\composite head tail)))) (def: namespaced_symbol^ (Parser Name) @@ -113,7 +114,7 @@ (def: attrs^ (Parser Attrs) - (<| (\ <>.monad map (dictionary.of_list name.hash)) + (<| (\ <>.monad each (dictionary.of_list name.hash)) <>.some (<>.and (..spaced^ attr_name^)) (<>.after (<text>.this "=")) @@ -126,7 +127,7 @@ ..spaced^ (<>.after (<text>.this "/")) (<text>.enclosed ["<" ">"]))] - (<>.assertion ($_ text\compose "Close tag does not match open tag." text.new_line + (<>.assertion ($_ text\composite "Close tag does not match open tag." text.new_line "Expected: " (name\encoded expected) text.new_line " Actual: " (name\encoded actual) text.new_line) (name\= expected actual)))) @@ -157,7 +158,7 @@ (Parser XML) (|> (..spaced^ (<text>.many xml_char^)) (<>.either cdata^) - (<>\map (|>> #Text)))) + (<>\each (|>> #Text)))) (def: null^ (Parser Any) @@ -209,7 +210,7 @@ (-> Tag Text) (case namespace "" name - _ ($_ text\compose namespace ..namespace_separator name))) + _ ($_ text\composite namespace ..namespace_separator name))) (def: .public attribute (-> Attribute Text) @@ -219,8 +220,8 @@ Text (let [quote (: (-> Text Text) (function (_ value) - ($_ text\compose text.double_quote value text.double_quote)))] - ($_ text\compose + ($_ text\composite text.double_quote value text.double_quote)))] + ($_ text\composite "<?xml" " version=" (quote "1.0") " encoding=" (quote "UTF-8") @@ -234,11 +235,11 @@ (function (_ attrs) (|> attrs dictionary.entries - (list\map (function (_ [key value]) - ($_ text\compose (..attribute key) "=" text.double_quote (sanitize_value value) text.double_quote))) + (list\each (function (_ [key value]) + ($_ text\composite (..attribute key) "=" text.double_quote (sanitize_value value) text.double_quote))) (text.interposed " "))))] (function (_ input) - ($_ text\compose + ($_ text\composite ..xml_header text.new_line (loop [prefix "" input input] @@ -250,8 +251,8 @@ (let [tag (..tag xml_tag) attrs (if (dictionary.empty? xml_attrs) "" - ($_ text\compose " " (attributes xml_attrs)))] - ($_ text\compose + ($_ text\composite " " (attributes xml_attrs)))] + ($_ text\composite prefix "<" tag attrs ">" (sanitize_value value) "</" tag ">")) @@ -260,12 +261,12 @@ (let [tag (..tag xml_tag) attrs (if (dictionary.empty? xml_attrs) "" - ($_ text\compose " " (attributes xml_attrs)))] + ($_ text\composite " " (attributes xml_attrs)))] (if (list.empty? xml_children) - ($_ text\compose prefix "<" tag attrs "/>") - ($_ text\compose prefix "<" tag attrs ">" + ($_ text\composite prefix "<" tag attrs "/>") + ($_ text\composite prefix "<" tag attrs ">" (|> xml_children - (list\map (|>> (recur (text\compose prefix text.tab)) (text\compose text.new_line))) + (list\each (|>> (recur (text\composite prefix text.tab)) (text\composite text.new_line))) text.together) text.new_line prefix "</" tag ">"))))) )))) diff --git a/stdlib/source/library/lux/data/identity.lux b/stdlib/source/library/lux/data/identity.lux index 300c0cd7b..ac82be699 100644 --- a/stdlib/source/library/lux/data/identity.lux +++ b/stdlib/source/library/lux/data/identity.lux @@ -15,7 +15,7 @@ (implementation: .public functor (Functor Identity) - (def: map function.identity)) + (def: each function.identity)) (implementation: .public apply (Apply Identity) @@ -29,11 +29,11 @@ (def: &functor ..functor) (def: in function.identity) - (def: join function.identity)) + (def: conjoint function.identity)) (implementation: .public comonad (CoMonad Identity) (def: &functor ..functor) (def: out function.identity) - (def: split function.identity)) + (def: disjoint function.identity)) diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux index 99d158095..bb0216ba5 100644 --- a/stdlib/source/library/lux/data/name.lux +++ b/stdlib/source/library/lux/data/name.lux @@ -48,7 +48,7 @@ (def: (encoded [module short]) (case module "" short - _ ($_ text\compose module ..separator short))) + _ ($_ text\composite module ..separator short))) (def: (decoded input) (case (text.all_split_by ..separator input) @@ -59,4 +59,4 @@ (#.Right [module short]) _ - (#.Left (text\compose "Invalid format for Name: " input))))) + (#.Left (text\composite "Invalid format for Name: " input))))) diff --git a/stdlib/source/library/lux/data/store.lux b/stdlib/source/library/lux/data/store.lux index a25331cd4..5fc594957 100644 --- a/stdlib/source/library/lux/data/store.lux +++ b/stdlib/source/library/lux/data/store.lux @@ -8,8 +8,9 @@ implicit]]]) (type: .public (Store s a) - {#cursor s - #peek (-> s a)}) + (Record + {#cursor s + #peek (-> s a)})) (def: (extend f wa) (All [s a b] (-> (-> (Store s a) b) (Store s a) (Store s b))) @@ -19,7 +20,7 @@ (implementation: .public functor (All [s] (Functor (Store s))) - (def: (map f fa) + (def: (each f fa) (extend (function (_ store) (f (\ store peek (\ store cursor)))) fa))) @@ -27,11 +28,14 @@ (implementation: .public comonad (All [s] (CoMonad (Store s))) - (def: &functor ..functor) + (def: &functor + ..functor) - (def: (out wa) (\\ peek (\\ cursor))) + (def: (out wa) + (\\ peek (\\ cursor))) - (def: split (extend id))) + (def: disjoint + (extend id))) (def: .public (peeks trans store) (All [s a] (-> (-> s s) (Store s a) a)) @@ -39,12 +43,12 @@ (def: .public (seek cursor store) (All [s a] (-> s (Store s a) (Store s a))) - (\ (\\ split store) peek cursor)) + (\ (\\ disjoint store) peek cursor)) (def: .public (seeks change store) (All [s a] (-> (-> s s) (Store s a) (Store s a))) - (|> store (\\ split) (peeks change))) + (|> store (\\ disjoint) (peeks change))) (def: .public (experiment Functor<f> change store) (All [f s a] (-> (Functor f) (-> s (f s)) (Store s a) (f a))) - (\ Functor<f> map (\\ peek) (change (\\ cursor)))) + (\ Functor<f> each (\\ peek) (change (\\ cursor)))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 5a1b8a981..daf951a7d 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -248,7 +248,7 @@ (def: identity "") - (def: (compose left right) + (def: (composite left right) ("lux text concat" left right))) (implementation: .public hash @@ -288,7 +288,7 @@ (-> (List Text) Text) (let [(^open ".") ..monoid] (|>> list.reversed - (list\mix compose identity)))) + (list\mix composite identity)))) (def: .public (interposed separator texts) (-> Text (List Text) Text) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index cd953ef05..11d1523e8 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -45,7 +45,7 @@ (implementation: .public functor (contravariant.Functor Format) - (def: (map f fb) + (def: (each f fb) (|>> f fb))) (syntax: .public (format [fragments (<>.many <code>.any)]) @@ -117,7 +117,7 @@ (def: .public (list formatter) (All [a] (-> (Format a) (Format (List a)))) - (|>> (list\map (|>> formatter (format " "))) + (|>> (list\each (|>> formatter (format " "))) text.together (text.enclosed ["(list" ")"]))) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index fa822c33b..77d4e94e1 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -52,9 +52,9 @@ (-> Text (Parser Text)) (<>.after (<text>.this reference) (<>\in reference))) -(def: join_text^ +(def: together^ (-> (Parser (List Text)) (Parser Text)) - (\ <>.monad map //.together)) + (\ <>.monad each //.together)) (def: name_char^ (Parser Text) @@ -85,9 +85,9 @@ (def: re_range^ (Parser Code) (do {! <>.monad} - [from (|> regex_char^ (\ ! map (|>> (//.char 0) maybe.trusted))) + [from (|> regex_char^ (\ ! each (|>> (//.char 0) maybe.trusted))) _ (<text>.this "-") - to (|> regex_char^ (\ ! map (|>> (//.char 0) maybe.trusted)))] + to (|> regex_char^ (\ ! each (|>> (//.char 0) maybe.trusted)))] (in (` ((~! <text>.range) (~ (code.nat from)) (~ (code.nat to))))))) (def: re_char^ @@ -221,11 +221,11 @@ (in (` ((~! <>.else) "" (~ base)))) "*" - (in (` ((~! join_text^) ((~! <>.some) (~ base))))) + (in (` ((~! together^) ((~! <>.some) (~ base))))) ... "+" _ - (in (` ((~! join_text^) ((~! <>.many) (~ base))))) + (in (` ((~! together^) ((~! <>.many) (~ base))))) ))) (exception: .public (incorrect_quantification {from Nat} {to Nat}) @@ -243,19 +243,19 @@ [[from to] (<>.and number^ (<>.after (<text>.this ",") number^)) _ (<>.assertion (exception.error ..incorrect_quantification [from to]) (n.<= to from))] - (in (` ((~! join_text^) ((~! <>.between) - (~ (code.nat from)) - (~ (code.nat (n.- from to))) - (~ base)))))) + (in (` ((~! together^) ((~! <>.between) + (~ (code.nat from)) + (~ (code.nat (n.- from to))) + (~ base)))))) (do ! [limit (<>.after (<text>.this ",") number^)] - (in (` ((~! join_text^) ((~! <>.at_most) (~ (code.nat limit)) (~ base)))))) + (in (` ((~! together^) ((~! <>.at_most) (~ (code.nat limit)) (~ base)))))) (do ! [limit (<>.before (<text>.this ",") number^)] - (in (` ((~! join_text^) ((~! <>.at_least) (~ (code.nat limit)) (~ base)))))) + (in (` ((~! together^) ((~! <>.at_least) (~ (code.nat limit)) (~ base)))))) (do ! [limit number^] - (in (` ((~! join_text^) ((~! <>.exactly) (~ (code.nat limit)) (~ base)))))))))) + (in (` ((~! together^) ((~! <>.exactly) (~ (code.nat limit)) (~ base)))))))))) (def: (re_quantified^ current_module) (-> Text (Parser Code)) @@ -269,8 +269,9 @@ (re_simple^ current_module))) (type: Re_Group - #Non_Capturing - (#Capturing [(Maybe Text) Nat])) + (Variant + #Non_Capturing + (#Capturing [(Maybe Text) Nat]))) (def: (re_sequential^ capturing? re_scoped^ current_module) (-> Bit @@ -291,7 +292,7 @@ [idx names (list& (list g!temp complex - (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' compose) (~ g!total) (~ g!temp))])) + (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' composite) (~ g!total) (~ g!temp))])) steps)] (#.Right [(#Capturing [?name num_captures]) scoped]) @@ -307,7 +308,7 @@ [idx! (list& name! names) (list& (list name! scoped - (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' compose) (~ g!total) (~ access))])) + (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' composite) (~ g!total) (~ access))])) steps)]) ))) [0 @@ -319,7 +320,7 @@ 0) (` ((~! do) (~! <>.monad) [.let [(~ g!total) ""] - (~+ (|> steps list.reversed list\join))] + (~+ (|> steps list.reversed list\conjoint))] ((~ (' in)) [(~ g!total) (~+ (list.reversed names))])))]) )) @@ -374,12 +375,12 @@ tail (<>.some (<>.after (<text>.this "|") sub^))] (if (list.empty? tail) (in head) - (in [(list\mix n.max (product.left head) (list\map product.left tail)) + (in [(list\mix n.max (product.left head) (list\each product.left tail)) (` ($_ ((~ (if capturing? (` (~! |||^)) (` (~! |||_^))))) (~ (prep_alternative head)) - (~+ (list\map prep_alternative tail))))])))) + (~+ (list\each prep_alternative tail))))])))) (def: (re_scoped^ current_module) (-> Text (Parser [Re_Group Code])) @@ -407,7 +408,7 @@ (def: (regex^ current_module) (-> Text (Parser Code)) - (\ <>.monad map product.right (re_alternative^ #1 re_scoped^ current_module))) + (\ <>.monad each product.right (re_alternative^ #1 re_scoped^ current_module))) (syntax: .public (regex [pattern <code>.text]) (do meta.monad @@ -419,8 +420,7 @@ error)) (#try.Success regex) - (in (list regex)) - ))) + (in (list regex))))) (syntax: .public (^regex [[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any))) body <code>.any diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 70087d56a..7c473d64d 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -26,7 +26,7 @@ (:abstraction (interval.between n.enum n\top n\bottom))) - (def: (compose left right) + (def: (composite left right) (let [left (:representation left) right (:representation right)] (:abstraction diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index 4b5da0b54..f07c533d9 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -8,28 +8,33 @@ function]]) (type: .public (Trace t a) - {#monoid (Monoid t) - #trace (-> t a)}) + (Record + {#monoid (Monoid t) + #trace (-> t a)})) -(implementation: .public functor (All [t] (Functor (Trace t))) - (def: (map f fa) - (revised@ #trace (compose f) fa))) +(implementation: .public functor + (All [t] (Functor (Trace t))) -(implementation: .public comonad (All [t] (CoMonad (Trace t))) + (def: (each f fa) + (revised@ #trace (composite f) fa))) + +(implementation: .public comonad + (All [t] (CoMonad (Trace t))) + (def: &functor ..functor) (def: (out wa) ((value@ #trace wa) (value@ [#monoid #monoid.identity] wa))) - (def: (split wa) + (def: (disjoint wa) (let [monoid (value@ #monoid wa)] {#monoid monoid #trace (function (_ t1) {#monoid monoid #trace (function (_ t2) ((value@ #trace wa) - (\ monoid compose t1 t2)))})}))) + (\ monoid composite t1 t2)))})}))) (def: .public (result context tracer) (All [t a] (-> t (Trace t a) a)) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index d033bd3f0..96ccfe30e 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -136,7 +136,7 @@ (`` (|>> (:as (array.Array Any)) <adaption> array.list - (list\map inspection) + (list\each inspection) (text.interposed " ") (text.enclosed ["[" "]"]))))) @@ -549,7 +549,7 @@ (<>.either (<>.and <code>.local_identifier (\ <>.monad in #.None)) (<code>.record (<>.and <code>.local_identifier - (\ <>.monad map (|>> #.Some) <code>.any))))) + (\ <>.monad each (|>> #.Some) <code>.any))))) (exception: .public (unknown_local_binding {name Text}) (exception.report @@ -573,25 +573,25 @@ #.End (|> environment dictionary.keys - (list\map (function (_ local) [local #.None])) + (list\each (function (_ local) [local #.None])) in) _ - (monad.map ! (function (_ [name format]) - (if (dictionary.key? environment name) - (in [name format]) - (function.constant (exception.except ..unknown_local_binding [name])))) - targets)))] + (monad.each ! (function (_ [name format]) + (if (dictionary.key? environment name) + (in [name format]) + (function.constant (exception.except ..unknown_local_binding [name])))) + targets)))] (in (list (` (..log! ("lux text concat" (~ (code.text (%.format (%.location location) text.new_line))) ((~! exception.report) - (~+ (list\map (function (_ [name format]) - (let [format (case format - #.None - (` (~! ..inspection)) - - (#.Some format) - format)] - (` [(~ (code.text name)) - ((~ format) (~ (code.local_identifier name)))]))) - targets)))))))))) + (~+ (list\each (function (_ [name format]) + (let [format (case format + #.None + (` (~! ..inspection)) + + (#.Some format) + format)] + (` [(~ (code.text name)) + ((~ format) (~ (code.local_identifier name)))]))) + targets)))))))))) diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 4768a1975..35cebc0f4 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -33,8 +33,9 @@ ["." syntax]]]]]]]) (type: Fragment - (#Comment Text) - (#Code Code)) + (Variant + (#Comment Text) + (#Code Code))) (def: fragment (Parser Fragment) @@ -59,14 +60,14 @@ (^template [<tag>] [[[_ _ column] (<tag> members)] (|> members - (list\map reference_column) + (list\each reference_column) (list\mix n.min column))]) ([#.Form] [#.Tuple]) [[_ _ column] (#.Record pairs)] - (|> (list\compose (list\map (|>> product.left reference_column) pairs) - (list\map (|>> product.right reference_column) pairs)) + (|> (list\composite (list\each (|>> product.left reference_column) pairs) + (list\each (|>> product.right reference_column) pairs)) (list\mix n.min column)) )) @@ -187,7 +188,7 @@ (def: example_documentation (-> Example Code) - (|>> (list\map ..fragment_documentation) + (|>> (list\each ..fragment_documentation) (list.interposed ..blank_line) (text.interposed "") code.text)) @@ -242,19 +243,21 @@ (list (` (<| ((~! md.code)) ((~! %.format) (~+ (|> examples - (list\map ..example_documentation) + (list\each ..example_documentation) (list.interposed ..example_separator)))))))))) ))))) (type: .public Definition - {#definition Text - #documentation (Markdown Block)}) + (Record + {#definition Text + #documentation (Markdown Block)})) (type: .public #rec Module - {#module Text - #description Text - #expected (Set Text) - #definitions (List Definition)}) + (Record + {#module Text + #description Text + #expected (Set Text) + #definitions (List Definition)})) (syntax: .public (default [name ..qualified_identifier]) (let [[_ short] name] @@ -278,7 +281,7 @@ (|>> (list.sorted (function (_ left right) (text\< (value@ #definition right) (value@ #definition left)))) - (list\map (value@ #documentation)) + (list\each (value@ #documentation)) (list\mix md.then md.empty))) (def: expected_separator @@ -316,10 +319,10 @@ (~ (code.text name)) (~ description) (~ (code.text (|> expected - (list\map product.left) + (list\each product.left) ..expected_format))) ((~! list.together) (list (~+ definitions)))) - ($_ (\ (~! list.monoid) (~' compose)) + ($_ (\ (~! list.monoid) (~' composite)) (: (List Module) (\ (~! list.monoid) (~' identity))) (~+ subs))))))))) @@ -327,9 +330,9 @@ (def: listing (-> (List Text) (Markdown Block)) (|>> (list.sorted text\<) - (list\map (function (_ definition) - [(md.snippet definition) - #.None])) + (list\each (function (_ definition) + [(md.snippet definition) + #.None])) md.numbered_list)) (def: (module_documentation module) @@ -369,7 +372,7 @@ (case (|> module (value@ #definitions) (list.only (|>> (value@ #definition) (set.member? expected) not)) - (list\map (value@ #definition))) + (list\each (value@ #definition))) #.End md.empty @@ -383,7 +386,7 @@ (-> (List Module) Text) (|>> (list.sorted (function (_ left right) (text\< (value@ #module right) (value@ #module left)))) - (list\map ..module_documentation) + (list\each ..module_documentation) (list.interposed md.horizontal_rule) (list\mix md.then (: (Markdown Block) md.empty)) md.markdown)) diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index acc859dba..b63c91b0c 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -20,11 +20,12 @@ ["." phase]]]]]) (type: Declaration - {#name Code - #label Text - #phase Text - #archive Text - #inputs (List Code)}) + (Record + {#name Code + #label Text + #phase Text + #archive Text + #inputs (List Code)})) (def: (declaration default) (-> Code (Parser Declaration)) diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index 6d8ed9658..38a207259 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -92,8 +92,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -114,9 +115,10 @@ ..common_method))) (type: Member - (#Constructor Constructor) - (#Field Field) - (#Method Method)) + (Variant + (#Constructor Constructor) + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -129,8 +131,8 @@ (def: input_variables (-> (List Nullable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nullable? type]]) - [nullable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nullable? type]]) + [nullable? (|> idx %.nat code.local_identifier)])))) (def: (nullable_type [nullable? type]) (-> Nullable Code) @@ -174,8 +176,9 @@ [Text (List Text)]) (type: Import - (#Class [Class_Declaration Text (List Member)]) - (#Function Static_Method)) + (Variant + (#Class [Class_Declaration Text (List Member)]) + (#Function Static_Method))) (def: class_declaration (Parser Class_Declaration) @@ -220,8 +223,8 @@ (-> Code Code Text (List Nullable) Bit Bit Nullable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nullable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nullable_type inputsT))] (~ (|> (nullable_type outputT) (try_type try?) (io_type io?)))) @@ -231,7 +234,7 @@ (without_null g!temp outputT) (` ("js apply" ("js constant" (~ (code.text source))) - (~+ (list\map (with_null g!temp) g!inputs))))))))))) + (~+ (list\each (with_null g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) {#.doc (example "Easily import types, methods, functions and constants." @@ -256,71 +259,71 @@ (text.replaced "#" class_name) (text.replaced "." member_name) code.local_identifier))) - class_parameters (list\map code.local_identifier class_parameters) + class_parameters (list\each code.local_identifier class_parameters) declaration (` ((~ (code.local_identifier class_name)) (~+ class_parameters))) real_class (text.replaced "/" "." class_name)] (in (list& (` (type: (~ declaration) (..Object (primitive (~ (code.text real_class)))))) - (list\map (function (_ member) - (case member - (#Constructor inputsT) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify "new")) - [(~+ (list\map product.right g!inputs))]) - (All [(~+ class_parameters)] - (-> [(~+ (list\map nullable_type inputsT))] - (~ declaration))) - (:expected - ("js object new" - ("js constant" (~ (code.text real_class))) - [(~+ (list\map (with_null g!temp) g!inputs))]))))) - - (#Field [static? field fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify field)) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (nullable_type fieldT)) - ("js constant" (~ (code.text (%.format real_class "." field)))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (All [(~+ class_parameters)] - (-> (~ declaration) - (~ (nullable_type fieldT)))) - (:expected - (~ (without_null g!temp fieldT (` ("js object get" (~ (code.text field)) (~ g!object))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (%.format real_class "." method) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (All [(~+ class_parameters)] - (-> [(~+ (list\map nullable_type inputsT))] - (~ declaration) - (~ (|> (nullable_type outputT) - (try_type try?) - (io_type io?))))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_null g!temp outputT) - (` ("js object do" - (~ (code.text method)) - (~ g!object) - [(~+ (list\map (with_null g!temp) g!inputs))]))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Constructor inputsT) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify "new")) + [(~+ (list\each product.right g!inputs))]) + (All [(~+ class_parameters)] + (-> [(~+ (list\each nullable_type inputsT))] + (~ declaration))) + (:expected + ("js object new" + ("js constant" (~ (code.text real_class))) + [(~+ (list\each (with_null g!temp) g!inputs))]))))) + + (#Field [static? field fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify field)) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (nullable_type fieldT)) + ("js constant" (~ (code.text (%.format real_class "." field)))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (All [(~+ class_parameters)] + (-> (~ declaration) + (~ (nullable_type fieldT)))) + (:expected + (~ (without_null g!temp fieldT (` ("js object get" (~ (code.text field)) (~ g!object))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (%.format real_class "." method) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (All [(~+ class_parameters)] + (-> [(~+ (list\each nullable_type inputsT))] + (~ declaration) + (~ (|> (nullable_type outputT) + (try_type try?) + (io_type io?))))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_null g!temp outputT) + (` ("js object do" + (~ (code.text method)) + (~ g!object) + [(~+ (list\each (with_null g!temp) g!inputs))]))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (in (list (..make_function (code.local_identifier (maybe.else name alias)) @@ -365,7 +368,7 @@ (~ g!_) (..constant (~ type) [(~ (code.local_identifier (%.format head "." next))) - (~+ (list\map code.local_identifier tail))]))))))))))) + (~+ (list\each code.local_identifier tail))]))))))))))) (template: (!defined? <constant>) (.case (..constant Any <constant>) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 16c4887ab..d57bde2b1 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -178,131 +178,150 @@ "<init>") (type: Primitive_Mode - #ManualPrM - #AutoPrM) + (Variant + #ManualPrM + #AutoPrM)) (type: .public Privacy - #PublicP - #PrivateP - #ProtectedP - #DefaultP) + (Variant + #PublicP + #PrivateP + #ProtectedP + #DefaultP)) (type: .public State - #VolatileS - #FinalS - #DefaultS) + (Variant + #VolatileS + #FinalS + #DefaultS)) (type: .public Inheritance - #FinalI - #AbstractI - #DefaultI) + (Variant + #FinalI + #AbstractI + #DefaultI)) (type: Class_Kind - #Class - #Interface) + (Variant + #Class + #Interface)) -(type: StackFrame (primitive "java/lang/StackTraceElement")) -(type: StackTrace (array.Array StackFrame)) +(type: StackFrame + (primitive "java/lang/StackTraceElement")) + +(type: StackTrace + (array.Array StackFrame)) (type: Annotation_Parameter [Text Code]) (type: Annotation - {#ann_name Text - #ann_params (List Annotation_Parameter)}) + (Record + {#ann_name Text + #ann_params (List Annotation_Parameter)})) (type: Member_Declaration - {#member_name Text - #member_privacy Privacy - #member_anns (List Annotation)}) + (Record + {#member_name Text + #member_privacy Privacy + #member_anns (List Annotation)})) (type: FieldDecl - (#ConstantField (Type Value) Code) - (#VariableField State (Type Value))) + (Variant + (#ConstantField (Type Value) Code) + (#VariableField State (Type Value)))) (type: MethodDecl - {#method_tvars (List (Type Var)) - #method_inputs (List (Type Value)) - #method_output (Type Return) - #method_exs (List (Type Class))}) + (Record + {#method_tvars (List (Type Var)) + #method_inputs (List (Type Value)) + #method_output (Type Return) + #method_exs (List (Type Class))})) (type: Method_Definition - (#ConstructorMethod [Bit - (List (Type Var)) - Text - (List Argument) - (List (Typed Code)) - Code - (List (Type Class))]) - (#VirtualMethod [Bit - Bit + (Variant + (#ConstructorMethod [Bit + (List (Type Var)) + Text + (List Argument) + (List (Typed Code)) + Code + (List (Type Class))]) + (#VirtualMethod [Bit + Bit + (List (Type Var)) + Text + (List Argument) + (Type Return) + Code + (List (Type Class))]) + (#OverridenMethod [Bit + (Type Declaration) + (List (Type Var)) + Text + (List Argument) + (Type Return) + Code + (List (Type Class))]) + (#StaticMethod [Bit (List (Type Var)) - Text (List Argument) (Type Return) Code (List (Type Class))]) - (#OverridenMethod [Bit - (Type Declaration) - (List (Type Var)) - Text + (#AbstractMethod [(List (Type Var)) (List Argument) (Type Return) - Code (List (Type Class))]) - (#StaticMethod [Bit - (List (Type Var)) - (List Argument) - (Type Return) - Code - (List (Type Class))]) - (#AbstractMethod [(List (Type Var)) - (List Argument) - (Type Return) - (List (Type Class))]) - (#NativeMethod [(List (Type Var)) - (List Argument) - (Type Return) - (List (Type Class))])) + (#NativeMethod [(List (Type Var)) + (List Argument) + (Type Return) + (List (Type Class))]))) (type: Partial_Call - {#pc_method Name - #pc_args (List Code)}) + (Record + {#pc_method Name + #pc_args (List Code)})) (type: ImportMethodKind - #StaticIMK - #VirtualIMK) + (Variant + #StaticIMK + #VirtualIMK)) (type: ImportMethodCommons - {#import_member_mode Primitive_Mode - #import_member_alias Text - #import_member_kind ImportMethodKind - #import_member_tvars (List (Type Var)) - #import_member_args (List [Bit (Type Value)]) - #import_member_maybe? Bit - #import_member_try? Bit - #import_member_io? Bit}) + (Record + {#import_member_mode Primitive_Mode + #import_member_alias Text + #import_member_kind ImportMethodKind + #import_member_tvars (List (Type Var)) + #import_member_args (List [Bit (Type Value)]) + #import_member_maybe? Bit + #import_member_try? Bit + #import_member_io? Bit})) (type: ImportConstructorDecl - {}) + (Record{})) (type: ImportMethodDecl - {#import_method_name Text - #import_method_return (Type Return)}) + (Record + {#import_method_name Text + #import_method_return (Type Return)})) (type: ImportFieldDecl - {#import_field_mode Primitive_Mode - #import_field_name Text - #import_field_static? Bit - #import_field_maybe? Bit - #import_field_setter? Bit - #import_field_type (Type Value)}) + (Record + {#import_field_mode Primitive_Mode + #import_field_name Text + #import_field_static? Bit + #import_field_maybe? Bit + #import_field_setter? Bit + #import_field_type (Type Value)})) (type: Import_Member_Declaration - (#EnumDecl (List Text)) - (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) - (#MethodDecl [ImportMethodCommons ImportMethodDecl]) - (#FieldAccessDecl ImportFieldDecl)) + (Variant + (#EnumDecl (List Text)) + (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) + (#MethodDecl [ImportMethodCommons ImportMethodDecl]) + (#FieldAccessDecl ImportFieldDecl))) (def: (primitive_type mode type) (-> Primitive_Mode (Type Primitive) Code) @@ -354,7 +373,7 @@ [parser.upper? limit (parameter_type limit)] [parser.class? [name parameters] (` (.primitive (~ (code.text name)) - [(~+ (list\map parameter_type parameters))]))])) + [(~+ (list\each parameter_type parameters))]))])) ... else (undefined) ))) @@ -415,15 +434,15 @@ (case (f input) (^template [<tag>] [[meta (<tag> parts)] - [meta (<tag> (list\map (replaced f) parts))]]) + [meta (<tag> (list\each (replaced f) parts))]]) ([#.Form] [#.Tuple]) [meta (#.Record pairs)] - [meta (#.Record (list\map (: (-> [Code Code] [Code Code]) - (function (_ [key val]) - [(replaced f key) (replaced f val)])) - pairs))] + [meta (#.Record (list\each (: (-> [Code Code] [Code Code]) + (function (_ [key val]) + [(replaced f key) (replaced f val)])) + pairs))] ast' ast')) @@ -460,8 +479,8 @@ (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] (in (` ("jvm member invoke constructor" (~ (code.text class_name)) (~+ (|> args - (list.zipped/2 (list\map product.right arguments)) - (list\map ..decorate_input)))))))) + (list.zipped/2 (list\each product.right arguments)) + (list\each ..decorate_input)))))))) (def: (static_method_parser class_name method_name arguments) (-> Text Text (List Argument) (Parser Code)) @@ -472,8 +491,8 @@ (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] (in (` ("jvm member invoke static" (~ (code.text class_name)) (~ (code.text method_name)) (~+ (|> args - (list.zipped/2 (list\map product.right arguments)) - (list\map ..decorate_input)))))))) + (list.zipped/2 (list\each product.right arguments)) + (list\each ..decorate_input)))))))) (template [<name> <jvm_op>] [(def: (<name> class_name method_name arguments self_name) @@ -486,8 +505,8 @@ (in (` (<jvm_op> (~ (code.text class_name)) (~ (code.text method_name)) (~ (code.local_identifier self_name)) (~+ (|> args - (list.zipped/2 (list\map product.right arguments)) - (list\map ..decorate_input))))))))] + (list.zipped/2 (list\each product.right arguments)) + (list\each ..decorate_input))))))))] [special_method_parser "jvm member invoke special"] [virtual_method_parser "jvm member invoke virtual"] @@ -554,7 +573,7 @@ (not (text.contains? name.external_separator name))) _ (..assertion ..class_name_cannot_be_a_type_variable [name type_vars] (not (list.member? text.equivalence - (list\map parser.name type_vars) + (list\each parser.name type_vars) name)))] (in name))) @@ -580,7 +599,7 @@ (do <>.monad [name <code>.local_identifier _ (..assertion ..unexpected_type_variable [name type_vars] - (list.member? text.equivalence (list\map parser.name type_vars) name))] + (list.member? text.equivalence (list\each parser.name type_vars) name))] (in (type.var name)))) (def: wildcard^ @@ -595,7 +614,7 @@ (|>> (<>.after (<code>.this! (' <comparison>))) (<>.after ..wildcard^) <code>.tuple - (\ <>.monad map <constructor>)))] + (\ <>.monad each <constructor>)))] [upper^ < type.upper] [lower^ > type.lower] @@ -638,7 +657,7 @@ (def: array^ (-> (Parser (Type Value)) (Parser (Type Array))) (|>> <code>.tuple - (\ <>.monad map type.array))) + (\ <>.monad each type.array))) (def: (type^ type_vars) (-> (List (Type Var)) (Parser (Type Value))) @@ -663,7 +682,7 @@ (def: var^ (Parser (Type Var)) - (\ <>.monad map type.var <code>.local_identifier)) + (\ <>.monad each type.var <code>.local_identifier)) (def: vars^ (Parser (List (Type Var))) @@ -719,7 +738,7 @@ (-> (List (Type Var)) (Parser [Member_Declaration MethodDecl])) (<code>.form (do <>.monad [tvars (<>.else (list) ..vars^) - .let [total_vars (list\compose tvars type_vars)] + .let [total_vars (list\composite tvars type_vars)] name <code>.local_identifier anns ..annotations^ inputs (<code>.tuple (<>.some (..type^ total_vars))) @@ -777,7 +796,7 @@ [pm privacy_modifier^ strict_fp? (<>.parses? (<code>.this! (' #strict))) method_vars (<>.else (list) ..vars^) - .let [total_vars (list\compose class_vars method_vars)] + .let [total_vars (list\composite class_vars method_vars)] [_ self_name arguments] (<code>.form ($_ <>.and (<code>.this! (' new)) <code>.local_identifier @@ -798,7 +817,7 @@ strict_fp? (<>.parses? (<code>.this! (' #strict))) final? (<>.parses? (<code>.this! (' #final))) method_vars (<>.else (list) ..vars^) - .let [total_vars (list\compose class_vars method_vars)] + .let [total_vars (list\composite class_vars method_vars)] [name self_name arguments] (<code>.form ($_ <>.and <code>.local_identifier <code>.local_identifier @@ -818,8 +837,8 @@ [strict_fp? (<>.parses? (<code>.this! (' #strict))) owner_class ..declaration^ method_vars (<>.else (list) ..vars^) - .let [total_vars (list\compose (product.right (parser.declaration owner_class)) - method_vars)] + .let [total_vars (list\composite (product.right (parser.declaration owner_class)) + method_vars)] [name self_name arguments] (<code>.form ($_ <>.and <code>.local_identifier <code>.local_identifier @@ -944,7 +963,7 @@ [tvars (<>.else (list) ..vars^) _ (<code>.identifier! ["" "new"]) ?alias import_member_alias^ - .let [total_vars (list\compose owner_vars tvars)] + .let [total_vars (list\composite owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] @@ -965,7 +984,7 @@ tvars (<>.else (list) ..vars^) name <code>.local_identifier ?alias import_member_alias^ - .let [total_vars (list\compose owner_vars tvars)] + .let [total_vars (list\composite owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ @@ -1023,7 +1042,7 @@ (def: (annotation$ [name params]) (-> Annotation Code) - (` ((~ (code.text name)) (~+ (list\map annotation_parameter$ params))))) + (` ((~ (code.text name)) (~+ (list\each annotation_parameter$ params))))) (template [<name> <category>] [(def: <name> @@ -1046,10 +1065,10 @@ (-> [Member_Declaration MethodDecl] Code) (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl] (` ((~ (code.text name)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ method_tvars))] - [(~+ (list\map class$ method_exs))] - [(~+ (list\map value$ method_inputs))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ method_tvars))] + [(~+ (list\each class$ method_exs))] + [(~+ (list\each value$ method_inputs))] (~ (return$ method_output)))))) (def: (state_modifier$ sm) @@ -1064,7 +1083,7 @@ (case field (#ConstantField class value) (` ("constant" (~ (code.text name)) - [(~+ (list\map annotation$ anns))] + [(~+ (list\each annotation$ anns))] (~ (value$ class)) (~ value) )) @@ -1073,7 +1092,7 @@ (` ("variable" (~ (code.text name)) (~ (privacy_modifier$ pm)) (~ (state_modifier$ sm)) - [(~+ (list\map annotation$ anns))] + [(~+ (list\each annotation$ anns))] (~ (value$ class)) )) )) @@ -1090,23 +1109,23 @@ (-> External (Parser Code) (Type Class) (List [Member_Declaration FieldDecl]) [Member_Declaration Method_Definition] Code) (case method_def (#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs) - (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields) + (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer)] (` ("init" (~ (privacy_modifier$ pm)) (~ (code.bit strict_fp?)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] - [(~+ (list\map class$ exs))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] + [(~+ (list\each class$ exs))] (~ (code.text self_name)) - [(~+ (list\map argument$ arguments))] - [(~+ (list\map constructor_arg$ constructor_args))] + [(~+ (list\each argument$ arguments))] + [(~+ (list\each constructor_arg$ constructor_args))] (~ (replaced replacer body)) ))) (#VirtualMethod final? strict_fp? type_vars self_name arguments return_type body exs) - (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields) + (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer)] (` ("virtual" @@ -1114,16 +1133,16 @@ (~ (privacy_modifier$ pm)) (~ (code.bit final?)) (~ (code.bit strict_fp?)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] (~ (code.text self_name)) - [(~+ (list\map argument$ arguments))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)) - [(~+ (list\map class$ exs))] + [(~+ (list\each class$ exs))] (~ (replaced replacer body))))) (#OverridenMethod strict_fp? declaration type_vars self_name arguments return_type body exs) - (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields) + (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer) super_replacer (parser->replacer (<code>.form (do <>.monad @@ -1134,18 +1153,18 @@ (~ (code.text name)) (~ (code.local_identifier self_name)) (~+ (|> args - (list.zipped/2 (list\map product.right arguments)) - (list\map ..decorate_input)))))))))] + (list.zipped/2 (list\each product.right arguments)) + (list\each ..decorate_input)))))))))] (` ("override" (~ (declaration$ declaration)) (~ (code.text name)) (~ (code.bit strict_fp?)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] (~ (code.text self_name)) - [(~+ (list\map argument$ arguments))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)) - [(~+ (list\map class$ exs))] + [(~+ (list\each class$ exs))] (~ (|> body (replaced replacer) (replaced super_replacer))) @@ -1157,31 +1176,31 @@ (~ (code.text name)) (~ (privacy_modifier$ pm)) (~ (code.bit strict_fp?)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] - [(~+ (list\map argument$ arguments))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)) - [(~+ (list\map class$ exs))] + [(~+ (list\each class$ exs))] (~ (replaced replacer body))))) (#AbstractMethod type_vars arguments return_type exs) (` ("abstract" (~ (code.text name)) (~ (privacy_modifier$ pm)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] - [(~+ (list\map argument$ arguments))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)) - [(~+ (list\map class$ exs))])) + [(~+ (list\each class$ exs))])) (#NativeMethod type_vars arguments return_type exs) (` ("native" (~ (code.text name)) (~ (privacy_modifier$ pm)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] - [(~+ (list\map class$ exs))] - [(~+ (list\map argument$ arguments))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] + [(~+ (list\each class$ exs))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)))) )) @@ -1195,7 +1214,7 @@ (syntax: .public (class: [.let [! <>.monad] im inheritance_modifier^ - [full_class_name class_vars] (\ ! map parser.declaration ..declaration^) + [full_class_name class_vars] (\ ! each parser.declaration ..declaration^) super (<>.else $Object (class^ class_vars)) interfaces (<>.else (list) @@ -1207,28 +1226,28 @@ [.let [fully_qualified_class_name full_class_name method_parser (: (Parser Code) (|> methods - (list\map (method->parser fully_qualified_class_name)) + (list\each (method->parser fully_qualified_class_name)) (list\mix <>.either (<>.failure ""))))]] (in (list (` ("jvm class" (~ (declaration$ (type.declaration full_class_name class_vars))) (~ (class$ super)) - [(~+ (list\map class$ interfaces))] + [(~+ (list\each class$ interfaces))] (~ (inheritance_modifier$ im)) - [(~+ (list\map annotation$ annotations))] - [(~+ (list\map field_decl$ fields))] - [(~+ (list\map (method_def$ fully_qualified_class_name method_parser super fields) methods))])))))) + [(~+ (list\each annotation$ annotations))] + [(~+ (list\each field_decl$ fields))] + [(~+ (list\each (method_def$ fully_qualified_class_name method_parser super fields) methods))])))))) (syntax: .public (interface: [.let [! <>.monad] - [full_class_name class_vars] (\ ! map parser.declaration ..declaration^) + [full_class_name class_vars] (\ ! each parser.declaration ..declaration^) supers (<>.else (list) (<code>.tuple (<>.some (class^ class_vars)))) annotations ..annotations^ members (<>.some (..method_decl^ class_vars))]) (in (list (` ("jvm class interface" (~ (declaration$ (type.declaration full_class_name class_vars))) - [(~+ (list\map class$ supers))] - [(~+ (list\map annotation$ annotations))] - (~+ (list\map method_decl$ members))))))) + [(~+ (list\each class$ supers))] + [(~+ (list\each annotation$ annotations))] + (~+ (list\each method_decl$ members))))))) (syntax: .public (object [class_vars ..vars^ super (<>.else $Object @@ -1238,11 +1257,11 @@ constructor_args (..constructor_args^ class_vars) methods (<>.some ..overriden_method_def^)]) (in (list (` ("jvm class anonymous" - [(~+ (list\map var$ class_vars))] + [(~+ (list\each var$ class_vars))] (~ (class$ super)) - [(~+ (list\map class$ interfaces))] - [(~+ (list\map constructor_arg$ constructor_args))] - [(~+ (list\map (method_def$ "" (<>.failure "") super (list)) methods))]))))) + [(~+ (list\each class$ interfaces))] + [(~+ (list\each constructor_arg$ constructor_args))] + [(~+ (list\each (method_def$ "" (<>.failure "") super (list)) methods))]))))) (syntax: .public (null []) (in (list (` ("jvm object null"))))) @@ -1297,14 +1316,14 @@ methods (<>.some partial_call^)]) (with_identifiers [g!obj] (in (list (` (let [(~ g!obj) (~ obj)] - (exec (~+ (list\map (complete_call$ g!obj) methods)) + (exec (~+ (list\each (complete_call$ g!obj) methods)) (~ g!obj)))))))) (def: (class_import$ declaration) (-> (Type Declaration) Code) (let [[full_name params] (parser.declaration declaration) def_name (..internal full_name) - params' (list\map ..var$' params)] + params' (list\each ..var$' params)] (` (def: (~ (code.identifier ["" def_name])) {#..jvm_class (~ (code.text (..internal full_name)))} .Type @@ -1316,7 +1335,7 @@ (-> (List (Type Var)) Import_Member_Declaration (List (Type Var))) (case member (#ConstructorDecl [commons _]) - (list\compose class_tvars (value@ #import_member_tvars commons)) + (list\composite class_tvars (value@ #import_member_tvars commons)) (#MethodDecl [commons _]) (case (value@ #import_member_kind commons) @@ -1324,7 +1343,7 @@ (value@ #import_member_tvars commons) _ - (list\compose class_tvars (value@ #import_member_tvars commons))) + (list\composite class_tvars (value@ #import_member_tvars commons))) _ class_tvars)) @@ -1335,20 +1354,20 @@ (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) (let [(^slots [#import_member_tvars #import_member_args]) commons] (do {! meta.monad} - [arg_inputs (monad.map ! - (: (-> [Bit (Type Value)] (Meta [Bit Code])) - (function (_ [maybe? _]) - (with_identifiers [arg_name] - (in [maybe? arg_name])))) - import_member_args) - .let [input_jvm_types (list\map product.right import_member_args) - arg_types (list\map (: (-> [Bit (Type Value)] Code) - (function (_ [maybe? arg]) - (let [arg_type (value_type (value@ #import_member_mode commons) arg)] - (if maybe? - (` (Maybe (~ arg_type))) - arg_type)))) - import_member_args)]] + [arg_inputs (monad.each ! + (: (-> [Bit (Type Value)] (Meta [Bit Code])) + (function (_ [maybe? _]) + (with_identifiers [arg_name] + (in [maybe? arg_name])))) + import_member_args) + .let [input_jvm_types (list\each product.right import_member_args) + arg_types (list\each (: (-> [Bit (Type Value)] Code) + (function (_ [maybe? arg]) + (let [arg_type (value_type (value@ #import_member_mode commons) arg)] + (if maybe? + (` (Maybe (~ arg_type))) + arg_type)))) + import_member_args)]] (in [arg_inputs input_jvm_types arg_types]))) _ @@ -1467,13 +1486,13 @@ (-> Primitive_Mode (List (Type Value)) (List [Bit Code]) (List Code)) (|> inputs (list.zipped/2 classes) - (list\map (function (_ [class [maybe? input]]) - (|> (if maybe? - (` (: (.primitive (~ (code.text (..reflection class)))) - ((~! !!!) (~ (..un_quoted input))))) - (..un_quoted input)) - [class] - (with_automatic_input_conversion mode)))))) + (list\each (function (_ [class [maybe? input]]) + (|> (if maybe? + (` (: (.primitive (~ (code.text (..reflection class)))) + ((~! !!!) (~ (..un_quoted input))))) + (..un_quoted input)) + [class] + (with_automatic_input_conversion mode)))))) (def: (import_name format class member) (-> Text Text Text Text) @@ -1483,9 +1502,9 @@ (def: syntax_inputs (-> (List Code) (List Code)) - (|>> (list\map (function (_ name) - (list name (` (~! <code>.any))))) - list\join)) + (|>> (list\each (function (_ name) + (list name (` (~! <code>.any))))) + list\conjoint)) (def: (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format) (-> (List (Type Var)) Class_Kind (Type Declaration) [(List [Bit Code]) (List (Type Value)) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) @@ -1499,7 +1518,7 @@ (` (primitive (~ (code.text full_name)))) _ - (let [=class_tvars (list\map ..var$' class_tvars)] + (let [=class_tvars (list\each ..var$' class_tvars)] (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)])))))) getter_interop (: (-> Text Code) (function (_ name) @@ -1507,7 +1526,7 @@ (` (def: (~ getter_name) (~ enum_type) (~ (get_static_field full_name name)))))))]] - (in (list\map getter_interop enum_members))) + (in (list\each getter_interop enum_members))) (#ConstructorDecl [commons _]) (do meta.monad @@ -1515,17 +1534,17 @@ def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) jvm_interop (|> [classT (` ("jvm member invoke constructor" - [(~+ (list\map ..var$ class_tvars))] + [(~+ (list\each ..var$ class_tvars))] (~ (code.text full_name)) - [(~+ (list\map ..var$ (value@ #import_member_tvars commons)))] + [(~+ (list\each ..var$ (value@ #import_member_tvars commons)))] (~+ (|> (jvm_invoke_inputs (value@ #import_member_mode commons) input_jvm_types arg_function_inputs) (list.zipped/2 input_jvm_types) - (list\map ..decorate_input)))))] + (list\each ..decorate_input)))))] (with_automatic_output_conversion (value@ #import_member_mode commons)) (with_return_maybe member true classT) (with_return_try member) (with_return_io member))]] - (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\map product.right arg_function_inputs)))]) + (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop))))))))) (#MethodDecl [commons method]) @@ -1553,17 +1572,17 @@ method_return (value@ #import_method_return method) callC (: Code (` ((~ (code.text jvm_op)) - [(~+ (list\map ..var$ class_tvars))] + [(~+ (list\each ..var$ class_tvars))] (~ (code.text full_name)) (~ (code.text import_method_name)) - [(~+ (list\map ..var$ (value@ #import_member_tvars commons)))] + [(~+ (list\each ..var$ (value@ #import_member_tvars commons)))] (~+ (|> object_ast - (list\map ..un_quoted) + (list\each ..un_quoted) (list.zipped/2 (list (type.class full_name (list)))) - (list\map (with_automatic_input_conversion (value@ #import_member_mode commons))))) + (list\each (with_automatic_input_conversion (value@ #import_member_mode commons))))) (~+ (|> (jvm_invoke_inputs (value@ #import_member_mode commons) input_jvm_types arg_function_inputs) (list.zipped/2 input_jvm_types) - (list\map ..decorate_input)))))) + (list\each ..decorate_input)))))) jvm_interop (: Code (case (type.void? method_return) (#.Left method_return) @@ -1579,7 +1598,7 @@ (|> callC (with_return_try member) (with_return_io member))))]] - (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\map product.right arg_function_inputs))) + (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1669,11 +1688,11 @@ (do {! meta.monad} [kind (class_kind declaration) =members (|> bundles - (list\map (function (_ [import_format members]) - (list\map (|>> [import_format]) members))) + (list\each (function (_ [import_format members]) + (list\each (|>> [import_format]) members))) list.together - (monad.map ! (member_import$ class_type_vars kind declaration)))] - (in (list& (class_import$ declaration) (list\join =members))))) + (monad.each ! (member_import$ class_type_vars kind declaration)))] + (in (list& (class_import$ declaration) (list\conjoint =members))))) (syntax: .public (array [type (..type^ (list)) size <code>.any]) @@ -1748,7 +1767,7 @@ (text\= array.type_name name) (case params (#.Item elementLT #.End) - (\ meta.monad map type.array + (\ meta.monad each type.array (lux_type->jvm_type elementLT)) _ @@ -1758,26 +1777,26 @@ (case params #.End (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] - (\ meta.monad map type.array + (\ meta.monad each type.array (lux_type->jvm_type (#.Primitive unprefixed (list))))) _ <failure>) ... else - (\ meta.monad map (type.class name) + (\ meta.monad each (type.class name) (: (Meta (List (Type Parameter))) - (monad.map meta.monad - (function (_ paramLT) - (do meta.monad - [paramJT (lux_type->jvm_type paramLT)] - (case (parser.parameter? paramJT) - (#.Some paramJT) - (in paramJT) - - #.None - <failure>))) - params))))) + (monad.each meta.monad + (function (_ paramLT) + (do meta.monad + [paramJT (lux_type->jvm_type paramLT)] + (case (parser.parameter? paramJT) + (#.Some paramJT) + (in paramJT) + + #.None + <failure>))) + params))))) (#.Apply A F) (case (lux_type.applied (list A) F) diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index 4d3f5aa26..3d14b554f 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -91,8 +91,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -113,8 +114,9 @@ ..common_method))) (type: Member - (#Field Field) - (#Method Method)) + (Variant + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -126,8 +128,8 @@ (def: input_variables (-> (List Nilable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nilable? type]]) - [nilable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nilable? type]]) + [nilable? (|> idx %.nat code.local_identifier)])))) (def: (nilable_type [nilable? type]) (-> Nilable Code) @@ -159,9 +161,10 @@ (.panic! "Nil is an invalid value!")))))) (type: Import - (#Class [Text Text (List Member)]) - (#Function Static_Method) - (#Constant Field)) + (Variant + (#Class [Text Text (List Member)]) + (#Function Static_Method) + (#Constant Field))) (def: import ($_ <>.or @@ -201,8 +204,8 @@ (-> Code Code Code (List Nilable) Bit Bit Nilable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nilable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nilable_type inputsT))] (~ (|> (nilable_type outputT) (try_type try?) (io_type io?)))) @@ -212,7 +215,7 @@ (without_nil g!temp outputT) (` ("lua apply" (:as ..Function (~ source)) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) {#.doc (example "Easily import types, methods, functions and constants." @@ -241,54 +244,54 @@ (` ("lua import" (~ (code.text class)))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text real_class)))))) - (list\map (function (_ member) - (case member - (#Field [static? field fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify field)) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (nilable_type fieldT)) - ("lua object get" (~ (code.text field)) - (:as (..Object .Any) (~ imported))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (-> (~ g!type) - (~ (nilable_type fieldT))) - (:expected - (~ (without_nil g!temp fieldT (` ("lua object get" (~ (code.text field)) - (:as (..Object .Any) (~ g!object)))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (` ("lua object get" (~ (code.text method)) - (:as (..Object .Any) (~ imported)))) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (-> [(~+ (list\map nilable_type inputsT))] - (~ g!type) - (~ (|> (nilable_type outputT) - (try_type try?) - (io_type io?)))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_nil g!temp outputT) - (` ("lua object do" - (~ (code.text method)) - (~ g!object) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Field [static? field fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify field)) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (nilable_type fieldT)) + ("lua object get" (~ (code.text field)) + (:as (..Object .Any) (~ imported))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (nilable_type fieldT))) + (:expected + (~ (without_nil g!temp fieldT (` ("lua object get" (~ (code.text field)) + (:as (..Object .Any) (~ g!object)))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (` ("lua object get" (~ (code.text method)) + (:as (..Object .Any) (~ imported)))) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\each nilable_type inputsT))] + (~ g!type) + (~ (|> (nilable_type outputT) + (try_type try?) + (io_type io?)))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_nil g!temp outputT) + (` ("lua object do" + (~ (code.text method)) + (~ g!object) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (in (list (..make_function (code.local_identifier (maybe.else name alias)) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 9ec503f1b..496b4475c 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -70,161 +70,187 @@ (def: member_separator "::") ... Types -(type: JVM_Code Text) +(type: JVM_Code + Text) (type: BoundKind - #UpperBound - #LowerBound) + (Variant + #UpperBound + #LowerBound)) (type: #rec GenericType - (#GenericTypeVar Text) - (#GenericClass [Text (List GenericType)]) - (#GenericArray GenericType) - (#GenericWildcard (Maybe [BoundKind GenericType]))) + (Variant + (#GenericTypeVar Text) + (#GenericClass [Text (List GenericType)]) + (#GenericArray GenericType) + (#GenericWildcard (Maybe [BoundKind GenericType])))) (type: Type_Parameter [Text (List GenericType)]) (type: Primitive_Mode - #ManualPrM - #AutoPrM) + (Variant + #ManualPrM + #AutoPrM)) (type: .public Privacy - #PublicP - #PrivateP - #ProtectedP - #DefaultP) + (Variant + #PublicP + #PrivateP + #ProtectedP + #DefaultP)) (type: .public State - #VolatileS - #FinalS - #DefaultS) + (Variant + #VolatileS + #FinalS + #DefaultS)) (type: .public Inheritance - #FinalI - #AbstractI - #DefaultI) + (Variant + #FinalI + #AbstractI + #DefaultI)) (type: Class_Kind - #Class - #Interface) + (Variant + #Class + #Interface)) (type: Class_Declaration - {#class_name Text - #class_params (List Type_Parameter)}) + (Record + {#class_name Text + #class_params (List Type_Parameter)})) -(type: StackFrame (primitive "java/lang/StackTraceElement")) -(type: StackTrace (Array StackFrame)) +(type: StackFrame + (primitive "java/lang/StackTraceElement")) + +(type: StackTrace + (Array StackFrame)) (type: Super_Class_Decl - {#super_class_name Text - #super_class_params (List GenericType)}) + (Record + {#super_class_name Text + #super_class_params (List GenericType)})) (type: AnnotationParam [Text Code]) (type: Annotation - {#ann_name Text - #ann_params (List AnnotationParam)}) + (Record + {#ann_name Text + #ann_params (List AnnotationParam)})) (type: Member_Declaration - {#member_name Text - #member_privacy Privacy - #member_anns (List Annotation)}) + (Record + {#member_name Text + #member_privacy Privacy + #member_anns (List Annotation)})) (type: FieldDecl - (#ConstantField GenericType Code) - (#VariableField State GenericType)) + (Variant + (#ConstantField GenericType Code) + (#VariableField State GenericType))) (type: MethodDecl - {#method_tvars (List Type_Parameter) - #method_inputs (List GenericType) - #method_output GenericType - #method_exs (List GenericType)}) + (Record + {#method_tvars (List Type_Parameter) + #method_inputs (List GenericType) + #method_output GenericType + #method_exs (List GenericType)})) (type: ArgDecl - {#arg_name Text - #arg_type GenericType}) + (Record + {#arg_name Text + #arg_type GenericType})) (type: ConstructorArg [GenericType Code]) (type: Method_Definition - (#ConstructorMethod [Bit - (List Type_Parameter) - (List ArgDecl) - (List ConstructorArg) - Code - (List GenericType)]) - (#VirtualMethod [Bit - Bit + (Variant + (#ConstructorMethod [Bit + (List Type_Parameter) + (List ArgDecl) + (List ConstructorArg) + Code + (List GenericType)]) + (#VirtualMethod [Bit + Bit + (List Type_Parameter) + Text + (List ArgDecl) + GenericType + Code + (List GenericType)]) + (#OverridenMethod [Bit + Class_Declaration + (List Type_Parameter) + Text + (List ArgDecl) + GenericType + Code + (List GenericType)]) + (#StaticMethod [Bit (List Type_Parameter) - Text (List ArgDecl) GenericType Code (List GenericType)]) - (#OverridenMethod [Bit - Class_Declaration - (List Type_Parameter) - Text + (#AbstractMethod [(List Type_Parameter) (List ArgDecl) GenericType - Code (List GenericType)]) - (#StaticMethod [Bit - (List Type_Parameter) - (List ArgDecl) - GenericType - Code - (List GenericType)]) - (#AbstractMethod [(List Type_Parameter) - (List ArgDecl) - GenericType - (List GenericType)]) - (#NativeMethod [(List Type_Parameter) - (List ArgDecl) - GenericType - (List GenericType)])) + (#NativeMethod [(List Type_Parameter) + (List ArgDecl) + GenericType + (List GenericType)]))) (type: Partial_Call - {#pc_method Name - #pc_args (List Code)}) + (Record + {#pc_method Name + #pc_args (List Code)})) (type: ImportMethodKind - #StaticIMK - #VirtualIMK) + (Variant + #StaticIMK + #VirtualIMK)) (type: ImportMethodCommons - {#import_member_mode Primitive_Mode - #import_member_alias Text - #import_member_kind ImportMethodKind - #import_member_tvars (List Type_Parameter) - #import_member_args (List [Bit GenericType]) - #import_member_maybe? Bit - #import_member_try? Bit - #import_member_io? Bit}) + (Record + {#import_member_mode Primitive_Mode + #import_member_alias Text + #import_member_kind ImportMethodKind + #import_member_tvars (List Type_Parameter) + #import_member_args (List [Bit GenericType]) + #import_member_maybe? Bit + #import_member_try? Bit + #import_member_io? Bit})) (type: ImportConstructorDecl - {}) + (Record + {})) (type: ImportMethodDecl - {#import_method_name Text - #import_method_return GenericType}) + (Record + {#import_method_name Text + #import_method_return GenericType})) (type: ImportFieldDecl - {#import_field_mode Primitive_Mode - #import_field_name Text - #import_field_static? Bit - #import_field_maybe? Bit - #import_field_setter? Bit - #import_field_type GenericType}) + (Record + {#import_field_mode Primitive_Mode + #import_field_name Text + #import_field_static? Bit + #import_field_maybe? Bit + #import_field_setter? Bit + #import_field_type GenericType})) (type: Import_Member_Declaration - (#EnumDecl (List Text)) - (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) - (#MethodDecl [ImportMethodCommons ImportMethodDecl]) - (#FieldAccessDecl ImportFieldDecl)) + (Variant + (#EnumDecl (List Text)) + (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) + (#MethodDecl [ImportMethodCommons ImportMethodDecl]) + (#FieldAccessDecl ImportFieldDecl))) ... Utils (def: (manual_primitive_type class) @@ -284,7 +310,7 @@ [[name params] _ _] (let [name (safe name) - =params (list\map (class_type' mode type_params in_array?) params)] + =params (list\each (class_type' mode type_params in_array?) params)] (` (primitive (~ (code.text name)) [(~+ =params)]))))) (def: (class_type' mode type_params in_array? class) @@ -326,15 +352,15 @@ (def: (class_decl_type$ (^slots [#class_name #class_params])) (-> Class_Declaration Code) - (let [=params (list\map (: (-> Type_Parameter Code) - (function (_ [pname pbounds]) - (case pbounds - #.End - (code.identifier ["" pname]) - - (#.Item bound1 _) - (class_type #ManualPrM class_params bound1)))) - class_params)] + (let [=params (list\each (: (-> Type_Parameter Code) + (function (_ [pname pbounds]) + (case pbounds + #.End + (code.identifier ["" pname]) + + (#.Item bound1 _) + (class_type #ManualPrM class_params bound1)))) + class_params)] (` (primitive (~ (code.text (safe class_name))) [(~+ =params)])))) @@ -411,15 +437,15 @@ (case (f input) (^template [<tag>] [[meta (<tag> parts)] - [meta (<tag> (list\map (pre_walk_replace f) parts))]]) + [meta (<tag> (list\each (pre_walk_replace f) parts))]]) ([#.Form] [#.Tuple]) [meta (#.Record pairs)] - [meta (#.Record (list\map (: (-> [Code Code] [Code Code]) - (function (_ [key val]) - [(pre_walk_replace f key) (pre_walk_replace f val)])) - pairs))] + [meta (#.Record (list\each (: (-> [Code Code] [Code Code]) + (function (_ [key val]) + [(pre_walk_replace f key) (pre_walk_replace f val)])) + pairs))] ast' ast')) @@ -450,7 +476,7 @@ [args (: (Parser (List Code)) (<code>.form (<>.after (<code>.this! (' ::new!)) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] + .let [arg_decls' (: (List Text) (list\each (|>> product.right (simple_class$ params)) arg_decls))]] (in (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) @@ -461,7 +487,7 @@ args (: (Parser (List Code)) (<code>.form (<>.after (<code>.this! (code.identifier ["" dotted_name])) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] + .let [arg_decls' (: (List Text) (list\each (|>> product.right (simple_class$ params)) arg_decls))]] (in (`' ((~ (code.text (format "jvm invokestatic" ":" class_name ":" method_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) @@ -473,7 +499,7 @@ args (: (Parser (List Code)) (<code>.form (<>.after (<code>.this! (code.identifier ["" dotted_name])) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] + .let [arg_decls' (: (List Text) (list\each (|>> product.right (simple_class$ params)) arg_decls))]] (in (`' ((~ (code.text (format <jvm_op> ":" class_name ":" method_name ":" (text.interposed "," arg_decls')))) (~' _jvm_this) (~+ args))))))] @@ -544,7 +570,7 @@ (do <>.monad [name <code>.local_identifier _ (no_periods_assertion name)] - (if (list.member? text.equivalence (list\map product.left type_vars) name) + (if (list.member? text.equivalence (list\each product.left type_vars) name) (in (#GenericTypeVar name)) (in (#GenericClass name (list))))) (<code>.tuple (do <>.monad @@ -569,7 +595,7 @@ _ (no_periods_assertion name) params (<>.some recur^) _ (<>.assertion (format name " cannot be a type-parameter!") - (not (list.member? text.equivalence (list\map product.left type_vars) name)))] + (not (list.member? text.equivalence (list\each product.left type_vars) name)))] (in (#GenericClass name params)))) )))) @@ -713,7 +739,7 @@ [pm privacy_modifier^ strict_fp? (<>.parses? (<code>.this! (' #strict))) method_vars ..type_params^ - .let [total_vars (list\compose class_vars method_vars)] + .let [total_vars (list\composite class_vars method_vars)] [_ arg_decls] (<code>.form (<>.and (<code>.this! (' new)) (..arg_decls^ total_vars))) constructor_args (..constructor_args^ total_vars) @@ -732,7 +758,7 @@ strict_fp? (<>.parses? (<code>.this! (' #strict))) final? (<>.parses? (<code>.this! (' #final))) method_vars ..type_params^ - .let [total_vars (list\compose class_vars method_vars)] + .let [total_vars (list\composite class_vars method_vars)] [name this_name arg_decls] (<code>.form ($_ <>.and <code>.local_identifier <code>.local_identifier @@ -755,7 +781,7 @@ [strict_fp? (<>.parses? (<code>.this! (' #strict))) owner_class ..class_decl^ method_vars ..type_params^ - .let [total_vars (list\compose (product.right owner_class) method_vars)] + .let [total_vars (list\composite (product.right owner_class) method_vars)] [name this_name arg_decls] (<code>.form ($_ <>.and <code>.local_identifier <code>.local_identifier @@ -879,7 +905,7 @@ [tvars ..type_params^ _ (<code>.this! (' new)) ?alias import_member_alias^ - .let [total_vars (list\compose owner_vars tvars)] + .let [total_vars (list\composite owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] @@ -900,7 +926,7 @@ tvars ..type_params^ name <code>.local_identifier ?alias import_member_alias^ - .let [total_vars (list\compose owner_vars tvars)] + .let [total_vars (list\composite owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ @@ -972,7 +998,7 @@ (def: (annotation$ [name params]) (-> Annotation JVM_Code) - (format "(" name " " "{" (text.interposed text.tab (list\map annotation_param$ params)) "}" ")")) + (format "(" name " " "{" (text.interposed text.tab (list\each annotation_param$ params)) "}" ")")) (def: (bound_kind$ kind) (-> BoundKind JVM_Code) @@ -987,7 +1013,7 @@ name (#GenericClass name params) - (format "(" (safe name) " " (spaced (list\map generic_type$ params)) ")") + (format "(" (safe name) " " (spaced (list\each generic_type$ params)) ")") (#GenericArray param) (format "(" array.type_name " " (generic_type$ param) ")") @@ -1000,25 +1026,25 @@ (def: (type_param$ [name bounds]) (-> Type_Parameter JVM_Code) - (format "(" name " " (spaced (list\map generic_type$ bounds)) ")")) + (format "(" name " " (spaced (list\each generic_type$ bounds)) ")")) (def: (class_decl$ (^open ".")) (-> Class_Declaration JVM_Code) - (format "(" (safe class_name) " " (spaced (list\map type_param$ class_params)) ")")) + (format "(" (safe class_name) " " (spaced (list\each type_param$ class_params)) ")")) (def: (super_class_decl$ (^slots [#super_class_name #super_class_params])) (-> Super_Class_Decl JVM_Code) - (format "(" (safe super_class_name) " " (spaced (list\map generic_type$ super_class_params)) ")")) + (format "(" (safe super_class_name) " " (spaced (list\each generic_type$ super_class_params)) ")")) (def: (method_decl$ [[name pm anns] method_decl]) (-> [Member_Declaration MethodDecl] JVM_Code) (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl] (with_parens (spaced (list name - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ method_tvars))) - (with_brackets (spaced (list\map generic_type$ method_exs))) - (with_brackets (spaced (list\map generic_type$ method_inputs))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ method_tvars))) + (with_brackets (spaced (list\each generic_type$ method_exs))) + (with_brackets (spaced (list\each generic_type$ method_inputs))) (generic_type$ method_output)) )))) @@ -1035,7 +1061,7 @@ (#ConstantField class value) (with_parens (spaced (list "constant" name - (with_brackets (spaced (list\map annotation$ anns))) + (with_brackets (spaced (list\each annotation$ anns))) (generic_type$ class) (code.format value)) )) @@ -1045,7 +1071,7 @@ (spaced (list "variable" name (privacy_modifier$ pm) (state_modifier$ sm) - (with_brackets (spaced (list\map annotation$ anns))) + (with_brackets (spaced (list\each annotation$ anns))) (generic_type$ class)) )) )) @@ -1068,11 +1094,11 @@ (spaced (list "init" (privacy_modifier$ pm) (bit\encoded strict_fp?) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) - (with_brackets (spaced (list\map constructor_arg$ constructor_args))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) + (with_brackets (spaced (list\each constructor_arg$ constructor_args))) (code.format (pre_walk_replace replacer body)) ))) @@ -1083,10 +1109,10 @@ (privacy_modifier$ pm) (bit\encoded final?) (bit\encoded strict_fp?) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type) (code.format (pre_walk_replace replacer (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)] (~ body)))))))) @@ -1095,8 +1121,8 @@ (let [super_replacer (parser_replacer (<code>.form (do <>.monad [_ (<code>.this! (' ::super!)) args (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any)) - .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ (list))) - arg_decls))]] + .let [arg_decls' (: (List Text) (list\each (|>> product.right (simple_class$ (list))) + arg_decls))]] (in (`' ((~ (code.text (format "jvm invokespecial" ":" (value@ #super_class_name super_class) ":" name @@ -1107,10 +1133,10 @@ (class_decl$ class_decl) name (bit\encoded strict_fp?) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type) (|> (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)] (~ body))) @@ -1125,10 +1151,10 @@ name (privacy_modifier$ pm) (bit\encoded strict_fp?) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type) (code.format (pre_walk_replace replacer body))))) @@ -1137,10 +1163,10 @@ (spaced (list "abstract" name (privacy_modifier$ pm) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type)))) (#NativeMethod type_vars arg_decls return_type exs) @@ -1148,10 +1174,10 @@ (spaced (list "native" name (privacy_modifier$ pm) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type)))) )) @@ -1209,19 +1235,19 @@ (do meta.monad [current_module meta.current_module_name .let [fully_qualified_class_name (format (safe current_module) "." full_class_name) - field_parsers (list\map (field_parser fully_qualified_class_name) fields) - method_parsers (list\map (method_parser (product.right class_decl) fully_qualified_class_name) methods) + field_parsers (list\each (field_parser fully_qualified_class_name) fields) + method_parsers (list\each (method_parser (product.right class_decl) fully_qualified_class_name) methods) replacer (parser_replacer (list\mix <>.either (<>.failure "") - (list\compose field_parsers method_parsers))) + (list\composite field_parsers method_parsers))) def_code (format "jvm class:" (spaced (list (class_decl$ class_decl) (super_class_decl$ super) - (with_brackets (spaced (list\map super_class_decl$ interfaces))) + (with_brackets (spaced (list\each super_class_decl$ interfaces))) (inheritance_modifier$ im) - (with_brackets (spaced (list\map annotation$ annotations))) - (with_brackets (spaced (list\map field_decl$ fields))) - (with_brackets (spaced (list\map (method_def$ replacer super) methods))))))]] + (with_brackets (spaced (list\each annotation$ annotations))) + (with_brackets (spaced (list\each field_decl$ fields))) + (with_brackets (spaced (list\each (method_def$ replacer super) methods))))))]] (in (list (` ((~ (code.text def_code)))))))) (syntax: .public (interface: [class_decl ..class_decl^ @@ -1235,9 +1261,9 @@ ([] foo [boolean String] void #throws [Exception])))} (let [def_code (format "jvm interface:" (spaced (list (class_decl$ class_decl) - (with_brackets (spaced (list\map super_class_decl$ supers))) - (with_brackets (spaced (list\map annotation$ annotations))) - (spaced (list\map method_decl$ members)))))] + (with_brackets (spaced (list\each super_class_decl$ supers))) + (with_brackets (spaced (list\each annotation$ annotations))) + (spaced (list\each method_decl$ members)))))] (in (list (` ((~ (code.text def_code)))))) )) @@ -1261,9 +1287,9 @@ )} (let [def_code (format "jvm anon-class:" (spaced (list (super_class_decl$ super) - (with_brackets (spaced (list\map super_class_decl$ interfaces))) - (with_brackets (spaced (list\map constructor_arg$ constructor_args))) - (with_brackets (spaced (list\map (method_def$ function.identity super) methods))))))] + (with_brackets (spaced (list\each super_class_decl$ interfaces))) + (with_brackets (spaced (list\each constructor_arg$ constructor_args))) + (with_brackets (spaced (list\each (method_def$ function.identity super) methods))))))] (in (list (` ((~ (code.text def_code)))))))) (syntax: .public (null []) @@ -1351,12 +1377,12 @@ (ClassName::method2 arg3 arg4 arg5)))} (with_identifiers [g!obj] (in (list (` (let [(~ g!obj) (~ obj)] - (exec (~+ (list\map (complete_call$ g!obj) methods)) + (exec (~+ (list\each (complete_call$ g!obj) methods)) (~ g!obj)))))))) (def: (class_import$ [full_name params]) (-> Class_Declaration Code) - (let [params' (list\map (|>> product.left code.local_identifier) params)] + (let [params' (list\each (|>> product.left code.local_identifier) params)] (` (def: (~ (code.identifier ["" full_name])) {#..jvm_class (~ (code.text full_name))} Type @@ -1368,7 +1394,7 @@ (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter)) (case member (#ConstructorDecl [commons _]) - (list\compose class_tvars (value@ #import_member_tvars commons)) + (list\composite class_tvars (value@ #import_member_tvars commons)) (#MethodDecl [commons _]) (case (value@ #import_member_kind commons) @@ -1376,7 +1402,7 @@ (value@ #import_member_tvars commons) _ - (list\compose class_tvars (value@ #import_member_tvars commons))) + (list\composite class_tvars (value@ #import_member_tvars commons))) _ class_tvars)) @@ -1387,22 +1413,22 @@ (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) (let [(^slots [#import_member_tvars #import_member_args]) commons] (do {! meta.monad} - [arg_inputs (monad.map ! - (: (-> [Bit GenericType] (Meta [Bit Code])) - (function (_ [maybe? _]) - (with_identifiers [arg_name] - (in [maybe? arg_name])))) - import_member_args) + [arg_inputs (monad.each ! + (: (-> [Bit GenericType] (Meta [Bit Code])) + (function (_ [maybe? _]) + (with_identifiers [arg_name] + (in [maybe? arg_name])))) + import_member_args) .let [arg_classes (: (List Text) - (list\map (|>> product.right (simple_class$ (list\compose type_params import_member_tvars))) - import_member_args)) - arg_types (list\map (: (-> [Bit GenericType] Code) - (function (_ [maybe? arg]) - (let [arg_type (class_type (value@ #import_member_mode commons) type_params arg)] - (if maybe? - (` (Maybe (~ arg_type))) - arg_type)))) - import_member_args)]] + (list\each (|>> product.right (simple_class$ (list\composite type_params import_member_tvars))) + import_member_args)) + arg_types (list\each (: (-> [Bit GenericType] Code) + (function (_ [maybe? arg]) + (let [arg_type (class_type (value@ #import_member_mode commons) type_params arg)] + (if maybe? + (` (Maybe (~ arg_type))) + arg_type)))) + import_member_args)]] (in [arg_inputs arg_classes arg_types]))) _ @@ -1478,12 +1504,12 @@ (def: (jvm_extension_inputs mode classes inputs) (-> Primitive_Mode (List Text) (List [Bit Code]) (List Code)) (|> inputs - (list\map (function (_ [maybe? input]) - (if maybe? - (` ((~! !!!) (~ (un_quote input)))) - (un_quote input)))) + (list\each (function (_ [maybe? input]) + (if maybe? + (` ((~! !!!) (~ (un_quote input)))) + (un_quote input)))) (list.zipped/2 classes) - (list\map (auto_convert_input mode)))) + (list\each (auto_convert_input mode)))) (def: (import_name format class member) (-> Text Text Text Text) @@ -1493,9 +1519,9 @@ (def: syntax_inputs (-> (List Code) (List Code)) - (|>> (list\map (function (_ name) - (list name (` (~! <code>.any))))) - list\join)) + (|>> (list\each (function (_ name) + (list name (` (~! <code>.any))))) + list\conjoint)) (def: (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format) (-> (List Type_Parameter) Class_Kind Class_Declaration [(List [Bit Code]) (List Text) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) @@ -1503,7 +1529,7 @@ full_name (safe full_name) all_params (|> (member_type_vars class_tvars member) (list.only free_type_param?) - (list\map lux_type_parameter))] + (list\each lux_type_parameter))] (case member (#EnumDecl enum_members) (do {! meta.monad} @@ -1515,7 +1541,7 @@ _ (let [=class_tvars (|> class_tvars (list.only free_type_param?) - (list\map lux_type_parameter))] + (list\each lux_type_parameter))] (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)])))))) getter_interop (: (-> Text Code) (function (_ name) @@ -1523,7 +1549,7 @@ (` (def: (~ getter_name) (~ enum_type) ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]] - (in (list\map getter_interop enum_members))) + (in (list\each getter_interop enum_members))) (#ConstructorDecl [commons _]) (do meta.monad @@ -1534,7 +1560,7 @@ (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] - (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\map product.right arg_function_inputs)))]) + (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop))))))))) (#MethodDecl [commons method]) @@ -1561,13 +1587,13 @@ ))) jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" import_method_name ":" (text.interposed "," arg_classes))) jvm_interop (|> [(simple_class$ (list) (value@ #import_method_return method)) - (` ((~ jvm_extension) (~+ (list\map un_quote object_ast)) + (` ((~ jvm_extension) (~+ (list\each un_quote object_ast)) (~+ (jvm_extension_inputs (value@ #import_member_mode commons) arg_classes arg_function_inputs))))] (auto_convert_output (value@ #import_member_mode commons)) (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] - (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\map product.right arg_function_inputs))) + (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1582,7 +1608,7 @@ tvar_asts (: (List Code) (|> class_tvars (list.only free_type_param?) - (list\map lux_type_parameter))) + (list\each lux_type_parameter))) getter_name (code.identifier ["" (..import_name import_format method_prefix import_field_name)]) setter_name (code.identifier ["" (..import_name import_format method_prefix (format import_field_name "!"))])] getter_interop (with_identifiers [g!obj] @@ -1715,11 +1741,11 @@ (do {! meta.monad} [kind (class_kind class_decl) =members (|> bundles - (list\map (function (_ [import_format members]) - (list\map (|>> [import_format]) members))) + (list\each (function (_ [import_format members]) + (list\each (|>> [import_format]) members))) list.together - (monad.map ! (member_import$ (product.right class_decl) kind class_decl)))] - (in (list& (class_import$ class_decl) (list\join =members))))) + (monad.each ! (member_import$ (product.right class_decl) kind class_decl)))] + (in (list& (class_import$ class_decl) (list\conjoint =members))))) (syntax: .public (array [type (..generic_type^ (list)) size <code>.any]) diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index 453f2c59e..82208f783 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -23,11 +23,11 @@ ["." code] ["." template]]]]) -(abstract: .public (Object brand) Any) +(abstract: .public (Object brand) {} Any) (template [<name>] [(with_expansions [<brand> (template.identifier [<name> "'"])] - (abstract: .public <brand> Any) + (abstract: .public <brand> {} Any) (type: .public <name> (..Object <brand>)))] @@ -97,8 +97,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -119,8 +120,9 @@ ..common_method))) (type: Member - (#Field Field) - (#Method Method)) + (Variant + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -132,8 +134,8 @@ (def: input_variables (-> (List Nullable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nullable? type]]) - [nullable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nullable? type]]) + [nullable? (|> idx %.nat code.local_identifier)])))) (def: (nullable_type [nullable? type]) (-> Nullable Code) @@ -165,9 +167,10 @@ (.panic! "Null is an invalid value!")))))) (type: Import - (#Class Text (Maybe Alias) Text (List Member)) - (#Function Static_Method) - (#Constant Field)) + (Variant + (#Class Text (Maybe Alias) Text (List Member)) + (#Function Static_Method) + (#Constant Field))) (def: import (Parser Import) @@ -219,8 +222,8 @@ (-> Code Code Code (List Nullable) Bit Bit Nullable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nullable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nullable_type inputsT))] (~ (|> (nullable_type outputT) (try_type try?) (io_type io?)))) @@ -230,7 +233,7 @@ (without_null g!temp outputT) (` ("php apply" (:as ..Function (~ source)) - (~+ (list\map (with_null g!temp) g!inputs))))))))))) + (~+ (list\each (with_null g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) (with_identifiers [g!temp] @@ -247,54 +250,54 @@ class_import (` ("php constant" (~ (code.text class))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text class)))))) - (list\map (function (_ member) - (case member - (#Field [static? field alias fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (nullable_type fieldT)) - ("php constant" (~ (code.text (%.format class "::" field)))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (-> (~ g!type) - (~ (nullable_type fieldT))) - (:expected - (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field)) - (:as (..Object .Any) (~ g!object)))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (` ("php object get" (~ (code.text method)) - (:as (..Object .Any) - ("php constant" (~ (code.text (%.format class "::" method))))))) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (-> [(~+ (list\map nullable_type inputsT))] - (~ g!type) - (~ (|> (nullable_type outputT) - (try_type try?) - (io_type io?)))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_null g!temp outputT) - (` ("php object do" - (~ (code.text method)) - (~ g!object) - (~+ (list\map (with_null g!temp) g!inputs))))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Field [static? field alias fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (nullable_type fieldT)) + ("php constant" (~ (code.text (%.format class "::" field)))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (nullable_type fieldT))) + (:expected + (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field)) + (:as (..Object .Any) (~ g!object)))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (` ("php object get" (~ (code.text method)) + (:as (..Object .Any) + ("php constant" (~ (code.text (%.format class "::" method))))))) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\each nullable_type inputsT))] + (~ g!type) + (~ (|> (nullable_type outputT) + (try_type try?) + (io_type io?)))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_null g!temp outputT) + (` ("php object do" + (~ (code.text method)) + (~ g!object) + (~+ (list\each (with_null g!temp) g!inputs))))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (let [imported (` ("php constant" (~ (code.text name))))] diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index e3eea52e2..3dbd3cc5a 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -92,8 +92,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -114,9 +115,10 @@ ..common_method))) (type: Member - (#Constructor Constructor) - (#Field Field) - (#Method Method)) + (Variant + (#Constructor Constructor) + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -129,8 +131,8 @@ (def: input_variables (-> (List Noneable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [noneable? type]]) - [noneable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [noneable? type]]) + [noneable? (|> idx %.nat code.local_identifier)])))) (def: (noneable_type [noneable? type]) (-> Noneable Code) @@ -162,8 +164,9 @@ (.panic! "None is an invalid value!")))))) (type: Import - (#Class [Text Text (List Member)]) - (#Function Static_Method)) + (Variant + (#Class [Text Text (List Member)]) + (#Function Static_Method))) (def: import (Parser Import) @@ -201,8 +204,8 @@ (-> Code Code Code (List Noneable) Bit Bit Noneable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map noneable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each noneable_type inputsT))] (~ (|> (noneable_type outputT) (try_type try?) (io_type io?)))) @@ -212,7 +215,7 @@ (without_none g!temp outputT) (` ("python apply" (:as ..Function (~ source)) - (~+ (list\map (with_none g!temp) g!inputs))))))))))) + (~+ (list\each (with_none g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) {#.doc (example "Easily import types, methods, functions and constants." @@ -261,65 +264,65 @@ (` ("python import" (~ (code.text class)))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text real_class)))))) - (list\map (function (_ member) - (case member - (#Constructor inputsT) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify "new")) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map noneable_type inputsT))] - (~ g!type)) - (:expected - ("python apply" - (:as ..Function (~ imported)) - (~+ (list\map (with_none g!temp) g!inputs))))))) - - (#Field [static? field fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify field)) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (noneable_type fieldT)) - ("python object get" (~ (code.text field)) - (:as (..Object .Any) (~ imported))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (-> (~ g!type) - (~ (noneable_type fieldT))) - (:expected - (~ (without_none g!temp fieldT (` ("python object get" (~ (code.text field)) - (:as (..Object .Any) (~ g!object)))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (` ("python object get" (~ (code.text method)) - (:as (..Object .Any) (~ imported)))) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (-> [(~+ (list\map noneable_type inputsT))] - (~ g!type) - (~ (|> (noneable_type outputT) - (try_type try?) - (io_type io?)))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_none g!temp outputT) - (` ("python object do" - (~ (code.text method)) - (~ g!object) - (~+ (list\map (with_none g!temp) g!inputs))))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Constructor inputsT) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify "new")) + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each noneable_type inputsT))] + (~ g!type)) + (:expected + ("python apply" + (:as ..Function (~ imported)) + (~+ (list\each (with_none g!temp) g!inputs))))))) + + (#Field [static? field fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify field)) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (noneable_type fieldT)) + ("python object get" (~ (code.text field)) + (:as (..Object .Any) (~ imported))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (noneable_type fieldT))) + (:expected + (~ (without_none g!temp fieldT (` ("python object get" (~ (code.text field)) + (:as (..Object .Any) (~ g!object)))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (` ("python object get" (~ (code.text method)) + (:as (..Object .Any) (~ imported)))) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\each noneable_type inputsT))] + (~ g!type) + (~ (|> (noneable_type outputT) + (try_type try?) + (io_type io?)))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_none g!temp outputT) + (` ("python object do" + (~ (code.text method)) + (~ g!object) + (~+ (list\each (with_none g!temp) g!inputs))))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (in (list (..make_function (code.local_identifier (maybe.else name alias)) diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux index c01b88565..2ba821582 100644 --- a/stdlib/source/library/lux/ffi.rb.lux +++ b/stdlib/source/library/lux/ffi.rb.lux @@ -99,8 +99,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -121,8 +122,9 @@ ..common_method))) (type: Member - (#Field Field) - (#Method Method)) + (Variant + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -134,8 +136,8 @@ (def: input_variables (-> (List Nilable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nilable? type]]) - [nilable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nilable? type]]) + [nilable? (|> idx %.nat code.local_identifier)])))) (def: (nilable_type [nilable? type]) (-> Nilable Code) @@ -167,9 +169,10 @@ (.panic! "Nil is an invalid value!")))))) (type: Import - (#Class Text (Maybe Alias) Text (List Member)) - (#Function Static_Method) - (#Constant Field)) + (Variant + (#Class Text (Maybe Alias) Text (List Member)) + (#Function Static_Method) + (#Constant Field))) (def: import (Parser [(Maybe Text) Import]) @@ -214,8 +217,8 @@ (-> Code Code Code (List Nilable) Bit Bit Nilable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nilable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nilable_type inputsT))] (~ (|> (nilable_type outputT) (try_type try?) (io_type io?)))) @@ -225,7 +228,7 @@ (without_nil g!temp outputT) (` ("ruby apply" (:as ..Function (~ source)) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: [[?module import] ..import]) {#.doc (example "Easily import types, methods, functions and constants." @@ -268,58 +271,58 @@ class_import (` ("ruby constant" (~ (code.text class))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text class)))))) - (list\map (function (_ member) - (case member - (#Field [static? field alias fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (nilable_type fieldT)) - (.exec - (~+ module_import) - ("ruby constant" (~ (code.text (%.format class "::" field))))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (-> (~ g!type) - (~ (nilable_type fieldT))) - (:expected - (~ (without_nil g!temp fieldT (` ("ruby object get" (~ (code.text field)) - (:as (..Object .Any) (~ g!object)))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (` ("ruby object get" (~ (code.text method)) - (:as (..Object .Any) - (.exec - (~+ module_import) - ("ruby constant" (~ (code.text (%.format class "::" method)))))))) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (-> [(~+ (list\map nilable_type inputsT))] - (~ g!type) - (~ (|> (nilable_type outputT) - (try_type try?) - (io_type io?)))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_nil g!temp outputT) - (` ("ruby object do" - (~ (code.text method)) - (~ g!object) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Field [static? field alias fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (nilable_type fieldT)) + (.exec + (~+ module_import) + ("ruby constant" (~ (code.text (%.format class "::" field))))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (nilable_type fieldT))) + (:expected + (~ (without_nil g!temp fieldT (` ("ruby object get" (~ (code.text field)) + (:as (..Object .Any) (~ g!object)))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (` ("ruby object get" (~ (code.text method)) + (:as (..Object .Any) + (.exec + (~+ module_import) + ("ruby constant" (~ (code.text (%.format class "::" method)))))))) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\each nilable_type inputsT))] + (~ g!type) + (~ (|> (nilable_type outputT) + (try_type try?) + (io_type io?)))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_nil g!temp outputT) + (` ("ruby object do" + (~ (code.text method)) + (~ g!object) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (let [imported (` (.exec diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index ab2e6cdff..675aadcd1 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -23,11 +23,11 @@ ["." code] ["." template]]]]) -(abstract: .public (Object brand) Any) +(abstract: .public (Object brand) {} Any) (template [<name>] [(with_expansions [<brand> (template.identifier [<name> "'"])] - (abstract: .public <brand> Any) + (abstract: .public <brand> {} Any) (type: .public <name> (..Object <brand>)))] @@ -106,8 +106,8 @@ (def: input_variables (-> (List Nilable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nilable? type]]) - [nilable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nilable? type]]) + [nilable? (|> idx %.nat code.local_identifier)])))) (def: (nilable_type [nilable? type]) (-> Nilable Code) @@ -139,8 +139,9 @@ (.panic! "Nil is an invalid value!")))))) (type: Import - (#Function Common_Method) - (#Constant Field)) + (Variant + (#Function Common_Method) + (#Constant Field))) (def: import (Parser Import) @@ -186,8 +187,8 @@ (-> Code Code Code (List Nilable) Bit Bit Nilable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nilable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nilable_type inputsT))] (~ (|> (nilable_type outputT) (try_type try?) (io_type io?)))) @@ -197,7 +198,7 @@ (without_nil g!temp outputT) (` ("scheme apply" (:as ..Function (~ source)) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) (with_identifiers [g!temp] diff --git a/stdlib/source/library/lux/locale.lux b/stdlib/source/library/lux/locale.lux index 39befd846..ac8c05384 100644 --- a/stdlib/source/library/lux/locale.lux +++ b/stdlib/source/library/lux/locale.lux @@ -28,10 +28,10 @@ (-> Language (Maybe Territory) (Maybe Encoding) Locale) (:abstraction (format (language.code language) (|> territory - (maybe\map (|>> territory.long_code (format ..territory_separator))) + (maybe\each (|>> territory.long_code (format ..territory_separator))) (maybe.else "")) (|> encoding - (maybe\map (|>> encoding.name (format ..encoding_separator))) + (maybe\each (|>> encoding.name (format ..encoding_separator))) (maybe.else ""))))) (def: .public code @@ -40,7 +40,7 @@ (def: .public hash (Hash Locale) - (\ hash.functor map ..code text.hash)) + (\ hash.functor each ..code text.hash)) (def: .public equivalence (Equivalence Locale) diff --git a/stdlib/source/library/lux/locale/language.lux b/stdlib/source/library/lux/locale/language.lux index 1739135aa..cb4314c59 100644 --- a/stdlib/source/library/lux/locale/language.lux +++ b/stdlib/source/library/lux/locale/language.lux @@ -15,8 +15,9 @@ (abstract: .public Language {} - {#name Text - #code Text} + (Record + {#name Text + #code Text}) (template [<name> <tag>] [(def: .public <name> diff --git a/stdlib/source/library/lux/locale/territory.lux b/stdlib/source/library/lux/locale/territory.lux index c4172993a..4b2dfd4b5 100644 --- a/stdlib/source/library/lux/locale/territory.lux +++ b/stdlib/source/library/lux/locale/territory.lux @@ -15,10 +15,11 @@ (abstract: .public Territory {} - {#name Text - #short Text - #long Text - #code Nat} + (Record + {#name Text + #short Text + #long Text + #code Nat}) (template [<name> <field> <type>] [(def: .public <name> diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index cdd76278b..f98f8c452 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -45,8 +45,8 @@ (do {! //.monad} [top_level_expansion ((:as Macro' macro) args)] (|> top_level_expansion - (monad.map //.monad expansion) - (\ ! map list\join))) + (monad.each //.monad expansion) + (\ ! each list\conjoint))) #.None (\ //.monad in (list syntax)))) @@ -64,39 +64,39 @@ (#.Some macro) (do //.monad [expansion ((:as Macro' macro) args) - expansion' (monad.map //.monad full_expansion expansion)] - (in (list\join expansion'))) + expansion' (monad.each //.monad full_expansion expansion)] + (in (list\conjoint expansion'))) #.None (do //.monad - [parts' (monad.map //.monad full_expansion (list& (code.identifier name) args))] - (in (list (code.form (list\join parts'))))))) + [parts' (monad.each //.monad full_expansion (list& (code.identifier name) args))] + (in (list (code.form (list\conjoint parts'))))))) [_ (#.Form (#.Item [harg targs]))] (do //.monad [harg+ (full_expansion harg) - targs+ (monad.map //.monad full_expansion targs)] - (in (list (code.form (list\compose harg+ (list\join (: (List (List Code)) targs+))))))) + targs+ (monad.each //.monad full_expansion targs)] + (in (list (code.form (list\composite harg+ (list\conjoint (: (List (List Code)) targs+))))))) [_ (#.Tuple members)] (do //.monad - [members' (monad.map //.monad full_expansion members)] - (in (list (code.tuple (list\join members'))))) + [members' (monad.each //.monad full_expansion members)] + (in (list (code.tuple (list\conjoint members'))))) [_ (#.Record members)] (|> members - (monad.map //.monad - (function (_ [left right]) - (do //.monad - [left (full_expansion left) - right (full_expansion right)] - (case [left right] - [(#.Item left #.End) (#.Item right #.End)] - (in [left right]) - - _ - (//.failure "Record members must expand into singletons."))))) - (\ //.monad map (|>> code.record list))) + (monad.each //.monad + (function (_ [left right]) + (do //.monad + [left (full_expansion left) + right (full_expansion right)] + (case [left right] + [(#.Item left #.End) (#.Item right #.End)] + (in [left right]) + + _ + (//.failure "Record members must expand into singletons."))))) + (\ //.monad each (|>> code.record list))) _ (\ //.monad in (list syntax)))) @@ -107,7 +107,7 @@ [id //.seed] (in (|> id (\ nat.decimal encoded) - ($_ text\compose "__gensym__" prefix) + ($_ text\composite "__gensym__" prefix) [""] code.identifier)))) (def: (local_identifier ast) @@ -117,22 +117,22 @@ (\ //.monad in name) _ - (//.failure (text\compose "Code is not a local identifier: " (code.format ast))))) + (//.failure (text\composite "Code is not a local identifier: " (code.format ast))))) (def: .public wrong_syntax_error (-> Name Text) (|>> name\encoded - (text.prefix (text\compose "Wrong syntax for " text.\'')) - (text.suffix (text\compose text.\'' ".")))) + (text.prefix (text\composite "Wrong syntax for " text.\'')) + (text.suffix (text\composite text.\'' ".")))) (macro: .public (with_identifiers tokens) (case tokens (^ (list [_ (#.Tuple identifiers)] body)) (do {! //.monad} - [identifier_names (monad.map ! ..local_identifier identifiers) - .let [identifier_defs (list\join (list\map (: (-> Text (List Code)) - (function (_ name) (list (code.identifier ["" name]) (` (..identifier (~ (code.text name))))))) - identifier_names))]] + [identifier_names (monad.each ! ..local_identifier identifiers) + .let [identifier_defs (list\conjoint (list\each (: (-> Text (List Code)) + (function (_ name) (list (code.identifier ["" name]) (` (..identifier (~ (code.text name))))))) + identifier_names))]] (in (list (` ((~! do) (~! //.monad) [(~+ identifier_defs)] (~ body)))))) @@ -171,9 +171,9 @@ (do //.monad [location //.location output (<func> token) - .let [_ ("lux io log" ($_ text\compose (name\encoded macro_name) " " (location.format location))) - _ (list\map (|>> code.format "lux io log") - output) + .let [_ ("lux io log" ($_ text\composite (name\encoded macro_name) " " (location.format location))) + _ (list\each (|>> code.format "lux io log") + output) _ ("lux io log" "")]] (in (if omit? (list) diff --git a/stdlib/source/library/lux/macro/code.lux b/stdlib/source/library/lux/macro/code.lux index 5de323722..b27e28c8c 100644 --- a/stdlib/source/library/lux/macro/code.lux +++ b/stdlib/source/library/lux/macro/code.lux @@ -108,17 +108,17 @@ (text.format value) [_ (#.Tag name)] - (text\compose "#" (\ name.codec encoded name)) + (text\composite "#" (\ name.codec encoded name)) (^template [<tag> <open> <close>] [[_ (<tag> members)] - ($_ text\compose + ($_ text\composite <open> (list\mix (function (_ next prev) (let [next (format next)] (if (text\= "" prev) next - ($_ text\compose prev " " next)))) + ($_ text\composite prev " " next)))) "" members) <close>)]) @@ -126,13 +126,13 @@ [#.Tuple "[" "]"]) [_ (#.Record pairs)] - ($_ text\compose + ($_ text\composite "{" (list\mix (function (_ [left right] prev) - (let [next ($_ text\compose (format left) " " (format right))] + (let [next ($_ text\composite (format left) " " (format right))] (if (text\= "" prev) next - ($_ text\compose prev " " next)))) + ($_ text\composite prev " " next)))) "" pairs) "}") @@ -145,15 +145,15 @@ (case ast (^template [<tag>] [[location (<tag> parts)] - [location (<tag> (list\map (replaced original substitute) parts))]]) + [location (<tag> (list\each (replaced original substitute) parts))]]) ([#.Form] [#.Tuple]) [location (#.Record parts)] - [location (#.Record (list\map (function (_ [left right]) - [(replaced original substitute left) - (replaced original substitute right)]) - parts))] + [location (#.Record (list\each (function (_ [left right]) + [(replaced original substitute left) + (replaced original substitute right)]) + parts))] _ ast))) diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index d17ae7728..68e22410e 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -85,7 +85,7 @@ ("lux macro" (function (_ _) (do {! meta.monad} - [_ (monad.map ! ..pop_one macros) + [_ (monad.each ! ..pop_one macros) _ (..pop_one self) compiler meta.compiler_state] (in (case (value@ #.expected compiler) @@ -98,9 +98,9 @@ (def: .public (push macros) (-> (List [Name Macro]) (Meta Code)) (do meta.monad - [_ (monad.map meta.monad ..push_one macros) + [_ (monad.each meta.monad ..push_one macros) seed meta.seed g!pop (//.identifier "pop") _ (let [g!pop (: Name ["" (//code.format g!pop)])] - (..push_one [g!pop (..pop_all (list\map product.left macros) g!pop)]))] + (..push_one [g!pop (..pop_all (list\each product.left macros) g!pop)]))] (in (` ((~ g!pop)))))) diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 4caed5bd7..c77d67feb 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -31,7 +31,7 @@ (#try.Success [tokens output]) (#try.Failure error) - (#try.Failure ($_ text\compose + (#try.Failure ($_ text\composite "Failed to parse: " (code.format binding) text.new_line error))))) @@ -73,22 +73,22 @@ [_ (if (|> args list.size nat.even?) (in []) (meta.failure "Syntax pattern expects pairs of bindings and code-parsers.")) - vars+parsers (monad.map ! - (: (-> [Code Code] (Meta [Code Code])) - (function (_ [var parser]) - (with_expansions [<default> (in [var - (` ((~! ..self_documenting) (' (~ var)) - (~ parser)))])] - (case var - [_ (#.Identifier ["" _])] - <default> + vars+parsers (monad.each ! + (: (-> [Code Code] (Meta [Code Code])) + (function (_ [var parser]) + (with_expansions [<default> (in [var + (` ((~! ..self_documenting) (' (~ var)) + (~ parser)))])] + (case var + [_ (#.Identifier ["" _])] + <default> - [_ (#.Identifier _)] - (in [var parser]) + [_ (#.Identifier _)] + (in [var parser]) - _ - <default>)))) - (list.pairs args)) + _ + <default>)))) + (list.pairs args)) this_module meta.current_module_name .let [g!state (code.identifier ["" "*lux*"]) error_msg (code.text (macro.wrong_syntax_error [this_module name]))]] diff --git a/stdlib/source/library/lux/macro/syntax/annotations.lux b/stdlib/source/library/lux/macro/syntax/annotations.lux index 29ef222c2..acfaabd37 100644 --- a/stdlib/source/library/lux/macro/syntax/annotations.lux +++ b/stdlib/source/library/lux/macro/syntax/annotations.lux @@ -31,7 +31,7 @@ (def: .public format (-> Annotations Code) (let [entry (product.then code.tag function.identity)] - (|>> (list\map entry) + (|>> (list\each entry) code.record))) (def: .public parser diff --git a/stdlib/source/library/lux/macro/syntax/check.lux b/stdlib/source/library/lux/macro/syntax/check.lux index 8c045da18..18b0049ee 100644 --- a/stdlib/source/library/lux/macro/syntax/check.lux +++ b/stdlib/source/library/lux/macro/syntax/check.lux @@ -18,8 +18,9 @@ "lux check") (type: .public Check - {#type Code - #value Code}) + (Record + {#type Code + #value Code})) (def: .public equivalence (Equivalence Check) diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index 004398916..ae6ae3ee7 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -15,8 +15,9 @@ ["." code]]]]) (type: .public Declaration - {#name Text - #arguments (List Text)}) + (Record + {#name Text + #arguments (List Text)})) (def: .public equivalence (Equivalence Declaration) @@ -40,4 +41,4 @@ g!name arguments - (` ((~ g!name) (~+ (list\map code.local_identifier arguments))))))) + (` ((~ g!name) (~+ (list\each code.local_identifier arguments))))))) diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index 601f44283..ee7238603 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -26,11 +26,12 @@ ["#." check (#+ Check)]]) (type: .public Definition - {#name Text - #value (Either Check - Code) - #anns Annotations - #export? Bit}) + (Record + {#name Text + #value (Either Check + Code) + #anns Annotations + #export? Bit})) (def: .public equivalence (Equivalence Definition) diff --git a/stdlib/source/library/lux/macro/syntax/input.lux b/stdlib/source/library/lux/macro/syntax/input.lux index 58675bbf7..47bf4d6ac 100644 --- a/stdlib/source/library/lux/macro/syntax/input.lux +++ b/stdlib/source/library/lux/macro/syntax/input.lux @@ -12,8 +12,9 @@ ["." code]]]]) (type: .public Input - {#binding Code - #type Code}) + (Record + {#binding Code + #type Code})) (def: .public equivalence (Equivalence Input) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index aea5bfb5c..65b4f96ba 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -36,12 +36,12 @@ body <code>.any]) (do {! meta.monad} [g!locals (|> locals - (list\map //.identifier) + (list\each //.identifier) (monad.all !))] (in (list (` (.with_expansions [(~+ (|> (list.zipped/2 locals g!locals) - (list\map (function (_ [name identifier]) - (list (code.local_identifier name) (as_is identifier)))) - list\join))] + (list\each (function (_ [name identifier]) + (list (code.local_identifier name) (as_is identifier)))) + list\conjoint))] (~ body))))))) (def: (name_side module_side? parser) @@ -68,11 +68,11 @@ full_tag (<>.either <code>.local_tag full_tag)) - (<>\map bit\encoded <code>.bit) - (<>\map nat\encoded <code>.nat) - (<>\map int\encoded <code>.int) - (<>\map rev\encoded <code>.rev) - (<>\map frac\encoded <code>.frac) + (<>\each bit\encoded <code>.bit) + (<>\each nat\encoded <code>.nat) + (<>\each int\encoded <code>.int) + (<>\each rev\encoded <code>.rev) + (<>\each frac\encoded <code>.frac) ))) (def: (part module_side?) @@ -113,24 +113,25 @@ (^template [<tag>] [[meta (<tag> elems)] - [meta (<tag> (list\map (applied env) elems))]]) + [meta (<tag> (list\each (applied env) elems))]]) ([#.Tuple] [#.Form]) [meta (#.Record members)] - [meta (#.Record (list\map (: (-> [Code Code] [Code Code]) - (function (_ [key value]) - [(applied env key) - (applied env value)])) - members))] + [meta (#.Record (list\each (: (-> [Code Code] [Code Code]) + (function (_ [key value]) + [(applied env key) + (applied env value)])) + members))] _ template)) (type: Local - {#name Text - #parameters (List Text) - #template (List Code)}) + (Record + {#name Text + #parameters (List Text) + #template (List Code)})) (exception: .public (irregular_arguments {expected Nat} {actual Nat}) (exception.report @@ -147,7 +148,7 @@ (.let [environment (: Environment (|> (list.zipped/2 parameters inputs) (dictionary.of_list text.hash)))] - (#.Right [compiler (list\map (..applied environment) template)])) + (#.Right [compiler (list\each (..applied environment) template)])) (exception.except ..irregular_arguments [parameters_amount inputs_amount])))))) (def: local @@ -172,10 +173,10 @@ (#.Some _) true)]))) - g!pop (local.push (list\map (function (_ local) - [[here_name (value@ #name local)] - (..macro local)]) - locals))] + g!pop (local.push (list\each (function (_ local) + [[here_name (value@ #name local)] + (..macro local)]) + locals))] (if expression? (//.with_identifiers [g!body] (in (list (` (.let [(~ g!body) (~ body)] diff --git a/stdlib/source/library/lux/math/infix.lux b/stdlib/source/library/lux/math/infix.lux index d2a210e7b..c2847d72e 100644 --- a/stdlib/source/library/lux/math/infix.lux +++ b/stdlib/source/library/lux/math/infix.lux @@ -19,22 +19,23 @@ ["i" int]]]]]) (type: #rec Infix - (#Const Code) - (#Call (List Code)) - (#Unary Code Infix) - (#Binary Infix Code Infix)) + (Variant + (#Const Code) + (#Call (List Code)) + (#Unary Code Infix) + (#Binary Infix Code Infix))) (def: literal (Parser Code) ($_ <>.either - (<>\map code.bit <code>.bit) - (<>\map code.nat <code>.nat) - (<>\map code.int <code>.int) - (<>\map code.rev <code>.rev) - (<>\map code.frac <code>.frac) - (<>\map code.text <code>.text) - (<>\map code.identifier <code>.identifier) - (<>\map code.tag <code>.tag))) + (<>\each code.bit <code>.bit) + (<>\each code.nat <code>.nat) + (<>\each code.int <code>.int) + (<>\each code.rev <code>.rev) + (<>\each code.frac <code>.frac) + (<>\each code.text <code>.text) + (<>\each code.identifier <code>.identifier) + (<>\each code.tag <code>.tag))) (def: expression (Parser Infix) diff --git a/stdlib/source/library/lux/math/logic/continuous.lux b/stdlib/source/library/lux/math/logic/continuous.lux index 6f7e4d116..57f3572b5 100644 --- a/stdlib/source/library/lux/math/logic/continuous.lux +++ b/stdlib/source/library/lux/math/logic/continuous.lux @@ -20,7 +20,7 @@ (Monoid Rev) (def: identity <identity>) - (def: compose <name>))] + (def: composite <name>))] [or /.max disjunction ..false] [and /.min conjunction ..true] diff --git a/stdlib/source/library/lux/math/logic/fuzzy.lux b/stdlib/source/library/lux/math/logic/fuzzy.lux index 5a21a6e39..4c3745470 100644 --- a/stdlib/source/library/lux/math/logic/fuzzy.lux +++ b/stdlib/source/library/lux/math/logic/fuzzy.lux @@ -22,7 +22,7 @@ (implementation: .public functor (contravariant.Functor Fuzzy) - (def: (map f fb) + (def: (each f fb) (|>> f fb))) (template [<name> <verdict>] diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index 9a94151c4..acfdbab2d 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -30,8 +30,9 @@ (abstract: .public (Mod m) {} - {#modulus (Modulus m) - #value Int} + (Record + {#modulus (Modulus m) + #value Int}) (def: .public (modular modulus value) (All [%] (-> (Modulus %) Int (Mod %))) @@ -66,7 +67,7 @@ (def: (encoded modular) (let [[_ value] (:representation modular)] - ($_ text\compose + ($_ text\composite (i\encoded value) ..separator (i\encoded (//.divisor expected))))) @@ -125,7 +126,7 @@ (def: identity (..modular modulus <identity>)) - (def: compose + (def: composite <composition>))] [..+ +0 addition] diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index 324b84d43..b3418da98 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -23,8 +23,9 @@ ["." int]]]]]) (type: .public Complex - {#real Frac - #imaginary Frac}) + (Record + {#real Frac + #imaginary Frac})) (syntax: .public (complex [real <code>.any ?imaginary (<>.maybe <code>.any)]) @@ -292,16 +293,16 @@ nth_phi (|> input ..argument (f./ r_nth)) slice (|> math.pi (f.* +2.0) (f./ r_nth))] (|> (list.indices nth) - (list\map (function (_ nth') - (let [inner (|> nth' .int int.frac - (f.* slice) - (f.+ nth_phi)) - real (f.* nth_root_of_abs - (math.cos inner)) - imaginary (f.* nth_root_of_abs - (math.sin inner))] - {#real real - #imaginary imaginary}))))))) + (list\each (function (_ nth') + (let [inner (|> nth' .int int.frac + (f.* slice) + (f.+ nth_phi)) + real (f.* nth_root_of_abs + (math.cos inner)) + imaginary (f.* nth_root_of_abs + (math.sin inner))] + {#real real + #imaginary imaginary}))))))) (def: .public (approximately? margin_of_error standard value) (-> Frac Complex Complex Bit) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 4e5eee846..7c4f1d8b1 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -150,12 +150,12 @@ (..- f2^-52) (..* f2^+1023)))) -(template [<name> <compose> <identity>] +(template [<name> <composite> <identity>] [(implementation: .public <name> (Monoid Frac) (def: identity <identity>) - (def: compose <compose>))] + (def: composite <composite>))] [addition ..+ +0.0] [multiplication ..* +1.0] diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 3f02cb4bd..e1706c217 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -130,12 +130,12 @@ (def: hash .nat)) -(template [<monoid> <identity> <compose>] +(template [<monoid> <identity> <composite>] [(implementation: .public <monoid> (All [a] (Monoid (I64 a))) (def: identity <identity>) - (def: compose <compose>))] + (def: composite <composite>))] [disjunction ..false ..or] [conjunction ..true ..and] diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index 657780bd9..91eaa9de4 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -187,12 +187,12 @@ ... -9,223,372,036,854,775,808 (//i64.left_shifted 63 +1))) -(template [<name> <compose> <identity>] +(template [<name> <composite> <identity>] [(implementation: .public <name> (Monoid Int) (def: identity <identity>) - (def: compose <compose>))] + (def: composite <composite>))] [addition ..+ +0] [multiplication ..* +1] @@ -220,13 +220,13 @@ (|> repr ("lux text clip" 1 (-- input_size)) (\ <codec> decoded) - (\ try.functor map .int)) + (\ try.functor each .int)) (^ (static ..-sign)) (|> repr ("lux text clip" 1 (-- input_size)) (\ <codec> decoded) - (\ try.functor map (|>> -- .int ..opposite --))) + (\ try.functor each (|>> -- .int ..opposite --))) _ (#try.Failure <error>)) diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index 2ec9333b7..0794950b4 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -168,12 +168,12 @@ (def: top (-- 0)) (def: bottom 0)) -(template [<name> <compose> <identity>] +(template [<name> <composite> <identity>] [(implementation: .public <name> (Monoid Nat) (def: identity <identity>) - (def: compose <compose>))] + (def: composite <composite>))] [addition ..+ 0] [multiplication ..* 1] diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index 6ab6d1349..6be8bce44 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -23,8 +23,9 @@ ["n" nat ("#\." decimal)]]) (type: .public Ratio - {#numerator Nat - #denominator Nat}) + (Record + {#numerator Nat + #denominator Nat})) (def: .public (nat value) (-> Ratio (Maybe Nat)) @@ -131,7 +132,7 @@ (Codec Text Ratio) (def: (encoded (^slots [#numerator #denominator])) - ($_ text\compose (n\encoded numerator) ..separator (n\encoded denominator))) + ($_ text\composite (n\encoded numerator) ..separator (n\encoded denominator))) (def: (decoded input) (case (text.split_by ..separator input) @@ -143,14 +144,14 @@ #denominator denominator}))) #.None - (#.Left (text\compose "Invalid syntax for ratio: " input))))) + (#.Left (text\composite "Invalid syntax for ratio: " input))))) -(template [<identity> <compose> <name>] +(template [<identity> <composite> <name>] [(implementation: .public <name> (Monoid Ratio) (def: identity (..ratio <identity>)) - (def: compose <compose>))] + (def: composite <composite>))] [0 ..+ addition] [1 ..* multiplication] diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index b4bf8bcd2..a65025c0b 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -205,12 +205,12 @@ (def: top (.rev -1)) (def: bottom (.rev 0))) -(template [<name> <compose> <identity>] +(template [<name> <composite> <identity>] [(implementation: .public <name> (Monoid Rev) (def: identity (\ interval <identity>)) - (def: compose <compose>))] + (def: composite <composite>))] [addition ..+ bottom] [maximum ..max bottom] diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index 3e9b14b8c..2f83a8d00 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -46,7 +46,7 @@ (implementation: .public functor (Functor Random) - (def: (map f fa) + (def: (each f fa) (function (_ state) (let [[state' a] (fa state)] [state' (f a)])))) @@ -71,7 +71,7 @@ (function (_ state) [state a])) - (def: (join ffa) + (def: (conjoint ffa) (function (_ state) (let [[state' fa] (ffa state)] (fa state'))))) @@ -125,7 +125,7 @@ (template [<name> <type> <cast>] [(def: .public <name> (Random <type>) - (\ ..monad map <cast> ..i64))] + (\ ..monad each <cast> ..i64))] [nat Nat .nat] [int Int .int] @@ -134,13 +134,13 @@ (def: .public frac (Random Frac) - (\ ..monad map (|>> .i64 f.of_bits) ..nat)) + (\ ..monad each (|>> .i64 f.of_bits) ..nat)) (def: .public safe_frac (Random Frac) (let [mantissa_range (.int (i64.left_shifted 53 1)) mantissa_max (i.frac (-- mantissa_range))] - (\ ..monad map + (\ ..monad each (|>> (i.% mantissa_range) i.frac (f./ mantissa_max)) @@ -154,7 +154,7 @@ in_range (: (-> Char Char) (|>> (n.% size) (n.+ start)))] (|> ..nat - (\ ..monad map in_range) + (\ ..monad each in_range) (..only (unicode.member? set))))) (def: .public (text char_gen size) @@ -164,7 +164,7 @@ (do ..monad [x char_gen xs (text char_gen (-- size))] - (in (text\compose (text.of_char x) xs))))) + (in (text\composite (text.of_char x) xs))))) (template [<name> <set>] [(def: .public <name> @@ -292,19 +292,19 @@ (def: .public instant (Random Instant) - (\ ..monad map instant.of_millis ..int)) + (\ ..monad each instant.of_millis ..int)) (def: .public date (Random Date) - (\ ..monad map instant.date ..instant)) + (\ ..monad each instant.date ..instant)) (def: .public time (Random Time) - (\ ..monad map instant.time ..instant)) + (\ ..monad each instant.time ..instant)) (def: .public duration (Random Duration) - (\ ..monad map duration.of_millis ..int)) + (\ ..monad each duration.of_millis ..int)) (def: .public month (Random Month) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index 13b7d9937..103796a2e 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -31,7 +31,7 @@ (implementation: .public functor (Functor Meta) - (def: (map f fa) + (def: (each f fa) (function (_ lux) (case (fa lux) (#try.Failure msg) @@ -68,7 +68,7 @@ (function (_ lux) (#try.Success [lux x]))) - (def: (join mma) + (def: (conjoint mma) (function (_ lux) (case (mma lux) (#try.Failure msg) @@ -121,7 +121,7 @@ (#try.Success [lux module]) _ - (#try.Failure ($_ text\compose "Unknown module: " name))))) + (#try.Failure ($_ text\composite "Unknown module: " name))))) (def: .public current_module_name (Meta Text) @@ -137,8 +137,8 @@ (Meta Module) (let [(^open "\.") ..monad] (|> ..current_module_name - (\map ..module) - \join))) + (\each ..module) + \conjoint))) (def: (macro_type? type) (-> Type Bit) @@ -265,7 +265,7 @@ ((clean_type var_type) lux) #.None - (#try.Failure ($_ text\compose "Unknown variable: " name)))))) + (#try.Failure ($_ text\composite "Unknown variable: " name)))))) (def: without_lux_runtime (-> (List Text) (List Text)) @@ -275,7 +275,7 @@ (def: listing_separator Text - ($_ text\compose text.new_line " ")) + ($_ text\composite text.new_line " ")) (def: module_listing (-> (List Text) Text) @@ -302,28 +302,28 @@ (let [current_module (|> lux (value@ #.current_module) (maybe.else "???")) all_known_modules (|> lux (value@ #.modules) - (list\map product.left) + (list\each product.left) ..module_listing)] - (#try.Failure ($_ text\compose + (#try.Failure ($_ text\composite "Unknown definition: " (name\encoded name) text.new_line " Current module: " current_module text.new_line (case (plist.value current_module (value@ #.modules lux)) (#.Some this_module) (let [candidates (|> lux (value@ #.modules) - (list\map (function (_ [module_name module]) - (|> module - (value@ #.definitions) - (list.all (function (_ [def_name global]) - (case global - (#.Definition [exported? _ _ _]) - (if (and exported? - (text\= normal_short def_name)) - (#.Some (name\encoded [module_name def_name])) - #.None) - - (#.Alias _) - #.None)))))) + (list\each (function (_ [module_name module]) + (|> module + (value@ #.definitions) + (list.all (function (_ [def_name global]) + (case global + (#.Definition [exported? _ _ _]) + (if (and exported? + (text\= normal_short def_name)) + (#.Some (name\encoded [module_name def_name])) + #.None) + + (#.Alias _) + #.None)))))) list.together (list.sorted text\<) (text.interposed ..listing_separator)) @@ -332,10 +332,10 @@ ..module_listing) aliases (|> this_module (value@ #.module_aliases) - (list\map (function (_ [alias real]) ($_ text\compose alias " => " real))) + (list\each (function (_ [alias real]) ($_ text\composite alias " => " real))) (list.sorted text\<) (text.interposed ..listing_separator))] - ($_ text\compose + ($_ text\composite " Candidates: " candidates text.new_line " Imports: " imports text.new_line " Aliases: " aliases text.new_line)) @@ -350,7 +350,7 @@ [definition (..definition name)] (case definition (#.Left de_aliased) - (failure ($_ text\compose + (failure ($_ text\composite "Aliases are not considered exports: " (name\encoded name))) @@ -358,7 +358,7 @@ (let [[exported? def_type def_data def_value] definition] (if exported? (in definition) - (failure ($_ text\compose "Definition is not an export: " (name\encoded name)))))))) + (failure ($_ text\composite "Definition is not an export: " (name\encoded name)))))))) (def: .public (definition_type name) (-> Name (Meta Type)) @@ -396,21 +396,21 @@ (type_code .Type) (type_code def_type))) (in (:as Type def_value)) - (..failure ($_ text\compose "Definition is not a type: " (name\encoded name)))))))) + (..failure ($_ text\composite "Definition is not a type: " (name\encoded name)))))))) (def: .public (globals module) (-> Text (Meta (List [Text Global]))) (function (_ lux) (case (plist.value module (value@ #.modules lux)) #.None - (#try.Failure ($_ text\compose "Unknown module: " module)) + (#try.Failure ($_ text\composite "Unknown module: " module)) (#.Some module) (#try.Success [lux (value@ #.definitions module)])))) (def: .public (definitions module) (-> Text (Meta (List [Text Definition]))) - (\ ..monad map + (\ ..monad each (list.all (function (_ [name global]) (case global (#.Left de_aliased) @@ -479,7 +479,7 @@ (def: .public (imported? import) (-> Text (Meta Bit)) - (\ ..functor map + (\ ..functor each (|>> (value@ #.imports) (list.any? (text\= import))) ..current_module)) @@ -495,14 +495,14 @@ (if (or (text\= this_module_name module) (and imported! exported?)) (in [idx tag_list type]) - (..failure ($_ text\compose "Cannot access tag: " (name\encoded tag_name) " from module " this_module_name))) + (..failure ($_ text\composite "Cannot access tag: " (name\encoded tag_name) " from module " this_module_name))) _ - (..failure ($_ text\compose + (..failure ($_ text\composite "Unknown tag: " (name\encoded tag_name) text.new_line " Known tags: " (|> =module (value@ #.tags) - (list\map (|>> product.left [module] name\encoded (text.prefix text.new_line))) + (list\each (|>> product.left [module] name\encoded (text.prefix text.new_line))) text.together) ))))) @@ -515,8 +515,8 @@ (list.only (function (_ [type_name [tag_list exported? type]]) (or exported? (text\= this_module_name module)))) - (list\map (function (_ [type_name [tag_list exported? type]]) - [tag_list type])))))) + (list\each (function (_ [type_name [tag_list exported? type]]) + [tag_list type])))))) (def: .public locals (Meta (List (List [Text Type]))) @@ -527,10 +527,10 @@ (#.Some scopes) (#try.Success [lux - (list\map (|>> (value@ [#.locals #.mappings]) - (list\map (function (_ [name [type _]]) - [name type]))) - scopes)])))) + (list\each (|>> (value@ [#.locals #.mappings]) + (list\each (function (_ [name [type _]]) + [name type]))) + scopes)])))) (def: .public (de_aliased def_name) (-> Name (Meta Name)) @@ -565,6 +565,6 @@ (def: .public (eval type code) (-> Type Code (Meta Any)) (do {! ..monad} - [eval (\ ! map (value@ #.eval) + [eval (\ ! each (value@ #.eval) ..compiler_state)] (eval type code))) diff --git a/stdlib/source/library/lux/meta/annotation.lux b/stdlib/source/library/lux/meta/annotation.lux index c73cc9247..292445ea8 100644 --- a/stdlib/source/library/lux/meta/annotation.lux +++ b/stdlib/source/library/lux/meta/annotation.lux @@ -71,7 +71,6 @@ [implementation? #.implementation?] [recursive_type? #.type_rec?] - [interface? #.interface?] ) (def: (text_parser input) @@ -89,7 +88,7 @@ (<| (maybe.else (list)) (do {! maybe.monad} [args (..tuple (name_of <tag>) ann)] - (monad.map ! ..text_parser args))))] + (monad.each ! ..text_parser args))))] [function_arguments #.func_args] [type_arguments #.type_args] diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index 87e80b27b..f53788682 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -20,8 +20,9 @@ ["." code]]]]) (type: Arguments - (#Raw Text) - (#Parsed (List Code))) + (Variant + (#Raw Text) + (#Parsed (List Code)))) (def: arguments^ (<code>.Parser Arguments) diff --git a/stdlib/source/library/lux/static.lux b/stdlib/source/library/lux/static.lux index 0a506ef2d..a332842ed 100644 --- a/stdlib/source/library/lux/static.lux +++ b/stdlib/source/library/lux/static.lux @@ -16,7 +16,7 @@ (template [<name> <type> <format>] [(syntax: .public (<name> [expression <code>.any]) - (\ meta.monad map + (\ meta.monad each (|>> (:as <type>) <format> list) (meta.eval <type> expression)))] diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index 3019924da..5a5b10a06 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -60,8 +60,9 @@ ) (type: .public Lambda - {#input Var/* - #output (Expression Any)}) + (Record + {#input Var/* + #output (Expression Any)})) (def: .public nil Literal @@ -146,7 +147,7 @@ (def: .public args (-> (List Var/1) Var/*) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed " ") ..as_form :abstraction)) @@ -159,7 +160,7 @@ (#.Item _) (|> singles - (list\map ..code) + (list\each ..code) (text.interposed " ") (text.suffix " "))) (format "&rest " (:representation rest)) @@ -168,7 +169,7 @@ (def: form (-> (List (Expression Any)) Expression) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed " ") ..as_form :abstraction)) @@ -189,9 +190,9 @@ (def: .public (labels definitions body) (-> (List [Var/1 Lambda]) (Expression Any) (Computation Any)) (..form (list (..var "labels") - (..form (list\map (function (_ [def_name [def_args def_body]]) - (..form (list def_name (:transmutation def_args) def_body))) - definitions)) + (..form (list\each (function (_ [def_name [def_args def_body]]) + (..form (list def_name (:transmutation def_args) def_body))) + definitions)) body))) (def: .public (destructuring_bind [bindings expression] body) @@ -349,8 +350,8 @@ (-> (List [Var/1 (Expression Any)]) (List (Expression Any)) (Computation Any)) (..form (list& (..var <host_name>) (|> bindings - (list\map (function (_ [name value]) - (..form (list name value)))) + (list\each (function (_ [name value]) + (..form (list name value)))) ..form) body)))] @@ -385,19 +386,20 @@ (..form (list (..var "setf") access value))) (type: .public Handler - {#condition_type (Expression Any) - #condition Var/1 - #body (Expression Any)}) + (Record + {#condition_type (Expression Any) + #condition Var/1 + #body (Expression Any)})) (def: .public (handler_case handlers body) (-> (List Handler) (Expression Any) (Computation Any)) (..form (list& (..var "handler-case") body - (list\map (function (_ [type condition handler]) - (..form (list type - (:transmutation (..args (list condition))) - handler))) - handlers)))) + (list\each (function (_ [type condition handler]) + (..form (list type + (:transmutation (..args (list condition))) + handler))) + handlers)))) (template [<name> <prefix>] [(def: .public (<name> conditions expression) @@ -412,7 +414,7 @@ _ (:abstraction - (format <prefix> (|> conditions (list\map ..symbol) + (format <prefix> (|> conditions (list\each ..symbol) (list& (..symbol "or")) ..form :representation) " " (:representation expression)))))] @@ -439,10 +441,10 @@ (def: .public (cond clauses else) (-> (List [(Expression Any) (Expression Any)]) (Expression Any) (Computation Any)) (..form (list& (..var "cond") - (list\compose (list\map (function (_ [test then]) - (..form (list test then))) - clauses) - (list (..form (list (..bool true) else))))))) + (list\composite (list\each (function (_ [test then]) + (..form (list test then))) + clauses) + (list (..form (list (..bool true) else))))))) (def: .public tag (-> Text Tag) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index b2af12ac2..7a1f5b3bc 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -119,7 +119,7 @@ (def: .public array (-> (List Expression) Computation) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed ..argument_separator) ..element :abstraction)) @@ -139,7 +139,7 @@ (def: .public (apply/* function inputs) (-> Expression (List Expression) Computation) (|> inputs - (list\map ..code) + (list\each ..code) (text.interposed ..argument_separator) ..expression (format (:representation function)) @@ -151,8 +151,8 @@ (def: .public object (-> (List [Text Expression]) Computation) - (|>> (list\map (.function (_ [key val]) - (format (:representation (..string key)) ..field_separator (:representation val)))) + (|>> (list\each (.function (_ [key val]) + (format (:representation (..string key)) ..field_separator (:representation val)))) (text.interposed ..argument_separator) (text.enclosed ["{" "}"]) ..expression @@ -184,7 +184,7 @@ ..block (format "function " (:representation name) (|> inputs - (list\map ..code) + (list\each ..code) (text.interposed ..argument_separator) ..expression) " ") @@ -203,7 +203,7 @@ ..block (format "function" (|> inputs - (list\map ..code) + (list\each ..code) (text.interposed ..argument_separator) ..expression) " ") @@ -285,7 +285,7 @@ (-> Expression (List Expression) Computation) (|> (format "new " (:representation constructor) (|> inputs - (list\map ..code) + (list\each ..code) (text.interposed ..argument_separator) ..expression)) ..expression @@ -408,11 +408,11 @@ (-> Expression (List [(List Literal) Statement]) (Maybe Statement) Statement) (:abstraction (format "switch (" (:representation input) ") " (|> (format (|> cases - (list\map (.function (_ [when then]) - (format (|> when - (list\map (|>> :representation (text.enclosed ["case " ":"]))) - (text.interposed text.new_line)) - (..nested (:representation then))))) + (list\each (.function (_ [when then]) + (format (|> when + (list\each (|>> :representation (text.enclosed ["case " ":"]))) + (text.interposed text.new_line)) + (..nested (:representation then))))) (text.interposed text.new_line)) text.new_line (case default diff --git a/stdlib/source/library/lux/target/jvm.lux b/stdlib/source/library/lux/target/jvm.lux index 1ada0da04..ce273f401 100644 --- a/stdlib/source/library/lux/target/jvm.lux +++ b/stdlib/source/library/lux/target/jvm.lux @@ -10,275 +10,304 @@ ["." category (#+ Primitive Class Value Method)]]]]]]) (type: .public Literal - (#Boolean Bit) - (#Int Int) - (#Long Int) - (#Double Frac) - (#Char Nat) - (#String Text)) + (Variant + (#Boolean Bit) + (#Int Int) + (#Long Int) + (#Double Frac) + (#Char Nat) + (#String Text))) (type: .public Constant - (#BIPUSH Int) - - (#SIPUSH Int) - - #ICONST_M1 - #ICONST_0 - #ICONST_1 - #ICONST_2 - #ICONST_3 - #ICONST_4 - #ICONST_5 - - #LCONST_0 - #LCONST_1 - - #FCONST_0 - #FCONST_1 - #FCONST_2 - - #DCONST_0 - #DCONST_1 - - #ACONST_NULL - - (#LDC Literal)) + (Variant + (#BIPUSH Int) + + (#SIPUSH Int) + + #ICONST_M1 + #ICONST_0 + #ICONST_1 + #ICONST_2 + #ICONST_3 + #ICONST_4 + #ICONST_5 + + #LCONST_0 + #LCONST_1 + + #FCONST_0 + #FCONST_1 + #FCONST_2 + + #DCONST_0 + #DCONST_1 + + #ACONST_NULL + + (#LDC Literal))) (type: .public Int_Arithmetic - #IADD - #ISUB - #IMUL - #IDIV - #IREM - #INEG) + (Variant + #IADD + #ISUB + #IMUL + #IDIV + #IREM + #INEG)) (type: .public Long_Arithmetic - #LADD - #LSUB - #LMUL - #LDIV - #LREM - #LNEG) + (Variant + #LADD + #LSUB + #LMUL + #LDIV + #LREM + #LNEG)) (type: .public Float_Arithmetic - #FADD - #FSUB - #FMUL - #FDIV - #FREM - #FNEG) + (Variant + #FADD + #FSUB + #FMUL + #FDIV + #FREM + #FNEG)) (type: .public Double_Arithmetic - #DADD - #DSUB - #DMUL - #DDIV - #DREM - #DNEG) + (Variant + #DADD + #DSUB + #DMUL + #DDIV + #DREM + #DNEG)) (type: .public Arithmetic - (#Int_Arithmetic Int_Arithmetic) - (#Long_Arithmetic Long_Arithmetic) - (#Float_Arithmetic Float_Arithmetic) - (#Double_Arithmetic Double_Arithmetic)) + (Variant + (#Int_Arithmetic Int_Arithmetic) + (#Long_Arithmetic Long_Arithmetic) + (#Float_Arithmetic Float_Arithmetic) + (#Double_Arithmetic Double_Arithmetic))) (type: .public Int_Bitwise - #IOR - #IXOR - #IAND - #ISHL - #ISHR - #IUSHR) + (Variant + #IOR + #IXOR + #IAND + #ISHL + #ISHR + #IUSHR)) (type: .public Long_Bitwise - #LOR - #LXOR - #LAND - #LSHL - #LSHR - #LUSHR) + (Variant + #LOR + #LXOR + #LAND + #LSHL + #LSHR + #LUSHR)) (type: .public Bitwise - (#Int_Bitwise Int_Bitwise) - (#Long_Bitwise Long_Bitwise)) + (Variant + (#Int_Bitwise Int_Bitwise) + (#Long_Bitwise Long_Bitwise))) (type: .public Conversion - #I2B - #I2S - #I2L - #I2F - #I2D - #I2C - - #L2I - #L2F - #L2D - - #F2I - #F2L - #F2D - - #D2I - #D2L - #D2F) + (Variant + #I2B + #I2S + #I2L + #I2F + #I2D + #I2C + + #L2I + #L2F + #L2D + + #F2I + #F2L + #F2D + + #D2I + #D2L + #D2F)) (type: .public Array - #ARRAYLENGTH + (Variant + #ARRAYLENGTH - (#NEWARRAY (Type Primitive)) - (#ANEWARRAY (Type category.Object)) + (#NEWARRAY (Type Primitive)) + (#ANEWARRAY (Type category.Object)) - #BALOAD - #BASTORE + #BALOAD + #BASTORE - #SALOAD - #SASTORE + #SALOAD + #SASTORE - #IALOAD - #IASTORE + #IALOAD + #IASTORE - #LALOAD - #LASTORE + #LALOAD + #LASTORE - #FALOAD - #FASTORE + #FALOAD + #FASTORE - #DALOAD - #DASTORE - - #CALOAD - #CASTORE + #DALOAD + #DASTORE + + #CALOAD + #CASTORE - #AALOAD - #AASTORE) + #AALOAD + #AASTORE)) (type: .public Object - (#GETSTATIC (Type Class) Text (Type Value)) - (#PUTSTATIC (Type Class) Text (Type Value)) - - (#NEW (Type Class)) - - (#INSTANCEOF (Type Class)) - (#CHECKCAST (Type category.Object)) - - (#GETFIELD (Type Class) Text (Type Value)) - (#PUTFIELD (Type Class) Text (Type Value)) - - (#INVOKEINTERFACE (Type Class) Text (Type Method)) - (#INVOKESPECIAL (Type Class) Text (Type Method)) - (#INVOKESTATIC (Type Class) Text (Type Method)) - (#INVOKEVIRTUAL (Type Class) Text (Type Method))) - -(type: .public Register Nat) + (Variant + (#GETSTATIC (Type Class) Text (Type Value)) + (#PUTSTATIC (Type Class) Text (Type Value)) + + (#NEW (Type Class)) + + (#INSTANCEOF (Type Class)) + (#CHECKCAST (Type category.Object)) + + (#GETFIELD (Type Class) Text (Type Value)) + (#PUTFIELD (Type Class) Text (Type Value)) + + (#INVOKEINTERFACE (Type Class) Text (Type Method)) + (#INVOKESPECIAL (Type Class) Text (Type Method)) + (#INVOKESTATIC (Type Class) Text (Type Method)) + (#INVOKEVIRTUAL (Type Class) Text (Type Method)))) + +(type: .public Register + Nat) (type: .public Local_Int - (#ILOAD Register) - (#ISTORE Register)) + (Variant + (#ILOAD Register) + (#ISTORE Register))) (type: .public Local_Long - (#LLOAD Register) - (#LSTORE Register)) + (Variant + (#LLOAD Register) + (#LSTORE Register))) (type: .public Local_Float - (#FLOAD Register) - (#FSTORE Register)) + (Variant + (#FLOAD Register) + (#FSTORE Register))) (type: .public Local_Double - (#DLOAD Register) - (#DSTORE Register)) + (Variant + (#DLOAD Register) + (#DSTORE Register))) (type: .public Local_Object - (#ALOAD Register) - (#ASTORE Register)) + (Variant + (#ALOAD Register) + (#ASTORE Register))) (type: .public Local - (#Local_Int Local_Int) - (#IINC Register) - (#Local_Long Local_Long) - (#Local_Float Local_Float) - (#Local_Double Local_Double) - (#Local_Object Local_Object)) + (Variant + (#Local_Int Local_Int) + (#IINC Register) + (#Local_Long Local_Long) + (#Local_Float Local_Float) + (#Local_Double Local_Double) + (#Local_Object Local_Object))) (type: .public Stack - #DUP - #DUP_X1 - #DUP_X2 - #DUP2 - #DUP2_X1 - #DUP2_X2 - #SWAP - #POP - #POP2) + (Variant + #DUP + #DUP_X1 + #DUP_X2 + #DUP2 + #DUP2_X1 + #DUP2_X2 + #SWAP + #POP + #POP2)) (type: .public Comparison - #LCMP - - #FCMPG - #FCMPL + (Variant + #LCMP + + #FCMPG + #FCMPL - #DCMPG - #DCMPL) + #DCMPG + #DCMPL)) -(type: .public Label Nat) +(type: .public Label + Nat) (type: .public (Branching label) - (#IF_ICMPEQ label) - (#IF_ICMPGE label) - (#IF_ICMPGT label) - (#IF_ICMPLE label) - (#IF_ICMPLT label) - (#IF_ICMPNE label) - (#IFEQ label) - (#IFNE label) - (#IFGE label) - (#IFGT label) - (#IFLE label) - (#IFLT label) - - (#TABLESWITCH Int Int label (List label)) - (#LOOKUPSWITCH label (List [Int label])) - - (#IF_ACMPEQ label) - (#IF_ACMPNE label) - (#IFNONNULL label) - (#IFNULL label)) + (Variant + (#IF_ICMPEQ label) + (#IF_ICMPGE label) + (#IF_ICMPGT label) + (#IF_ICMPLE label) + (#IF_ICMPLT label) + (#IF_ICMPNE label) + (#IFEQ label) + (#IFNE label) + (#IFGE label) + (#IFGT label) + (#IFLE label) + (#IFLT label) + + (#TABLESWITCH Int Int label (List label)) + (#LOOKUPSWITCH label (List [Int label])) + + (#IF_ACMPEQ label) + (#IF_ACMPNE label) + (#IFNONNULL label) + (#IFNULL label))) (type: .public (Exception label) - (#Try label label label (Type Class)) - #ATHROW) + (Variant + (#Try label label label (Type Class)) + #ATHROW)) (type: .public Concurrency - #MONITORENTER - #MONITOREXIT) + (Variant + #MONITORENTER + #MONITOREXIT)) (type: .public Return - #RETURN - #IRETURN - #LRETURN - #FRETURN - #DRETURN - #ARETURN) + (Variant + #RETURN + #IRETURN + #LRETURN + #FRETURN + #DRETURN + #ARETURN)) (type: .public (Control label) - (#GOTO label) - (#Branching (Branching label)) - (#Exception (Exception label)) - (#Concurrency Concurrency) - (#Return Return)) + (Variant + (#GOTO label) + (#Branching (Branching label)) + (#Exception (Exception label)) + (#Concurrency Concurrency) + (#Return Return))) (type: .public (Instruction embedded label) - #NOP - (#Constant Constant) - (#Arithmetic Arithmetic) - (#Bitwise Bitwise) - (#Conversion Conversion) - (#Array Array) - (#Object Object) - (#Local Local) - (#Stack Stack) - (#Comparison Comparison) - (#Control (Control label)) - (#Embedded embedded)) + (Variant + #NOP + (#Constant Constant) + (#Arithmetic Arithmetic) + (#Bitwise Bitwise) + (#Conversion Conversion) + (#Array Array) + (#Object Object) + (#Local Local) + (#Stack Stack) + (#Comparison Comparison) + (#Control (Control label)) + (#Embedded embedded))) (type: .public (Bytecode embedded label) (Row (Instruction embedded label))) diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 1dd3c323e..640ad8683 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -26,9 +26,10 @@ ["#." code]]) (type: .public (Info about) - {#name (Index UTF8) - #length U4 - #info about}) + (Record + {#name (Index UTF8) + #length U4 + #info about})) (def: .public (info_equivalence Equivalence<about>) (All [about] @@ -52,8 +53,9 @@ (with_expansions [<Code> (as_is (/code.Code Attribute))] (type: .public #rec Attribute - (#Constant (Info (Constant Any))) - (#Code (Info <Code>))) + (Variant + (#Constant (Info (Constant Any))) + (#Code (Info <Code>)))) (type: .public Code <Code>) diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux index 265c951a2..d63057a68 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux @@ -23,10 +23,11 @@ ["#." exception (#+ Exception)]]) (type: .public (Code Attribute) - {#limit Limit - #code Binary - #exception_table (Row Exception) - #attributes (Row Attribute)}) + (Record + {#limit Limit + #code Binary + #exception_table (Row Exception) + #attributes (Row Attribute)})) (def: .public (length length code) (All [Attribute] (-> (-> Attribute Nat) (Code Attribute) Nat)) @@ -50,7 +51,7 @@ ... attribute_info attributes[attributes_count]; (|> code (value@ #attributes) - (row\map length) + (row\each length) (row\mix n.+ 0)))) (def: .public (equivalence attribute_equivalence) @@ -66,7 +67,7 @@ ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 (def: .public (writer writer code) (All [Attribute] (-> (Writer Attribute) (Writer (Code Attribute)))) - ($_ binaryF\compose + ($_ binaryF\composite ... u2 max_stack; ... u2 max_locals; (///limit.writer (value@ #limit code)) diff --git a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux index 5ba6db613..a2a4f45c1 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux @@ -20,10 +20,11 @@ ["#." unsigned (#+ U2)]]]]) (type: .public Exception - {#start Address - #end Address - #handler Address - #catch (Index Class)}) + (Record + {#start Address + #end Address + #handler Address + #catch (Index Class)})) (def: .public equivalence (Equivalence Exception) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 9b16b5be6..7e56004c3 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -51,14 +51,17 @@ ["." reflection] ["." parser]]]]) -(type: .public Label Nat) +(type: .public Label + Nat) -(type: .public Resolver (Dictionary Label [Stack (Maybe Address)])) +(type: .public Resolver + (Dictionary Label [Stack (Maybe Address)])) (type: .public Tracker - {#program_counter Address - #next Label - #known Resolver}) + (Record + {#program_counter Address + #next Label + #known Resolver})) (def: fresh Tracker @@ -82,7 +85,7 @@ (def: identity ..relative_identity) - (def: (compose left right) + (def: (composite left right) (cond (same? ..relative_identity left) right @@ -94,8 +97,8 @@ (do try.monad [[left_exceptions left_instruction] (left resolver) [right_exceptions right_instruction] (right resolver)] - (in [(\ row.monoid compose left_exceptions right_exceptions) - (_\compose left_instruction right_instruction)])))))) + (in [(\ row.monoid composite left_exceptions right_exceptions) + (_\composite left_instruction right_instruction)])))))) (type: .public (Bytecode a) (+State Try [Pool Environment Tracker] (Writer Relative a))) @@ -687,12 +690,14 @@ ["Start" (|> @from /address.value //unsigned.value %.nat)] ["Target" (|> jump //signed.value %.int)])) -(type: Any_Jump (Either Big_Jump Jump)) +(type: Any_Jump + (Either Big_Jump + Jump)) (def: (jump @from @to) (-> Address Address (Try Any_Jump)) (do {! try.monad} - [jump (\ ! map //signed.value + [jump (\ ! each //signed.value (/address.jump @from @to))] (let [big? (n.> (//unsigned.value //unsigned.maximum/2) (.nat (i.* (if (i.>= +0 jump) @@ -700,8 +705,8 @@ -1) jump)))] (if big? - (\ ! map (|>> #.Left) (//signed.s4 jump)) - (\ ! map (|>> #.Right) (//signed.s2 jump)))))) + (\ ! each (|>> #.Left) (//signed.s4 jump)) + (\ ! each (|>> #.Right) (//signed.s2 jump)))))) (exception: .public (unset_label {label Label}) (exception.report @@ -857,15 +862,15 @@ [@default (|> default get (monad.then ! product.right)) @at_minimum (|> at_minimum get (monad.then ! product.right)) @afterwards (|> afterwards - (monad.map ! get) - (monad.then ! (monad.map ! product.right)))] + (monad.each ! get) + (monad.then ! (monad.each ! product.right)))] (in [@default @at_minimum @afterwards])) (#.Some [@default @at_minimum @afterwards]) (do {! try.monad} - [>default (\ ! map ..big_jump (..jump @from @default)) - >at_minimum (\ ! map ..big_jump (..jump @from @at_minimum)) - >afterwards (monad.map ! (|>> (..jump @from) (\ ! map ..big_jump)) - @afterwards)] + [>default (\ ! each ..big_jump (..jump @from @default)) + >at_minimum (\ ! each ..big_jump (..jump @from @at_minimum)) + >afterwards (monad.each ! (|>> (..jump @from) (\ ! each ..big_jump)) + @afterwards)] (in [..no_exceptions (bytecode minimum >default [>at_minimum >afterwards])])) #.None @@ -890,7 +895,7 @@ (in (let [@from (value@ #program_counter tracker)] [[pool environment' - (|> (list\mix (..acknowledge_label actual) tracker (list& default (list\map product.right cases))) + (|> (list\mix (..acknowledge_label actual) tracker (list& default (list\each product.right cases))) (with@ #program_counter program_counter'))] [(function (_ resolver) (let [get (: (-> Label (Maybe [Stack (Maybe Address)])) @@ -899,15 +904,15 @@ (case (do {! maybe.monad} [@default (|> default get (monad.then ! product.right)) @cases (|> cases - (monad.map ! (|>> product.right get)) - (monad.then ! (monad.map ! product.right)))] + (monad.each ! (|>> product.right get)) + (monad.then ! (monad.each ! product.right)))] (in [@default @cases])) (#.Some [@default @cases]) (do {! try.monad} - [>default (\ ! map ..big_jump (..jump @from @default)) + [>default (\ ! each ..big_jump (..jump @from @default)) >cases (|> @cases - (monad.map ! (|>> (..jump @from) (\ ! map ..big_jump))) - (\ ! map (|>> (list.zipped/2 (list\map product.left cases)))))] + (monad.each ! (|>> (..jump @from) (\ ! each ..big_jump))) + (\ ! each (|>> (list.zipped/2 (list\each product.left cases)))))] (in [..no_exceptions (bytecode >default >cases)])) #.None @@ -974,7 +979,7 @@ {#//constant/pool.name method #//constant/pool.descriptor (type.descriptor type)}) .let [consumption (|> inputs - (list\map ..type_size) + (list\each ..type_size) (list\mix n.+ (if <static?> 0 1)) //unsigned.u1 try.trusted) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/address.lux b/stdlib/source/library/lux/target/jvm/bytecode/address.lux index 669b49548..51ab13080 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/address.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/address.lux @@ -40,7 +40,7 @@ (-> U2 (-> Address (Try Address))) (|>> :representation (///unsigned.+/2 distance) - (\ try.functor map (|>> :abstraction)))) + (\ try.functor each (|>> :abstraction)))) (def: with_sign (-> Address (Try S4)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index 54c754dc5..ff778621c 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -18,8 +18,9 @@ [category (#+ Method)]]]]) (type: .public Environment - {#limit Limit - #stack (Maybe Stack)}) + (Record + {#limit Limit + #stack (Maybe Stack)})) (template [<name> <limit>] [(def: .public (<name> type) @@ -41,7 +42,7 @@ (def: identity (|>> #try.Success)) - (def: (compose left right) + (def: (composite left right) (function (_ environment) (do try.monad [environment (left environment)] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux index d57c07354..515728d71 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux @@ -21,8 +21,9 @@ [category (#+ Method)]]]]) (type: .public Limit - {#stack Stack - #registry Registry}) + (Record + {#stack Stack + #registry Registry})) (template [<name> <registry>] [(def: .public (<name> type) @@ -52,7 +53,7 @@ (def: .public (writer limit) (Writer Limit) - ($_ format\compose + ($_ format\composite (/stack.writer (value@ #stack limit)) (/registry.writer (value@ #registry limit)) )) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux index b1d51e164..04bf00456 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux @@ -22,7 +22,8 @@ [category (#+ Method)] ["#/." parser]]]) -(type: .public Register U1) +(type: .public Register + U1) (def: normal 1) (def: wide 2) @@ -40,11 +41,11 @@ (-> (Type Method) Nat) (let [[type_variables inputs output exceptions] (/////type/parser.method type)] (|> inputs - (list\map (function (_ input) - (if (or (same? /////type.long input) - (same? /////type.double input)) - ..wide - ..normal))) + (list\each (function (_ input) + (if (or (same? /////type.long input) + (same? /////type.double input)) + ..wide + ..normal))) (list\mix n.+ 0)))) (template [<start> <name>] @@ -53,7 +54,7 @@ (|>> ..minimal (n.+ <start>) /////unsigned.u2 - (try\map ..registry)))] + (try\each ..registry)))] [0 static] [1 virtual] @@ -61,7 +62,7 @@ (def: .public equivalence (Equivalence Registry) - (\ equivalence.functor map + (\ equivalence.functor each (|>> :representation) /////unsigned.equivalence)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux index ac3934f87..13d4b5137 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux @@ -33,7 +33,7 @@ (def: .public equivalence (Equivalence Stack) - (\ equivalence.functor map + (\ equivalence.functor each (|>> :representation) /////unsigned.equivalence)) @@ -50,7 +50,7 @@ (-> U2 (-> Stack (Try Stack))) (|>> :representation (<op> amount) - (\ try.functor map ..stack)))] + (\ try.functor each ..stack)))] [/////unsigned.+/2 push] [/////unsigned.-/2 pop] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 2e21d2a8e..bba0c67da 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -36,7 +36,8 @@ [type [category (#+ Value Method)]]]]) -(type: .public Size U2) +(type: .public Size + U2) (type: .public Estimator (-> Address Size)) @@ -56,7 +57,8 @@ (-> Instruction Specification) (function.on format.no_op)) -(type: Opcode Nat) +(type: Opcode + Nat) (template [<name> <size>] [(def: <name> Size (|> <size> ///unsigned.u2 try.trusted))] @@ -608,7 +610,7 @@ tableswitch_size (try.trusted (do {! try.monad} [size (///unsigned.u2 size)] - (\ ! map (|>> estimator ///unsigned.value) + (\ ! each (|>> estimator ///unsigned.value) (//address.move size //address.start)))) tableswitch_mutation (: Mutation (function (_ [offset binary]) @@ -672,7 +674,7 @@ lookupswitch_size (try.trusted (do {! try.monad} [size (///unsigned.u2 size)] - (\ ! map (|>> estimator ///unsigned.value) + (\ ! each (|>> estimator ///unsigned.value) (//address.move size //address.start)))) lookupswitch_mutation (: Mutation (function (_ [offset binary]) @@ -713,5 +715,5 @@ (def: identity ..empty) - (def: (compose left right) + (def: (composite left right) (|>> left right))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux index 74821d838..4b908d990 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux @@ -10,7 +10,8 @@ [encoding ["#." signed (#+ S2 S4)]]]) -(type: .public Jump S2) +(type: .public Jump + S2) (def: .public equivalence (Equivalence Jump) @@ -20,7 +21,8 @@ (Writer Jump) ///signed.writer/2) -(type: .public Big_Jump S4) +(type: .public Big_Jump + S4) (def: .public lifted (-> Jump Big_Jump) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index 0b792934b..1280b23c4 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -28,17 +28,18 @@ ["#/." pool (#+ Pool Resource)]]]) (type: .public #rec Class - {#magic Magic - #minor_version Minor - #major_version Major - #constant_pool Pool - #modifier (Modifier Class) - #this (Index //constant.Class) - #super (Index //constant.Class) - #interfaces (Row (Index //constant.Class)) - #fields (Row Field) - #methods (Row Method) - #attributes (Row Attribute)}) + (Record + {#magic Magic + #minor_version Minor + #major_version Major + #constant_pool Pool + #modifier (Modifier Class) + #this (Index //constant.Class) + #super (Index //constant.Class) + #interfaces (Row (Index //constant.Class)) + #fields (Row Field) + #methods (Row Method) + #attributes (Row Attribute)})) (modifiers: Class ["0001" public] @@ -112,7 +113,7 @@ (def: .public (writer class) (Writer Class) - (`` ($_ binaryF\compose + (`` ($_ binaryF\composite (~~ (template [<writer> <slot>] [(<writer> (value@ <slot> class))] diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux index 5916d245d..c2756715e 100644 --- a/stdlib/source/library/lux/target/jvm/constant.lux +++ b/stdlib/source/library/lux/target/jvm/constant.lux @@ -34,7 +34,8 @@ [encoding ["#." unsigned]]]]) -(type: .public UTF8 Text) +(type: .public UTF8 + Text) (def: utf8_writer (Writer UTF8) @@ -55,7 +56,7 @@ (def: .public class_equivalence (Equivalence Class) - (\ equivalence.functor map + (\ equivalence.functor each ..index //index.equivalence)) @@ -97,12 +98,13 @@ (All [kind] (-> (Equivalence kind) (Equivalence (Value kind)))) - (\ equivalence.functor map + (\ equivalence.functor each (|>> :representation) Equivalence<kind>)) (template [<constructor> <type> <marker>] - [(type: .public <type> (Value <marker>)) + [(type: .public <type> + (Value <marker>)) (def: .public <constructor> (-> <marker> <type>) @@ -131,12 +133,14 @@ ) (type: .public (Name_And_Type of) - {#name (Index UTF8) - #descriptor (Index (Descriptor of))}) + (Record + {#name (Index UTF8) + #descriptor (Index (Descriptor of))})) (type: .public (Reference of) - {#class (Index Class) - #name_and_type (Index (Name_And_Type of))}) + (Record + {#class (Index Class) + #name_and_type (Index (Name_And_Type of))})) (template [<type> <equivalence> <writer>] [(def: .public <equivalence> @@ -156,17 +160,18 @@ ) (type: .public Constant - (#UTF8 UTF8) - (#Integer Integer) - (#Float Float) - (#Long Long) - (#Double Double) - (#Class Class) - (#String String) - (#Field (Reference //category.Value)) - (#Method (Reference //category.Method)) - (#Interface_Method (Reference //category.Method)) - (#Name_And_Type (Name_And_Type Any))) + (Variant + (#UTF8 UTF8) + (#Integer Integer) + (#Float Float) + (#Long Long) + (#Double Double) + (#Class Class) + (#String String) + (#Field (Reference //category.Value)) + (#Method (Reference //category.Method)) + (#Interface_Method (Reference //category.Method)) + (#Name_And_Type (Name_And_Type Any)))) (def: .public (size constant) (-> Constant Nat) @@ -244,7 +249,7 @@ (case value (^template [<case> <tag> <writer>] [(<case> value) - (binaryF\compose (/tag.writer <tag>) - (<writer> value))]) + (binaryF\composite (/tag.writer <tag>) + (<writer> value))]) (<constants>) )))) diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index 99597756d..50872e835 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -35,7 +35,8 @@ [category (#+ Value Method)] ["#." descriptor (#+ Descriptor)]]]]) -(type: .public Pool [Index (Row [Index Constant])]) +(type: .public Pool + [Index (Row [Index Constant])]) (def: .public equivalence (Equivalence Pool) @@ -75,7 +76,7 @@ (|> current //index.value (//unsigned.+/2 @new) - (\ ! map //index.index)))] + (\ ! each //index.index)))] (in [[next (row.suffix [current new] pool)] current]))))))))]) @@ -120,8 +121,9 @@ (!add #//.UTF8 text.equivalence value))) (type: .public (Member of) - {#name UTF8 - #descriptor (Descriptor of)}) + (Record + {#name UTF8 + #descriptor (Descriptor of)})) (def: .public (name_and_type [name descriptor]) (All [of] @@ -148,7 +150,7 @@ (Writer Pool) (function (_ [next pool]) (row\mix (function (_ [_index post] pre) - (specification\compose pre (//.writer post))) + (specification\composite pre (//.writer post))) (format.bits/16 (!index next)) pool))) diff --git a/stdlib/source/library/lux/target/jvm/encoding/name.lux b/stdlib/source/library/lux/target/jvm/encoding/name.lux index 16efc410a..eb232aaba 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/name.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/name.lux @@ -10,7 +10,8 @@ (def: .public internal_separator "/") (def: .public external_separator ".") -(type: .public External Text) +(type: .public External + Text) (abstract: .public Internal {} diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux index b8d84170d..4ccaf58c4 100644 --- a/stdlib/source/library/lux/target/jvm/field.lux +++ b/stdlib/source/library/lux/target/jvm/field.lux @@ -21,10 +21,11 @@ [descriptor (#+ Descriptor)]]]) (type: .public #rec Field - {#modifier (Modifier Field) - #name (Index UTF8) - #descriptor (Index (Descriptor Value)) - #attributes (Row Attribute)}) + (Record + {#modifier (Modifier Field) + #name (Index UTF8) + #descriptor (Index (Descriptor Value)) + #attributes (Row Attribute)})) (modifiers: Field ["0001" public] @@ -48,7 +49,7 @@ (def: .public (writer field) (Writer Field) - (`` ($_ binaryF\compose + (`` ($_ binaryF\composite (~~ (template [<writer> <slot>] [(<writer> (value@ <slot> field))] diff --git a/stdlib/source/library/lux/target/jvm/index.lux b/stdlib/source/library/lux/target/jvm/index.lux index 66df65314..07ae1e85d 100644 --- a/stdlib/source/library/lux/target/jvm/index.lux +++ b/stdlib/source/library/lux/target/jvm/index.lux @@ -30,7 +30,7 @@ (def: .public equivalence (All [kind] (Equivalence (Index kind))) - (\ equivalence.functor map + (\ equivalence.functor each ..value //unsigned.equivalence)) diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index e604eb3c2..38bae94fc 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -27,10 +27,11 @@ ["#." descriptor (#+ Descriptor)]]]) (type: .public #rec Method - {#modifier (Modifier Method) - #name (Index UTF8) - #descriptor (Index (Descriptor //type/category.Method)) - #attributes (Row Attribute)}) + (Record + {#modifier (Modifier Method) + #name (Index UTF8) + #descriptor (Index (Descriptor //type/category.Method)) + #attributes (Row Attribute)})) (modifiers: Method ["0001" public] @@ -55,7 +56,7 @@ @descriptor (//constant/pool.descriptor (//type.descriptor type)) attributes (|> attributes (monad.all !) - (\ ! map row.of_list)) + (\ ! each row.of_list)) attributes (case code (#.Some code) (do ! @@ -93,7 +94,7 @@ (def: .public (writer field) (Writer Method) - (`` ($_ format\compose + (`` ($_ format\composite (~~ (template [<writer> <slot>] [(<writer> (value@ <slot> field))] diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux index c7eb021b2..64359dea1 100644 --- a/stdlib/source/library/lux/target/jvm/modifier.lux +++ b/stdlib/source/library/lux/target/jvm/modifier.lux @@ -64,7 +64,7 @@ (def: identity (!wrap (hex "0000"))) - (def: (compose left right) + (def: (composite left right) (!wrap (i64.or (!unwrap left) (!unwrap right))))) (def: .public empty diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index f23e3c019..3fdf491bc 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -175,7 +175,7 @@ [paramsT (|> reflection java/lang/reflect/ParameterizedType::getActualTypeArguments array.list - (monad.map ! parameter))] + (monad.each ! parameter))] (in (/.class (|> raw (:as (java/lang/Class java/lang/Object)) java/lang/Class::getName) @@ -208,7 +208,7 @@ (#try.Success /.wildcard) _ - (\ try.monad map <kind> (..class' parameter bound)))]) + (\ try.monad each <kind> (..class' parameter bound)))]) ([[_ (#.Some bound)] /.upper] [[(#.Some bound) _] /.lower]) @@ -251,7 +251,7 @@ (|> reflection java/lang/reflect/GenericArrayType::getGenericComponentType type - (\ try.monad map /.array)) + (\ try.monad each /.array)) _) ... else (..parameter reflection))) @@ -303,8 +303,8 @@ (if (text\= class_name name) (if (n.= num_class_params num_type_params) (|> params - (list.zipped/2 (list\map (|>> java/lang/reflect/TypeVariable::getName) - class_params)) + (list.zipped/2 (list\each (|>> java/lang/reflect/TypeVariable::getName) + class_params)) (list\mix (function (_ [name paramT] mapping) (dictionary.has name paramT mapping)) /lux.fresh) @@ -375,8 +375,8 @@ <then?> (|> fieldJ java/lang/reflect/Field::getGenericType ..type - (\ ! map (|>> [(java/lang/reflect/Modifier::isFinal modifiers) - (..deprecated? (java/lang/reflect/Field::getDeclaredAnnotations fieldJ))]))) + (\ ! each (|>> [(java/lang/reflect/Modifier::isFinal modifiers) + (..deprecated? (java/lang/reflect/Field::getDeclaredAnnotations fieldJ))]))) <else?> (exception.except <exception> [field class]))))] [static_field ..not_a_static_field #1 #0] diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux index e87838ef1..1eeccbe72 100644 --- a/stdlib/source/library/lux/target/jvm/type.lux +++ b/stdlib/source/library/lux/target/jvm/type.lux @@ -37,9 +37,10 @@ [(Type Value) a]) (type: .public Constraint - {#name Text - #super_class (Type Class) - #super_interfaces (List (Type Class))}) + (Record + {#name Text + #super_class (Type Class) + #super_interfaces (List (Type Class))})) (template [<name> <style>] [(def: .public (<name> type) @@ -84,14 +85,14 @@ (def: .public (class name parameters) (-> External (List (Type Parameter)) (Type Class)) (:abstraction - [(/signature.class name (list\map ..signature parameters)) + [(/signature.class name (list\each ..signature parameters)) (/descriptor.class name) (/reflection.class name)])) (def: .public (declaration name variables) (-> External (List (Type Var)) (Type Declaration)) (:abstraction - [(/signature.declaration name (list\map ..signature variables)) + [(/signature.declaration name (list\each ..signature variables)) (/descriptor.declaration name) (/reflection.declaration name)])) @@ -140,11 +141,11 @@ (List (Type Class))] (Type Method)) (:abstraction - [(/signature.method [(list\map ..signature type_variables) - (list\map ..signature inputs) + [(/signature.method [(list\each ..signature type_variables) + (list\each ..signature inputs) (..signature output) - (list\map ..signature exceptions)]) - (/descriptor.method [(list\map ..descriptor inputs) + (list\each ..signature exceptions)]) + (/descriptor.method [(list\each ..descriptor inputs) (..descriptor output)]) (:expected ..void)])) @@ -202,7 +203,7 @@ (n.- suffix_size))] (|> repr (text.clip prefix_size name_size) - (\ maybe.monad map (|>> //name.internal //name.external)))) + (\ maybe.monad each (|>> //name.internal //name.external)))) #.None))) (def: .public format diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 5ba678bf6..20f0b2921 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -56,7 +56,7 @@ [(def: <name> (-> (Parser (Type Class)) (Parser (Type Parameter))) (|>> (<>.after (<text>.this <prefix>)) - (\ <>.monad map <bound>)))] + (\ <>.monad each <bound>)))] [lower //signature.lower_prefix //.lower ..Lower] [upper //signature.upper_prefix //.upper ..Upper] @@ -112,7 +112,7 @@ (def: (bound_type_var aliasing) (-> Aliasing (Parser (Type Var))) (|> //parser.var_name - (\ <>.monad map //.var) + (\ <>.monad each //.var) (<>.before (<>.many (..bound aliasing))))) (def: .public (method aliasing) diff --git a/stdlib/source/library/lux/target/jvm/type/descriptor.lux b/stdlib/source/library/lux/target/jvm/type/descriptor.lux index 099a68287..c9d622ca0 100644 --- a/stdlib/source/library/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/library/lux/target/jvm/type/descriptor.lux @@ -97,7 +97,7 @@ (Descriptor Method)) (:abstraction (format (|> inputs - (list\map ..descriptor) + (list\each ..descriptor) text.together (text.enclosed ["(" ")"])) (:representation output)))) @@ -121,6 +121,6 @@ (|> (text.size repr) (n.- prefix_size) (n.- suffix_size))) - (\ maybe.monad map ///name.internal) + (\ maybe.monad each ///name.internal) maybe.trusted)))))) ) diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index 99845fa7e..d7b6f155e 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -112,8 +112,8 @@ (def: wildcard (Parser (Check Type)) (<>.after //parser.wildcard - (<>\in (check\map product.right - check.existential)))) + (<>\in (check\each product.right + check.existential)))) (def: (var mapping) (-> Mapping (Parser (Check Type))) @@ -145,7 +145,7 @@ (-> (Parser (Check Type)) (Parser (Check Type))) (|> (<>.after (<text>.this <prefix>)) ... TODO: Re-enable Lower and Upper, instead of using the simplified limit. - ... (<>\map (check\map (|>> <ctor> .type))) + ... (<>\each (check\each (|>> <ctor> .type))) ))] [lower //signature.lower_prefix ..Lower] @@ -171,25 +171,25 @@ (def: array (-> (Parser (Check Type)) (Parser (Check Type))) - (|>> (<>\map (check\map (function (_ elementT) - (case elementT - (#.Primitive name #.End) - (if (`` (or (~~ (template [<reflection>] - [(text\= (//reflection.reflection <reflection>) name)] - - [//reflection.boolean] - [//reflection.byte] - [//reflection.short] - [//reflection.int] - [//reflection.long] - [//reflection.float] - [//reflection.double] - [//reflection.char])))) - (#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.End) - (|> elementT array.Array .type)) - - _ - (|> elementT array.Array .type))))) + (|>> (<>\each (check\each (function (_ elementT) + (case elementT + (#.Primitive name #.End) + (if (`` (or (~~ (template [<reflection>] + [(text\= (//reflection.reflection <reflection>) name)] + + [//reflection.boolean] + [//reflection.byte] + [//reflection.short] + [//reflection.int] + [//reflection.long] + [//reflection.float] + [//reflection.double] + [//reflection.char])))) + (#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.End) + (|> elementT array.Array .type)) + + _ + (|> elementT array.Array .type))))) (<>.after (<text>.this //descriptor.array_prefix)))) (def: .public (type mapping) diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux index 2bbbca6ca..cf0064195 100644 --- a/stdlib/source/library/lux/target/jvm/type/parser.lux +++ b/stdlib/source/library/lux/target/jvm/type/parser.lux @@ -68,7 +68,7 @@ (template [<type> <name> <head> <tail> <adapter>] [(def: .public <name> (Parser <type>) - (\ <>.functor map <adapter> + (\ <>.functor each <adapter> (<text>.slice (<text>.and! (<text>.one_of! <head>) (<text>.some! (<text>.one_of! <tail>))))))] @@ -84,7 +84,7 @@ (def: .public var (Parser (Type Var)) - (<>\map //.var ..var')) + (<>\each //.var ..var')) (def: .public var? (-> (Type Value) (Maybe Text)) @@ -104,7 +104,7 @@ [(def: <name> (-> (Parser (Type Class)) (Parser (Type Parameter))) (|>> (<>.after (<text>.this <prefix>)) - (<>\map <constructor>)))] + (<>\each <constructor>)))] [lower //signature.lower_prefix //.lower] [upper //signature.upper_prefix //.upper] @@ -125,7 +125,7 @@ (def: class' (-> (Parser (Type Parameter)) (Parser (Type Class))) (|>> ..class'' - (\ <>.monad map (product.uncurried //.class)))) + (\ <>.monad each (product.uncurried //.class)))) (def: .public parameter (Parser (Type Parameter)) @@ -143,7 +143,7 @@ (def: .public array' (-> (Parser (Type Value)) (Parser (Type Array))) (|>> (<>.after (<text>.this //descriptor.array_prefix)) - (<>\map //.array))) + (<>\each //.array))) (def: .public class (Parser (Type Class)) diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index 7195c4918..5e2f5fbdf 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -98,7 +98,7 @@ _ (format ..parameters_start (|> parameters - (list\map ..signature) + (list\each ..signature) text.together) ..parameters_end)) //descriptor.class_suffix))) @@ -133,19 +133,19 @@ "" _ (|> type_variables - (list\map (|>> ..var_name - (text.suffix ..class_bound))) + (list\each (|>> ..var_name + (text.suffix ..class_bound))) text.together (text.enclosed [..parameters_start ..parameters_end]))) (|> inputs - (list\map ..signature) + (list\each ..signature) text.together (text.enclosed [..arguments_start ..arguments_end])) (:representation output) (|> exceptions - (list\map (|>> :representation (format ..exception_prefix))) + (list\each (|>> :representation (format ..exception_prefix))) text.together)))) (implementation: .public equivalence diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index 8bac227eb..7a057f870 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -140,21 +140,21 @@ (def: .public multi (-> (List Expression) Literal) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed ..input_separator) :abstraction)) (def: .public array (-> (List Expression) Literal) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) (def: .public table (-> (List [Text Expression]) Literal) - (|>> (list\map (.function (_ [key value]) - (format key " = " (:representation value)))) + (|>> (list\each (.function (_ [key value]) + (format key " = " (:representation value)))) (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) @@ -176,7 +176,7 @@ (def: .public (apply/* args func) (-> (List Expression) Expression Computation) (|> args - (list\map ..code) + (list\each ..code) (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation func)) @@ -185,7 +185,7 @@ (def: .public (do method args table) (-> Text (List Expression) Expression Computation) (|> args - (list\map ..code) + (list\each ..code) (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation table) ":" method) @@ -255,7 +255,7 @@ (def: locations (-> (List Location) Text) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed ..input_separator))) (def: .public (local vars) @@ -305,7 +305,7 @@ (-> (List Var) Expression Statement Statement) (:abstraction (format "for " (|> vars - (list\map ..code) + (list\each ..code) (text.interposed ..input_separator)) " in " (:representation source) " do" (..nested (:representation body!)) @@ -376,7 +376,7 @@ 0 (.list) _ (|> (-- arity) (enum.range n.enum 0) - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` ..Expression)))) diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 4d9817ae4..031198ffa 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -93,8 +93,9 @@ ) (type: .public Argument - {#reference? Bit - #var Var}) + (Record + {#reference? Bit + #var Var})) (def: .public ; (-> Expression Statement) @@ -183,7 +184,7 @@ (def: arguments (-> (List Expression) Text) - (|>> (list\map ..code) (text.interposed ..input_separator) ..group)) + (|>> (list\each ..code) (text.interposed ..input_separator) ..group)) (def: .public (apply/* args func) (-> (List Expression) Expression Computation) @@ -197,10 +198,10 @@ (def: parameters (-> (List Argument) Text) - (|>> (list\map (function (_ [reference? var]) - (.if reference? - (format "&" (:representation var)) - (:representation var)))) + (|>> (list\each (function (_ [reference? var]) + (.if reference? + (format "&" (:representation var)) + (:representation var)))) (text.interposed ..input_separator) ..group)) @@ -232,7 +233,7 @@ 0 (.list) _ (|> (-- arity) (enum.range n.enum 0) - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` ..Expression)))) @@ -309,7 +310,7 @@ (def: .public (array/* values) (-> (List Expression) Literal) (|> values - (list\map ..code) + (list\each ..code) (text.interposed ..input_separator) ..group (format "array") @@ -322,8 +323,8 @@ (def: .public (array/** kvs) (-> (List [Expression Expression]) Literal) (|> kvs - (list\map (function (_ [key value]) - (format (:representation key) " => " (:representation value)))) + (list\each (function (_ [key value]) + (format (:representation key) " => " (:representation value)))) (text.interposed ..input_separator) ..group (format "array") @@ -475,9 +476,10 @@ ") " (..block (:representation body!))))) (type: .public Except - {#class Constant - #exception Var - #handler Statement}) + (Record + {#class Constant + #exception Var + #handler Statement})) (def: (catch except) (-> Except Text) @@ -492,7 +494,7 @@ (format "try " (..block (:representation body!)) text.new_line (|> excepts - (list\map catch) + (list\each catch) (text.interposed text.new_line))))) (template [<name> <keyword>] diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 47fbc7fdc..b63e24118 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -191,7 +191,7 @@ ... ..expression (format left_delimiter (|> entries - (list\map entry_serializer) + (list\each entry_serializer) (text.interposed ", ")) right_delimiter)))) @@ -224,7 +224,7 @@ (-> (Expression Any) (List (Expression Any)) (Computation Any)) (<| :abstraction ... ..expression - (format (:representation func) "(" (text.interposed ", " (list\map ..code args)) ")"))) + (format (:representation func) "(" (text.interposed ", " (list\each ..code args)) ")"))) (template [<name> <brand> <prefix>] [(def: (<name> var) @@ -242,7 +242,7 @@ ... ..expression (format (:representation func) (format "(" (|> args - (list\map (function (_ arg) (format (:representation arg) ", "))) + (list\each (function (_ arg) (format (:representation arg) ", "))) text.together) (<splat> extra) ")"))))] @@ -323,13 +323,13 @@ (-> (List (Var Any)) (Expression Any) (Computation Any)) (<| :abstraction ..expression - (format "lambda " (|> arguments (list\map ..code) (text.interposed ", ")) ": " + (format "lambda " (|> arguments (list\each ..code) (text.interposed ", ")) ": " (:representation body)))) (def: .public (set vars value) (-> (List (Location Any)) (Expression Any) (Statement Any)) (:abstraction - (format (|> vars (list\map ..code) (text.interposed ", ")) + (format (|> vars (list\each ..code) (text.interposed ", ")) " = " (:representation value)))) @@ -395,9 +395,10 @@ (:abstraction "pass")) (type: .public Except - {#classes (List SVar) - #exception SVar - #handler (Statement Any)}) + (Record + {#classes (List SVar) + #exception SVar + #handler (Statement Any)})) (def: .public (try body! excepts) (-> (Statement Any) (List Except) (Statement Any)) @@ -405,10 +406,10 @@ (format "try:" (..nested (:representation body!)) (|> excepts - (list\map (function (_ [classes exception catch!]) - (format text.new_line "except (" (text.interposed ", " (list\map ..code classes)) - ") as " (:representation exception) ":" - (..nested (:representation catch!))))) + (list\each (function (_ [classes exception catch!]) + (format text.new_line "except (" (text.interposed ", " (list\each ..code classes)) + ") as " (:representation exception) ":" + (..nested (:representation catch!))))) text.together)))) (template [<name> <keyword> <pre>] @@ -437,7 +438,7 @@ (-> SVar (List (Ex [k] (Var k))) (Statement Any) (Statement Any)) (:abstraction (format "def " (:representation name) - "(" (|> args (list\map ..code) (text.interposed ", ")) "):" + "(" (|> args (list\each ..code) (text.interposed ", ")) "):" (..nested (:representation body))))) (def: .public (import module_name) @@ -462,7 +463,7 @@ 0 (.list) _ (|> (-- arity) (enum.range n.enum 0) - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` (Expression Any))))) diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index 2b4fcede3..02b192b08 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -174,7 +174,7 @@ (:abstraction (format func "(" (|> args - (list\map ..code) + (list\each ..code) (text.interposed (format "," text.new_line)) ..nested) ")")))) @@ -190,8 +190,8 @@ (def: .public named_list (-> (List [Text Expression]) Expression) - (|>> (list\map (.function (_ [key value]) - (:abstraction (format key "=" (:representation value))))) + (|>> (list\each (.function (_ [key value]) + (:abstraction (format key "=" (:representation value))))) ..list)) (def: .public (apply_kw args kw_args func) @@ -199,10 +199,10 @@ (..self_contained (format (:representation func) (format "(" - (text.interposed "," (list\map ..code args)) "," - (text.interposed "," (list\map (.function (_ [key val]) - (format key "=" (:representation val))) - kw_args)) + (text.interposed "," (list\each ..code args)) "," + (text.interposed "," (list\each (.function (_ [key val]) + (format key "=" (:representation val))) + kw_args)) ")")))) (syntax: (arity_inputs [arity <code>.nat]) @@ -210,7 +210,7 @@ 0 (.list) _ (|> arity list.indices - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` ..Expression)))) @@ -328,7 +328,7 @@ (def: .public (function inputs body) (-> (List (Ex [k] (Var k))) Expression Expression) - (let [args (|> inputs (list\map ..code) (text.interposed ", "))] + (let [args (|> inputs (list\each ..code) (text.interposed ", "))] (..self_contained (format "function(" args ") " (.._block (:representation body)))))) @@ -338,7 +338,7 @@ (let [optional (: (-> Text (Maybe Expression) (-> Text Text) Text) (.function (_ parameter value preparation) (|> value - (maybe\map (|>> :representation preparation (format ", " parameter " = "))) + (maybe\each (|>> :representation preparation (format ", " parameter " = "))) (maybe.else ""))))] (..self_contained (format "tryCatch(" diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index a63a15d09..04ddd831c 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -200,15 +200,15 @@ (def: .public array (-> (List Expression) Literal) - (|>> (list\map (|>> :representation)) + (|>> (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["[" "]"]) :abstraction)) (def: .public hash (-> (List [Expression Expression]) Literal) - (|>> (list\map (.function (_ [k v]) - (format (:representation k) " => " (:representation v)))) + (|>> (list\each (.function (_ [k v]) + (format (:representation k) " => " (:representation v)))) (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) @@ -216,7 +216,7 @@ (def: .public (apply/* args func) (-> (List Expression) Expression Computation) (|> args - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation func)) @@ -225,7 +225,7 @@ (def: .public (apply_lambda/* args lambda) (-> (List Expression) Expression Computation) (|> args - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["[" "]"]) (format (:representation lambda)) @@ -267,7 +267,7 @@ (-> (List Location) Expression Statement) (:abstraction (format (|> vars - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator)) " = " (:representation value) ..statement_suffix))) @@ -307,9 +307,10 @@ (..nested (:representation iteration!))))) (type: .public Rescue - {#classes (List Text) - #exception LVar - #rescue Statement}) + (Record + {#classes (List Text) + #exception LVar + #rescue Statement})) (def: .public (begin body! rescues) (-> Statement (List Rescue) Statement) @@ -317,10 +318,10 @@ ..block (format "begin" (..nested (:representation body!)) (|> rescues - (list\map (.function (_ [classes exception rescue]) - (format text.new_line "rescue " (text.interposed ..input_separator classes) - " => " (:representation exception) - (..nested (:representation rescue))))) + (list\each (.function (_ [classes exception rescue]) + (format text.new_line "rescue " (text.interposed ..input_separator classes) + " => " (:representation exception) + (..nested (:representation rescue))))) (text.interposed text.new_line))))) (def: .public (catch expectation body!) @@ -356,7 +357,7 @@ ..block (format "def " (:representation name) (|> args - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["(" ")"])) (..nested (:representation body!))))) @@ -364,7 +365,7 @@ (def: .public (lambda name args body!) (-> (Maybe LVar) (List Var) Statement Literal) (let [proc (|> (format (|> args - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed' "|")) (..nested (:representation body!))) @@ -438,7 +439,7 @@ 0 (.list) _ (|> (-- arity) (enum.range n.enum 0) - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` ..Expression)))) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index c91478519..104e8dda2 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -59,8 +59,9 @@ ) (type: .public Arguments - {#mandatory (List Var) - #rest (Maybe Var)}) + (Record + {#mandatory (List Var) + #rest (Maybe Var)})) (def: .public manual (-> Text Code) @@ -85,14 +86,14 @@ _ (|> (format " . " (:representation rest)) (format (|> mandatory - (list\map ..code) + (list\each ..code) (text.interposed " "))) (text.enclosed ["(" ")"]) :abstraction)) #.None (|> mandatory - (list\map ..code) + (list\each ..code) (text.interposed " ") (text.enclosed ["(" ")"]) :abstraction))) @@ -162,7 +163,7 @@ (#.Item head tail) (|> tail - (list\map (|>> :representation ..nested)) + (list\each (|>> :representation ..nested)) (#.Item (:representation head)) (text.interposed nested_new_line) (text.enclosed ["(" ")"]) @@ -309,9 +310,9 @@ (-> (List [<var> Expression]) Expression Computation) (..form (list (..var <scheme_name>) (|> bindings - (list\map (function (_ [binding/name binding/value]) - (..form (list (|> binding/name <pre>) - binding/value)))) + (list\each (function (_ [binding/name binding/value]) + (..form (list (|> binding/name <pre>) + binding/value)))) ..form) body)))] @@ -374,9 +375,9 @@ (#.Some else) (list (..form (list (..var "else") else)))) - (list\compose (list\map (function (_ [when then]) - (..form (list when then))) - clauses)) + (list\composite (list\each (function (_ [when then]) + (..form (list when then))) + clauses)) (list& variable))) body))) ) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 8df92c80a..afe40ea8b 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -1,5 +1,4 @@ (.module: - {#.doc "Tools for unit & property-based/generative testing."} [library [lux (#- and for) ["." meta] @@ -42,11 +41,11 @@ ["." program]]]]) (type: .public Tally - {#.doc (example "A record of successes and failures while executing tests.")} - {#successes Nat - #failures Nat - #expected_coverage (Set Name) - #actual_coverage (Set Name)}) + (Record + {#successes Nat + #failures Nat + #expected_coverage (Set Name) + #actual_coverage (Set Name)})) (def: (total parameter subject) (-> Tally Tally Tally) @@ -74,18 +73,15 @@ ) (type: .public Assertion - {#.doc (example "An asynchronous operation that yields test results.")} (Async [Tally Text])) (type: .public Test - {#.doc (example "A test that relies on random data generation to thoroughly cover different scenarios.")} (Random Assertion)) (def: separator text.new_line) (def: .public (and' left right) - {#.doc "Sequencing combinator (for assertions)."} (-> Assertion Assertion Assertion) (let [[read! write!] (: [(Async [Tally Text]) (async.Resolver [Tally Text])] @@ -100,30 +96,27 @@ read!)) (def: .public (and left right) - {#.doc "Sequencing combinator."} (-> Test Test Test) (do {! random.monad} [left left] - (\ ! map (..and' left) right))) + (\ ! each (..and' left) right))) (def: context_prefix text.tab) (def: .public (context description) - {#.doc (example "Adds a contextual description to a test's documentation.")} (-> Text Test Test) - (random\map (async\map (function (_ [tally documentation]) - [tally (|> documentation - (text.all_split_by ..separator) - (list\map (|>> (format context_prefix))) - (text.interposed ..separator) - (format description ..separator))])))) + (random\each (async\each (function (_ [tally documentation]) + [tally (|> documentation + (text.all_split_by ..separator) + (list\each (|>> (format context_prefix))) + (text.interposed ..separator) + (format description ..separator))])))) (def: failure_prefix "[Failure] ") (def: success_prefix "[Success] ") (def: .public failure - {#.doc (example "A failing test, with a given error message.")} (-> Text Test) (|>> (format ..failure_prefix) [..failure_tally] @@ -131,7 +124,6 @@ random\in)) (def: .public (assertion message condition) - {#.doc "Check that a condition is #1, and fail with the given message otherwise."} (-> Text Bit Assertion) (<| async\in (if condition @@ -139,25 +131,21 @@ [..failure_tally (format ..failure_prefix message)]))) (def: .public (test message condition) - {#.doc "Check that a condition is #1, and fail with the given message otherwise."} (-> Text Bit Test) (random\in (..assertion message condition))) (def: .public (lifted message random) (-> Text (Random Bit) Test) - (random\map (..assertion message) random)) + (random\each (..assertion message) random)) (def: pcg_32_magic_inc Nat (hex "FEDCBA9876543210")) (type: .public Seed - {#.doc "The seed value used for random testing (if that feature is used)."} Nat) (def: .public (seed value test) - {#.doc (example "Execute the given test with a specific seed value." - "This allows you to reproduce a failing test case as many times as you want while debugging.")} (-> Seed Test Test) (function (_ prng) (let [[_ result] (random.result (random.pcg_32 [..pcg_32_magic_inc value]) @@ -176,9 +164,6 @@ (exception: .public must_try_test_at_least_once) (def: .public (times amount test) - {#.doc (example "Allows executing a test several times." - "By doing this, it's possible to thoroughly test code with many different scenarios." - "This assumes that random data generation is being used in tests instead of fixed/constant inputs.")} (-> Nat Test Test) (case amount 0 (..failure (exception.error ..must_try_test_at_least_once [])) @@ -251,8 +236,6 @@ (def: success_exit_code +0) (def: .public (run! test) - {#.doc (example "Executes a test, and exits the program with either a successful or a failing exit code." - "WARNING: This procedure is only meant to be used in (program: ...) forms.")} (-> Test (Async Nothing)) (do async.monad [pre (async.future instant.now) @@ -272,13 +255,13 @@ (def: (|cover'| coverage condition) (-> (List Name) Bit Assertion) (let [message (|> coverage - (list\map %.name) + (list\each %.name) (text.interposed " & ")) coverage (set.of_list name.hash coverage)] (|> (..assertion message condition) - (async\map (function (_ [tally documentation]) - [(revised@ #actual_coverage (set.union coverage) tally) - documentation]))))) + (async\each (function (_ [tally documentation]) + [(revised@ #actual_coverage (set.union coverage) tally) + documentation]))))) (def: (|cover| coverage condition) (-> (List Name) Bit Test) @@ -288,13 +271,13 @@ (def: (|for| coverage test) (-> (List Name) Test Test) (let [context (|> coverage - (list\map %.name) + (list\each %.name) (text.interposed " & ")) coverage (set.of_list name.hash coverage)] - (random\map (async\map (function (_ [tally documentation]) - [(revised@ #actual_coverage (set.union coverage) tally) - documentation])) - (..context context test)))) + (random\each (async\each (function (_ [tally documentation]) + [(revised@ #actual_coverage (set.union coverage) tally) + documentation])) + (..context context test)))) (def: (name_code name) (-> Name Code) @@ -332,14 +315,9 @@ (template [<macro> <function>] [(syntax: .public (<macro> [coverage (<code>.tuple (<>.many <code>.any)) condition <code>.any]) - {#.doc (example "Specifies a test as covering one or more definitions." - "Adds to the test tally information to track which definitions have been tested." - (<macro> [definition/0 definition/1 ,,, definition/N] - (: Bit - (some "computation"))))} - (let [coverage (list\map (function (_ definition) - (` ((~! ..reference) (~ definition)))) - coverage)] + (let [coverage (list\each (function (_ definition) + (` ((~! ..reference) (~ definition)))) + coverage)] (in (list (` ((~! <function>) (: (.List .Name) (.list (~+ coverage))) @@ -351,14 +329,9 @@ (syntax: .public (for [coverage (<code>.tuple (<>.many <code>.any)) test <code>.any]) - {#.doc (example "Specifies a context for tests as covering one or more definitions." - "Adds to the test tally information to track which definitions have been tested." - (for [definition/0 definition/1 ,,, definition/N] - (: Test - some_test)))} - (let [coverage (list\map (function (_ definition) - (` ((~! ..reference) (~ definition)))) - coverage)] + (let [coverage (list\each (function (_ definition) + (` ((~! ..reference) (~ definition)))) + coverage)] (in (list (` ((~! ..|for|) (: (.List .Name) (.list (~+ coverage))) @@ -368,17 +341,12 @@ (-> Text Text Test Test) (let [coverage (..coverage module coverage)] (|> (..context module test) - (random\map (async\map (function (_ [tally documentation]) - [(revised@ #expected_coverage (set.union coverage) tally) - documentation])))))) + (random\each (async\each (function (_ [tally documentation]) + [(revised@ #expected_coverage (set.union coverage) tally) + documentation])))))) (syntax: .public (covering [module <code>.identifier test <code>.any]) - {#.doc (example "Specifies the module being covered by a test." - "Adds tracking information to the tally to know which exported definitions in the module need to be covered." - (covering .._ - (: Test - some_test)))} (do meta.monad [.let [module (name.module module)] definitions (meta.definitions module) @@ -399,7 +367,6 @@ ["Error" (%.text error)])) (def: .public (in_parallel tests) - {#.doc (example "Executes multiple tests in parallel (if the host platform supports it) to take advantage of multiple cores.")} (-> (List Test) Test) (case (list.size tests) 0 @@ -421,28 +388,28 @@ (..assertion (exception.error ..error_during_execution [error]) false)) io.io async.future - async\join)) + async\conjoint)) state (: (Atom (Dictionary Nat [Tally Text])) (atom.atom (dictionary.empty n.order))) [read! write!] (: [Assertion (async.Resolver [Tally Text])] (async.async [])) - _ (io.run! (monad.map io.monad - (function (_ [index test]) - (async.upon! (function (_ assertion) - (do io.monad - [[_ results] (atom.update! (dictionary.has index assertion) state)] - (if (n.= expected_tests (dictionary.size results)) - (let [assertions (|> results - dictionary.entries - (list\map product.right))] - (write! [(|> assertions - (list\map product.left) - (list\mix ..total ..start)) - (|> assertions - (list\map product.right) - (text.interposed ..separator))])) - (in [])))) - (run! test))) - (list.enumeration tests)))]] + _ (io.run! (monad.each io.monad + (function (_ [index test]) + (async.upon! (function (_ assertion) + (do io.monad + [[_ results] (atom.update! (dictionary.has index assertion) state)] + (if (n.= expected_tests (dictionary.size results)) + (let [assertions (|> results + dictionary.entries + (list\each product.right))] + (write! [(|> assertions + (list\each product.left) + (list\mix ..total ..start)) + (|> assertions + (list\each product.right) + (text.interposed ..separator))])) + (in [])))) + (run! test))) + (list.enumeration tests)))]] (in read!)))) diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index 051012a8d..9b7ce7118 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -23,20 +23,15 @@ [/ ["." duration (#+ Duration)]]) -(template [<name> <singular> <plural> <doc>] +(template [<name> <singular> <plural>] [(def: .public <name> - {#.doc (example <doc>)} Nat (.nat (duration.ticks <singular> <plural>)))] - [milli_seconds duration.milli_second duration.second - "Number of milli-seconds in a second."] - [seconds duration.second duration.minute - "Number of seconds in a minute."] - [minutes duration.minute duration.hour - "Number of minutes in an hour."] - [hours duration.hour duration.day - "Number of hours in an day."] + [milli_seconds duration.milli_second duration.second] + [seconds duration.second duration.minute] + [minutes duration.minute duration.hour] + [hours duration.hour duration.day] ) (def: limit @@ -82,12 +77,11 @@ ) (abstract: .public Time - {#.doc "Time is defined as milliseconds since the start of the day (00:00:00.000)."} + {} Nat (def: .public midnight - {#.doc "The instant corresponding to the start of the day: 00:00:00.000"} Time (:abstraction 0)) @@ -156,7 +150,7 @@ (def: (padded value) (-> Nat Text) (if (n.< 10 value) - (text\compose "0" (n\encoded value)) + (text\composite "0" (n\encoded value)) (n\encoded value))) (def: (positive space duration) @@ -168,17 +162,17 @@ (def: (millis_format millis) (-> Nat Text) (cond (n.= 0 millis) "" - (n.< 10 millis) ($_ text\compose ".00" (n\encoded millis)) - (n.< 100 millis) ($_ text\compose ".0" (n\encoded millis)) + (n.< 10 millis) ($_ text\composite ".00" (n\encoded millis)) + (n.< 100 millis) ($_ text\composite ".0" (n\encoded millis)) ... (n.< 1,000 millis) - ($_ text\compose "." (n\encoded millis)))) + ($_ text\composite "." (n\encoded millis)))) (type: .public Clock - {#.doc (example "A clock marking the specific hour, minute, second, and milli-second in a day.")} - {#hour Nat - #minute Nat - #second Nat - #milli_second Nat}) + (Record + {#hour Nat + #minute Nat + #second Nat + #milli_second Nat})) (def: .public (clock time) (-> Time Clock) @@ -208,15 +202,13 @@ (def: (format time) (-> Time Text) (let [(^slots [#hour #minute #second #milli_second]) (..clock time)] - ($_ text\compose + ($_ text\composite (..padded hour) ..separator (..padded minute) ..separator (..padded second) (..millis_format milli_second)))) (implementation: .public codec - {#.doc (example "Based on ISO 8601." - "For example: 21:14:51.827")} (Codec Text Time) (def: encoded ..format) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index dd2cae8de..7009c54eb 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -61,21 +61,21 @@ (-> Nat Text) (let [digits (n\encoded value)] (if (n.< 10 value) - (text\compose "0" digits) + (text\composite "0" digits) digits))) (def: separator "-") (abstract: .public Date - {#.doc (example "A date specified as a year/month/day triplet.")} + {} - {#year Year - #month Month - #day Nat} + (Record + {#year Year + #month Month + #day Nat}) (def: .public (date year month day_of_month) - {#.doc (example "A date, within the allowed limits.")} (-> Year Month Nat (Try Date)) (if (..day_is_within_limits? year month day_of_month) (#try.Success @@ -184,14 +184,12 @@ (def: (format value) (-> Date Text) - ($_ text\compose + ($_ text\composite (\ //year.codec encoded (..year value)) ..separator (..padded (|> value ..month //month.number)) ..separator (..padded (..day_of_month value)))) (implementation: .public codec - {#.doc (example "Based on ISO 8601." - "For example: 2017-01-15")} (Codec Text Date) (def: encoded ..format) diff --git a/stdlib/source/library/lux/time/day.lux b/stdlib/source/library/lux/time/day.lux index e091d2d5b..3286062ea 100644 --- a/stdlib/source/library/lux/time/day.lux +++ b/stdlib/source/library/lux/time/day.lux @@ -19,14 +19,14 @@ ["n" nat]]]]]) (type: .public Day - {#.doc (example "A day of the week.")} - #Sunday - #Monday - #Tuesday - #Wednesday - #Thursday - #Friday - #Saturday) + (Variant + #Sunday + #Monday + #Tuesday + #Wednesday + #Thursday + #Friday + #Saturday)) (implementation: .public equivalence (Equivalence Day) @@ -123,7 +123,6 @@ _ (exception.except ..not_a_day_of_the_week [value])))) (def: .public week - {#.doc (example "All the days, ordered by when they come in a week.")} (List Day) (list #Sunday #Monday diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index f36e0dff1..7b2c8e289 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -24,7 +24,7 @@ ["#." year]]) (abstract: .public Duration - {#.doc "Durations have a resolution of milli-seconds."} + {} Int @@ -112,7 +112,7 @@ (Monoid Duration) (def: identity ..empty) - (def: compose ..merged)) + (def: composite ..merged)) (template [<value> <definition>] [(def: <definition> <value>)] @@ -129,7 +129,7 @@ (def: (encoded duration) (if (\ ..equivalence = ..empty duration) - ($_ text\compose + ($_ text\composite ..positive_sign (nat\encoded 0) ..milli_second_suffix) @@ -145,13 +145,13 @@ [minutes time_left] [(ticks minute time_left) (framed minute time_left)] [seconds time_left] [(ticks second time_left) (framed second time_left)] millis (..millis time_left)] - ($_ text\compose + ($_ text\composite (if signed? ..negative_sign ..positive_sign) - (if (i.= +0 days) "" (text\compose (nat\encoded (.nat days)) ..day_suffix)) - (if (i.= +0 hours) "" (text\compose (nat\encoded (.nat hours)) ..hour_suffix)) - (if (i.= +0 minutes) "" (text\compose (nat\encoded (.nat minutes)) ..minute_suffix)) - (if (i.= +0 seconds) "" (text\compose (nat\encoded (.nat seconds)) ..second_suffix)) - (if (i.= +0 millis) "" (text\compose (nat\encoded (.nat millis)) ..milli_second_suffix)) + (if (i.= +0 days) "" (text\composite (nat\encoded (.nat days)) ..day_suffix)) + (if (i.= +0 hours) "" (text\composite (nat\encoded (.nat hours)) ..hour_suffix)) + (if (i.= +0 minutes) "" (text\composite (nat\encoded (.nat minutes)) ..minute_suffix)) + (if (i.= +0 seconds) "" (text\composite (nat\encoded (.nat seconds)) ..second_suffix)) + (if (i.= +0 millis) "" (text\composite (nat\encoded (.nat millis)) ..milli_second_suffix)) )))) (def: parser diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index 5b7b0e493..d8a1d0bff 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -33,7 +33,7 @@ ["." date (#+ Date)]]) (abstract: .public Instant - {#.doc "Instant is defined as milli-seconds since the epoch."} + {} Int @@ -87,7 +87,6 @@ ) (def: .public epoch - {#.doc "The instant corresponding to 1970-01-01T00:00:00Z."} Instant (..of_millis +0)) @@ -128,16 +127,16 @@ (-> Instant Text) (let [[date time] (..date_time instant) time (..clock_time time)] - ($_ text\compose + ($_ text\composite (\ date.codec encoded date) ..date_suffix (\ //.codec encoded time) ..time_suffix))) (def: parser (Parser Instant) (do {! <>.monad} - [days (\ ! map date.days date.parser) + [days (\ ! each date.days date.parser) _ (<text>.this ..date_suffix) - time (\ ! map //.millis //.parser) + time (\ ! each //.millis //.parser) _ (<text>.this ..time_suffix)] (in (|> (if (i.< +0 days) (|> duration.day @@ -148,15 +147,12 @@ ..absolute)))) (implementation: .public codec - {#.doc (example "Based on ISO 8601." - "For example: 2017-01-15T21:14:51.827Z")} (Codec Text Instant) (def: encoded ..format) (def: decoded (<text>.result ..parser))) (def: .public now - {#.doc (example "Yields the current instant, as measured from the operating-system's clock.")} (IO Instant) (io (..of_millis (for {@.old ("jvm invokestatic:java.lang.System:currentTimeMillis:") @.jvm (|> ("jvm member invoke static" [] "java.lang.System" "currentTimeMillis" []) diff --git a/stdlib/source/library/lux/time/month.lux b/stdlib/source/library/lux/time/month.lux index 216365ac8..c7e4af9e9 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -19,19 +19,19 @@ ["n" nat]]]]]) (type: .public Month - {#.doc (example "A month of the year.")} - #January - #February - #March - #April - #May - #June - #July - #August - #September - #October - #November - #December) + (Variant + #January + #February + #March + #April + #May + #June + #July + #August + #September + #October + #November + #December)) (implementation: .public equivalence (Equivalence Month) @@ -159,7 +159,6 @@ #January #December))) (def: .public (days month) - {#.doc (example "The amount of days of a month.")} (-> Month Nat) (case month (^template [<days> <month>] @@ -181,14 +180,12 @@ [31 #December]))) (def: .public (leap_year_days month) - {#.doc (example "The amount of days of a month (in a leap year).")} (-> Month Nat) (case month #February (++ (..days month)) _ (..days month))) (def: .public year - {#.doc (example "All the months, ordered by when they come in a year.")} (List Month) (list #January #February diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index 4347aff81..e47b0d465 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -36,14 +36,11 @@ ... https://en.wikipedia.org/wiki/Gregorian_calendar (abstract: .public Year - {#.doc (example "A year in the gregorian calendar." - "Both negative (< 0) and positive (> 0) values are valid, but not 0." - "This is because the first year of the gregorian calendar was year 1.")} + {} Int (def: .public (year value) - {#.doc (example "A valid year in the gregorian calendar, if possible.")} (-> Int (Try Year)) (case value +0 (exception.except ..there_is_no_year_0 []) @@ -59,12 +56,10 @@ ) (def: .public days - {#.doc (example "The amount of days in a typical year.")} Nat 365) (type: .public Period - {#.doc (example "An amount of years.")} Nat) (template [<period> <name>] @@ -96,7 +91,6 @@ days))) (def: .public (leaps year) - {#.doc (example "The number of leap years in a period of years.")} (-> Year Int) (let [year (|> year ..value ..internal) limit (if (i.> +0 year) @@ -124,14 +118,12 @@ (do {! <>.monad} [sign (<>.or (<text>.this "-") (in [])) digits (<text>.many <text>.decimal) - raw_year (<>.codec i.decimal (in (text\compose "+" digits)))] + raw_year (<>.codec i.decimal (in (text\composite "+" digits)))] (<>.lifted (..year (case sign (#.Left _) (i.* -1 raw_year) (#.Right _) raw_year))))) (implementation: .public codec - {#.doc (example "Based on ISO 8601." - "For example: 2017")} (Codec Text Year) (def: encoded ..encoded) diff --git a/stdlib/source/library/lux/tool/compiler.lux b/stdlib/source/library/lux/tool/compiler.lux index 10ad0d939..b1408854c 100644 --- a/stdlib/source/library/lux/tool/compiler.lux +++ b/stdlib/source/library/lux/tool/compiler.lux @@ -25,16 +25,18 @@ Text) (type: .public Input - {#module Module - #file Path - #hash Nat - #code Code}) + (Record + {#module Module + #file Path + #hash Nat + #code Code})) (type: .public (Compilation s d o) - {#dependencies (List Module) - #process (-> s Archive - (Try [s (Either (Compilation s d o) - [Descriptor (Document d) Output])]))}) + (Record + {#dependencies (List Module) + #process (-> s Archive + (Try [s (Either (Compilation s d o) + [Descriptor (Document d) Output])]))})) (type: .public (Compiler s d o) (-> Input (Compilation s d o))) diff --git a/stdlib/source/library/lux/tool/compiler/arity.lux b/stdlib/source/library/lux/tool/compiler/arity.lux index e0a3c06aa..5d20220c3 100644 --- a/stdlib/source/library/lux/tool/compiler/arity.lux +++ b/stdlib/source/library/lux/tool/compiler/arity.lux @@ -5,7 +5,8 @@ [number ["n" nat]]]]]) -(type: .public Arity Nat) +(type: .public Arity + Nat) (template [<comparison> <name>] [(def: .public <name> (-> Arity Bit) (<comparison> 1))] diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index c01a1f6c1..d7e8ca736 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -130,7 +130,7 @@ (///directive.lifted_analysis (do {! ///phase.monad} [_ (module.create hash module) - _ (monad.map ! module.import dependencies) + _ (monad.each ! module.import dependencies) .let [source (///analysis.source (value@ #///.module input) (value@ #///.code input))] _ (///analysis.set_source_code source)] (in [source [///generation.empty_buffer @@ -259,16 +259,16 @@ (in [state (#.Right [descriptor (document.write key analysis_module) - (row\map (function (_ [artifact_id custom directive]) - [artifact_id custom (write_directive directive)]) - final_buffer)])])) + (row\each (function (_ [artifact_id custom directive]) + [artifact_id custom (write_directive directive)]) + final_buffer)])])) (#.Some [source requirements temporary_payload]) (let [[temporary_buffer temporary_registry] temporary_payload] (in [state (#.Left {#///.dependencies (|> requirements (value@ #///directive.imports) - (list\map product.left)) + (list\each product.left)) #///.process (function (_ state archive) (recur (<| (///phase.result' state) (do {! ///phase.monad} @@ -282,7 +282,7 @@ (///generation.set_registry temporary_registry)) _ (|> requirements (value@ #///directive.referrals) - (monad.map ! (execute! archive))) + (monad.each ! (execute! archive))) temporary_payload (..get_current_payload temporary_payload)] (..iteration wrapper archive expander module source temporary_payload (..module_aliases analysis_module))))))})])) )))))})))) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index 1894359a9..16571b165 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -65,12 +65,13 @@ (with_expansions [<type_vars> (as_is anchor expression directive) <Operation> (as_is ///generation.Operation <type_vars>)] (type: .public (Platform <type_vars>) - {#&file_system (file.System Async) - #host (///generation.Host expression directive) - #phase (///generation.Phase <type_vars>) - #runtime (<Operation> [Registry Output]) - #phase_wrapper (-> Archive (<Operation> ///phase.Wrapper)) - #write (-> directive Binary)}) + (Record + {#&file_system (file.System Async) + #host (///generation.Host expression directive) + #phase (///generation.Phase <type_vars>) + #runtime (<Operation> [Registry Output]) + #phase_wrapper (-> Archive (<Operation> ///phase.Wrapper)) + #write (-> directive Binary)})) ... TODO: Get rid of this (type: (Action a) @@ -103,11 +104,11 @@ _ (for {@.python (|> output row.list (list.sub 128) - (monad.map ! (monad.map ! write_artifact!)) + (monad.each ! (monad.each ! write_artifact!)) (: (Action (List (List Any)))))} (|> output row.list - (monad.map ..monad write_artifact!) + (monad.each ..monad write_artifact!) (: (Action (List Any))))) document (\ async.monad in (document.check $.key document))] @@ -190,7 +191,7 @@ _ (extension.with extender (:expected directives))] (in []))) (///phase.result' state) - (\ try.monad map product.left))) + (\ try.monad each product.left))) (def: (phase_wrapper archive platform state) (All [<type_vars>] @@ -254,8 +255,8 @@ (initialize_state (extender phase_wrapper) (:expected (..complete_extensions host_directive_bundle phase_wrapper (:expected bundles))) analysis_state) - (try\map (|>> (//init.with_default_directives expander host_analysis program anchorT,expressionT,directiveT (extender phase_wrapper)) - [phase_wrapper])))))))]] + (try\each (|>> (//init.with_default_directives expander host_analysis program anchorT,expressionT,directiveT (extender phase_wrapper)) + [phase_wrapper])))))))]] (if (archive.archived? archive archive.runtime_module) (do ! [[phase_wrapper state] (with_missing_extensions platform program state)] @@ -302,8 +303,9 @@ (Dictionary Module (Set Module))) (type: Dependence - {#depends_on Mapping - #depended_by Mapping}) + (Record + {#depends_on Mapping + #depended_by Mapping})) (def: independence Dependence @@ -489,14 +491,14 @@ (All [<type_vars>] (-> Archive <State+> (Try <State+>))) (do {! try.monad} - [modules (monad.map ! (function (_ module) - (do ! - [[descriptor document output] (archive.find module archive) - lux_module (document.read $.key document)] - (in [module lux_module]))) - (archive.archived archive)) + [modules (monad.each ! (function (_ module) + (do ! + [[descriptor document output] (archive.find module archive) + lux_module (document.read $.key document)] + (in [module lux_module]))) + (archive.archived archive)) .let [additions (|> modules - (list\map product.left) + (list\each product.left) (set.of_list text.hash))]] (in (revised@ [#extension.state #///directive.analysis @@ -506,11 +508,11 @@ (|> analysis_state (:as .Lux) (revised@ #.modules (function (_ current) - (list\compose (list.only (|>> product.left - (set.member? additions) - not) - current) - modules))) + (list\composite (list.only (|>> product.left + (set.member? additions) + not) + current) + modules))) :expected)) state)))) @@ -580,10 +582,10 @@ (#.Item _) (do ! [archive,document+ (|> new_dependencies - (list\map (import! module)) + (list\each (import! module)) (monad.all ..monad)) .let [archive (|> archive,document+ - (list\map product.left) + (list\each product.left) (list\mix archive.merged archive))]] (in [archive (try.trusted (..updated_state archive state))]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux index 6d1f355ba..c8d3e1d9e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple nat int rev) + [lux (#- Tuple Variant nat int rev) [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -35,22 +35,24 @@ ["." reference (#+ Reference) ["." variable (#+ Register Variable)]]]]) -(type: .public #rec Primitive - #Unit - (#Bit Bit) - (#Nat Nat) - (#Int Int) - (#Rev Rev) - (#Frac Frac) - (#Text Text)) +(type: .public Primitive + (.Variant + #Unit + (#Bit Bit) + (#Nat Nat) + (#Int Int) + (#Rev Rev) + (#Frac Frac) + (#Text Text))) (type: .public Tag Nat) (type: .public (Variant a) - {#lefts Nat - #right? Bit - #value a}) + (Record + {#lefts Nat + #right? Bit + #value a})) (def: .public (tag lefts right?) (-> Nat Bit Nat) @@ -74,17 +76,20 @@ (List a)) (type: .public (Composite a) - (#Variant (Variant a)) - (#Tuple (Tuple a))) + (.Variant + (#Variant (Variant a)) + (#Tuple (Tuple a)))) (type: .public #rec Pattern - (#Simple Primitive) - (#Complex (Composite Pattern)) - (#Bind Register)) + (.Variant + (#Simple Primitive) + (#Complex (Composite Pattern)) + (#Bind Register))) (type: .public (Branch' e) - {#when Pattern - #then e}) + (Record + {#when Pattern + #then e})) (type: .public (Match' e) [(Branch' e) (List (Branch' e))]) @@ -93,13 +98,14 @@ (List a)) (type: .public #rec Analysis - (#Primitive Primitive) - (#Structure (Composite Analysis)) - (#Reference Reference) - (#Case Analysis (Match' Analysis)) - (#Function (Environment Analysis) Analysis) - (#Apply Analysis Analysis) - (#Extension (Extension Analysis))) + (.Variant + (#Primitive Primitive) + (#Structure (Composite Analysis)) + (#Reference Reference) + (#Case Analysis (Match' Analysis)) + (#Function (Environment Analysis) Analysis) + (#Apply Analysis Analysis) + (#Extension (Extension Analysis)))) (type: .public Branch (Branch' Analysis)) @@ -354,7 +360,7 @@ (#Tuple members) (|> members - (list\map %analysis) + (list\each %analysis) (text.interposed " ") (text.enclosed ["[" "]"]))) @@ -368,7 +374,7 @@ (|> (%analysis body) (format " ") (format (|> environment - (list\map %analysis) + (list\each %analysis) (text.interposed " ") (text.enclosed ["[" "]"]))) (text.enclosed ["(" ")"])) @@ -377,13 +383,13 @@ (|> analysis ..application #.Item - (list\map %analysis) + (list\each %analysis) (text.interposed " ") (text.enclosed ["(" ")"])) (#Extension name parameters) (|> parameters - (list\map %analysis) + (list\each %analysis) (text.interposed " ") (format (%.text name) " ") (text.enclosed ["(" ")"])))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux index 5f2770068..fa8525f02 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux @@ -21,24 +21,28 @@ [descriptor (#+ Module)]]]]]) (type: .public (Component state phase) - {#state state - #phase phase}) + (Record + {#state state + #phase phase})) (type: .public (State anchor expression directive) - {#analysis (Component analysis.State+ - analysis.Phase) - #synthesis (Component synthesis.State+ - synthesis.Phase) - #generation (Component (generation.State+ anchor expression directive) - (generation.Phase anchor expression directive))}) + (Record + {#analysis (Component analysis.State+ + analysis.Phase) + #synthesis (Component synthesis.State+ + synthesis.Phase) + #generation (Component (generation.State+ anchor expression directive) + (generation.Phase anchor expression directive))})) (type: .public Import - {#module Module - #alias Text}) + (Record + {#module Module + #alias Text})) (type: .public Requirements - {#imports (List Import) - #referrals (List Code)}) + (Record + {#imports (List Import) + #referrals (List Code)})) (def: .public no_requirements Requirements @@ -47,8 +51,8 @@ (def: .public (merge_requirements left right) (-> Requirements Requirements Requirements) - {#imports (list\compose (value@ #imports left) (value@ #imports right)) - #referrals (list\compose (value@ #referrals left) (value@ #referrals right))}) + {#imports (list\composite (value@ #imports left) (value@ #imports right)) + #referrals (list\composite (value@ #referrals left) (value@ #referrals right))}) (template [<special> <general>] [(type: .public (<special> anchor expression directive) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index aee61ebc7..aab4af121 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -65,14 +65,15 @@ re_load)) (type: .public (State anchor expression directive) - {#module Module - #anchor (Maybe anchor) - #host (Host expression directive) - #buffer (Maybe (Buffer directive)) - #registry artifact.Registry - #counter Nat - #context (Maybe artifact.ID) - #log (Row Text)}) + (Record + {#module Module + #anchor (Maybe anchor) + #host (Host expression directive) + #buffer (Maybe (Buffer directive)) + #registry artifact.Registry + #counter Nat + #context (Maybe artifact.ID) + #log (Row Text)})) (template [<special> <general>] [(type: .public (<special> anchor expression directive) @@ -176,7 +177,7 @@ (def: .public (identifier prefix) (All [anchor expression directive] (-> Text (Operation anchor expression directive Text))) - (\ phase.monad map (|>> %.nat (format prefix)) ..next)) + (\ phase.monad each (|>> %.nat (format prefix)) ..next)) (def: .public (enter_module module) (All [anchor expression directive] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux index 6c31960e4..d5b6529f0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -130,7 +130,7 @@ (#.Product _) (|> caseT type.flat_tuple - (list\map (re_quantify envs)) + (list\each (re_quantify envs)) type.tuple (\ ///.monad in)) @@ -314,12 +314,12 @@ [[inputT inputA] (//type.with_inference (analyse archive inputC)) outputH (analyse_pattern #.None inputT patternH (analyse archive bodyH)) - outputT (monad.map ! - (function (_ [patternT bodyT]) - (analyse_pattern #.None inputT patternT (analyse archive bodyT))) - branchesT) + outputT (monad.each ! + (function (_ [patternT bodyT]) + (analyse_pattern #.None inputT patternT (analyse archive bodyT))) + branchesT) outputHC (|> outputH product.left /coverage.determine) - outputTC (monad.map ! (|>> product.left /coverage.determine) outputT) + outputTC (monad.each ! (|>> product.left /coverage.determine) outputT) _ (.case (monad.mix try.monad /coverage.merged outputHC outputTC) (#try.Success coverage) (///.assertion non_exhaustive_pattern_matching [inputC branches coverage] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux index 753f6a13e..31ed0f394 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux @@ -78,8 +78,8 @@ (#Variant ?max_cases cases) (|> cases dictionary.entries - (list\map (function (_ [idx coverage]) - (format (%.nat idx) " " (%coverage coverage)))) + (list\each (function (_ [idx coverage]) + (format (%.nat idx) " " (%coverage coverage)))) (text.interposed " ") (text.enclosed ["{" "}"]) (format (%.nat (..cases ?max_cases)) " ") diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux index 3589b7224..931e27eeb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -38,8 +38,8 @@ ["Function" (%.code functionC)] ["Arguments" (|> arguments list.enumeration - (list\map (.function (_ [idx argC]) - (format (%.nat idx) " " (%.code argC)))) + (list\each (.function (_ [idx argC]) + (format (%.nat idx) " " (%.code argC)))) (text.interposed text.new_line))])) (def: .public (function analyse function_name arg_name archive body) @@ -88,10 +88,10 @@ (in functionA)))) (#.Function inputT outputT) - (<| (\ ! map (.function (_ [scope bodyA]) - (#/.Function (list\map (|>> /.variable) - (//scope.environment scope)) - bodyA))) + (<| (\ ! each (.function (_ [scope bodyA]) + (#/.Function (list\each (|>> /.variable) + (//scope.environment scope)) + bodyA))) /.with_scope ... Functions have access not only to their argument, but ... also to themselves, through a local variable. diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux index 452bf6bc1..36ddce2e2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux @@ -62,7 +62,7 @@ (-> Nat Type Type Type) (case type (#.Primitive name params) - (#.Primitive name (list\map (replace parameter_idx replacement) params)) + (#.Primitive name (list\each (replace parameter_idx replacement) params)) (^template [<tag>] [(<tag> left right) @@ -80,7 +80,7 @@ (^template [<tag>] [(<tag> env quantified) - (<tag> (list\map (replace parameter_idx replacement) env) + (<tag> (list\each (replace parameter_idx replacement) env) (replace (n.+ 2 parameter_idx) replacement quantified))]) ([#.UnivQ] [#.ExQ]) @@ -184,7 +184,7 @@ (function (recur base) (case base (#.Primitive name parameters) - (#.Primitive name (list\map recur parameters)) + (#.Primitive name (list\each recur parameters)) (^template [<tag>] [(<tag> left right) @@ -198,7 +198,7 @@ (^template [<tag>] [(<tag> environment quantified) - (<tag> (list\map recur environment) quantified)]) + (<tag> (list\each recur environment) quantified)]) ([#.UnivQ] [#.ExQ]) _ @@ -230,7 +230,7 @@ (#.Product _) (let [[lefts right] (list.split_at (-- record_size) (type.flat_tuple inferT))] (///\in (|> inferT - (type.function (list\compose lefts (list (type.tuple right)))) + (type.function (list\composite lefts (list (type.tuple right)))) (substitute_bound target originalT)))) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux index abe4b8df6..1ffb4f787 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux @@ -232,15 +232,15 @@ (-> Text (List Tag) (Operation Any)) (do {! ///.monad} [bindings (..tags module_name) - _ (monad.map ! - (function (_ tag) - (case (plist.value tag bindings) - #.None - (in []) + _ (monad.each ! + (function (_ tag) + (case (plist.value tag bindings) + #.None + (in []) - (#.Some _) - (/.except ..cannot_declare_tag_twice [module_name tag]))) - tags)] + (#.Some _) + (/.except ..cannot_declare_tag_twice [module_name tag]))) + tags)] (in []))) (def: .public (declare_tags tags exported? type) @@ -260,7 +260,7 @@ (function (_ state) (case (|> state (value@ #.modules) (plist.value self_name)) (#.Some module) - (let [namespaced_tags (list\map (|>> [self_name]) tags)] + (let [namespaced_tags (list\each (|>> [self_name]) tags)] (#try.Success [(revised@ #.modules (plist.revised self_name (|>> (revised@ #.tags (function (_ tag_bindings) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux index b859c7528..c66a7b13f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux @@ -40,8 +40,8 @@ (|> scope (value@ [#.locals #.mappings]) (plist.value name) - (maybe\map (function (_ [type value]) - [type (#variable.Local value)])))) + (maybe\each (function (_ [type value]) + [type (#variable.Local value)])))) (def: (captured? name scope) (-> Text Scope Bit) @@ -101,7 +101,7 @@ (product.right ref+inner))])) [init_ref #.End] (list.reversed inner)) - scopes (list\compose inner' outer)] + scopes (list\composite inner' outer)] (#.Right [(with@ #.scopes scopes state) (#.Some [ref_type ref])])) ))))) @@ -205,4 +205,4 @@ (-> Scope (List Variable)) (|> scope (value@ [#.captured #.mappings]) - (list\map (function (_ [_ [_ ref]]) (ref_variable ref))))) + (list\each (function (_ [_ [_ ref]]) (ref_variable ref))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux index b23704981..76781c92a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -70,9 +70,9 @@ (template [<name>] [(exception: .public (<name> {key Name} {record (List [Name Code])}) (ex.report ["Tag" (%.code (code.tag key))] - ["Record" (%.code (code.record (list\map (function (_ [keyI valC]) - [(code.tag keyI) valC]) - record)))]))] + ["Record" (%.code (code.record (list\each (function (_ [keyI valC]) + [(code.tag keyI) valC]) + record)))]))] [cannot_repeat_tag] ) @@ -86,8 +86,8 @@ ["Actual" (%.nat actual)] ["Type" (%.type type)] ["Expression" (%.code (|> record - (list\map (function (_ [keyI valueC]) - [(code.tag keyI) valueC])) + (list\each (function (_ [keyI valueC]) + [(code.tag keyI) valueC])) code.record))])) (def: .public (sum analyse lefts right? archive) @@ -176,11 +176,11 @@ (case [membersT+ membersC+] [(#.Item memberT #.End) _] (//type.with_type memberT - (\ ! map (|>> list) (analyse archive (code.tuple membersC+)))) + (\ ! each (|>> list) (analyse archive (code.tuple membersC+)))) [_ (#.Item memberC #.End)] (//type.with_type (type.tuple membersT+) - (\ ! map (|>> list) (analyse archive memberC))) + (\ ! each (|>> list) (analyse archive memberC))) [(#.Item memberT membersT+') (#.Item memberC membersC+')] (do ! @@ -218,12 +218,12 @@ _ ... Must do inference... (do ! - [membersTA (monad.map ! (|>> (analyse archive) //type.with_inference) - membersC) + [membersTA (monad.each ! (|>> (analyse archive) //type.with_inference) + membersC) _ (//type.with_env (check.check expectedT - (type.tuple (list\map product.left membersTA))))] - (in (/.tuple (list\map product.right membersTA)))))) + (type.tuple (list\each product.left membersTA))))] + (in (/.tuple (list\each product.right membersTA)))))) (^template [<tag> <instancer>] [(<tag> _) @@ -285,17 +285,17 @@ ... canonical form (with their corresponding module identified). (def: .public (normal record) (-> (List [Code Code]) (Operation (List [Name Code]))) - (monad.map ///.monad - (function (_ [key val]) - (case key - [_ (#.Tag key)] - (do ///.monad - [key (///extension.lifted (meta.normal key))] - (in [key val])) - - _ - (/.except ..record_keys_must_be_tags [key record]))) - record)) + (monad.each ///.monad + (function (_ [key val]) + (case key + [_ (#.Tag key)] + (do ///.monad + [key (///extension.lifted (meta.normal key))] + (in [key val])) + + _ + (/.except ..record_keys_must_be_tags [key record]))) + record)) ... Lux already possesses the means to analyse tuples, so ... re-implementing the same functionality for records makes no sense. @@ -333,9 +333,9 @@ (: (Dictionary Nat Code) (dictionary.empty n.hash)) record) - .let [ordered_tuple (list\map (function (_ idx) - (maybe.trusted (dictionary.value idx idx->val))) - tuple_range)]] + .let [ordered_tuple (list\each (function (_ idx) + (maybe.trusted (dictionary.value idx idx->val))) + tuple_range)]] (in [size_ts ordered_tuple recordT])) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux index 98163f30d..8db59f655 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux @@ -96,12 +96,12 @@ (case expansion (^ (list& <lux_def_module> referrals)) (|> (recur archive <lux_def_module>) - (\ ! map (revised@ #/.referrals (list\compose referrals)))) + (\ ! each (revised@ #/.referrals (list\composite referrals)))) _ (|> expansion - (monad.map ! (recur archive)) - (\ ! map (list\mix /.merge_requirements /.no_requirements))))) + (monad.each ! (recur archive)) + (\ ! each (list\mix /.merge_requirements /.no_requirements))))) _ (//.except ..not_a_directive code))))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux index 18da2442f..898766876 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux @@ -51,8 +51,9 @@ (dictionary.empty text.hash)) (type: .public (State s i o) - {#bundle (Bundle s i o) - #state s}) + (Record + {#bundle (Bundle s i o) + #state s})) (type: .public (Operation s i o v) (//.Operation (State s i o) v)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux index 16a8764d5..22c663250 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux @@ -115,7 +115,7 @@ (do {! phase.monad} [constructorA (analysis/type.with_type Any (phase archive constructorC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& constructorA inputsA)))))])) @@ -139,7 +139,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type Any (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -175,7 +175,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type Any (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index d4ffdbb2b..b1b57e1ff 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -231,7 +231,7 @@ ["Class" class] ["Method" method] ["Arguments" (exception.listing ..signature inputsJT)] - ["Hints" (exception.listing %.type (list\map product.left hints))]))] + ["Hints" (exception.listing %.type (list\each product.left hints))]))] [no_candidates] [too_many_candidates] @@ -360,7 +360,7 @@ (/////analysis.except ..non_jvm_type luxT)) (^ (#.Primitive (static array.type_name) (list elemT))) - (phase\map jvm.array (jvm_type elemT)) + (phase\each jvm.array (jvm_type elemT)) (#.Primitive class parametersT) (case (dictionary.value class ..boxes) @@ -375,17 +375,17 @@ #.None (do {! phase.monad} [parametersJT (: (Operation (List (Type Parameter))) - (monad.map ! - (function (_ parameterT) - (do phase.monad - [parameterJT (jvm_type parameterT)] - (case (jvm_parser.parameter? parameterJT) - (#.Some parameterJT) - (in parameterJT) - - #.None - (/////analysis.except ..non_parameter parameterT)))) - parametersT))] + (monad.each ! + (function (_ parameterT) + (do phase.monad + [parameterJT (jvm_type parameterT)] + (case (jvm_parser.parameter? parameterJT) + (#.Some parameterJT) + (in parameterJT) + + #.None + (/////analysis.except ..non_parameter parameterT)))) + parametersT))] (in (jvm.class class parametersJT)))) (#.Ex _) @@ -557,7 +557,7 @@ (text.starts_with? descriptor.array_prefix name) (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] - (\ phase.monad map jvm.array + (\ phase.monad each jvm.array (check_jvm (#.Primitive unprefixed (list))))) ... else @@ -567,11 +567,11 @@ (list elementT))) (|> elementT check_jvm - (phase\map jvm.array)) + (phase\each jvm.array)) (#.Primitive name parameters) (do {! phase.monad} - [parameters (monad.map ! check_parameter parameters)] + [parameters (monad.each ! check_parameter parameters)] (phase\in (jvm.class name parameters))) (#.Named name anonymous) @@ -597,7 +597,7 @@ (def: (check_object objectT) (-> .Type (Operation External)) (do {! phase.monad} - [name (\ ! map ..reflection (check_jvm objectT))] + [name (\ ! each ..reflection (check_jvm objectT))] (if (dictionary.key? ..boxes name) (/////analysis.except ..primitives_are_not_objects [name]) (phase\in name)))) @@ -864,36 +864,36 @@ (do {! phase.monad} [source_class (phase.lifted (reflection!.load class_loader source_name)) mapping (phase.lifted (reflection!.correspond source_class fromT))] - (monad.map ! - (function (_ superJT) - (do ! - [superJT (phase.lifted (reflection!.type superJT)) - .let [super_name (|> superJT ..reflection)] - super_class (phase.lifted (reflection!.load class_loader super_name)) - superT (reflection_type mapping superJT)] - (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class target_class)]))) - (case (java/lang/Class::getGenericSuperclass source_class) - (#.Some super) - (list& super (array.list (java/lang/Class::getGenericInterfaces source_class))) - - #.None - (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers source_class)) - (#.Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) - (array.list (java/lang/Class::getGenericInterfaces source_class))) - (array.list (java/lang/Class::getGenericInterfaces source_class))))))) + (monad.each ! + (function (_ superJT) + (do ! + [superJT (phase.lifted (reflection!.type superJT)) + .let [super_name (|> superJT ..reflection)] + super_class (phase.lifted (reflection!.load class_loader super_name)) + superT (reflection_type mapping superJT)] + (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class target_class)]))) + (case (java/lang/Class::getGenericSuperclass source_class) + (#.Some super) + (list& super (array.list (java/lang/Class::getGenericInterfaces source_class))) + + #.None + (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers source_class)) + (#.Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) + (array.list (java/lang/Class::getGenericInterfaces source_class))) + (array.list (java/lang/Class::getGenericInterfaces source_class))))))) (def: (inheritance_candidate_parents class_loader fromT target_class toT fromC) (-> java/lang/ClassLoader .Type (java/lang/Class java/lang/Object) .Type Code (Operation (List [[Text .Type] Bit]))) (case fromT (^ (#.Primitive _ (list& self_classT super_classT super_interfacesT+))) - (monad.map phase.monad - (function (_ superT) - (do {! phase.monad} - [super_name (\ ! map ..reflection (check_jvm superT)) - super_class (phase.lifted (reflection!.load class_loader super_name))] - (in [[super_name superT] - (java/lang/Class::isAssignableFrom super_class target_class)]))) - (list& super_classT super_interfacesT+)) + (monad.each phase.monad + (function (_ superT) + (do {! phase.monad} + [super_name (\ ! each ..reflection (check_jvm superT)) + super_class (phase.lifted (reflection!.load class_loader super_name))] + (in [[super_name superT] + (java/lang/Class::isAssignableFrom super_class target_class)]))) + (list& super_classT super_interfacesT+)) _ (/////analysis.except ..cannot_cast [fromT toT fromC]))) @@ -905,10 +905,10 @@ (^ (list fromC)) (do {! phase.monad} [toT (///.lifted meta.expected_type) - target_name (\ ! map ..reflection (check_jvm toT)) + target_name (\ ! each ..reflection (check_jvm toT)) [fromT fromA] (typeA.with_inference (analyse archive fromC)) - source_name (\ ! map ..reflection (check_jvm fromT)) + source_name (\ ! each ..reflection (check_jvm fromT)) can_cast? (: (Operation Bit) (`` (cond (~~ (template [<primitive> <object>] [(let [=primitive (reflection.reflection <primitive>)] @@ -951,7 +951,7 @@ (class_candidate_parents class_loader current_name currentT target_name target_class)))] (case (|> candidate_parents (list.only product.right) - (list\map product.left)) + (list\each product.left)) (#.Item [next_name nextT] _) (recur [next_name nextT]) @@ -1090,7 +1090,7 @@ (do phase.monad [parameters (|> (java/lang/reflect/Method::getGenericParameterTypes method) array.list - (monad.map try.monad reflection!.type) + (monad.each try.monad reflection!.type) phase.lifted) .let [modifiers (java/lang/reflect/Method::getModifiers method) correct_class? (java/lang/Object::equals class (java/lang/reflect/Method::getDeclaringClass method)) @@ -1136,7 +1136,7 @@ (do phase.monad [parameters (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) array.list - (monad.map try.monad reflection!.type) + (monad.each try.monad reflection!.type) phase.lifted)] (in (and (java/lang/Object::equals class (java/lang/reflect/Constructor::getDeclaringClass constructor)) (n.= (list.size inputsJT) (list.size parameters)) @@ -1159,15 +1159,15 @@ (def: (jvm_type_var_mapping owner_tvars method_tvars) (-> (List Text) (List Text) [(List .Type) Mapping]) - (let [jvm_tvars (list\compose owner_tvars method_tvars) + (let [jvm_tvars (list\composite owner_tvars method_tvars) lux_tvars (|> jvm_tvars list.reversed list.enumeration - (list\map (function (_ [idx name]) - [name (index_parameter idx)])) + (list\each (function (_ [idx name]) + [name (index_parameter idx)])) list.reversed) num_owner_tvars (list.size owner_tvars) - owner_tvarsT (|> lux_tvars (list.first num_owner_tvars) (list\map product.right)) + owner_tvarsT (|> lux_tvars (list.first num_owner_tvars) (list\each product.right)) mapping (dictionary.of_list text.hash lux_tvars)] [owner_tvarsT mapping])) @@ -1181,28 +1181,28 @@ _ (|> (java/lang/Class::getTypeParameters owner) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName)))) + (list\each (|>> java/lang/reflect/TypeVariable::getName)))) method_tvars (|> (java/lang/reflect/Method::getTypeParameters method) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName))) + (list\each (|>> java/lang/reflect/TypeVariable::getName))) [owner_tvarsT mapping] (jvm_type_var_mapping owner_tvars method_tvars)] (do {! phase.monad} [inputsT (|> (java/lang/reflect/Method::getGenericParameterTypes method) array.list - (monad.map ! (|>> reflection!.type phase.lifted)) - (phase\map (monad.map ! (..reflection_type mapping))) - phase\join) + (monad.each ! (|>> reflection!.type phase.lifted)) + (phase\each (monad.each ! (..reflection_type mapping))) + phase\conjoint) outputT (|> method java/lang/reflect/Method::getGenericReturnType reflection!.return phase.lifted - (phase\map (..reflection_return mapping)) - phase\join) + (phase\each (..reflection_return mapping)) + phase\conjoint) exceptionsT (|> (java/lang/reflect/Method::getGenericExceptionTypes method) array.list - (monad.map ! (|>> reflection!.type phase.lifted)) - (phase\map (monad.map ! (..reflection_type mapping))) - phase\join) + (monad.each ! (|>> reflection!.type phase.lifted)) + (phase\each (monad.each ! (..reflection_type mapping))) + phase\conjoint) .let [methodT (<| (type.univ_q (dictionary.size mapping)) (type.function (case method_style #Static @@ -1221,22 +1221,22 @@ (let [owner (java/lang/reflect/Constructor::getDeclaringClass constructor) owner_tvars (|> (java/lang/Class::getTypeParameters owner) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName))) + (list\each (|>> java/lang/reflect/TypeVariable::getName))) method_tvars (|> (java/lang/reflect/Constructor::getTypeParameters constructor) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName))) + (list\each (|>> java/lang/reflect/TypeVariable::getName))) [owner_tvarsT mapping] (jvm_type_var_mapping owner_tvars method_tvars)] (do {! phase.monad} [inputsT (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) array.list - (monad.map ! (|>> reflection!.type phase.lifted)) - (phase\map (monad.map ! (reflection_type mapping))) - phase\join) + (monad.each ! (|>> reflection!.type phase.lifted)) + (phase\each (monad.each ! (reflection_type mapping))) + phase\conjoint) exceptionsT (|> (java/lang/reflect/Constructor::getGenericExceptionTypes constructor) array.list - (monad.map ! (|>> reflection!.type phase.lifted)) - (phase\map (monad.map ! (reflection_type mapping))) - phase\join) + (monad.each ! (|>> reflection!.type phase.lifted)) + (phase\each (monad.each ! (reflection_type mapping))) + phase\conjoint) .let [objectT (#.Primitive (java/lang/Class::getName owner) owner_tvarsT) constructorT (<| (type.univ_q (dictionary.size mapping)) (type.function inputsT) @@ -1267,7 +1267,7 @@ (-> <type> (List (Type Var))) (|>> <method> array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName jvm.var))))] + (list\each (|>> java/lang/reflect/TypeVariable::getName jvm.var))))] [class_type_variables (java/lang/Class java/lang/Object) java/lang/Class::getTypeParameters] [constructor_type_variables (java/lang/reflect/Constructor java/lang/Object) java/lang/reflect/Constructor::getTypeParameters] @@ -1276,8 +1276,8 @@ (def: (aliasing expected actual) (-> (List (Type Var)) (List (Type Var)) Aliasing) - (|> (list.zipped/2 (list\map jvm_parser.name actual) - (list\map jvm_parser.name expected)) + (|> (list.zipped/2 (list\each jvm_parser.name actual) + (list\each jvm_parser.name expected)) (dictionary.of_list text.hash))) (def: (method_candidate class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) @@ -1289,17 +1289,17 @@ java/lang/Class::getDeclaredMethods array.list (list.only (|>> java/lang/reflect/Method::getName (text\= method_name))) - (monad.map ! (: (-> java/lang/reflect/Method (Operation Evaluation)) - (function (_ method) - (do ! - [.let [expected_method_tvars (method_type_variables method) - aliasing (dictionary.merged (..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)] - (\ ! map (if passes? - (|>> #Pass) - (|>> #Hint)) - (method_signature method_style method)))))))] + (monad.each ! (: (-> java/lang/reflect/Method (Operation Evaluation)) + (function (_ method) + (do ! + [.let [expected_method_tvars (method_type_variables method) + aliasing (dictionary.merged (..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)] + (\ ! each (if passes? + (|>> #Pass) + (|>> #Hint)) + (method_signature method_style method)))))))] (case (list.all pass! candidates) (#.Item method #.End) (in method) @@ -1321,15 +1321,15 @@ candidates (|> class java/lang/Class::getConstructors array.list - (monad.map ! (function (_ constructor) - (do ! - [.let [expected_method_tvars (constructor_type_variables constructor) - aliasing (dictionary.merged (..aliasing expected_class_tvars actual_class_tvars) - (..aliasing expected_method_tvars actual_method_tvars))] - passes? (check_constructor aliasing class inputsJT constructor)] - (\ ! map - (if passes? (|>> #Pass) (|>> #Hint)) - (constructor_signature constructor))))))] + (monad.each ! (function (_ constructor) + (do ! + [.let [expected_method_tvars (constructor_type_variables constructor) + aliasing (dictionary.merged (..aliasing expected_class_tvars actual_class_tvars) + (..aliasing expected_method_tvars actual_method_tvars))] + passes? (check_constructor aliasing class inputsJT constructor)] + (\ ! each + (if passes? (|>> #Pass) (|>> #Hint)) + (constructor_signature constructor))))))] (case (list.all pass! candidates) (#.Item constructor #.End) (in constructor) @@ -1358,9 +1358,9 @@ (def: (decorate_inputs typesT inputsA) (-> (List (Type Value)) (List Analysis) (List Analysis)) (|> inputsA - (list.zipped/2 (list\map (|>> ..signature /////analysis.text) typesT)) - (list\map (function (_ [type value]) - (/////analysis.tuple (list type value)))))) + (list.zipped/2 (list\each (|>> ..signature /////analysis.text) typesT)) + (list\each (function (_ [type value]) + (/////analysis.tuple (list type value)))))) (def: type_vars (<code>.tuple (<>.some ..var))) @@ -1372,11 +1372,11 @@ (function (_ extension_name analyse archive [class_tvars [class method] method_tvars argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Static argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) - [outputT argsA] (inferenceA.general archive analyse methodT (list\map product.right argsTC)) + [outputT argsA] (inferenceA.general archive analyse methodT (list\each product.right argsTC)) outputJT (check_return outputT)] (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) @@ -1390,11 +1390,11 @@ (function (_ extension_name analyse archive [class_tvars [class method] method_tvars objectC argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Virtual argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) - [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\map product.right argsTC))) + [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) .let [[objectA argsA] (case allA (#.Item objectA argsA) [objectA argsA] @@ -1415,11 +1415,11 @@ (function (_ extension_name analyse archive [class_tvars [class method] method_tvars objectC argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Special argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) - [outputT argsA] (inferenceA.general archive analyse methodT (list& objectC (list\map product.right argsTC))) + [outputT argsA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) outputJT (check_return outputT)] (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) @@ -1433,14 +1433,14 @@ (function (_ extension_name analyse archive [class_tvars [class_name method] method_tvars objectC argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class_name) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] class (phase.lifted (reflection!.load class_loader class_name)) _ (phase.assertion non_interface class_name (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers class))) [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class_name method_tvars method #Interface argsT) _ (phase.assertion ..deprecated_method [class_name method methodT] (not deprecated?)) - [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\map product.right argsTC))) + [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) .let [[objectA argsA] (case allA (#.Item objectA argsA) [objectA argsA] @@ -1462,11 +1462,11 @@ (function (_ extension_name analyse archive [class_tvars class method_tvars argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] [methodT deprecated? exceptionsT] (..constructor_candidate class_loader class_tvars class method_tvars argsT) _ (phase.assertion ..deprecated_method [class ..constructor_method methodT] (not deprecated?)) - [outputT argsA] (inferenceA.general archive analyse methodT (list\map product.right argsTC))] + [outputT argsA] (inferenceA.general archive analyse methodT (list\each product.right argsTC))] (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (decorate_inputs argsT argsA))))))])) @@ -1517,7 +1517,7 @@ (def: (annotation_analysis [name parameters]) (-> (Annotation Analysis) Analysis) (/////analysis.tuple (list& (/////analysis.text name) - (list\map annotation_parameter_analysis parameters)))) + (list\each annotation_parameter_analysis parameters)))) (template [<name> <category>] [(def: <name> @@ -1547,24 +1547,24 @@ (|>> java/lang/Class::getDeclaredMethods array.list <only> - (monad.map try.monad - (function (_ method) - (do {! try.monad} - [.let [type_variables (|> (java/lang/reflect/Method::getTypeParameters method) - array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName - jvm.var)))] - inputs (|> (java/lang/reflect/Method::getGenericParameterTypes method) - array.list - (monad.map ! reflection!.type)) - return (|> method - java/lang/reflect/Method::getGenericReturnType - reflection!.return) - exceptions (|> (java/lang/reflect/Method::getGenericExceptionTypes method) - array.list - (monad.map ! reflection!.class))] - (in [(java/lang/reflect/Method::getName method) - (jvm.method [type_variables inputs return exceptions])]))))))] + (monad.each try.monad + (function (_ method) + (do {! try.monad} + [.let [type_variables (|> (java/lang/reflect/Method::getTypeParameters method) + array.list + (list\each (|>> java/lang/reflect/TypeVariable::getName + jvm.var)))] + inputs (|> (java/lang/reflect/Method::getGenericParameterTypes method) + array.list + (monad.each ! reflection!.type)) + return (|> method + java/lang/reflect/Method::getGenericReturnType + reflection!.return) + exceptions (|> (java/lang/reflect/Method::getGenericExceptionTypes method) + array.list + (monad.each ! reflection!.class))] + (in [(java/lang/reflect/Method::getName method) + (jvm.method [type_variables inputs return exceptions])]))))))] [abstract_methods (list.only (|>> java/lang/reflect/Method::getModifiers java/lang/reflect/Modifier::isAbstract))] [methods (<|)] @@ -1575,10 +1575,10 @@ (template [<name> <methods>] [(def: (<name> class_loader) (-> java/lang/ClassLoader (List (Type Class)) (Try (List [Text (Type Method)]))) - (|>> (monad.map try.monad (|>> ..reflection (reflection!.load class_loader))) - (try\map (monad.map try.monad <methods>)) - try\join - (try\map list\join)))] + (|>> (monad.each try.monad (|>> ..reflection (reflection!.load class_loader))) + (try\each (monad.each try.monad <methods>)) + try\conjoint + (try\each list\conjoint)))] [all_abstract_methods ..abstract_methods] [all_methods ..methods] @@ -1660,28 +1660,28 @@ annotations vars exceptions self_name arguments super_arguments body] method] (do {! phase.monad} - [annotationsA (monad.map ! (function (_ [name parameters]) - (do ! - [parametersA (monad.map ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) - super_arguments (monad.map ! (function (_ [jvmT super_argC]) - (do ! - [luxT (reflection_type mapping jvmT) - super_argA (typeA.with_type luxT - (analyse archive super_argC))] - (in [jvmT super_argA]))) - super_arguments) - arguments' (monad.map ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + [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.with_type 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) [scope bodyA] (|> arguments' (#.Item [self_name selfT]) list.reversed @@ -1691,15 +1691,15 @@ (in (/////analysis.tuple (list (/////analysis.text ..constructor_tag) (visibility_analysis visibility) (/////analysis.bit strict_fp?) - (/////analysis.tuple (list\map annotation_analysis annotationsA)) - (/////analysis.tuple (list\map var_analysis vars)) + (/////analysis.tuple (list\each annotation_analysis annotationsA)) + (/////analysis.tuple (list\each var_analysis vars)) (/////analysis.text self_name) - (/////analysis.tuple (list\map ..argument_analysis arguments)) - (/////analysis.tuple (list\map class_analysis exceptions)) - (/////analysis.tuple (list\map typed_analysis super_arguments)) + (/////analysis.tuple (list\each ..argument_analysis arguments)) + (/////analysis.tuple (list\each class_analysis exceptions)) + (/////analysis.tuple (list\each typed_analysis super_arguments)) (#/////analysis.Function - (list\map (|>> /////analysis.variable) - (scope.environment scope)) + (list\each (|>> /////analysis.variable) + (scope.environment scope)) (/////analysis.tuple (list bodyA))) )))))) @@ -1742,22 +1742,22 @@ self_name arguments return exceptions body] method] (do {! phase.monad} - [annotationsA (monad.map ! (function (_ [name parameters]) - (do ! - [parametersA (monad.map ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) + [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) returnT (reflection_return mapping return) - arguments' (monad.map ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + arguments' (monad.each ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) [scope bodyA] (|> arguments' (#.Item [self_name selfT]) list.reversed @@ -1769,15 +1769,15 @@ (visibility_analysis visibility) (/////analysis.bit final?) (/////analysis.bit strict_fp?) - (/////analysis.tuple (list\map annotation_analysis annotationsA)) - (/////analysis.tuple (list\map var_analysis vars)) + (/////analysis.tuple (list\each annotation_analysis annotationsA)) + (/////analysis.tuple (list\each var_analysis vars)) (/////analysis.text self_name) - (/////analysis.tuple (list\map ..argument_analysis arguments)) + (/////analysis.tuple (list\each ..argument_analysis arguments)) (return_analysis return) - (/////analysis.tuple (list\map class_analysis exceptions)) + (/////analysis.tuple (list\each class_analysis exceptions)) (#/////analysis.Function - (list\map (|>> /////analysis.variable) - (scope.environment scope)) + (list\each (|>> /////analysis.variable) + (scope.environment scope)) (/////analysis.tuple (list bodyA))) )))))) @@ -1816,22 +1816,22 @@ arguments return body] method] (do {! phase.monad} - [annotationsA (monad.map ! (function (_ [name parameters]) - (do ! - [parametersA (monad.map ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) + [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) returnT (reflection_return mapping return) - arguments' (monad.map ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + arguments' (monad.each ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) [scope bodyA] (|> arguments' list.reversed (list\mix scope.with_local (analyse archive body)) @@ -1841,15 +1841,15 @@ (/////analysis.text method_name) (visibility_analysis visibility) (/////analysis.bit strict_fp?) - (/////analysis.tuple (list\map annotation_analysis annotationsA)) - (/////analysis.tuple (list\map var_analysis vars)) - (/////analysis.tuple (list\map ..argument_analysis arguments)) + (/////analysis.tuple (list\each annotation_analysis annotationsA)) + (/////analysis.tuple (list\each var_analysis vars)) + (/////analysis.tuple (list\each ..argument_analysis arguments)) (return_analysis return) - (/////analysis.tuple (list\map class_analysis - exceptions)) + (/////analysis.tuple (list\each class_analysis + exceptions)) (#/////analysis.Function - (list\map (|>> /////analysis.variable) - (scope.environment scope)) + (list\each (|>> /////analysis.variable) + (scope.environment scope)) (/////analysis.tuple (list bodyA))) )))))) @@ -1910,12 +1910,12 @@ (if (n.= expected_count actual_count) (do {! phase.monad} [parent_parameters (|> parent_parameters - (monad.map maybe.monad jvm_parser.var?) + (monad.each maybe.monad jvm_parser.var?) try.of_maybe phase.lifted)] (|> super_parameters - (monad.map ! (..reflection_type mapping)) - (\ ! map (|>> (list.zipped/2 parent_parameters))))) + (monad.each ! (..reflection_type mapping)) + (\ ! each (|>> (list.zipped/2 parent_parameters))))) (phase.lifted (exception.except ..mismatched_super_parameters [parent_name expected_count actual_count])))) #.None @@ -1924,12 +1924,12 @@ (def: .public (with_fresh_type_vars vars mapping) (-> (List (Type Var)) Mapping (Operation Mapping)) (do {! phase.monad} - [pairings (monad.map ! (function (_ var) - (do ! - [[_ exT] (typeA.with_env - check.existential)] - (in [var exT]))) - vars)] + [pairings (monad.each ! (function (_ var) + (do ! + [[_ exT] (typeA.with_env + check.existential)] + (in [var exT]))) + vars)] (in (list\mix (function (_ [varJ varT] mapping) (dictionary.has (jvm_parser.name varJ) varT mapping)) mapping @@ -1967,7 +1967,7 @@ (#/////analysis.Complex (#/////analysis.Tuple (|> arity list.indices - (list\map (|>> (n.+ 2) #/////analysis.Bind))))) + (list\each (|>> (n.+ 2) #/////analysis.Bind))))) #/////analysis.then bodyA} @@ -1982,21 +1982,21 @@ (do {! phase.monad} [mapping (..with_override_mapping supers parent_type mapping) mapping (..with_fresh_type_vars vars mapping) - annotationsA (monad.map ! (function (_ [name parameters]) - (do ! - [parametersA (monad.map ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) - arguments' (monad.map ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + 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) returnT (boxed_reflection_return mapping return) [scope bodyA] (|> arguments' (#.Item [self_name selfT]) @@ -2008,16 +2008,16 @@ (class_analysis parent_type) (/////analysis.text method_name) (/////analysis.bit strict_fp?) - (/////analysis.tuple (list\map annotation_analysis annotationsA)) - (/////analysis.tuple (list\map var_analysis vars)) + (/////analysis.tuple (list\each annotation_analysis annotationsA)) + (/////analysis.tuple (list\each var_analysis vars)) (/////analysis.text self_name) - (/////analysis.tuple (list\map ..argument_analysis arguments)) + (/////analysis.tuple (list\each ..argument_analysis arguments)) (return_analysis return) - (/////analysis.tuple (list\map class_analysis - exceptions)) + (/////analysis.tuple (list\each class_analysis + exceptions)) (#/////analysis.Function - (list\map (|>> /////analysis.variable) - (scope.environment scope)) + (list\each (|>> /////analysis.variable) + (scope.environment scope)) (..hide_method_body (list.size arguments) bodyA)) )))))) @@ -2026,11 +2026,11 @@ (def: .public parameter_types (-> (List (Type Var)) (Check (List [(Type Var) .Type]))) - (monad.map check.monad - (function (_ parameterJ) - (do check.monad - [[_ parameterT] check.existential] - (in [parameterJ parameterT]))))) + (monad.each check.monad + (function (_ parameterJ) + (do check.monad + [[_ parameterT] check.existential] + (in [parameterJ parameterT]))))) (def: (mismatched_methods super_set sub_set) (-> (List [Text (Type Method)]) @@ -2061,7 +2061,7 @@ class (phase.lifted (reflection!.load class_loader name)) .let [expected_parameters (|> (java/lang/Class::getTypeParameters class) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName)))] + (list\each (|>> java/lang/reflect/TypeVariable::getName)))] _ (phase.assertion ..class_parameter_mismatch [expected_parameters actual_parameters] (n.= (list.size expected_parameters) (list.size actual_parameters)))] @@ -2086,18 +2086,18 @@ (do {! phase.monad} [required_abstract_methods (phase.lifted (all_abstract_methods class_loader supers)) available_methods (phase.lifted (all_methods class_loader supers)) - overriden_methods (monad.map ! (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 [method_name (|> (jvm.method [type_vars - (list\map product.right arguments) - return - exceptions]) - (jvm_alias.method aliasing))]))) - methods) + 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 [method_name (|> (jvm.method [type_vars + (list\each product.right arguments) + return + exceptions]) + (jvm_alias.method aliasing))]))) + 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 missing_abstract_methods @@ -2122,7 +2122,7 @@ methods]) (do {! phase.monad} [_ (..ensure_fresh_class! class_loader (..reflection super_class)) - _ (monad.map ! (|>> ..reflection (..ensure_fresh_class! class_loader)) super_interfaces) + _ (monad.each ! (|>> ..reflection (..ensure_fresh_class! class_loader)) super_interfaces) parameters (typeA.with_env (..parameter_types parameters)) .let [mapping (list\mix (function (_ [parameterJ parameterT] mapping) @@ -2134,9 +2134,9 @@ super_classT (typeA.with_env (luxT.check (luxT.class mapping) (..signature super_class))) super_interfaceT+ (typeA.with_env - (monad.map check.monad - (|>> ..signature (luxT.check (luxT.class mapping))) - super_interfaces)) + (monad.each check.monad + (|>> ..signature (luxT.check (luxT.class mapping))) + super_interfaces)) selfT (///.lifted (do meta.monad [where meta.current_module_name id meta.seed] @@ -2144,20 +2144,20 @@ super_classT super_interfaceT+)))) _ (typeA.infer selfT) - constructor_argsA+ (monad.map ! (function (_ [type term]) - (do ! - [argT (reflection_type mapping type) - termA (typeA.with_type argT - (analyse archive term))] - (in [type termA]))) - constructor_args) + constructor_argsA+ (monad.each ! (function (_ [type term]) + (do ! + [argT (reflection_type mapping type) + termA (typeA.with_type argT + (analyse archive term))] + (in [type termA]))) + constructor_args) .let [supers (#.Item super_class super_interfaces)] _ (..require_complete_method_concretion class_loader supers methods) - methodsA (monad.map ! (analyse_overriden_method analyse archive selfT mapping supers) methods)] + methodsA (monad.each ! (analyse_overriden_method analyse archive selfT mapping supers) methods)] (in (#/////analysis.Extension extension_name (list (class_analysis super_class) - (/////analysis.tuple (list\map class_analysis super_interfaces)) - (/////analysis.tuple (list\map typed_analysis constructor_argsA+)) + (/////analysis.tuple (list\each class_analysis super_interfaces)) + (/////analysis.tuple (list\each typed_analysis constructor_argsA+)) (/////analysis.tuple methodsA))))))])) (def: (bundle::class class_loader) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux index 9428404aa..7cfd9eed6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux @@ -139,7 +139,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -196,7 +196,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index e56a48572..827edf300 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -55,11 +55,11 @@ (if (n.= num_expected num_actual) (do {! ////.monad} [_ (typeA.infer outputT) - argsA (monad.map ! - (function (_ [argT argC]) - (typeA.with_type argT - (analyse archive argC))) - (list.zipped/2 inputsT+ args))] + argsA (monad.each ! + (function (_ [argT argC]) + (typeA.with_type argT + (analyse archive argC))) + (list.zipped/2 inputsT+ args))] (in (#////analysis.Extension extension_name argsA))) (////analysis.except ///.incorrect_arity [extension_name num_expected num_actual])))))) @@ -105,19 +105,19 @@ [input (typeA.with_type text.Char (phase archive input)) expectedT (///.lifted meta.expected_type) - conditionals (monad.map ! (function (_ [cases branch]) - (do ! - [branch (typeA.with_type expectedT - (phase archive branch))] - (in [cases branch]))) - conditionals) + conditionals (monad.each ! (function (_ [cases branch]) + (do ! + [branch (typeA.with_type expectedT + (phase archive branch))] + (in [cases branch]))) + conditionals) else (typeA.with_type expectedT (phase archive else))] (in (|> conditionals - (list\map (function (_ [cases branch]) - (////analysis.tuple - (list (////analysis.tuple (list\map (|>> ////analysis.nat) cases)) - branch)))) + (list\each (function (_ [cases branch]) + (////analysis.tuple + (list (////analysis.tuple (list\each (|>> ////analysis.nat) cases)) + branch)))) (list& input else) (#////analysis.Extension extension_name)))))]))) @@ -164,7 +164,7 @@ (case args (^ (list typeC valueC)) (do {! ////.monad} - [actualT (\ ! map (|>> (:as Type)) + [actualT (\ ! each (|>> (:as Type)) (eval archive Type typeC)) _ (typeA.infer actualT)] (typeA.with_type actualT @@ -179,7 +179,7 @@ (case args (^ (list typeC valueC)) (do {! ////.monad} - [actualT (\ ! map (|>> (:as Type)) + [actualT (\ ! each (|>> (:as Type)) (eval archive Type typeC)) _ (typeA.infer actualT) [valueT valueA] (typeA.with_inference diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux index 306eb960e..02cb8bbb7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux @@ -125,7 +125,7 @@ [($_ <>.and <c>.text (<>.some <c>.any)) (function (_ extension phase archive [constructor inputsC]) (do {! phase.monad} - [inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + [inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text constructor) inputsA)))))])) @@ -149,7 +149,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -183,7 +183,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index 5fb859b4a..85b9124ce 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -144,7 +144,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -186,7 +186,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux index 1cc151f14..2f5ef9cbb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -139,7 +139,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -172,7 +172,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux index 2d729e701..e29c99177 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux @@ -141,7 +141,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux index 3e6c7a0ef..d9621c994 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux @@ -25,5 +25,5 @@ (All [s i o] (-> Text (-> (Bundle s i o) (Bundle s i o)))) (|>> dictionary.entries - (list\map (function (_ [key val]) [(format prefix " " key) val])) + (list\each (function (_ [key val]) [(format prefix " " key) val])) (dictionary.of_list text.hash))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 29de45227..02037b6b0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -177,7 +177,7 @@ (def: constant::modifier (Modifier field.Field) - ($_ modifier\compose + ($_ modifier\composite field.public field.static field.final)) @@ -211,7 +211,7 @@ ... TODO: Handle annotations. (#Variable [name visibility state annotations type]) - (field.field (modifier\compose visibility state) + (field.field (modifier\composite visibility state) name type (row.row)))) (def: (method_definition [mapping selfT] [analyse synthesize generate]) @@ -272,26 +272,26 @@ (luxT.check (luxT.class mapping) (..signature super_class)))) super_interfaceT+ (directive.lifted_analysis (typeA.with_env - (monad.map check.monad - (|>> ..signature (luxT.check (luxT.class mapping))) - super_interfaces))) - .let [selfT (jvm.inheritance_relationship_type (#.Primitive name (list\map product.right parameters)) + (monad.each check.monad + (|>> ..signature (luxT.check (luxT.class mapping))) + super_interfaces))) + .let [selfT (jvm.inheritance_relationship_type (#.Primitive name (list\each product.right parameters)) super_classT super_interfaceT+)] state (extension.lifted phase.get_state) .let [analyse (value@ [#directive.analysis #directive.phase] state) synthesize (value@ [#directive.synthesis #directive.phase] state) generate (value@ [#directive.generation #directive.phase] state)] - methods (monad.map ! (..method_definition [mapping selfT] [analyse synthesize generate]) - methods) + methods (monad.each ! (..method_definition [mapping selfT] [analyse synthesize generate]) + methods) ... _ (directive.lifted_generation ... (generation.save! true ["" name] ... [name ... (class.class version.v6_0 - ... (modifier\compose class.public inheritance) - ... (name.internal name) (list\map (|>> product.left parser.name ..constraint) parameters) + ... (modifier\composite class.public inheritance) + ... (name.internal name) (list\each (|>> product.left parser.name ..constraint) parameters) ... super_class super_interfaces - ... (list\map ..field_definition fields) + ... (list\each ..field_definition fields) ... (list) ... TODO: Add methods ... (row.row))])) _ (directive.lifted_generation diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index c5f410370..7a3ccaf26 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -240,9 +240,9 @@ (All [anchor expression directive] (-> (List Text) Type (Operation anchor expression directive (List Any)))) (/////directive.lifted_generation - (monad.map phase.monad (function (_ tag) - (/////generation.log! (format "#" tag " : Tag of " (%.type owner)))) - tags))) + (monad.each phase.monad (function (_ tag) + (/////generation.log! (format "#" tag " : Tag of " (%.type owner)))) + tags))) (def: (def::type_tagged expander host_analysis) (-> Expander /////analysis.Bundle Handler) @@ -283,13 +283,13 @@ .let [annotationsV (:as Code annotationsV)] _ (/////directive.lifted_analysis (do ! - [_ (monad.map ! (function (_ [module alias]) - (do ! - [_ (module.import module)] - (case alias - "" (in []) - _ (module.alias alias module)))) - imports)] + [_ (monad.each ! (function (_ [module alias]) + (do ! + [_ (module.import module)] + (case alias + "" (in []) + _ (module.alias alias module)))) + imports)] (module.set_annotations annotationsV)))] (in {#/////directive.imports imports #/////directive.referrals (list)})))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux index 49b696138..bebec6929 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux @@ -64,14 +64,14 @@ ... <s>.any)))) ... (function (_ extension_name phase archive [input else conditionals]) ... (do {! /////.monad} -... [@input (\ ! map _.var (generation.identifier "input")) +... [@input (\ ! each _.var (generation.identifier "input")) ... inputG (phase archive input) ... elseG (phase archive else) ... conditionalsG (: (Operation (List [Expression Expression])) -... (monad.map ! (function (_ [chars branch]) +... (monad.each ! (function (_ [chars branch]) ... (do ! ... [branchG (phase archive branch)] -... (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) +... (in [(|> chars (list\each (|>> .int _.int (_.=/2 @input))) _.or) ... branchG]))) ... conditionals))] ... (in (_.let (list [@input inputG]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux index 50b60d954..00da05b89 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux @@ -105,12 +105,12 @@ elseG (phase archive else) conditionalsG (: (Operation (List [(List Literal) Statement])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(list\map (|>> .int _.int) chars) - (_.return branchG)]))) - conditionals))] + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(list\each (|>> .int _.int) chars) + (_.return branchG)]))) + conditionals))] (in (_.apply/* (_.closure (list) (_.switch (_.the //runtime.i64_low_field inputG) conditionalsG diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux index 9e681c65d..546085ce4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux @@ -68,7 +68,7 @@ (function (_ extension phase archive [constructorS inputsS]) (do {! ////////phase.monad} [constructorG (phase archive constructorS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.new constructorG inputsG))))])) (def: object::get @@ -87,7 +87,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -123,7 +123,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* abstractionG inputsG))))])) (def: js::function @@ -134,9 +134,9 @@ [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation Var)) (|>> generation.identifier - (\ ! map _.var)))] - g!inputs (monad.map ! (function (_ _) (variable "input")) - (list.repeated (.nat arity) [])) + (\ ! each _.var)))] + g!inputs (monad.each ! (function (_ _) (variable "input")) + (list.repeated (.nat arity) [])) g!abstraction (variable "abstraction")] (in (_.closure g!inputs ($_ _.then diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index e18b6d356..759b2ad63 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -111,23 +111,23 @@ elseG (phase archive elseS) conditionalsG+ (: (Operation (List [(List [S4 Label]) (Bytecode Any)])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch) - @branch ///runtime.forge_label] - (in [(list\map (function (_ char) - [(try.trusted (signed.s4 (.int char))) @branch]) - chars) - ($_ _.composite - (_.set_label @branch) - branchG - (_.goto @end))]))) - conditionalsS)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch) + @branch ///runtime.forge_label] + (in [(list\each (function (_ char) + [(try.trusted (signed.s4 (.int char))) @branch]) + chars) + ($_ _.composite + (_.set_label @branch) + branchG + (_.goto @end))]))) + conditionalsS)) .let [table (|> conditionalsG+ - (list\map product.left) - list\join) + (list\each product.left) + list\conjoint) conditionalsG (|> conditionalsG+ - (list\map product.right) + (list\each product.right) (monad.all _.monad))]] (in (do _.monad [@else _.new_label] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index be90b8876..e176bcda7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -752,10 +752,10 @@ [($_ <>.and ..class <s>.text ..return (<>.some ..input)) (function (_ extension_name generate archive [class method outputT inputsTS]) (do {! //////.monad} - [inputsTG (monad.map ! (generate_input generate archive) inputsTS)] + [inputsTG (monad.each ! (generate_input generate archive) inputsTS)] (in ($_ _.composite - (monad.map _.monad product.right inputsTG) - (_.invokestatic class method (type.method [(list\map product.left inputsTG) outputT (list)])) + (monad.each _.monad product.right inputsTG) + (_.invokestatic class method (type.method [(list\each product.left inputsTG) outputT (list)])) (prepare_output outputT)))))])) (template [<name> <invoke>] @@ -766,12 +766,12 @@ (function (_ extension_name generate archive [class method outputT objectS inputsTS]) (do {! //////.monad} [objectG (generate archive objectS) - inputsTG (monad.map ! (generate_input generate archive) inputsTS)] + inputsTG (monad.each ! (generate_input generate archive) inputsTS)] (in ($_ _.composite objectG (_.checkcast class) - (monad.map _.monad product.right inputsTG) - (<invoke> class method (type.method [(list\map product.left inputsTG) outputT (list)])) + (monad.each _.monad product.right inputsTG) + (<invoke> class method (type.method [(list\each product.left inputsTG) outputT (list)])) (prepare_output outputT)))))]))] [invoke::virtual _.invokevirtual] @@ -785,12 +785,12 @@ [($_ <>.and ..class (<>.some ..input)) (function (_ extension_name generate archive [class inputsTS]) (do {! //////.monad} - [inputsTG (monad.map ! (generate_input generate archive) inputsTS)] + [inputsTG (monad.each ! (generate_input generate archive) inputsTS)] (in ($_ _.composite (_.new class) _.dup - (monad.map _.monad product.right inputsTG) - (_.invokespecial class "<init>" (type.method [(list\map product.left inputsTG) type.void (list)]))))))])) + (monad.each _.monad product.right inputsTG) + (_.invokespecial class "<init>" (type.method [(list\each product.left inputsTG) type.void (list)]))))))])) (def: bundle::member Bundle @@ -884,7 +884,7 @@ (//////synthesis.variant [lefts right? (recur sub)]) (^ (//////synthesis.tuple members)) - (//////synthesis.tuple (list\map recur members)) + (//////synthesis.tuple (list\each recur members)) (^ (//////synthesis.variable var)) (|> mapping @@ -905,31 +905,31 @@ (//////synthesis.branch/get [path (recur recordS)]) (^ (//////synthesis.loop/scope [offset initsS+ bodyS])) - (//////synthesis.loop/scope [offset (list\map recur initsS+) (recur bodyS)]) + (//////synthesis.loop/scope [offset (list\each recur initsS+) (recur bodyS)]) (^ (//////synthesis.loop/recur updatesS+)) - (//////synthesis.loop/recur (list\map recur updatesS+)) + (//////synthesis.loop/recur (list\each recur updatesS+)) (^ (//////synthesis.function/abstraction [environment arity bodyS])) - (//////synthesis.function/abstraction [(list\map (function (_ local) - (case local - (^ (//////synthesis.variable local)) - (|> mapping - (dictionary.value local) - (maybe.else local) - //////synthesis.variable) - - _ - local)) - environment) + (//////synthesis.function/abstraction [(list\each (function (_ local) + (case local + (^ (//////synthesis.variable local)) + (|> mapping + (dictionary.value local) + (maybe.else local) + //////synthesis.variable) + + _ + local)) + environment) arity bodyS]) (^ (//////synthesis.function/apply [functionS inputsS+])) - (//////synthesis.function/apply [(recur functionS) (list\map recur inputsS+)]) + (//////synthesis.function/apply [(recur functionS) (list\each recur inputsS+)]) (#//////synthesis.Extension [name inputsS+]) - (#//////synthesis.Extension [name (list\map recur inputsS+)])))) + (#//////synthesis.Extension [name (list\each recur inputsS+)])))) (def: $Object (type.class "java.lang.Object" (list))) @@ -945,24 +945,24 @@ (let [store_capturedG (|> env list.size list.indices - (monad.map _.monad (.function (_ register) - ($_ _.composite - (_.aload 0) - (_.aload (++ register)) - (_.putfield class (///reference.foreign_name register) $Object)))))] + (monad.each _.monad (.function (_ register) + ($_ _.composite + (_.aload 0) + (_.aload (++ register)) + (_.putfield class (///reference.foreign_name register) $Object)))))] (method.method method.public "<init>" (anonymous_init_method env) (list) (#.Some ($_ _.composite (_.aload 0) - (monad.map _.monad product.right inputsTG) - (_.invokespecial super_class "<init>" (type.method [(list\map product.left inputsTG) type.void (list)])) + (monad.each _.monad product.right inputsTG) + (_.invokespecial super_class "<init>" (type.method [(list\each product.left inputsTG) type.void (list)])) store_capturedG _.return))))) (def: (anonymous_instance generate archive class env) (-> Phase Archive (Type category.Class) (Environment Synthesis) (Operation (Bytecode Any))) (do {! //////.monad} - [captureG+ (monad.map ! (generate archive) env)] + [captureG+ (monad.each ! (generate archive) env)] (in ($_ _.composite (_.new class) _.dup @@ -1017,65 +1017,65 @@ class (type.class anonymous_class_name (list)) total_environment (|> overriden_methods ... Get all the environments. - (list\map product.left) + (list\each product.left) ... Combine them. - list\join + list\conjoint ... Remove duplicates. (set.from_list //////synthesis.hash) set.list) global_mapping (|> total_environment ... Give them names as "foreign" variables. list.enumeration - (list\map (function (_ [id capture]) - [capture (#//////variable.Foreign id)])) + (list\each (function (_ [id capture]) + [capture (#//////variable.Foreign id)])) (dictionary.from_list //////variable.hash)) - normalized_methods (list\map (function (_ [environment - [ownerT name - strict_fp? annotations vars - self_name arguments returnT exceptionsT - body]]) - (let [local_mapping (|> environment - list.enumeration - (list\map (function (_ [foreign_id capture]) - [(#//////variable.Foreign foreign_id) - (|> global_mapping - (dictionary.value capture) - maybe.trusted)])) - (dictionary.from_list //////variable.hash))] - [ownerT name - strict_fp? annotations vars - self_name arguments returnT exceptionsT - (normalize_method_body local_mapping body)])) - overriden_methods)] - inputsTI (monad.map ! (generate_input generate archive) inputsTS) - method_definitions (monad.map ! (function (_ [ownerT name - strict_fp? annotations vars - self_name arguments returnT exceptionsT - bodyS]) - (do ! - [bodyG (//////generation.with_context artifact_id - (generate archive bodyS))] - (in (method.method ($_ modifier\compose - method.public - method.final - (if strict_fp? - method.strict - modifier\identity)) - name - (type.method [(list\map product.right arguments) - returnT - exceptionsT]) - (list) - (#.Some ($_ _.composite - bodyG - (returnG returnT))))))) - normalized_methods) - bytecode (<| (\ ! map (format.result class.writer)) + normalized_methods (list\each (function (_ [environment + [ownerT name + strict_fp? annotations vars + self_name arguments returnT exceptionsT + body]]) + (let [local_mapping (|> environment + list.enumeration + (list\each (function (_ [foreign_id capture]) + [(#//////variable.Foreign foreign_id) + (|> global_mapping + (dictionary.value capture) + maybe.trusted)])) + (dictionary.from_list //////variable.hash))] + [ownerT name + strict_fp? annotations vars + self_name arguments returnT exceptionsT + (normalize_method_body local_mapping body)])) + overriden_methods)] + inputsTI (monad.each ! (generate_input generate archive) inputsTS) + method_definitions (monad.each ! (function (_ [ownerT name + strict_fp? annotations vars + self_name arguments returnT exceptionsT + bodyS]) + (do ! + [bodyG (//////generation.with_context artifact_id + (generate archive bodyS))] + (in (method.method ($_ modifier\composite + method.public + method.final + (if strict_fp? + method.strict + modifier\identity)) + name + (type.method [(list\each product.right arguments) + returnT + exceptionsT]) + (list) + (#.Some ($_ _.composite + bodyG + (returnG returnT))))))) + normalized_methods) + bytecode (<| (\ ! each (format.result class.writer)) //////.lifted - (class.class version.v6_0 ($_ modifier\compose class.public class.final) + (class.class version.v6_0 ($_ modifier\composite class.public class.final) (name.internal anonymous_class_name) (name.internal (..reflection super_class)) - (list\map (|>> ..reflection name.internal) super_interfaces) + (list\each (|>> ..reflection name.internal) super_interfaces) (foreign.variables total_environment) (list& (..with_anonymous_init class total_environment super_class inputsTI) method_definitions) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index 142691489..11605c1d5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -63,20 +63,20 @@ (do {! /////.monad} [inputG (phase archive input) elseG (phase archive else) - @input (\ ! map _.var (generation.identifier "input")) + @input (\ ! each _.var (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars - (list\map (|>> .int _.int (_.= @input))) - (list\mix (function (_ clause total) - (if (same? _.nil total) - clause - (_.or clause total))) - _.nil)) - branchG]))) - conditionals)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars + (list\each (|>> .int _.int (_.= @input))) + (list\mix (function (_ clause total) + (if (same? _.nil total) + clause + (_.or clause total))) + _.nil)) + branchG]))) + conditionals)) .let [closure (_.closure (list @input) (list\mix (function (_ [test then] else) (_.if test (_.return then) else)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux index f3525e411..a1bffe3cf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux @@ -80,7 +80,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -145,7 +145,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* inputsG abstractionG))))])) (def: lua::power @@ -172,10 +172,10 @@ [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation Var)) (|>> generation.identifier - (\ ! map _.var)))] - g!inputs (monad.map ! (function (_ _) - (variable "input")) - (list.repeated (.nat arity) []))] + (\ ! each _.var)))] + g!inputs (monad.each ! (function (_ _) + (variable "input")) + (list.repeated (.nat arity) []))] (in (<| (_.closure g!inputs) _.statement (case (.nat arity) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux index 3acac79be..f22dc34f1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux @@ -67,28 +67,28 @@ [inputG (phase archive input) [[context_module context_artifact] elseG] (generation.with_new_context archive (phase archive else)) - @input (\ ! map _.var (generation.identifier "input")) + @input (\ ! each _.var (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars - (list\map (|>> .int _.int (_.=== @input))) - (list\mix (function (_ clause total) - (if (same? _.null total) - clause - (_.or clause total))) - _.null)) - branchG]))) - conditionals)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars + (list\each (|>> .int _.int (_.=== @input))) + (list\mix (function (_ clause total) + (if (same? _.null total) + clause + (_.or clause total))) + _.null)) + branchG]))) + conditionals)) .let [foreigns (|> conditionals - (list\map (|>> product.right synthesis.path/then //case.dependencies)) + (list\each (|>> product.right synthesis.path/then //case.dependencies)) (list& (//case.dependencies (synthesis.path/then else))) list.together (set.of_list _.hash) set.list) @expression (_.constant (reference.artifact [context_module context_artifact])) - directive (_.define_function @expression (list& (_.parameter @input) (list\map _.reference foreigns)) + directive (_.define_function @expression (list& (_.parameter @input) (list\each _.reference foreigns)) (list\mix (function (_ [test then] else) (_.if test (_.return then) else)) (_.return elseG) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux index 3a294d06e..e391dba46 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux @@ -65,7 +65,7 @@ [($_ <>.and <s>.text (<>.some <s>.any)) (function (_ extension phase archive [constructor inputsS]) (do {! ////////phase.monad} - [inputsG (monad.map ! (phase archive) inputsS)] + [inputsG (monad.each ! (phase archive) inputsS)] (in (_.new (_.constant constructor) inputsG))))])) (def: object::get @@ -84,7 +84,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -117,7 +117,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* inputsG abstractionG))))])) (def: php::pack diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux index 6f51e40f1..78e4d7a4a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux @@ -54,7 +54,7 @@ (^template [<tag>] [(^ (<tag> value)) - (/////\map _.return (expression archive synthesis))]) + (/////\each _.return (expression archive synthesis))]) ([synthesis.bit] [synthesis.i64] [synthesis.f64] @@ -78,7 +78,7 @@ [synthesis.loop/recur //loop.recur!]) (^ (synthesis.function/abstraction abstraction)) - (/////\map _.return (//function.function statement expression archive abstraction)) + (/////\each _.return (//function.function statement expression archive abstraction)) )) (def: .public (custom [parser handler]) @@ -106,26 +106,26 @@ (do {! /////.monad} [inputG (phase archive input) else! (..statement phase archive else) - @input (\ ! map _.var (generation.identifier "input")) + @input (\ ! each _.var (generation.identifier "input")) conditionals! (: (Operation (List [(Expression Any) (Statement Any)])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branch! (..statement phase archive branch)] - (in [(|> chars - (list\map (|>> .int _.int (_.= @input))) - (list\mix (function (_ clause total) - (if (same? _.none total) - clause - (_.or clause total))) - _.none)) - branch!]))) - conditionals)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branch! (..statement phase archive branch)] + (in [(|> chars + (list\each (|>> .int _.int (_.= @input))) + (list\mix (function (_ clause total) + (if (same? _.none total) + clause + (_.or clause total))) + _.none)) + branch!]))) + conditionals)) ... .let [dependencies (//case.dependencies (list\mix (function (_ right left) ... (synthesis.path/seq left right)) ... (synthesis.path/then input) ... (#.Item (synthesis.path/then else) - ... (list\map (|>> product.right + ... (list\each (|>> product.right ... synthesis.path/then) ... conditionals)))) ... @closure (_.var (reference.artifact artifact_id)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux index 8db4b2ffd..c5b2d8abf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux @@ -79,7 +79,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -121,7 +121,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* abstractionG inputsG))))])) (def: python::function @@ -132,9 +132,9 @@ [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation SVar)) (|>> generation.identifier - (\ ! map _.var)))] - g!inputs (monad.map ! (function (_ _) (variable "input")) - (list.repeated (.nat arity) []))] + (\ ! each _.var)))] + g!inputs (monad.each ! (function (_ _) (variable "input")) + (list.repeated (.nat arity) []))] (in (_.lambda g!inputs (case (.nat arity) 0 (_.apply/1 abstractionG //runtime.unit) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux index 3cc7cf91c..1593d7a25 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux @@ -64,14 +64,14 @@ ... ... <s>.any)))) ... ... (function (_ extension_name phase archive [input else conditionals]) ... ... (do {! /////.monad} -... ... [@input (\ ! map _.var (generation.identifier "input")) +... ... [@input (\ ! each _.var (generation.identifier "input")) ... ... inputG (phase archive input) ... ... elseG (phase archive else) ... ... conditionalsG (: (Operation (List [Expression Expression])) -... ... (monad.map ! (function (_ [chars branch]) +... ... (monad.each ! (function (_ [chars branch]) ... ... (do ! ... ... [branchG (phase archive branch)] -... ... (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) +... ... (in [(|> chars (list\each (|>> .int _.int (_.=/2 @input))) _.or) ... ... branchG]))) ... ... conditionals))] ... ... (in (_.let (list [@input inputG]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux index 253b342e8..83791324e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -60,20 +60,20 @@ (do {! /////.monad} [inputG (phase archive input) elseG (phase archive else) - @input (\ ! map _.local (generation.identifier "input")) + @input (\ ! each _.local (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars - (list\map (|>> .int _.int (_.= @input))) - (list\mix (function (_ clause total) - (if (same? _.nil total) - clause - (_.or clause total))) - _.nil)) - branchG]))) - conditionals)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars + (list\each (|>> .int _.int (_.= @input))) + (list\mix (function (_ clause total) + (if (same? _.nil total) + clause + (_.or clause total))) + _.nil)) + branchG]))) + conditionals)) .let [closure (_.lambda #.None (list @input) (list\mix (function (_ [test then] else) (_.if test (_.return then) else)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux index 25d29d1a8..98edb6d30 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux @@ -80,7 +80,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -112,7 +112,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* inputsG abstractionG))))])) (def: ruby::import diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux index 79c3cce7b..3b3e87e30 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux @@ -64,16 +64,16 @@ <s>.any)))) (function (_ extension_name phase archive [input else conditionals]) (do {! /////.monad} - [@input (\ ! map _.var (generation.identifier "input")) + [@input (\ ! each _.var (generation.identifier "input")) inputG (phase archive input) elseG (phase archive else) conditionalsG (: (Operation (List [Expression Expression])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) - branchG]))) - conditionals))] + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars (list\each (|>> .int _.int (_.=/2 @input))) _.or) + branchG]))) + conditionals))] (in (_.let (list [@input inputG]) (list\mix (function (_ [test then] else) (_.if test then else)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux index 680cec039..cd2b46e13 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux @@ -93,7 +93,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* inputsG abstractionG))))])) (def: .public bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux index 982b48475..8577bb82a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux @@ -129,7 +129,7 @@ (def: (alternation @otherwise pre! post!) (-> _.Tag (Expression Any) (Expression Any) (Expression Any)) - (_.tagbody ($_ list\compose + (_.tagbody ($_ list\composite (list ..save! pre! @otherwise) @@ -141,7 +141,7 @@ (function (recur [$output @done @fail pathP]) (.case pathP (^ (/////synthesis.path/then bodyS)) - (\ ///////phase.monad map + (\ ///////phase.monad each (function (_ outputV) (_.progn (list (_.setq $output outputV) (_.go @done)))) @@ -173,13 +173,13 @@ (^template [<tag> <format> <=>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur [$output @done @fail then])] - (in [(<=> [(|> match <format>) - ..peek]) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur [$output @done @fail then])] + (in [(<=> [(|> match <format>) + ..peek]) + then!]))) + (#.Item item))] (in (list\mix (function (_ [when then] else) (_.if when then else)) (_.go @fail) @@ -195,7 +195,7 @@ (^ (<simple> idx nextP)) (|> nextP [$output @done @fail] recur - (\ ///////phase.monad map (|>> #.Some (<choice> @fail true idx))))]) + (\ ///////phase.monad each (|>> #.Some (<choice> @fail true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -217,7 +217,7 @@ (^ (/////synthesis.path/alt preP postP)) (do {! ///////phase.monad} - [@otherwise (\ ! map (|>> %.nat (format "lux_case_otherwise") _.tag) /////generation.next) + [@otherwise (\ ! each (|>> %.nat (format "lux_case_otherwise") _.tag) /////generation.next) pre! (recur [$output @done @otherwise preP]) post! (recur [$output @done @fail postP])] (in (..alternation @otherwise pre! post!))) @@ -231,8 +231,8 @@ (def: (pattern_matching $output expression archive pathP) (-> Var/1 (Generator Path)) (do {! ///////phase.monad} - [@done (\ ! map (|>> %.nat (format "lux_case_done") _.tag) /////generation.next) - @fail (\ ! map (|>> %.nat (format "lux_case_fail") _.tag) /////generation.next) + [@done (\ ! each (|>> %.nat (format "lux_case_done") _.tag) /////generation.next) + @fail (\ ! each (|>> %.nat (format "lux_case_fail") _.tag) /////generation.next) pattern_matching! (pattern_matching' expression archive [$output @done @fail pathP])] (in (_.tagbody (list pattern_matching! @@ -244,15 +244,15 @@ (Generator [Synthesis Path]) (do {! ///////phase.monad} [initG (expression archive valueS) - $output (\ ! map (|>> %.nat (format "lux_case_output") _.var) /////generation.next) + $output (\ ! each (|>> %.nat (format "lux_case_output") _.var) /////generation.next) pattern_matching! (pattern_matching $output expression archive pathP) .let [storage (|> pathP ////synthesis/case.storage (value@ #////synthesis/case.bindings) set.list - (list\map (function (_ register) - [(..register register) - _.nil])))]] + (list\each (function (_ register) + [(..register register) + _.nil])))]] (in (_.let (list& [@cursor (_.list/* (list initG))] [@savepoint (_.list/* (list))] [@temp _.nil] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux index c54bae779..9a2b543d9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux @@ -33,7 +33,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionG (expression archive functionS) - argsG+ (monad.map ! (expression archive) argsS+)] + argsG+ (monad.each ! (expression archive) argsS+)] (in (_.funcall/+ [functionG argsG+])))) (def: capture @@ -48,9 +48,9 @@ _ (do {! ///////phase.monad} - [@closure (\ ! map _.var (/////generation.identifier "closure"))] + [@closure (\ ! each _.var (/////generation.identifier "closure"))] (in (_.labels (list [@closure [(|> (list.enumeration inits) - (list\map (|>> product.left ..capture)) + (list\each (|>> product.left ..capture)) _.args) function_definition]]) (_.funcall/+ [(_.function/1 @closure) inits])))))) @@ -61,12 +61,12 @@ (def: .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) (do {! ///////phase.monad} - [@scope (\ ! map (|>> %.nat (format "function_scope") _.tag) /////generation.next) - @output (\ ! map (|>> %.nat (format "loop_output") _.var) /////generation.next) + [@scope (\ ! each (|>> %.nat (format "function_scope") _.tag) /////generation.next) + @output (\ ! each (|>> %.nat (format "loop_output") _.var) /////generation.next) [function_name bodyG] (/////generation.with_new_context archive (/////generation.with_anchor [@scope 1] (expression archive bodyS))) - closureG+ (monad.map ! (expression archive) environment) + closureG+ (monad.each ! (expression archive) environment) .let [@curried (_.var "curried") @missing (_.var "missing") arityG (|> arity .int _.int) @@ -74,7 +74,7 @@ @self (_.var (///reference.artifact function_name)) initialize_self! [(//case.register 0) (_.function/1 @self)] initialize! [(|> (list.indices arity) - (list\map ..input) + (list\each ..input) _.args) @curried]]] (with_closure closureG+ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux index 7258dc416..592733e5e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux @@ -42,16 +42,16 @@ ... true loop _ (do {! ///////phase.monad} - [@scope (\ ! map (|>> %.nat (format "loop_scope") _.tag) /////generation.next) - @output (\ ! map (|>> %.nat (format "loop_output") _.var) /////generation.next) - initsG+ (monad.map ! (expression archive) initsS+) + [@scope (\ ! each (|>> %.nat (format "loop_scope") _.tag) /////generation.next) + @output (\ ! each (|>> %.nat (format "loop_output") _.var) /////generation.next) + initsG+ (monad.each ! (expression archive) initsS+) bodyG (/////generation.with_anchor [@scope start] (expression archive bodyS))] (in (_.let (|> initsG+ list.enumeration - (list\map (function (_ [idx init]) - [(|> idx (n.+ start) //case.register) - init])) + (list\each (function (_ [idx init]) + [(|> idx (n.+ start) //case.register) + init])) (list& [@output _.nil])) (list (_.tagbody (list @scope (_.setq @output bodyG))) @@ -61,10 +61,10 @@ (Generator (List Synthesis)) (do {! ///////phase.monad} [[tag offset] /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+) + argsO+ (monad.each ! (expression archive) argsS+) .let [bindings (|> argsO+ list.enumeration - (list\map (|>> product.left (n.+ offset) //case.register)) + (list\each (|>> product.left (n.+ offset) //case.register)) _.args)]] (in (_.progn (list (_.multiple_value_setq bindings (_.values/* argsO+)) (_.go tag)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux index 0b2328715..c478118de 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux @@ -93,9 +93,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -124,9 +124,9 @@ (let [g!name (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` (_.Expression Any))) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` (_.Expression Any))) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) (_.Computation Any)) (_.call/* (~ runtime_name) (list (~+ inputsC))))) @@ -272,7 +272,7 @@ (list @io//exit)) (def: runtime - (_.progn ($_ list\compose + (_.progn ($_ list\composite runtime//adt runtime//lux runtime//i64 diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux index 6755b8f33..c8f9230a3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux @@ -25,13 +25,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (expression archive)) - (///////phase\map _.vector/*)))) + (monad.each ///////phase.monad (expression archive)) + (///////phase\each _.vector/*)))) (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (|>> [tag right?] //runtime.variant) - (expression archive valueS)))) + (///////phase\each (|>> [tag right?] //runtime.variant) + (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux index 3802776c8..c7b2eba9d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux @@ -46,8 +46,8 @@ (^ (list (~+ g!input+))) (do ///.monad [(~+ (|> g!input+ - (list\map (function (_ g!input) - (list g!input (` ((~ g!phase) (~ g!archive) (~ g!input)))))) + (list\each (function (_ g!input) + (list g!input (` ((~ g!phase) (~ g!archive) (~ g!input)))))) list.together))] ((~' in) ((~ g!extension) [(~+ g!input+)]))) @@ -65,5 +65,5 @@ (function (_ extension_name) (function (_ phase archive inputsS) (do {! ///.monad} - [inputsI (monad.map ! (phase archive) inputsS)] + [inputsI (monad.each ! (phase archive) inputsS)] (in (extension inputsI)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux index 608217f8f..61119e473 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux @@ -32,7 +32,7 @@ (case synthesis (^template [<tag>] [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) + (//////phase\each _.return (expression archive synthesis))]) ([synthesis.bit] [synthesis.i64] [synthesis.f64] @@ -60,7 +60,7 @@ (/loop.recur! statement expression archive updates) (^ (synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) + (//////phase\each _.return (/function.function statement expression archive abstraction)) )) (exception: .public cannot_recur_as_an_expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux index edce73735..2b80bcc35 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux @@ -166,7 +166,7 @@ [(^ (<simple> idx nextP)) (|> nextP recur - (\ ///////phase.monad map (|>> (_.then (<choice> true idx)) #.Some)))]) + (\ ///////phase.monad each (|>> (_.then (<choice> true idx)) #.Some)))]) ([/////synthesis.simple_left_side ..left_choice] [/////synthesis.simple_right_side ..right_choice]) @@ -254,21 +254,21 @@ (#/////synthesis.I64_Fork item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(//runtime.i64//= (//primitive.i64 (.int match)) - ..peek_cursor) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(//runtime.i64//= (//primitive.i64 (.int match)) + ..peek_cursor) + then!]))) + (#.Item item))] (in (_.cond clauses ..fail_pm!))) (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [cases (monad.map ! (function (_ [match then]) - (\ ! map (|>> [(list (<format> match))]) (recur then))) - (#.Item item))] + [cases (monad.each ! (function (_ [match then]) + (\ ! each (|>> [(list (<format> match))]) (recur then))) + (#.Item item))] (in (_.switch ..peek_cursor cases (#.Some ..fail_pm!))))]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux index 90f1cca9a..078cc797d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux @@ -31,7 +31,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* functionO argsO+)))) (def: capture @@ -48,7 +48,7 @@ _ [(_.function! @self (|> (list.enumeration inits) - (list\map (|>> product.left ..capture))) + (list\each (|>> product.left ..capture))) (_.return (_.function @self (list) body!))) (_.apply/* @self inits)])) @@ -70,7 +70,7 @@ (do {! ///////phase.monad} [[function_name body!] (/////generation.with_new_context archive (do ! - [scope (\ ! map ..@scope + [scope (\ ! each ..@scope (/////generation.context archive))] (/////generation.with_anchor [1 scope] (statement expression archive bodyS)))) @@ -87,7 +87,7 @@ (_.define (..input post) (_.at (_.i32 (.int post)) @@arguments)))) initialize_self! (list.indices arity))] - environment (monad.map ! (expression archive) environment) + environment (monad.each ! (expression archive) environment) .let [[definition instantiation] (with_closure @self environment ($_ _.then (_.define @num_args (_.the "length" @@arguments)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux index 8c3762238..7946e7b12 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux @@ -33,11 +33,11 @@ (-> Bit Register (List Expression) Statement Statement) (|> bindings list.enumeration - (list\map (function (_ [register value]) - (let [variable (//case.register (n.+ offset register))] - (if initial? - (_.define variable value) - (_.set variable value))))) + (list\each (function (_ [register value]) + (let [variable (//case.register (n.+ offset register))] + (if initial? + (_.define variable value) + (_.set variable value))))) list.reversed (list\mix _.then body))) @@ -51,8 +51,8 @@ ... true loop _ (do {! ///////phase.monad} - [@scope (\ ! map ..@scope /////generation.next) - initsO+ (monad.map ! (expression archive) initsS+) + [@scope (\ ! each ..@scope /////generation.next) + initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor [start @scope] (statement expression archive bodyS))] (in (..setup true start initsO+ @@ -80,12 +80,12 @@ (Generator! (List Synthesis)) (do {! ///////phase.monad} [[offset @scope] /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in ($_ _.then (_.define @temp (_.array argsO+)) (..setup false offset (|> argsO+ list.enumeration - (list\map (function (_ [idx _]) - (_.at (_.i32 (.int idx)) @temp)))) + (list\each (function (_ [idx _]) + (_.at (_.i32 (.int idx)) @temp)))) (_.continue_at (_.label @scope))))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 3ea974987..6579de615 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -91,9 +91,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -118,8 +118,8 @@ (#.Right [name inputs]) (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply/* (~ runtime_name) (list (~+ inputsC))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux index 6253b38b5..3788b7f6d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux @@ -25,7 +25,7 @@ _ (do {! ///////phase.monad} - [elemsT+ (monad.map ! (generate archive) elemsS+)] + [elemsT+ (monad.each ! (generate archive) elemsS+)] (in (_.array elemsT+))))) (def: .public (variant generate archive [lefts right? valueS]) @@ -33,6 +33,6 @@ (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant (_.i32 (.int tag)) - (//runtime.flag right?)) - (generate archive valueS)))) + (///////phase\each (//runtime.variant (_.i32 (.int tag)) + (//runtime.flag right?)) + (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux index 5eafc6556..afa615823 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux @@ -66,15 +66,15 @@ (let [classT (type.class class (list)) fields (: (List (Resource Field)) (list& /arity.constant - (list\compose (/foreign.variables environment) - (/partial.variables arity)))) + (list\composite (/foreign.variables environment) + (/partial.variables arity)))) methods (: (List (Resource Method)) (list& (/init.method classT environment arity) (/reset.method classT environment arity) (if (arity.multiary? arity) (|> (n.min arity /arity.maximum) list.indices - (list\map (|>> ++ (/apply.method classT environment arity @begin body))) + (list\each (|>> ++ (/apply.method classT environment arity @begin body))) (list& (/implementation.method arity @begin body))) (list (/implementation.method' //runtime.apply::name arity @begin body)))))] (do phase.monad @@ -83,7 +83,7 @@ (def: modifier (Modifier Class) - ($_ modifier\compose + ($_ modifier\composite class.public class.final)) @@ -120,16 +120,16 @@ (Generator Apply) (do {! phase.monad} [abstractionG (generate archive abstractionS) - inputsG (monad.map ! (generate archive) inputsS)] + inputsG (monad.each ! (generate archive) inputsS)] (in ($_ _.composite abstractionG (|> inputsG (list.sub /arity.maximum) - (monad.map _.monad - (function (_ batchG) - ($_ _.composite - (_.checkcast /abstract.class) - (monad.all _.monad batchG) - (_.invokevirtual /abstract.class //runtime.apply::name (//runtime.apply::type (list.size batchG))) - )))) + (monad.each _.monad + (function (_ batchG) + ($_ _.composite + (_.checkcast /abstract.class) + (monad.all _.monad batchG) + (_.invokevirtual /abstract.class //runtime.apply::name (//runtime.apply::type (list.size batchG))) + )))) )))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux index 53d058584..47ab7df90 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux @@ -15,7 +15,7 @@ (def: modifier (Modifier Field) - ($_ modifier\compose + ($_ modifier\composite field.public field.static field.final diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux index ba69187b8..b843aa13a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux @@ -39,7 +39,7 @@ (def: modifier (Modifier Field) - ($_ modifier\compose + ($_ modifier\composite field.private field.final )) @@ -52,5 +52,5 @@ (-> (-> Register Text) Nat (List (Resource Field))) (|> amount list.indices - (list\map (function (_ register) - (..variable (naming register) ..type))))) + (list\each (function (_ register) + (..variable (naming register) ..type))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux index 4dbadacb0..802592b0d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux @@ -8,7 +8,7 @@ (def: .public modifier (Modifier Method) - ($_ modifier\compose + ($_ modifier\composite method.public method.strict )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux index 1addefe99..0114ef23c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux @@ -58,7 +58,7 @@ ($_ _.composite (|> amount list.indices - (monad.map _.monad (|>> (n.+ offset) _.aload))) + (monad.each _.monad (|>> (n.+ offset) _.aload))) (_\in []) )) @@ -97,59 +97,59 @@ @labelsT (|> _.new_label (list.repeated (-- num_partials)) (monad.all _.monad)) - .let [cases (|> (list\compose (#.Item [@labelsH @labelsT]) - (list @default)) + .let [cases (|> (list\composite (#.Item [@labelsH @labelsT]) + (list @default)) list.enumeration - (list\map (function (_ [stage @case]) - (let [current_partials (|> (list.indices stage) - (list\map (///partial.get class)) - (monad.all _.monad)) - already_partial? (n.> 0 stage) - exact_match? (i.= over_extent (.int stage)) - has_more_than_necessary? (i.> over_extent (.int stage))] - ($_ _.composite - (_.set_label @case) - (cond exact_match? - ($_ _.composite - ////reference.this - (if already_partial? - (_.invokevirtual class //reset.name (//reset.type class)) - (_\in [])) - current_partials - (..inputs ..this_offset apply_arity) - (_.invokevirtual class //implementation.name (//implementation.type function_arity)) - _.areturn) - - has_more_than_necessary? - (let [arity_inputs (|> function_arity (n.- stage)) - additional_inputs (|> apply_arity (n.- arity_inputs))] - ($_ _.composite - ////reference.this - (_.invokevirtual class //reset.name (//reset.type class)) - current_partials - (..inputs ..this_offset arity_inputs) - (_.invokevirtual class //implementation.name (//implementation.type function_arity)) - (apply (n.+ ..this_offset arity_inputs) additional_inputs) - _.areturn)) + (list\each (function (_ [stage @case]) + (let [current_partials (|> (list.indices stage) + (list\each (///partial.get class)) + (monad.all _.monad)) + already_partial? (n.> 0 stage) + exact_match? (i.= over_extent (.int stage)) + has_more_than_necessary? (i.> over_extent (.int stage))] + ($_ _.composite + (_.set_label @case) + (cond exact_match? + ($_ _.composite + ////reference.this + (if already_partial? + (_.invokevirtual class //reset.name (//reset.type class)) + (_\in [])) + current_partials + (..inputs ..this_offset apply_arity) + (_.invokevirtual class //implementation.name (//implementation.type function_arity)) + _.areturn) + + has_more_than_necessary? + (let [arity_inputs (|> function_arity (n.- stage)) + additional_inputs (|> apply_arity (n.- arity_inputs))] + ($_ _.composite + ////reference.this + (_.invokevirtual class //reset.name (//reset.type class)) + current_partials + (..inputs ..this_offset arity_inputs) + (_.invokevirtual class //implementation.name (//implementation.type function_arity)) + (apply (n.+ ..this_offset arity_inputs) additional_inputs) + _.areturn)) - ... (i.< over_extent (.int stage)) - (let [current_environment (|> (list.indices (list.size environment)) - (list\map (///foreign.get class)) - (monad.all _.monad)) - missing_partials (|> _.aconst_null - (list.repeated (|> num_partials (n.- apply_arity) (n.- stage))) - (monad.all _.monad))] - ($_ _.composite - (_.new class) - _.dup - current_environment - ///partial/count.value - (..increment apply_arity) - current_partials - (..inputs ..this_offset apply_arity) - missing_partials - (_.invokevirtual class //init.name (//init.type environment function_arity)) - _.areturn))))))) + ... (i.< over_extent (.int stage)) + (let [current_environment (|> (list.indices (list.size environment)) + (list\each (///foreign.get class)) + (monad.all _.monad)) + missing_partials (|> _.aconst_null + (list.repeated (|> num_partials (n.- apply_arity) (n.- stage))) + (monad.all _.monad))] + ($_ _.composite + (_.new class) + _.dup + current_environment + ///partial/count.value + (..increment apply_arity) + current_partials + (..inputs ..this_offset apply_arity) + missing_partials + (_.invokevirtual class //init.name (//init.type environment function_arity)) + _.areturn))))))) (monad.all _.monad))]] ($_ _.composite ///partial/count.value diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux index 3c1922063..a9dc55525 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux @@ -49,10 +49,10 @@ (def: .public (type environment arity) (-> (Environment Synthesis) Arity (Type category.Method)) - (type.method [(list\compose (///foreign.closure environment) - (if (arity.multiary? arity) - (list& ///arity.type (..partials arity)) - (list))) + (type.method [(list\composite (///foreign.closure environment) + (if (arity.multiary? arity) + (list& ///arity.type (..partials arity)) + (list))) type.void (list)])) @@ -77,9 +77,9 @@ (-> Register Register) (Bytecode Any)) (|> (list.indices amount) - (list\map (function (_ register) - (put register - (_.aload (offset register))))) + (list\each (function (_ register) + (put register + (_.aload (offset register))))) (monad.all _.monad))) (def: .public (method class environment arity) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux index c126f0296..e155c518b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux @@ -54,7 +54,7 @@ (def: .public (instance generate archive class environment arity) (-> Phase Archive (Type Class) (Environment Synthesis) Arity (Operation (Bytecode Any))) (do {! phase.monad} - [foreign* (monad.map ! (generate archive) environment)] + [foreign* (monad.each ! (generate archive) environment)] (in (instance' foreign* class environment arity)))) (def: .public (method class environment arity) @@ -72,10 +72,10 @@ (#.Some ($_ _.composite ////reference.this (//init.super environment_size arity) - (monad.map _.monad (function (_ register) - (///foreign.put class register (_.aload (after_this register)))) - (list.indices environment_size)) - (monad.map _.monad (function (_ register) - (///partial.put class register (_.aload (after_arity register)))) - (list.indices (n.- ///arity.minimum arity))) + (monad.each _.monad (function (_ register) + (///foreign.put class register (_.aload (after_this register)))) + (list.indices environment_size)) + (monad.each _.monad (function (_ register) + (///partial.put class register (_.aload (after_arity register)))) + (list.indices (n.- ///arity.minimum arity))) _.areturn))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux index d787bf16e..ea526c674 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux @@ -36,7 +36,7 @@ (-> (Type Class) (Environment Synthesis) (List (Bytecode Any))) (|>> list.size list.indices - (list\map (///foreign.get class)))) + (list\each (///foreign.get class)))) (def: .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index 4915e010a..832fce239 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -55,10 +55,10 @@ (def: value::field "value") (def: value::type (type.class "java.lang.Object" (list))) -(def: value::modifier ($_ modifier\compose field.public field.final field.static)) +(def: value::modifier ($_ modifier\composite field.public field.final field.static)) (def: init::type (type.method [(list) type.void (list)])) -(def: init::modifier ($_ modifier\compose method.public method.static method.strict)) +(def: init::modifier ($_ modifier\composite method.public method.static method.strict)) (exception: .public (cannot_load {class Text} {error Text}) (exception.report @@ -114,7 +114,7 @@ _.return)))) (row.row))] (io.run! (do {! (try.with io.monad)} - [bytecode (\ ! map (format.result class.writer) + [bytecode (\ ! each (format.result class.writer) (io.io bytecode)) _ (loader.store eval_class bytecode library) class (loader.load eval_class loader) @@ -126,8 +126,8 @@ (-> Library java/lang/ClassLoader Text Definition (Try Any)) (io.run! (do (try.with io.monad) [existing_class? (|> (atom.read! library) - (\ io.monad map (function (_ library) - (dictionary.key? library class_name))) + (\ io.monad each (function (_ library) + (dictionary.key? library class_name))) (try.lifted io.monad) (: (IO (Try Bit)))) _ (if existing_class? @@ -152,7 +152,7 @@ (implementation (def: (evaluate! temp_label valueG) (let [eval_class (|> temp_label name.normal (text.replaced " " "$"))] - (\ try.monad map product.left + (\ try.monad each product.left (..evaluate! library loader eval_class valueG)))) (def: execute! diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux index 9b69ffbae..b7e934447 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux @@ -43,16 +43,16 @@ [[@begin offset] generation.anchor updatesG (|> updatesS list.enumeration - (list\map (function (_ [index updateS]) - [(n.+ offset index) updateS])) - (monad.map ! (function (_ [register updateS]) - (if (invariant? register updateS) - (in [..no_op - ..no_op]) - (do ! - [fetchG (translate archive updateS) - .let [storeG (_.astore register)]] - (in [fetchG storeG]))))))] + (list\each (function (_ [index updateS]) + [(n.+ offset index) updateS])) + (monad.each ! (function (_ [register updateS]) + (if (invariant? register updateS) + (in [..no_op + ..no_op]) + (do ! + [fetchG (translate archive updateS) + .let [storeG (_.astore register)]] + (in [fetchG storeG]))))))] (in ($_ _.composite ... It may look weird that first I fetch all the values separately, ... and then I store them all. @@ -63,11 +63,11 @@ ... will refer to the new value of X, instead of the old value, as ... should be the case. (|> updatesG - (list\map product.left) + (list\each product.left) (monad.all _.monad)) (|> updatesG list.reversed - (list\map product.right) + (list\each product.right) (monad.all _.monad)) (_.goto @begin))))) @@ -75,14 +75,14 @@ (Generator [Nat (List Synthesis) Synthesis]) (do {! phase.monad} [@begin //runtime.forge_label - initsI+ (monad.map ! (translate archive) initsS+) + initsI+ (monad.each ! (translate archive) initsS+) iterationG (generation.with_anchor [@begin offset] (translate archive iterationS)) .let [initializationG (|> (list.enumeration initsI+) - (list\map (function (_ [index initG]) - ($_ _.composite - initG - (_.astore (n.+ offset index))))) + (list\each (function (_ [index initG]) + ($_ _.composite + initG + (_.astore (n.+ offset index))))) (monad.all _.monad))]] (in ($_ _.composite initializationG diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux index 419c4eac9..3b1a602da 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux @@ -41,7 +41,7 @@ (def: main::modifier (Modifier Method) - ($_ modifier\compose + ($_ modifier\composite method.public method.static method.strict @@ -49,7 +49,7 @@ (def: program::modifier (Modifier Class) - ($_ modifier\compose + ($_ modifier\composite class.public class.final )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux index 3dafea811..fb134924a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux @@ -42,7 +42,7 @@ (def: (foreign archive variable) (-> Archive Register (Operation (Bytecode Any))) (do {! ////.monad} - [bytecode_name (\ ! map //runtime.class_name + [bytecode_name (\ ! each //runtime.class_name (generation.context archive))] (in ($_ _.composite ..this @@ -62,6 +62,6 @@ (def: .public (constant archive name) (-> Archive Name (Operation (Bytecode Any))) (do {! ////.monad} - [bytecode_name (\ ! map //runtime.class_name + [bytecode_name (\ ! each //runtime.class_name (generation.remember archive name))] (in (_.getstatic (type.class bytecode_name (list)) //value.field //type.value)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index 1d414ab77..469ab0e89 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -103,7 +103,7 @@ (def: modifier (Modifier Method) - ($_ modifier\compose + ($_ modifier\composite method.public method.static method.strict @@ -514,7 +514,7 @@ (Operation Any) (let [class (..reflection ..class) modifier (: (Modifier Class) - ($_ modifier\compose + ($_ modifier\composite class.public class.final)) bytecode (<| (format.result class.writer) @@ -546,21 +546,21 @@ (let [apply::method+ (|> (enum.range n.enum (++ //function/arity.minimum) //function/arity.maximum) - (list\map (function (_ arity) - (method.method method.public ..apply::name (..apply::type arity) - (list) - (#.Some - (let [previous_inputs (|> arity - list.indices - (monad.map _.monad _.aload))] - ($_ _.composite - previous_inputs - (_.invokevirtual //function.class ..apply::name (..apply::type (-- arity))) - (_.checkcast //function.class) - (_.aload arity) - (_.invokevirtual //function.class ..apply::name (..apply::type //function/arity.minimum)) - _.areturn)))))) - (list& (method.method (modifier\compose method.public method.abstract) + (list\each (function (_ arity) + (method.method method.public ..apply::name (..apply::type arity) + (list) + (#.Some + (let [previous_inputs (|> arity + list.indices + (monad.each _.monad _.aload))] + ($_ _.composite + previous_inputs + (_.invokevirtual //function.class ..apply::name (..apply::type (-- arity))) + (_.checkcast //function.class) + (_.aload arity) + (_.invokevirtual //function.class ..apply::name (..apply::type //function/arity.minimum)) + _.areturn)))))) + (list& (method.method (modifier\composite method.public method.abstract) ..apply::name (..apply::type //function/arity.minimum) (list) #.None))) @@ -576,12 +576,12 @@ (_.putfield //function.class //function/count.field //function/count.type) _.return)))) modifier (: (Modifier Class) - ($_ modifier\compose + ($_ modifier\composite class.public class.abstract)) class (..reflection //function.class) partial_count (: (Resource Field) - (field.field (modifier\compose field.public field.final) + (field.field (modifier\composite field.public field.final) //function/count.field //function/count.type (row.row))) @@ -610,4 +610,4 @@ ... This shift is done to avoid the possibility of forged labels ... to be in the range of the labels that are generated automatically ... during the evaluation of Bytecode expressions. - (\ ////.monad map (i64.left_shifted shift) generation.next))) + (\ ////.monad each (i64.left_shifted shift) generation.next))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux index 815c4fca0..d260cca20 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux @@ -39,14 +39,14 @@ (do {! phase.monad} [membersI (|> membersS list.enumeration - (monad.map ! (function (_ [idx member]) - (do ! - [memberI (generate archive member)] - (in (do _.monad - [_ _.dup - _ (_.int (.i64 idx)) - _ memberI] - _.aastore))))))] + (monad.each ! (function (_ [idx member]) + (do ! + [memberI (generate archive member)] + (in (do _.monad + [_ _.dup + _ (_.int (.i64 idx)) + _ memberI] + _.aastore))))))] (in (do {! _.monad} [_ (_.int (.i64 (list.size membersS))) _ (_.anewarray $Object)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux index 56860a588..59dc82f3c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux @@ -32,7 +32,7 @@ (case synthesis (^template [<tag>] [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) + (//////phase\each _.return (expression archive synthesis))]) ([synthesis.bit] [synthesis.i64] [synthesis.f64] @@ -62,7 +62,7 @@ (/loop.recur! statement expression archive updates) (^ (synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) + (//////phase\each _.return (/function.function statement expression archive abstraction)) )) (exception: .public cannot_recur_as_an_expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux index 67c156db0..c894606cf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux @@ -192,13 +192,13 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(_.= (|> match <format>) - ..peek) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(_.= (|> match <format>) + ..peek) + then!]))) + (#.Item item))] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork (<| _.int .int)] [#/////synthesis.F64_Fork _.float] @@ -209,7 +209,7 @@ (///////phase\in (<choice> false idx)) (^ (<simple> idx nextP)) - (///////phase\map (_.then (<choice> true idx)) (recur nextP))]) + (///////phase\each (_.then (<choice> true idx)) (recur nextP))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -252,13 +252,13 @@ (|>> ////synthesis/case.storage (value@ #////synthesis/case.dependencies) set.list - (list\map (function (_ variable) - (.case variable - (#///////variable.Local register) - (..register register) - - (#///////variable.Foreign register) - (..capture register)))))) + (list\each (function (_ variable) + (.case variable + (#///////variable.Local register) + (..register register) + + (#///////variable.Foreign register) + (..capture register)))))) (def: .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) @@ -275,6 +275,6 @@ (-> Phase! (Generator [Synthesis Path])) (|> [valueS pathP] (..case! statement expression archive) - (\ ///////phase.monad map + (\ ///////phase.monad each (|>> (_.closure (list)) (_.apply/* (list)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux index 88f59675d..0d96c3150 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux @@ -33,7 +33,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* argsO+ functionO)))) (def: capture @@ -49,7 +49,7 @@ _ (let [@inits (|> (list.enumeration inits) - (list\map (|>> product.left ..capture)))] + (list\each (|>> product.left ..capture)))] [(_.function @self @inits ($_ _.then (_.local_function @self @args body!) @@ -68,11 +68,11 @@ (do {! ///////phase.monad} [[function_name body!] (/////generation.with_new_context archive (do ! - [@scope (\ ! map ..@scope + [@scope (\ ! each ..@scope (/////generation.context archive))] (/////generation.with_anchor [1 @scope] (statement expression archive bodyS)))) - closureO+ (monad.map ! (expression archive) environment) + closureO+ (monad.each ! (expression archive) environment) .let [@curried (_.var "curried") arityO (|> arity .int _.int) @num_args (_.var "num_args") diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux index ddc716045..eb8ff0322 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux @@ -38,7 +38,7 @@ (-> Bit Register (List Expression) Bit Statement Statement) (let [variables (|> bindings list.enumeration - (list\map (|>> product.left (n.+ offset) //case.register)))] + (list\each (|>> product.left (n.+ offset) //case.register)))] (if as_expression? body ($_ _.then @@ -56,13 +56,13 @@ #.End (|> bodyS (statement expression archive) - (\ ///////phase.monad map (|>> [(list)]))) + (\ ///////phase.monad each (|>> [(list)]))) ... true loop _ (do {! ///////phase.monad} - [@scope (\ ! map ..@scope /////generation.next) - initsO+ (monad.map ! (expression archive) initsS+) + [@scope (\ ! each ..@scope /////generation.next) + initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor [start @scope] (statement expression archive bodyS))] (in [initsO+ @@ -86,7 +86,7 @@ .let [@loop (_.var (///reference.artifact [artifact_module artifact_id])) locals (|> initsO+ list.enumeration - (list\map (|>> product.left (n.+ start) //case.register))) + (list\each (|>> product.left (n.+ start) //case.register))) [directive instantiation] (: [Statement Expression] (case (|> (synthesis.path/then bodyS) //case.dependencies @@ -115,5 +115,5 @@ (Generator! (List Synthesis)) (do {! ///////phase.monad} [[offset @scope] /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (..setup false offset argsO+ false (_.go_to @scope))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index 997030d05..0a8cbd859 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -108,9 +108,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -143,9 +143,9 @@ (#.Right [name inputs]) (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply/* (list (~+ inputsC)) (~ runtime_name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux index 6bbd167eb..59d70ae69 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux @@ -25,13 +25,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (generate archive)) - (///////phase\map _.array)))) + (monad.each ///////phase.monad (generate archive)) + (///////phase\each _.array)))) (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase\each (//runtime.variant tag right?) + (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux index 1366ae632..4364995c7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux @@ -32,7 +32,7 @@ (case synthesis (^template [<tag>] [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) + (//////phase\each _.return (expression archive synthesis))]) ([////synthesis.bit] [////synthesis.i64] [////synthesis.f64] @@ -56,7 +56,7 @@ [////synthesis.loop/recur /loop.recur!]) (^ (////synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) + (//////phase\each _.return (/function.function statement expression archive abstraction)) )) (exception: .public cannot_recur_as_an_expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux index ccea519f2..dcd9a3c12 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux @@ -192,13 +192,13 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(_.=== (|> match <format>) - ..peek) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(_.=== (|> match <format>) + ..peek) + then!]))) + (#.Item item))] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork //primitive.i64] [#/////synthesis.F64_Fork //primitive.f64] @@ -211,7 +211,7 @@ (^ (<simple> idx nextP)) (|> nextP recur - (\ ///////phase.monad map (_.then (<choice> true idx))))]) + (\ ///////phase.monad each (_.then (<choice> true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -262,13 +262,13 @@ (|>> ////synthesis/case.storage (value@ #////synthesis/case.dependencies) set.list - (list\map (function (_ variable) - (.case variable - (#///////variable.Local register) - (..register register) - - (#///////variable.Foreign register) - (..capture register)))))) + (list\each (function (_ variable) + (.case variable + (#///////variable.Local register) + (..register register) + + (#///////variable.Foreign register) + (..capture register)))))) (def: .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) @@ -288,7 +288,7 @@ .let [@case (_.constant (///reference.artifact [case_module case_artifact])) @dependencies+ (..dependencies (/////synthesis.path/seq (/////synthesis.path/then valueS) pathP)) - directive (_.define_function @case (list\map _.parameter @dependencies+) case!)] + directive (_.define_function @case (list\each _.parameter @dependencies+) case!)] _ (/////generation.execute! directive) _ (/////generation.save! case_artifact directive)] (in (_.apply/* @dependencies+ @case)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux index c749c30f2..b68f9a404 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux @@ -33,7 +33,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionG (expression archive functionS) - argsG+ (monad.map ! (expression archive) argsS+)] + argsG+ (monad.each ! (expression archive) argsS+)] (in (_.apply/*' argsG+ functionG)))) (def: capture @@ -58,10 +58,10 @@ _ (let [@inits (|> (list.enumeration inits) - (list\map (|>> product.left ..capture)))] - [(_.set! @selfG (_.closure (list) (list\map _.parameter @inits) + (list\each (|>> product.left ..capture)))] + [(_.set! @selfG (_.closure (list) (list\each _.parameter @inits) ($_ _.then - (_.set! @selfL (_.closure (list& (_.reference @selfL) (list\map _.reference @inits)) + (_.set! @selfL (_.closure (list& (_.reference @selfL) (list\each _.reference @inits)) (list) body!)) (_.return @selfL)))) @@ -72,11 +72,11 @@ (do {! ///////phase.monad} [[function_name body!] (/////generation.with_new_context archive (do ! - [@scope (\ ! map ..@scope + [@scope (\ ! each ..@scope (/////generation.context archive))] (/////generation.with_anchor [1 @scope] (statement expression archive bodyS)))) - closureG+ (monad.map ! (expression archive) environment) + closureG+ (monad.each ! (expression archive) environment) .let [@curried (_.var "curried") arityG (|> arity .int _.int) @num_args (_.var "num_args") diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux index 8baa09008..e513411b3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux @@ -41,9 +41,9 @@ (-> Register (List Expression) Statement Statement) (|> bindings list.enumeration - (list\map (function (_ [register value]) - (let [variable (//case.register (n.+ offset register))] - (_.set! variable value)))) + (list\each (function (_ [register value]) + (let [variable (//case.register (n.+ offset register))] + (_.set! variable value)))) list.reversed (list\mix _.then body))) @@ -57,8 +57,8 @@ ... true loop _ (do {! ///////phase.monad} - [@scope (\ ! map ..@scope /////generation.next) - initsO+ (monad.map ! (expression archive) initsS+) + [@scope (\ ! each ..@scope /////generation.next) + initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor [start @scope] (statement expression archive bodyS))] (in (..setup start initsO+ @@ -80,15 +80,15 @@ (..scope! statement expression archive [start initsS+ bodyS])) .let [locals (|> initsS+ list.enumeration - (list\map (|>> product.left (n.+ start) //case.register _.parameter))) + (list\each (|>> product.left (n.+ start) //case.register _.parameter))) @loop (_.constant (///reference.artifact [loop_module loop_artifact])) - loop_variables (set.of_list _.hash (list\map product.right locals)) + loop_variables (set.of_list _.hash (list\each product.right locals)) referenced_variables (: (-> Synthesis (Set Var)) (|>> synthesis.path/then //case.dependencies (set.of_list _.hash))) [directive instantiation] (: [Statement Expression] - (case (|> (list\map referenced_variables initsS+) + (case (|> (list\each referenced_variables initsS+) (list\mix set.union (referenced_variables bodyS)) (set.difference loop_variables) set.list) @@ -97,8 +97,8 @@ @loop] foreigns - [(<| (_.define_function @loop (list\map _.parameter foreigns)) - (_.return (_.closure (list\map _.parameter foreigns) (list) scope!))) + [(<| (_.define_function @loop (list\each _.parameter foreigns)) + (_.return (_.closure (list\each _.parameter foreigns) (list) scope!))) (_.apply/* foreigns @loop)]))] _ (/////generation.execute! directive) _ (/////generation.save! loop_artifact directive)] @@ -111,12 +111,12 @@ (Generator! (List Synthesis)) (do {! ///////phase.monad} [[offset @scope] /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in ($_ _.then (_.set! @temp (_.array/* argsO+)) (..setup offset (|> argsO+ list.enumeration - (list\map (function (_ [idx _]) - (_.item (_.int (.int idx)) @temp)))) + (list\each (function (_ [idx _]) + (_.item (_.int (.int idx)) @temp)))) (_.go_to @scope)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index 8dfb51dd7..f5bde1d64 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -76,9 +76,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -111,9 +111,9 @@ (#.Right [name inputs]) (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply/* (list (~+ inputsC)) (~ runtime_name)))) @@ -124,7 +124,7 @@ (function ((~ g!_) (~ g!_)) (..with_vars [(~+ inputsC)] (_.define_function (~ g!_) - (list (~+ (list\map (|>> (~) [false] (`)) inputsC))) + (list (~+ (list\each (|>> (~) [false] (`)) inputsC))) (~ code)))))))))))))))) (runtime: (io//log! message) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux index a7fe22f6d..4d73dcec5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux @@ -29,14 +29,14 @@ _ (let [size (_.int (.int (list.size elemsS+)))] (|> elemsS+ - (monad.map ///////phase.monad (expression archive)) - (///////phase\map (|>> _.array/* - (//runtime.tuple//make size))))))) + (monad.each ///////phase.monad (expression archive)) + (///////phase\each (|>> _.array/* + (//runtime.tuple//make size))))))) (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant tag right?) - (expression archive valueS)))) + (///////phase\each (//runtime.variant tag right?) + (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index 6262f0104..e0385c419 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -36,8 +36,8 @@ (def: .public (identifier prefix) (-> Text (Operation SVar)) - (///////phase\map (|>> %.nat (format prefix) _.var) - /////generation.next)) + (///////phase\each (|>> %.nat (format prefix) _.var) + /////generation.next)) (def: .public register (-> Register SVar) @@ -199,12 +199,12 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (\ ! map - (|>> [(_.= (|> match <format>) - ..peek)]) - (recur then))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (\ ! each + (|>> [(_.= (|> match <format>) + ..peek)]) + (recur then))) + (#.Item item))] (in (#.Some (_.cond clauses ..fail_pm!))))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] @@ -241,7 +241,7 @@ (^ (<simple> idx nextP)) (|> nextP recur - (///////phase\map (_.then (<choice> true idx))))]) + (///////phase\each (_.then (<choice> true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -300,13 +300,13 @@ (|>> case.storage (value@ #case.dependencies) set.list - (list\map (function (_ variable) - (.case variable - (#///////variable.Local register) - (..register register) - - (#///////variable.Foreign register) - (..capture register)))))) + (list\each (function (_ variable) + (.case variable + (#///////variable.Local register) + (..register register) + + (#///////variable.Foreign register) + (..capture register)))))) (def: .public (case! in_closure? statement expression archive [valueS pathP]) (-> Bit (Generator! [Synthesis Path])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux index f4b31f61d..bd8bd4047 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux @@ -35,7 +35,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* functionO argsO+)))) (def: .public capture @@ -55,7 +55,7 @@ (do {! ///////phase.monad} [.let [directive (_.def @function (|> (list.enumeration inits) - (list\map (|>> product.left ..capture))) + (list\each (|>> product.left ..capture))) ($_ _.then function_definition (_.return @function)))] @@ -72,7 +72,7 @@ [[[function_module function_artifact] body!] (/////generation.with_new_context archive (/////generation.with_anchor 1 (statement expression archive bodyS))) - environment (monad.map ! (expression archive) environment) + environment (monad.each ! (expression archive) environment) .let [@curried (_.var "curried") arityO (|> arity .int _.int) @num_args (_.var "num_args") diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux index 50469f64e..670480f8e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux @@ -35,9 +35,9 @@ (-> Register (List (Expression Any)) (Statement Any) (Statement Any)) (|> bindings list.enumeration - (list\map (function (_ [register value]) - (_.set (list (//case.register (n.+ offset register))) - value))) + (list\each (function (_ [register value]) + (_.set (list (//case.register (n.+ offset register))) + value))) list.reversed (list\mix _.then body))) @@ -57,7 +57,7 @@ ... true loop _ (do {! ///////phase.monad} - [initsO+ (monad.map ! (expression archive) initsS+) + [initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor start (statement expression archive bodyS))] (in (<| (..setup start initsO+) @@ -74,14 +74,14 @@ ... true loop _ (do {! ///////phase.monad} - [initsO+ (monad.map ! (expression archive) initsS+) + [initsO+ (monad.each ! (expression archive) initsS+) [[loop_module loop_artifact] body!] (/////generation.with_new_context archive (/////generation.with_anchor start (statement expression archive bodyS))) .let [@loop (_.var (///reference.artifact [loop_module loop_artifact])) locals (|> initsS+ list.enumeration - (list\map (|>> product.left (n.+ start) //case.register))) + (list\each (|>> product.left (n.+ start) //case.register))) actual_loop (<| (_.def @loop locals) ..set_scope body!) @@ -111,11 +111,11 @@ (do {! ///////phase.monad} [offset /////generation.anchor @temp (//case.identifier "lux_recur_values") - argsO+ (monad.map ! (expression archive) argsS+) + argsO+ (monad.each ! (expression archive) argsS+) .let [re_binds (|> argsO+ list.enumeration - (list\map (function (_ [idx _]) - (_.item (_.int (.int idx)) @temp))))]] + (list\each (function (_ [idx _]) + (_.item (_.int (.int idx)) @temp))))]] (in ($_ _.then (_.set (list @temp) (_.list argsO+)) (..setup offset re_binds diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index 9952ea02d..fafc59235 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -115,9 +115,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -143,9 +143,9 @@ (let [nameC (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) runtime_nameC (` (runtime_name (~ (code.text name)))) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` (_.Expression Any))) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` (_.Expression Any))) + inputs)] (in (list (` (def: .public ((~ nameC) (~+ inputsC)) (-> (~+ inputs_typesC) (Computation Any)) (_.apply/* (~ runtime_nameC) (list (~+ inputsC))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux index 756e3f00d..85dc6218c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux @@ -25,13 +25,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (generate archive)) - (///////phase\map _.list)))) + (monad.each ///////phase.monad (generate archive)) + (///////phase\each _.list)))) (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase\each (//runtime.variant tag right?) + (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux index e751e412b..86f376beb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux @@ -164,13 +164,13 @@ (^template [<tag> <format> <=>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(<=> (|> match <format>) - ..peek) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(<=> (|> match <format>) + ..peek) + then!]))) + (#.Item item))] (in (list\mix (function (_ [when then] else) (_.if when then else)) ..fail! @@ -233,8 +233,8 @@ (Generator [Synthesis Path]) (do {! ///////phase.monad} [valueO (expression archive valueS)] - (<| (\ ! map (|>> ($_ _.then - (_.set! $cursor (_.list (list valueO))) - (_.set! $savepoint (_.list (list)))) - _.block)) + (<| (\ ! each (|>> ($_ _.then + (_.set! $cursor (_.list (list valueO))) + (_.set! $savepoint (_.list (list)))) + _.block)) (pattern_matching expression archive pathP)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux index f2335374c..5a4914c31 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux @@ -36,7 +36,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) (def: (with_closure function_id $function inits function_definition) @@ -55,7 +55,7 @@ (_.function (|> inits list.size list.indices - (list\map //case.capture)) + (list\each //case.capture)) ($_ _.then function_definition $function)))] @@ -76,11 +76,11 @@ (do {! ///////phase.monad} [[[function_module function_artifact] bodyO] (/////generation.with_new_context archive (do ! - [$self (\ ! map (|>> ///reference.artifact _.var) + [$self (\ ! each (|>> ///reference.artifact _.var) (/////generation.context archive))] (/////generation.with_anchor $self (expression archive bodyS)))) - closureO+ (monad.map ! (expression archive) environment) + closureO+ (monad.each ! (expression archive) environment) .let [arityO (|> arity .int _.int) $num_args (_.var "num_args") $self (_.var (///reference.artifact [function_module function_artifact])) @@ -96,7 +96,7 @@ (_.set! (//case.register 0) $self) (|> arity list.indices - (list\map input_declaration) + (list\each input_declaration) (list\mix _.then bodyO)))] [(|> $num_args (_.> arityO)) (let [arity_args (_.slice (_.int +1) arityO $curried) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux index 28ac47ffb..82b97c26a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux @@ -43,8 +43,8 @@ ... true loop _ (do {! ///////phase.monad} - [$scope (\ ! map _.var (/////generation.identifier "loop_scope")) - initsO+ (monad.map ! (expression archive) initsS+) + [$scope (\ ! each _.var (/////generation.identifier "loop_scope")) + initsO+ (monad.each ! (expression archive) initsS+) bodyO (/////generation.with_anchor $scope (expression archive bodyS))] (in (_.block @@ -53,7 +53,7 @@ (_.function (|> initsS+ list.size list.indices - (list\map (|>> (n.+ offset) //case.register))) + (list\each (|>> (n.+ offset) //case.register))) bodyO)) (_.apply initsO+ $scope))))))) @@ -61,5 +61,5 @@ (Generator (List Synthesis)) (do {! ///////phase.monad} [$scope /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ $scope)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index 624826639..e528b33a0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -54,7 +54,7 @@ (-> Text Bundle Bundle) (|> bundle dict.entries - (list/map (function (_ [key val]) [(format prefix " " key) val])) + (list/each (function (_ [key val]) [(format prefix " " key) val])) (dict.from_list text.Hash<Text>))) (def: (wrong_arity proc expected actual) @@ -69,21 +69,21 @@ (do {@ macro.monad} [g!input+ (monad.all @ (list.repeated arity (macro.identifier "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!proc)) - (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) - (-> Text ..Proc)) - (function ((~ g!_) (~ g!name)) - (function ((~ g!_) (~ g!translate) (~ g!inputs)) - (case (~ g!inputs) - (^ (list (~+ g!input+))) - (do macro.Monad<Meta> - [(~+ (|> g!input+ - (list/map (function (_ g!input) - (list g!input (` ((~ g!translate) (~ g!input)))))) - list.together))] - ((~' in) ((~ g!proc) [(~+ g!input+)]))) - - (~' _) - (macro.failure (wrong_arity (~ g!name) +1 (list.size (~ g!inputs)))))))))))))) + (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) + (-> Text ..Proc)) + (function ((~ g!_) (~ g!name)) + (function ((~ g!_) (~ g!translate) (~ g!inputs)) + (case (~ g!inputs) + (^ (list (~+ g!input+))) + (do macro.Monad<Meta> + [(~+ (|> g!input+ + (list/each (function (_ g!input) + (list g!input (` ((~ g!translate) (~ g!input)))))) + list.together))] + ((~' in) ((~ g!proc) [(~+ g!input+)]))) + + (~' _) + (macro.failure (wrong_arity (~ g!name) +1 (list.size (~ g!inputs)))))))))))))) (arity: nullary +0) (arity: unary +1) @@ -95,7 +95,7 @@ (function (_ proc_name) (function (_ translate inputsS) (do {@ macro.Monad<Meta>} - [inputsI (monad.map @ translate inputsS)] + [inputsI (monad.each @ translate inputsS)] (in (proc inputsI)))))) ... [Procedures] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux index db45a04fc..b810862e2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux @@ -39,7 +39,7 @@ ... (^ (list& functionS argsS+)) ... (do {@ macro.Monad<Meta>} ... [functionO (translate functionS) -... argsO+ (monad.map @ translate argsS+)] +... argsO+ (monad.each @ translate argsS+)] ... (in (lua.apply functionO argsO+))) ... _ @@ -59,7 +59,7 @@ ... (^ (list& tableS [_ (#.Text field)] argsS+)) ... (do {@ macro.Monad<Meta>} ... [tableO (translate tableS) -... argsO+ (monad.map @ translate argsS+)] +... argsO+ (monad.each @ translate argsS+)] ... (in (lua.method field tableO argsO+))) ... _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index f0ea2c3fb..5d91dbde7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -82,9 +82,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -110,9 +110,9 @@ (#.Right [name inputs]) (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) _.Expression) (_.apply (list (~+ inputsC)) (~ runtime_name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux index 748f56955..2a69cfb08 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux @@ -28,13 +28,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (expression archive)) - (///////phase\map _.list)))) + (monad.each ///////phase.monad (expression archive)) + (///////phase\each _.list)))) (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (|>> (//runtime.variant tag right?)) - (expression archive valueS)))) + (///////phase\each (|>> (//runtime.variant tag right?)) + (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index 26ccf116d..9259c0ef1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -54,8 +54,8 @@ (All [anchor expression directive] (-> (System expression) Archive Name (////generation.Operation anchor expression directive expression))) - (phase\map (|>> ..artifact (\ system constant)) - (////generation.remember archive name))) + (phase\each (|>> ..artifact (\ system constant)) + (////generation.remember archive name))) (template [<sigil> <name>] [(def: .public (<name> system) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux index 0c56f55b1..e963dad17 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux @@ -32,7 +32,7 @@ (case synthesis (^template [<tag>] [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) + (//////phase\each _.return (expression archive synthesis))]) ([////synthesis.bit] [////synthesis.i64] [////synthesis.f64] @@ -56,7 +56,7 @@ [////synthesis.loop/recur /loop.recur!]) (^ (////synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) + (//////phase\each _.return (/function.function statement expression archive abstraction)) )) (exception: .public cannot_recur_as_an_expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index df08d8a21..276716fef 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -38,7 +38,7 @@ (def: .public (identifier prefix) (-> Text (Operation LVar)) - (///////phase\map (|>> %.nat (format prefix) _.local) /////generation.next)) + (///////phase\each (|>> %.nat (format prefix) _.local) /////generation.next)) (def: .public register (-> Register LVar) @@ -208,12 +208,12 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (\ ! map - (|>> [(_.= (|> match <format>) - ..peek)]) - (recur then))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (\ ! each + (|>> [(_.= (|> match <format>) + ..peek)]) + (recur then))) + (#.Item item))] (in (#.Some (_.cond clauses ..fail!))))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] @@ -263,12 +263,12 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (\ ! map - (|>> [(_.= (|> match <format>) - ..peek)]) - (recur then))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (\ ! each + (|>> [(_.= (|> match <format>) + ..peek)]) + (recur then))) + (#.Item item))] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] @@ -282,7 +282,7 @@ (^ (<simple> idx nextP)) (|> nextP recur - (///////phase\map (_.then (<choice> true idx))))]) + (///////phase\each (_.then (<choice> true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -355,6 +355,6 @@ (-> Phase! (Generator [Synthesis Path])) (|> case (case! true statement expression archive) - (\ ///////phase.monad map + (\ ///////phase.monad each (|>> (_.lambda #.None (list)) (_.apply_lambda/* (list)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux index efc132065..768d4a928 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux @@ -35,7 +35,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply_lambda/* argsO+ functionO)))) (def: .public capture @@ -54,7 +54,7 @@ (let [@self (_.local self)] [(_.function @self (|> (list.enumeration inits) - (list\map (|>> product.left ..capture))) + (list\each (|>> product.left ..capture))) ($_ _.then (_.set (list @self) function_definition) (_.return @self))) @@ -69,7 +69,7 @@ [[[function_module function_artifact] body!] (/////generation.with_new_context archive (/////generation.with_anchor 1 (statement expression archive bodyS))) - closureO+ (monad.map ! (expression archive) environment) + closureO+ (monad.each ! (expression archive) environment) .let [function_name (///reference.artifact [function_module function_artifact]) @curried (_.local "curried") arityO (|> arity .int _.int) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux index caf3afb78..2c6f7dbe9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux @@ -35,9 +35,9 @@ (-> Register (List Expression) Statement Statement) (|> bindings list.enumeration - (list\map (function (_ [register value]) - (_.set (list (//case.register (n.+ offset register))) - value))) + (list\each (function (_ [register value]) + (_.set (list (//case.register (n.+ offset register))) + value))) list.reversed (list\mix _.then body))) @@ -58,7 +58,7 @@ ... true loop _ (do {! ///////phase.monad} - [initsO+ (monad.map ! (expression archive) initsS+) + [initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor start (statement expression archive bodyS))] (in (<| (..setup start initsO+) @@ -85,11 +85,11 @@ (do {! ///////phase.monad} [offset /////generation.anchor @temp (//case.identifier "lux_recur_values") - argsO+ (monad.map ! (expression archive) argsS+) + argsO+ (monad.each ! (expression archive) argsS+) .let [re_binds (|> argsO+ list.enumeration - (list\map (function (_ [idx _]) - (_.item (_.int (.int idx)) @temp))))]] + (list\each (function (_ [idx _]) + (_.item (_.int (.int idx)) @temp))))]] (in ($_ _.then (_.set (list @temp) (_.array argsO+)) (..setup offset re_binds diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index b083c0a67..c4d57ef09 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -77,9 +77,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.local (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.local (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -109,9 +109,9 @@ (#.Right [name inputs]) (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply/* (list (~+ inputsC)) (~ runtime_name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux index 57861f7d4..a5ac11d83 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux @@ -25,13 +25,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (generate archive)) - (///////phase\map _.array)))) + (monad.each ///////phase.monad (generate archive)) + (///////phase\each _.array)))) (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase\each (//runtime.variant tag right?) + (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux index e68b23464..de65969b2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux @@ -158,13 +158,13 @@ (^template [<tag> <format> <=>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(<=> (|> match <format>) - ..peek) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(<=> (|> match <format>) + ..peek) + then!]))) + (#.Item item))] (in (list\mix (function (_ [when then] else) (_.if when then else)) ..fail! @@ -210,7 +210,7 @@ (def: (pattern_matching expression archive pathP) (Generator Path) - (\ ///////phase.monad map + (\ ///////phase.monad each (try_pm (_.raise/1 (_.string "Invalid expression for pattern-matching."))) (pattern_matching' expression archive pathP))) @@ -218,6 +218,6 @@ (Generator [Synthesis Path]) (do {! ///////phase.monad} [valueO (expression archive valueS)] - (<| (\ ! map (_.let (list [@cursor (_.list/* (list valueO))] - [@savepoint (_.list/* (list))]))) + (<| (\ ! each (_.let (list [@cursor (_.list/* (list valueO))] + [@savepoint (_.list/* (list))]))) (pattern_matching expression archive pathP)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux index dc3c75d98..b46b2e0b5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux @@ -51,8 +51,8 @@ (^ (list (~+ g!input+))) (do /////.monad [(~+ (|> g!input+ - (list\map (function (_ g!input) - (list g!input (` ((~ g!phase) (~ g!input)))))) + (list\each (function (_ g!input) + (list g!input (` ((~ g!phase) (~ g!input)))))) list.together))] ((~' in) ((~ g!extension) [(~+ g!input+)]))) @@ -69,7 +69,7 @@ (function (_ extension_name) (function (_ phase inputsS) (do {! /////.monad} - [inputsI (monad.map ! phase inputsS)] + [inputsI (monad.each ! phase inputsS)] (in (extension inputsI)))))) (def: bundle::lux diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux index cfb345097..c7d8dbcd4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux @@ -33,7 +33,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* argsO+ functionO)))) (def: capture @@ -50,7 +50,7 @@ _ (|> function_definition (_.lambda [(|> (list.enumeration inits) - (list\map (|>> product.left ..capture))) + (list\each (|>> product.left ..capture))) #.None]) (_.apply/* inits))))) @@ -65,11 +65,11 @@ (do {! ///////phase.monad} [[function_name bodyO] (/////generation.with_new_context archive (do ! - [@self (\ ! map (|>> ///reference.artifact _.var) + [@self (\ ! each (|>> ///reference.artifact _.var) (/////generation.context archive))] (/////generation.with_anchor @self (expression archive bodyS)))) - closureO+ (monad.map ! (expression archive) environment) + closureO+ (monad.each ! (expression archive) environment) .let [arityO (|> arity .int _.int) apply_poly (.function (_ args func) (_.apply/2 (_.var "apply") func args)) @@ -81,7 +81,7 @@ (<| (_.if (|> @num_args (_.=/2 arityO)) (<| (_.let (list [(//case.register 0) @self])) (_.let_values (list [[(|> (list.indices arity) - (list\map ..input)) + (list\each ..input)) #.None] (_.apply/2 (_.var "apply") (_.var "values") @curried)])) bodyO)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux index 87ddc4929..d0610fdfa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux @@ -46,12 +46,12 @@ ... true loop _ (do {! ///////phase.monad} - [initsO+ (monad.map ! (expression archive) initsS+) + [initsO+ (monad.each ! (expression archive) initsS+) bodyO (/////generation.with_anchor @scope (expression archive bodyS))] (in (_.letrec (list [@scope (_.lambda [(|> initsS+ list.enumeration - (list\map (|>> product.left (n.+ start) //case.register))) + (list\each (|>> product.left (n.+ start) //case.register))) #.None] bodyO)]) (_.apply/* initsO+ @scope)))))) @@ -60,5 +60,5 @@ (Generator (List Synthesis)) (do {! ///////phase.monad} [@scope /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* argsO+ @scope)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux index 221ee6d88..fefd850ce 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux @@ -64,9 +64,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -92,9 +92,9 @@ (#.Right [name inputs]) (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) _.Computation) (_.apply/* (list (~+ inputsC)) (~ runtime_name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux index 3c21b5e17..0e5d70dbf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux @@ -28,13 +28,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (expression archive)) - (///////phase\map _.vector/*)))) + (monad.each ///////phase.monad (expression archive)) + (///////phase\each _.vector/*)))) (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (|>> [tag right?] //runtime.variant) - (expression archive valueS)))) + (///////phase\each (|>> [tag right?] //runtime.variant) + (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux index 9e80130aa..f71e89b0c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux @@ -64,8 +64,8 @@ (#///analysis.Tuple tuple) (|> tuple - (monad.map phase.monad optimization') - (phase\map (|>> /.tuple))))) + (monad.each phase.monad optimization') + (phase\each (|>> /.tuple))))) (#///analysis.Case inputA branchesAB+) (/.with_currying? false @@ -91,8 +91,8 @@ (#try.Failure _) (|> args - (monad.map phase.monad optimization') - (phase\map (|>> [name] #/.Extension)) + (monad.each phase.monad optimization') + (phase\each (|>> [name] #/.Extension)) (phase.result' state)))))) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux index d2bf439da..75e27d5bf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -42,15 +42,15 @@ thenC (#///analysis.Bit when) - (///\map (function (_ then) - (#/.Bit_Fork when then #.None)) - thenC) + (///\each (function (_ then) + (#/.Bit_Fork when then #.None)) + thenC) (^template [<from> <to> <conversion>] [(<from> test) - (///\map (function (_ then) - (<to> [(<conversion> test) then] (list))) - thenC)]) + (///\each (function (_ then) + (<to> [(<conversion> test) then] (list))) + thenC)]) ([#///analysis.Nat #/.I64_Fork .i64] [#///analysis.Int #/.I64_Fork .i64] [#///analysis.Rev #/.I64_Fork .i64] @@ -58,16 +58,16 @@ [#///analysis.Text #/.Text_Fork |>])) (#///analysis.Bind register) - (<| (\ ///.monad map (|>> (#/.Seq (#/.Bind register)))) + (<| (\ ///.monad each (|>> (#/.Seq (#/.Bind register)))) /.with_new_local thenC) (#///analysis.Complex (#///analysis.Variant [lefts right? value_pattern])) - (<| (///\map (|>> (#/.Seq (#/.Access (#/.Side (if right? - (#.Right lefts) - (#.Left lefts))))))) + (<| (///\each (|>> (#/.Seq (#/.Access (#/.Side (if right? + (#.Right lefts) + (#.Left lefts))))))) (path' value_pattern end?) - (when> [(new> (not end?) [])] [(///\map ..clean_up)]) + (when> [(new> (not end?) [])] [(///\each ..clean_up)]) thenC) (#///analysis.Complex (#///analysis.Tuple tuple)) @@ -80,11 +80,11 @@ _ (let [right? (n.= tuple::last tuple::lefts) end?' (and end? right?)] - (<| (///\map (|>> (#/.Seq (#/.Access (#/.Member (if right? - (#.Right (-- tuple::lefts)) - (#.Left tuple::lefts))))))) + (<| (///\each (|>> (#/.Seq (#/.Access (#/.Member (if right? + (#.Right (-- tuple::lefts)) + (#.Left tuple::lefts))))))) (path' tuple::member end?') - (when> [(new> (not end?') [])] [(///\map ..clean_up)]) + (when> [(new> (not end?') [])] [(///\each ..clean_up)]) nextC)))) thenC (list.reversed (list.enumeration tuple)))) @@ -92,7 +92,7 @@ (def: (path archive synthesize pattern bodyA) (-> Archive Phase Pattern Analysis (Operation Path)) - (path' pattern true (///\map (|>> #/.Then) (synthesize archive bodyA)))) + (path' pattern true (///\each (|>> #/.Then) (synthesize archive bodyA)))) (def: (weave_branch weave equivalence [new_test new_then] [[old_test old_then] old_tail]) (All [a] (-> (-> Path Path Path) (Equivalence a) [a Path] (/.Fork a Path) @@ -227,7 +227,7 @@ (-> Phase Archive Synthesis Match (Operation Synthesis)) (do {! ///.monad} [headSP (path archive synthesize headP headA) - tailSP+ (monad.map ! (product.uncurried (path archive synthesize)) tailPA+)] + tailSP+ (monad.each ! (product.uncurried (path archive synthesize)) tailPA+)] (in (/.branch/case [input (list\mix weave headSP tailSP+)])))) (template: (!masking <variable> <output>) @@ -269,7 +269,7 @@ path (case input (^ (/.branch/get [sub_path sub_input])) - (///\in (/.branch/get [(list\compose path sub_path) sub_input])) + (///\in (/.branch/get [(list\composite path sub_path) sub_input])) _ (///\in (/.branch/get [path input]))))) @@ -357,7 +357,7 @@ (#/.F64_Fork forks) (#/.Text_Fork forks)) (|> (#.Item forks) - (list\map product.right) + (list\each product.right) (list\mix for_path path_storage)) (^or (^ (/.path/seq left right)) @@ -413,7 +413,7 @@ (set.union (|> synthesis_storage (revised@ #bindings (set.union (|> initsS+ list.enumeration - (list\map (|>> product.left (n.+ start))) + (list\each (|>> product.left (n.+ start))) (set.of_list n.hash)))) (for_synthesis iterationS) (value@ #dependencies))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 2aeacc78d..84d91d48d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -36,7 +36,7 @@ (-> Arity (List Synthesis)) (|>> -- (enum.range n.enum 1) - (list\map (|>> /.variable/local)))) + (list\each (|>> /.variable/local)))) (template: .public (self_reference) [(/.variable/local 0)]) @@ -51,7 +51,7 @@ (let [[funcA argsA] (////analysis.application exprA)] (do {! phase.monad} [funcS (phase archive funcA) - argsS (monad.map ! (phase archive) argsA)] + argsS (monad.each ! (phase archive) argsA)] (with_expansions [<apply> (as_is (/.function/apply [funcS argsS]))] (case funcS (^ (/.function/abstraction functionS)) @@ -61,22 +61,22 @@ [locals /.locals] (in (|> functionS (//loop.optimization true locals argsS) - (maybe\map (: (-> [Nat (List Synthesis) Synthesis] Synthesis) - (function (_ [start inits iteration]) - (case iteration - (^ (/.loop/scope [start' inits' output])) - (if (and (n.= start start') - (list.empty? inits')) - (/.loop/scope [start inits output]) - (/.loop/scope [start inits iteration])) + (maybe\each (: (-> [Nat (List Synthesis) Synthesis] Synthesis) + (function (_ [start inits iteration]) + (case iteration + (^ (/.loop/scope [start' inits' output])) + (if (and (n.= start start') + (list.empty? inits')) + (/.loop/scope [start inits output]) + (/.loop/scope [start inits iteration])) - _ - (/.loop/scope [start inits iteration]))))) + _ + (/.loop/scope [start inits iteration]))))) (maybe.else <apply>)))) (in <apply>)) (^ (/.function/apply [funcS' argsS'])) - (in (/.function/apply [funcS' (list\compose argsS' argsS)])) + (in (/.function/apply [funcS' (list\composite argsS' argsS)])) _ (in <apply>))))))) @@ -109,7 +109,7 @@ [then (grow_path grow then) else (case else (#.Some else) - (\ ! map (|>> #.Some) (grow_path grow else)) + (\ ! each (|>> #.Some) (grow_path grow else)) #.None (in #.None))] @@ -119,11 +119,11 @@ [(<tag> [[test then] elses]) (do {! phase.monad} [then (grow_path grow then) - elses (monad.map ! (function (_ [else_test else_then]) - (do ! - [else_then (grow_path grow else_then)] - (in [else_test else_then]))) - elses)] + elses (monad.each ! (function (_ [else_test else_then]) + (do ! + [else_then (grow_path grow else_then)] + (in [else_test else_then]))) + elses)] (in (<tag> [[test then] elses])))]) ([#/.I64_Fork] [#/.F64_Fork] @@ -132,7 +132,7 @@ (#/.Then thenS) (|> thenS grow - (phase\map (|>> #/.Then))) + (phase\each (|>> #/.Then))) _ (phase\in path))) @@ -145,12 +145,12 @@ (#////analysis.Variant [lefts right? subS]) (|> subS (grow environment) - (phase\map (|>> [lefts right?] /.variant))) + (phase\each (|>> [lefts right?] /.variant))) (#////analysis.Tuple membersS+) (|> membersS+ - (monad.map phase.monad (grow environment)) - (phase\map (|>> /.tuple)))) + (monad.each phase.monad (grow environment)) + (phase\each (|>> /.tuple)))) (^ (..self_reference)) (phase\in (/.function/apply [expression (list (/.variable/local 1))])) @@ -200,36 +200,36 @@ (case loop (#/.Scope [start initsS+ iterationS]) (do {! phase.monad} - [initsS+' (monad.map ! (grow environment) initsS+) + [initsS+' (monad.each ! (grow environment) initsS+) iterationS' (grow environment iterationS)] (in (/.loop/scope [(++ start) initsS+' iterationS']))) (#/.Recur argumentsS+) (|> argumentsS+ - (monad.map phase.monad (grow environment)) - (phase\map (|>> /.loop/recur)))) + (monad.each phase.monad (grow environment)) + (phase\each (|>> /.loop/recur)))) (#/.Function function) (case function (#/.Abstraction [_env _arity _body]) (do {! phase.monad} - [_env' (monad.map ! - (|>> (case> (#/.Reference (#////reference.Variable (#////reference/variable.Foreign register))) - (..find_foreign environment register) + [_env' (monad.each ! + (|>> (case> (#/.Reference (#////reference.Variable (#////reference/variable.Foreign register))) + (..find_foreign environment register) - captured - (grow environment captured))) - _env)] + captured + (grow environment captured))) + _env)] (in (/.function/abstraction [_env' _arity _body]))) (#/.Apply funcS argsS+) (do {! phase.monad} [funcS (grow environment funcS) - argsS+ (monad.map ! (grow environment) argsS+)] + argsS+ (monad.each ! (grow environment) argsS+)] (in (/.function/apply (case funcS (^ (/.function/apply [(..self_reference) pre_argsS+])) [(..self_reference) - (list\compose pre_argsS+ argsS+)] + (list\composite pre_argsS+ argsS+)] _ [funcS @@ -237,8 +237,8 @@ (#/.Extension name argumentsS+) (|> argumentsS+ - (monad.map phase.monad (grow environment)) - (phase\map (|>> (#/.Extension name)))) + (monad.each phase.monad (grow environment)) + (phase\each (|>> (#/.Extension name)))) (#/.Primitive _) (phase\in expression))) @@ -247,7 +247,7 @@ (-> Phase (Environment Analysis) Phase) (do {! phase.monad} [currying? /.currying? - environment (monad.map ! (phase archive) environment) + environment (monad.each ! (phase archive) environment) bodyS (/.with_currying? true (/.with_locals 2 (phase archive bodyA))) @@ -256,10 +256,10 @@ (^ (/.function/abstraction [env' down_arity' bodyS'])) (|> bodyS' (grow env') - (\ ! map (function (_ body) - {#/.environment environment - #/.arity (++ down_arity') - #/.body body}))) + (\ ! each (function (_ body) + {#/.environment environment + #/.arity (++ down_arity') + #/.body body}))) _ (in {#/.environment environment diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index bba61a90f..882a8c5d6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -46,7 +46,7 @@ [then (recur then) else (case else (#.Some else) - (\ ! map (|>> #.Some) (recur else)) + (\ ! each (|>> #.Some) (recur else)) #.None (in #.None))] @@ -56,11 +56,11 @@ [(<tag> [[test then] elses]) (do {! maybe.monad} [then (recur then) - elses (monad.map ! (function (_ [else_test else_then]) - (do ! - [else_then (recur else_then)] - (in [else_test else_then]))) - elses)] + elses (monad.each ! (function (_ [else_test else_then]) + (do ! + [else_then (recur else_then)] + (in [else_test else_then]))) + elses)] (in (<tag> [[test then] elses])))]) ([#/.I64_Fork] [#/.F64_Fork] @@ -69,7 +69,7 @@ (#/.Then body) (|> body body_optimization - (maybe\map (|>> #/.Then))) + (maybe\each (|>> #/.Then))) _ (#.Some path)))) @@ -93,8 +93,8 @@ (#analysis.Tuple tuple) (|> tuple - (monad.map maybe.monad (recur false)) - (maybe\map (|>> /.tuple)))) + (monad.each maybe.monad (recur false)) + (maybe\each (|>> /.tuple)))) (#/.Reference reference) (case reference @@ -142,7 +142,7 @@ (do {! maybe.monad} [inits' (|> scope (value@ #/.inits) - (monad.map ! (recur false))) + (monad.each ! (recur false))) iteration' (recur return? (value@ #/.iteration scope))] (in (/.loop/scope {#/.start (|> scope (value@ #/.start) (register_optimization offset)) #/.inits inits' @@ -150,17 +150,17 @@ (^ (/.loop/recur args)) (|> args - (monad.map maybe.monad (recur false)) - (maybe\map (|>> /.loop/recur))) + (monad.each maybe.monad (recur false)) + (maybe\each (|>> /.loop/recur))) (^ (/.function/abstraction [environment arity body])) (do {! maybe.monad} - [environment' (monad.map ! (recur false) environment)] + [environment' (monad.each ! (recur false) environment)] (in (/.function/abstraction [environment' arity body]))) (^ (/.function/apply [abstraction arguments])) (do {! maybe.monad} - [arguments' (monad.map ! (recur false) arguments)] + [arguments' (monad.each ! (recur false) arguments)] (with_expansions [<application> (as_is (do ! [abstraction' (recur false abstraction)] (in (/.function/apply [abstraction' arguments']))))] @@ -181,29 +181,29 @@ (if return? (do {! maybe.monad} [input (recur false input) - matches (monad.map ! - (function (_ match) - (case match - (^ (#/.Structure (#analysis.Tuple (list when then)))) - (do ! - [when (recur false when) - then (recur return? then)] - (in (#/.Structure (#analysis.Tuple (list when then))))) - - _ - (recur false match))) - matches) + matches (monad.each ! + (function (_ match) + (case match + (^ (#/.Structure (#analysis.Tuple (list when then)))) + (do ! + [when (recur false when) + then (recur return? then)] + (in (#/.Structure (#analysis.Tuple (list when then))))) + + _ + (recur false match))) + matches) else (recur return? else)] (in (#/.Extension ["lux syntax char case!" (list& input else matches)]))) #.None) (#/.Extension [name args]) (|> args - (monad.map maybe.monad (recur false)) - (maybe\map (|>> [name] #/.Extension)))))) + (monad.each maybe.monad (recur false)) + (maybe\each (|>> [name] #/.Extension)))))) (def: .public (optimization true_loop? offset inits functionS) (-> Bit Register (List Synthesis) Abstraction (Maybe [Register (List Synthesis) Synthesis])) (|> (value@ #/.body functionS) (body_optimization true_loop? offset (value@ #/.environment functionS) (value@ #/.arity functionS)) - (maybe\map (|>> [offset inits])))) + (maybe\each (|>> [offset inits])))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 88b2d3f1f..212a2a0a2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -71,14 +71,14 @@ [#/.Alt]) (#/.Bit_Fork when then else) - (#/.Bit_Fork when (recur then) (maybe\map recur else)) + (#/.Bit_Fork when (recur then) (maybe\each recur else)) (^template [<tag>] [(<tag> [[test then] tail]) (<tag> [[test (recur then)] - (list\map (function (_ [test' then']) - [test' (recur then')]) - tail)])]) + (list\each (function (_ [test' then']) + [test' (recur then')]) + tail)])]) ([#/.I64_Fork] [#/.F64_Fork] [#/.Text_Fork]) @@ -116,7 +116,7 @@ (#analysis.Variant [lefts right (recur value)]) (#analysis.Tuple tuple) - (#analysis.Tuple (list\map recur tuple)))) + (#analysis.Tuple (list\each recur tuple)))) (#/.Reference reference) (case reference @@ -148,24 +148,24 @@ (#/.Loop (case loop (#/.Scope [start inits iteration]) (#/.Scope [(..prune redundant start) - (list\map recur inits) + (list\each recur inits) (recur iteration)]) (#/.Recur resets) - (#/.Recur (list\map recur resets)))) + (#/.Recur (list\each recur resets)))) (#/.Function function) (#/.Function (case function (#/.Abstraction [environment arity body]) - (#/.Abstraction [(list\map recur environment) + (#/.Abstraction [(list\each recur environment) arity body]) (#/.Apply abstraction inputs) - (#/.Apply (recur abstraction) (list\map recur inputs)))))) + (#/.Apply (recur abstraction) (list\each recur inputs)))))) (#/.Extension name inputs) - (#/.Extension name (list\map recur inputs))))) + (#/.Extension name (list\each recur inputs))))) (type: Redundancy (Dictionary Register Bit)) @@ -179,7 +179,7 @@ (def: (extended offset amount redundancy) (-> Register Nat Redundancy [(List Register) Redundancy]) - (let [extension (|> amount list.indices (list\map (n.+ offset)))] + (let [extension (|> amount list.indices (list\each (n.+ offset)))] [extension (list\mix (function (_ register redundancy) (dictionary.has register ..necessary! redundancy)) @@ -239,8 +239,8 @@ (%.Format Redundancy) (|> redundancy dictionary.entries - (list\map (function (_ [register redundant?]) - (%.format (%.nat register) ": " (%.bit redundant?)))) + (list\each (function (_ [register redundant?]) + (%.format (%.nat register) ": " (%.bit redundant?)))) (text.interposed ", "))) (def: (path_optimization optimization) @@ -257,7 +257,7 @@ [[redundancy then] (recur [redundancy then]) [redundancy else] (case else (#.Some else) - (\ ! map + (\ ! each (function (_ [redundancy else]) [redundancy (#.Some else)]) (recur [redundancy else])) @@ -309,7 +309,7 @@ (list.only (function (_ [register redundant?]) (and (set.member? bindings register) redundant?))) - (list\map product.left))]] + (list\each product.left))]] (in [(list\mix dictionary.lacks redundancy (set.list bindings)) (|> redundants (list.sorted n.>) @@ -440,4 +440,4 @@ (-> Synthesis (Try Synthesis)) (|>> [..initial] optimization' - (\ try.monad map product.right))) + (\ try.monad each product.right))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux index f181fd077..047565e77 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -37,12 +37,12 @@ (do {! try.monad} [registries (|> archive archive.archived - (monad.map ! - (function (_ module) - (do ! - [id (archive.id module archive) - [descriptor document] (archive.find module archive)] - (in [[module id] (value@ #descriptor.registry descriptor)])))))] + (monad.each ! + (function (_ module) + (do ! + [id (archive.id module archive) + [descriptor document] (archive.find module archive)] + (in [[module id] (value@ #descriptor.registry descriptor)])))))] (case (list.one (function (_ [[module module_id] registry]) (do maybe.monad [program_id (artifact.remember ..name registry)] @@ -53,5 +53,5 @@ #.None (|> registries - (list\map (|>> product.left product.left)) + (list\each (|>> product.left product.left)) (exception.except ..cannot_find_program))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index 7f7d205c3..dc555b85d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -38,9 +38,10 @@ (Dictionary Variable Variable)) (type: .public State - {#locals Nat - ... https://en.wikipedia.org/wiki/Currying - #currying? Bit}) + (Record + {#locals Nat + ... https://en.wikipedia.org/wiki/Currying + #currying? Bit})) (def: .public fresh_resolver Resolver @@ -52,10 +53,11 @@ #currying? false}) (type: .public Primitive - (#Bit Bit) - (#I64 (I64 Any)) - (#F64 Frac) - (#Text Text)) + (Variant + (#Bit Bit) + (#I64 (I64 Any)) + (#F64 Frac) + (#Text Text))) (type: .public Side (Either Nat Nat)) @@ -64,63 +66,73 @@ (Either Nat Nat)) (type: .public Access - (#Side Side) - (#Member Member)) + (Variant + (#Side Side) + (#Member Member))) (type: .public (Fork value next) [[value next] (List [value next])]) (type: .public (Path' s) - #Pop - (#Access Access) - (#Bind Register) - (#Bit_Fork Bit (Path' s) (Maybe (Path' s))) - (#I64_Fork (Fork (I64 Any) (Path' s))) - (#F64_Fork (Fork Frac (Path' s))) - (#Text_Fork (Fork Text (Path' s))) - (#Alt (Path' s) (Path' s)) - (#Seq (Path' s) (Path' s)) - (#Then s)) + (Variant + #Pop + (#Access Access) + (#Bind Register) + (#Bit_Fork Bit (Path' s) (Maybe (Path' s))) + (#I64_Fork (Fork (I64 Any) (Path' s))) + (#F64_Fork (Fork Frac (Path' s))) + (#Text_Fork (Fork Text (Path' s))) + (#Alt (Path' s) (Path' s)) + (#Seq (Path' s) (Path' s)) + (#Then s))) (type: .public (Abstraction' s) - {#environment (Environment s) - #arity Arity - #body s}) + (Record + {#environment (Environment s) + #arity Arity + #body s})) (type: .public (Apply' s) - {#function s - #arguments (List s)}) + (Record + {#function s + #arguments (List s)})) (type: .public (Branch s) - (#Let s Register s) - (#If s s s) - (#Get (List Member) s) - (#Case s (Path' s))) + (Variant + (#Let s Register s) + (#If s s s) + (#Get (List Member) s) + (#Case s (Path' s)))) (type: .public (Scope s) - {#start Register - #inits (List s) - #iteration s}) + (Record + {#start Register + #inits (List s) + #iteration s})) (type: .public (Loop s) - (#Scope (Scope s)) - (#Recur (List s))) + (Variant + (#Scope (Scope s)) + (#Recur (List s)))) (type: .public (Function s) - (#Abstraction (Abstraction' s)) - (#Apply s (List s))) + (Variant + (#Abstraction (Abstraction' s)) + (#Apply s (List s)))) (type: .public (Control s) - (#Branch (Branch s)) - (#Loop (Loop s)) - (#Function (Function s))) + (Variant + (#Branch (Branch s)) + (#Loop (Loop s)) + (#Function (Function s)))) (type: .public #rec Synthesis - (#Primitive Primitive) - (#Structure (Composite Synthesis)) - (#Reference Reference) - (#Control (Control Synthesis)) - (#Extension (Extension Synthesis))) + (Variant + (#Primitive Primitive) + (#Structure (Composite Synthesis)) + (#Reference Reference) + (#Control (Control Synthesis)) + (#Extension (Extension Synthesis)))) (template [<special> <general>] [(type: .public <special> @@ -277,8 +289,8 @@ (^template [<tag> <format>] [(<tag> item) (|> (#.Item item) - (list\map (function (_ [test then]) - (format (<format> test) " " (%path' %then then)))) + (list\each (function (_ [test then]) + (format (<format> test) " " (%path' %then then)))) (text.interposed " ") (text.enclosed ["(? " ")"]))]) ([#I64_Fork (|>> .int %.int)] @@ -340,7 +352,7 @@ (#analysis.Tuple members) (|> members - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"]))) @@ -353,7 +365,7 @@ (case function (#Abstraction [environment arity body]) (let [environment' (|> environment - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"]))] (|> (format environment' " " (%.nat arity) " " (%synthesis body)) @@ -361,7 +373,7 @@ (#Apply func args) (|> args - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (format (%synthesis func) " ") (text.enclosed ["(" ")"]))) @@ -378,7 +390,7 @@ (#Get members record) (|> (format (%.list (%path' %synthesis) - (list\map (|>> #Member #Access) members)) + (list\each (|>> #Member #Access) members)) " " (%synthesis record)) (text.enclosed ["(#get " ")"])) @@ -391,7 +403,7 @@ (#Scope scope) (|> (format (%.nat (value@ #start scope)) " " (|> (value@ #inits scope) - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"])) " " (%synthesis (value@ #iteration scope))) @@ -399,12 +411,12 @@ (#Recur args) (|> args - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (text.enclosed ["(#recur " ")"])))) (#Extension [name args]) - (|> (list\map %synthesis args) + (|> (list\each %synthesis args) (text.interposed " ") (format (%.text name) " ") (text.enclosed ["(" ")"])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index e1ea19e37..d326a2bbb 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -77,8 +77,9 @@ (abstract: .public Archive {} - {#next ID - #resolver (Dictionary Module [ID (Maybe [Descriptor (Document Any) Output])])} + (Record + {#next ID + #resolver (Dictionary Module [ID (Maybe [Descriptor (Document Any) Output])])}) (def: next (-> Archive ID) @@ -188,8 +189,8 @@ (|>> :representation (value@ #resolver) dictionary.entries - (list\map (function (_ [module [id _]]) - [module id])))) + (list\each (function (_ [module [id _]]) + [module id])))) (def: .public (merged additions archive) (-> Archive Archive Archive) @@ -252,7 +253,7 @@ (-> (List Reservation) Bit) (n.= (list.size reservations) (|> reservations - (list\map product.left) + (list\each product.left) (set.of_list text.hash) set.size))) @@ -260,7 +261,7 @@ (-> (List Reservation) Bit) (n.= (list.size reservations) (|> reservations - (list\map product.right) + (list\each product.right) (set.of_list n.hash) set.size))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index af69bbdc9..7a2d25b1a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -25,23 +25,26 @@ Nat) (type: .public Category - #Anonymous - (#Definition Text) - (#Analyser Text) - (#Synthesizer Text) - (#Generator Text) - (#Directive Text) - (#Custom Text)) + (Variant + #Anonymous + (#Definition Text) + (#Analyser Text) + (#Synthesizer Text) + (#Generator Text) + (#Directive Text) + (#Custom Text))) (type: .public Artifact - {#id ID - #category Category}) + (Record + {#id ID + #category Category})) (abstract: .public Registry {} - {#artifacts (Row Artifact) - #resolver (Dictionary Text ID)} + (Record + {#artifacts (Row Artifact) + #resolver (Dictionary Text ID)}) (def: .public empty Registry @@ -120,7 +123,7 @@ (binary.row/64 category))] (|>> :representation (value@ #artifacts) - (row\map (value@ #category)) + (row\each (value@ #category)) artifacts))) (exception: .public (invalid_category {tag Nat}) @@ -134,7 +137,7 @@ [tag <binary>.nat] (case tag (^template [<nat> <tag> <parser>] - [<nat> (\ ! map (|>> <tag>) <parser>)]) + [<nat> (\ ! each (|>> <tag>) <parser>)]) ([0 #Anonymous <binary>.any] [1 #Definition <binary>.text] [2 #Analyser <binary>.text] @@ -145,21 +148,21 @@ _ (<>.failure (exception.error ..invalid_category [tag])))))] (|> (<binary>.row/64 category) - (\ <>.monad map (row\mix (function (_ artifact registry) - (product.right - (case artifact - #Anonymous - (..resource registry) - - (^template [<tag> <create>] - [(<tag> name) - (<create> name registry)]) - ([#Definition ..definition] - [#Analyser ..analyser] - [#Synthesizer ..synthesizer] - [#Generator ..generator] - [#Directive ..directive] - [#Custom ..custom]) - ))) - ..empty))))) + (\ <>.monad each (row\mix (function (_ artifact registry) + (product.right + (case artifact + #Anonymous + (..resource registry) + + (^template [<tag> <create>] + [(<tag> name) + (<create> name registry)]) + ([#Definition ..definition] + [#Analyser ..analyser] + [#Synthesizer ..synthesizer] + [#Generator ..generator] + [#Directive ..directive] + [#Custom ..custom]) + ))) + ..empty))))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux index 59f1981bc..5a30c2c50 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux @@ -19,12 +19,13 @@ Text) (type: .public Descriptor - {#name Module - #file Path - #hash Nat - #state Module_State - #references (Set Module) - #registry Registry}) + (Record + {#name Module + #file Path + #hash Nat + #state Module_State + #references (Set Module) + #registry Registry})) (def: .public writer (Writer Descriptor) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux index a14d708d5..8858eefa3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux @@ -28,8 +28,9 @@ (abstract: .public (Document d) {} - {#signature Signature - #content d} + (Record + {#signature Signature + #content d}) (def: .public (read key document) (All [d] (-> (Key d) (Document Any) (Try d))) @@ -70,5 +71,5 @@ (def: .public parser (All [d] (-> (Parser d) (Parser (Document d)))) (|>> (<>.and signature.parser) - (\ <>.monad map (|>> :abstraction)))) + (\ <>.monad each (|>> :abstraction)))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux index 8b4dfedb8..ebe18755a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux @@ -20,8 +20,9 @@ [version (#+ Version)]]) (type: .public Signature - {#name Name - #version Version}) + (Record + {#name Name + #version Version})) (def: .public equivalence (Equivalence Signature) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux index e2a3ef238..9796bdcfb 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -41,8 +41,9 @@ dictionary.keys) (type: Dependency - {#module Module - #imports Ancestry}) + (Record + {#module Module + #imports Ancestry})) (def: .public graph (-> (List Dependency) Graph) @@ -61,7 +62,7 @@ (#try.Failure error) ..fresh)] - ancestors (monad.map ! recur (set.list parents))] + ancestors (monad.each ! recur (set.list parents))] (in (list\mix set.union parents ancestors))))) ancestry (memo.open memo)] (list\mix (function (_ module memory) @@ -88,10 +89,10 @@ (|> ancestry dictionary.keys (list.sorted (..dependency? ancestry)) - (monad.map try.monad - (function (_ module) - (do try.monad - [module_id (archive.id module archive) - [descriptor document output] (archive.find module archive) - document (document.check key document)] - (in [module [module_id [descriptor document output]]]))))))) + (monad.each try.monad + (function (_ module) + (do try.monad + [module_id (archive.id module archive) + [descriptor document output] (archive.find module archive) + document (document.check key document)] + (in [module [module_id [descriptor document output]]]))))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index 45f489e8b..efb13c9e8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -110,13 +110,13 @@ _ (ensure_directory fs (..versioned_lux_archive fs static))] (|> module (\ fs make_directory) - (\ ! map (|>> (case> (#try.Success output) - (#try.Success []) + (\ ! each (|>> (case> (#try.Success output) + (#try.Success []) - (#try.Failure error) - (exception.except ..cannot_prepare [(..archive fs static) - module_id - error]))))))))) + (#try.Failure error) + (exception.except ..cannot_prepare [(..archive fs static) + module_id + error]))))))))) (def: .public (write fs static module_id artifact_id content) (-> (file.System Async) Static archive.ID artifact.ID Binary (Async (Try Any))) @@ -168,12 +168,12 @@ (-> Target Archive (Try .Lux)) (do {! try.monad} [modules (: (Try (List [Module .Module])) - (monad.map ! (function (_ module) - (do ! - [[descriptor document output] (archive.find module archive) - content (document.read $.key document)] - (in [module content]))) - (archive.archived archive)))] + (monad.each ! (function (_ module) + (do ! + [[descriptor document output] (archive.find module archive) + content (document.read $.key document)] + (in [module content]))) + (archive.archived archive)))] (in (with@ #.modules modules (fresh_analysis_state host))))) (def: (cached_artifacts fs static module_id) @@ -181,15 +181,15 @@ (let [! (try.with async.monad)] (|> (..module fs static module_id) (\ fs directory_files) - (\ ! map (|>> (list\map (function (_ file) - [(file.name fs file) file])) - (list.only (|>> product.left (text\= ..module_descriptor_file) not)) - (monad.map ! (function (_ [name path]) - (|> path - (\ fs read) - (\ ! map (|>> [name]))))) - (\ ! map (dictionary.of_list text.hash)))) - (\ ! join)))) + (\ ! each (|>> (list\each (function (_ file) + [(file.name fs file) file])) + (list.only (|>> product.left (text\= ..module_descriptor_file) not)) + (monad.each ! (function (_ [name path]) + (|> path + (\ fs read) + (\ ! each (|>> [name]))))) + (\ ! each (dictionary.of_list text.hash)))) + (\ ! conjoint)))) (type: Definitions (Dictionary Text Any)) (type: Analysers (Dictionary Text analysis.Handler)) @@ -321,19 +321,19 @@ #.End (#try.Success [definitions bundles output]))))) content (document.read $.key document) - definitions (monad.map ! (function (_ [def_name def_global]) - (case def_global - (#.Alias alias) - (in [def_name (#.Alias alias)]) - - (#.Definition [exported? type annotations _]) - (|> definitions - (dictionary.value def_name) - try.of_maybe - (\ ! map (|>> [exported? type annotations] - #.Definition - [def_name]))))) - (value@ #.definitions content))] + definitions (monad.each ! (function (_ [def_name def_global]) + (case def_global + (#.Alias alias) + (in [def_name (#.Alias alias)]) + + (#.Definition [exported? type annotations _]) + (|> definitions + (dictionary.value def_name) + try.of_maybe + (\ ! each (|>> [exported? type annotations] + #.Definition + [def_name]))))) + (value@ #.definitions content))] (in [(document.write $.key (with@ #.definitions definitions content)) bundles]))) @@ -355,8 +355,8 @@ [.let [cache (..module fs static module_id)] _ (|> cache (\ fs directory_files) - (\ ! map (monad.map ! (\ fs delete))) - (\ ! join))] + (\ ! each (monad.each ! (\ fs delete))) + (\ ! conjoint))] (\ fs delete cache))) (def: (valid_cache? expected actual) @@ -409,37 +409,37 @@ (do {! (try.with async.monad)} [pre_loaded_caches (|> archive archive.reservations - (monad.map ! (function (_ [module_name module_id]) - (do ! - [data (..read_module_descriptor fs static module_id) - [descriptor document] (async\in (<binary>.result ..parser data))] - (if (text\= archive.runtime_module module_name) - (in [true - [module_name [module_id [descriptor document]]]]) - (do ! - [input (//context.read fs ..pseudo_module import contexts (value@ #static.host_module_extension static) module_name)] - (in [(..valid_cache? descriptor input) - [module_name [module_id [descriptor document]]]]))))))) + (monad.each ! (function (_ [module_name module_id]) + (do ! + [data (..read_module_descriptor fs static module_id) + [descriptor document] (async\in (<binary>.result ..parser data))] + (if (text\= archive.runtime_module module_name) + (in [true + [module_name [module_id [descriptor document]]]]) + (do ! + [input (//context.read fs ..pseudo_module import contexts (value@ #static.host_module_extension static) module_name)] + (in [(..valid_cache? descriptor input) + [module_name [module_id [descriptor document]]]]))))))) load_order (|> pre_loaded_caches - (list\map product.right) + (list\each product.right) (monad.mix try.monad (function (_ [module [module_id [descriptor document]]] archive) (archive.has module [descriptor document (: Output row.empty)] archive)) archive) - (\ try.monad map (dependency.load_order $.key)) - (\ try.monad join) + (\ try.monad each (dependency.load_order $.key)) + (\ try.monad conjoint) async\in) .let [purge (..full_purge pre_loaded_caches load_order)] _ (|> purge dictionary.entries - (monad.map ! (..purge! fs static))) + (monad.each ! (..purge! fs static))) loaded_caches (|> load_order (list.only (|>> product.left (dictionary.key? purge) not)) - (monad.map ! (function (_ [module_name [module_id [descriptor document _]]]) - (do ! - [[descriptor,document,output bundles] (..load_definitions fs static module_id host_environment descriptor document)] - (in [[module_name descriptor,document,output] - bundles])))))] + (monad.each ! (function (_ [module_name [module_id [descriptor document _]]]) + (do ! + [[descriptor,document,output bundles] (..load_definitions fs static module_id host_environment descriptor document)] + (in [[module_name descriptor,document,output] + bundles])))))] (async\in (do {! try.monad} [archive (monad.mix ! diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index 74d5aab33..fe83f0fb3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -83,14 +83,14 @@ (#try.Success path) (|> path (\ fs read) - (\ (try.with !) map (|>> [path]))) + (\ (try.with !) each (|>> [path]))) (#try.Failure _) (do {! (try.with !)} [path (..find_source_file fs importer contexts module ..lux_extension)] (|> path (\ fs read) - (\ ! map (|>> [path]))))))) + (\ ! each (|>> [path]))))))) (def: (find_library_source_file importer import partial_host_extension module) (-> Module Import Extension Module (Try [file.Path Binary])) @@ -145,18 +145,18 @@ (do {! (try.with async.monad)} [enumeration (|> directory (\ fs directory_files) - (\ ! map (monad.mix ! (function (_ file enumeration) - (if (text.ends_with? ..lux_extension file) - (do ! - [source_code (\ fs read file)] - (async\in (dictionary.has' (text.replaced context "" file) source_code enumeration))) - (in enumeration))) - enumeration)) - (\ ! join))] + (\ ! each (monad.mix ! (function (_ file enumeration) + (if (text.ends_with? ..lux_extension file) + (do ! + [source_code (\ fs read file)] + (async\in (dictionary.has' (text.replaced context "" file) source_code enumeration))) + (in enumeration))) + enumeration)) + (\ ! conjoint))] (|> directory (\ fs sub_directories) - (\ ! map (monad.mix ! (context_listing fs context) enumeration)) - (\ ! join)))) + (\ ! each (monad.mix ! (context_listing fs context) enumeration)) + (\ ! conjoint)))) (def: Action (type (All [a] (Async (Try a))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager.lux b/stdlib/source/library/lux/tool/compiler/meta/packager.lux index 744d0ecb9..f846a28a8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager.lux @@ -33,10 +33,10 @@ (def: .public order (-> dependency.Order Order) - (list\map (function (_ [module [module_id [descriptor document]]]) - (|> descriptor - (value@ #descriptor.registry) - artifact.artifacts - row.list - (list\map (|>> (value@ #artifact.id))) - [module_id])))) + (list\each (function (_ [module [module_id [descriptor document]]]) + (|> descriptor + (value@ #descriptor.registry) + artifact.artifacts + row.list + (list\each (|>> (value@ #artifact.id))) + [module_id])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index ffee37de6..832c6f8f6 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -141,7 +141,7 @@ (-> Static archive.ID artifact.ID (Maybe Text) Binary java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) (let [class_path (|> custom - (maybe\map (|>> name.internal name.read)) + (maybe\each (|>> name.internal name.read)) (maybe.else (runtime.class_name [module artifact])) (text.suffix (value@ #static.artifact_extension static)))] (do try.monad @@ -249,8 +249,8 @@ [order (dependency.load_order $.key archive) .let [buffer (java/io/ByteArrayOutputStream::new (.int ..mebi_byte))] sink (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module_id output])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module_id output])) (monad.mix ! (..write_module static) (java/util/jar/JarOutputStream::new buffer (..manifest program)))) [entries duplicates sink] (|> host_dependencies diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index f888e6975..c1fdd9d5d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -57,12 +57,12 @@ (def: bundle_module (-> Output (Try _.Expression)) (|>> row.list - (list\map product.right) + (list\each product.right) (monad.mix try.monad (function (_ content so_far) (|> content (\ encoding.utf8 decoded) - (\ try.monad map + (\ try.monad each (|>> :expected (:sharing [directive] directive @@ -107,7 +107,7 @@ (value@ #descriptor.references) set.list (list.all (function (_ module) (dictionary.value module mapping))) - (list\map (|>> ..module_file _.string _.load_relative/1)) + (list\each (|>> ..module_file _.string _.load_relative/1)) (list\mix ..then bundle) (: _.Expression) _.code @@ -122,11 +122,11 @@ (do {! try.monad} [order (dependency.load_order $.key archive) .let [mapping (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module module_id])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module module_id])) (dictionary.of_list text.hash) (: (Dictionary Module archive.ID)))] - entries (monad.map ! (..write_module now mapping) order)] + entries (monad.each ! (..write_module now mapping) order)] (in (|> entries row.of_list (binary.result tar.writer)))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux index 9b49232e3..0beeffa1c 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux @@ -39,12 +39,12 @@ (Try directive))) (|> output row.list - (list\map (|>> product.right product.right)) + (list\each (|>> product.right product.right)) (monad.mix try.monad (function (_ content so_far) (|> content (\ utf8.codec decoded) - (\ try.monad map + (\ try.monad each (|>> :expected (:sharing [directive] directive @@ -65,7 +65,7 @@ (do {! try.monad} [order (dependency.load_order $.key archive)] (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module_id output])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module_id output])) (monad.mix ! (..write_module sequence) header) - (\ ! map (|>> scope code (\ utf8.codec encoded))))))) + (\ ! each (|>> scope code (\ utf8.codec encoded))))))) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 7e137387e..22362318a 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -47,7 +47,7 @@ (-> s (Operation s o) (Try o))) (|> state operation - (\ try.monad map product.right))) + (\ try.monad each product.right))) (def: .public get_state (All [s o] @@ -82,7 +82,7 @@ (def: .public (lifted error) (All [s a] (-> (Try a) (Operation s a))) (function (_ state) - (try\map (|>> [state]) error))) + (try\each (|>> [state]) error))) (syntax: .public (assertion [exception <code>.any message <code>.any diff --git a/stdlib/source/library/lux/tool/compiler/reference.lux b/stdlib/source/library/lux/tool/compiler/reference.lux index e8714bb2a..c90aa41f6 100644 --- a/stdlib/source/library/lux/tool/compiler/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/reference.lux @@ -20,8 +20,9 @@ Name) (type: .public Reference - (#Variable Variable) - (#Constant Constant)) + (Variant + (#Variable Variable) + (#Constant Constant))) (implementation: .public equivalence (Equivalence Reference) diff --git a/stdlib/source/library/lux/tool/compiler/reference/variable.lux b/stdlib/source/library/lux/tool/compiler/reference/variable.lux index c45c5239b..0c0eaad22 100644 --- a/stdlib/source/library/lux/tool/compiler/reference/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/reference/variable.lux @@ -18,8 +18,9 @@ Nat) (type: .public Variable - (#Local Register) - (#Foreign Register)) + (Variant + (#Local Register) + (#Foreign Register))) (implementation: .public equivalence (Equivalence Variable) diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index ee02eacc9..c26e9b789 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -162,9 +162,10 @@ codeV)))) (type: (Context anchor expression directive) - {#configuration Configuration - #state (State+ anchor expression directive) - #source Source}) + (Record + {#configuration Configuration + #state (State+ anchor expression directive) + #source Source})) (with_expansions [<Context> (as_is (Context anchor expression directive))] (def: (read_eval_print context) diff --git a/stdlib/source/library/lux/tool/mediator.lux b/stdlib/source/library/lux/tool/mediator.lux index 9357999f4..f46d2f486 100644 --- a/stdlib/source/library/lux/tool/mediator.lux +++ b/stdlib/source/library/lux/tool/mediator.lux @@ -3,14 +3,15 @@ [lux (#- Source Module) [world ["." binary (#+ Binary)] - ["." file (#+ File)]]]] + ["." file (#+ Path)]]]] [// [compiler (#+ Compiler) [meta ["." archive (#+ Archive) [descriptor (#+ Module)]]]]]) -(type: .public Source File) +(type: .public Source + Path) (type: .public (Mediator !) (-> Archive Module (! Archive))) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index e1e42c28c..fb2baf861 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -62,7 +62,7 @@ (case type (#.Apply arg func') (let [[func args] (flat_application func')] - [func (list\compose args (list arg))]) + [func (list\composite args (list arg))]) _ [type (list)])) @@ -87,57 +87,57 @@ (-> Type Text) (case type (#.Primitive name params) - ($_ text\compose + ($_ text\composite "(primitive " (text.enclosed' text.double_quote name) (|> params - (list\map (|>> format (text\compose " "))) - (list\mix (function.flipped text\compose) "")) + (list\each (|>> format (text\composite " "))) + (list\mix (function.flipped text\composite) "")) ")") (^template [<tag> <open> <close> <flat>] [(<tag> _) - ($_ text\compose <open> + ($_ text\composite <open> (|> (<flat> type) - (list\map format) + (list\each format) list.reversed (list.interposed " ") - (list\mix text\compose "")) + (list\mix text\composite "")) <close>)]) ([#.Sum "(Or " ")" flat_variant] [#.Product "[" "]" flat_tuple]) (#.Function input output) (let [[ins out] (flat_function type)] - ($_ text\compose "(-> " + ($_ text\composite "(-> " (|> ins - (list\map format) + (list\each format) list.reversed (list.interposed " ") - (list\mix text\compose "")) + (list\mix text\composite "")) " " (format out) ")")) (#.Parameter idx) (n\encoded idx) (#.Var id) - ($_ text\compose "⌈v:" (n\encoded id) "⌋") + ($_ text\composite "⌈v:" (n\encoded id) "⌋") (#.Ex id) - ($_ text\compose "⟨e:" (n\encoded id) "⟩") + ($_ text\composite "⟨e:" (n\encoded id) "⟩") (#.Apply param fun) (let [[type_func type_args] (flat_application type)] - ($_ text\compose "(" (format type_func) " " (|> type_args (list\map format) list.reversed (list.interposed " ") (list\mix text\compose "")) ")")) + ($_ text\composite "(" (format type_func) " " (|> type_args (list\each format) list.reversed (list.interposed " ") (list\mix text\composite "")) ")")) (^template [<tag> <desc>] [(<tag> env body) - ($_ text\compose "(" <desc> " {" (|> env (list\map format) (text.interposed " ")) "} " (format body) ")")]) + ($_ text\composite "(" <desc> " {" (|> env (list\each format) (text.interposed " ")) "} " (format body) ")")]) ([#.UnivQ "All"] [#.ExQ "Ex"]) (#.Named [module name] type) - ($_ text\compose module "." name) + ($_ text\composite module "." name) )) ... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction @@ -145,7 +145,7 @@ (-> (List Type) Type Type) (case type (#.Primitive name params) - (#.Primitive name (list\map (reduced env) params)) + (#.Primitive name (list\each (reduced env) params)) (^template [<tag>] [(<tag> left right) @@ -160,21 +160,21 @@ (<tag> env def) _ - (<tag> (list\map (reduced env) old_env) def))]) + (<tag> (list\each (reduced env) old_env) def))]) ([#.UnivQ] [#.ExQ]) (#.Parameter idx) - (maybe.else (panic! ($_ text\compose + (maybe.else (panic! ($_ text\composite "Unknown type parameter" text.new_line " Index: " (n\encoded idx) text.new_line "Environment: " (|> env list.enumeration - (list\map (.function (_ [index type]) - ($_ text\compose - (n\encoded index) - " " (..format type)))) - (text.interposed (text\compose text.new_line " "))))) + (list\each (.function (_ [index type]) + ($_ text\composite + (n\encoded index) + " " (..format type)))) + (text.interposed (text\composite text.new_line " "))))) (list.item idx env)) _ @@ -258,7 +258,7 @@ (case type (#.Primitive name params) (` (#.Primitive (~ (code.text name)) - (.list (~+ (list\map code params))))) + (.list (~+ (list\each code params))))) (^template [<tag>] [(<tag> idx) @@ -276,7 +276,7 @@ (^template [<tag>] [(<tag> env body) - (` (<tag> (.list (~+ (list\map code env))) + (` (<tag> (.list (~+ (list\each code env))) (~ (code body))))]) ([#.UnivQ] [#.ExQ]) )) @@ -360,7 +360,7 @@ (#.Apply A F) (|> (..applied (list A) F) - (\ maybe.monad map quantified?) + (\ maybe.monad each quantified?) (maybe.else #0)) (^or (#.UnivQ _) (#.ExQ _)) @@ -420,7 +420,7 @@ [location meta.location valueT (meta.type valueN) .let [_ ("lux io log" - ($_ text\compose + ($_ text\composite (name\encoded (name_of ..:log!)) " " (location.format location) text.new_line "Expression: " (case valueC (#.Some valueC) @@ -454,7 +454,7 @@ (: (Foo Bit [Nat Text]) (foo expression)))) "NOTE: Careless use of type-casts is an easy way to introduce bugs. USE WITH CAUTION.")} - (let [casterC (` (: (All [(~+ (list\map code.local_identifier type_vars))] + (let [casterC (` (: (All [(~+ (list\each code.local_identifier type_vars))] (-> (~ input) (~ output))) (|>> :expected)))] (case value @@ -465,8 +465,9 @@ (in (list (` ((~ casterC) (~ value)))))))) (type: Typed - {#type Code - #expression Code}) + (Record + {#type Code + #expression Code})) (def: typed (Parser Typed) @@ -486,7 +487,7 @@ (Bar a b c) (bar expression))))} (macro.with_identifiers [g!_] - (let [shareC (` (: (All [(~+ (list\map code.local_identifier type_vars))] + (let [shareC (` (: (All [(~+ (list\each code.local_identifier type_vars))] (-> (~ (value@ #type exemplar)) (~ (value@ #type computation)))) (.function ((~ g!_) (~ g!_)) @@ -507,7 +508,7 @@ "=>" (.type (Bar Bit Nat Text)))} (in (list (` (:of ((~! :sharing) - [(~+ (list\map code.local_identifier type_vars))] + [(~+ (list\each code.local_identifier type_vars))] (~ (value@ #type exemplar)) (~ (value@ #expression exemplar)) diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index 57d9ae3ab..4e9e07045 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -35,11 +35,11 @@ list.tail) (type: .public Frame - {#.doc (example "Meta-data about an abstract/nominal type in a stack of them.")} - {#name Text - #type_vars (List Code) - #abstraction Code - #representation Code}) + (Record + {#name Text + #type_vars (List Code) + #abstraction Code + #representation Code})) (def: frames (Stack Frame) @@ -93,12 +93,10 @@ (exception.except ..no_active_frames []))))) (def: .public current - {#.doc (example "The currently-being-defined abstract/nominal type.")} (Meta Frame) (..peek! #.None)) (def: .public (specific name) - {#.doc (example "A specific abstract/nominal type still being defined somewhere in the scope.")} (-> Text (Meta Frame)) (..peek! (#.Some name))) @@ -179,10 +177,6 @@ (template [<name> <from> <to>] [(syntax: .public (<name> [[frame value] ..cast]) - {#.doc (example "Type-casting macro for abstract/nominal types." - (: <to> - (<name> (: <from> - value))))} (do meta.monad [[name type_vars abstraction representation] (peek! frame)] (in (list (` ((~! //.:as) [(~+ type_vars)] (~ <from>) (~ <to>) @@ -195,13 +189,13 @@ (def: abstraction_type_name (-> Name Text) (|>> name\encoded - ($_ text\compose + ($_ text\composite (name\encoded (name_of #..Abstraction)) " "))) (def: representation_definition_name (-> Text Text) - (|>> ($_ text\compose + (|>> ($_ text\composite (name\encoded (name_of #..Representation)) " "))) @@ -228,87 +222,9 @@ ... (This applies to uses of ":abstraction" and ":representation") (syntax: .public (abstract: [[export_policy [name type_vars] annotations representation_type primitives] ..abstract]) - {#.doc (example "Define abstract/nominal types which hide their representation details." - "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others." - (abstract: String - {#.doc "An opaque text."} - - Text - - (def: (string value) - (-> Text String) - (:abstraction value)) - - (def: (text value) - (-> String Text) - (:representation value))) - - "Type-parameters are optional." - (abstract: (Duplicate a) - {} - - [a a] - - (def: (duplicate value) - (All [a] (-> a (Duplicate a))) - (:abstraction [value value]))) - - "Definitions can be nested." - (abstract: (Single a) - {} - - a - - (def: (single value) - (All [a] (-> a (Single a))) - (:abstraction value)) - - (abstract: (Double a) - {} - - [a a] - - (def: (double value) - (All [a] (-> a (Double a))) - (:abstraction [value value])) - - (def: (single' value) - (All [a] (-> a (Single a))) - (:abstraction Single [value value])) - - (let [value 0123] - (same? value - (|> value - single' - (:representation Single) - double - :representation))))) - - "Type-parameters do not necessarily have to be used in the representation type." - "If they are not used, they become phantom types and can be used to customize types without changing the representation." - (abstract: (JavaScript a) - {} - - Text - - (abstract: Expression {} Any) - (abstract: Statement {} Any) - - (def: (+ x y) - (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression)) - (:abstraction - (format "(" (:representation x) "+" (:representation y) ")"))) - - (def: (while test body) - (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement)) - (:abstraction - (format "while(" (:representation test) ") {" - (:representation body) - "}")))) - )} (do meta.monad [current_module meta.current_module_name - .let [type_varsC (list\map code.local_identifier type_vars) + .let [type_varsC (list\each code.local_identifier type_vars) abstraction_declaration (` ((~ (code.local_identifier name)) (~+ type_varsC))) representation_declaration (` ((~ (code.local_identifier (representation_definition_name name))) (~+ type_varsC)))] @@ -322,13 +238,14 @@ [(~+ type_varsC)]))) (` (type: (~ representation_declaration) (~ representation_type))) - ($_ list\compose + ($_ list\composite primitives (list (` ((~! ..pop!))))))))) (type: (Selection a) - (#Specific Code a) - (#Current a)) + (Variant + (#Specific Code a) + (#Current a))) (def: (selection parser) (All [a] (-> (Parser a) (Parser (Selection a)))) @@ -336,22 +253,6 @@ parser)) (syntax: .public (:transmutation [selection (..selection <code>.any)]) - {#.doc (example "Transmutes an abstract/nominal type's phantom types." - (abstract: (JavaScript a) - {} - - Text - - (abstract: Expression {} Any) - (abstract: Statement {} Any) - - (def: (statement expression) - (-> (JavaScript Expression) (JavaScript Statement)) - (:transmutation expression)) - - (def: (statement' expression) - (-> (JavaScript Expression) (JavaScript Statement)) - (:transmutation JavaScript expression))))} (case selection (#Specific specific value) (in (list (` (.|> (~ value) @@ -364,11 +265,6 @@ (syntax: .public (^:representation [selection (<code>.form (..selection <code>.local_identifier)) body <code>.any branches (<>.some <code>.any)]) - {#.doc (example "Pattern-matching macro to easily extract a representation." - (def: (computation abstraction) - (All [a] (-> (Abstract a) ???)) - (let [(^:representation value) abstraction] - (foo (bar (baz value))))))} (case selection (#Specific specific name) (let [g!var (code.local_identifier name)] diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 3e6f6a8c4..2d57a12d7 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -1,5 +1,4 @@ (.module: - {#.doc "Type-checking functionality."} [library [lux #* ["@" target] @@ -53,14 +52,12 @@ ["Actual" (//.format actual)])) (type: .public Var - {#.doc (example "The ID for a type-variable in a type-checking context.")} Nat) (type: Assumption [Type Type]) (type: .public (Check a) - {#.doc (example "A type-checking computation which may fail or yield a value.")} (-> Type_Context (Try [Type_Context a]))) (type: (Checker a) @@ -72,7 +69,7 @@ (implementation: .public functor (Functor Check) - (def: (map f fa) + (def: (each f fa) (function (_ context) (case (fa context) (#try.Success [context' output]) @@ -111,7 +108,7 @@ (function (_ context) (#try.Success [context x]))) - (def: (join ffa) + (def: (conjoint ffa) (function (_ context) (case (ffa context) (#try.Success [context' fa]) @@ -185,7 +182,6 @@ (..failure (exception.error exception message))) (def: .public existential - {#.doc "A brand-new existential type."} (Check [Nat Type]) (function (_ context) (let [id (value@ #.ex_counter context)] @@ -236,8 +232,6 @@ (exception.except ..unknown_type_var id)))) (def: .public (bind type id) - {#.doc (example "Attemmpts to buy a type-variable." - "Fails if the variable has been bound already.")} (-> Type Var (Check Any)) (function (_ context) (case (|> context (value@ #.var_bindings) (var::get id)) @@ -263,7 +257,6 @@ (exception.except ..unknown_type_var id)))) (def: .public var - {#.doc (example "A brand-new (unbound) type-variable.")} (Check [Var Type]) (function (_ context) (let [id (value@ #.var_counter context)] @@ -329,7 +322,6 @@ (exception.except ..unknown_type_var current))))) (def: .public fresh_context - {#.doc (example "An empty/un-used type-checking context.")} Type_Context {#.var_counter 0 #.ex_counter 0 @@ -374,7 +366,7 @@ (do {! ..monad} [ring (..ring id) _ (..assertion "" (n.> 1 (set.size ring))) - _ (monad.map ! (re_bind type) (set.list ring))] + _ (monad.each ! (re_bind type) (set.list ring))] then) (do ..monad [?bound (read' id)] @@ -453,7 +445,7 @@ [<pattern> (do ! [ring (..ring <id>) - _ (monad.map ! (re_bind <type>) (set.list ring))] + _ (monad.each ! (re_bind <type>) (set.list ring))] (in assumptions))]) ([[(#.Var _) _] idE atype] [[_ (#.Var _)] idA etype]) @@ -639,8 +631,8 @@ ..silent_failure!)) ..silent_failure!) - (^template [<compose>] - [[(<compose> eL eR) (<compose> aL aR)] + (^template [<composite>] + [[(<composite> eL eR) (<composite> aL aR)] (do ..monad [assumptions (check' assumptions eL aL)] (check' assumptions eR aR))]) @@ -667,12 +659,10 @@ ..silent_failure!)))) (def: .public (check expected actual) - {#.doc "Type-check to ensure that the 'expected' type subsumes the 'actual' type."} (-> Type Type (Check Any)) (check' (list) expected actual)) (def: .public (subsumes? expected actual) - {#.doc "A simple type-checking function that just returns a yes/no answer."} (-> Type Type Bit) (case (..result ..fresh_context (..check' (list) expected actual)) (#try.Failure _) @@ -682,19 +672,17 @@ true)) (def: .public context - {#.doc (example "The current state of the type-checking context.")} (Check Type_Context) (function (_ context) (#try.Success [context context]))) (def: .public (clean inputT) - {#.doc (example "Resolves every bound type-variable to yield a new type that is as resolved as possible.")} (-> Type (Check Type)) (case inputT (#.Primitive name paramsT+) (|> paramsT+ - (monad.map ..monad clean) - (check\map (|>> (#.Primitive name)))) + (monad.each ..monad clean) + (check\each (|>> (#.Primitive name)))) (^or (#.Parameter _) (#.Ex _) (#.Named _)) (check\in inputT) @@ -704,7 +692,7 @@ (do ..monad [leftT' (clean leftT)] (|> (clean rightT) - (check\map (|>> (<tag> leftT')))))]) + (check\each (|>> (<tag> leftT')))))]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) (#.Var id) @@ -720,7 +708,7 @@ (^template [<tag>] [(<tag> envT+ unquantifiedT) (do {! ..monad} - [envT+' (monad.map ! clean envT+)] + [envT+' (monad.each ! clean envT+)] (in (<tag> envT+' unquantifiedT)))]) ([#.UnivQ] [#.ExQ]) )) diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index f2f28fdf2..19898da65 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -21,7 +21,7 @@ ["Actual" (%.type actual)])) (abstract: .public Dynamic - {#.doc "A value coupled with its type, so it can be checked later."} + {} [Type Any] @@ -34,16 +34,12 @@ (|>> :representation)) (syntax: .public (:dynamic [value <code>.any]) - {#.doc (example (: Dynamic - (:dynamic 123)))} (with_identifiers [g!value] (in (list (` (let [(~ g!value) (~ value)] ((~! ..abstraction) [(:of (~ g!value)) (~ g!value)]))))))) (syntax: .public (:static [type <code>.any value <code>.any]) - {#.doc (example (: (try.Try Nat) - (:static Nat (:dynamic 123))))} (with_identifiers [g!type g!value] (in (list (` (let [[(~ g!type) (~ g!value)] ((~! ..representation) (~ value))] (: ((~! try.Try) (~ type)) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 8af389efc..faaa608b2 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -93,8 +93,8 @@ (do {! meta.monad} [this_module_name meta.current_module_name imp_mods (meta.imported_modules this_module_name) - tag_lists (monad.map ! meta.tag_lists imp_mods) - .let [tag_lists (|> tag_lists list\join (list\map product.left) list\join) + tag_lists (monad.each ! meta.tag_lists imp_mods) + .let [tag_lists (|> tag_lists list\conjoint (list\each product.left) list\conjoint) candidates (list.only (|>> product.right (text\= simple_name)) tag_lists)]] (case candidates @@ -136,10 +136,10 @@ (try.else table (dictionary.has' name type table))) (: (Dictionary Text Type) (dictionary.empty text.hash)) - (list\join local_batches))]] + (list\conjoint local_batches))]] (in (|> total_locals dictionary.entries - (list\map (function (_ [name type]) [["" name] type])))))) + (list\each (function (_ [name type]) [["" name] type])))))) (def: local_structs (Meta (List [Name Type])) @@ -153,7 +153,7 @@ (do {! meta.monad} [this_module_name meta.current_module_name imported_modules (meta.imported_modules this_module_name) - accessible_definitions (monad.map ! meta.definitions imported_modules)] + accessible_definitions (monad.each ! meta.definitions imported_modules)] (in (list\mix (function (_ [imported_module definitions] tail) (available_definitions imported_module this_module_name definitions tail)) #.End @@ -201,8 +201,9 @@ (check.check expected_output actual_output))) (type: #rec Instance - {#constructor Name - #dependencies (List Instance)}) + (Record + {#constructor Name + #dependencies (List Instance)})) (def: (candidate_provision provision context dep alts) (-> (-> Lux Type_Context Type (Check Instance)) @@ -211,21 +212,21 @@ (do meta.monad [compiler meta.compiler_state] (case (|> alts - (list\map (function (_ [alt_name alt_type]) - (case (check.result context - (do {! check.monad} - [[tvars alt_type] (concrete_type alt_type) - .let [[deps alt_type] (type.flat_function alt_type)] - _ (check.check dep alt_type) - context' check.context - =deps (monad.map ! (provision compiler context') deps)] - (in =deps))) - (#.Left error) - (list) - - (#.Right =deps) - (list [alt_name =deps])))) - list\join) + (list\each (function (_ [alt_name alt_type]) + (case (check.result context + (do {! check.monad} + [[tvars alt_type] (concrete_type alt_type) + .let [[deps alt_type] (type.flat_function alt_type)] + _ (check.check dep alt_type) + context' check.context + =deps (monad.each ! (provision compiler context') deps)] + (in =deps))) + (#.Left error) + (list) + + (#.Right =deps) + (list [alt_name =deps])))) + list\conjoint) #.End (meta.failure (format "No candidates for provisioning: " (%.type dep))) @@ -260,23 +261,23 @@ [compiler meta.compiler_state context meta.type_context] (case (|> alts - (list\map (function (_ [alt_name alt_type]) - (case (<| (check.result context) - (do {! check.monad} - [[tvars alt_type] (concrete_type alt_type) - .let [[deps alt_type] (type.flat_function alt_type)] - _ (check.check alt_type sig_type) - member_type (member_type member_idx alt_type) - _ (ensure_function_application! member_type input_types output_type) - context' check.context - =deps (monad.map ! (provision compiler context') deps)] - (in =deps))) - (#.Left error) - (list) - - (#.Right =deps) - (list [alt_name =deps])))) - list\join) + (list\each (function (_ [alt_name alt_type]) + (case (<| (check.result context) + (do {! check.monad} + [[tvars alt_type] (concrete_type alt_type) + .let [[deps alt_type] (type.flat_function alt_type)] + _ (check.check alt_type sig_type) + member_type (member_type member_idx alt_type) + _ (ensure_function_application! member_type input_types output_type) + context' check.context + =deps (monad.each ! (provision compiler context') deps)] + (in =deps))) + (#.Left error) + (list) + + (#.Right =deps) + (list [alt_name =deps])))) + list\conjoint) #.End (meta.failure (format "No alternatives for " (%.type (type.function input_types output_type)))) @@ -311,39 +312,16 @@ (code.identifier constructor) _ - (` ((~ (code.identifier constructor)) (~+ (list\map instance$ dependencies)))))) + (` ((~ (code.identifier constructor)) (~+ (list\each instance$ dependencies)))))) (syntax: .public (\\ [member <code>.identifier args (<>.or (<>.and (<>.some <code>.identifier) <code>.end!) (<>.and (<>.some <code>.any) <code>.end!))]) - {#.doc (example "Automatic implementation selection (for type-class style polymorphism)." - "This feature layers type-class style polymorphism on top of Lux's signatures and implementations." - "When calling a polymorphic function, or using a polymorphic constant," - "this macro will check the types of the arguments, and the expected type for the whole expression" - "and it will search in the local scope, the module's scope and the imports' scope" - "in order to find suitable implementations to satisfy those requirements." - "If a single alternative is found, that one will be used automatically." - "If no alternative is found, or if more than one alternative is found (ambiguity)" - "a compile-time error will be raised, to alert the user." - "Examples:" - "Nat equivalence" - (\ number.equivalence = x y) - (\\ = x y) - "Can optionally add the prefix of the module where the signature was defined." - (\\ equivalence.= x y) - "(List Nat) equivalence" - (\\ = - (list.indices 10) - (list.indices 10)) - "(Functor List) map" - (\\ map ++ (list.indices 10)) - "Caveat emptor: You need to make sure to import the module of any implementation you want to use." - "Otherwise, this macro will not find it.")} (case args (#.Left [args _]) (do {! meta.monad} [[member_idx sig_type] (..implicit_member member) - input_types (monad.map ! ..implicit_type args) + input_types (monad.each ! ..implicit_type args) output_type meta.expected_type chosen_ones (alternatives sig_type member_idx input_types output_type)] (case chosen_ones @@ -353,19 +331,19 @@ (#.Item chosen #.End) (in (list (` (\ (~ (instance$ chosen)) (~ (code.local_identifier (product.right member))) - (~+ (list\map code.identifier args)))))) + (~+ (list\each code.identifier args)))))) _ (meta.failure (format "Too many implementations available: " (|> chosen_ones - (list\map (|>> product.left %.name)) + (list\each (|>> product.left %.name)) (text.interposed ", ")) " --- for type: " (%.type sig_type))))) (#.Right [args _]) (do {! meta.monad} [labels (|> (macro.identifier "") (list.repeated (list.size args)) (monad.all !))] - (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\map ..pair_list) list\join))] + (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\each ..pair_list) list\conjoint))] (..\\ (~ (code.identifier member)) (~+ labels))))))) )) @@ -381,28 +359,19 @@ (syntax: .public (with [implementations ..implicits body <code>.any]) - {#.doc (example "Establish lexical bindings for implementations that will be prioritized over non-lexically-bound implementations." - (with [n.addition] - (n.= (\ n.addition compose left right) - (\\ compose left right))))} (do meta.monad [g!implicit+ (implicit_bindings (list.size implementations))] (in (list (` (let [(~+ (|> (list.zipped/2 g!implicit+ implementations) - (list\map (function (_ [g!implicit implementation]) - (list g!implicit implementation))) - list\join))] + (list\each (function (_ [g!implicit implementation]) + (list g!implicit implementation))) + list\conjoint))] (~ body))))))) (syntax: .public (implicit: [implementations ..implicits]) - {#.doc (example "Establish local definitions for implementations that will be prioritized over foreign definitions." - (implicit: [n.multiplication]) - - (n.= (\ n.multiplication compose left right) - (\\ compose left right)))} (do meta.monad [g!implicit+ (implicit_bindings (list.size implementations))] (in (|> (list.zipped/2 g!implicit+ implementations) - (list\map (function (_ [g!implicit implementation]) - (` (def: .private (~ g!implicit) - {#.implementation? #1} - (~ implementation))))))))) + (list\each (function (_ [g!implicit implementation]) + (` (def: .private (~ g!implicit) + {#.implementation? #1} + (~ implementation))))))))) diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index 8fba22756..def324897 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -59,13 +59,13 @@ (syntax: .public (derived: [[export_policy name [poly_func poly_args] ?custom_impl] ..derivedP]) (do {! meta.monad} - [poly_args (monad.map ! meta.normal poly_args) + [poly_args (monad.each ! meta.normal poly_args) .let [impl (case ?custom_impl (#.Some custom_impl) custom_impl #.None - (` ((~ (code.identifier poly_func)) (~+ (list\map code.identifier poly_args)))))]] + (` ((~ (code.identifier poly_func)) (~+ (list\each code.identifier poly_args)))))]] (in (.list (` (def: (~ export_policy) (~ (code.identifier ["" name])) {#.implementation? #1} (~ impl))))))) @@ -75,7 +75,7 @@ (`` (case type (#.Primitive name params) (` (#.Primitive (~ (code.text name)) - (.list (~+ (list\map (code env) params))))) + (.list (~+ (list\each (code env) params))))) (^template [<tag>] [(<tag> idx) @@ -102,8 +102,8 @@ (^template [<macro> <tag> <flattener>] [(<tag> left right) - (` (<macro> (~+ (list\map (code env) (<flattener> type)))))]) - ([.Variant #.Sum type.flat_variant] + (` (<macro> (~+ (list\each (code env) (<flattener> type)))))]) + ([.Union #.Sum type.flat_variant] [.Tuple #.Product type.flat_tuple]) (#.Named name sub_type) @@ -111,7 +111,7 @@ (^template [<tag>] [(<tag> scope body) - (` (<tag> (.list (~+ (list\map (code env) scope))) + (` (<tag> (.list (~+ (list\each (code env) scope))) (~ (code env body))))]) ([#.UnivQ] [#.ExQ]) ))) diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux index 6334d68f3..be7663444 100644 --- a/stdlib/source/library/lux/type/quotient.lux +++ b/stdlib/source/library/lux/type/quotient.lux @@ -27,8 +27,9 @@ "All equivalent values will belong to the same class." "This means all equivalent values possess the same label.")} - {#value t - #label c} + (Record + {#value t + #label c}) (def: .public (quotient class value) (All [t c %] diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 7bb718659..2ab800d2c 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -14,8 +14,9 @@ (abstract: .public (Refined t %) {#.doc "A refined version of another type, using a predicate to select valid instances."} - {#value t - #predicate (Predicate t)} + (Record + {#value t + #predicate (Predicate t)}) (type: .public (Refiner t %) {#.doc (example "A selection mechanism for refined instances of a type.")} diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 3e37d8b30..796bf4e4d 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -176,8 +176,8 @@ swaps) maybe.trusted row.list) - g!inputsT+ (list\map (|>> (~) (..Key ..Commutative) (`)) g!inputs) - g!outputsT+ (list\map (|>> (~) (..Key ..Commutative) (`)) g!outputs)]] + g!inputsT+ (list\each (|>> (~) (..Key ..Commutative) (`)) g!inputs) + g!outputsT+ (list\each (|>> (~) (..Key ..Commutative) (`)) g!outputs)]] (in (list (` (: (All [(~ g!!) (~+ g!inputs) (~ g!context)] (-> ((~! monad.Monad) (~ g!!)) (Procedure (~ g!!) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 80e8eaebb..4f52cacb1 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -86,7 +86,7 @@ (def: (read _) (|> jvm_input java/io/InputStream::read - (\ (try.with io.monad) map .nat))) + (\ (try.with io.monad) each .nat))) (def: (read_line _) (java/io/Console::readLine jvm_console)) diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux index 76c1cc17b..f2ca6ee00 100644 --- a/stdlib/source/library/lux/world/db/jdbc.lux +++ b/stdlib/source/library/lux/world/db/jdbc.lux @@ -51,16 +51,19 @@ (#static getConnection [java/lang/String java/lang/String java/lang/String] #io #try java/sql/Connection)) (type: .public Credentials - {#url URL - #user Text - #password Text}) + (Record + {#url URL + #user Text + #password Text})) -(type: .public ID Int) +(type: .public ID + Int) (type: .public (Statement input) - {#sql sql.Statement - #input (Input input) - #value input}) + (Record + {#sql sql.Statement + #input (Input input) + #value input})) (template [<name> <forge> <output>] [(capability: .public (<name> ! i) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index 4a2f43507..e9035aded 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -47,8 +47,10 @@ (-> a [Nat java/sql/PreparedStatement] (Try [Nat java/sql/PreparedStatement]))) -(implementation: .public contravariant (Contravariant Input) - (def: (map-1 f fb) +(implementation: .public contravariant + (Contravariant Input) + + (def: (each f fb) (function (fa value circumstance) (fb (f value) circumstance)))) diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index e6e9a8306..933830e1e 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -53,7 +53,7 @@ (implementation: .public functor (Functor Output) - (def: (map f fa) + (def: (each f fa) (function (_ idx+rs) (case (fa idx+rs) (#try.Failure error) @@ -90,7 +90,7 @@ (function (_ [idx rs]) (#.Some [idx a]))) - (def: (join mma) + (def: (conjoint mma) (function (_ [idx rs]) (case (mma [idx rs]) (#try.Failure error) diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index a3b7aff6a..6b01531bc 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -55,7 +55,8 @@ [(Statement' kind)] ) -(type: .public Alias Text) +(type: .public Alias + Text) (def: .public no_alias Alias "") @@ -64,7 +65,8 @@ ... SQL (template [<declaration> <kind>] - [(type: .public <declaration> (SQL <kind>))] + [(type: .public <declaration> + (SQL <kind>))] [Literal (Value' Literal')] [Column (Value' Column')] @@ -108,7 +110,7 @@ (def: listing (-> (List (SQL Any)) Text) - (|>> (list\map (|>> :representation)) + (|>> (list\each (|>> :representation)) (text.interposed ", "))) ... Value @@ -215,10 +217,10 @@ _ (|> columns - (list\map (.function (_ [column alias]) - (if (text\= ..no_alias alias) - (:representation column) - (format (:representation column) " AS " alias)))) + (list\each (.function (_ [column alias]) + (if (text\= ..no_alias alias) + (:representation column) + (format (:representation column) " AS " alias)))) (text.interposed ", "))) " FROM " (:representation source))))] @@ -296,8 +298,8 @@ (format (:representation query) " ORDER BY " (|> pairs - (list\map (.function (_ [value order]) - (format (:representation value) " " (:representation order)))) + (list\each (.function (_ [value order]) + (format (:representation value) " " (:representation order)))) (text.interposed ", ")))))) (def: .public (group_by pairs query) @@ -323,7 +325,7 @@ (..parenthesize (..listing columns)) " VALUES " (|> rows - (list\map (|>> ..listing ..parenthesize)) + (list\each (|>> ..listing ..parenthesize)) (text.interposed ", ")) ))) @@ -336,8 +338,8 @@ _ (format " SET " (|> pairs - (list\map (.function (_ [column value]) - (format (:representation column) "=" (:representation value)))) + (list\each (.function (_ [column value]) + (format (:representation column) "=" (:representation value)))) (text.interposed ", "))))))) (def: .public delete diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 2a8dd0951..08bffdb97 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -97,14 +97,14 @@ (All [!] (-> (System !) Path (Maybe Path))) (|> path (..un_rooted fs) - (maybe\map product.left))) + (maybe\each product.left))) (def: .public (name fs path) {#.doc (example "The un-nested name of a file/directory.")} (All [!] (-> (System !) Path Text)) (|> path (..un_rooted fs) - (maybe\map product.right) + (maybe\each product.right) (maybe.else path))) (def: .public (async fs) @@ -218,7 +218,7 @@ [(def: <name> (|>> java/io/File::new <method> - (io\map (|>> (try.else false)))))] + (io\each (|>> (try.else false)))))] [file? java/io/File::isFile] [directory? java/io/File::isDirectory] @@ -238,8 +238,8 @@ (|> children array.list (monad.only ! (|>> <method>)) - (\ ! map (monad.map ! (|>> java/io/File::getAbsolutePath))) - (\ ! join)) + (\ ! each (monad.each ! (|>> java/io/File::getAbsolutePath))) + (\ ! conjoint)) #.None (\ io.monad in (exception.except ..cannot_find_directory [path])))))] @@ -251,12 +251,12 @@ (def: file_size (|>> java/io/File::new java/io/File::length - (\ (try.with io.monad) map .nat))) + (\ (try.with io.monad) each .nat))) (def: last_modified (|>> java/io/File::new (java/io/File::lastModified) - (\ (try.with io.monad) map (|>> duration.of_millis instant.absolute)))) + (\ (try.with io.monad) each (|>> duration.of_millis instant.absolute)))) (def: can_execute? (|>> java/io/File::new @@ -456,13 +456,13 @@ (Fs::readdir [path (..value_callback write!)] node_fs))] (|> subs array.list - (list\map (|>> (format path ..js_separator))) - (monad.map ! (function (_ sub) - (\ ! map (|>> (<method> []) [sub]) - (with_async write! (Try Stats) - (Fs::stat [sub (..value_callback write!)] node_fs))))) - (\ ! map (|>> (list.only product.right) - (list\map product.left))))))] + (list\each (|>> (format path ..js_separator))) + (monad.each ! (function (_ sub) + (\ ! each (|>> (<method> []) [sub]) + (with_async write! (Try Stats) + (Fs::stat [sub (..value_callback write!)] node_fs))))) + (\ ! each (|>> (list.only product.right) + (list\each product.left))))))] [directory_files Stats::isFile] [sub_directories Stats::isDirectory] @@ -490,7 +490,7 @@ (def: (can_execute? path) (let [node_fs (..node_fs [])] - (\ async.monad map + (\ async.monad each (|>> (case> (#try.Success _) true @@ -588,7 +588,7 @@ (~~ (template [<name> <method>] [(def: <name> (|>> <method> - (io\map (|>> (try.else false)))))] + (io\each (|>> (try.else false)))))] [file? os/path::isfile] [directory? os/path::isdir] @@ -602,13 +602,13 @@ (let [! (try.with io.monad)] (|> path os::listdir - (\ ! map (|>> array.list - (list\map (|>> (format path ..python_separator))) - (monad.map ! (function (_ sub) - (\ ! map (|>> [sub]) (<method> [sub])))) - (\ ! map (|>> (list.only product.right) - (list\map product.left))))) - (\ ! join))))] + (\ ! each (|>> array.list + (list\each (|>> (format path ..python_separator))) + (monad.each ! (function (_ sub) + (\ ! each (|>> [sub]) (<method> [sub])))) + (\ ! each (|>> (list.only product.right) + (list\each product.left))))) + (\ ! conjoint))))] [directory_files os/path::isfile] [sub_directories os/path::isdir] @@ -616,14 +616,14 @@ (def: file_size (|>> os/path::getsize - (\ (try.with io.monad) map .nat))) + (\ (try.with io.monad) each .nat))) (def: last_modified (|>> os/path::getmtime - (\ (try.with io.monad) map (|>> f.int - (i.* +1,000) - duration.of_millis - instant.absolute)))) + (\ (try.with io.monad) each (|>> f.int + (i.* +1,000) + duration.of_millis + instant.absolute)))) (def: (can_execute? path) (os::access [path (os::X_OK)])) @@ -714,7 +714,7 @@ (~~ (template [<name> <test>] [(def: <name> (|>> <test> - (io\map (|>> (try.else false)))))] + (io\each (|>> (try.else false)))))] [file? RubyFile::file?] [directory? RubyFile::directory?] @@ -730,7 +730,7 @@ children (RubyDir::children [] self) output (loop [input (|> children array.list - (list\map (|>> (format path ..ruby_separator)))) + (list\each (|>> (format path ..ruby_separator)))) output (: (List ..Path) (list))] (case input @@ -754,7 +754,7 @@ [(def: <name> (let [! (try.with io.monad)] (|>> RubyFile::stat - (\ ! map (`` (|>> (~~ (template.spliced <pipeline>))))))))] + (\ ! each (`` (|>> (~~ (template.spliced <pipeline>))))))))] [file_size [RubyStat::size .nat]] [last_modified [(RubyStat::mtime []) @@ -1000,9 +1000,10 @@ (\ fs directory? path)))) (type: Mock_File - {#mock_last_modified Instant - #mock_can_execute Bit - #mock_content Binary}) + (Record + {#mock_last_modified Instant + #mock_can_execute Bit + #mock_content Binary})) (type: #rec Mock (Dictionary Text (Either Mock_File Mock))) @@ -1189,9 +1190,9 @@ [(def: (<method> path) (|> store stm.read - (\ stm.monad map + (\ stm.monad each (|>> (<retrieve> separator path) - (try\map (function.constant true)) + (try\each (function.constant true)) (try.else false))) stm.commit!))] @@ -1238,9 +1239,9 @@ [|store| (stm.read store)] (in (|> |store| (..retrieve_mock_file! separator path) - (try\map (|>> product.right - (value@ #mock_content) - binary.size))))))) + (try\each (|>> product.right + (value@ #mock_content) + binary.size))))))) (def: (last_modified path) (stm.commit! @@ -1248,8 +1249,8 @@ [|store| (stm.read store)] (in (|> |store| (..retrieve_mock_file! separator path) - (try\map (|>> product.right - (value@ #mock_last_modified)))))))) + (try\each (|>> product.right + (value@ #mock_last_modified)))))))) (def: (can_execute? path) (stm.commit! @@ -1257,8 +1258,8 @@ [|store| (stm.read store)] (in (|> |store| (..retrieve_mock_file! separator path) - (try\map (|>> product.right - (value@ #mock_can_execute)))))))) + (try\each (|>> product.right + (value@ #mock_can_execute)))))))) (def: (read path) (stm.commit! @@ -1266,8 +1267,8 @@ [|store| (stm.read store)] (in (|> |store| (..retrieve_mock_file! separator path) - (try\map (|>> product.right - (value@ #mock_content)))))))) + (try\each (|>> product.right + (value@ #mock_content)))))))) (def: (delete path) (stm.commit! @@ -1295,7 +1296,7 @@ (do try.monad [[name file] (..retrieve_mock_file! separator path |store|)] (..update_mock_file! separator path now - (\ binary.monoid compose + (\ binary.monoid composite (value@ #mock_content file) content) |store|))) diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 1625f79ef..35dfb894d 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -35,9 +35,10 @@ (abstract: .public Concern {#.doc (example "A particular concern to watch-out for.")} - {#creation Bit - #modification Bit - #deletion Bit} + (Record + {#creation Bit + #modification Bit + #deletion Bit}) (def: none Concern @@ -139,11 +140,11 @@ (-> (//.System Async) //.Path (Async (Try (List [//.Path Instant])))) (do {! (try.with async.monad)} [files (\ fs directory_files directory)] - (monad.map ! (function (_ file) - (|> file - (\ fs last_modified) - (\ ! map (|>> [file])))) - files))) + (monad.each ! (function (_ file) + (|> file + (\ fs last_modified) + (\ ! each (|>> [file])))) + files))) (def: (available_directory_changes fs [directory [concern file_tracker]]) (-> (//.System Async) [//.Path [Concern File_Tracker]] @@ -158,11 +159,11 @@ current_files) (list)) available (|> current_files - (list\map product.left) + (list\each product.left) (set.of_list text.hash)) deletions (if (..deletion? concern) (|> (dictionary.entries file_tracker) - (list\map product.left) + (list\each product.left) (list.only (|>> (set.member? available) not))) (list)) modifications (list.all (function (_ [path current_modification]) @@ -235,28 +236,28 @@ (do {! (try.with async.monad)} [changes (|> @tracker dictionary.entries - (monad.map ! (..available_directory_changes fs))) + (monad.each ! (..available_directory_changes fs))) _ (do async.monad [_ (stm.commit! (stm.write (|> changes - (list\map product.left) + (list\each product.left) (dictionary.of_list text.hash)) tracker))] (in (#try.Success []))) .let [[creations modifications deletions] (list\mix (function (_ [_ [creations modifications deletions]] [all_creations all_modifications all_deletions]) - [(list\compose creations all_creations) - (list\compose modifications all_modifications) - (list\compose deletions all_deletions)]) + [(list\composite creations all_creations) + (list\composite modifications all_modifications) + (list\composite deletions all_deletions)]) [(list) (list) (list)] changes)]] - (in ($_ list\compose - (list\map (|>> product.left [..creation]) creations) + (in ($_ list\composite + (list\each (|>> product.left [..creation]) creations) (|> modifications (list.only (function (_ [path previous_modification current_modification]) (not (instant\= previous_modification current_modification)))) - (list\map (|>> product.left [..modification]))) - (list\map (|>> [..deletion]) deletions) + (list\each (|>> product.left [..modification]))) + (list\each (|>> [..deletion]) deletions) ))))) ))) @@ -338,9 +339,9 @@ (def: default_key_concern (-> java/nio/file/WatchKey (IO Concern)) (|>> java/nio/file/WatchKey::pollEvents - (\ io.monad map (|>> ..default_list - (list\map default_event_concern) - (list\mix ..also ..none))))) + (\ io.monad each (|>> ..default_list + (list\each default_event_concern) + (list\mix ..also ..none))))) (import: java/nio/file/WatchService ["#::." @@ -401,7 +402,7 @@ (def: (watch_events concern) (-> Concern (List Watch_Event)) - ($_ list\compose + ($_ list\composite (if (..creation? concern) (list (:as Watch_Event (java/nio/file/StandardWatchEventKinds::ENTRY_CREATE))) (list)) diff --git a/stdlib/source/library/lux/world/input/keyboard.lux b/stdlib/source/library/lux/world/input/keyboard.lux index 4b3127c18..e33e8c4a7 100644 --- a/stdlib/source/library/lux/world/input/keyboard.lux +++ b/stdlib/source/library/lux/world/input/keyboard.lux @@ -100,8 +100,9 @@ (type: .public Press {#.doc (example "A key-press for a key.")} - {#pressed? Bit - #input Key}) + (Record + {#pressed? Bit + #input Key})) (template [<bit> <name>] [(def: .public (<name> key) diff --git a/stdlib/source/library/lux/world/net.lux b/stdlib/source/library/lux/world/net.lux index d1acb1f01..fae3c1f78 100644 --- a/stdlib/source/library/lux/world/net.lux +++ b/stdlib/source/library/lux/world/net.lux @@ -15,5 +15,6 @@ Text) (type: .public Location - {#address Address - #port Port}) + (Record + {#address Address + #port Port})) diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index 2c0877351..75b3c7b86 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -16,15 +16,16 @@ Text) (type: .public Method - #Post - #Get - #Put - #Patch - #Delete - #Head - #Connect - #Options - #Trace) + (Variant + #Post + #Get + #Put + #Patch + #Delete + #Head + #Connect + #Options + #Trace)) (type: .public Port Nat) @@ -46,28 +47,34 @@ (-> (Maybe Nat) (! (Try [Nat Binary])))) (type: .public Scheme - #HTTP - #HTTPS) + (Variant + #HTTP + #HTTPS)) (type: .public Address - {#port Port - #host Text}) + (Record + {#port Port + #host Text})) (type: .public Identification - {#local Address - #remote Address}) + (Record + {#local Address + #remote Address})) (type: .public Protocol - {#version Version - #scheme Scheme}) + (Record + {#version Version + #scheme Scheme})) (type: .public Resource - {#method Method - #uri URI}) + (Record + {#method Method + #uri URI})) (type: .public (Message !) - {#headers Headers - #body (Body !)}) + (Record + {#headers Headers + #body (Body !)})) (type: .public (Request !) [Identification Protocol Resource (Message !)]) diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 50a5a2436..eaf97a16e 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -127,7 +127,7 @@ (def: (default_body input) (-> java/io/BufferedInputStream (//.Body IO)) - (|>> (maybe\map (|>> [true])) + (|>> (maybe\each (|>> [true])) (maybe.else [false ..default_buffer_size]) (case> [_ 0] (do (try.with io.monad) @@ -161,14 +161,14 @@ +0 (in (..body_of output)) _ (|> buffer (binary.slice 0 (.nat so_far)) - (\ try.functor map - (|>> (\ binary.monoid compose output) + (\ try.functor each + (|>> (\ binary.monoid composite output) ..body_of)) (\ io.monad in)))) +0 (recur so_far output) _ (if (i.= remaining bytes_read) (recur +0 - (\ binary.monoid compose output buffer)) + (\ binary.monoid composite output buffer)) (recur (i.+ bytes_read so_far) output)))))))))) @@ -197,9 +197,9 @@ [connection (|> url java/net/URL::new java/net/URL::openConnection) .let [connection (:as java/net/HttpURLConnection connection)] _ (java/net/HttpURLConnection::setRequestMethod (..jvm_method method) connection) - _ (monad.map ! (function (_ [name value]) - (java/net/URLConnection::setRequestProperty name value connection)) - (dictionary.entries headers)) + _ (monad.each ! (function (_ [name value]) + (java/net/URLConnection::setRequestProperty name value connection)) + (dictionary.entries headers)) _ (case data (#.Some data) (do ! @@ -216,7 +216,7 @@ headers (..default_headers connection) input (|> connection java/net/URLConnection::getInputStream - (\ ! map (|>> java/io/BufferedInputStream::new)))] + (\ ! each (|>> java/io/BufferedInputStream::new)))] (in [(.nat status) {#//.headers headers #//.body (..default_body input)}]))))))] @@ -230,7 +230,7 @@ (def: (request method url headers data) (|> (\ client request method url headers data) async.future - (\ async.monad map + (\ async.monad each (|>> (case> (#try.Success [status message]) (#try.Success [status (revised@ #//.body (: (-> (//.Body IO) (//.Body Async)) (function (_ body) diff --git a/stdlib/source/library/lux/world/net/http/cookie.lux b/stdlib/source/library/lux/world/net/http/cookie.lux index c9673ed31..bb93c2c82 100644 --- a/stdlib/source/library/lux/world/net/http/cookie.lux +++ b/stdlib/source/library/lux/world/net/http/cookie.lux @@ -58,8 +58,9 @@ ) (type: .public CSRF_Policy - #Strict - #Lax) + (Variant + #Strict + #Lax)) (def: .public (same_site policy) (-> CSRF_Policy Directive) diff --git a/stdlib/source/library/lux/world/net/http/query.lux b/stdlib/source/library/lux/world/net/http/query.lux index 0fc879552..1f71fbcc7 100644 --- a/stdlib/source/library/lux/world/net/http/query.lux +++ b/stdlib/source/library/lux/world/net/http/query.lux @@ -35,7 +35,7 @@ [_ (l.this "%") code (|> (l.exactly 2 l.hexadecimal) (p.codec nat.hex) - (\ ! map text.from_code)) + (\ ! each text.from_code)) tail component] (in (format head code tail)))))))) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 30adaea99..26e25e7a7 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -35,10 +35,10 @@ (monad.mix try.monad (function (_ input [offset output]) (let [amount (binary.size input)] - (\ try.functor map (|>> [(n.+ amount offset)]) + (\ try.functor each (|>> [(n.+ amount offset)]) (binary.copy amount 0 input offset output)))) [0 (|> inputs - (list\map binary.size) + (list\each binary.size) (list\mix n.+ 0) binary.empty)] inputs))] diff --git a/stdlib/source/library/lux/world/output/video/resolution.lux b/stdlib/source/library/lux/world/output/video/resolution.lux index 08b5f1a3f..973cdac9b 100644 --- a/stdlib/source/library/lux/world/output/video/resolution.lux +++ b/stdlib/source/library/lux/world/output/video/resolution.lux @@ -20,8 +20,9 @@ (type: .public Resolution {#.doc (example "A screen resolution.")} - {#width Nat - #height Nat}) + (Record + {#width Nat + #height Nat})) (def: .public hash (Hash Resolution) diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index 05f9cd8a6..6262649aa 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -58,9 +58,9 @@ (All [!] (-> (Monad !) (Program !) (! Environment))) (do {! monad} [variables (\ program available_variables []) - entries (monad.map ! (function (_ name) - (\ ! map (|>> [name]) (\ program variable name))) - variables)] + entries (monad.each ! (function (_ name) + (\ ! each (|>> [name]) (\ program variable name))) + variables)] (in (|> entries (list.all (function (_ [name value]) (case value @@ -319,12 +319,12 @@ (#.Some process/env) (|> (Object::entries [process/env]) array.list - (list\map (|>> (array.read! 0) maybe.trusted))) + (list\each (|>> (array.read! 0) maybe.trusted))) #.None (list)) (list))) - @.python (\ io.monad map array.list (os/environ::keys [])) + @.python (\ io.monad each array.list (os/environ::keys [])) ... Lua offers no way to get all the environment variables available. @.lua (io.io (list)) @.ruby (|> (RubyEnv::keys []) @@ -335,7 +335,7 @@ ... (in (|> environment ... ..array_keys ... array.list - ... (list\map (function (_ variable) + ... (list\each (function (_ variable) ... [variable ("php array read" (:as Nat variable) environment)])) ... (dictionary.of_list text.hash)))) ... @.scheme (do io.monad diff --git a/stdlib/source/library/lux/world/service/inventory.lux b/stdlib/source/library/lux/world/service/inventory.lux index 38c69557e..6a5fac798 100644 --- a/stdlib/source/library/lux/world/service/inventory.lux +++ b/stdlib/source/library/lux/world/service/inventory.lux @@ -6,7 +6,8 @@ [security ["!" capability (#+ capability:)]]]]]) -(type: .public ID Nat) +(type: .public ID + Nat) (type: .public Ownership {#owner ID diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index a86f33a67..209c161bd 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -290,7 +290,7 @@ ... https://en.wikipedia.org/wiki/Code_injection#Shell_injection (def: windows? (IO (Try Bit)) - (\ (try.with io.monad) map + (\ (try.with io.monad) each (|>> java/lang/String::toLowerCase (text.starts_with? "windows")) (java/lang/System::getProperty "os.name"))) @@ -305,7 +305,7 @@ (java/lang/ProcessBuilder::directory (java/io/File::new working_directory)))] _ (|> builder java/lang/ProcessBuilder::environment - (\ try.functor map (..jvm::load_environment environment)) + (\ try.functor each (..jvm::load_environment environment)) (\ io.monad in)) process (java/lang/ProcessBuilder::start builder)] (..default_process process)))) @@ -380,5 +380,5 @@ (def: execute (|>> mock - (\ try.monad map (..mock_process (atom.atom init))) + (\ try.monad each (..mock_process (atom.atom init))) io.io))) diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/poly/lux/abstract/equivalence.lux index bc633d1ed..a75f56f2d 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -115,15 +115,15 @@ (in (` (: (~ (@Equivalence inputT)) (function ((~ g!_) (~ g!left) (~ g!right)) (case [(~ g!left) (~ g!right)] - (~+ (list\join (list\map (function (_ [tag g!eq]) - (if (nat.= last tag) - (list (` [((~ (code.nat (-- tag))) #1 (~ g!left)) - ((~ (code.nat (-- tag))) #1 (~ g!right))]) - (` ((~ g!eq) (~ g!left) (~ g!right)))) - (list (` [((~ (code.nat tag)) #0 (~ g!left)) - ((~ (code.nat tag)) #0 (~ g!right))]) - (` ((~ g!eq) (~ g!left) (~ g!right)))))) - (list.enumeration members)))) + (~+ (list\conjoint (list\each (function (_ [tag g!eq]) + (if (nat.= last tag) + (list (` [((~ (code.nat (-- tag))) #1 (~ g!left)) + ((~ (code.nat (-- tag))) #1 (~ g!right))]) + (` ((~ g!eq) (~ g!left) (~ g!right)))) + (list (` [((~ (code.nat tag)) #0 (~ g!left)) + ((~ (code.nat tag)) #0 (~ g!right))]) + (` ((~ g!eq) (~ g!left) (~ g!right)))))) + (list.enumeration members)))) (~ g!_) #0)))))) ... Tuples @@ -131,13 +131,13 @@ [g!eqs (<type>.tuple (<>.many equivalence)) .let [g!_ (code.local_identifier "_____________") indices (list.indices (list.size g!eqs)) - g!lefts (list\map (|>> nat\encoded (text\compose "left") code.local_identifier) indices) - g!rights (list\map (|>> nat\encoded (text\compose "right") code.local_identifier) indices)]] + g!lefts (list\each (|>> nat\encoded (text\composite "left") code.local_identifier) indices) + g!rights (list\each (|>> nat\encoded (text\composite "right") code.local_identifier) indices)]] (in (` (: (~ (@Equivalence inputT)) (function ((~ g!_) [(~+ g!lefts)] [(~+ g!rights)]) (and (~+ (|> (list.zipped/3 g!eqs g!lefts g!rights) - (list\map (function (_ [g!eq g!left g!right]) - (` ((~ g!eq) (~ g!left) (~ g!right))))))))))))) + (list\each (function (_ [g!eq g!left g!right]) + (` ((~ g!eq) (~ g!left) (~ g!right))))))))))))) ... Type recursion (do ! [[g!self bodyC] (<type>.recursive equivalence) @@ -156,13 +156,13 @@ (do ! [[funcC varsC bodyC] (<type>.polymorphic equivalence)] (in (` (: (All [(~+ varsC)] - (-> (~+ (list\map (|>> (~) ((~! /.Equivalence)) (`)) varsC)) + (-> (~+ (list\each (|>> (~) ((~! /.Equivalence)) (`)) varsC)) ((~! /.Equivalence) ((~ (poly.code *env* inputT)) (~+ varsC))))) (function ((~ funcC) (~+ varsC)) (~ bodyC)))))) <type>.recursive_call ... If all else fails... (|> <type>.any - (\ ! map (|>> %.type (format "Cannot create Equivalence for: ") <>.failure)) - (\ ! join)) + (\ ! each (|>> %.type (format "Cannot create Equivalence for: ") <>.failure)) + (\ ! conjoint)) )))) diff --git a/stdlib/source/poly/lux/abstract/functor.lux b/stdlib/source/poly/lux/abstract/functor.lux index d68d55af8..e607f1174 100644 --- a/stdlib/source/poly/lux/abstract/functor.lux +++ b/stdlib/source/poly/lux/abstract/functor.lux @@ -38,7 +38,7 @@ (function (_ unwrappedT) (if (n.= 1 num_vars) (` ((~! /.Functor) (~ (poly.code *env* unwrappedT)))) - (let [paramsC (|> num_vars -- list.indices (list\map (|>> %.nat code.local_identifier)))] + (let [paramsC (|> num_vars -- list.indices (list\each (|>> %.nat code.local_identifier)))] (` (All [(~+ paramsC)] ((~! /.Functor) ((~ (poly.code *env* unwrappedT)) (~+ paramsC))))))))) Arg<?> (: (-> Code (<type>.Parser Code)) @@ -55,13 +55,13 @@ membersC (<type>.variant (p.many (Arg<?> valueC))) .let [last (-- (list.size membersC))]] (in (` (case (~ valueC) - (~+ (list\join (list\map (function (_ [tag memberC]) - (if (n.= last tag) - (list (` ((~ (code.nat (-- tag))) #1 (~ valueC))) - (` ((~ (code.nat (-- tag))) #1 (~ memberC)))) - (list (` ((~ (code.nat tag)) #0 (~ valueC))) - (` ((~ (code.nat tag)) #0 (~ memberC)))))) - (list.enumeration membersC)))))))) + (~+ (list\conjoint (list\each (function (_ [tag memberC]) + (if (n.= last tag) + (list (` ((~ (code.nat (-- tag))) #1 (~ valueC))) + (` ((~ (code.nat (-- tag))) #1 (~ memberC)))) + (list (` ((~ (code.nat tag)) #0 (~ valueC))) + (` ((~ (code.nat tag)) #0 (~ memberC)))))) + (list.enumeration membersC)))))))) ... Tuples (do p.monad [pairsCC (: (<type>.Parser (List [Code Code])) @@ -73,11 +73,11 @@ [_ (in []) memberC (Arg<?> slotC)] (recur (++ idx) - (list\compose pairsCC (list [slotC memberC]))))) + (list\composite pairsCC (list [slotC memberC]))))) (in pairsCC)))))] (in (` (case (~ valueC) - [(~+ (list\map product.left pairsCC))] - [(~+ (list\map product.right pairsCC))])))) + [(~+ (list\each product.left pairsCC))] + [(~+ (list\each product.right pairsCC))])))) ... Functions (do ! [_ (in []) @@ -87,14 +87,14 @@ (Arg<?> outL)) .let [inC+ (|> (list.size inT+) list.indices - (list\map (|>> %.nat (format "____________inC") code.local_identifier)))]] + (list\each (|>> %.nat (format "____________inC") code.local_identifier)))]] (in (` (function ((~ g!) (~+ inC+)) (let [(~ outL) ((~ valueC) (~+ inC+))] (~ outC)))))) ... Recursion (do p.monad [_ <type>.recursive_call] - (in (` ((~' map) (~ funcC) (~ valueC))))) + (in (` ((~' each) (~ funcC) (~ valueC))))) ... Parameters (do p.monad [_ <type>.any] @@ -106,5 +106,5 @@ (p.failure (format "Cannot create Functor for: " (%.type inputT)))))] (in (` (: (~ (@Functor inputT)) (implementation - (def: ((~' map) (~ funcC) (~ inputC)) + (def: ((~' each) (~ funcC) (~ inputC)) (~ outputC)))))))) diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index be290d301..8de72193b 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -76,7 +76,7 @@ (def: encoded (|>> .nat (\ nat_codec encoded))) (def: decoded - (|>> (\ nat_codec decoded) (\ try.functor map .int)))) + (|>> (\ nat_codec decoded) (\ try.functor each .int)))) (def: (nullable writer) {#.doc "Builds a JSON generator for potentially inexistent values."} @@ -95,7 +95,7 @@ (\ ..int_codec encoded))) (def: decoded (|>> (\ ..int_codec decoded) - (\ try.functor map (debug.private unit.in))))) + (\ try.functor each (debug.private unit.in))))) (poly: encoded (with_expansions @@ -147,8 +147,8 @@ encoded))] (in (` (: (~ (@JSON\encoded inputT)) (|>> ((~! dictionary.entries)) - ((~! list\map) (function ((~ g!_) [(~ g!key) (~ g!val)]) - [(~ g!key) ((~ =val=) (~ g!val))])) + ((~! list\each) (function ((~ g!_) [(~ g!key) (~ g!val)]) + [(~ g!key) ((~ =val=) (~ g!val))])) ((~! dictionary.of_list) (~! text.hash)) #/.Object))))) (do ! @@ -162,7 +162,7 @@ (<type>.exactly .List) encoded))] (in (` (: (~ (@JSON\encoded inputT)) - (|>> ((~! list\map) (~ =sub=)) ((~! row.of_list)) #/.Array))))) + (|>> ((~! list\each) (~ =sub=)) ((~! row.of_list)) #/.Array))))) (do ! [.let [g!_ (code.local_identifier "_______") g!input (code.local_identifier "_______input")] @@ -171,28 +171,28 @@ (in (` (: (~ (@JSON\encoded inputT)) (function ((~ g!_) (~ g!input)) (case (~ g!input) - (~+ (list\join (list\map (function (_ [tag g!encoded]) - (if (n.= last tag) - (.list (` ((~ (code.nat (-- tag))) #1 (~ g!input))) - (` ((~! /.json) [(~ (code.frac (..tag (-- tag)))) - #1 - ((~ g!encoded) (~ g!input))]))) - (.list (` ((~ (code.nat tag)) #0 (~ g!input))) - (` ((~! /.json) [(~ (code.frac (..tag tag))) - #0 - ((~ g!encoded) (~ g!input))]))))) - (list.enumeration members)))))))))) + (~+ (list\conjoint (list\each (function (_ [tag g!encoded]) + (if (n.= last tag) + (.list (` ((~ (code.nat (-- tag))) #1 (~ g!input))) + (` ((~! /.json) [(~ (code.frac (..tag (-- tag)))) + #1 + ((~ g!encoded) (~ g!input))]))) + (.list (` ((~ (code.nat tag)) #0 (~ g!input))) + (` ((~! /.json) [(~ (code.frac (..tag tag))) + #0 + ((~ g!encoded) (~ g!input))]))))) + (list.enumeration members)))))))))) (do ! [g!encoders (<type>.tuple (<>.many encoded)) .let [g!_ (code.local_identifier "_______") g!members (|> (list.size g!encoders) list.indices - (list\map (|>> n\encoded code.local_identifier)))]] + (list\each (|>> n\encoded code.local_identifier)))]] (in (` (: (~ (@JSON\encoded inputT)) (function ((~ g!_) [(~+ g!members)]) - ((~! /.json) [(~+ (list\map (function (_ [g!member g!encoded]) - (` ((~ g!encoded) (~ g!member)))) - (list.zipped/2 g!members g!encoders)))])))))) + ((~! /.json) [(~+ (list\each (function (_ [g!member g!encoded]) + (` ((~ g!encoded) (~ g!member)))) + (list.zipped/2 g!members g!encoders)))])))))) ... Type recursion (do ! [[selfC non_recC] (<type>.recursive encoded) @@ -209,8 +209,8 @@ (do ! [[funcC varsC bodyC] (<type>.polymorphic encoded)] (in (` (: (All [(~+ varsC)] - (-> (~+ (list\map (function (_ varC) (` (-> (~ varC) /.JSON))) - varsC)) + (-> (~+ (list\each (function (_ varC) (` (-> (~ varC) /.JSON))) + varsC)) (-> ((~ (poly.code *env* inputT)) (~+ varsC)) /.JSON))) (function ((~ funcC) (~+ varsC)) @@ -282,17 +282,17 @@ .let [last (-- (list.size members))]] (in (` (: (~ (@JSON\decoded inputT)) ($_ ((~! <>.or)) - (~+ (list\map (function (_ [tag memberC]) - (if (n.= last tag) - (` (|> (~ memberC) - ((~! <>.after) ((~! </>.boolean!) (~ (code.bit #1)))) - ((~! <>.after) ((~! </>.number!) (~ (code.frac (..tag (-- tag)))))) - ((~! </>.array)))) - (` (|> (~ memberC) - ((~! <>.after) ((~! </>.boolean!) (~ (code.bit #0)))) - ((~! <>.after) ((~! </>.number!) (~ (code.frac (..tag tag))))) - ((~! </>.array)))))) - (list.enumeration members)))))))) + (~+ (list\each (function (_ [tag memberC]) + (if (n.= last tag) + (` (|> (~ memberC) + ((~! <>.after) ((~! </>.boolean!) (~ (code.bit #1)))) + ((~! <>.after) ((~! </>.number!) (~ (code.frac (..tag (-- tag)))))) + ((~! </>.array)))) + (` (|> (~ memberC) + ((~! <>.after) ((~! </>.boolean!) (~ (code.bit #0)))) + ((~! <>.after) ((~! </>.number!) (~ (code.frac (..tag tag))))) + ((~! </>.array)))))) + (list.enumeration members)))))))) (do ! [g!decoders (<type>.tuple (<>.many decoded))] (in (` (: (~ (@JSON\decoded inputT)) @@ -313,7 +313,7 @@ (do ! [[funcC varsC bodyC] (<type>.polymorphic decoded)] (in (` (: (All [(~+ varsC)] - (-> (~+ (list\map (|>> (~) </>.Parser (`)) varsC)) + (-> (~+ (list\each (|>> (~) </>.Parser (`)) varsC)) (</>.Parser ((~ (poly.code *env* inputT)) (~+ varsC))))) (function ((~ funcC) (~+ varsC)) (~ bodyC)))))) diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index 4dd110551..0637d36b8 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -68,7 +68,7 @@ (-> /.Profile (List (Repository Async))) (|>> (value@ #/.repositories) set.list - (list\map (|>> (/repository/remote.repository http.default #.None) /repository.async)))) + (list\each (|>> (/repository/remote.repository http.default #.None) /repository.async)))) (def: (with_dependencies program console command profile) (All [a] @@ -127,7 +127,7 @@ (program: [[profile operation] /cli.command] (do {! io.monad} [?console console.default] - (case (try\map console.async ?console) + (case (try\each console.async ?console) (#try.Failure error) (..fail! error) diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux index 6fd2d495f..8aca29ea0 100644 --- a/stdlib/source/program/aedifex/artifact.lux +++ b/stdlib/source/program/aedifex/artifact.lux @@ -101,8 +101,8 @@ (def: .public (local artifact) (-> Artifact (List Text)) - (list\compose (|> artifact - (value@ #group) - (text.all_split_by ..group_separator)) - (list (value@ #name artifact) - (value@ #version artifact)))) + (list\composite (|> artifact + (value@ #group) + (text.all_split_by ..group_separator)) + (list (value@ #name artifact) + (value@ #version artifact)))) diff --git a/stdlib/source/program/aedifex/artifact/versioning.lux b/stdlib/source/program/aedifex/artifact/versioning.lux index 9f9963731..886e89491 100644 --- a/stdlib/source/program/aedifex/artifact/versioning.lux +++ b/stdlib/source/program/aedifex/artifact/versioning.lux @@ -66,7 +66,7 @@ (list (//snapshot.format snapshot) (..last_updated_format last_updated) (|> versions - (list\map //snapshot/version.format) + (list\each //snapshot/version.format) (#xml.Node ..<snapshot_versions> xml.attributes))))) (def: (text tag) diff --git a/stdlib/source/program/aedifex/cli.lux b/stdlib/source/program/aedifex/cli.lux index 7f9fe61ff..87ad9938a 100644 --- a/stdlib/source/program/aedifex/cli.lux +++ b/stdlib/source/program/aedifex/cli.lux @@ -92,6 +92,6 @@ ($_ <>.and cli.any ..command')) - (\ <>.monad map (|>> [/.default]) + (\ <>.monad each (|>> [/.default]) ..command') )) diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 0a1998730..77a0c8714 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -30,10 +30,10 @@ (let [! async.monad] (|> path (\ fs sub_directories) - (\ ! map (|>> (try.else (list)) - (monad.map ! (targets fs)))) - (\ ! join) - (\ ! map (|>> list.together (list& path)))))) + (\ ! each (|>> (try.else (list)) + (monad.each ! (targets fs)))) + (\ ! conjoint) + (\ ! each (|>> list.together (list& path)))))) (def: .public delay Nat @@ -55,10 +55,10 @@ [targets (|> profile (value@ #///.sources) set.list - (monad.map ! (..targets fs)) - (\ ! map list.together))] + (monad.each ! (..targets fs)) + (\ ! each list.together))] (do {! ///action.monad} - [_ (monad.map ! (\ watcher start watch.modification) targets) + [_ (monad.each ! (\ watcher start watch.modification) targets) _ <call>] (loop [_ []] (do ! diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index d3c5b17a0..bf7c95870 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -123,7 +123,7 @@ (|>> dictionary.keys (list.only (|>> (value@ #///dependency.type) (text\= ///artifact/type.lux_library))) - (list\map (..path fs home)))) + (list\each (..path fs home)))) (def: version_separator ".") @@ -175,7 +175,7 @@ (: (Dictionary [Group Name] [Version Dependency]) (dictionary.empty (product.hash text.hash text.hash)))) dictionary.values - (list\map (|>> product.right (..path fs home))))) + (list\each (|>> product.right (..path fs home))))) (def: (singular name) (-> Text Text (List Text)) @@ -183,7 +183,7 @@ (def: (plural name) (-> Text (List Text) (List Text)) - (|>> (list\map (|>> (list name))) list.together)) + (|>> (list\each (|>> (list name))) list.together)) (def: .public start "[BUILD STARTED]") (def: .public success "[BUILD ENDED]") diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux index 9e55ccc83..5ff16928f 100644 --- a/stdlib/source/program/aedifex/command/clean.lux +++ b/stdlib/source/program/aedifex/command/clean.lux @@ -23,8 +23,8 @@ (let [! ///action.monad] (|> root (\ fs directory_files) - (\ ! map (monad.map ! (\ fs delete))) - (\ ! join)))) + (\ ! each (monad.each ! (\ fs delete))) + (\ ! conjoint)))) (def: .public success (-> ///.Target Text) @@ -42,8 +42,8 @@ [_ (..clean_files! fs root) _ (|> root (\ fs sub_directories) - (\ ! map (monad.map ! recur)) - (\ ! join))] + (\ ! each (monad.each ! recur)) + (\ ! conjoint))] (\ fs delete root))) (\ ! in [])))] (console.write_line (..success target) console))) diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux index 62ec8e985..fc0562699 100644 --- a/stdlib/source/program/aedifex/command/deploy.lux +++ b/stdlib/source/program/aedifex/command/deploy.lux @@ -63,7 +63,7 @@ (value@ #/.sources) set.list (export.library fs) - (\ ! map (binary.result tar.writer))) + (\ ! each (binary.result tar.writer))) pom (\ async.monad in (///pom.write profile)) _ (///dependency/deployment.one repository diff --git a/stdlib/source/program/aedifex/command/pom.lux b/stdlib/source/program/aedifex/command/pom.lux index c43982a98..9c449a0b9 100644 --- a/stdlib/source/program/aedifex/command/pom.lux +++ b/stdlib/source/program/aedifex/command/pom.lux @@ -29,8 +29,8 @@ (-> (Console Async) (file.System Async) (Command Any)) (do ///action.monad [content (|> (///pom.write profile) - (try\map (|>> (\ xml.codec encoded) - (\ utf8.codec encoded))) + (try\each (|>> (\ xml.codec encoded) + (\ utf8.codec encoded))) async\in) _ (\ fs write content ///pom.file)] (console.write_line ..success console))) diff --git a/stdlib/source/program/aedifex/dependency/deployment.lux b/stdlib/source/program/aedifex/dependency/deployment.lux index c637ae931..22788dc3d 100644 --- a/stdlib/source/program/aedifex/dependency/deployment.lux +++ b/stdlib/source/program/aedifex/dependency/deployment.lux @@ -111,8 +111,8 @@ #///artifact/snapshot/version/value.snapshot versioning_snapshot}) #///artifact/snapshot/version.updated now})) ... (with@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] - ... (list\compose (..artifacts type (product.right (value@ #///package.library package))) - ... (..artifacts ///artifact/type.pom (product.right (value@ #///package.pom package))))) + ... (list\composite (..artifacts type (product.right (value@ #///package.library package))) + ... (..artifacts ///artifact/type.pom (product.right (value@ #///package.pom package))))) )))) (def: .public (one repository [artifact type] package) @@ -144,6 +144,6 @@ (-> (Repository Async) Resolution (Async (Try (Set Artifact)))) (let [! (try.with async.monad)] (|> (dictionary.entries resolution) - (monad.map ! (function (_ [dependency package]) - (..one repository dependency package))) - (\ ! map (set.of_list ///artifact.hash))))) + (monad.each ! (function (_ [dependency package]) + (..one repository dependency package))) + (\ ! each (set.of_list ///artifact.hash))))) diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index 50415b61f..8de6d2423 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -84,10 +84,10 @@ (case ?actual (#try.Success actual) (in (do {! try.monad} - [output (\ ! map (for {@.old (|>> (:as java/lang/String) - java/lang/String::trim - (:as Text)) - @.jvm (|>> java/lang/String::trim)}) + [output (\ ! each (for {@.old (|>> (:as java/lang/String) + java/lang/String::trim + (:as Text)) + @.jvm (|>> java/lang/String::trim)}) (\ utf8.codec decoded actual)) actual (|> output (text.all_split_by " ") @@ -234,15 +234,15 @@ (do ! [.let [sub_dependencies (|> package ///package.dependencies - (try\map set.list) + (try\each set.list) (try.else (list))) ... For security reasons, it's not a good idea to allow dependencies to introduce repositories. ... package_repositories (|> package ... ///package.repositories - ... (try\map set.list) + ... (try\each set.list) ... (try.else (list)) - ... (list\map new_repository)) - ... sub_repositories (list\compose repositories package_repositories) + ... (list\each new_repository)) + ... sub_repositories (list\composite repositories package_repositories) sub_repositories repositories] [successes failures resolution] (recur sub_repositories (#.Item head successes) diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux index 74583c8f5..d36d597b3 100644 --- a/stdlib/source/program/aedifex/format.lux +++ b/stdlib/source/program/aedifex/format.lux @@ -59,8 +59,8 @@ (def: aggregate (Format Aggregate) (|>> dictionary.entries - (list\map (function (_ [key value]) - [(code.local_tag key) value])) + (list\each (function (_ [key value]) + [(code.local_tag key) value])) code.record)) (def: empty @@ -85,7 +85,7 @@ aggregate value - (dictionary.has field (` [(~+ (list\map format value))]) aggregate))) + (dictionary.has field (` [(~+ (list\each format value))]) aggregate))) (def: (on_set field value format aggregate) (All [a] @@ -100,8 +100,8 @@ (dictionary.has field (|> value dictionary.entries - (list\map (function (_ [key value]) - [(key_format key) (value_format value)])) + (list\each (function (_ [key value]) + [(key_format key) (value_format value)])) code.record) aggregate))) @@ -137,7 +137,7 @@ (def: (runtime [program parameters]) (Format Runtime) (` [(~ (code.text program)) - (~+ (list\map code.text parameters))])) + (~+ (list\each code.text parameters))])) (def: .public (profile value) (Format /.Profile) @@ -166,6 +166,6 @@ (def: .public project (Format Project) (|>> dictionary.entries - (list\map (function (_ [key value]) - [(code.text key) (..profile value)])) + (list\each (function (_ [key value]) + [(code.text key) (..profile value)])) code.record)) diff --git a/stdlib/source/program/aedifex/input.lux b/stdlib/source/program/aedifex/input.lux index b78e502a6..27591c709 100644 --- a/stdlib/source/program/aedifex/input.lux +++ b/stdlib/source/program/aedifex/input.lux @@ -50,7 +50,7 @@ (All [!] (-> (Monad !) (file.System !) Text (! (Try Profile)))) (|> //project.file (\ fs read) - (\ monad map (|>> (do> try.monad - [] - [..project_parser] - [(//project.profile profile)]))))) + (\ monad each (|>> (do> try.monad + [] + [..project_parser] + [(//project.profile profile)]))))) diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux index d8134515c..85fe747bd 100644 --- a/stdlib/source/program/aedifex/metadata/artifact.lux +++ b/stdlib/source/program/aedifex/metadata/artifact.lux @@ -93,7 +93,7 @@ (def: versions_format (-> (List Version) XML) - (|>> (list\map ..version_format) (#xml.Node ..<versions> xml.attributes))) + (|>> (list\each ..version_format) (#xml.Node ..<versions> xml.attributes))) (def: .public (format value) (-> Metadata XML) diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux index 3852f5fe1..3a3464cd6 100644 --- a/stdlib/source/program/aedifex/metadata/snapshot.lux +++ b/stdlib/source/program/aedifex/metadata/snapshot.lux @@ -94,7 +94,7 @@ #///artifact/snapshot/version.value version #///artifact/snapshot/version.updated ///artifact/time.epoch}] (|> (<xml>.somewhere ///artifact/versioning.parser) - (\ ! map + (\ ! each (revised@ #///artifact/versioning.versions (: (-> (List ///artifact/snapshot/version.Version) (List ///artifact/snapshot/version.Version)) diff --git a/stdlib/source/program/aedifex/package.lux b/stdlib/source/program/aedifex/package.lux index 7611cdac9..6a3a71f6d 100644 --- a/stdlib/source/program/aedifex/package.lux +++ b/stdlib/source/program/aedifex/package.lux @@ -65,7 +65,7 @@ product.left list (<xml>.result //pom.parser) - (try\map (value@ #/.dependencies)))) + (try\each (value@ #/.dependencies)))) (def: .public repositories (-> Package (Try (Set Address))) @@ -73,7 +73,7 @@ product.left list (<xml>.result //pom.parser) - (try\map (value@ #/.repositories)))) + (try\each (value@ #/.repositories)))) (def: .public equivalence (Equivalence Package) diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux index d5f4d3bb8..8ece73b51 100644 --- a/stdlib/source/program/aedifex/parser.lux +++ b/stdlib/source/program/aedifex/parser.lux @@ -82,7 +82,7 @@ (def: license (Parser /.License) (do {! <>.monad} - [input (\ ! map + [input (\ ! each (dictionary.of_list text.hash) (<code>.record (<>.some (<>.and <code>.local_tag <code>.any))))] @@ -97,7 +97,7 @@ (def: organization (Parser /.Organization) (do {! <>.monad} - [input (\ ! map + [input (\ ! each (dictionary.of_list text.hash) (<code>.record (<>.some (<>.and <code>.local_tag <code>.any))))] @@ -108,7 +108,7 @@ (def: developer (Parser /.Developer) (do {! <>.monad} - [input (\ ! map + [input (\ ! each (dictionary.of_list text.hash) (<code>.record (<>.some (<>.and <code>.local_tag <code>.any))))] @@ -125,7 +125,7 @@ (def: info (Parser /.Info) (do {! <>.monad} - [input (\ ! map + [input (\ ! each (dictionary.of_list text.hash) (<code>.record (<>.some (<>.and <code>.local_tag <code>.any))))] @@ -181,7 +181,7 @@ (def: profile (Parser /.Profile) (do {! <>.monad} - [input (\ ! map + [input (\ ! each (dictionary.of_list text.hash) (<code>.record (<>.some (<>.and <code>.local_tag <code>.any)))) @@ -196,19 +196,19 @@ (..singular input "info" ..info))) ^repositories (: (Parser (Set //repository.Address)) (|> (..plural input "repositories" ..repository) - (\ ! map (set.of_list text.hash)) + (\ ! each (set.of_list text.hash)) (<>.else (set.empty text.hash)) - (\ ! map (set.has /.default_repository)))) + (\ ! each (set.has /.default_repository)))) ^dependencies (: (Parser (Set //dependency.Dependency)) (|> (..plural input "dependencies" ..dependency) - (\ ! map (set.of_list //dependency.hash)) + (\ ! each (set.of_list //dependency.hash)) (<>.else (set.empty //dependency.hash)))) ^compiler (|> ..dependency (..singular input "compiler") (<>.else /.default_compiler)) ^sources (: (Parser (Set /.Source)) (|> (..plural input "sources" ..source) - (\ ! map (set.of_list text.hash)) + (\ ! each (set.of_list text.hash)) (<>.else (set.of_list text.hash (list /.default_source))))) ^target (: (Parser /.Target) (|> ..target @@ -221,7 +221,7 @@ (<>.maybe (..singular input "test" ..module))) ^deploy_repositories (: (Parser (Dictionary Text //repository.Address)) - (<| (\ ! map (dictionary.of_list text.hash)) + (<| (\ ! each (dictionary.of_list text.hash)) (<>.else (list)) (..singular input "deploy_repositories" ..deploy_repository))) ^java (|> ..runtime @@ -261,11 +261,11 @@ (def: .public project (Parser Project) (let [default_profile (: (Parser Project) - (\ <>.monad map + (\ <>.monad each (|>> [/.default] (list) (dictionary.of_list text.hash)) ..profile)) multi_profile (: (Parser Project) - (\ <>.monad map + (\ <>.monad each (dictionary.of_list text.hash) (<code>.record (<>.many (<>.and <code>.text ..profile)))))] diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index 7f9464e5c..a093a4091 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -85,8 +85,8 @@ (-> Dependency XML) (#_.Node ["" ..dependency_tag] _.attributes - (list\compose (..artifact (value@ #//dependency.artifact value)) - (list (..property "type" (value@ #//dependency.type value)))))) + (list\composite (..artifact (value@ #//dependency.artifact value)) + (list (..property "type" (value@ #//dependency.type value)))))) (def: (group tag) (-> Text (-> (List XML) XML)) @@ -114,7 +114,7 @@ (-> /.Developer (List XML)) (list& (..property "name" name) (..property "email" email) - (|> organization (maybe\map ..developer_organization) (maybe.else (list))))) + (|> organization (maybe\each ..developer_organization) (maybe.else (list))))) (template [<name> <type> <tag>] [(def: <name> @@ -127,14 +127,14 @@ (def: (info value) (-> /.Info (List XML)) - ($_ list\compose - (|> value (value@ #/.url) (maybe\map (..property ..url_tag)) maybe.list) - (|> value (value@ #/.description) (maybe\map (..property "description")) maybe.list) - (|> value (value@ #/.licenses) (list\map ..license) (..group "licenses") list) - (|> value (value@ #/.scm) (maybe\map ..scm) maybe.list) - (|> value (value@ #/.organization) (maybe\map ..organization) maybe.list) - (|> value (value@ #/.developers) (list\map ..developer) (..group "developers") list) - (|> value (value@ #/.contributors) (list\map ..contributor) (..group "contributors") list) + ($_ list\composite + (|> value (value@ #/.url) (maybe\each (..property ..url_tag)) maybe.list) + (|> value (value@ #/.description) (maybe\each (..property "description")) maybe.list) + (|> value (value@ #/.licenses) (list\each ..license) (..group "licenses") list) + (|> value (value@ #/.scm) (maybe\each ..scm) maybe.list) + (|> value (value@ #/.organization) (maybe\each ..organization) maybe.list) + (|> value (value@ #/.developers) (list\each ..developer) (..group "developers") list) + (|> value (value@ #/.contributors) (list\each ..contributor) (..group "contributors") list) )) ) @@ -144,11 +144,11 @@ (#.Some identity) (#try.Success (#_.Node ["" ..project_tag] _.attributes - ($_ list\compose + ($_ list\composite (list ..version) (..artifact identity) - (|> value (value@ #/.repositories) set.list (list\map ..repository) (..group "repositories") list) - (|> value (value@ #/.dependencies) set.list (list\map ..dependency) (..group ..dependencies_tag) list) + (|> value (value@ #/.repositories) set.list (list\each ..repository) (..group "repositories") list) + (|> value (value@ #/.dependencies) set.list (list\each ..dependency) (..group ..dependencies_tag) list) ))) _ @@ -159,13 +159,13 @@ (do {! <>.monad} [tag <xml>.tag] (<| (<xml>.node tag) - (\ ! map (|>> [tag])) + (\ ! each (|>> [tag])) <xml>.text))) (def: (dependency_parser own_version parent_version) (-> Text Text (Parser Dependency)) (do {! <>.monad} - [properties (\ ! map (dictionary.of_list name.hash) + [properties (\ ! each (dictionary.of_list name.hash) (<| (<xml>.node ["" ..dependency_tag]) (<>.some ..property_parser)))] (<| <>.lifted diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index f4a1f9a0d..264bc9015 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -228,14 +228,14 @@ #lua runtime.default_lua #ruby runtime.default_ruby}) - (def: (compose override baseline) + (def: (composite override baseline) (template.let [(!runtime <tag> <runtime>) [(if (runtime\= <runtime> (value@ <tag> override)) (value@ <tag> baseline) (value@ <tag> override))]] - {#parents (list\compose (value@ #parents baseline) (value@ #parents override)) - #identity (maybe\compose (value@ #identity override) (value@ #identity baseline)) - #info (maybe\compose (value@ #info override) (value@ #info baseline)) + {#parents (list\composite (value@ #parents baseline) (value@ #parents override)) + #identity (maybe\composite (value@ #identity override) (value@ #identity baseline)) + #info (maybe\composite (value@ #info override) (value@ #info baseline)) #repositories (set.union (value@ #repositories baseline) (value@ #repositories override)) #dependencies (set.union (value@ #dependencies baseline) (value@ #dependencies override)) #compiler (if (dependency\= ..default_compiler (value@ #compiler override)) @@ -245,8 +245,8 @@ #target (if (text\= ..default_target (value@ #target baseline)) (value@ #target override) (value@ #target baseline)) - #program (maybe\compose (value@ #program override) (value@ #program baseline)) - #test (maybe\compose (value@ #test override) (value@ #test baseline)) + #program (maybe\composite (value@ #program override) (value@ #program baseline)) + #test (maybe\composite (value@ #test override) (value@ #test baseline)) #deploy_repositories (dictionary.merged (value@ #deploy_repositories override) (value@ #deploy_repositories baseline)) #java (!runtime #java runtime.default_java) #js (!runtime #js runtime.default_js) diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux index 687fd215b..4f6da6d62 100644 --- a/stdlib/source/program/aedifex/project.lux +++ b/stdlib/source/program/aedifex/project.lux @@ -38,8 +38,8 @@ (def: identity (dictionary.empty text.hash)) - (def: compose - (dictionary.merged_with (\ //.monoid compose)))) + (def: composite + (dictionary.merged_with (\ //.monoid composite)))) (exception: .public (unknown_profile {name Name}) (exception.report @@ -61,10 +61,10 @@ #.None (do {! try.monad} - [parents (monad.map ! (profile' (set.has name lineage) project) - (value@ #//.parents profile))] + [parents (monad.each ! (profile' (set.has name lineage) project) + (value@ #//.parents profile))] (in (list\mix (function (_ parent child) - (\ //.monoid compose child parent)) + (\ //.monoid composite child parent)) (with@ #//.parents (list) profile) parents)))) diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index 11d29716e..d6cea3f06 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -68,7 +68,7 @@ http))] (case status (^ (static http/status.ok)) - (\ ! map product.right ((value@ #@http.body message) #.None)) + (\ ! each product.right ((value@ #@http.body message) #.None)) _ (do ! diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux index f029bed15..addfd4a52 100644 --- a/stdlib/source/program/aedifex/runtime.lux +++ b/stdlib/source/program/aedifex/runtime.lux @@ -42,5 +42,5 @@ (-> Runtime file.Path Runtime) (revised@ #parameters (function (_ parameters) - (list\compose parameters (list path))) + (list\composite parameters (list path))) runtime)) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index 184914216..637ed76e1 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -179,6 +179,6 @@ ... (do {! async.monad} ... [console (|> console.default ... async.future - ... (\ ! map (|>> try.trusted console.async)))] + ... (\ ! each (|>> try.trusted console.async)))] ... (interpreter.run! (try.with async.monad) console platform interpretation generation_bundle))) )))) diff --git a/stdlib/source/program/compositor/export.lux b/stdlib/source/program/compositor/export.lux index 309678908..a9c76f039 100644 --- a/stdlib/source/program/compositor/export.lux +++ b/stdlib/source/program/compositor/export.lux @@ -44,28 +44,28 @@ (do (try.with async.monad) [files (io.listing fs sources)] (|> (dictionary.entries files) - (monad.map try.monad - (function (_ [path source_code]) - (do try.monad - [path (|> path - (text.replaced (\ fs separator) .module_separator) - tar.path) - source_code (tar.content source_code)] - (in (#tar.Normal [path - (instant.of_millis +0) - ($_ tar.and - tar.read_by_owner tar.write_by_owner - tar.read_by_group tar.write_by_group - tar.read_by_other) - ..no_ownership - source_code]))))) - (\ try.monad map row.of_list) + (monad.each try.monad + (function (_ [path source_code]) + (do try.monad + [path (|> path + (text.replaced (\ fs separator) .module_separator) + tar.path) + source_code (tar.content source_code)] + (in (#tar.Normal [path + (instant.of_millis +0) + ($_ tar.and + tar.read_by_owner tar.write_by_owner + tar.read_by_group tar.write_by_group + tar.read_by_other) + ..no_ownership + source_code]))))) + (\ try.monad each row.of_list) (\ async.monad in)))) (def: .public (export fs [sources target]) (-> (file.System Async) Export (Async (Try Any))) (do {! (try.with async.monad)} - [tar (\ ! map (binary.result tar.writer) + [tar (\ ! each (binary.result tar.writer) (..library fs sources))] (|> ..file (format target (\ fs separator)) diff --git a/stdlib/source/program/compositor/import.lux b/stdlib/source/program/compositor/import.lux index 1950c4ebb..d05867201 100644 --- a/stdlib/source/program/compositor/import.lux +++ b/stdlib/source/program/compositor/import.lux @@ -47,25 +47,25 @@ (let [! async.monad] (|> library (\ system read) - (\ ! map (let [! try.monad] - (|>> (\ ! map (<binary>.result tar.parser)) - (\ ! join) - (\ ! map (|>> row.list - (monad.mix ! (function (_ entry import) - (case entry - (#tar.Normal [path instant mode ownership content]) - (let [path (tar.from_path path)] - (case (dictionary.has' path (tar.data content) import) - (#try.Failure error) - (exception.except ..duplicate [library path]) + (\ ! each (let [! try.monad] + (|>> (\ ! each (<binary>.result tar.parser)) + (\ ! conjoint) + (\ ! each (|>> row.list + (monad.mix ! (function (_ entry import) + (case entry + (#tar.Normal [path instant mode ownership content]) + (let [path (tar.from_path path)] + (case (dictionary.has' path (tar.data content) import) + (#try.Failure error) + (exception.except ..duplicate [library path]) - import' - import')) - - _ - (exception.except ..useless_tar_entry []))) - import))) - (\ ! join))))))) + import' + import')) + + _ + (exception.except ..useless_tar_entry []))) + import))) + (\ ! conjoint))))))) (def: .public (import system libraries) (-> (file.System Async) (List Library) (Action Import)) diff --git a/stdlib/source/program/scriptum.lux b/stdlib/source/program/scriptum.lux index e99367e91..6841682df 100644 --- a/stdlib/source/program/scriptum.lux +++ b/stdlib/source/program/scriptum.lux @@ -51,7 +51,7 @@ (def: type_var_names (Sequence Text) - (|> 0 (sequence.iterations ++) (sequence\map parameter_type_name))) + (|> 0 (sequence.iterations ++) (sequence\each parameter_type_name))) (template [<name> <partition>] [(def: (<name> id) @@ -88,13 +88,13 @@ (|> level -- (enum.range n.enum 0) - (list\map (|>> (n.+ (++ offset)) parameter_type_name))))) + (list\each (|>> (n.+ (++ offset)) parameter_type_name))))) (def: (prefix_lines prefix lines) (-> Text Text Text) (|> lines (text.all_split_by text.new_line) - (list\map (|>> (format prefix))) + (list\each (|>> (format prefix))) (text.interposed text.new_line))) (def: (pprint_type_definition level type_func_info tags module interface? recursive_type? type) @@ -113,7 +113,7 @@ (format "(primitive " (%.text name) ")") _ - (format "(primitive " (%.text name) " " (|> params (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) ")")) + (format "(primitive " (%.text name) " " (|> params (list\each (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) ")")) [_ (#.Sum _)] (let [members (type.flat_variant type)] @@ -121,40 +121,40 @@ #.End (format "(Or " (|> members - (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) + (list\each (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) ")") _ (|> members (list.zipped/2 tags) - (list\map (function (_ [[_ t_name] type]) - (case type - (#.Product _) - (let [types (type.flat_tuple type)] - (format "(#" t_name " " - (|> types - (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) - (text.interposed " ")) - ")")) - - _ - (format "(#" t_name " " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type) ")")))) + (list\each (function (_ [[_ t_name] type]) + (case type + (#.Product _) + (let [types (type.flat_tuple type)] + (format "(#" t_name " " + (|> types + (list\each (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) + (text.interposed " ")) + ")")) + + _ + (format "(#" t_name " " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type) ")")))) (text.interposed text.new_line)))) [_ (#.Product _)] (let [members (type.flat_tuple type)] (case tags #.End - (format "[" (|> members (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) "]") + (format "[" (|> members (list\each (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) "]") _ (let [member_docs (|> members (list.zipped/2 tags) - (list\map (function (_ [[_ t_name] type]) - (if interface? - (format "(: " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type) text.new_line " " t_name ")") - (format "#" t_name " " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type))))) + (list\each (function (_ [[_ t_name] type]) + (if interface? + (format "(: " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type) text.new_line " " t_name ")") + (format "#" t_name " " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type))))) (text.interposed (format text.new_line " ")))] (if interface? member_docs @@ -162,7 +162,7 @@ [_ (#.Function input output)] (let [[ins out] (type.flat_function type)] - (format "(-> " (|> ins (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) + (format "(-> " (|> ins (list\each (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) " " (pprint_type_definition level type_func_info #.None module interface? recursive_type? out) ")")) @@ -197,7 +197,7 @@ [_ (#.Apply param fun)] (let [[type_func type_arguments] (type.flat_application type)] - (format "(" (pprint_type_definition level type_func_info tags module interface? recursive_type? type_func) " " (|> type_arguments (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) ")")) + (format "(" (pprint_type_definition level type_func_info tags module interface? recursive_type? type_func) " " (|> type_arguments (list\each (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) ")")) [_ (#.Named [_module _name] type)] (if (text\= module _module) @@ -214,20 +214,20 @@ (format "(primitive " (%.text name) ")") _ - (format "(primitive " (%.text name) " " (|> params (list\map (pprint_type level type_func_name module)) (text.interposed " ")) ")")) + (format "(primitive " (%.text name) " " (|> params (list\each (pprint_type level type_func_name module)) (text.interposed " ")) ")")) (#.Sum _) (let [members (type.flat_variant type)] - (format "(Or " (|> members (list\map (pprint_type level type_func_name module)) (text.interposed " ")) ")")) + (format "(Or " (|> members (list\each (pprint_type level type_func_name module)) (text.interposed " ")) ")")) (#.Product _) (let [members (type.flat_tuple type)] - (format "[" (|> members (list\map (pprint_type level type_func_name module)) (text.interposed " ")) "]")) + (format "[" (|> members (list\each (pprint_type level type_func_name module)) (text.interposed " ")) "]")) (#.Function input output) (let [[ins out] (type.flat_function type)] (format "(-> " - (|> ins (list\map (pprint_type level type_func_name module)) (text.interposed " ")) + (|> ins (list\each (pprint_type level type_func_name module)) (text.interposed " ")) " " (pprint_type level type_func_name module out) ")")) @@ -254,7 +254,7 @@ (#.Apply param fun) (let [[type_func type_arguments] (type.flat_application type)] - (format "(" (pprint_type level type_func_name module type_func) " " (|> type_arguments (list\map (pprint_type level type_func_name module)) (text.interposed " ")) ")")) + (format "(" (pprint_type level type_func_name module type_func) " " (|> type_arguments (list\each (pprint_type level type_func_name module)) (text.interposed " ")) ")")) (#.Named [_module _name] type) (if (text\= module _module) @@ -373,7 +373,7 @@ (when> [(new> recursive_type? [])] [unrecurse_type]) (pprint_type_definition (-- nesting) [_name type_arguments] (maybe.else (list) tags) module interface? recursive_type?) (text.all_split_by text.new_line) - (list\map (|>> (format " "))) + (list\each (|>> (format " "))) (text.interposed text.new_line)) ")")))) @@ -383,22 +383,22 @@ (def: (document_types module types) (-> Text (List Value) (Meta (Markdown Block))) (do {! meta.monad} - [type_docs (monad.map ! - (: (-> Value (Meta (Markdown Block))) - (function (_ [name def_annotations type]) - (do meta.monad - [.let [?doc (annotation.documentation def_annotations)] - type_code (document_type module type def_annotations)] - (in ($_ md.then - (md.heading/3 name) - (case ?doc - (#.Some doc) - (md.paragraph (md.text doc)) - - _ - md.empty) - type_code))))) - types)] + [type_docs (monad.each ! + (: (-> Value (Meta (Markdown Block))) + (function (_ [name def_annotations type]) + (do meta.monad + [.let [?doc (annotation.documentation def_annotations)] + type_code (document_type module type def_annotations)] + (in ($_ md.then + (md.heading/3 name) + (case ?doc + (#.Some doc) + (md.paragraph (md.text doc)) + + _ + md.empty) + type_code))))) + types)] (in (list\mix (function.flipped md.then) (md.heading/2 "Types") type_docs)))) @@ -406,15 +406,15 @@ (def: (document_macros module_name names) (-> Text (List [Text Code]) (Markdown Block)) (|> names - (list\map (: (-> [Text Code] (Markdown Block)) - (function (_ [name def_annotations]) - ($_ md.then - (md.heading/3 name) - (<| (: (Markdown Block)) - (maybe.else md.empty) - (do maybe.monad - [documentation (annotation.documentation def_annotations)] - (in (md.code documentation)))))))) + (list\each (: (-> [Text Code] (Markdown Block)) + (function (_ [name def_annotations]) + ($_ md.then + (md.heading/3 name) + (<| (: (Markdown Block)) + (maybe.else md.empty) + (do maybe.monad + [documentation (annotation.documentation def_annotations)] + (in (md.code documentation)))))))) (list\mix (function.flipped md.then) (md.heading/2 "Macros")))) @@ -426,23 +426,23 @@ (def: (<plural> module values) (-> Text (List Value) (Markdown Block)) (|> values - (list\map (function (_ [name def_annotations value_type]) - (let [?doc (annotation.documentation def_annotations) - usage (case (annotation.function_arguments def_annotations) - #.End - name - - args - (format "(" (text.interposed " " (list& name args)) ")"))] - ($_ md.then - (md.heading/3 usage) - (case ?doc - (#.Some doc) - (md.code doc) - - _ - md.empty) - (<singular> module value_type))))) + (list\each (function (_ [name def_annotations value_type]) + (let [?doc (annotation.documentation def_annotations) + usage (case (annotation.function_arguments def_annotations) + #.End + name + + args + (format "(" (text.interposed " " (list& name args)) ")"))] + ($_ md.then + (md.heading/3 usage) + (case ?doc + (#.Some doc) + (md.code doc) + + _ + md.empty) + (<singular> module value_type))))) (list\mix (function.flipped md.then) (md.heading/2 <header>))))] @@ -454,7 +454,7 @@ (-> [Text Text] Text Text) (|> block (text.all_split_by text.new_line) - (list\map (text.enclosed pre+post)) + (list\each (text.enclosed pre+post)) (text.interposed text.new_line))) (def: (document_module [[module_name module] organization]) @@ -507,12 +507,12 @@ .let [lux_modules (|> all_modules (list.only (function.composite lux_module? product.left)) (list.sorted name_sort))] - lux_exports (monad.map ! (function.composite meta.exports product.left) - lux_modules) - module_documentation (|> (list\map organize_definitions lux_exports) + lux_exports (monad.each ! (function.composite meta.exports product.left) + lux_modules) + module_documentation (|> (list\each organize_definitions lux_exports) (list.zipped/2 lux_modules) - (monad.map ! document_module)) - .let [_ (io.run! (monad.map io.monad save_documentation! module_documentation))]] + (monad.each ! document_module)) + .let [_ (io.run! (monad.each io.monad save_documentation! module_documentation))]] (in (list)))) (gen_documentation!) diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux index 87fc1a5fc..3bfcec4e8 100644 --- a/stdlib/source/specification/compositor/generation/case.lux +++ b/stdlib/source/specification/compositor/generation/case.lux @@ -32,7 +32,7 @@ (def: size (Random Nat) - (|> r.nat (\ r.monad map (|>> (n.% ..limit) (n.max 2))))) + (|> r.nat (\ r.monad each (|>> (n.% ..limit) (n.max 2))))) (def: (tail? size idx) (-> Nat Nat Bit) @@ -66,7 +66,7 @@ [(r.unicode 5) synthesis.text synthesis.path/text])) (do {! r.monad} [size ..size - idx (|> r.nat (\ ! map (n.% size))) + idx (|> r.nat (\ ! each (n.% size))) [subS subP] case .let [unitS (synthesis.text synthesis.unit) caseS (synthesis.tuple @@ -81,7 +81,7 @@ (in [caseS caseP])) (do {! r.monad} [size ..size - idx (|> r.nat (\ ! map (n.% size))) + idx (|> r.nat (\ ! each (n.% size))) [subS subP] case .let [right? (tail? size idx) caseS (synthesis.variant diff --git a/stdlib/source/specification/compositor/generation/common.lux b/stdlib/source/specification/compositor/generation/common.lux index 6387b3013..729ce81f4 100644 --- a/stdlib/source/specification/compositor/generation/common.lux +++ b/stdlib/source/specification/compositor/generation/common.lux @@ -118,7 +118,7 @@ (def: simple_frac (Random Frac) - (|> r.nat (\ r.monad map (|>> (n.% 1000) .int i.frac)))) + (|> r.nat (\ r.monad each (|>> (n.% 1000) .int i.frac)))) (def: (f64 run) (-> Runner Test) @@ -175,12 +175,12 @@ (def: (text run) (-> Runner Test) (do {! r.monad} - [sample_size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + [sample_size (|> r.nat (\ ! each (|>> (n.% 10) (n.max 1)))) sample_lower (r.ascii/lower_alpha sample_size) sample_upper (r.ascii/upper_alpha sample_size) sample_alpha (|> (r.ascii/alpha sample_size) (r.only (|>> (text\= sample_upper) not))) - char_idx (|> r.nat (\ ! map (n.% sample_size))) + char_idx (|> r.nat (\ ! each (n.% sample_size))) .let [sample_lowerS (synthesis.text sample_lower) sample_upperS (synthesis.text sample_upper) sample_alphaS (synthesis.text sample_alpha) diff --git a/stdlib/source/specification/compositor/generation/function.lux b/stdlib/source/specification/compositor/generation/function.lux index 8a090094f..36b45c283 100644 --- a/stdlib/source/specification/compositor/generation/function.lux +++ b/stdlib/source/specification/compositor/generation/function.lux @@ -30,11 +30,11 @@ (def: arity (Random Arity) - (|> r.nat (r\map (|>> (n.% max_arity) (n.max 1))))) + (|> r.nat (r\each (|>> (n.% max_arity) (n.max 1))))) (def: (local arity) (-> Arity (Random Register)) - (|> r.nat (r\map (|>> (n.% arity) ++)))) + (|> r.nat (r\each (|>> (n.% arity) ++)))) (def: function (Random [Arity Register Synthesis]) @@ -51,10 +51,10 @@ (-> Runner Test) (do {! r.monad} [[arity local functionS] ..function - partial_arity (|> r.nat (\ ! map (|>> (n.% arity) (n.max 1)))) + partial_arity (|> r.nat (\ ! each (|>> (n.% arity) (n.max 1)))) inputs (r.list arity r.safe_frac) .let [expectation (maybe.trusted (list.item (-- local) inputs)) - inputsS (list\map (|>> synthesis.f64) inputs)]] + inputsS (list\each (|>> synthesis.f64) inputs)]] ($_ _.and (_.test "Can read arguments." (|> (synthesis.function/apply {#synthesis.function functionS @@ -75,7 +75,7 @@ (or (n.= 1 arity) (let [environment (|> partial_arity (enum.range n.enum 1) - (list\map (|>> #reference.Local))) + (list\each (|>> #reference.Local))) variableS (if (n.<= partial_arity local) (synthesis.variable/foreign (-- local)) (synthesis.variable/local (|> local (n.- partial_arity)))) diff --git a/stdlib/source/specification/compositor/generation/reference.lux b/stdlib/source/specification/compositor/generation/reference.lux index 02338e915..ee9da7455 100644 --- a/stdlib/source/specification/compositor/generation/reference.lux +++ b/stdlib/source/specification/compositor/generation/reference.lux @@ -40,7 +40,7 @@ (def: (variable run) (-> Runner Test) (do {! r.monad} - [register (|> r.nat (\ ! map (n.% 100))) + [register (|> r.nat (\ ! each (n.% 100))) expected r.safe_frac] (_.test "Local variables." (|> (synthesis.branch/let [(synthesis.f64 expected) diff --git a/stdlib/source/specification/compositor/generation/structure.lux b/stdlib/source/specification/compositor/generation/structure.lux index de61ed882..ec9893e7c 100644 --- a/stdlib/source/specification/compositor/generation/structure.lux +++ b/stdlib/source/specification/compositor/generation/structure.lux @@ -31,8 +31,8 @@ (def: (variant run) (-> Runner Test) (do {! r.monad} - [num_tags (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) - tag_in (|> r.nat (\ ! map (n.% num_tags))) + [num_tags (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) + tag_in (|> r.nat (\ ! each (n.% num_tags))) .let [last?_in (|> num_tags -- (n.= tag_in))] value_in r.i64] (_.test (%.name (name_of synthesis.variant)) @@ -66,10 +66,10 @@ (def: (tuple run) (-> Runner Test) (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) + [size (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) tuple_in (r.list size r.i64)] (_.test (%.name (name_of synthesis.tuple)) - (|> (synthesis.tuple (list\map (|>> synthesis.i64) tuple_in)) + (|> (synthesis.tuple (list\each (|>> synthesis.i64) tuple_in)) (run "tuple") (case> (#try.Success tuple_out) (let [tuple_out (:as (Array Any) tuple_out)] diff --git a/stdlib/source/specification/lux/abstract/apply.lux b/stdlib/source/specification/lux/abstract/apply.lux index e857c81e5..1e2c7b676 100644 --- a/stdlib/source/specification/lux/abstract/apply.lux +++ b/stdlib/source/specification/lux/abstract/apply.lux @@ -18,7 +18,7 @@ (def: (identity injection comparison (^open "\.")) (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) (do {! random.monad} - [sample (\ ! map injection random.nat)] + [sample (\ ! each injection random.nat)] (_.test "Identity." ((comparison n.=) (\on sample (injection function.identity)) @@ -28,7 +28,7 @@ (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) (do {! random.monad} [sample random.nat - increase (\ ! map n.+ random.nat)] + increase (\ ! each n.+ random.nat)] (_.test "Homomorphism." ((comparison n.=) (\on (injection sample) (injection increase)) @@ -38,7 +38,7 @@ (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) (do {! random.monad} [sample random.nat - increase (\ ! map n.+ random.nat)] + increase (\ ! each n.+ random.nat)] (_.test "Interchange." ((comparison n.=) (\on (injection sample) (injection increase)) @@ -49,8 +49,8 @@ (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) (do {! random.monad} [sample random.nat - increase (\ ! map n.+ random.nat) - decrease (\ ! map n.- random.nat)] + increase (\ ! each n.+ random.nat) + decrease (\ ! each n.- random.nat)] (_.test "Composition." ((comparison n.=) (|> (injection function.composite) diff --git a/stdlib/source/specification/lux/abstract/comonad.lux b/stdlib/source/specification/lux/abstract/comonad.lux index b1fca7ab7..785cc06fd 100644 --- a/stdlib/source/specification/lux/abstract/comonad.lux +++ b/stdlib/source/specification/lux/abstract/comonad.lux @@ -17,13 +17,13 @@ (All [f] (-> (Injection f) (CoMonad f) Test)) (do {! random.monad} [sample random.nat - morphism (\ ! map (function (_ diff) - (|>> _//out (n.+ diff))) + morphism (\ ! each (function (_ diff) + (|>> _//out (n.+ diff))) random.nat) .let [start (injection sample)]] (_.test "Left identity." (n.= (morphism start) - (|> start _//split (_//map morphism) _//out))))) + (|> start _//disjoint (_//each morphism) _//out))))) (def: (right_identity injection comparison (^open "_//.")) (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) @@ -33,23 +33,23 @@ == (comparison n.=)]] (_.test "Right identity." (== start - (|> start _//split (_//map _//out)))))) + (|> start _//disjoint (_//each _//out)))))) (def: (associativity injection comparison (^open "_//.")) (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) (do {! random.monad} [sample random.nat - increase (\ ! map (function (_ diff) - (|>> _//out (n.+ diff))) + increase (\ ! each (function (_ diff) + (|>> _//out (n.+ diff))) random.nat) - decrease (\ ! map (function (_ diff) - (|>> _//out(n.- diff))) + decrease (\ ! each (function (_ diff) + (|>> _//out(n.- diff))) random.nat) .let [start (injection sample) == (comparison n.=)]] (_.test "Associativity." - (== (|> start _//split (_//map (|>> _//split (_//map increase) decrease))) - (|> start _//split (_//map increase) _//split (_//map decrease)))))) + (== (|> start _//disjoint (_//each (|>> _//disjoint (_//each increase) decrease))) + (|> start _//disjoint (_//each increase) _//disjoint (_//each decrease)))))) (def: .public (spec injection comparison subject) (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) diff --git a/stdlib/source/specification/lux/abstract/functor.lux b/stdlib/source/specification/lux/abstract/functor.lux index d60555ae0..33c6506c5 100644 --- a/stdlib/source/specification/lux/abstract/functor.lux +++ b/stdlib/source/specification/lux/abstract/functor.lux @@ -25,32 +25,32 @@ (def: (identity injection comparison (^open "@//.")) (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) (do {! random.monad} - [sample (\ ! map injection random.nat)] + [sample (\ ! each injection random.nat)] (_.test "Identity." ((comparison n.=) - (@//map function.identity sample) + (@//each function.identity sample) sample)))) (def: (homomorphism injection comparison (^open "@//.")) (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) (do {! random.monad} [sample random.nat - increase (\ ! map n.+ random.nat)] + increase (\ ! each n.+ random.nat)] (_.test "Homomorphism." ((comparison n.=) - (@//map increase (injection sample)) + (@//each increase (injection sample)) (injection (increase sample)))))) (def: (composition injection comparison (^open "@//.")) (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) (do {! random.monad} - [sample (\ ! map injection random.nat) - increase (\ ! map n.+ random.nat) - decrease (\ ! map n.- random.nat)] + [sample (\ ! each injection random.nat) + increase (\ ! each n.+ random.nat) + decrease (\ ! each n.- random.nat)] (_.test "Composition." ((comparison n.=) - (|> sample (@//map increase) (@//map decrease)) - (|> sample (@//map (|>> increase decrease))))))) + (|> sample (@//each increase) (@//each decrease)) + (|> sample (@//each (|>> increase decrease))))))) (def: .public (spec injection comparison functor) (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) diff --git a/stdlib/source/specification/lux/abstract/functor/contravariant.lux b/stdlib/source/specification/lux/abstract/functor/contravariant.lux index 719398e71..9e50001c5 100644 --- a/stdlib/source/specification/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/specification/lux/abstract/functor/contravariant.lux @@ -18,7 +18,7 @@ (All [f a] (-> (Equivalence (f a)) (f a) (Functor f) Test)) (_.test "Law of identity." (equivalence - (@//map function.identity value) + (@//each function.identity value) value))) (def: .public (spec equivalence value functor) diff --git a/stdlib/source/specification/lux/abstract/monad.lux b/stdlib/source/specification/lux/abstract/monad.lux index 01395330f..2e538db50 100644 --- a/stdlib/source/specification/lux/abstract/monad.lux +++ b/stdlib/source/specification/lux/abstract/monad.lux @@ -15,12 +15,12 @@ (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) (do {! random.monad} [sample random.nat - morphism (\ ! map (function (_ diff) - (|>> (n.+ diff) _//in)) + morphism (\ ! each (function (_ diff) + (|>> (n.+ diff) _//in)) random.nat)] (_.test "Left identity." ((comparison n.=) - (|> (injection sample) (_//map morphism) _//join) + (|> (injection sample) (_//each morphism) _//conjoint) (morphism sample))))) (def: (right_identity injection comparison (^open "_//.")) @@ -29,23 +29,23 @@ [sample random.nat] (_.test "Right identity." ((comparison n.=) - (|> (injection sample) (_//map _//in) _//join) + (|> (injection sample) (_//each _//in) _//conjoint) (injection sample))))) (def: (associativity injection comparison (^open "_//.")) (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) (do {! random.monad} [sample random.nat - increase (\ ! map (function (_ diff) - (|>> (n.+ diff) _//in)) + increase (\ ! each (function (_ diff) + (|>> (n.+ diff) _//in)) random.nat) - decrease (\ ! map (function (_ diff) - (|>> (n.- diff) _//in)) + decrease (\ ! each (function (_ diff) + (|>> (n.- diff) _//in)) random.nat)] (_.test "Associativity." ((comparison n.=) - (|> (injection sample) (_//map increase) _//join (_//map decrease) _//join) - (|> (injection sample) (_//map (|>> increase (_//map decrease) _//join)) _//join))))) + (|> (injection sample) (_//each increase) _//conjoint (_//each decrease) _//conjoint) + (|> (injection sample) (_//each (|>> increase (_//each decrease) _//conjoint)) _//conjoint))))) (def: .public (spec injection comparison monad) (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) diff --git a/stdlib/source/specification/lux/abstract/monoid.lux b/stdlib/source/specification/lux/abstract/monoid.lux index c8e4e4e6e..a9ce67fd2 100644 --- a/stdlib/source/specification/lux/abstract/monoid.lux +++ b/stdlib/source/specification/lux/abstract/monoid.lux @@ -22,11 +22,11 @@ ($_ _.and (_.test "Left identity." (\= sample - (\compose \identity sample))) + (\composite \identity sample))) (_.test "Right identity." (\= sample - (\compose sample \identity))) + (\composite sample \identity))) (_.test "Associativity." - (\= (\compose left (\compose mid right)) - (\compose (\compose left mid) right))) + (\= (\composite left (\composite mid right)) + (\composite (\composite left mid) right))) )))) diff --git a/stdlib/source/specification/lux/world/file.lux b/stdlib/source/specification/lux/world/file.lux index 504990ea4..8a618c3ae 100644 --- a/stdlib/source/specification/lux/world/file.lux +++ b/stdlib/source/specification/lux/world/file.lux @@ -48,7 +48,7 @@ (_.cover' [/.parent] (|> (/.rooted fs parent child) (/.parent fs) - (maybe\map (text\= parent)) + (maybe\each (text\= parent)) (maybe.else false))) (_.cover' [/.name] (|> (/.rooted fs parent child) @@ -91,18 +91,18 @@ (in (<| (try.else false) (do {! try.monad} [pre_file_size! - (\ ! map (n.= expected_file_size) pre_file_size) + (\ ! each (n.= expected_file_size) pre_file_size) pre_content! - (\ ! map (binary\= content) pre_content) + (\ ! each (binary\= content) pre_content) _ appended? post_file_size! - (\ ! map (n.= (n.* 2 expected_file_size)) post_file_size) + (\ ! each (n.= (n.* 2 expected_file_size)) post_file_size) post_content! - (\ ! map (binary\= (binary\compose content appendix)) post_content)] + (\ ! each (binary\= (binary\composite content appendix)) post_content)] (in (and pre_file_size! pre_content! post_file_size! @@ -116,7 +116,7 @@ (in (<| (try.else false) (do {! try.monad} [_ modified?] - (\ ! map (instant\= expected_time) last_modified)))))) + (\ ! each (instant\= expected_time) last_modified)))))) (def: (directory_files&sub_directories fs parent sub_dir child) (-> (/.System Async) /.Path /.Path /.Path (Async Bit)) @@ -131,10 +131,10 @@ (do try.monad [_ made_sub?] (in (and (|> directory_files - (try\map (list\= (list child))) + (try\each (list\= (list child))) (try.else false)) (|> sub_directories - (try\map (list\= (list sub_dir))) + (try\each (list\= (list sub_dir))) (try.else false)))))))))) (def: (move&delete fs parent child alternate_child) @@ -145,7 +145,7 @@ [moved? (\ fs move destination origin) lost? (|> origin (\ fs file?) - (\ ! map not)) + (\ ! each not)) found? (\ fs file? destination) deleted? (\ fs delete destination)] (in (<| (try.else false) @@ -166,7 +166,7 @@ (|>> (text\= child) not) (|>> (text\= sub_dir) not)) (random.ascii/numeric 2)) - expected_file_size (\ ! map (|>> (n.% 10) ++) random.nat) + expected_file_size (\ ! each (|>> (n.% 10) ++) random.nat) content ($binary.random expected_file_size) appendix ($binary.random expected_file_size) expected_time random.instant]) @@ -190,7 +190,7 @@ can_execute? (|> path (\ fs can_execute?) - (\ ! map (|>> (try.else true) not))) + (\ ! each (|>> (try.else true) not))) directory_files&sub_directories (..directory_files&sub_directories fs parent sub_dir child) diff --git a/stdlib/source/specification/lux/world/shell.lux b/stdlib/source/specification/lux/world/shell.lux index 6817d14be..cedfd317b 100644 --- a/stdlib/source/specification/lux/world/shell.lux +++ b/stdlib/source/specification/lux/world/shell.lux @@ -36,16 +36,16 @@ (def: (can_wait! process) (-> (/.Process Async) _.Assertion) (|> (\ process await []) - (async\map (|>> (try\map (i.= /.normal)) - (try.else false) - (_.cover' [/.Exit /.normal]))) - async\join)) + (async\each (|>> (try\each (i.= /.normal)) + (try.else false) + (_.cover' [/.Exit /.normal]))) + async\conjoint)) (def: (can_read! expected process) (-> Text (/.Process Async) (Async Bit)) (|> (\ process read []) - (async\map (|>> (try\map (text\= expected)) - (try.else false))))) + (async\each (|>> (try\each (text\= expected)) + (try.else false))))) (def: (can_destroy! process) (-> (/.Process Async) (Async Bit)) @@ -71,7 +71,7 @@ (<| (_.for [/.Shell /.Process]) (do {! random.monad} [message (random.ascii/alpha 10) - seconds (\ ! map (|>> (n.% 5) (n.+ 5)) random.nat)] + seconds (\ ! each (|>> (n.% 5) (n.+ 5)) random.nat)] (in (do {! async.monad} [?echo (\ shell execute (..echo! message)) ?sleep (\ shell execute (..sleep! seconds))] diff --git a/stdlib/source/test/aedifex/artifact/snapshot.lux b/stdlib/source/test/aedifex/artifact/snapshot.lux index c4ebdfc66..40fc5e137 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot.lux @@ -40,7 +40,7 @@ /.format list (<xml>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) $/build.test diff --git a/stdlib/source/test/aedifex/artifact/snapshot/build.lux b/stdlib/source/test/aedifex/artifact/snapshot/build.lux index d207053c9..ab169fe29 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/build.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/build.lux @@ -34,6 +34,6 @@ /.format list (<xml>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) )))) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux index ed77767cb..e1903c937 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux @@ -41,6 +41,6 @@ (|> expected /.format (<xml>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) ))) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/time.lux b/stdlib/source/test/aedifex/artifact/snapshot/time.lux index 7f33a9e86..22436060e 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/time.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/time.lux @@ -36,7 +36,7 @@ (|> expected /.format (<text>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))) )) ))) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version.lux b/stdlib/source/test/aedifex/artifact/snapshot/version.lux index 3976d7054..f027e0e46 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/version.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/version.lux @@ -43,7 +43,7 @@ /.format list (<xml>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) /value.test diff --git a/stdlib/source/test/aedifex/artifact/time.lux b/stdlib/source/test/aedifex/artifact/time.lux index 8270969fd..c4f74df92 100644 --- a/stdlib/source/test/aedifex/artifact/time.lux +++ b/stdlib/source/test/aedifex/artifact/time.lux @@ -43,7 +43,7 @@ (|> expected /.format (<text>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) (do random.monad [expected ..random] @@ -51,7 +51,7 @@ (|> expected /.instant /.of_instant - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) (_.cover [/.epoch] (instant\= instant.epoch (/.instant /.epoch))) diff --git a/stdlib/source/test/aedifex/artifact/time/date.lux b/stdlib/source/test/aedifex/artifact/time/date.lux index c67ade3ec..15eb29aba 100644 --- a/stdlib/source/test/aedifex/artifact/time/date.lux +++ b/stdlib/source/test/aedifex/artifact/time/date.lux @@ -49,13 +49,13 @@ (|> expected /.format (<text>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))) (_.cover [/.value /.date] (|> expected /.value /.date - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))) (_.cover [/.year_is_out_of_range] (case (/.date candidate) diff --git a/stdlib/source/test/aedifex/artifact/time/time.lux b/stdlib/source/test/aedifex/artifact/time/time.lux index 1f5e4c6e7..7e8317b78 100644 --- a/stdlib/source/test/aedifex/artifact/time/time.lux +++ b/stdlib/source/test/aedifex/artifact/time/time.lux @@ -33,6 +33,6 @@ (|> expected /.format (<text>.result /.parser) - (try\map (\ time.equivalence = expected)) + (try\each (\ time.equivalence = expected)) (try.else false)))) ))) diff --git a/stdlib/source/test/aedifex/artifact/versioning.lux b/stdlib/source/test/aedifex/artifact/versioning.lux index aa90619cb..95019139f 100644 --- a/stdlib/source/test/aedifex/artifact/versioning.lux +++ b/stdlib/source/test/aedifex/artifact/versioning.lux @@ -42,13 +42,13 @@ /.format list (<xml>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) (_.cover [/.init] (|> /.init /.format list (<xml>.result /.parser) - (try\map (\ /.equivalence = /.init)) + (try\each (\ /.equivalence = /.init)) (try.else false))) ))) diff --git a/stdlib/source/test/aedifex/cache.lux b/stdlib/source/test/aedifex/cache.lux index 91870d680..143766eb6 100644 --- a/stdlib/source/test/aedifex/cache.lux +++ b/stdlib/source/test/aedifex/cache.lux @@ -64,7 +64,7 @@ (def: content (Random Binary) (do {! random.monad} - [content_size (\ ! map (n.% 100) random.nat)] + [content_size (\ ! each (n.% 100) random.nat)] (_binary.random content_size))) (def: package @@ -82,20 +82,20 @@ (do {! random.monad} [[main_dependency main_package] ..package dependencies (|> (//package.dependencies main_package) - (\ try.monad map set.list) + (\ try.monad each set.list) (try.else (list)) - (monad.map ! (function (_ dependency) - (do ! - [pom (random.one (function (_ [identity profile pom]) - (|> profile - (with@ #//.dependencies (set.empty //dependency.hash)) - (with@ #//.identity (#.Some (value@ #//dependency.artifact dependency))) - //pom.write - try.maybe)) - ..profile) - content ..content] - (in [dependency - (with@ #//package.origin (#//repository/origin.Remote "") (//package.local pom content))])))))] + (monad.each ! (function (_ dependency) + (do ! + [pom (random.one (function (_ [identity profile pom]) + (|> profile + (with@ #//.dependencies (set.empty //dependency.hash)) + (with@ #//.identity (#.Some (value@ #//dependency.artifact dependency))) + //pom.write + try.maybe)) + ..profile) + content ..content] + (in [dependency + (with@ #//package.origin (#//repository/origin.Remote "") (//package.local pom content))])))))] (in (dictionary.of_list //dependency.hash (list& [main_dependency main_package] dependencies))))) (def: singular @@ -137,7 +137,7 @@ [_ wrote! actual read!] (in (\ //dependency/resolution.equivalence = - (\ dictionary.functor map + (\ dictionary.functor each (with@ #//package.origin (#//repository/origin.Local "")) expected) actual))))))))) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 1ed19ddf7..91506ca06 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -89,8 +89,8 @@ home (random.ascii/alpha 5) working_directory (random.ascii/alpha 5) - expected_runs (\ ! map (|>> (n.% 10) (n.max 2)) random.nat) - dummy_path (\ ! map (|>> (format source /)) (random.ascii/alpha 5)) + expected_runs (\ ! each (|>> (n.% 10) (n.max 2)) random.nat) + dummy_path (\ ! each (|>> (format source /)) (random.ascii/alpha 5)) [compiler resolution] $build.resolution] ($_ _.and (_.cover [/.delay] @@ -110,15 +110,15 @@ fs (shell.async ($build.good_shell [])) resolution) - (\ ! map (|>> (case> (#try.Failure error) - (same? end_signal error) + (\ ! each (|>> (case> (#try.Failure error) + (same? end_signal error) - (#try.Success _) - false)))) + (#try.Success _) + false)))) correct_number_of_runs! (|> @runs atom.read! async.future - (\ ! map (n.= expected_runs)))] + (\ ! each (n.= expected_runs)))] (in (#try.Success (and correct_number_of_runs! no_dangling_process!)))))] (_.cover' [/.do!] diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 03625f0c1..ff5f7450b 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -232,12 +232,12 @@ actual/1 (\ console read_line []) actual/2 (\ console read_line []) end! (|> (\ console read_line []) - (\ ! map (|>> (case> (#try.Failure error) - true - - (#try.Success _) - false) - #try.Success)))] + (\ ! each (|>> (case> (#try.Failure error) + true + + (#try.Success _) + false) + #try.Success)))] (in (and (text\= expected/0 actual/0) (text\= expected/1 actual/1) (text\= expected/2 actual/2) diff --git a/stdlib/source/test/aedifex/command/clean.lux b/stdlib/source/test/aedifex/command/clean.lux index 30ef6eb6f..59908a364 100644 --- a/stdlib/source/test/aedifex/command/clean.lux +++ b/stdlib/source/test/aedifex/command/clean.lux @@ -43,10 +43,10 @@ (def: (files prefix) (-> Path (Random (List [Path Binary]))) (do {! random.monad} - [count (\ ! map (n.% 10) random.nat) + [count (\ ! each (n.% 10) random.nat) names (random.set text.hash count ..node_name) contents (random.list count ($binary.random 100))] - (in (list.zipped/2 (list\map (|>> (format prefix)) (set.list names)) + (in (list.zipped/2 (list\each (|>> (format prefix)) (set.list names)) contents)))) (def: (create_file! fs [path content]) @@ -58,7 +58,7 @@ (do {! (try.with async.monad)} [_ (: (Async (Try Any)) (file.make_directories async.monad fs path)) - _ (monad.map ! (..create_file! fs) files)] + _ (monad.each ! (..create_file! fs) files)] (in []))) (def: (directory_exists? fs) @@ -75,8 +75,8 @@ [directory_exists? (..directory_exists? fs directory_path) files_exist? (: (Action (List Bit)) (|> files - (list\map product.left) - (monad.map ///action.monad (..file_exists? fs))))] + (list\each product.left) + (monad.each ///action.monad (..file_exists? fs))))] (in (and directory_exists? (list.every? (|>>) files_exist?))))) diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 526227f2d..b36998b6f 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -84,7 +84,7 @@ (value@ #///.sources) set.list (export.library fs) - (\ ! map (format.result tar.writer))) + (\ ! each (format.result tar.writer))) actual_pom (\ repository download (///repository/remote.uri (value@ #///artifact.version artifact) artifact ///artifact/extension.pom)) actual_library (\ repository download (///repository/remote.uri (value@ #///artifact.version artifact) artifact ///artifact/extension.lux_library)) diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index f1c0c2de1..93d304d36 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -45,12 +45,12 @@ ! ///action.monad] (|> sources set.list - (monad.map ! (function (_ head) - (do ! - [_ (: (Async (Try Any)) - (file.make_directories async.monad fs head))] - (: (Async (Try Any)) - (file.make_file async.monad fs (binary.empty 0) (format head / head ".lux"))))))))) + (monad.each ! (function (_ head) + (do ! + [_ (: (Async (Try Any)) + (file.make_directories async.monad fs head))] + (: (Async (Try Any)) + (file.make_file async.monad fs (binary.empty 0) (format head / head ".lux"))))))))) (def: (execute! program fs sample) (-> (Program Async) (file.System Async) ///.Profile (Async (Try Text))) @@ -65,7 +65,7 @@ (<| (_.covering /._) (do {! random.monad} [identity $artifact.random - sample (\ ! map (with@ #///.identity (#.Some identity)) + sample (\ ! each (with@ #///.identity (#.Some identity)) $profile.random) home (random.ascii/alpha 5) working_directory (random.ascii/alpha 5) @@ -79,16 +79,16 @@ library_path (format artifact_path ///artifact/extension.lux_library) pom_path (format artifact_path ///artifact/extension.pom)] verdict (do {! ///action.monad} - [succeeded! (\ ! map (text\= /.success) + [succeeded! (\ ! each (text\= /.success) (..execute! program fs sample)) library_exists! (|> library_path (format home /) (\ fs file?) - (\ async.monad map (|>> #try.Success))) + (\ async.monad each (|>> #try.Success))) pom_exists! (|> pom_path (format home /) (\ fs file?) - (\ async.monad map (|>> #try.Success)))] + (\ async.monad each (|>> #try.Success)))] (in (and succeeded! library_exists! pom_exists!)))] @@ -100,6 +100,6 @@ logging (..execute! program fs (with@ #///.identity #.None sample))] (_.cover' [/.failure] (|> logging - (try\map (text\= /.failure)) + (try\each (text\= /.failure)) (try.else false))))) )))) diff --git a/stdlib/source/test/aedifex/command/pom.lux b/stdlib/source/test/aedifex/command/pom.lux index 7c2097a4d..211ce1ad5 100644 --- a/stdlib/source/test/aedifex/command/pom.lux +++ b/stdlib/source/test/aedifex/command/pom.lux @@ -44,12 +44,12 @@ (do ! [verdict (do ///action.monad [expected (|> (///pom.write sample) - (try\map (|>> (\ xml.codec encoded) - (\ utf8.codec encoded))) + (try\each (|>> (\ xml.codec encoded) + (\ utf8.codec encoded))) (\ ! in)) actual (\ fs read ///pom.file) - logging! (\ ///action.monad map + logging! (\ ///action.monad each (text\= /.success) (\ console read_line [])) diff --git a/stdlib/source/test/aedifex/dependency/deployment.lux b/stdlib/source/test/aedifex/dependency/deployment.lux index 97fd9f1f4..cd92cec74 100644 --- a/stdlib/source/test/aedifex/dependency/deployment.lux +++ b/stdlib/source/test/aedifex/dependency/deployment.lux @@ -106,7 +106,7 @@ correct_library_upload! (and (|> cache (dictionary.value library_url) - (maybe\map (binary\= expected_library)) + (maybe\each (binary\= expected_library)) (maybe.else false)) (dictionary.key? cache (format library_url artifact/extension.sha-1)) (dictionary.key? cache (format library_url artifact/extension.md5))) @@ -114,7 +114,7 @@ correct_pom_upload! (and (|> cache (dictionary.value pom_url) - (maybe\map (binary\= expected_pom)) + (maybe\each (binary\= expected_pom)) (maybe.else false)) (dictionary.key? cache (format pom_url artifact/extension.sha-1)) (dictionary.key? cache (format pom_url artifact/extension.md5))) @@ -147,7 +147,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [address (\ ! map (text.suffix uri.separator) + [address (\ ! each (text.suffix uri.separator) (random.ascii/upper 10))] ($_ _.and (do {! random.monad} @@ -161,16 +161,16 @@ cache (async.future (atom.read! cache))] (_.cover' [/.one] (|> ?outcome - (try\map (verify_one 1 address package cache expected_artifact)) + (try\each (verify_one 1 address package cache expected_artifact)) (try.else false)))))) (do {! random.monad} [.let [hash (: (Hash [Dependency Artifact Package]) - (\ hash.functor map (|>> product.right product.left product.left) + (\ hash.functor each (|>> product.right product.left product.left) text.hash))] - num_bundles (\ ! map (n.% 10) random.nat) + num_bundles (\ ! each (n.% 10) random.nat) bundles (|> ..bundle (random.set hash num_bundles) - (\ ! map set.list)) + (\ ! each set.list)) .let [resolution (list\mix (function (_ [dependency expected_artifact package] resolution) (dictionary.has dependency package resolution)) resolution.empty @@ -184,21 +184,21 @@ cache (async.future (atom.read! cache))] (_.cover' [/.all] (|> ?outcome - (try\map (function (_ actual_artifacts) - (let [expected_deployments! - (n.= num_bundles (set.size actual_artifacts)) + (try\each (function (_ actual_artifacts) + (let [expected_deployments! + (n.= num_bundles (set.size actual_artifacts)) - every_deployment_was_correct! - (list.every? (function (_ [dependency expected_artifact package]) - (let [deployed! - (set.member? actual_artifacts expected_artifact) + every_deployment_was_correct! + (list.every? (function (_ [dependency expected_artifact package]) + (let [deployed! + (set.member? actual_artifacts expected_artifact) - deployed_correctly! - (verify_one num_bundles address package cache expected_artifact expected_artifact)] - (and deployed! - deployed_correctly!))) - bundles)] - (and expected_deployments! - every_deployment_was_correct!)))) + deployed_correctly! + (verify_one num_bundles address package cache expected_artifact expected_artifact)] + (and deployed! + deployed_correctly!))) + bundles)] + (and expected_deployments! + every_deployment_was_correct!)))) (try.else false)))))) )))) diff --git a/stdlib/source/test/aedifex/hash.lux b/stdlib/source/test/aedifex/hash.lux index 5e267091d..e91b79e1f 100644 --- a/stdlib/source/test/aedifex/hash.lux +++ b/stdlib/source/test/aedifex/hash.lux @@ -30,8 +30,8 @@ (-> (-> Binary (/.Hash h)) (Random (/.Hash h)))) (do {! random.monad} - [size (\ ! map (n.% 100) random.nat)] - (\ ! map hash (_binary.random size)))) + [size (\ ! each (n.% 100) random.nat)] + (\ ! each hash (_binary.random size)))) (def: .public test Test @@ -55,7 +55,7 @@ (#try.Failure error) false) - (case (<constructor> (\ binary.monoid compose + (case (<constructor> (\ binary.monoid composite (/.data expected) (/.data expected))) (#try.Success actual) diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux index 675357e7e..993e67088 100644 --- a/stdlib/source/test/aedifex/input.lux +++ b/stdlib/source/test/aedifex/input.lux @@ -45,7 +45,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [expected (\ ! map (with@ #//.parents (list)) $profile.random) + [expected (\ ! each (with@ #//.parents (list)) $profile.random) .let [fs (: (file.System Async) (file.mock (\ file.default separator)))]] (in (do async.monad diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index 85aafa550..eb8b4aec1 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -48,12 +48,12 @@ (random.ascii/alpha 5) (random.list 5 (random.ascii/alpha 5)) (do {! random.monad} - [year (\ ! map (|>> (n.% 9,000) (n.+ 1,000) .int) random.nat) - month (\ ! map (|>> (n.% 12) (n.+ 1)) random.nat) - day_of_month (\ ! map (|>> (n.% 28) (n.+ 1)) random.nat) - hour (\ ! map (n.% 24) random.nat) - minute (\ ! map (n.% 60) random.nat) - second (\ ! map (n.% 60) random.nat)] + [year (\ ! each (|>> (n.% 9,000) (n.+ 1,000) .int) random.nat) + month (\ ! each (|>> (n.% 12) (n.+ 1)) random.nat) + day_of_month (\ ! each (|>> (n.% 28) (n.+ 1)) random.nat) + hour (\ ! each (n.% 24) random.nat) + minute (\ ! each (n.% 60) random.nat) + second (\ ! each (n.% 60) random.nat)] (in (try.trusted (do try.monad [year (year.year year) @@ -89,7 +89,7 @@ /.format list (<xml>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) (_.cover [/.uri] (text\= (//.remote_project_uri artifact) diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index 2c74296e0..5010053a5 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -52,12 +52,12 @@ (def: random_instant (Random Instant) (do {! random.monad} - [year (\ ! map (|>> (n.% 9,000) (n.+ 1,000) .int) random.nat) - month (\ ! map (|>> (n.% 12) (n.+ 1)) random.nat) - day_of_month (\ ! map (|>> (n.% 28) (n.+ 1)) random.nat) - hour (\ ! map (n.% 24) random.nat) - minute (\ ! map (n.% 60) random.nat) - second (\ ! map (n.% 60) random.nat)] + [year (\ ! each (|>> (n.% 9,000) (n.+ 1,000) .int) random.nat) + month (\ ! each (|>> (n.% 12) (n.+ 1)) random.nat) + day_of_month (\ ! each (|>> (n.% 28) (n.+ 1)) random.nat) + hour (\ ! each (n.% 24) random.nat) + minute (\ ! each (n.% 60) random.nat) + second (\ ! each (n.% 60) random.nat)] (in (try.trusted (do try.monad [year (year.year year) @@ -101,7 +101,7 @@ /.format list (<xml>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))) (_.cover [/.uri] (text\= (//.remote_artifact_uri artifact) diff --git a/stdlib/source/test/aedifex/package.lux b/stdlib/source/test/aedifex/package.lux index 7e9cf1dd6..7b2ac3865 100644 --- a/stdlib/source/test/aedifex/package.lux +++ b/stdlib/source/test/aedifex/package.lux @@ -43,7 +43,7 @@ (def: .public random (Random [//.Profile /.Package]) (do {! random.monad} - [content_size (\ ! map (n.% 100) random.nat) + [content_size (\ ! each (n.% 100) random.nat) content ($binary.random content_size) [profile pom] (random.one (function (_ profile) (try.maybe @@ -61,7 +61,7 @@ [[profile package] ..random] ($_ _.and (_.for [/.equivalence] - ($equivalence.spec /.equivalence (\ ! map product.right ..random))) + ($equivalence.spec /.equivalence (\ ! each product.right ..random))) (_.cover [/.local?] (/.local? (with@ #/.origin (#//origin.Local "~/yolo") package))) diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux index 6f1516258..de27a0ee8 100644 --- a/stdlib/source/test/aedifex/parser.lux +++ b/stdlib/source/test/aedifex/parser.lux @@ -40,12 +40,12 @@ (def: (list_of random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} - [size (\ ! map (n.% 5) random.nat)] + [size (\ ! each (n.% 5) random.nat)] (random.list size random))) (def: (dictionary_of key_hash key_random value_random) (All [k v] (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v)))) - (\ random.functor map + (\ random.functor each (dictionary.of_list key_hash) (..list_of (random.and key_random value_random)))) @@ -104,10 +104,10 @@ (|> expected ..with_empty_profile dictionary.entries - (list\map (function (_ [name profile]) - [name (|> profile - ..with_default_sources - ..with_default_repository)])) + (list\each (function (_ [name profile]) + [name (|> profile + ..with_default_sources + ..with_default_repository)])) (dictionary.of_list text.hash) (\ //project.equivalence = actual)) diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 4cb58d0d0..92d755290 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -74,18 +74,18 @@ (def: (list_of random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} - [size (\ ! map (n.% 5) random.nat)] + [size (\ ! each (n.% 5) random.nat)] (random.list size random))) (def: (set_of hash random) (All [a] (-> (Hash a) (Random a) (Random (Set a)))) - (\ random.functor map + (\ random.functor each (set.of_list hash) (..list_of random))) (def: (dictionary_of key_hash key_random value_random) (All [k v] (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v)))) - (\ random.functor map + (\ random.functor each (dictionary.of_list key_hash) (..list_of (random.and key_random value_random)))) diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux index 291935293..ebf37db81 100644 --- a/stdlib/source/test/aedifex/project.lux +++ b/stdlib/source/test/aedifex/project.lux @@ -27,7 +27,7 @@ (def: profile (Random [//.Name //.Profile]) (|> @profile.random - (random\map (with@ #//.parents (list))) + (random\each (with@ #//.parents (list))) (random.and (random.ascii/alpha 1)))) (def: .public random @@ -63,24 +63,24 @@ (not (text\= dummy_name name)) (not (text\= sub_name name)))) (random.ascii/alpha 1)) - .let [project ($_ (\ /.monoid compose) + .let [project ($_ (\ /.monoid composite) (/.project super_name super_profile) (/.project dummy_name dummy_profile) (/.project sub_name (with@ #//.parents (list super_name) sub_profile))) - circular ($_ (\ /.monoid compose) + circular ($_ (\ /.monoid composite) (/.project super_name (with@ #//.parents (list sub_name) super_profile)) (/.project dummy_name dummy_profile) (/.project sub_name (with@ #//.parents (list super_name) sub_profile)))]] ($_ _.and (_.cover [/.profile] (and (|> (/.profile super_name project) - (try\map (\ //.equivalence = super_profile)) + (try\each (\ //.equivalence = super_profile)) (try.else false)) (|> (/.profile dummy_name project) - (try\map (\ //.equivalence = dummy_profile)) + (try\each (\ //.equivalence = dummy_profile)) (try.else false)) (|> (/.profile sub_name project) - (try\map (\ //.equivalence = (\ //.monoid compose sub_profile super_profile))) + (try\each (\ //.equivalence = (\ //.monoid composite sub_profile super_profile))) (try.else false)))) (_.cover [/.unknown_profile] (case (/.profile fake_name project) diff --git a/stdlib/source/test/aedifex/repository/local.lux b/stdlib/source/test/aedifex/repository/local.lux index ccc13752f..34ae887d7 100644 --- a/stdlib/source/test/aedifex/repository/local.lux +++ b/stdlib/source/test/aedifex/repository/local.lux @@ -35,7 +35,7 @@ repo (/.repository program fs)] uri (random.ascii/lower 10) - expected (\ ! map (\ utf8.codec encoded) + expected (\ ! each (\ utf8.codec encoded) (random.ascii/lower 10))] ($_ _.and (in (do async.monad @@ -47,6 +47,6 @@ (#try.Success _) false (#try.Failure _) true) (|> actual - (try\map (binary\= expected)) + (try\each (binary\= expected)) (try.else false)))))) )))) diff --git a/stdlib/source/test/aedifex/repository/remote.lux b/stdlib/source/test/aedifex/repository/remote.lux index 96d62ef6f..3013d8889 100644 --- a/stdlib/source/test/aedifex/repository/remote.lux +++ b/stdlib/source/test/aedifex/repository/remote.lux @@ -48,7 +48,7 @@ #try.Success (if (|> headers (dictionary.value "User-Agent") - (maybe\map (same? /.user_agent)) + (maybe\each (same? /.user_agent)) (maybe.else false)) (case [method input] [#@http.Get #.None] @@ -59,7 +59,7 @@ [#@http.Put (#.Some input)] (if (|> headers (dictionary.value "Authorization") - (maybe\map (text\= (//identity.basic_auth user password))) + (maybe\each (text\= (//identity.basic_auth user password))) (maybe.else false)) [http/status.created {#@http.headers (http.headers (list)) @@ -90,7 +90,7 @@ user (random.ascii/lower 10) password (random.ascii/lower 10) - content (\ ! map (\ utf8.codec encoded) + content (\ ! each (\ utf8.codec encoded) (random.ascii/lower 10))] ($_ _.and (_.cover [/.repository /.user_agent /.Address] @@ -100,13 +100,13 @@ address)] (and (|> (\ repo download uri) io.run! - (try\map (\ utf8.codec decoded)) - try\join - (try\map (text\= (format address uri))) + (try\each (\ utf8.codec decoded)) + try\conjoint + (try\each (text\= (format address uri))) (try.else false)) (|> (\ repo upload uri content) io.run! - (try\map (function.constant true)) + (try\each (function.constant true)) (try.else false))))) (_.cover [/.upload_failure] (let [repo (/.repository (..good_http user password) diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index 782b20204..d4f116242 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -44,7 +44,7 @@ (~~ (template [<command>] [(_.cover [/.default_java /.default_js /.default_python /.default_lua /.default_ruby] (let [listing (|> (list /.default_java /.default_js /.default_python /.default_lua /.default_ruby) - (list\map (value@ #/.program))) + (list\each (value@ #/.program))) unique (set.of_list text.hash listing)] (n.= (list.size listing) (set.size unique))))] @@ -62,6 +62,6 @@ (|> runtime' (value@ #/.parameters) list.last - (maybe\map (text\= path)) + (maybe\each (text\= path)) (maybe.else false))))) ))))) diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 68f155559..a072fbc25 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -464,13 +464,15 @@ )))))) (/.type: for_type/variant - #Case/0 - (#Case/1 Nat) - (#Case/2 Int Text)) + (Variant + #Case/0 + (#Case/1 Nat) + (#Case/2 Int Text))) (/.type: for_type/record - {#slot/0 Bit - #slot/1 Rev}) + (Record + {#slot/0 Bit + #slot/1 Rev})) (/.type: (for_type/all parameter) [parameter parameter]) @@ -483,7 +485,7 @@ expected_left random.nat expected_right random.nat - .let [existential_type (\ ! map (|>> #.Ex) random.nat)] + .let [existential_type (\ ! each (|>> #.Ex) random.nat)] expected/0 existential_type expected/1 existential_type] (<| (_.for [/.Type]) @@ -620,7 +622,7 @@ (n.= (n.+ left right) (!n/+ left right)))) (do {! random.monad} - [sample (\ ! map (n.% 5) random.nat)] + [sample (\ ! each (n.% 5) random.nat)] (_.cover [/.^template] (case sample (/.^template [<case>] @@ -653,12 +655,14 @@ ))) (type: Small - {#small_left Nat - #small_right Text}) + (Record + {#small_left Nat + #small_right Text})) (type: Big - {#big_left Nat - #big_right Small}) + (Record + {#big_left Nat + #big_right Small})) (def: for_slot Test @@ -886,8 +890,9 @@ ))) (type: (Pair l r) - {#left l - #right r}) + (Record + {#left l + #right r})) (template: (!pair <left> <right>) [{#left <left> @@ -896,8 +901,8 @@ (def: for_case Test (do {! random.monad} - [expected_nat (\ ! map (n.% 1) random.nat) - expected_int (\ ! map (i.% +1) random.int) + [expected_nat (\ ! each (n.% 1) random.nat) + expected_int (\ ! each (i.% +1) random.int) expected_rev (random.either (in .5) (in .25)) expected_frac (random.either (in +0.5) @@ -1003,8 +1008,8 @@ Test ($_ _.and (do random.monad - [factor (random\map (|>> (n.% 10) (n.max 1)) random.nat) - iterations (random\map (n.% 10) random.nat) + [factor (random\each (|>> (n.% 10) (n.max 1)) random.nat) + iterations (random\each (n.% 10) random.nat) .let [expected (n.* factor iterations)]] (_.cover [/.loop] (n.= expected @@ -1112,7 +1117,7 @@ let/3)) actual_locals/2 (|> locals/2 (value@ #.mappings) - (list\map product.left) + (list\each product.left) (set.of_list text.hash)) correct_locals! @@ -1134,7 +1139,7 @@ (|> captured/2 (value@ #.mappings) (plist.value name) - (maybe\map (|>> product.right is?)) + (maybe\each (|>> product.right is?)) (maybe.else false)))) correct_closure! diff --git a/stdlib/source/test/lux/abstract/comonad/cofree.lux b/stdlib/source/test/lux/abstract/comonad/cofree.lux index 916d1953b..971088981 100644 --- a/stdlib/source/test/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/test/lux/abstract/comonad/cofree.lux @@ -21,12 +21,12 @@ (def: (injection value) (Injection (/.CoFree Sequence)) - [value (sequence\map injection (sequence.repeated value))]) + [value (sequence\each injection (sequence.repeated value))]) (def: (interpret [head tail]) (All [a] (-> (/.CoFree Sequence a) (Sequence a))) (|> tail - (sequence\map (\ (/.comonad sequence.functor) out)) + (sequence\each (\ (/.comonad sequence.functor) out)) [head] //.pending)) diff --git a/stdlib/source/test/lux/abstract/enum.lux b/stdlib/source/test/lux/abstract/enum.lux index 33dff9472..afb40be03 100644 --- a/stdlib/source/test/lux/abstract/enum.lux +++ b/stdlib/source/test/lux/abstract/enum.lux @@ -20,7 +20,7 @@ (def: .public test Test (let [limit (: (Random Nat) - (\ random.monad map (n.% 20) random.nat))] + (\ random.monad each (n.% 20) random.nat))] (do random.monad [start limit end limit @@ -32,8 +32,8 @@ ($_ _.and (_.cover [/.range] (let [expected_size (|> end (n.- start) ++) - expected_start? (|> range list.head (maybe\map (n.= start)) (maybe.else false)) - expected_end? (|> range list.last (maybe\map (n.= end)) (maybe.else false)) + expected_start? (|> range list.head (maybe\each (n.= start)) (maybe.else false)) + expected_end? (|> range list.last (maybe\each (n.= end)) (maybe.else false)) can_be_backwards? (\ (list.equivalence n.equivalence) = (/.range n.enum start end) (list.reversed (/.range n.enum end start))) diff --git a/stdlib/source/test/lux/abstract/functor.lux b/stdlib/source/test/lux/abstract/functor.lux index 522707615..c2d48f298 100644 --- a/stdlib/source/test/lux/abstract/functor.lux +++ b/stdlib/source/test/lux/abstract/functor.lux @@ -25,7 +25,7 @@ (<| (_.covering /._) ($_ _.and (_.cover [/.Or /.sum] - (and (case (\ (/.sum maybe.functor list.functor) map + (and (case (\ (/.sum maybe.functor list.functor) each (n.+ shift) (#.Left (#.Some left))) (#.Left (#.Some actual)) @@ -33,7 +33,7 @@ _ false) - (case (\ (/.sum maybe.functor list.functor) map + (case (\ (/.sum maybe.functor list.functor) each (n.+ shift) (#.Right (list right))) (^ (#.Right (list actual))) @@ -42,7 +42,7 @@ _ false))) (_.cover [/.And /.product] - (case (\ (/.product maybe.functor list.functor) map + (case (\ (/.product maybe.functor list.functor) each (n.+ shift) [(#.Some left) (list right)]) (^ [(#.Some actualL) (list actualR)]) @@ -52,7 +52,7 @@ _ false)) (_.cover [/.Then /.composite] - (case (\ (/.composite maybe.functor list.functor) map + (case (\ (/.composite maybe.functor list.functor) each (n.+ shift) (#.Some (list left))) (^ (#.Some (list actual))) diff --git a/stdlib/source/test/lux/abstract/interval.lux b/stdlib/source/test/lux/abstract/interval.lux index 76b45ddce..6be3c331b 100644 --- a/stdlib/source/test/lux/abstract/interval.lux +++ b/stdlib/source/test/lux/abstract/interval.lux @@ -139,13 +139,13 @@ Test (do {! random.monad} [[l m r] (|> (random.set n.hash 3 random.nat) - (\ ! map (|>> set.list - (list.sorted n.<) - (case> (^ (list b t1 t2)) - [b t1 t2] + (\ ! each (|>> set.list + (list.sorted n.<) + (case> (^ (list b t1 t2)) + [b t1 t2] - _ - (undefined))))) + _ + (undefined))))) .let [left (/.singleton n.enum l) right (/.singleton n.enum r)]] ($_ _.and @@ -161,13 +161,13 @@ Test (do {! random.monad} [[b t1 t2] (|> (random.set n.hash 3 random.nat) - (\ ! map (|>> set.list - (list.sorted n.<) - (case> (^ (list b t1 t2)) - [b t1 t2] + (\ ! each (|>> set.list + (list.sorted n.<) + (case> (^ (list b t1 t2)) + [b t1 t2] - _ - (undefined))))) + _ + (undefined))))) .let [int_left (/.between n.enum t1 t2) int_right (/.between n.enum b t1)]] ($_ _.and @@ -188,13 +188,13 @@ (do {! random.monad} [some_interval ..interval [x0 x1 x2 x3] (|> (random.set n.hash 4 random.nat) - (\ ! map (|>> set.list - (list.sorted n.<) - (case> (^ (list x0 x1 x2 x3)) - [x0 x1 x2 x3] + (\ ! each (|>> set.list + (list.sorted n.<) + (case> (^ (list x0 x1 x2 x3)) + [x0 x1 x2 x3] - _ - (undefined)))))] + _ + (undefined)))))] ($_ _.and (_.test "Every interval is nested into itself." (/.nested? some_interval some_interval)) @@ -221,13 +221,13 @@ (do {! random.monad} [some_interval ..interval [x0 x1 x2 x3] (|> (random.set n.hash 4 random.nat) - (\ ! map (|>> set.list - (list.sorted n.<) - (case> (^ (list x0 x1 x2 x3)) - [x0 x1 x2 x3] + (\ ! each (|>> set.list + (list.sorted n.<) + (case> (^ (list x0 x1 x2 x3)) + [x0 x1 x2 x3] - _ - (undefined)))))] + _ + (undefined)))))] ($_ _.and (_.test "No interval overlaps with itself." (not (/.overlaps? some_interval some_interval))) diff --git a/stdlib/source/test/lux/abstract/mix.lux b/stdlib/source/test/lux/abstract/mix.lux index 5aac1fd2b..a93f24cc9 100644 --- a/stdlib/source/test/lux/abstract/mix.lux +++ b/stdlib/source/test/lux/abstract/mix.lux @@ -21,6 +21,6 @@ (<| (_.covering /._) ($_ _.and (_.cover [/.with_monoid] - (n.= (\ list.mix mix (\ n.addition compose) (\ n.addition identity) samples) + (n.= (\ list.mix mix (\ n.addition composite) (\ n.addition identity) samples) (/.with_monoid n.addition list.mix samples))) )))) diff --git a/stdlib/source/test/lux/abstract/monad.lux b/stdlib/source/test/lux/abstract/monad.lux index 5ede269ef..db0829989 100644 --- a/stdlib/source/test/lux/abstract/monad.lux +++ b/stdlib/source/test/lux/abstract/monad.lux @@ -34,17 +34,17 @@ (\ identity.monad in mono))))) (_.cover [/.all] (\ (list.equivalence n.equivalence) = - (list\map ++ poly) + (list\each ++ poly) (|> poly - (list\map (|>> ++ (\ identity.monad in))) + (list\each (|>> ++ (\ identity.monad in))) (: (List (Identity Nat))) (/.all identity.monad) (: (Identity (List Nat)))))) - (_.cover [/.map] + (_.cover [/.each] (\ (list.equivalence n.equivalence) = - (list\map ++ poly) + (list\each ++ poly) (|> poly - (/.map identity.monad (|>> ++ (\ identity.monad in))) + (/.each identity.monad (|>> ++ (\ identity.monad in))) (: (Identity (List Nat)))))) (_.cover [/.only] (\ (list.equivalence n.equivalence) = diff --git a/stdlib/source/test/lux/abstract/monad/free.lux b/stdlib/source/test/lux/abstract/monad/free.lux index 523741df6..8df494aac 100644 --- a/stdlib/source/test/lux/abstract/monad/free.lux +++ b/stdlib/source/test/lux/abstract/monad/free.lux @@ -30,7 +30,7 @@ (#/.Effect effect) (|> effect - (list\map interpret) + (list\each interpret) list.together))) (def: comparison diff --git a/stdlib/source/test/lux/abstract/monoid.lux b/stdlib/source/test/lux/abstract/monoid.lux index c78d2d8f6..95d932e81 100644 --- a/stdlib/source/test/lux/abstract/monoid.lux +++ b/stdlib/source/test/lux/abstract/monoid.lux @@ -24,10 +24,10 @@ (<| (_.covering /._) ($_ _.and (_.cover [/.and] - (let [[natLR intLR] (\ (/.and nat.addition int.multiplication) compose + (let [[natLR intLR] (\ (/.and nat.addition int.multiplication) composite [natL intL] [natR intR])] - (and (nat.= (\ nat.addition compose natL natR) + (and (nat.= (\ nat.addition composite natL natR) natLR) - (int.= (\ int.multiplication compose intL intR) + (int.= (\ int.multiplication composite intL intR) intLR)))) )))) diff --git a/stdlib/source/test/lux/abstract/predicate.lux b/stdlib/source/test/lux/abstract/predicate.lux index b3521ca3c..098136df4 100644 --- a/stdlib/source/test/lux/abstract/predicate.lux +++ b/stdlib/source/test/lux/abstract/predicate.lux @@ -46,7 +46,7 @@ (let [generator (: (Random (/.Predicate Nat)) (|> random.nat (random.only (|>> (n.= 0) not)) - (\ ! map multiple?)))] + (\ ! each multiple?)))] ($_ _.and (_.for [/.union] ($monoid.spec equivalence /.union generator)) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 93c68faff..c5c66d2fc 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -200,9 +200,9 @@ verdict))) (do ! - [num_events (\ ! map (|>> (n.% 10) ++) random.nat) + [num_events (\ ! each (|>> (n.% 10) ++) random.nat) events (random.list num_events random.nat) - num_observations (\ ! map (n.% num_events) random.nat) + num_observations (\ ! each (n.% num_events) random.nat) .let [expected (list.first num_observations events) sink (: (Atom (Row Nat)) (atom.atom row.empty))]] diff --git a/stdlib/source/test/lux/control/concurrency/async.lux b/stdlib/source/test/lux/control/concurrency/async.lux index f9b917ee5..c6a858a5d 100644 --- a/stdlib/source/test/lux/control/concurrency/async.lux +++ b/stdlib/source/test/lux/control/concurrency/async.lux @@ -54,7 +54,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [waiting_time (|> random.nat (\ ! map (|>> (n.% ..delay) (n.+ ..delay)))) + [waiting_time (|> random.nat (\ ! each (|>> (n.% ..delay) (n.+ ..delay)))) expected random.nat dummy random.nat .let [not_dummy (|> random.nat (random.only (|>> (n.= dummy) not)))] diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index 174c8adc7..ad508df7b 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -59,7 +59,7 @@ (in #.End) (#.Some [head tail]) - (\ ! map (|>> (#.Item head)) + (\ ! each (|>> (#.Item head)) (take_amount (-- amount_of_polls) [channel sink])))))) (def: .public test @@ -152,12 +152,12 @@ (do ! [_ (!signal [])] (in #.None))))) - (/.sequential 0 (list\compose inputs inputs)))) + (/.sequential 0 (list\composite inputs inputs)))) _ ?signal listened (|> sink atom.read! async.future - (\ ! map row.list))] + (\ ! each row.list))] (_.cover' [/.Subscriber /.subscribe!] (list\= inputs listened)))) (in (do async.monad @@ -189,8 +189,8 @@ (list\= (list distint/0 distint/1 distint/2) actual)))) (do ! - [polling_delay (\ ! map (|>> (n.% 10) ++) random.nat) - amount_of_polls (\ ! map (|>> (n.% 10) ++) random.nat)] + [polling_delay (\ ! each (|>> (n.% 10) ++) random.nat) + amount_of_polls (\ ! each (|>> (n.% 10) ++) random.nat)] ($_ _.and (in (do {! async.monad} [actual (..take_amount amount_of_polls (/.poll polling_delay (: (IO Nat) (io.io sample)))) diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index b4b07bbb0..796a1604e 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -39,7 +39,7 @@ (_.for [/.Semaphore] ($_ _.and (do {! random.monad} - [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + [initial_open_positions (|> random.nat (\ ! each (|>> (n.% 10) (n.max 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do async.monad [result (async.within ..delay (/.wait! semaphore))] @@ -51,10 +51,10 @@ #.None false))))) (do {! random.monad} - [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + [initial_open_positions (|> random.nat (\ ! each (|>> (n.% 10) (n.max 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do {! async.monad} - [_ (monad.map ! /.wait! (list.repeated initial_open_positions semaphore)) + [_ (monad.each ! /.wait! (list.repeated initial_open_positions semaphore)) result (async.within ..delay (/.wait! semaphore))] (_.cover' [/.wait!] (case result @@ -64,10 +64,10 @@ #.None true))))) (do {! random.monad} - [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + [initial_open_positions (|> random.nat (\ ! each (|>> (n.% 10) (n.max 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do {! async.monad} - [_ (monad.map ! /.wait! (list.repeated initial_open_positions semaphore)) + [_ (monad.each ! /.wait! (list.repeated initial_open_positions semaphore)) .let [block (/.wait! semaphore)] result/0 (async.within ..delay block) open_positions (/.signal! semaphore) @@ -80,7 +80,7 @@ _ false))))) (do {! random.monad} - [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + [initial_open_positions (|> random.nat (\ ! each (|>> (n.% 10) (n.max 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do async.monad [outcome (/.signal! semaphore)] @@ -98,7 +98,7 @@ (_.for [/.Mutex] ($_ _.and (do {! random.monad} - [repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) + [repetitions (|> random.nat (\ ! each (|>> (n.% 100) (n.max 10)))) .let [resource (atom.atom "") expected_As (text.together (list.repeated repetitions "A")) expected_Bs (text.together (list.repeated repetitions "B")) @@ -155,7 +155,7 @@ _ false))) (do {! random.monad} - [limit (\ ! map (|>> (n.% 9) ++) random.nat) + [limit (\ ! each (|>> (n.% 9) ++) random.nat) .let [barrier (/.barrier (maybe.trusted (/.limit limit))) resource (atom.atom "")]] (in (do {! async.monad} @@ -165,10 +165,10 @@ text.together) expected_ids (enum.range n.enum 0 (-- limit))] _ (|> expected_ids - (list\map (function (_ id) - (exec - (io.run! (atom.update! (|>> (format suffix)) resource)) - (waiter resource barrier id)))) + (list\each (function (_ id) + (exec + (io.run! (atom.update! (|>> (format suffix)) resource)) + (waiter resource barrier id)))) (monad.all !)) .let [outcome (io.run! (atom.read! resource))]] (_.cover' [/.barrier /.block!] diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux index f3a5c618c..8d56cbed2 100644 --- a/stdlib/source/test/lux/control/concurrency/stm.lux +++ b/stdlib/source/test/lux/control/concurrency/stm.lux @@ -41,7 +41,7 @@ (do {! random.monad} [dummy random.nat expected random.nat - iterations_per_process (|> random.nat (\ ! map (n.% 100)))] + iterations_per_process (|> random.nat (\ ! each (n.% 100)))] ($_ _.and (_.for [/.functor] ($functor.spec ..injection ..comparison /.functor)) @@ -94,7 +94,7 @@ (in (let [var (/.var 0)] (do {! async.monad} [_ (|> (list.repeated iterations_per_process []) - (list\map (function (_ _) (/.commit! (/.update ++ var)))) + (list\each (function (_ _) (/.commit! (/.update ++ var)))) (monad.all !)) cummulative (/.commit! (/.read var))] (_.cover' [/.STM] diff --git a/stdlib/source/test/lux/control/concurrency/thread.lux b/stdlib/source/test/lux/control/concurrency/thread.lux index bee49206d..42c4c2d9f 100644 --- a/stdlib/source/test/lux/control/concurrency/thread.lux +++ b/stdlib/source/test/lux/control/concurrency/thread.lux @@ -26,7 +26,7 @@ (do {! random.monad} [dummy random.nat expected random.nat - delay (\ ! map (|>> (n.% 5) (n.+ 5)) + delay (\ ! each (|>> (n.% 5) (n.+ 5)) random.nat)] ($_ _.and (_.cover [/.parallelism] diff --git a/stdlib/source/test/lux/control/exception.lux b/stdlib/source/test/lux/control/exception.lux index 74e73f45b..aacd0ab5a 100644 --- a/stdlib/source/test/lux/control/exception.lux +++ b/stdlib/source/test/lux/control/exception.lux @@ -29,7 +29,7 @@ [expected random.nat wrong (|> random.nat (random.only (|>> (n.= expected) not))) assertion_succeeded? random.bit - .let [report_element (\ ! map %.nat random.nat)] + .let [report_element (\ ! each %.nat random.nat)] field0 report_element value0 report_element field1 report_element diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux index 4450991ec..714d33949 100644 --- a/stdlib/source/test/lux/control/function.lux +++ b/stdlib/source/test/lux/control/function.lux @@ -25,8 +25,8 @@ Test (do {! random.monad} [expected random.nat - f0 (\ ! map n.+ random.nat) - f1 (\ ! map n.* random.nat) + f0 (\ ! each n.+ random.nat) + f1 (\ ! each n.* random.nat) dummy random.nat extra (|> random.nat (random.only (|>> (n.= expected) not)))] (<| (_.covering /._) @@ -37,7 +37,7 @@ (n.= (left extra) (right extra))))) generator (: (Random (-> Nat Nat)) - (\ ! map n.- random.nat))] + (\ ! each n.- random.nat))] (_.for [/.monoid] ($monoid.spec equivalence /.monoid generator))) diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index 3941998fc..ca4d06e2d 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -58,7 +58,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [input (|> random.nat (\ ! map (|>> (n.% 5) (n.+ 21))))]) + [input (|> random.nat (\ ! each (|>> (n.% 5) (n.+ 21))))]) (_.for [/.Memo]) ($_ _.and (_.cover [/.closed /.none] @@ -111,7 +111,7 @@ [output' (recur (-- input))] (in (n.* input output'))))))) expected (|> (list.indices input) - (list\map ++) + (list\each ++) (list\mix n.* 1)) actual (|> (memo input) (state.result (dictionary.empty n.hash)) diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index 001626888..533f88072 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -25,7 +25,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [input (|> random.nat (\ ! map (|>> (n.% 6) (n.+ 20)))) + [input (|> random.nat (\ ! each (|>> (n.% 6) (n.+ 20)))) dummy random.nat shift (|> random.nat (random.only (|>> (n.= dummy) not))) .let [equivalence (: (Equivalence (/.Mixin Nat Nat)) @@ -39,7 +39,7 @@ (in (function (_ delegate recur input) output)))) expected (|> (list.indices input) - (list\map ++) + (list\each ++) (list\mix n.* 1))]]) ($_ _.and (_.for [/.Mixin] diff --git a/stdlib/source/test/lux/control/function/mutual.lux b/stdlib/source/test/lux/control/function/mutual.lux index 4fe2e4219..2e24285ef 100644 --- a/stdlib/source/test/lux/control/function/mutual.lux +++ b/stdlib/source/test/lux/control/function/mutual.lux @@ -18,7 +18,7 @@ (def: test_let Test (do {! random.monad} - [sample (\ ! map (n.% 10) random.nat) + [sample (\ ! each (n.% 10) random.nat) .let [expected (n.even? sample)]] (<| (_.cover [/.let]) (/.let [(even? number) @@ -51,7 +51,7 @@ (def: test_def Test (do {! random.monad} - [sample (\ ! map (n.% 10) random.nat) + [sample (\ ! each (n.% 10) random.nat) .let [expected (n.even? sample)]] (<| (_.cover [/.def:]) (and (bit\= expected (..even? sample)) diff --git a/stdlib/source/test/lux/control/lazy.lux b/stdlib/source/test/lux/control/lazy.lux index ea1b1f787..bc1ed13d0 100644 --- a/stdlib/source/test/lux/control/lazy.lux +++ b/stdlib/source/test/lux/control/lazy.lux @@ -29,7 +29,7 @@ (def: .public lazy (All [a] (-> (Random a) (Random (Lazy a)))) - (\ random.functor map (|>> /.lazy))) + (\ random.functor each (|>> /.lazy))) (def: .public test Test diff --git a/stdlib/source/test/lux/control/maybe.lux b/stdlib/source/test/lux/control/maybe.lux index 6f4213268..291d61adf 100644 --- a/stdlib/source/test/lux/control/maybe.lux +++ b/stdlib/source/test/lux/control/maybe.lux @@ -34,7 +34,7 @@ ($equivalence.spec (/.equivalence n.equivalence) (random.maybe random.nat))) (_.for [/.hash] (|> random.nat - (\ random.monad map (|>> #.Some)) + (\ random.monad each (|>> #.Some)) ($hash.spec (/.hash n.hash)))) (_.for [/.monoid] ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.maybe random.nat))) diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index e37a2f355..fd29bd07b 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -90,7 +90,7 @@ Test (do {! random.monad} [expected0 random.nat - variadic (\ ! map (|>> (n.max 1) (n.min 20)) random.nat) + variadic (\ ! each (|>> (n.max 1) (n.min 20)) random.nat) expected+ (random.list variadic random.nat) even0 (random.only n.even? random.nat) odd0 (random.only n.odd? random.nat) @@ -106,16 +106,16 @@ (match #.None #1)))) (_.cover [/.some] - (and (|> (list\map code.nat expected+) + (and (|> (list\each code.nat expected+) (/.result (/.some <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) - (|> (list\map (|>> .int code.int) expected+) + (|> (list\each (|>> .int code.int) expected+) (/.result (/.some <code>.nat)) (match #.End #1)))) (_.cover [/.many] - (and (|> (list\map code.nat expected+) + (and (|> (list\each code.nat expected+) (/.result (/.many <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) @@ -123,7 +123,7 @@ (/.result (/.many <code>.nat)) (match (list actual) (n.= expected0 actual))) - (|> (list\map (|>> .int code.int) expected+) + (|> (list\each (|>> .int code.int) expected+) (/.result (/.many <code>.nat)) fails?))) (_.cover [/.only] @@ -180,72 +180,72 @@ (def: combinators_1 Test (do {! random.monad} - [variadic (\ ! map (|>> (n.max 1) (n.min 20)) random.nat) - times (\ ! map (n.% variadic) random.nat) + [variadic (\ ! each (|>> (n.max 1) (n.min 20)) random.nat) + times (\ ! each (n.% variadic) random.nat) expected random.nat wrong (|> random.nat (random.only (|>> (n.= expected) not))) expected+ (random.list variadic random.nat) separator (random.ascii 1)] ($_ _.and (_.cover [/.exactly] - (and (|> (list\map code.nat expected+) + (and (|> (list\each code.nat expected+) (/.result (/.exactly times <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = (list.first times expected+) actual))) - (|> (list\map code.nat expected+) + (|> (list\each code.nat expected+) (/.result (/.exactly (++ variadic) <code>.nat)) fails?))) (_.cover [/.at_least] - (and (|> (list\map code.nat expected+) + (and (|> (list\each code.nat expected+) (/.result (/.at_least times <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) - (|> (list\map code.nat expected+) + (|> (list\each code.nat expected+) (/.result (/.at_least (++ variadic) <code>.nat)) fails?))) (_.cover [/.at_most] - (and (|> (list\map code.nat expected+) + (and (|> (list\each code.nat expected+) (/.result (/.at_most times <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = (list.first times expected+) actual))) - (|> (list\map code.nat expected+) + (|> (list\each code.nat expected+) (/.result (/.at_most (++ variadic) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))))) (_.cover [/.between] - (and (|> (list\map code.nat expected+) + (and (|> (list\each code.nat expected+) (/.result (/.between times (n.- times variadic) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) - (|> (list\map code.nat (list.first times expected+)) + (|> (list\each code.nat (list.first times expected+)) (/.result (/.between times (n.- times variadic) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = (list.first times expected+) actual))))) (_.cover [/.separated_by] - (|> (list.interposed (code.text separator) (list\map code.nat expected+)) + (|> (list.interposed (code.text separator) (list\each code.nat expected+)) (/.result (/.separated_by (<code>.this! (code.text separator)) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual)))) (_.cover [/.remaining] - (|> (list\map code.nat expected+) + (|> (list\each code.nat expected+) (/.result /.remaining) (match actual (\ (list.equivalence code.equivalence) = - (list\map code.nat expected+) + (list\each code.nat expected+) actual)))) (_.cover [/.else] (and (|> (/.result (/.else wrong (\ /.monad in expected)) (list)) diff --git a/stdlib/source/test/lux/control/parser/analysis.lux b/stdlib/source/test/lux/control/parser/analysis.lux index 85ab04863..7cce374d0 100644 --- a/stdlib/source/test/lux/control/parser/analysis.lux +++ b/stdlib/source/test/lux/control/parser/analysis.lux @@ -53,7 +53,7 @@ [] (`` ($_ _.and (do {! random.monad} - [expected (\ ! map (|>> analysis.bit) random.bit)] + [expected (\ ! each (|>> analysis.bit) random.bit)] (_.cover [/.result /.any] (|> (list expected) (/.result /.any) diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index a3c20dbde..cdb9a1572 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -92,7 +92,7 @@ (random.rec (function (_ recur) (let [random_sequence (do {! random.monad} - [size (\ ! map (n.% 2) random.nat)] + [size (\ ! each (n.% 2) random.nat)] (random.list size recur))] ($_ random.and ..random_location @@ -109,7 +109,7 @@ random_sequence random_sequence (do {! random.monad} - [size (\ ! map (n.% 2) random.nat)] + [size (\ ! each (n.% 2) random.nat)] (random.list size (random.and recur recur))) ))))))) @@ -128,7 +128,7 @@ (`` ($_ _.and (~~ (template [<size> <parser> <format>] [(do {! random.monad} - [expected (\ ! map (i64.and (i64.mask <size>)) + [expected (\ ! each (i64.and (i64.mask <size>)) random.nat)] (_.cover [<size> <parser> <format>] (|> (format.result <format> expected) @@ -148,7 +148,7 @@ (`` ($_ _.and (~~ (template [<parser> <format>] [(do {! random.monad} - [expected (\ ! map (\ utf8.codec encoded) (random.ascii ..segment_size))] + [expected (\ ! each (\ utf8.codec encoded) (random.ascii ..segment_size))] (_.cover [<parser> <format>] (|> (format.result <format> expected) (/.result <parser>) @@ -227,8 +227,8 @@ (and (frac.not_a_number? expected) (frac.not_a_number? actual)))))))) (do {! random.monad} - [expected (\ ! map (|>> (i64.and (i64.mask /.size/8)) - (n.max 2)) + [expected (\ ! each (|>> (i64.and (i64.mask /.size/8)) + (n.max 2)) random.nat)] (_.cover [/.not_a_bit] (|> expected @@ -270,7 +270,7 @@ [/.set (/.set n.hash /.nat) format.set (format.set format.nat) (random.set n.hash ..segment_size random.nat) set.equivalence] [/.name /.name format.name format.name ..random_name name.equivalence])) (do {! random.monad} - [expected (\ ! map (list.repeated ..segment_size) random.nat)] + [expected (\ ! each (list.repeated ..segment_size) random.nat)] (_.cover [/.set_elements_are_not_unique] (|> expected (format.result (format.list format.nat)) @@ -289,8 +289,8 @@ expected actual)))))) (do {! random.monad} - [tag (\ ! map (|>> (i64.and (i64.mask /.size/8)) - (n.max 2)) + [tag (\ ! each (|>> (i64.and (i64.mask /.size/8)) + (n.max 2)) random.nat) value random.bit] (_.cover [/.invalid_tag] @@ -329,14 +329,14 @@ (/.result /.any) (!expect (#try.Success _)))) (do {! random.monad} - [data (\ ! map (\ utf8.codec encoded) (random.ascii ..segment_size))] + [data (\ ! each (\ utf8.codec encoded) (random.ascii ..segment_size))] (_.cover [/.binary_was_not_fully_read] (|> data (/.result /.any) (!expect (^multi (#try.Failure error) (exception.match? /.binary_was_not_fully_read error)))))) (do {! random.monad} - [expected (\ ! map (\ utf8.codec encoded) (random.ascii ..segment_size))] + [expected (\ ! each (\ utf8.codec encoded) (random.ascii ..segment_size))] (_.cover [/.segment format.segment format.result] (|> expected (format.result (format.segment ..segment_size)) @@ -344,7 +344,7 @@ (!expect (^multi (#try.Success actual) (\ binary.equivalence = expected actual)))))) (do {! random.monad} - [data (\ ! map (\ utf8.codec encoded) (random.ascii ..segment_size))] + [data (\ ! each (\ utf8.codec encoded) (random.ascii ..segment_size))] (_.cover [/.end?] (|> data (/.result (do <>.monad @@ -355,8 +355,8 @@ post)))) (!expect (#try.Success #1))))) (do {! random.monad} - [to_read (\ ! map (n.% (++ ..segment_size)) random.nat) - data (\ ! map (\ utf8.codec encoded) (random.ascii ..segment_size))] + [to_read (\ ! each (n.% (++ ..segment_size)) random.nat) + data (\ ! each (\ utf8.codec encoded) (random.ascii ..segment_size))] (_.cover [/.Offset /.offset] (|> data (/.result (do <>.monad @@ -370,8 +370,8 @@ (n.= ..segment_size nothing_left))))) (!expect (#try.Success #1))))) (do {! random.monad} - [to_read (\ ! map (n.% (++ ..segment_size)) random.nat) - data (\ ! map (\ utf8.codec encoded) (random.ascii ..segment_size))] + [to_read (\ ! each (n.% (++ ..segment_size)) random.nat) + data (\ ! each (\ utf8.codec encoded) (random.ascii ..segment_size))] (_.cover [/.remaining] (|> data (/.result (do <>.monad diff --git a/stdlib/source/test/lux/control/parser/cli.lux b/stdlib/source/test/lux/control/parser/cli.lux index 9c1247775..a70abb3b4 100644 --- a/stdlib/source/test/lux/control/parser/cli.lux +++ b/stdlib/source/test/lux/control/parser/cli.lux @@ -31,7 +31,7 @@ (<| (_.covering /._) (_.for [/.Parser]) (do {! random.monad} - [expected (\ ! map n\encoded random.nat) + [expected (\ ! each n\encoded random.nat) .let [random_dummy (random.only (|>> (text\= expected) not) (random.unicode 5))] dummy random_dummy diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux index b6a3768d4..99ea38f16 100644 --- a/stdlib/source/test/lux/control/parser/code.lux +++ b/stdlib/source/test/lux/control/parser/code.lux @@ -45,7 +45,7 @@ (_.for [/.Parser]) (`` ($_ _.and (do {! random.monad} - [expected (\ ! map code.bit random.bit)] + [expected (\ ! each code.bit random.bit)] (_.cover [/.result] (and (|> (/.result /.any (list expected)) (!expect (#try.Success _))) @@ -67,7 +67,7 @@ (!expect (#try.Failure _))))) ))] - [/.any /.this! (\ ! map code.bit random.bit) function.identity code.equivalence] + [/.any /.this! (\ ! each code.bit random.bit) function.identity code.equivalence] [/.bit /.bit! random.bit code.bit bit.equivalence] [/.nat /.nat! random.nat code.nat nat.equivalence] [/.int /.int! random.int code.int int.equivalence] @@ -115,7 +115,7 @@ (and (\ nat.equivalence = expected_local actual_local) (\ int.equivalence = expected_global actual_global))))))) (do {! random.monad} - [dummy (\ ! map code.bit random.bit)] + [dummy (\ ! each code.bit random.bit)] (_.cover [/.end?] (|> (/.result (do <>.monad [pre /.end? @@ -127,7 +127,7 @@ (!expect (^multi (#try.Success verdict) verdict))))) (do {! random.monad} - [dummy (\ ! map code.bit random.bit)] + [dummy (\ ! each code.bit random.bit)] (_.cover [/.end!] (and (|> (/.result /.end! (list)) (!expect (#try.Success []))) diff --git a/stdlib/source/test/lux/control/parser/environment.lux b/stdlib/source/test/lux/control/parser/environment.lux index ba846b8b2..a1652a95f 100644 --- a/stdlib/source/test/lux/control/parser/environment.lux +++ b/stdlib/source/test/lux/control/parser/environment.lux @@ -30,7 +30,7 @@ [expected random.nat] (_.cover [/.result] (|> (/.result (//\in expected) /.empty) - (\ try.functor map (n.= expected)) + (\ try.functor each (n.= expected)) (try.else false)))) (do random.monad [property (random.ascii/alpha 1) @@ -39,7 +39,7 @@ (|> /.empty (dictionary.has property expected) (/.result (/.property property)) - (\ try.functor map (text\= expected)) + (\ try.functor each (text\= expected)) (try.else false)))) (do random.monad [property (random.ascii/alpha 1)] diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux index a87396228..043f00979 100644 --- a/stdlib/source/test/lux/control/parser/json.lux +++ b/stdlib/source/test/lux/control/parser/json.lux @@ -46,7 +46,7 @@ (_.for [/.Parser]) (`` ($_ _.and (do {! random.monad} - [expected (\ ! map (|>> #json.String) (random.unicode 1))] + [expected (\ ! each (|>> #json.String) (random.unicode 1))] (_.cover [/.result /.any] (|> (/.result /.any expected) (!expect (^multi (#try.Success actual) @@ -102,17 +102,17 @@ (!expect (^multi (#try.Success actual) (\ (maybe.equivalence text.equivalence) = (#.Some expected) actual))))))) (do {! random.monad} - [size (\ ! map (n.% 10) random.nat) + [size (\ ! each (n.% 10) random.nat) expected (|> (random.unicode 1) (random.list size) - (\ ! map row.of_list))] + (\ ! each row.of_list))] (_.cover [/.array] (|> (/.result (/.array (<>.some /.string)) - (#json.Array (row\map (|>> #json.String) expected))) + (#json.Array (row\each (|>> #json.String) expected))) (!expect (^multi (#try.Success actual) (\ (row.equivalence text.equivalence) = expected (row.of_list actual))))))) (do {! random.monad} - [expected (\ ! map (|>> #json.String) (random.unicode 1))] + [expected (\ ! each (|>> #json.String) (random.unicode 1))] (_.cover [/.unconsumed_input] (|> (/.result (/.array /.any) (#json.Array (row expected expected))) (!expect (^multi (#try.Failure error) @@ -126,12 +126,12 @@ expected_number ..safe_frac expected_string (random.unicode 1) [boolean_field number_field string_field] (|> (random.set text.hash 3 (random.unicode 3)) - (\ ! map (|>> set.list - (case> (^ (list boolean_field number_field string_field)) - [boolean_field number_field string_field] + (\ ! each (|>> set.list + (case> (^ (list boolean_field number_field string_field)) + [boolean_field number_field string_field] - _ - (undefined)))))] + _ + (undefined)))))] (_.cover [/.object /.field] (|> (/.result (/.object ($_ <>.and (/.field boolean_field /.boolean) @@ -147,7 +147,7 @@ (\ frac.equivalence = expected_number actual_number) (\ text.equivalence = expected_string actual_string))))))) (do {! random.monad} - [size (\ ! map (n.% 10) random.nat) + [size (\ ! each (n.% 10) random.nat) keys (random.list size (random.unicode 1)) values (random.list size (random.unicode 1)) .let [expected (dictionary.of_list text.hash (list.zipped/2 keys values))]] @@ -155,7 +155,7 @@ (|> (/.result (/.dictionary /.string) (#json.Object (|> values - (list\map (|>> #json.String)) + (list\each (|>> #json.String)) (list.zipped/2 keys) (dictionary.of_list text.hash)))) (!expect (^multi (#try.Success actual) diff --git a/stdlib/source/test/lux/control/parser/synthesis.lux b/stdlib/source/test/lux/control/parser/synthesis.lux index e412ff262..82b851696 100644 --- a/stdlib/source/test/lux/control/parser/synthesis.lux +++ b/stdlib/source/test/lux/control/parser/synthesis.lux @@ -53,9 +53,9 @@ (def: random_environment (Random (Environment Synthesis)) (do {! random.monad} - [size (\ ! map (n.% 5) random.nat)] + [size (\ ! each (n.% 5) random.nat)] (|> ..random_variable - (\ ! map (|>> synthesis.variable)) + (\ ! each (|>> synthesis.variable)) (random.list size)))) (def: simple @@ -79,7 +79,7 @@ ))] [/.bit /.bit! random.bit synthesis.bit bit.equivalence] - [/.i64 /.i64! (\ ! map .i64 random.nat) synthesis.i64 i64.equivalence] + [/.i64 /.i64! (\ ! each .i64 random.nat) synthesis.i64 i64.equivalence] [/.f64 /.f64! random.safe_frac synthesis.f64 frac.equivalence] [/.text /.text! (random.unicode 1) synthesis.text text.equivalence] [/.local /.local! random.nat synthesis.variable/local n.equivalence] @@ -93,7 +93,7 @@ ($_ _.and (do {! random.monad} [expected_bit random.bit - expected_i64 (\ ! map .i64 random.nat) + expected_i64 (\ ! each .i64 random.nat) expected_f64 random.safe_frac expected_text (random.unicode 1)] (_.cover [/.tuple] @@ -137,14 +137,14 @@ (!expect (^multi (#try.Failure error) (exception.match? /.wrong_arity error)))))) (do {! random.monad} - [arity (\ ! map (|>> (n.% 10) ++) random.nat) + [arity (\ ! each (|>> (n.% 10) ++) random.nat) expected_offset random.nat expected_inits (random.list arity random.bit) expected_body (random.unicode 1)] (_.cover [/.loop] (and (|> (/.result (/.loop (<>.many /.bit) /.text) (list (synthesis.loop/scope [expected_offset - (list\map (|>> synthesis.bit) expected_inits) + (list\each (|>> synthesis.bit) expected_inits) (synthesis.text expected_body)]))) (!expect (^multi (#try.Success [actual_offset actual_inits actual_body]) (and (\ n.equivalence = expected_offset actual_offset) @@ -164,7 +164,7 @@ (_.for [/.Parser]) ($_ _.and (do {! random.monad} - [expected (\ ! map (|>> synthesis.i64) random.nat)] + [expected (\ ! each (|>> synthesis.i64) random.nat)] (_.cover [/.result /.any] (|> (/.result /.any (list expected)) (!expect (^multi (#try.Success actual) @@ -174,13 +174,13 @@ (!expect (^multi (#try.Failure error) (exception.match? /.empty_input error))))) (do {! random.monad} - [expected (\ ! map (|>> synthesis.i64) random.nat)] + [expected (\ ! each (|>> synthesis.i64) random.nat)] (_.cover [/.unconsumed_input] (|> (/.result /.any (list expected expected)) (!expect (^multi (#try.Failure error) (exception.match? /.unconsumed_input error)))))) (do {! random.monad} - [dummy (\ ! map (|>> synthesis.i64) random.nat)] + [dummy (\ ! each (|>> synthesis.i64) random.nat)] (_.cover [/.end! /.expected_empty_input] (and (|> (/.result /.end! (list)) (!expect (#try.Success _))) @@ -188,7 +188,7 @@ (!expect (^multi (#try.Failure error) (exception.match? /.expected_empty_input error))))))) (do {! random.monad} - [dummy (\ ! map (|>> synthesis.i64) random.nat)] + [dummy (\ ! each (|>> synthesis.i64) random.nat)] (_.cover [/.end?] (and (|> (/.result /.end? (list)) (!expect (#try.Success #1))) diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index b3767ab01..3b28d2390 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -61,7 +61,7 @@ (-> Text (/.Parser Text) Bit) (|> expected (/.result parser) - (\ try.functor map (text\= expected)) + (\ try.functor each (text\= expected)) (try.else false))) (def: (should_pass! expected parser) @@ -72,13 +72,13 @@ Test ($_ _.and (do {! random.monad} - [offset (\ ! map (n.% 50) random.nat) - range (\ ! map (|>> (n.% 50) (n.+ 10)) random.nat) + [offset (\ ! each (n.% 50) random.nat) + range (\ ! each (|>> (n.% 50) (n.+ 10)) random.nat) .let [limit (n.+ offset range)] - expected (\ ! map (|>> (n.% range) (n.+ offset) text.of_char) random.nat) + expected (\ ! each (|>> (n.% range) (n.+ offset) text.of_char) random.nat) out_of_range (case offset - 0 (\ ! map (|>> (n.% 10) ++ (n.+ limit) text.of_char) random.nat) - _ (\ ! map (|>> (n.% offset) text.of_char) random.nat))] + 0 (\ ! each (|>> (n.% 10) ++ (n.+ limit) text.of_char) random.nat) + _ (\ ! each (|>> (n.% offset) text.of_char) random.nat))] (_.cover [/.range] (and (..should_pass expected (/.range offset limit)) (..should_fail out_of_range (/.range offset limit))))) @@ -97,19 +97,19 @@ (and (..should_pass (text.of_char expected) /.lower) (..should_fail (text.of_char invalid) /.lower)))) (do {! random.monad} - [expected (\ ! map (n.% 10) random.nat) + [expected (\ ! each (n.% 10) random.nat) invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.decimal] (and (..should_pass (\ n.decimal encoded expected) /.decimal) (..should_fail (text.of_char invalid) /.decimal)))) (do {! random.monad} - [expected (\ ! map (n.% 8) random.nat) + [expected (\ ! each (n.% 8) random.nat) invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.octal] (and (..should_pass (\ n.octal encoded expected) /.octal) (..should_fail (text.of_char invalid) /.octal)))) (do {! random.monad} - [expected (\ ! map (n.% 16) random.nat) + [expected (\ ! each (n.% 16) random.nat) invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.hexadecimal] (and (..should_pass (\ n.hex encoded expected) /.hexadecimal) @@ -155,13 +155,13 @@ [.let [num_options 3] options (|> (random.char unicode.character) (random.set n.hash num_options) - (\ ! map (|>> set.list - (list\map text.of_char) - text.together))) - expected (\ ! map (function (_ value) - (|> options - (text.char (n.% num_options value)) - maybe.trusted)) + (\ ! each (|>> set.list + (list\each text.of_char) + text.together))) + expected (\ ! each (function (_ value) + (|> options + (text.char (n.% num_options value)) + maybe.trusted)) random.nat) invalid (random.only (function (_ char) (not (text.contains? (text.of_char char) options))) @@ -181,13 +181,13 @@ [.let [num_options 3] options (|> (random.char unicode.character) (random.set n.hash num_options) - (\ ! map (|>> set.list - (list\map text.of_char) - text.together))) - invalid (\ ! map (function (_ value) - (|> options - (text.char (n.% num_options value)) - maybe.trusted)) + (\ ! each (|>> set.list + (list\each text.of_char) + text.together))) + invalid (\ ! each (function (_ value) + (|> options + (text.char (n.% num_options value)) + maybe.trusted)) random.nat) expected (random.only (function (_ char) (not (text.contains? (text.of_char char) options))) @@ -210,26 +210,26 @@ (let [octal! (/.one_of! "01234567")] ($_ _.and (do {! random.monad} - [left (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat) - right (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat) + [left (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat) + right (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat) .let [expected (format left right)] invalid (|> random.nat - (\ ! map (n.% 16)) + (\ ! each (n.% 16)) (random.only (n.>= 8)) - (\ ! map (\ n.hex encoded)))] + (\ ! each (\ n.hex encoded)))] (_.cover [/.many /.many!] (and (..should_pass expected (/.many /.octal)) (..should_fail invalid (/.many /.octal)) (..should_pass! expected (/.many! octal!))))) (do {! random.monad} - [left (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat) - right (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat) + [left (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat) + right (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat) .let [expected (format left right)] invalid (|> random.nat - (\ ! map (n.% 16)) + (\ ! each (n.% 16)) (random.only (n.>= 8)) - (\ ! map (\ n.hex encoded)))] + (\ ! each (\ n.hex encoded)))] (_.cover [/.some /.some!] (and (..should_pass expected (/.some /.octal)) (..should_pass "" (/.some /.octal)) @@ -238,7 +238,7 @@ (..should_pass! expected (/.some! octal!)) (..should_pass! "" (/.some! octal!))))) (do {! random.monad} - [.let [octal (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat)] + [.let [octal (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat)] first octal second octal third octal] @@ -251,7 +251,7 @@ (..should_fail (format first second third) (/.exactly! 2 octal!)) (..should_fail (format first) (/.exactly! 2 octal!))))) (do {! random.monad} - [.let [octal (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat)] + [.let [octal (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat)] first octal second octal third octal] @@ -264,7 +264,7 @@ (..should_pass! (format first) (/.at_most! 2 octal!)) (..should_fail (format first second third) (/.at_most! 2 octal!))))) (do {! random.monad} - [.let [octal (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat)] + [.let [octal (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat)] first octal second octal third octal] @@ -277,7 +277,7 @@ (..should_pass! (format first second third) (/.at_least! 2 octal!)) (..should_fail (format first) (/.at_least! 2 octal!))))) (do {! random.monad} - [.let [octal (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat)] + [.let [octal (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat)] first octal second octal third octal] @@ -389,7 +389,7 @@ (/.this output))) (!expect (#try.Success _))))) (do {! random.monad} - [expected (\ ! map (|>> (n.% 8) (\ n.octal encoded)) random.nat)] + [expected (\ ! each (|>> (n.% 8) (\ n.octal encoded)) random.nat)] (_.cover [/.then] (|> (list (code.text expected)) (<c>.result (/.then /.octal <c>.text)) diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux index dc901e3c4..fd1706b0f 100644 --- a/stdlib/source/test/lux/control/parser/type.lux +++ b/stdlib/source/test/lux/control/parser/type.lux @@ -31,8 +31,8 @@ (def: primitive (Random Type) (|> (random.ascii/alpha_num 1) - (\ random.monad map (function (_ name) - (#.Primitive name (list)))))) + (\ random.monad each (function (_ name) + (#.Primitive name (list)))))) (def: matches Test @@ -166,7 +166,7 @@ Test (do {! random.monad} [not_polymorphic ..primitive - expected_inputs (\ ! map (|>> (n.% 10) ++) random.nat)] + expected_inputs (\ ! each (|>> (n.% 10) ++) random.nat)] ($_ _.and (_.cover [/.not_polymorphic] (and (|> (/.result (/.polymorphic /.any) diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index e92216696..ffc96e172 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -69,10 +69,10 @@ [[(//\in expected) (#xml.Text expected)]]) (do {! random.monad} - [expected (\ ! map (|>> #xml.Text) (random.ascii/alpha 1))] + [expected (\ ! each (|>> #xml.Text) (random.ascii/alpha 1))] (_.cover [/.any] (|> (/.result /.any (list expected)) - (try\map (xml\= expected)) + (try\each (xml\= expected)) (try.else false)))) (do {! random.monad} [expected ..random_tag] @@ -159,7 +159,7 @@ (//\in [])) _ (//.some /.any)] (in [])))] - repetitions (\ ! map (n.% 10) random.nat)] + repetitions (\ ! each (n.% 10) random.nat)] ($_ _.and (_.cover [/.somewhere] (|> (/.result parser diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index 555f30b4f..5cf65f56b 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -81,7 +81,7 @@ (<| (_.covering /._) (_.for [/.Region]) (do {! random.monad} - [expected_clean_ups (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1))))] + [expected_clean_ups (|> random.nat (\ ! each (|>> (n.% 100) (n.max 1))))] ($_ _.and (_.for [/.functor] ($functor.spec ..injection ..comparison (: (All [! r] @@ -107,8 +107,8 @@ (in (#try.Success []))))] outcome (/.run! ! (do {! (/.monad !)} - [_ (monad.map ! (/.acquire! //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups))] + [_ (monad.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) @@ -125,8 +125,8 @@ (in (#try.Success []))))] outcome (/.run! ! (do {! (/.monad !)} - [_ (monad.map ! (/.acquire! //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups)) + [_ (monad.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)] @@ -144,8 +144,8 @@ (in (#try.Success []))))] outcome (/.run! ! (do {! (/.monad !)} - [_ (monad.map ! (/.acquire! //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups)) + [_ (monad.each ! (/.acquire! //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups)) _ (/.except //@ ..oops [])] (in []))) actual_clean_ups (thread.read! clean_up_counter)] @@ -164,8 +164,8 @@ (exception.except ..oops [])))))] outcome (/.run! ! (do {! (/.monad !)} - [_ (monad.map ! (/.acquire! //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups))] + [_ (monad.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/control/remember.lux b/stdlib/source/test/lux/control/remember.lux index 045e2d0df..ae5240f7e 100644 --- a/stdlib/source/test/lux/control/remember.lux +++ b/stdlib/source/test/lux/control/remember.lux @@ -29,8 +29,8 @@ ["." /]]) (def: deadline (Random Date) random.date) -(def: message (Random Text) (random\map %.bit random.bit)) -(def: focus (Random Code) (random\map code.bit random.bit)) +(def: message (Random Text) (random\each %.bit random.bit)) +(def: focus (Random Code) (random\each code.bit random.bit)) (def: (memory macro deadline message focus) (-> Name Date Text (Maybe Code) Code) diff --git a/stdlib/source/test/lux/control/state.lux b/stdlib/source/test/lux/control/state.lux index eda78cbeb..10bda7445 100644 --- a/stdlib/source/test/lux/control/state.lux +++ b/stdlib/source/test/lux/control/state.lux @@ -82,7 +82,7 @@ (def: loops Test (do {! random.monad} - [limit (|> random.nat (\ ! map (n.% 10))) + [limit (|> random.nat (\ ! each (n.% 10))) .let [condition (do /.monad [state /.get] (in (n.< limit state)))]] diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 9d843b540..6ee71541c 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -79,13 +79,13 @@ Test (<| (_.covering /._) (do {! random.monad} - [.let [gen_size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 8))))] + [.let [gen_size (|> random.nat (\ ! each (|>> (n.% 100) (n.max 8))))] size gen_size sample (..random size) value random.nat - .let [gen_idx (|> random.nat (\ ! map (n.% size)))] + .let [gen_idx (|> random.nat (\ ! each (n.% size)))] offset gen_idx - length (\ ! map (n.% (n.- offset size)) random.nat)] + length (\ ! each (n.% (n.- offset size)) random.nat)] (_.for [/.Binary] ($_ _.and (_.for [/.equivalence] @@ -121,8 +121,8 @@ reader (function (_ binary idx) (/.read/8! idx binary))] (and (n.= length (/.size random_slice)) - (case [(monad.map try.monad (|>> (n.+ offset) (reader sample)) idxs) - (monad.map try.monad (reader random_slice) idxs)] + (case [(monad.each try.monad (|>> (n.+ offset) (reader sample)) idxs) + (monad.each try.monad (reader random_slice) idxs)] [(#try.Success binary_vals) (#try.Success slice_vals)] (\ (list.equivalence n.equivalence) = binary_vals slice_vals) diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index c7fad1619..03ff479ff 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -29,7 +29,7 @@ (def: bounded_size (Random Nat) - (\ random.monad map (|>> (n.% 100) (n.+ 1)) + (\ random.monad each (|>> (n.% 100) (n.+ 1)) random.nat)) (def: structures @@ -169,7 +169,7 @@ _ false))) (do ! - [occupancy (\ ! map (n.% (++ size)) random.nat)] + [occupancy (\ ! each (n.% (++ size)) random.nat)] (_.cover [/.occupancy /.vacancy] (let [the_array (loop [output (: (Array Nat) (/.empty size)) @@ -189,7 +189,7 @@ (|> the_array /.list /.of_list (\ (/.equivalence n.equivalence) = the_array))))) (do ! - [amount (\ ! map (n.% (++ size)) random.nat)] + [amount (\ ! each (n.% (++ size)) random.nat)] (_.cover [/.copy!] (let [copy (: (Array Nat) (/.empty size))] diff --git a/stdlib/source/test/lux/data/collection/bits.lux b/stdlib/source/test/lux/data/collection/bits.lux index c0e54e3bb..3d28272fb 100644 --- a/stdlib/source/test/lux/data/collection/bits.lux +++ b/stdlib/source/test/lux/data/collection/bits.lux @@ -17,16 +17,16 @@ (def: (size min max) (-> Nat Nat (Random Nat)) (|> random.nat - (\ random.monad map (|>> (n.% (++ max)) (n.max min))))) + (\ random.monad each (|>> (n.% (++ max)) (n.max min))))) (def: .public random (Random Bits) (do {! random.monad} - [size (\ ! map (n.% 1,000) random.nat)] + [size (\ ! each (n.% 1,000) random.nat)] (case size 0 (in /.empty) _ (do {! random.monad} - [idx (|> random.nat (\ ! map (n.% size)))] + [idx (|> random.nat (\ ! each (n.% size)))] (in (/.one idx /.empty)))))) (def: .public test @@ -47,8 +47,8 @@ (/.empty? /.empty)) (do {! random.monad} - [size (\ ! map (|>> (n.% 1,000) ++) random.nat) - idx (\ ! map (n.% size) random.nat) + [size (\ ! each (|>> (n.% 1,000) ++) random.nat) + idx (\ ! each (n.% size) random.nat) sample ..random] ($_ _.and (_.cover [/.bit /.one] diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index 446c4e354..60312b812 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -31,7 +31,7 @@ (def: for_dictionaries Test (do {! random.monad} - [.let [capped_nat (\ random.monad map (n.% 100) random.nat)] + [.let [capped_nat (\ random.monad each (n.% 100) random.nat)] size capped_nat dict (random.dictionary n.hash size random.nat capped_nat) non_key (random.only (|>> (/.key? dict) not) @@ -71,7 +71,7 @@ unique_keys! (|> entries - (list\map product.left) + (list\each product.left) (set.of_list n.hash) set.size (n.= (/.size dict))) @@ -80,7 +80,7 @@ (list.every? (function (_ [key value]) (|> dict (/.value key) - (maybe\map (n.= value)) + (maybe\each (n.= value)) (maybe.else false))) entries)] (and correct_size! @@ -112,7 +112,7 @@ (let [merging_with_oneself (let [(^open ".") (/.equivalence n.equivalence)] (= dict (/.merged dict dict))) overwritting_keys (let [dict' (|> dict /.entries - (list\map (function (_ [k v]) [k (++ v)])) + (list\each (function (_ [k v]) [k (++ v)])) (/.of_list n.hash)) (^open ".") (/.equivalence n.equivalence)] (= dict' (/.merged dict' dict)))] @@ -133,7 +133,7 @@ (def: for_entries Test (do random.monad - [.let [capped_nat (\ random.monad map (n.% 100) random.nat)] + [.let [capped_nat (\ random.monad each (n.% 100) random.nat)] size capped_nat dict (random.dictionary n.hash size random.nat capped_nat) non_key (random.only (|>> (/.key? dict) not) @@ -253,7 +253,7 @@ (<| (_.covering /._) (_.for [/.Dictionary]) (do random.monad - [.let [capped_nat (\ random.monad map (n.% 100) random.nat)] + [.let [capped_nat (\ random.monad each (n.% 100) random.nat)] size capped_nat dict (random.dictionary n.hash size random.nat capped_nat) non_key (random.only (|>> (/.key? dict) not) diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 7f6178f8e..739756640 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -43,7 +43,7 @@ (<| (_.covering /._) (_.for [/.Dictionary]) (do {! random.monad} - [size (\ ! map (n.% 100) random.nat) + [size (\ ! each (n.% 100) random.nat) keys (random.set n.hash size random.nat) values (random.set n.hash size random.nat) extra_key (random.only (|>> (set.member? keys) not) @@ -56,7 +56,7 @@ sorted_pairs (list.sorted (function (_ [left _] [right _]) (n.< left right)) pairs) - sorted_values (list\map product.right sorted_pairs) + sorted_values (list\each product.right sorted_pairs) (^open "list\.") (list.equivalence (: (Equivalence [Nat Nat]) (function (_ [kr vr] [ks vs]) (and (n.= kr ks) @@ -132,6 +132,6 @@ (/.has extra_key extra_value) (/.revised extra_key (n.+ shift)) (/.value extra_key) - (maybe\map (n.= (n.+ shift extra_value))) + (maybe\each (n.= (n.+ shift extra_value))) (maybe.else false))) )))) diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux index 2172fbd44..f83e4cf82 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux @@ -35,7 +35,7 @@ (_.for [/.PList]) (do {! random.monad} [.let [gen_key (random.ascii/alpha 10)] - size (\ ! map (n.% 100) random.nat) + size (\ ! each (n.% 100) random.nat) sample (..random size gen_key random.nat) .let [keys (|> sample /.keys (set.of_list text.hash))] @@ -75,14 +75,14 @@ (|> sample (/.has extra_key extra_value) (/.value extra_key) - (maybe\map (n.= extra_value)) + (maybe\each (n.= extra_value)) (maybe.else false))) (_.cover [/.revised] (|> sample (/.has extra_key extra_value) (/.revised extra_key (n.+ shift)) (/.value extra_key) - (maybe\map (n.= (n.+ shift extra_value))) + (maybe\each (n.= (n.+ shift extra_value))) (maybe.else false))) (_.cover [/.lacks] (|> sample diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index 41139da07..1f6749dc3 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -34,7 +34,7 @@ (def: bounded_size (Random Nat) - (\ random.monad map (n.% 100) + (\ random.monad each (n.% 100) random.nat)) (def: random @@ -43,7 +43,7 @@ [size ..bounded_size] (|> random.nat (random.set n.hash size) - (\ ! map set.list)))) + (\ ! each set.list)))) (def: signatures Test @@ -52,7 +52,7 @@ ($equivalence.spec (/.equivalence n.equivalence) ..random)) (_.for [/.hash] (|> random.nat - (\ random.monad map (|>> list)) + (\ random.monad each (|>> list)) ($hash.spec (/.hash n.hash)))) (_.for [/.monoid] ($monoid.spec (/.equivalence n.equivalence) /.monoid ..random)) @@ -88,7 +88,7 @@ (do {! random.monad} [size ..bounded_size .let [(^open "/\.") (/.equivalence n.equivalence)] - sample (\ ! map set.list (random.set n.hash size random.nat))] + sample (\ ! each set.list (random.set n.hash size random.nat))] ($_ _.and (_.cover [/.size] (n.= size (/.size sample))) @@ -158,11 +158,11 @@ has_correct_indices! (/\= (/.indices (/.size enumeration)) - (/\map product.left enumeration)) + (/\each product.left enumeration)) has_correct_values! (/\= sample - (/\map product.right enumeration))] + (/\each product.right enumeration))] (and has_correct_indices! has_correct_values!))) (_.cover [/.item] @@ -184,8 +184,8 @@ [sample (random.only (|>> /.size (n.> 0)) ..random) .let [size (/.size sample)] - idx (\ ! map (n.% size) random.nat) - sub_size (\ ! map (|>> (n.% size) ++) random.nat)] + idx (\ ! each (n.% size) random.nat) + sub_size (\ ! each (|>> (n.% size) ++) random.nat)] ($_ _.and (_.cover [/.only] (let [positives (/.only n.even? sample) @@ -205,19 +205,19 @@ (_.cover [/.split_at] (let [[left right] (/.split_at idx sample)] (/\= sample - (/\compose left right)))) + (/\composite left right)))) (_.cover [/.split_when] (let [[left right] (/.split_when n.even? sample)] (/\= sample - (/\compose left right)))) + (/\composite left right)))) (_.cover [/.first /.after] (/\= sample - (/\compose (/.first idx sample) - (/.after idx sample)))) + (/\composite (/.first idx sample) + (/.after idx sample)))) (_.cover [/.while /.until] (/\= sample - (/\compose (/.while n.even? sample) - (/.until n.even? sample)))) + (/\composite (/.while n.even? sample) + (/.until n.even? sample)))) (_.cover [/.sub] (let [subs (/.sub sub_size sample)] (and (/.every? (|>> /.size (n.<= sub_size)) subs) @@ -293,9 +293,9 @@ can_extract_values! (and (/\= (/.first zipped::size sample/0) - (/\map product.left zipped)) + (/\each product.left zipped)) (/\= (/.first zipped::size sample/1) - (/\map product.right zipped)))] + (/\each product.right zipped)))] (and size_of_smaller_list! can_extract_values!))) (_.cover [/.zipped/3] @@ -311,11 +311,11 @@ can_extract_values! (and (/\= (/.first zipped::size sample/0) - (/\map product.left zipped)) + (/\each product.left zipped)) (/\= (/.first zipped::size sample/1) - (/\map (|>> product.right product.left) zipped)) + (/\each (|>> product.right product.left) zipped)) (/\= (/.first zipped::size sample/2) - (/\map (|>> product.right product.right) zipped)))] + (/\each (|>> product.right product.right) zipped)))] (and size_of_smaller_list! can_extract_values!))) (_.cover [/.zipped] @@ -327,14 +327,14 @@ ((/.zipped 3) sample/0 sample/1 sample/2)))) (_.cover [/.zipped_with/2] - (/\= (/\map (function (_ [left right]) - (+/2 left right)) - (/.zipped/2 sample/0 sample/1)) + (/\= (/\each (function (_ [left right]) + (+/2 left right)) + (/.zipped/2 sample/0 sample/1)) (/.zipped_with/2 +/2 sample/0 sample/1))) (_.cover [/.zipped_with/3] - (/\= (/\map (function (_ [left mid right]) - (+/3 left mid right)) - (/.zipped/3 sample/0 sample/1 sample/2)) + (/\= (/\each (function (_ [left mid right]) + (+/3 left mid right)) + (/.zipped/3 sample/0 sample/1 sample/2)) (/.zipped_with/3 +/3 sample/0 sample/1 sample/2))) (_.cover [/.zipped_with] (and (/\= (/.zipped_with/2 +/2 sample/0 sample/1) @@ -342,9 +342,9 @@ (/\= (/.zipped_with/3 +/3 sample/0 sample/1 sample/2) ((/.zipped_with 3) +/3 sample/0 sample/1 sample/2)))) (_.cover [/.together] - (and (/\= (/\compose sample/0 sample/1) + (and (/\= (/\composite sample/0 sample/1) (/.together (list sample/0 sample/1))) - (/\= ($_ /\compose sample/0 sample/1 sample/2) + (/\= ($_ /\composite sample/0 sample/1 sample/2) (/.together (list sample/0 sample/1 sample/2))))) )))) @@ -363,7 +363,7 @@ (_.cover [/.one] (case [(|> sample (/.only n.even?) - (/\map (\ n.decimal encoded)) + (/\each (\ n.decimal encoded)) /.head) (/.one choose sample)] [(#.Some expected) (#.Some actual)] @@ -378,7 +378,7 @@ (\ (/.equivalence text.equivalence) = (|> sample (/.only n.even?) - (/\map (\ n.decimal encoded))) + (/\each (\ n.decimal encoded))) (/.all choose sample))) (_.cover [/.example] (case (/.example n.even? sample) @@ -423,9 +423,9 @@ #.None)) 0))))) (_.cover [/.mixes] - (/\= (/\map (function (_ index) - (\ /.mix mix n.+ 0 (/.first index sample))) - (/.indices (++ (/.size sample)))) + (/\= (/\each (function (_ index) + (\ /.mix mix n.+ 0 (/.first index sample))) + (/.indices (++ (/.size sample)))) (/.mixes n.+ 0 sample))) (do random.monad [expected random.nat diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index cdb7198b5..064f1891e 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -28,7 +28,7 @@ (<| (_.covering /._) (_.for [/.Queue]) (do {! random.monad} - [size (\ ! map (n.% 100) random.nat) + [size (\ ! each (n.% 100) random.nat) members (random.set n.hash size random.nat) non_member (random.only (|>> (set.member? members) not) random.nat) @@ -88,7 +88,7 @@ has_expected_order! (\ (list.equivalence n.equivalence) = - (list\compose (/.list sample) (list non_member)) + (list\composite (/.list sample) (list non_member)) (/.list pushed))] (and size_increases! new_member_is_identified! diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux index 1e199d23e..da99e408d 100644 --- a/stdlib/source/test/lux/data/collection/queue/priority.lux +++ b/stdlib/source/test/lux/data/collection/queue/priority.lux @@ -31,7 +31,7 @@ (<| (_.covering /._) (_.for [/.Queue]) (do {! random.monad} - [size (\ ! map (n.% 100) random.nat) + [size (\ ! each (n.% 100) random.nat) sample (..random size) non_member_priority random.nat non_member (random.only (|>> (/.member? n.equivalence sample) not) @@ -80,7 +80,7 @@ (/.end /.min min_member) (/.end /.max max_member) /.front - (maybe\map (n.= max_member)) + (maybe\each (n.= max_member)) (maybe.else false))) (_.cover [/.min] (|> /.empty @@ -88,7 +88,7 @@ (/.end /.min min_member) /.next /.front - (maybe\map (n.= min_member)) + (maybe\each (n.= min_member)) (maybe.else false))) )) )))) diff --git a/stdlib/source/test/lux/data/collection/row.lux b/stdlib/source/test/lux/data/collection/row.lux index a8ff3a7ab..b5ba88171 100644 --- a/stdlib/source/test/lux/data/collection/row.lux +++ b/stdlib/source/test/lux/data/collection/row.lux @@ -29,7 +29,7 @@ (def: signatures Test (do {! random.monad} - [size (\ ! map (n.% 100) random.nat)] + [size (\ ! each (n.% 100) random.nat)] ($_ _.and (_.for [/.equivalence] ($equivalence.spec (/.equivalence n.equivalence) (random.row size random.nat))) @@ -48,7 +48,7 @@ (def: whole Test (do {! random.monad} - [size (\ ! map (n.% 100) random.nat) + [size (\ ! each (n.% 100) random.nat) sample (random.set n.hash size random.nat) .let [sample (|> sample set.list /.of_list)] .let [(^open "/\.") (/.equivalence n.equivalence)]] @@ -81,10 +81,10 @@ (def: index_based Test (do {! random.monad} - [size (\ ! map (|>> (n.% 100) ++) random.nat)] + [size (\ ! each (|>> (n.% 100) ++) random.nat)] ($_ _.and (do ! - [good_index (|> random.nat (\ ! map (n.% size))) + [good_index (|> random.nat (\ ! each (n.% size))) .let [bad_index (n.+ size good_index)] sample (random.set n.hash size random.nat) non_member (random.only (|>> (set.member? sample) not) @@ -134,7 +134,7 @@ (<| (_.covering /._) (_.for [/.Row]) (do {! random.monad} - [size (\ ! map (|>> (n.% 100) ++) random.nat)] + [size (\ ! each (|>> (n.% 100) ++) random.nat)] ($_ _.and ..signatures ..whole diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index fc67cf27d..ace5fa0cb 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -45,9 +45,9 @@ (let [(^open "list\.") (list.equivalence n.equivalence)]) (do {! random.monad} [repeated random.nat - index (\ ! map (n.% 100) random.nat) - size (\ ! map (|>> (n.% 10) ++) random.nat) - offset (\ ! map (n.% 100) random.nat) + index (\ ! each (n.% 100) random.nat) + size (\ ! each (|>> (n.% 10) ++) random.nat) + offset (\ ! each (n.% 100) random.nat) cycle_start random.nat cycle_next (random.list size random.nat)] ($_ _.and @@ -94,7 +94,7 @@ (list\= (enum.range n.enum (++ offset) (n.+ size offset)) (/.first size (/.tail (..iterations ++ offset))))) (_.cover [/.only] - (list\= (list\map (n.* 2) (enum.range n.enum 0 (-- size))) + (list\= (list\each (n.* 2) (enum.range n.enum 0 (-- size))) (/.first size (/.only n.even? (..iterations ++ 0))))) (_.cover [/.partition] (let [[evens odds] (/.partition n.even? (..iterations ++ 0))] @@ -106,7 +106,7 @@ (let [(^open "/\.") /.functor (^open "list\.") (list.equivalence text.equivalence)] (list\= (/.first size - (/\map %.nat (..iterations ++ offset))) + (/\each %.nat (..iterations ++ offset))) (/.first size (/.iterations (function (_ n) [(++ n) (%.nat n)]) offset))))) diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index 66ecd0ca3..2ed9fb511 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -22,7 +22,7 @@ (def: gen_nat (Random Nat) - (\ random.monad map (n.% 100) + (\ random.monad each (n.% 100) random.nat)) (def: .public test @@ -36,7 +36,7 @@ ($equivalence.spec /.equivalence (random.set n.hash size random.nat))) (_.for [/.hash] (|> random.nat - (\ random.monad map (|>> list (/.of_list n.hash))) + (\ random.monad each (|>> list (/.of_list n.hash))) ($hash.spec /.hash))) (_.for [/.monoid] ($monoid.spec /.equivalence (/.monoid n.hash) (random.set n.hash size random.nat))) @@ -52,13 +52,13 @@ (_.cover [/.empty] (/.empty? (/.empty n.hash))) (do ! - [hash (\ ! map (function (_ constant) - (: (Hash Nat) - (implementation - (def: &equivalence n.equivalence) - - (def: (hash _) - constant)))) + [hash (\ ! each (function (_ constant) + (: (Hash Nat) + (implementation + (def: &equivalence n.equivalence) + + (def: (hash _) + constant)))) random.nat)] (_.cover [/.member_hash] (same? hash (/.member_hash (/.empty hash))))) diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux index 0afe973ef..55928932f 100644 --- a/stdlib/source/test/lux/data/collection/set/multi.lux +++ b/stdlib/source/test/lux/data/collection/set/multi.lux @@ -23,7 +23,7 @@ (def: count (Random Nat) - (\ random.monad map (|>> (n.% 10) ++) random.nat)) + (\ random.monad each (|>> (n.% 10) ++) random.nat)) (def: .public (random size hash count element) (All [a] (-> Nat (Hash a) (Random Nat) (Random a) (Random (/.Set a)))) @@ -39,21 +39,21 @@ (def: signature Test (do {! random.monad} - [diversity (\ ! map (n.% 10) random.nat)] + [diversity (\ ! each (n.% 10) random.nat)] ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence (..random diversity n.hash ..count random.nat))) (_.for [/.hash] (|> random.nat - (\ random.monad map (function (_ single) - (/.has 1 single (/.empty n.hash)))) + (\ random.monad each (function (_ single) + (/.has 1 single (/.empty n.hash)))) ($hash.spec /.hash))) ))) (def: composition Test (do {! random.monad} - [diversity (\ ! map (n.% 10) random.nat) + [diversity (\ ! each (n.% 10) random.nat) sample (..random diversity n.hash ..count random.nat) another (..random diversity n.hash ..count random.nat)] (`` ($_ _.and @@ -113,12 +113,12 @@ (<| (_.covering /._) (_.for [/.Set]) (do {! random.monad} - [diversity (\ ! map (n.% 10) random.nat) + [diversity (\ ! each (n.% 10) random.nat) sample (..random diversity n.hash ..count random.nat) non_member (random.only (predicate.complement (set.member? (/.support sample))) random.nat) addition_count ..count - partial_removal_count (\ ! map (n.% addition_count) random.nat) + partial_removal_count (\ ! each (n.% addition_count) random.nat) another (..random diversity n.hash ..count random.nat)] ($_ _.and (_.cover [/.list /.of_list] diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index b753ac1af..31b8b0405 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -21,7 +21,7 @@ (def: size (random.Random Nat) - (\ random.monad map (n.% 100) random.nat)) + (\ random.monad each (n.% 100) random.nat)) (def: .public (random size &order gen_value) (All [a] (-> Nat (Order a) (Random a) (Random (Set a)))) @@ -47,7 +47,7 @@ non_memberL (random.only (|>> (//.member? usetL) not) random.nat) .let [listL (//.list usetL)] - listR (|> (random.set n.hash sizeR random.nat) (\ ! map //.list)) + listR (|> (random.set n.hash sizeR random.nat) (\ ! each //.list)) .let [(^open "/\.") /.equivalence setL (/.of_list n.order listL) setR (/.of_list n.order listR) diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux index 79355156f..a6aa8c1dc 100644 --- a/stdlib/source/test/lux/data/collection/stack.lux +++ b/stdlib/source/test/lux/data/collection/stack.lux @@ -27,7 +27,7 @@ (<| (_.covering /._) (_.for [/.Stack]) (do random.monad - [size (\ random.monad map (n.% 100) random.nat) + [size (\ random.monad each (n.% 100) random.nat) sample (random.stack size random.nat) expected_top random.nat] ($_ _.and diff --git a/stdlib/source/test/lux/data/collection/tree.lux b/stdlib/source/test/lux/data/collection/tree.lux index be610c25d..d48a8d208 100644 --- a/stdlib/source/test/lux/data/collection/tree.lux +++ b/stdlib/source/test/lux/data/collection/tree.lux @@ -23,13 +23,13 @@ (All [a] (-> (Random a) (Random [Nat (Tree a)]))) (do {! random.monad} [value gen_value - num_children (\ ! map (n.% 2) random.nat) + num_children (\ ! each (n.% 2) random.nat) children (random.list num_children (tree gen_value))] (in [(|> children - (list\map product.left) + (list\each product.left) (list\mix n.+ 1)) {#/.value value - #/.children (list\map product.right children)}]))) + #/.children (list\each product.right children)}]))) (def: .public test Test @@ -38,7 +38,7 @@ ($_ _.and (_.for [/.equivalence] (|> (..tree random.nat) - (\ random.monad map product.right) + (\ random.monad each product.right) ($equivalence.spec (/.equivalence n.equivalence)))) (_.for [/.mix] ($mix.spec /.leaf /.equivalence /.mix)) @@ -58,12 +58,12 @@ (/.flat (/.leaf expected))))) (do {! random.monad} [value random.nat - num_children (\ ! map (n.% 3) random.nat) + num_children (\ ! each (n.% 3) random.nat) children (random.list num_children random.nat)] (_.cover [/.branch] (\ (list.equivalence n.equivalence) = (list& value children) - (/.flat (/.branch value (list\map /.leaf children)))))) + (/.flat (/.branch value (list\each /.leaf children)))))) (do random.monad [expected/0 random.nat expected/1 random.nat diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux index 53631edbf..5ec0569bb 100644 --- a/stdlib/source/test/lux/data/collection/tree/finger.lux +++ b/stdlib/source/test/lux/data/collection/tree/finger.lux @@ -45,7 +45,7 @@ (_.cover [/.tag] (and (text\= tag_left (/.tag (\ ..builder leaf tag_left expected_left))) - (text\= (text\compose tag_left tag_right) + (text\= (text\composite tag_left tag_right) (/.tag (\ ..builder branch (\ ..builder leaf tag_left expected_left) (\ ..builder leaf tag_right expected_right)))))) @@ -96,13 +96,13 @@ (let [can_find_correct_one! (|> (\ ..builder leaf tag_left expected_left) (/.one (text.contains? tag_left)) - (maybe\map (n.= expected_left)) + (maybe\each (n.= expected_left)) (maybe.else false)) cannot_find_incorrect_one! (|> (\ ..builder leaf tag_right expected_right) (/.one (text.contains? tag_left)) - (maybe\map (n.= expected_left)) + (maybe\each (n.= expected_left)) (maybe.else false) not) @@ -111,7 +111,7 @@ (\ ..builder leaf tag_left expected_left) (\ ..builder leaf tag_right expected_right)) (/.one (text.contains? tag_left)) - (maybe\map (n.= expected_left)) + (maybe\each (n.= expected_left)) (maybe.else false)) can_find_right! @@ -119,7 +119,7 @@ (\ ..builder leaf tag_left expected_left) (\ ..builder leaf tag_right expected_right)) (/.one (text.contains? tag_right)) - (maybe\map (n.= expected_right)) + (maybe\each (n.= expected_right)) (maybe.else false))] (and can_find_correct_one! cannot_find_incorrect_one! diff --git a/stdlib/source/test/lux/data/collection/tree/zipper.lux b/stdlib/source/test/lux/data/collection/tree/zipper.lux index 2b20582e9..d134be2ca 100644 --- a/stdlib/source/test/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/test/lux/data/collection/tree/zipper.lux @@ -163,7 +163,7 @@ (^open "list\.") (list.equivalence n.equivalence)]] ($_ _.and (_.for [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (\ ! map (|>> product.right /.zipper) (//.tree random.nat)))) + ($equivalence.spec (/.equivalence n.equivalence) (\ ! each (|>> product.right /.zipper) (//.tree random.nat)))) (_.for [/.functor] ($functor.spec (|>> tree.leaf /.zipper) /.equivalence /.functor)) (_.for [/.comonad] @@ -197,7 +197,7 @@ (|> sample /.zipper /.end - (maybe\map /.end?) + (maybe\each /.end?) (maybe.else false)))) (_.cover [/.interpose] (let [cursor (|> (tree.branch dummy (list (tree.leaf dummy))) diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index 67158dc10..2665beb41 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -26,7 +26,7 @@ (def: .public random (Random /.Color) (|> ($_ random.and random.nat random.nat random.nat) - (\ random.monad map /.of_rgb))) + (\ random.monad each /.of_rgb))) (def: scale (-> Nat Frac) @@ -131,15 +131,15 @@ Test (_.for [/.Spread /.Palette] (do {! random.monad} - [eH (\ ! map (|>> f.abs (f.% +0.9) (f.+ +0.05)) + [eH (\ ! each (|>> f.abs (f.% +0.9) (f.+ +0.05)) random.safe_frac) .let [eS +0.5] - variations (\ ! map (|>> (n.% 3) (n.+ 2)) random.nat) + variations (\ ! each (|>> (n.% 3) (n.+ 2)) random.nat) .let [max_spread (f./ (|> variations ++ .int int.frac) +1.0) min_spread (f./ +2.0 max_spread) spread_space (f.- min_spread max_spread)] - spread (\ ! map (|>> f.abs (f.% spread_space) (f.+ min_spread)) + spread (\ ! each (|>> f.abs (f.% spread_space) (f.+ min_spread)) random.safe_frac)] (`` ($_ _.and (~~ (template [<brightness> <palette>] diff --git a/stdlib/source/test/lux/data/format/binary.lux b/stdlib/source/test/lux/data/format/binary.lux index 107d95714..842186da7 100644 --- a/stdlib/source/test/lux/data/format/binary.lux +++ b/stdlib/source/test/lux/data/format/binary.lux @@ -23,7 +23,7 @@ (def: random (Random /.Specification) - (\ random.monad map /.nat random.nat)) + (\ random.monad each /.nat random.nat)) (def: .public test Test diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index 9e5a03843..9b885e9de 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -36,7 +36,7 @@ (random.rec (function (_ recur) (do {! random.monad} - [size (\ ! map (n.% 2) random.nat)] + [size (\ ! each (n.% 2) random.nat)] ($_ random.or (\ ! in []) random.bit @@ -85,20 +85,20 @@ (|> expected /.format (\ /.codec decoded) - (try\map (\= expected)) + (try\each (\= expected)) (try.else false)))) (do random.monad [keys (random.set text.hash 3 (random.ascii/alpha 1)) values (random.set frac.hash 3 random.safe_frac) .let [expected (list.zipped/2 (set.list keys) - (list\map (|>> #/.Number) (set.list values))) + (list\each (|>> #/.Number) (set.list values))) object (/.object expected)]] ($_ _.and (_.cover [/.object /.fields] (case (/.fields object) (#try.Success actual) (\ (list.equivalence text.equivalence) = - (list\map product.left expected) + (list\each product.left expected) actual) (#try.Failure error) @@ -106,7 +106,7 @@ (_.cover [/.field] (list.every? (function (_ [key expected]) (|> (/.field key object) - (try\map (\= expected)) + (try\each (\= expected)) (try.else false))) expected)) )) @@ -122,7 +122,7 @@ .let [can_find_known_key! (|> object (/.field key) - (try\map (\= (#/.Number expected))) + (try\each (\= (#/.Number expected))) (try.else false)) cannot_find_unknown_key! @@ -141,7 +141,7 @@ (_.cover [<type> <field>] (|> (/.object (list [key (<tag> value)])) (<field> key) - (try\map (\ <equivalence> = value)) + (try\each (\ <equivalence> = value)) (try.else false))))] [/.Boolean /.boolean_field #/.Boolean random.bit bit.equivalence] diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index 7a84f12fd..2567d277f 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -108,8 +108,8 @@ Test (_.for [/.Small] (do {! random.monad} - [expected (|> random.nat (\ ! map (n.% /.small_limit))) - invalid (|> random.nat (\ ! map (n.max /.small_limit)))] + [expected (|> random.nat (\ ! each (n.% /.small_limit))) + invalid (|> random.nat (\ ! each (n.max /.small_limit)))] (`` ($_ _.and (_.cover [/.small /.from_small] (case (/.small expected) @@ -132,8 +132,8 @@ Test (_.for [/.Big] (do {! random.monad} - [expected (|> random.nat (\ ! map (n.% /.big_limit))) - invalid (|> random.nat (\ ! map (n.max /.big_limit)))] + [expected (|> random.nat (\ ! each (n.% /.big_limit))) + invalid (|> random.nat (\ ! each (n.max /.big_limit)))] (`` ($_ _.and (_.cover [/.big /.from_big] (case (/.big expected) @@ -158,10 +158,10 @@ Test (do {! random.monad} [expected_path (random.ascii/lower (-- /.path_size)) - expected_moment (\ ! map (|>> (n.% 1,0,00,00,00,00,000) .int instant.of_millis) + expected_moment (\ ! each (|>> (n.% 1,0,00,00,00,00,000) .int instant.of_millis) random.nat) chunk (random.ascii/lower chunk_size) - chunks (\ ! map (n.% 100) random.nat) + chunks (\ ! each (n.% 100) random.nat) .let [content (|> chunk (list.repeated chunks) text.together @@ -402,11 +402,11 @@ (|> row.empty (format.result /.writer) (<b>.result /.parser) - (\ try.monad map row.empty?) + (\ try.monad each row.empty?) (try.else false))) (_.cover [/.invalid_end_of_archive] (let [dump (format.result /.writer row.empty)] - (case (<b>.result /.parser (binary\compose dump dump)) + (case (<b>.result /.parser (binary\composite dump dump)) (#try.Success _) false diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux index 0ce833e92..0d9f9ead4 100644 --- a/stdlib/source/test/lux/data/format/xml.lux +++ b/stdlib/source/test/lux/data/format/xml.lux @@ -36,13 +36,13 @@ (def: char (Random Nat) (do {! random.monad} - [idx (|> random.nat (\ ! map (n.% (text.size char_range))))] + [idx (|> random.nat (\ ! each (n.% (text.size char_range))))] (in (maybe.trusted (text.char idx char_range))))) (def: (size bottom top) (-> Nat Nat (Random Nat)) (let [constraint (|>> (n.% top) (n.max bottom))] - (random\map constraint random.nat))) + (random\each constraint random.nat))) (def: (text bottom top) (-> Nat Nat (Random Text)) diff --git a/stdlib/source/test/lux/data/name.lux b/stdlib/source/test/lux/data/name.lux index 0a882efaf..ef4057d1c 100644 --- a/stdlib/source/test/lux/data/name.lux +++ b/stdlib/source/test/lux/data/name.lux @@ -30,12 +30,12 @@ (<| (_.covering /._) (do {! random.monad} [... First Name - sizeM1 (|> random.nat (\ ! map (n.% 100))) - sizeS1 (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1)))) + sizeM1 (|> random.nat (\ ! each (n.% 100))) + sizeS1 (|> random.nat (\ ! each (|>> (n.% 100) (n.max 1)))) (^@ name1 [module1 short1]) (..random sizeM1 sizeS1) ... Second Name - sizeM2 (|> random.nat (\ ! map (n.% 100))) - sizeS2 (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1)))) + sizeM2 (|> random.nat (\ ! each (n.% 100))) + sizeS2 (|> random.nat (\ ! each (|>> (n.% 100) (n.max 1)))) (^@ name2 [module2 short2]) (..random sizeM2 sizeS2)] (_.for [.Name] ($_ _.and @@ -43,7 +43,7 @@ ($equivalence.spec /.equivalence (..random sizeM1 sizeS1))) (_.for [/.hash] (|> (random.ascii 1) - (\ ! map (|>> [""])) + (\ ! each (|>> [""])) ($hash.spec /.hash))) (_.for [/.order] ($order.spec /.order (..random sizeM1 sizeS1))) diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux index 61b9c43a1..44588b3b6 100644 --- a/stdlib/source/test/lux/data/sum.lux +++ b/stdlib/source/test/lux/data/sum.lux @@ -23,7 +23,7 @@ (def: .public test Test (<| (_.covering /._) - (_.for [.Variant .Or]) + (_.for [.Union .Or]) (do {! random.monad} [expected random.nat shift random.nat] @@ -70,12 +70,12 @@ (/.then (n.+ shift) (n.- shift)) (case> (0 #1 actual) (n.= (n.- shift expected) actual) _ false)))) (do ! - [size (\ ! map (n.% 5) random.nat) + [size (\ ! each (n.% 5) random.nat) expected (random.list size random.nat)] ($_ _.and (_.cover [/.lefts] (let [actual (: (List (Or Nat Nat)) - (list\map /.left expected))] + (list\each /.left expected))] (and (\ (list.equivalence n.equivalence) = expected (/.lefts actual)) @@ -84,7 +84,7 @@ (/.rights actual))))) (_.cover [/.rights] (let [actual (: (List (Or Nat Nat)) - (list\map /.right expected))] + (list\each /.right expected))] (and (\ (list.equivalence n.equivalence) = expected (/.rights actual)) @@ -93,10 +93,10 @@ (/.lefts actual))))) (_.cover [/.partition] (let [[lefts rights] (|> expected - (list\map (function (_ value) - (if (n.even? value) - (/.left value) - (/.right value)))) + (list\each (function (_ value) + (if (n.even? value) + (/.left value) + (/.right value)))) (: (List (Or Nat Nat))) /.partition)] (and (\ (list.equivalence n.equivalence) = diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 832c5a094..df0c6000c 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -34,12 +34,12 @@ (def: bounded_size (random.Random Nat) (|> random.nat - (\ random.monad map (|>> (n.% 20) (n.+ 1))))) + (\ random.monad each (|>> (n.% 20) (n.+ 1))))) (def: size Test (do {! random.monad} - [size (\ ! map (n.% 10) random.nat) + [size (\ ! each (n.% 10) random.nat) sample (random.unicode size)] ($_ _.and (_.cover [/.size] @@ -56,7 +56,7 @@ (random.unicode 1)) left (random.unicode 1) right (random.unicode 1) - .let [full (\ /.monoid compose inner outer) + .let [full (\ /.monoid composite inner outer) fake_index (-- 0)]] (`` ($_ _.and (~~ (template [<affix> <predicate>] @@ -86,18 +86,18 @@ .let [fake_index (-- 0)]] ($_ _.and (_.cover [/.contains?] - (let [full (\ /.monoid compose inner outer)] + (let [full (\ /.monoid composite inner outer)] (and (/.contains? inner full) (/.contains? outer full)))) (_.cover [/.index] - (and (|> (/.index inner (\ /.monoid compose inner outer)) + (and (|> (/.index inner (\ /.monoid composite inner outer)) (maybe.else fake_index) (n.= 0)) - (|> (/.index outer (\ /.monoid compose inner outer)) + (|> (/.index outer (\ /.monoid composite inner outer)) (maybe.else fake_index) (n.= 1)))) (_.cover [/.index'] - (let [full (\ /.monoid compose inner outer)] + (let [full (\ /.monoid composite inner outer)] (and (|> (/.index' 0 inner full) (maybe.else fake_index) (n.= 0)) @@ -115,7 +115,7 @@ (maybe.else fake_index) (n.= fake_index))))) (_.cover [/.last_index] - (let [full ($_ (\ /.monoid compose) outer inner outer)] + (let [full ($_ (\ /.monoid composite) outer inner outer)] (and (|> (/.last_index inner full) (maybe.else fake_index) (n.= 1)) @@ -146,10 +146,10 @@ (\ /.equivalence = /.new_line /.line_feed)) ))) (do {! random.monad} - [size (\ ! map (|>> (n.% 10) ++) random.nat) + [size (\ ! each (|>> (n.% 10) ++) random.nat) characters (random.set /.hash size (random.ascii/alpha 1)) .let [sample (|> characters set.list /.together)] - expected (\ ! map (n.% size) random.nat)] + expected (\ ! each (n.% size) random.nat)] (_.cover [/.char] (case (/.char expected sample) (#.Some char) @@ -178,7 +178,7 @@ (def: manipulation Test (do {! random.monad} - [size (\ ! map (|>> (n.% 10) (n.+ 2)) random.nat) + [size (\ ! each (|>> (n.% 10) (n.+ 2)) random.nat) characters (random.set /.hash size (random.ascii/alpha 1)) separator (random.only (|>> (set.member? characters) not) (random.ascii/alpha 1)) @@ -206,10 +206,10 @@ (/.interposed "" (set.list characters))))) (_.cover [/.replaced/1] (\ /.equivalence = - (\ /.monoid compose post static) - (/.replaced/1 pre post (\ /.monoid compose pre static)))) + (\ /.monoid composite post static) + (/.replaced/1 pre post (\ /.monoid composite pre static)))) (_.cover [/.split_by] - (case (/.split_by static ($_ (\ /.monoid compose) pre static post)) + (case (/.split_by static ($_ (\ /.monoid composite) pre static post)) (#.Some [left right]) (and (\ /.equivalence = pre left) (\ /.equivalence = post right)) @@ -317,7 +317,7 @@ .let [... The wider unicode charset includes control characters that ... can make text replacement work improperly. ... Because of that, I restrict the charset. - normal_char_gen (|> random.nat (\ ! map (|>> (n.% 128) (n.max 1))))] + normal_char_gen (|> random.nat (\ ! each (|>> (n.% 128) (n.max 1))))] sep1 (random.text normal_char_gen 1) sep2 (random.text normal_char_gen 1) .let [part_gen (|> (random.text normal_char_gen sizeP) diff --git a/stdlib/source/test/lux/data/text/buffer.lux b/stdlib/source/test/lux/data/text/buffer.lux index 7d502d2fb..aa88a2ac3 100644 --- a/stdlib/source/test/lux/data/text/buffer.lux +++ b/stdlib/source/test/lux/data/text/buffer.lux @@ -17,7 +17,7 @@ (def: part (Random Text) (do {! random.monad} - [size (\ ! map (|>> (n.% 10) ++) random.nat)] + [size (\ ! each (|>> (n.% 10) ++) random.nat)] (random.ascii/alpha size))) (def: .public test diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux index ca28e316d..c17b7ce36 100644 --- a/stdlib/source/test/lux/data/text/encoding.lux +++ b/stdlib/source/test/lux/data/text/encoding.lux @@ -214,7 +214,7 @@ (Random /.Encoding) (let [options (list.size ..all_encodings)] (do {! random.monad} - [choice (\ ! map (n.% options) random.nat)] + [choice (\ ! each (n.% options) random.nat)] (in (maybe.trusted (list.item choice ..all_encodings)))))) (def: .public test diff --git a/stdlib/source/test/lux/data/text/escape.lux b/stdlib/source/test/lux/data/text/escape.lux index 49b125cba..855064059 100644 --- a/stdlib/source/test/lux/data/text/escape.lux +++ b/stdlib/source/test/lux/data/text/escape.lux @@ -34,7 +34,7 @@ (def: (range max min) (-> Char Char (Random Char)) (let [range (n.- min max)] - (\ random.monad map + (\ random.monad each (|>> (n.% range) (n.+ min)) random.nat))) @@ -114,7 +114,7 @@ (text\= expected (/.escaped expected)))))) (do {! random.monad} [dummy (|> (random.char unicode.character) - (\ ! map text.of_char))] + (\ ! each text.of_char))] (_.cover [/.dangling_escape] (case (/.un_escaped (format (/.escaped dummy) "\")) (#try.Success _) @@ -125,7 +125,7 @@ (do {! random.monad} [dummy (|> (random.char unicode.character) (random.only (|>> (set.member? ..valid_sigils) not)) - (\ ! map text.of_char))] + (\ ! each text.of_char))] (_.cover [/.invalid_escape] (case (/.un_escaped (format "\" dummy)) (#try.Success _) @@ -135,7 +135,7 @@ (exception.match? /.invalid_escape error)))) (do {! random.monad} [too_short (|> (random.char unicode.character) - (\ ! map (n.% (hex "1000")))) + (\ ! each (n.% (hex "1000")))) code (|> (random.unicode 4) (random.only (function (_ code) (case (\ n.hex decoded code) diff --git a/stdlib/source/test/lux/data/text/format.lux b/stdlib/source/test/lux/data/text/format.lux index cbeedd65a..5f604f1f8 100644 --- a/stdlib/source/test/lux/data/text/format.lux +++ b/stdlib/source/test/lux/data/text/format.lux @@ -159,7 +159,7 @@ (_.cover [/.list] (text\= (/.list /.nat members) (|> members - (list\map /.nat) + (list\each /.nat) (text.interposed " ") list (/.list (|>>)))))) @@ -177,7 +177,7 @@ [modulus (random.one (|>> modulus.modulus try.maybe) random.int) - sample (\ ! map (modular.modular modulus) + sample (\ ! each (modular.modular modulus) random.int)] (_.cover [/.mod] (text\= (\ (modular.codec modulus) encoded sample) diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index 926a56446..3c006d6d8 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -25,8 +25,8 @@ (def: .public random (Random /.Block) (do {! random.monad} - [start (\ ! map (n.% 1,000,000) random.nat) - additional (\ ! map (n.% 1,000,000) random.nat)] + [start (\ ! each (n.% 1,000,000) random.nat) + additional (\ ! each (n.% 1,000,000) random.nat)] (in (/.block start additional)))) (with_expansions [<blocks> (as_is [blocks/0 @@ -173,12 +173,12 @@ [.let [top_start (hex "AC00") top_end (hex "D7AF") end_range (n.- top_start top_end)] - start (\ ! map (|>> (n.% top_start) ++) random.nat) - end (\ ! map (|>> (n.% end_range) (n.+ top_start)) random.nat) + start (\ ! each (|>> (n.% top_start) ++) random.nat) + end (\ ! each (|>> (n.% end_range) (n.+ top_start)) random.nat) .let [additional (n.- start end) sample (/.block start additional) size (/.size sample)] - inside (\ ! map + inside (\ ! each (|>> (n.% size) (n.+ (/.start sample))) random.nat)] diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux index b0be9c914..2ff6ade86 100644 --- a/stdlib/source/test/lux/data/text/unicode/set.lux +++ b/stdlib/source/test/lux/data/text/unicode/set.lux @@ -36,7 +36,7 @@ (_.for [/.Set]) (do {! random.monad} [block //block.random - inside (\ ! map + inside (\ ! each (|>> (n.% (block.size block)) (n.+ (block.start block))) random.nat) diff --git a/stdlib/source/test/lux/debug.lux b/stdlib/source/test/lux/debug.lux index 151dd34c2..af3363bac 100644 --- a/stdlib/source/test/lux/debug.lux +++ b/stdlib/source/test/lux/debug.lux @@ -59,7 +59,7 @@ sample_rev random.rev] (in (`` (and (~~ (template [<type> <format> <sample>] [(|> (/.representation <type> <sample>) - (try\map (text\= (<format> <sample>))) + (try\each (text\= (<format> <sample>))) (try.else false))] [Bit %.bit sample_bit] @@ -92,7 +92,7 @@ ... [(|> (/.representation (type (Or Bit Int Frac)) ... (: (Or Bit Int Frac) ... (<lefts> <right?> <value>))) - ... (try\map (text\= (format "(" (%.nat <lefts>) + ... (try\each (text\= (format "(" (%.nat <lefts>) ... " " (%.bit <right?>) ... " " (<format> <value>) ")"))) ... (try.else false))] @@ -115,7 +115,7 @@ sample_json $//json.random] (in (`` (and (~~ (template [<type> <format> <sample>] [(|> (/.representation <type> <sample>) - (try\map (text\= (<format> <sample>))) + (try\each (text\= (<format> <sample>))) (try.else false))] [Ratio %.ratio sample_ratio] @@ -138,7 +138,7 @@ sample_day random.day] (in (`` (and (~~ (template [<type> <format> <sample>] [(|> (/.representation <type> <sample>) - (try\map (text\= (<format> <sample>))) + (try\each (text\= (<format> <sample>))) (try.else false))] [Instant %.instant sample_instant] @@ -169,14 +169,14 @@ can_represent_time_types! (|> (/.representation .Any sample_frac) - (try\map (text\= "[]")) + (try\each (text\= "[]")) (try.else false)) (|> (/.representation (type (List Nat)) (: (List Nat) (list sample_nat))) - (try\map (text\= (%.list %.nat (list sample_nat)))) + (try\each (text\= (%.list %.nat (list sample_nat)))) (try.else false)) (~~ (template [<sample>] [(|> (/.representation (type (Maybe Nat)) (: (Maybe Nat) <sample>)) - (try\map (text\= (%.maybe %.nat <sample>))) + (try\each (text\= (%.maybe %.nat <sample>))) (try.else false))] [(#.Some sample_nat)] @@ -210,7 +210,7 @@ )) (text\= (|> (list sample_bit sample_int sample_frac sample_text) (: (List Any)) - (list\map /.inspection) + (list\each /.inspection) (text.interposed " ") (text.enclosed ["[" "]"])) (/.inspection [sample_bit sample_int sample_frac sample_text])) diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux index bf7c312c9..b35ff1fb7 100644 --- a/stdlib/source/test/lux/documentation.lux +++ b/stdlib/source/test/lux/documentation.lux @@ -30,7 +30,7 @@ (#try.Failure "OOPS!")))) (syntax: (description []) - (\ meta.monad map + (\ meta.monad each (|>> %.nat code.text list) meta.seed)) diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux index 68a945f9c..b83b83e11 100644 --- a/stdlib/source/test/lux/extension.lux +++ b/stdlib/source/test/lux/extension.lux @@ -63,8 +63,8 @@ (analysis: (..my_synthesis self phase archive [parameters (<>.some <code>.any)]) (let [! phase.monad] (|> parameters - (monad.map ! (phase archive)) - (\ ! map (|>> (#analysis.Extension self)))))) + (monad.each ! (phase archive)) + (\ ! each (|>> (#analysis.Extension self)))))) (synthesis: (..my_synthesis self phase archive [pass_through <analysis>.any]) (phase archive pass_through)) @@ -73,18 +73,18 @@ (analysis: (..my_generation self phase archive [parameters (<>.some <code>.any)]) (let [! phase.monad] (|> parameters - (monad.map ! (phase archive)) - (\ ! map (|>> (#analysis.Extension self)))))) + (monad.each ! (phase archive)) + (\ ! each (|>> (#analysis.Extension self)))))) (synthesis: (..my_generation self phase archive [parameters (<>.some <analysis>.any)]) (let [! phase.monad] (|> parameters - (monad.map ! (phase archive)) - (\ ! map (|>> (#synthesis.Extension self)))))) + (monad.each ! (phase archive)) + (\ ! each (|>> (#synthesis.Extension self)))))) (generation: (..my_generation self phase archive [pass_through <synthesis>.any]) (for {@.jvm - (\ phase.monad map (|>> #jvm.Embedded row.row) + (\ phase.monad each (|>> #jvm.Embedded row.row) (phase archive pass_through))} (phase archive pass_through))) diff --git a/stdlib/source/test/lux/ffi.js.lux b/stdlib/source/test/lux/ffi.js.lux index 6e41aef82..230fad9a9 100644 --- a/stdlib/source/test/lux/ffi.js.lux +++ b/stdlib/source/test/lux/ffi.js.lux @@ -46,11 +46,11 @@ Test (do {! random.monad} [boolean random.bit - number (\ ! map (|>> (nat.% 100) nat.frac) random.nat) + number (\ ! each (|>> (nat.% 100) nat.frac) random.nat) string (random.ascii 5) - function (\ ! map (function (_ shift) - (: (-> Nat Nat) - (nat.+ shift))) + function (\ ! each (function (_ shift) + (: (-> Nat Nat) + (nat.+ shift))) random.nat) ... I64s get compiled as JavaScript objects with a specific structure. object random.nat] diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index 41a794c4e..e130626de 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -71,13 +71,13 @@ (def: for_conversions Test (do {! random.monad} - [long (\ ! map (|>> (:as /.Long)) random.int) - integer (\ ! map (|>> (:as /.Long) /.long_to_int) random.int) - byte (\ ! map (|>> (:as /.Long) /.long_to_byte) random.int) - short (\ ! map (|>> (:as /.Long) /.long_to_short) random.int) + [long (\ ! each (|>> (:as /.Long)) random.int) + integer (\ ! each (|>> (:as /.Long) /.long_to_int) random.int) + byte (\ ! each (|>> (:as /.Long) /.long_to_byte) random.int) + short (\ ! each (|>> (:as /.Long) /.long_to_short) random.int) float (|> random.frac (random.only (|>> f.not_a_number? not)) - (\ ! map (|>> (:as /.Double) /.double_to_float)))] + (\ ! each (|>> (:as /.Double) /.double_to_float)))] (`` ($_ _.and (~~ (template [<sample> <=> <to> <from>] [(_.cover [<to> <from>] @@ -106,9 +106,9 @@ (def: for_arrays Test (do {! random.monad} - [size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1)))) - idx (|> random.nat (\ ! map (n.% size))) - value (\ ! map (|>> (:as java/lang/Long)) random.int)] + [size (|> random.nat (\ ! each (|>> (n.% 100) (n.max 1)))) + idx (|> random.nat (\ ! each (n.% size))) + value (\ ! each (|>> (:as java/lang/Long)) random.int)] ($_ _.and (_.cover [/.array /.length] (|> size @@ -132,21 +132,21 @@ (def: for_miscellaneous Test (`` (do {! random.monad} - [sample (\ ! map (|>> (:as java/lang/Object)) + [sample (\ ! each (|>> (:as java/lang/Object)) (random.ascii 1)) - boolean (\ ! map (|>> (:as /.Boolean)) random.bit) - byte (\ ! map (|>> (:as /.Long) /.long_to_byte) random.int) - short (\ ! map (|>> (:as /.Long) /.long_to_short) random.int) - integer (\ ! map (|>> (:as /.Long) /.long_to_int) random.int) - long (\ ! map (|>> (:as /.Long)) random.int) + boolean (\ ! each (|>> (:as /.Boolean)) random.bit) + byte (\ ! each (|>> (:as /.Long) /.long_to_byte) random.int) + short (\ ! each (|>> (:as /.Long) /.long_to_short) random.int) + integer (\ ! each (|>> (:as /.Long) /.long_to_int) random.int) + long (\ ! each (|>> (:as /.Long)) random.int) float (|> random.frac (random.only (|>> f.not_a_number? not)) - (\ ! map (|>> (:as /.Double) /.double_to_float))) + (\ ! each (|>> (:as /.Double) /.double_to_float))) double (|> random.frac (random.only (|>> f.not_a_number? not)) - (\ ! map (|>> (:as /.Double)))) - character (\ ! map (|>> (:as /.Long) /.long_to_int /.int_to_char) random.int) - string (\ ! map (|>> (:as java/lang/String)) + (\ ! each (|>> (:as /.Double)))) + character (\ ! each (|>> (:as /.Long) /.long_to_int /.int_to_char) random.int) + string (\ ! each (|>> (:as java/lang/String)) (random.ascii 1))] ($_ _.and (_.cover [/.check] @@ -546,7 +546,7 @@ (test/TestInterface4::actual4 left right right object/8)))] .let [random_long (: (Random java/lang/Long) - (\ ! map (|>> (:as java/lang/Long)) + (\ ! each (|>> (:as java/lang/Long)) random.int))] dummy/0 random_long dummy/1 random_long diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux index 701828389..22c0a636a 100644 --- a/stdlib/source/test/lux/ffi.old.lux +++ b/stdlib/source/test/lux/ffi.old.lux @@ -89,13 +89,13 @@ Test (do {! random.monad} [long random.int - int (\ ! map (|>> /.long_to_int) random.int) - char (\ ! map (|>> /.long_to_int /.int_to_char) random.int) + int (\ ! each (|>> /.long_to_int) random.int) + char (\ ! each (|>> /.long_to_int /.int_to_char) random.int) double (|> random.frac (random.only (|>> f.not_a_number? not))) float (|> random.frac (random.only (|>> f.not_a_number? not)) - (\ ! map (|>> /.double_to_float)))] + (\ ! each (|>> /.double_to_float)))] (`` ($_ _.and (~~ (template [<=> <sample> <to> <from>] [(_.cover [<to> <from>] @@ -156,8 +156,8 @@ (def: arrays Test (do {! random.monad} - [size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1)))) - idx (|> random.nat (\ ! map (n.% size))) + [size (|> random.nat (\ ! each (|>> (n.% 100) (n.max 1)))) + idx (|> random.nat (\ ! each (n.% size))) value random.int] ($_ _.and (_.cover [/.array /.length] diff --git a/stdlib/source/test/lux/locale.lux b/stdlib/source/test/lux/locale.lux index afc69ea50..3c37647aa 100644 --- a/stdlib/source/test/lux/locale.lux +++ b/stdlib/source/test/lux/locale.lux @@ -59,16 +59,16 @@ fixed_encoding ..random_encoding] ($_ _.and (|> ..random_language - (\ ! map (function (_ language) - (/.locale language (#.Some fixed_territory) (#.Some fixed_encoding)))) + (\ ! each (function (_ language) + (/.locale language (#.Some fixed_territory) (#.Some fixed_encoding)))) ($hash.spec /.hash)) (|> ..random_territory - (\ ! map (function (_ territory) - (/.locale fixed_language (#.Some territory) (#.Some fixed_encoding)))) + (\ ! each (function (_ territory) + (/.locale fixed_language (#.Some territory) (#.Some fixed_encoding)))) ($hash.spec /.hash)) (|> ..random_encoding - (\ ! map (function (_ encoding) - (/.locale fixed_language (#.Some fixed_territory) (#.Some encoding)))) + (\ ! each (function (_ encoding) + (/.locale fixed_language (#.Some fixed_territory) (#.Some encoding)))) ($hash.spec /.hash)) ))) diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index b8ac893fd..19883a827 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -24,11 +24,12 @@ ["." /]]) (type: Bundle - {#amount Nat - #names (Set Text) - #codes (Set Text) - #languages (Set /.Language) - #test Test}) + (Record + {#amount Nat + #names (Set Text) + #codes (Set Text) + #languages (Set /.Language) + #test Test})) (template [<bundle> <languages>] [(def: <bundle> @@ -37,8 +38,8 @@ languages (: (List /.Language) (`` (list (~~ (template.spliced <languages>)))))] {#amount amount - #names (|> languages (list\map /.name) (set.of_list text.hash)) - #codes (|> languages (list\map /.code) (set.of_list text.hash)) + #names (|> languages (list\each /.name) (set.of_list text.hash)) + #codes (|> languages (list\each /.code) (set.of_list text.hash)) #languages (set.of_list /.hash languages) #test (_.cover <languages> true)}))] @@ -198,7 +199,7 @@ Test (|> ..languages list.reversed - (list\map (value@ #test)) + (list\each (value@ #test)) (list\mix _.and (`` ($_ _.and (~~ (template [<lens> <tag> <hash>] @@ -278,10 +279,10 @@ (def: .public random (Random /.Language) (let [options (|> ..languages - (list\map (|>> (value@ #languages) set.list)) + (list\each (|>> (value@ #languages) set.list)) list.together)] (do {! random.monad} - [choice (\ ! map (n.% (list.size options)) + [choice (\ ! each (n.% (list.size options)) random.nat)] (in (maybe.trusted (list.item choice options)))))) diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index b8a36d4fd..2a225a58e 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -24,13 +24,14 @@ ["." /]]) (type: Bundle - {#amount Nat - #names (Set Text) - #shorts (Set Text) - #longs (Set Text) - #numbers (Set Nat) - #territories (Set /.Territory) - #test Test}) + (Record + {#amount Nat + #names (Set Text) + #shorts (Set Text) + #longs (Set Text) + #numbers (Set Nat) + #territories (Set /.Territory) + #test Test})) (template [<bundle> <territories>] [(def: <bundle> @@ -38,10 +39,10 @@ (let [amount (template.amount <territories>) territories (`` (list (~~ (template.spliced <territories>))))] {#amount amount - #names (|> territories (list\map /.name) (set.of_list text.hash)) - #shorts (|> territories (list\map /.short_code) (set.of_list text.hash)) - #longs (|> territories (list\map /.long_code) (set.of_list text.hash)) - #numbers (|> territories (list\map /.numeric_code) (set.of_list n.hash)) + #names (|> territories (list\each /.name) (set.of_list text.hash)) + #shorts (|> territories (list\each /.short_code) (set.of_list text.hash)) + #longs (|> territories (list\each /.long_code) (set.of_list text.hash)) + #numbers (|> territories (list\each /.numeric_code) (set.of_list n.hash)) #territories (|> territories (set.of_list /.hash)) #test (_.cover <territories> true)}))] @@ -153,7 +154,7 @@ Test (|> ..territories list.reversed - (list\map (value@ #test)) + (list\each (value@ #test)) (list\mix _.and (`` ($_ _.and (~~ (template [<lens> <tag> <hash>] @@ -204,10 +205,10 @@ (def: .public random (Random /.Territory) (let [options (|> ..territories - (list\map (|>> (value@ #territories) set.list)) + (list\each (|>> (value@ #territories) set.list)) list.together)] (do {! random.monad} - [choice (\ ! map (n.% (list.size options)) + [choice (\ ! each (n.% (list.size options)) random.nat)] (in (maybe.trusted (list.item choice options)))))) diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux index a335aa996..2e8c199b4 100644 --- a/stdlib/source/test/lux/macro.lux +++ b/stdlib/source/test/lux/macro.lux @@ -111,9 +111,9 @@ (do {! random.monad} [[seed identifier_prefix lux] ..random_lux - pow/1 (\ ! map code.nat random.nat) + pow/1 (\ ! each code.nat random.nat) - repetitions (\ ! map (nat.% 10) random.nat) + repetitions (\ ! each (nat.% 10) random.nat) .let [single_expansion (` (..pow/2 (..pow/2 (~ pow/1)))) expansion (` (nat.* (..pow/2 (~ pow/1)) (..pow/2 (~ pow/1)))) @@ -124,18 +124,18 @@ [(_.cover [<expander>] (|> (<expander> (` (..pow/4 (~ pow/1)))) (meta.result lux) - (try\map (\ (list.equivalence code.equivalence) = - (list <expansion>))) + (try\each (\ (list.equivalence code.equivalence) = + (list <expansion>))) (try.else false))) (_.cover [<logger>] (and (|> (/.single_expansion (` (<logger> (~' #omit) (..pow/4 (~ pow/1))))) (meta.result lux) - (try\map (\ (list.equivalence code.equivalence) = (list))) + (try\each (\ (list.equivalence code.equivalence) = (list))) (try.else false)) (|> (/.single_expansion (` (<logger> (..pow/4 (~ pow/1))))) (meta.result lux) - (try\map (\ (list.equivalence code.equivalence) = (list <expansion>))) + (try\each (\ (list.equivalence code.equivalence) = (list <expansion>))) (try.else false))))] [/.single_expansion /.log_single_expansion! single_expansion] @@ -158,7 +158,7 @@ ($_ _.and (_.cover [/.identifier] (|> (/.identifier identifier_prefix) - (\ meta.monad map %.code) + (\ meta.monad each %.code) (meta.result lux) (!expect (^multi (#try.Success actual_identifier) (and (text.contains? identifier_prefix actual_identifier) diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index d0bd1343a..666e8734c 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -38,13 +38,13 @@ (def: (random_sequence random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} - [size (|> random.nat (\ ! map (n.% 3)))] + [size (|> random.nat (\ ! each (n.% 3)))] (random.list size random))) (def: (random_record random) (All [a] (-> (Random a) (Random (List [a a])))) (do {! random.monad} - [size (|> random.nat (\ ! map (n.% 3)))] + [size (|> random.nat (\ ! each (n.% 3)))] (random.list size (random.and random random)))) (def: .public random @@ -52,17 +52,17 @@ (random.rec (function (_ random) ($_ random.either - (random\map /.bit random.bit) - (random\map /.nat random.nat) - (random\map /.int random.int) - (random\map /.rev random.rev) - (random\map /.frac random.safe_frac) - (random\map /.text ..random_text) - (random\map /.identifier ..random_name) - (random\map /.tag ..random_name) - (random\map /.form (..random_sequence random)) - (random\map /.tuple (..random_sequence random)) - (random\map /.record (..random_record random)) + (random\each /.bit random.bit) + (random\each /.nat random.nat) + (random\each /.int random.int) + (random\each /.rev random.rev) + (random\each /.frac random.safe_frac) + (random\each /.text ..random_text) + (random\each /.identifier ..random_name) + (random\each /.tag ..random_name) + (random\each /.form (..random_sequence random)) + (random\each /.tuple (..random_sequence random)) + (random\each /.record (..random_record random)) )))) (def: (read source_code) @@ -87,29 +87,29 @@ (function (_ to_code) (do {! random.monad} [parts (..random_sequence replacement_simulation)] - (in [(to_code (list\map product.left parts)) - (to_code (list\map product.right parts))]))))] + (in [(to_code (list\each product.left parts)) + (to_code (list\each product.right parts))]))))] ($_ random.either (random\in [original substitute]) (do {! random.monad} [sample (random.only (|>> (\ /.equivalence = original) not) ($_ random.either - (random\map /.bit random.bit) - (random\map /.nat random.nat) - (random\map /.int random.int) - (random\map /.rev random.rev) - (random\map /.frac random.safe_frac) - (random\map /.text ..random_text) - (random\map /.identifier ..random_name) - (random\map /.tag ..random_name)))] + (random\each /.bit random.bit) + (random\each /.nat random.nat) + (random\each /.int random.int) + (random\each /.rev random.rev) + (random\each /.frac random.safe_frac) + (random\each /.text ..random_text) + (random\each /.identifier ..random_name) + (random\each /.tag ..random_name)))] (in [sample sample])) (for_sequence /.form) (for_sequence /.tuple) (do {! random.monad} [parts (..random_sequence replacement_simulation)] - (in [(/.record (let [parts' (list\map product.left parts)] + (in [(/.record (let [parts' (list\each product.left parts)] (list.zipped/2 parts' parts'))) - (/.record (let [parts' (list\map product.right parts)] + (/.record (let [parts' (list\each product.right parts)] (list.zipped/2 parts' parts')))])) ))))) diff --git a/stdlib/source/test/lux/macro/syntax/annotations.lux b/stdlib/source/test/lux/macro/syntax/annotations.lux index 3fd71b7a3..bfe3bde4b 100644 --- a/stdlib/source/test/lux/macro/syntax/annotations.lux +++ b/stdlib/source/test/lux/macro/syntax/annotations.lux @@ -27,7 +27,7 @@ (let [word (random.ascii/alpha 10) tag (random.and word word)] (do {! random.monad} - [size (\ ! map (n.% 10) random.nat)] + [size (\ ! each (n.% 10) random.nat)] (random.list size (random.and tag $///code.random))))) (def: .public test diff --git a/stdlib/source/test/lux/macro/syntax/declaration.lux b/stdlib/source/test/lux/macro/syntax/declaration.lux index 8301899bd..8812f0509 100644 --- a/stdlib/source/test/lux/macro/syntax/declaration.lux +++ b/stdlib/source/test/lux/macro/syntax/declaration.lux @@ -23,7 +23,7 @@ ($_ random.and word (do {! random.monad} - [size (\ ! map (n.% 10) random.nat)] + [size (\ ! each (n.% 10) random.nat)] (random.list size word)) ))) diff --git a/stdlib/source/test/lux/macro/syntax/export.lux b/stdlib/source/test/lux/macro/syntax/export.lux index 1653dc4b4..5455656c0 100644 --- a/stdlib/source/test/lux/macro/syntax/export.lux +++ b/stdlib/source/test/lux/macro/syntax/export.lux @@ -22,7 +22,7 @@ (Random [(Maybe Code) Nat]) ($_ random.and (|> random.bit - (\ random.monad map code.bit) + (\ random.monad each code.bit) random.maybe) random.nat)) @@ -39,9 +39,9 @@ #.None (list (code.nat expected_un_exported))) (<code>.result (/.parser <code>.nat)) - (try\map (function (_ [actual_export_policy actual_un_exported]) - (|> expected_export_policy - (maybe.else /.default_policy) - (code\= actual_export_policy) - (and (n.= expected_un_exported actual_un_exported))))) + (try\each (function (_ [actual_export_policy actual_un_exported]) + (|> expected_export_policy + (maybe.else /.default_policy) + (code\= actual_export_policy) + (and (n.= expected_un_exported actual_un_exported))))) (try.else false)))))) diff --git a/stdlib/source/test/lux/macro/syntax/type/variable.lux b/stdlib/source/test/lux/macro/syntax/type/variable.lux index cf8d65157..125f02c19 100644 --- a/stdlib/source/test/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/test/lux/macro/syntax/type/variable.lux @@ -32,6 +32,6 @@ (_.cover [/.format /.parser] (|> (list (/.format expected)) (<code>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) ))) diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index 8aeb528f5..da5cfd057 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -37,7 +37,7 @@ ($_ _.and (do {! random.monad} [.let [~= (f.approximately? ..margin_of_error)] - angle (|> random.safe_frac (\ ! map (f.* /.tau)))] + angle (|> random.safe_frac (\ ! each (f.* /.tau)))] ($_ _.and (_.cover [/.sin /.asin] (trigonometric_symmetry /.sin /.asin angle)) @@ -61,7 +61,7 @@ (~= (f./ +2.0 /.tau) /.pi)) )) (do {! random.monad} - [sample (|> random.safe_frac (\ ! map (f.* +1000.0)))] + [sample (|> random.safe_frac (\ ! each (f.* +1000.0)))] ($_ _.and (_.cover [/.ceil] (let [ceil'd (/.ceil sample)] @@ -91,8 +91,8 @@ )) (do {! random.monad} [.let [~= (f.approximately? ..margin_of_error)] - sample (\ ! map (f.* +10.0) random.safe_frac) - power (\ ! map (|>> (n.% 10) ++ n.frac) random.nat)] + sample (\ ! each (f.* +10.0) random.safe_frac) + power (\ ! each (|>> (n.% 10) ++ n.frac) random.nat)] ($_ _.and (_.cover [/.exp /.log] (|> sample /.exp /.log (f.approximately? +0.000000000000001 sample))) @@ -107,9 +107,9 @@ )) (do {! random.monad} [.let [~= (f.approximately? ..margin_of_error)] - angle (\ ! map (f.* /.tau) random.safe_frac) - sample (\ ! map f.abs random.safe_frac) - big (\ ! map (f.* +1,000,000,000.00) random.safe_frac)] + angle (\ ! each (f.* /.tau) random.safe_frac) + sample (\ ! each f.abs random.safe_frac) + big (\ ! each (f.* +1,000,000,000.00) random.safe_frac)] (template.let [(odd! <function>) [(_.cover [<function>] (~= (f.opposite (<function> angle)) @@ -137,8 +137,8 @@ (inverse! /.atanh /.acoth big) ))) (do {! random.monad} - [x (\ ! map (|>> (f.* +10.0) f.abs) random.safe_frac) - y (\ ! map (|>> (f.* +10.0) f.abs) random.safe_frac)] + [x (\ ! each (|>> (f.* +10.0) f.abs) random.safe_frac) + y (\ ! each (|>> (f.* +10.0) f.abs) random.safe_frac)] (_.cover [/.hypotenuse] (let [h (/.hypotenuse x y)] (and (f.>= x h) @@ -146,8 +146,8 @@ (do {! random.monad} [.let [~= (f.approximately? ..margin_of_error) tau/4 (f./ +4.0 /.tau)] - x (\ ! map (f.* tau/4) random.safe_frac) - y (\ ! map (f.* tau/4) random.safe_frac)] + x (\ ! each (f.* tau/4) random.safe_frac) + y (\ ! each (f.* tau/4) random.safe_frac)] (_.cover [/.atan/2] (let [expected (/.atan/2 x y) actual (if (f.> +0.0 x) @@ -160,7 +160,7 @@ (~= (f.opposite tau/4) (/.atan/2 +0.0 (f.opposite (f.abs y)))) (f.not_a_number? (/.atan/2 +0.0 +0.0)))))) (do {! random.monad} - [of (\ ! map (|>> (n.% 10) ++) random.nat)] + [of (\ ! each (|>> (n.% 10) ++) random.nat)] (_.cover [/.factorial] (and (n.= 1 (/.factorial 0)) (|> (/.factorial of) (n.% of) (n.= 0))))) diff --git a/stdlib/source/test/lux/math/logic/fuzzy.lux b/stdlib/source/test/lux/math/logic/fuzzy.lux index 4b1a6919a..d8198d026 100644 --- a/stdlib/source/test/lux/math/logic/fuzzy.lux +++ b/stdlib/source/test/lux/math/logic/fuzzy.lux @@ -39,9 +39,9 @@ (do {! random.monad} [sample random.rev - threshold_0 (\ ! map (r.% .5) + threshold_0 (\ ! each (r.% .5) random.rev) - threshold_1 (\ ! map (|>> (r.% .5) (r.+ .5)) + threshold_1 (\ ! each (|>> (r.% .5) (r.+ .5)) random.rev) .let [bottom (r.min threshold_0 threshold_1) @@ -89,7 +89,7 @@ [bottom middle_bottom middle_top top] (|> random.rev (random.set r.hash 4) - (\ ! map (|>> set.list (list.sorted r.<))) + (\ ! each (|>> set.list (list.sorted r.<))) (random.one (function (_ thresholds) (case thresholds (^ (list threshold_0 threshold_1 threshold_2 threshold_3)) @@ -173,7 +173,7 @@ [bottom middle_bottom middle_top top] (|> random.rev (random.set r.hash 4) - (\ ! map (|>> set.list (list.sorted r.<))) + (\ ! each (|>> set.list (list.sorted r.<))) (random.one (function (_ thresholds) (case thresholds (^ (list threshold_0 threshold_1 threshold_2 threshold_3)) diff --git a/stdlib/source/test/lux/math/modular.lux b/stdlib/source/test/lux/math/modular.lux index ce10c6ca2..8d4e69ab7 100644 --- a/stdlib/source/test/lux/math/modular.lux +++ b/stdlib/source/test/lux/math/modular.lux @@ -30,7 +30,7 @@ (def: .public (random modulus) (All [%] (-> (//.Modulus %) (Random (/.Mod %)))) - (\ random.monad map + (\ random.monad each (/.modular modulus) random.int)) @@ -52,8 +52,8 @@ ($equivalence.spec /.equivalence (..random subject\\%))) (_.for [/.order /.<] ($order.spec /.order (..random subject\\%))) - (~~ (template [<compose> <monoid>] - [(_.for [<monoid> <compose>] + (~~ (template [<composite> <monoid>] + [(_.for [<monoid> <composite>] ($monoid.spec /.equivalence (<monoid> subject\\%) (..random subject\\%)))] [/.+ /.addition] diff --git a/stdlib/source/test/lux/math/modulus.lux b/stdlib/source/test/lux/math/modulus.lux index ae3bbb8e1..54ceeac1d 100644 --- a/stdlib/source/test/lux/math/modulus.lux +++ b/stdlib/source/test/lux/math/modulus.lux @@ -28,7 +28,7 @@ (def: .public (random range) (Ex [%] (-> Int (Random (/.Modulus %)))) (|> random.int - (\ random.monad map (i.% range)) + (\ random.monad each (i.% range)) (random.one (|>> /.modulus try.maybe)))) (def: .public test diff --git a/stdlib/source/test/lux/math/number/complex.lux b/stdlib/source/test/lux/math/number/complex.lux index 70706538d..e73c363ba 100644 --- a/stdlib/source/test/lux/math/number/complex.lux +++ b/stdlib/source/test/lux/math/number/complex.lux @@ -28,7 +28,7 @@ (def: dimension (Random Frac) (do {! random.monad} - [factor (|> random.nat (\ ! map (|>> (n.% 1000) (n.max 1)))) + [factor (|> random.nat (\ ! each (|>> (n.% 1000) (n.max 1)))) measure (|> random.safe_frac (random.only (f.> +0.0)))] (in (f.* (|> factor .int int.frac) measure)))) @@ -42,7 +42,7 @@ (def: angle (Random /.Complex) - (\ random.monad map + (\ random.monad each (|>> (revised@ #/.real (f.% +1.0)) (revised@ #/.imaginary (f.% +1.0))) ..random)) @@ -260,11 +260,11 @@ Test (do {! random.monad} [sample ..random - degree (|> random.nat (\ ! map (|>> (n.max 1) (n.% 5))))] + degree (|> random.nat (\ ! each (|>> (n.max 1) (n.% 5))))] (_.cover [/.roots] (|> sample (/.roots degree) - (list\map (/.pow' (|> degree .int int.frac))) + (list\each (/.pow' (|> degree .int int.frac))) (list.every? (/.approximately? ..margin_of_error sample)))))) (def: .public test diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux index 91f44f41b..7b11df2cb 100644 --- a/stdlib/source/test/lux/math/number/frac.lux +++ b/stdlib/source/test/lux/math/number/frac.lux @@ -26,7 +26,7 @@ (def: random (Random Frac) - (\ random.monad map (|>> (i.% +1,000,000) i.frac) random.int)) + (\ random.monad each (|>> (i.% +1,000,000) i.frac) random.int)) (def: constant Test @@ -52,7 +52,7 @@ Test (do {! random.monad} [sample ..random - shift (\ ! map /.abs ..random)] + shift (\ ! each /.abs ..random)] ($_ _.and (_.cover [/.negative?] (bit\= (/.negative? sample) @@ -77,15 +77,15 @@ Test ($_ _.and (do {! random.monad} - [expected (\ ! map (n.% 1,000,000) random.nat)] + [expected (\ ! each (n.% 1,000,000) random.nat)] (_.cover [/.nat] (|> expected n.frac /.nat (n.= expected)))) (do {! random.monad} - [expected (\ ! map (i.% +1,000,000) random.int)] + [expected (\ ! each (i.% +1,000,000) random.int)] (_.cover [/.int] (|> expected i.frac /.int (i.= expected)))) (do {! random.monad} - [expected (\ ! map (|>> (i64.left_shifted 52) .rev) + [expected (\ ! each (|>> (i64.left_shifted 52) .rev) random.nat)] (_.cover [/.rev] (|> expected r.frac /.rev (r.= expected)))) @@ -100,8 +100,8 @@ ($hash.spec /.hash random.frac)) (_.for [/.order /.<] ($order.spec /.order random.safe_frac)) - (~~ (template [<compose> <monoid>] - [(_.for [<monoid> <compose>] + (~~ (template [<composite> <monoid>] + [(_.for [<monoid> <composite>] ($monoid.spec /.equivalence <monoid> ..random))] [/.+ /.addition] diff --git a/stdlib/source/test/lux/math/number/i16.lux b/stdlib/source/test/lux/math/number/i16.lux index 807a58886..fbb0b62b7 100644 --- a/stdlib/source/test/lux/math/number/i16.lux +++ b/stdlib/source/test/lux/math/number/i16.lux @@ -16,7 +16,7 @@ (def: .public random (Random /.I16) - (\ random.functor map /.i16 random.i64)) + (\ random.functor each /.i16 random.i64)) (def: .public test Test @@ -27,7 +27,7 @@ //i64.mask .int ++)] - expected (\ ! map (i.% limit) random.int)] + expected (\ ! each (i.% limit) random.int)] ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) diff --git a/stdlib/source/test/lux/math/number/i32.lux b/stdlib/source/test/lux/math/number/i32.lux index 06b2458e9..00a5daee6 100644 --- a/stdlib/source/test/lux/math/number/i32.lux +++ b/stdlib/source/test/lux/math/number/i32.lux @@ -16,7 +16,7 @@ (def: .public random (Random /.I32) - (\ random.functor map /.i32 random.i64)) + (\ random.functor each /.i32 random.i64)) (def: .public test Test @@ -27,7 +27,7 @@ //i64.mask .int ++)] - expected (\ ! map (i.% limit) random.int)] + expected (\ ! each (i.% limit) random.int)] ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) diff --git a/stdlib/source/test/lux/math/number/i64.lux b/stdlib/source/test/lux/math/number/i64.lux index 4692a646c..851da2db3 100644 --- a/stdlib/source/test/lux/math/number/i64.lux +++ b/stdlib/source/test/lux/math/number/i64.lux @@ -22,7 +22,7 @@ Test (do {! random.monad} [pattern random.nat - idx (\ ! map (n.% /.width) random.nat)] + idx (\ ! each (n.% /.width) random.nat)] ($_ _.and (_.cover [/.one? /.one] (if (/.one? idx pattern) @@ -48,7 +48,7 @@ [pattern random.nat] ($_ _.and (do ! - [idx (\ ! map (|>> (n.% (-- /.width)) ++) random.nat)] + [idx (\ ! each (|>> (n.% (-- /.width)) ++) random.nat)] (_.cover [/.left_shifted /.right_shifted] (let [nullity! (and (\= pattern (/.left_shifted 0 pattern)) @@ -74,7 +74,7 @@ (<| (_.for [/.Mask]) (do {! random.monad} [pattern random.nat - idx (\ ! map (n.% /.width) random.nat) + idx (\ ! each (n.% /.width) random.nat) signed random.int] ($_ _.and (_.cover [/.sign] @@ -98,9 +98,9 @@ empty! full!))) (do ! - [size (\ ! map (n.% /.width) random.nat) + [size (\ ! each (n.% /.width) random.nat) .let [spare (n.- size /.width)] - offset (\ ! map (n.% spare) random.nat)] + offset (\ ! each (n.% spare) random.nat)] (_.cover [/.region] (case size 0 (\= /.false (/.region offset size)) @@ -122,7 +122,7 @@ Test (_.for [/.Sub] (do {! random.monad} - [size (\ ! map (n.% /.width) random.nat)] + [size (\ ! each (n.% /.width) random.nat)] (case (/.sub size) #.None (_.cover [/.sub] @@ -134,11 +134,11 @@ /.mask .int ++)] - expected (\ ! map (i.% limit) random.int) + expected (\ ! each (i.% limit) random.int) .let [random (: (All [size] (-> (-> I64 (I64 size)) (Random (I64 size)))) (function (_ narrow) - (\ random.functor map narrow random.i64)))]] + (\ random.functor each narrow random.i64)))]] ($_ _.and ($equivalence.spec (\ sub &equivalence) (random (\ sub narrow))) (_.cover [/.sub] @@ -165,7 +165,7 @@ (_.for [.I64]) (do {! random.monad} [pattern random.nat - idx (\ ! map (n.% /.width) random.nat)] + idx (\ ! each (n.% /.width) random.nat)] ($_ _.and (_.cover [/.width /.bits_per_byte /.bytes_per_i64] (and (n.= /.bytes_per_i64 diff --git a/stdlib/source/test/lux/math/number/i8.lux b/stdlib/source/test/lux/math/number/i8.lux index 7d753733d..8a8e7f0f6 100644 --- a/stdlib/source/test/lux/math/number/i8.lux +++ b/stdlib/source/test/lux/math/number/i8.lux @@ -16,7 +16,7 @@ (def: .public random (Random /.I8) - (\ random.functor map /.i8 random.i64)) + (\ random.functor each /.i8 random.i64)) (def: .public test Test @@ -27,7 +27,7 @@ //i64.mask .int ++)] - expected (\ ! map (i.% limit) random.int)] + expected (\ ! each (i.% limit) random.int)] ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) diff --git a/stdlib/source/test/lux/math/number/int.lux b/stdlib/source/test/lux/math/number/int.lux index 3c7cb47be..be091eb18 100644 --- a/stdlib/source/test/lux/math/number/int.lux +++ b/stdlib/source/test/lux/math/number/int.lux @@ -36,8 +36,8 @@ ($enum.spec /.enum random.int)) (_.for [/.interval] ($interval.spec /.interval random.int)) - (~~ (template [<compose> <monoid>] - [(_.for [<monoid> <compose>] + (~~ (template [<composite> <monoid>] + [(_.for [<monoid> <composite>] ($monoid.spec /.equivalence <monoid> random.int))] [/.+ /.addition] @@ -136,7 +136,7 @@ )) (do {! random.monad} [.let [random (|> random.int - (\ ! map (/.% +1,000)) + (\ ! each (/.% +1,000)) (random.only (|>> (/.= +0) not)))] left random right random] @@ -177,14 +177,14 @@ (and subtraction! inverse!)))) (do {! random.monad} - [expected (\ ! map (/.% +1,000,000) random.int) + [expected (\ ! each (/.% +1,000,000) random.int) sample random.int] (_.cover [/.frac] (and (|> expected /.frac f.int (/.= expected)) (f.number? (/.frac sample))))) (do {! random.monad} [pattern random.int - idx (\ ! map (n.% i64.width) random.nat)] + idx (\ ! each (n.% i64.width) random.nat)] (_.cover [/.right_shifted] (let [nullity! (/.= pattern (/.right_shifted 0 pattern)) diff --git a/stdlib/source/test/lux/math/number/nat.lux b/stdlib/source/test/lux/math/number/nat.lux index bf4a7eb40..d01260c09 100644 --- a/stdlib/source/test/lux/math/number/nat.lux +++ b/stdlib/source/test/lux/math/number/nat.lux @@ -34,8 +34,8 @@ ($enum.spec /.enum random.nat)) (_.for [/.interval] ($interval.spec /.interval random.nat)) - (~~ (template [<compose> <monoid>] - [(_.for [<monoid> <compose>] + (~~ (template [<composite> <monoid>] + [(_.for [<monoid> <composite>] ($monoid.spec /.equivalence <monoid> random.nat))] [/.+ /.addition] @@ -104,7 +104,7 @@ (/.= rem (/.% left right))))) )) (do {! random.monad} - [.let [random (\ ! map (|>> (/.% 1,000) ++) random.nat)] + [.let [random (\ ! each (|>> (/.% 1,000) ++) random.nat)] left random right random] ($_ _.and @@ -121,7 +121,7 @@ (/.= 0 (/.% right lcm))))) )) (do {! random.monad} - [expected (\ ! map (/.% 1,000,000) random.nat) + [expected (\ ! each (/.% 1,000,000) random.nat) sample random.nat] (_.cover [/.frac] (and (|> expected /.frac f.nat (/.= expected)) diff --git a/stdlib/source/test/lux/math/number/ratio.lux b/stdlib/source/test/lux/math/number/ratio.lux index 27da768f8..916cb5197 100644 --- a/stdlib/source/test/lux/math/number/ratio.lux +++ b/stdlib/source/test/lux/math/number/ratio.lux @@ -22,7 +22,7 @@ (def: part (Random Nat) - (\ random.monad map + (\ random.monad each (|>> (n.% 1,000,000) (n.max 1)) random.nat)) @@ -43,8 +43,8 @@ ($equivalence.spec /.equivalence ..random)) (_.for [/.order /.<] ($order.spec /.order ..random)) - (~~ (template [<compose> <monoid>] - [(_.for [<monoid> <compose>] + (~~ (template [<composite> <monoid>] + [(_.for [<monoid> <composite>] ($monoid.spec /.equivalence <monoid> ..random))] [/.+ /.addition] @@ -68,13 +68,13 @@ (let [only_numerator! (|> (/.ratio numerator) /.nat - (maybe\map (n\= numerator)) + (maybe\each (n\= numerator)) (maybe.else false)) denominator_1! (|> (/.ratio numerator 1) /.nat - (maybe\map (n\= numerator)) + (maybe\each (n\= numerator)) (maybe.else false)) with_denominator! diff --git a/stdlib/source/test/lux/math/number/rev.lux b/stdlib/source/test/lux/math/number/rev.lux index fdb68b72c..cde50ec02 100644 --- a/stdlib/source/test/lux/math/number/rev.lux +++ b/stdlib/source/test/lux/math/number/rev.lux @@ -36,8 +36,8 @@ ($enum.spec /.enum random.rev)) (_.for [/.interval] ($interval.spec /.interval random.rev)) - (~~ (template [<compose> <monoid>] - [(_.for [<monoid> <compose>] + (~~ (template [<composite> <monoid>] + [(_.for [<monoid> <composite>] ($monoid.spec /.equivalence <monoid> random.rev))] [/.+ /.addition] @@ -88,18 +88,18 @@ (and (/.< left (/.* left right)) (/.< right (/.* left right))))) (do {! random.monad} - [.let [dividend (\ ! map (i64.and (hex "FFFF")) + [.let [dividend (\ ! each (i64.and (hex "FFFF")) random.rev) - divisor (\ ! map (|>> (i64.and (hex "F")) - (i64.or (hex "1")) - (i64.right_rotated 8) - .rev) + divisor (\ ! each (|>> (i64.and (hex "F")) + (i64.or (hex "1")) + (i64.right_rotated 8) + .rev) random.nat)] dividend (random.only (/.> .0) dividend) divisor/0 divisor divisor/1 (random.only (|>> (/.= divisor/0) not) divisor) - scale (\ ! map (|>> (n.% 10) ++) + scale (\ ! each (|>> (n.% 10) ++) random.nat)] ($_ _.and (_.cover [/./] @@ -155,7 +155,7 @@ (/.= (/.reciprocal sample) (|> sample /.reciprocal .nat /.reciprocal .nat /.reciprocal)))) (do {! random.monad} - [expected (\ ! map (|>> f.abs (f.% +1.0)) + [expected (\ ! each (|>> f.abs (f.% +1.0)) random.safe_frac) sample random.rev] (_.cover [/.frac] diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 742523a67..7d397e5d5 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -248,13 +248,13 @@ (_.cover [/.imported_modules] (and (|> (/.imported_modules expected_current_module) (/.result expected_lux) - (try\map (\ (list.equivalence text.equivalence) = - (list imported_module_name))) + (try\each (\ (list.equivalence text.equivalence) = + (list imported_module_name))) (try.else false)) (|> (/.imported_modules imported_module_name) (/.result expected_lux) - (try\map (\ (list.equivalence text.equivalence) = - (list))) + (try\each (\ (list.equivalence text.equivalence) = + (list))) (try.else false)))) (_.cover [/.imported_by?] (|> (/.imported_by? imported_module_name expected_current_module) @@ -290,8 +290,8 @@ version (random.ascii/upper 1) source_code (random.ascii/upper 1) expected_current_module (random.ascii/upper 1) - expected_type (\ ! map (function (_ name) - (#.Primitive name (list))) + expected_type (\ ! each (function (_ name) + (#.Primitive name (list))) (random.ascii/upper 1)) expected_seed random.nat expected random.nat @@ -338,7 +338,7 @@ (_.cover [.Type_Context /.type_context] (|> /.type_context (/.result expected_lux) - (try\map (same? type_context)) + (try\each (same? type_context)) (try.else false))) ))) @@ -349,8 +349,8 @@ expected_macro_module (random.only (|>> (text\= expected_current_module) not) (random.ascii/upper 1)) expected_short (random.ascii/upper 1) - expected_type (\ ! map (function (_ name) - (#.Primitive name (list))) + expected_type (\ ! each (function (_ name) + (#.Primitive name (list))) (random.ascii/upper 1)) expected_value (random.either (in .def:) (in .macro:)) @@ -470,8 +470,8 @@ expected_macro_module (random.only (|>> (text\= expected_current_module) not) (random.ascii/upper 1)) expected_short (random.ascii/upper 1) - expected_type (\ ! map (function (_ name) - (#.Primitive name (list))) + expected_type (\ ! each (function (_ name) + (#.Primitive name (list))) (random.ascii/upper 1)) .let [expected_annotations (' [])] expected_value (random.either (in .def:) @@ -580,11 +580,11 @@ (expected_lux true (#.Some .Macro))] (and (|> (/.de_aliased [expected_macro_module expected_short]) (/.result expected_lux) - (try\map (name\= [expected_macro_module expected_short])) + (try\each (name\= [expected_macro_module expected_short])) (try.else false)) (|> (/.de_aliased [expected_current_module expected_short]) (/.result expected_lux) - (try\map (name\= [expected_macro_module expected_short])) + (try\each (name\= [expected_macro_module expected_short])) (try.else false))))) (_.cover [/.definition] (let [[current_globals macro_globals expected_lux] @@ -654,11 +654,11 @@ name_1 (random.only (|>> (text\= name_0) not) (random.ascii/upper 1)) - .let [random_tag (\ ! map (|>> [tag_module]) + .let [random_tag (\ ! each (|>> [tag_module]) (random.ascii/upper 1))] all_tags (|> random_tag (random.set name.hash 10) - (\ ! map set.list)) + (\ ! each set.list)) .let [tags_0 (list.first 5 all_tags) tags_1 (list.after 5 all_tags) @@ -690,14 +690,14 @@ #.module_aliases (list) #.definitions (list) #.imports (list) - #.tags (list\compose (|> tags_0 - list.enumeration - (list\map (function (_ [index [_ short]]) - [short [index tags_0 false type_0]]))) - (|> tags_1 - list.enumeration - (list\map (function (_ [index [_ short]]) - [short [index tags_1 true type_1]])))) + #.tags (list\composite (|> tags_0 + list.enumeration + (list\each (function (_ [index [_ short]]) + [short [index tags_0 false type_0]]))) + (|> tags_1 + list.enumeration + (list\each (function (_ [index [_ short]]) + [short [index tags_1 true type_1]])))) #.types (list entry_0 entry_1) #.module_annotations #.None #.module_state #.Active}]) @@ -719,12 +719,12 @@ type.equivalence))] (|> (/.tag_lists tag_module) (/.result expected_lux) - (try\map (\ equivalence = (list [tags_1 type_1]))) + (try\each (\ equivalence = (list [tags_1 type_1]))) (try.else false)))) (_.cover [/.tags_of] (|> (/.tags_of [tag_module name_1]) (/.result expected_lux) - (try\map (\ (maybe.equivalence (list.equivalence name.equivalence)) = (#.Some tags_1))) + (try\each (\ (maybe.equivalence (list.equivalence name.equivalence)) = (#.Some tags_1))) (try.else false))) (_.cover [/.tag] (|> tags_1 @@ -757,7 +757,7 @@ [current_module (random.ascii/upper 1) [name_0 name_1 name_2 name_3 name_4] (|> (random.ascii/upper 1) (random.set text.hash 5) - (\ ! map set.list) + (\ ! each set.list) (random.one (function (_ values) (case values (^ (list name_0 name_1 name_2 name_3 name_4)) @@ -831,51 +831,51 @@ type.equivalence))))] (|> /.locals (/.result expected_lux) - (try\map (\ equivalence = (list (list [name_3 type_3]) - (list [name_1 type_1] - [name_2 type_2])))) + (try\each (\ equivalence = (list (list [name_3 type_3]) + (list [name_1 type_1] + [name_2 type_2])))) (try.else false)))) (_.cover [/.var_type] (and (|> (/.var_type name_0) (/.result expected_lux) - (try\map (\ type.equivalence = type_0)) + (try\each (\ type.equivalence = type_0)) (try.else false)) (|> (/.var_type name_1) (/.result expected_lux) - (try\map (\ type.equivalence = type_1)) + (try\each (\ type.equivalence = type_1)) (try.else false)) (|> (/.var_type name_2) (/.result expected_lux) - (try\map (\ type.equivalence = type_2)) + (try\each (\ type.equivalence = type_2)) (try.else false)) (|> (/.var_type name_3) (/.result expected_lux) - (try\map (\ type.equivalence = type_3)) + (try\each (\ type.equivalence = type_3)) (try.else false)))) (_.cover [/.type] (and (|> (/.type ["" name_0]) (/.result expected_lux) - (try\map (\ type.equivalence = type_0)) + (try\each (\ type.equivalence = type_0)) (try.else false)) (|> (/.type ["" name_1]) (/.result expected_lux) - (try\map (\ type.equivalence = type_1)) + (try\each (\ type.equivalence = type_1)) (try.else false)) (|> (/.type ["" name_2]) (/.result expected_lux) - (try\map (\ type.equivalence = type_2)) + (try\each (\ type.equivalence = type_2)) (try.else false)) (|> (/.type ["" name_3]) (/.result expected_lux) - (try\map (\ type.equivalence = type_3)) + (try\each (\ type.equivalence = type_3)) (try.else false)) (|> (/.type [current_module name_4]) (/.result expected_lux) - (try\map (\ type.equivalence = type_4)) + (try\each (\ type.equivalence = type_4)) (try.else false)) (|> (/.type ["" name_4]) (/.result expected_lux) - (try\map (\ type.equivalence = type_4)) + (try\each (\ type.equivalence = type_4)) (try.else false)))) ))) @@ -904,8 +904,8 @@ version (random.ascii/upper 1) source_code (random.ascii/upper 1) expected_current_module (random.ascii/upper 1) - expected_type (\ ! map (function (_ name) - (#.Primitive name (list))) + expected_type (\ ! each (function (_ name) + (#.Primitive name (list))) (random.ascii/upper 1)) expected_seed random.nat expected random.nat diff --git a/stdlib/source/test/lux/meta/annotation.lux b/stdlib/source/test/lux/meta/annotation.lux index e0fa2d3e5..f80ffeb29 100644 --- a/stdlib/source/test/lux/meta/annotation.lux +++ b/stdlib/source/test/lux/meta/annotation.lux @@ -36,13 +36,13 @@ (def: (random_sequence random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} - [size (|> random.nat (\ ! map (nat.% 3)))] + [size (|> random.nat (\ ! each (nat.% 3)))] (random.list size random))) (def: (random_record random) (All [a] (-> (Random a) (Random (List [a a])))) (do {! random.monad} - [size (|> random.nat (\ ! map (nat.% 3)))] + [size (|> random.nat (\ ! each (nat.% 3)))] (random.list size (random.and random random)))) (template: (!expect <pattern> <value>) @@ -115,7 +115,6 @@ [/.implementation? #.implementation?] [/.recursive_type? #.type_rec?] - [/.interface? #.interface?] )) )))) @@ -128,11 +127,11 @@ [(do ! [expected (random.list 5 (random.ascii/alpha 1))] (_.cover [<definition>] - (and (|> expected (list\map code.text) code.tuple + (and (|> expected (list\each code.text) code.tuple (..annotation (name_of <tag>)) <definition> (\ (list.equivalence text.equivalence) = expected)) - (|> expected (list\map code.text) code.tuple + (|> expected (list\each code.text) code.tuple (..annotation key) <definition> (\ (list.equivalence text.equivalence) = (list))))))] diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index 2a21207d4..541e7c763 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -55,7 +55,7 @@ ["." category (#+ Value Object Class)]]]]) (def: method_modifier - ($_ /modifier\compose + ($_ /modifier\composite /method.public /method.static)) @@ -134,11 +134,12 @@ false)))) (type: (Primitive a) - {#unboxed (Type category.Return) - #boxed (Type category.Class) - #wrap (Bytecode Any) - #random (Random a) - #literal (-> a (Bytecode Any))}) + (Record + {#unboxed (Type category.Return) + #boxed (Type category.Class) + #wrap (Bytecode Any) + #random (Random a) + #literal (-> a (Bytecode Any))})) (def: $Boolean (/type.class "java.lang.Boolean" (list))) @@ -166,7 +167,7 @@ (/.invokestatic ..$Byte "valueOf" (/type.method [(list) (list /type.byte) ..$Byte (list)]))) (def: $Byte::random (Random java/lang/Byte) - (\ random.monad map (|>> (:as java/lang/Long) ffi.long_to_byte) random.int)) + (\ random.monad each (|>> (:as java/lang/Long) ffi.long_to_byte) random.int)) (def: $Byte::literal (-> java/lang/Byte (Bytecode Any)) (|>> ffi.byte_to_long (:as I64) i32.i32 /.int)) @@ -184,7 +185,7 @@ (/.invokestatic ..$Short "valueOf" (/type.method [(list) (list /type.short) ..$Short (list)]))) (def: $Short::random (Random java/lang/Short) - (\ random.monad map (|>> (:as java/lang/Long) ffi.long_to_short) random.int)) + (\ random.monad each (|>> (:as java/lang/Long) ffi.long_to_short) random.int)) (def: $Short::literal (-> java/lang/Short (Bytecode Any)) (|>> ffi.short_to_long (:as I64) i32.i32 /.int)) @@ -202,7 +203,7 @@ (/.invokestatic ..$Integer "valueOf" (/type.method [(list) (list /type.int) ..$Integer (list)]))) (def: $Integer::random (Random java/lang/Integer) - (\ random.monad map (|>> (:as java/lang/Long) ffi.long_to_int) random.int)) + (\ random.monad each (|>> (:as java/lang/Long) ffi.long_to_int) random.int)) (def: $Integer::literal (-> java/lang/Integer (Bytecode Any)) (|>> ffi.int_to_long (:as I64) i32.i32 /.int)) @@ -230,7 +231,7 @@ (def: $Float::wrap (/.invokestatic ..$Float "valueOf" (/type.method [(list) (list /type.float) ..$Float (list)]))) (def: $Float::random (Random java/lang/Float) - (\ random.monad map + (\ random.monad each (|>> (:as java/lang/Double) ffi.double_to_float) random.frac)) (def: $Float::literal /.float) @@ -270,7 +271,7 @@ (/.invokestatic ..$Character "valueOf" (/type.method [(list) (list /type.char) ..$Character (list)]))) (def: $Character::random (Random java/lang/Character) - (\ random.monad map (|>> (:as java/lang/Long) ffi.long_to_int ffi.int_to_char) random.int)) + (\ random.monad each (|>> (:as java/lang/Long) ffi.long_to_int ffi.int_to_char) random.int)) (def: $Character::literal (-> java/lang/Character (Bytecode Any)) (|>> ffi.char_to_long (:as I64) i32.i32 /.int)) @@ -305,7 +306,7 @@ [(def: <name> Test (do {! random.monad} - [expected (\ ! map (i64.and (i64.mask <bits>)) random.nat)] + [expected (\ ! each (i64.and (i64.mask <bits>)) random.nat)] (<| (_.lifted <message>) (..bytecode (for {@.old (|>> (:as <type>) <to_long> ("jvm leq" expected)) @@ -383,7 +384,7 @@ shift (: (-> (-> java/lang/Integer java/lang/Integer java/lang/Integer) (Bytecode Any) (Random Bit)) (function (_ reference instruction) (do {! random.monad} - [parameter (\ ! map (|>> (n.% 32) .int (:as java/lang/Long) ffi.long_to_int) random.nat) + [parameter (\ ! each (|>> (n.% 32) .int (:as java/lang/Long) ffi.long_to_int) random.nat) subject ..$Integer::random] (int (reference parameter subject) (do /.monad @@ -462,7 +463,7 @@ shift (: (-> (-> java/lang/Integer java/lang/Long java/lang/Long) (Bytecode Any) (Random Bit)) (function (_ reference instruction) (do {! random.monad} - [parameter (\ ! map (|>> (n.% 64) (:as java/lang/Long)) random.nat) + [parameter (\ ! each (|>> (n.% 64) (:as java/lang/Long)) random.nat) subject ..$Long::random] (long (reference (ffi.long_to_int parameter) subject) (do /.monad @@ -869,7 +870,7 @@ _ /.lload_1 _ (/.putfield $Self object_field /type.long)] /.return))) - (/method.method ($_ /modifier\compose + (/method.method ($_ /modifier\composite /method.public /method.static) static_method @@ -943,7 +944,7 @@ Test)) (function (_ constructor random literal [*store *load *wrap] test) (do {! random.monad} - [size (\ ! map (|>> (n.% 1024) (n.max 1)) random.nat) + [size (\ ! each (|>> (n.% 1024) (n.max 1)) random.nat) value random] ($_ _.and (<| (_.lifted "length") @@ -1015,7 +1016,7 @@ (function (_ expected) (|>> (:as Text) (text\= (:as Text expected)))))) (<| (_.context "multi") (do {! random.monad} - [.let [size (\ ! map (|>> (n.% 5) (n.+ 1)) + [.let [size (\ ! each (|>> (n.% 5) (n.+ 1)) random.nat)] dimensions size sizesH size @@ -1029,8 +1030,8 @@ (<| (_.lifted "MULTIANEWARRAY") (..bytecode (|>> (:as Nat) (n.= sizesH))) (do {! /.monad} - [_ (monad.map ! (|>> (:as java/lang/Long) ffi.long_to_int ..$Integer::literal) - (#.Item sizesH sizesT)) + [_ (monad.each ! (|>> (:as java/lang/Long) ffi.long_to_int ..$Integer::literal) + (#.Item sizesH sizesT)) _ (/.multianewarray type (|> dimensions /unsigned.u1 try.trusted)) _ ?length] $Long::wrap)))) @@ -1128,7 +1129,7 @@ (function (_ random_value literal *wrap [store load] test) (do {! random.monad} [expected random_value - register (\ ! map (n.% 128) random.nat)] + register (\ ! each (n.% 128) random.nat)] (<| (..bytecode (test expected)) (do /.monad [_ (literal expected) @@ -1152,7 +1153,7 @@ (_.lifted "IINC" (do {! random.monad} [base ..$Byte::random - increment (\ ! map (|>> (n.% 100) /unsigned.u1 try.trusted) + increment (\ ! each (|>> (n.% 100) /unsigned.u1 try.trusted) random.nat) .let [expected (: java/lang/Long (for {@.old @@ -1476,9 +1477,9 @@ (do {! random.monad} [expected ..$Long::random dummy ..$Long::random - minimum (\ ! map (|>> (n.% 100) .int /signed.s4 try.trusted) + minimum (\ ! each (|>> (n.% 100) .int /signed.s4 try.trusted) random.nat) - afterwards (\ ! map (n.% 10) random.nat)]) + afterwards (\ ! each (n.% 10) random.nat)]) (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) (do /.monad [@right /.new_label @@ -1495,13 +1496,13 @@ ..$Long::wrap)) (<| (_.lifted "LOOKUPSWITCH") (do {! random.monad} - [options (\ ! map (|>> (n.% 10) (n.+ 1)) + [options (\ ! each (|>> (n.% 10) (n.+ 1)) random.nat) - choice (\ ! map (n.% options) random.nat) + choice (\ ! each (n.% options) random.nat) options (|> random.int - (\ ! map (|>> (:as java/lang/Long) ffi.long_to_int ffi.int_to_long (:as Int))) + (\ ! each (|>> (:as java/lang/Long) ffi.long_to_int ffi.int_to_long (:as Int))) (random.set i.hash options) - (\ ! map set.list)) + (\ ! each set.list)) .let [choice (maybe.trusted (list.item choice options))] expected ..$Long::random dummy ..$Long::random]) @@ -1511,10 +1512,10 @@ @wrong /.new_label @return /.new_label _ (..$Integer::literal (ffi.long_to_int (:as java/lang/Long choice))) - _ (/.lookupswitch @wrong (list\map (function (_ option) - [(|> option /signed.s4 try.trusted) - (if (i.= choice option) @right @wrong)]) - options)) + _ (/.lookupswitch @wrong (list\each (function (_ option) + [(|> option /signed.s4 try.trusted) + (if (i.= choice option) @right @wrong)]) + options)) _ (/.set_label @wrong) _ (..$Long::literal dummy) _ (/.goto @return) @@ -1626,17 +1627,17 @@ [_ (..$Long::literal value)] /.lreturn))))) - interface_bytecode (|> (/class.class /version.v6_0 ($_ /modifier\compose /class.public /class.abstract /class.interface) + interface_bytecode (|> (/class.class /version.v6_0 ($_ /modifier\composite /class.public /class.abstract /class.interface) (/name.internal interface_class) (/name.internal "java.lang.Object") (list) (list) - (list (/method.method ($_ /modifier\compose /method.public /method.abstract) + (list (/method.method ($_ /modifier\composite /method.public /method.abstract) interface_method method::type (list) #.None)) (row.row)) try.trusted (format.result /class.writer)) - abstract_bytecode (|> (/class.class /version.v6_0 ($_ /modifier\compose /class.public /class.abstract) + abstract_bytecode (|> (/class.class /version.v6_0 ($_ /modifier\composite /class.public /class.abstract) (/name.internal abstract_class) (/name.internal "java.lang.Object") (list) @@ -1651,7 +1652,7 @@ /.return))) (method inherited_method part0) (method overriden_method fake_part2) - (/method.method ($_ /modifier\compose /method.public /method.abstract) + (/method.method ($_ /modifier\composite /method.public /method.abstract) abstract_method method::type (list) #.None)) (row.row)) try.trusted @@ -1678,7 +1679,7 @@ (method overriden_method part2) (method abstract_method part3) (method interface_method part4) - (/method.method ($_ /modifier\compose + (/method.method ($_ /modifier\composite /method.public /method.static) static_method diff --git a/stdlib/source/test/lux/test.lux b/stdlib/source/test/lux/test.lux index e51623e28..516f1eb51 100644 --- a/stdlib/source/test/lux/test.lux +++ b/stdlib/source/test/lux/test.lux @@ -99,7 +99,7 @@ (n.= 0 (value@ #/.successes tally)) (n.= 1 (value@ #/.failures tally))))))) (do {! random.monad} - [expected (\ ! map (|>> (n.% 10) ++) random.nat) + [expected (\ ! each (|>> (n.% 10) ++) random.nat) .let [counter (: (Atom Nat) (atom.atom 0))] times_assertion (<| (/.times expected) @@ -120,7 +120,7 @@ /.Test ($_ /.and (do {! random.monad} - [expected (\ ! map (|>> (n.% 10) ++) random.nat) + [expected (\ ! each (|>> (n.% 10) ++) random.nat) .let [counter (: (Atom Nat) (atom.atom 0))] assertion (<| /.in_parallel @@ -138,7 +138,7 @@ (n.= expected (value@ #/.successes tally)) (n.= 0 (value@ #/.failures tally))))))) (do {! random.monad} - [expected (\ ! map (|>> (n.% 10) ++) random.nat) + [expected (\ ! each (|>> (n.% 10) ++) random.nat) .let [counter (: (Atom Nat) (atom.atom 0))] assertion (<| /.in_parallel diff --git a/stdlib/source/test/lux/time.lux b/stdlib/source/test/lux/time.lux index 81c56089d..c1f967528 100644 --- a/stdlib/source/test/lux/time.lux +++ b/stdlib/source/test/lux/time.lux @@ -53,16 +53,16 @@ (|> expected /.clock /.time - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))))) (def: for_ranges Test (do {! random.monad} - [valid_hour (\ ! map (|>> (n.% /.hours) (n.max 10)) random.nat) - valid_minute (\ ! map (|>> (n.% /.minutes) (n.max 10)) random.nat) - valid_second (\ ! map (|>> (n.% /.seconds) (n.max 10)) random.nat) - valid_milli_second (\ ! map (n.% /.milli_seconds) random.nat) + [valid_hour (\ ! each (|>> (n.% /.hours) (n.max 10)) random.nat) + valid_minute (\ ! each (|>> (n.% /.minutes) (n.max 10)) random.nat) + valid_second (\ ! each (|>> (n.% /.seconds) (n.max 10)) random.nat) + valid_milli_second (\ ! each (n.% /.milli_seconds) random.nat) .let [invalid_hour (|> valid_hour (n.+ /.hours)) invalid_minute (|> valid_minute (n.+ /.minutes) (n.min 99)) @@ -114,7 +114,7 @@ [.let [day (.nat (duration.millis duration.day))] expected random.time - out_of_bounds (\ ! map (|>> /.millis (n.+ day)) + out_of_bounds (\ ! each (|>> /.millis (n.+ day)) random.time)] (`` ($_ _.and ..for_implementation @@ -123,7 +123,7 @@ (|> expected /.millis /.of_millis - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))) (_.cover [/.time_exceeds_a_day] (case (/.of_millis out_of_bounds) @@ -140,7 +140,7 @@ (|> expected (\ /.codec encoded) (<text>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))) ..for_ranges (_.for [/.Clock] diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux index 87e54e623..2492e1e31 100644 --- a/stdlib/source/test/lux/time/date.lux +++ b/stdlib/source/test/lux/time/date.lux @@ -45,7 +45,7 @@ (|> (/.date (/.year expected) (/.month expected) (/.day_of_month expected)) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) (do random.monad [expected random.date] @@ -74,14 +74,14 @@ (_.cover [/.parser] (|> (\ /.codec encoded expected) (<text>.result /.parser) - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false)))) (do {! random.monad} - [year (\ ! map (|>> (n.% 10,000) ++) + [year (\ ! each (|>> (n.% 10,000) ++) random.nat) - month (\ ! map (|>> (n.% 10) (n.+ 13)) + month (\ ! each (|>> (n.% 10) (n.+ 13)) random.nat) - day (\ ! map (|>> (n.% 10) (n.+ 10)) + day (\ ! each (|>> (n.% 10) (n.+ 10)) random.nat) .let [input (format (%.nat year) "-" (%.nat month) diff --git a/stdlib/source/test/lux/time/day.lux b/stdlib/source/test/lux/time/day.lux index 462a96939..82a3f3df1 100644 --- a/stdlib/source/test/lux/time/day.lux +++ b/stdlib/source/test/lux/time/day.lux @@ -69,7 +69,7 @@ (|> expected /.number /.by_number - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))) (_.cover [/.invalid_day] (case (/.by_number invalid) diff --git a/stdlib/source/test/lux/time/duration.lux b/stdlib/source/test/lux/time/duration.lux index f522dc613..5eb56c94b 100644 --- a/stdlib/source/test/lux/time/duration.lux +++ b/stdlib/source/test/lux/time/duration.lux @@ -67,10 +67,10 @@ [.let [(^open "\.") /.order positive (|> random.duration (random.only (|>> (\= /.empty) not)) - (\ ! map (function (_ duration) - (if (/.positive? duration) - duration - (/.inverse duration)))))] + (\ ! each (function (_ duration) + (if (/.positive? duration) + duration + (/.inverse duration)))))] sample positive frame positive] (`` ($_ _.and diff --git a/stdlib/source/test/lux/time/month.lux b/stdlib/source/test/lux/time/month.lux index 7f5487069..0874c2ec1 100644 --- a/stdlib/source/test/lux/time/month.lux +++ b/stdlib/source/test/lux/time/month.lux @@ -31,7 +31,7 @@ (Random /.Month) (let [december (/.number #/.December)] (|> random.nat - (\ random.monad map (|>> (n.% december) ++)) + (\ random.monad each (|>> (n.% december) ++)) (random.one (|>> /.by_number try.maybe))))) (def: .public test @@ -60,7 +60,7 @@ (|> expected /.number /.by_number - (try\map (\ /.equivalence = expected)) + (try\each (\ /.equivalence = expected)) (try.else false))) (_.cover [/.invalid_month] (case (/.by_number invalid) @@ -79,13 +79,13 @@ (_.cover [/.days] (let [expected (.nat (duration.ticks duration.day duration.normal_year))] (|> /.year - (list\map /.days) + (list\each /.days) (list\mix n.+ 0) (n.= expected)))) (_.cover [/.leap_year_days] (let [expected (.nat (duration.ticks duration.day duration.leap_year))] (|> /.year - (list\map /.leap_year_days) + (list\each /.leap_year_days) (list\mix n.+ 0) (n.= expected)))) (do random.monad diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux index 92acc8672..43a7fd17a 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -45,7 +45,7 @@ #.End (#.Item head+ #.End) - (list\map (|>> list) head+) + (list\each (|>> list) head+) (#.Item head+ tail++) (do list.monad @@ -84,33 +84,33 @@ [_ (#.Tuple members)] (do {! r.monad} - [member_wise_patterns (monad.map ! (exhaustive_branches allow_literals? variantTC) members)] + [member_wise_patterns (monad.each ! (exhaustive_branches allow_literals? variantTC) members)] (in (|> member_wise_patterns exhaustive_weaving - (list\map code.tuple)))) + (list\each code.tuple)))) (^ [_ (#.Record (list))]) (r\in (list (' {}))) [_ (#.Record kvs)] (do {! r.monad} - [.let [ks (list\map product.left kvs) - vs (list\map product.right kvs)] - member_wise_patterns (monad.map ! (exhaustive_branches allow_literals? variantTC) vs)] + [.let [ks (list\each product.left kvs) + vs (list\each product.right kvs)] + member_wise_patterns (monad.each ! (exhaustive_branches allow_literals? variantTC) vs)] (in (|> member_wise_patterns exhaustive_weaving - (list\map (|>> (list.zipped/2 ks) code.record))))) + (list\each (|>> (list.zipped/2 ks) code.record))))) (^ [_ (#.Form (list [_ (#.Tag _)] _))]) (do {! r.monad} - [bundles (monad.map ! - (function (_ [_tag _code]) - (do ! - [v_branches (exhaustive_branches allow_literals? variantTC _code)] - (in (list\map (function (_ pattern) (` ((~ _tag) (~ pattern)))) - v_branches)))) - variantTC)] - (in (list\join bundles))) + [bundles (monad.each ! + (function (_ [_tag _code]) + (do ! + [v_branches (exhaustive_branches allow_literals? variantTC _code)] + (in (list\each (function (_ pattern) (` ((~ _tag) (~ pattern)))) + v_branches)))) + variantTC)] + (in (list\conjoint bundles))) _ (r\in (list)) @@ -121,14 +121,14 @@ (r.rec (function (_ input) ($_ r.either - (r\map product.right _primitive.primitive) + (r\each product.right _primitive.primitive) (do {! r.monad} - [choice (|> r.nat (\ ! map (n.% (list.size variant_tags)))) + [choice (|> r.nat (\ ! each (n.% (list.size variant_tags)))) .let [choiceT (maybe.trusted (list.item choice variant_tags)) choiceC (maybe.trusted (list.item choice primitivesC))]] (in (` ((~ choiceT) (~ choiceC))))) (do {! r.monad} - [size (|> r.nat (\ ! map (n.% 3))) + [size (|> r.nat (\ ! each (n.% 3))) elems (r.list size input)] (in (code.tuple elems))) (r\in (code.record (list.zipped/2 record_tags primitivesC))) @@ -144,15 +144,15 @@ [module_name (r.unicode 5) variant_name (r.unicode 5) record_name (|> (r.unicode 5) (r.only (|>> (text\= variant_name) not))) - size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) - variant_tags (|> (r.set text.hash size (r.unicode 5)) (\ ! map set.list)) - record_tags (|> (r.set text.hash size (r.unicode 5)) (\ ! map set.list)) + size (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) + variant_tags (|> (r.set text.hash size (r.unicode 5)) (\ ! each set.list)) + record_tags (|> (r.set text.hash size (r.unicode 5)) (\ ! each set.list)) primitivesTC (r.list size _primitive.primitive) - .let [primitivesT (list\map product.left primitivesTC) - primitivesC (list\map product.right primitivesTC) + .let [primitivesT (list\each product.left primitivesTC) + primitivesC (list\each product.right primitivesTC) code_tag (|>> [module_name] code.tag) - variant_tags+ (list\map code_tag variant_tags) - record_tags+ (list\map code_tag record_tags) + variant_tags+ (list\each code_tag variant_tags) + record_tags+ (list\each code_tag record_tags) variantTC (list.zipped/2 variant_tags+ primitivesC)] inputC (input variant_tags+ record_tags+ primitivesC) [outputT outputC] (r.only (|>> product.left (same? Any) not) @@ -170,8 +170,8 @@ (type.tuple primitivesT)))]) (//module.with_module 0 module_name)))] exhaustive_patterns (exhaustive_branches true variantTC inputC) - .let [exhaustive_branchesC (list\map (branch outputC) - exhaustive_patterns)]] + .let [exhaustive_branchesC (list\each (branch outputC) + exhaustive_patterns)]] ($_ _.and (_.test "Will reject empty pattern-matching (no branches)." (|> (analyse_pm (list)) @@ -186,8 +186,8 @@ _structure.check_fails))) (do ! [redundant_patterns (exhaustive_branches false variantTC inputC) - redundancy_idx (|> r.nat (\ ! map (n.% (list.size redundant_patterns)))) - .let [redundant_branchesC (<| (list!map (branch outputC)) + redundancy_idx (|> r.nat (\ ! each (n.% (list.size redundant_patterns)))) + .let [redundant_branchesC (<| (list!each (branch outputC)) list.together (list (list.first redundancy_idx redundant_patterns) (list (maybe.trusted (list.item redundancy_idx redundant_patterns))) @@ -198,7 +198,7 @@ (do ! [[heterogeneousT heterogeneousC] (r.only (|>> product.left (check.subsumes? outputT) not) _primitive.primitive) - heterogeneous_idx (|> r.nat (\ ! map (n.% (list.size exhaustive_patterns)))) + heterogeneous_idx (|> r.nat (\ ! each (n.% (list.size exhaustive_patterns)))) .let [heterogeneous_branchesC (list.together (list (list.first heterogeneous_idx exhaustive_branchesC) (list (let [[_pattern _body] (maybe.trusted (list.item heterogeneous_idx exhaustive_branchesC))] [_pattern heterogeneousC])) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux index b0feacead..d87321459 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -81,12 +81,12 @@ (def: apply (do {! r.monad} - [full_args (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) - partial_args (|> r.nat (\ ! map (n.% full_args))) - var_idx (|> r.nat (\ ! map (|>> (n.% full_args) (n.max 1)))) + [full_args (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) + partial_args (|> r.nat (\ ! each (n.% full_args))) + var_idx (|> r.nat (\ ! each (|>> (n.% full_args) (n.max 1)))) inputsTC (r.list full_args _primitive.primitive) - .let [inputsT (list\map product.left inputsTC) - inputsC (list\map product.right inputsTC)] + .let [inputsT (list\each product.left inputsTC) + inputsC (list\each product.right inputsTC)] [outputT outputC] _primitive.primitive .let [funcT (type.function inputsT outputT) partialT (type.function (list.after partial_args inputsT) outputT) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/primitive.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/primitive.lux index fcec6b95c..1016f975d 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/primitive.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/primitive.lux @@ -54,7 +54,7 @@ (Random [Type Code]) (`` ($_ r.either (~~ (template [<type> <code_wrapper> <value_gen>] - [(r.and (r\in <type>) (r\map <code_wrapper> <value_gen>))] + [(r.and (r\in <type>) (r\each <code_wrapper> <value_gen>))] [Any code.tuple (r.list 0 (r\in (' [])))] [Bit code.bit r.bit] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux index ef7be9dcd..812e876bb 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux @@ -1,6 +1,7 @@ (.module: [lux #* - [abstract ["." monad (#+ do)]] + [abstract + ["." monad (#+ do)]] [data ["." name ("#\." equivalence)]] ["r" math/random (#+ Random)] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux index 1b8939368..4802c0910 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -119,19 +119,19 @@ (def: sum (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) - choice (|> r.nat (\ ! map (n.% size))) + [size (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) + choice (|> r.nat (\ ! each (n.% size))) primitives (r.list size _primitive.primitive) - +choice (|> r.nat (\ ! map (n.% (++ size)))) + +choice (|> r.nat (\ ! each (n.% (++ size)))) [_ +valueC] _primitive.primitive - .let [variantT (type.variant (list\map product.left primitives)) + .let [variantT (type.variant (list\each product.left primitives)) [valueT valueC] (maybe.trusted (list.item choice primitives)) +size (++ size) +primitives (list.together (list (list.first choice primitives) (list [(#.Parameter 1) +valueC]) (list.after choice primitives))) [+valueT +valueC] (maybe.trusted (list.item +choice +primitives)) - +variantT (type.variant (list\map product.left +primitives))]] + +variantT (type.variant (list\each product.left +primitives))]] (<| (_.context (%.name (name_of /.sum))) ($_ _.and (_.test "Can analyse." @@ -171,21 +171,21 @@ (def: product (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) + [size (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) primitives (r.list size _primitive.primitive) - choice (|> r.nat (\ ! map (n.% size))) + choice (|> r.nat (\ ! each (n.% size))) [_ +valueC] _primitive.primitive - .let [tupleT (type.tuple (list\map product.left primitives)) + .let [tupleT (type.tuple (list\each product.left primitives)) [singletonT singletonC] (|> primitives (list.item choice) maybe.trusted) +primitives (list.together (list (list.first choice primitives) (list [(#.Parameter 1) +valueC]) (list.after choice primitives))) - +tupleT (type.tuple (list\map product.left +primitives))]] + +tupleT (type.tuple (list\each product.left +primitives))]] (<| (_.context (%.name (name_of /.product))) ($_ _.and (_.test "Can analyse." (|> (//type.with_type tupleT - (/.product archive.empty _primitive.phase (list\map product.right primitives))) + (/.product archive.empty _primitive.phase (list\each product.right primitives))) (phase.result _primitive.state) (case> (#try.Success tupleA) (correct_size? size tupleA) @@ -194,7 +194,7 @@ false))) (_.test "Can infer." (|> (//type.with_inference - (/.product archive.empty _primitive.phase (list\map product.right primitives))) + (/.product archive.empty _primitive.phase (list\each product.right primitives))) (phase.result _primitive.state) (case> (#try.Success [_type tupleA]) (and (check.subsumes? tupleT _type) @@ -210,9 +210,9 @@ (|> (do phase.monad [[_ varT] (//type.with_env check.var) _ (//type.with_env - (check.check varT (type.tuple (list\map product.left primitives))))] + (check.check varT (type.tuple (list\each product.left primitives))))] (//type.with_type varT - (/.product archive.empty _primitive.phase (list\map product.right primitives)))) + (/.product archive.empty _primitive.phase (list\each product.right primitives)))) (phase.result _primitive.state) (case> (#try.Success tupleA) (correct_size? size tupleA) @@ -221,26 +221,26 @@ false))) (_.test "Can analyse through existential quantification." (|> (//type.with_type (type.ex_q 1 +tupleT) - (/.product archive.empty _primitive.phase (list\map product.right +primitives))) + (/.product archive.empty _primitive.phase (list\each product.right +primitives))) check_succeeds)) (_.test "Cannot analyse through universal quantification." (|> (//type.with_type (type.univ_q 1 +tupleT) - (/.product archive.empty _primitive.phase (list\map product.right +primitives))) + (/.product archive.empty _primitive.phase (list\each product.right +primitives))) check_fails)) )))) (def: variant (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) - tags (|> (r.set text.hash size (r.unicode 5)) (\ ! map set.list)) - choice (|> r.nat (\ ! map (n.% size))) - other_choice (|> r.nat (\ ! map (n.% size)) (r.only (|>> (n.= choice) not))) + [size (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) + tags (|> (r.set text.hash size (r.unicode 5)) (\ ! each set.list)) + choice (|> r.nat (\ ! each (n.% size))) + other_choice (|> r.nat (\ ! each (n.% size)) (r.only (|>> (n.= choice) not))) primitives (r.list size _primitive.primitive) module_name (r.unicode 5) type_name (r.unicode 5) .let [with_name (|>> (#.Named [module_name type_name])) varT (#.Parameter 1) - primitivesT (list\map product.left primitives) + primitivesT (list\each product.left primitives) [choiceT choiceC] (maybe.trusted (list.item choice primitives)) [other_choiceT other_choiceC] (maybe.trusted (list.item other_choice primitives)) monoT (type.variant primitivesT) @@ -277,16 +277,16 @@ (def: record (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) - tags (|> (r.set text.hash size (r.unicode 5)) (\ ! map set.list)) + [size (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) + tags (|> (r.set text.hash size (r.unicode 5)) (\ ! each set.list)) primitives (r.list size _primitive.primitive) module_name (r.unicode 5) type_name (r.unicode 5) - choice (|> r.nat (\ ! map (n.% size))) + choice (|> r.nat (\ ! each (n.% size))) .let [varT (#.Parameter 1) - tagsC (list\map (|>> [module_name] code.tag) tags) - primitivesT (list\map product.left primitives) - primitivesC (list\map product.right primitives) + tagsC (list\each (|>> [module_name] code.tag) tags) + primitivesT (list\each product.left primitives) + primitivesC (list\each product.right primitives) monoT (#.Named [module_name type_name] (type.tuple primitivesT)) recordC (list.zipped/2 tagsC primitivesC) polyT (|> (type.tuple (list.together (list (list.first choice primitivesT) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index 47abe0165..f209a235b 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -73,9 +73,9 @@ (def: i64 Test (do {! r.monad} - [subjectC (|> r.nat (\ ! map code.nat)) - signedC (|> r.int (\ ! map code.int)) - paramC (|> r.nat (\ ! map code.nat))] + [subjectC (|> r.nat (\ ! each code.nat)) + signedC (|> r.int (\ ! each code.int)) + paramC (|> r.nat (\ ! each code.nat))] ($_ _.and (_.test "i64 'and'." (check_success+ "lux i64 and" (list paramC subjectC) Nat)) @@ -100,8 +100,8 @@ (def: int Test (do {! r.monad} - [subjectC (|> r.int (\ ! map code.int)) - paramC (|> r.int (\ ! map code.int))] + [subjectC (|> r.int (\ ! each code.int)) + paramC (|> r.int (\ ! each code.int))] ($_ _.and (_.test "Can multiply integers." (check_success+ "lux i64 *" (list paramC subjectC) Int)) @@ -120,9 +120,9 @@ (def: frac Test (do {! r.monad} - [subjectC (|> r.safe_frac (\ ! map code.frac)) - paramC (|> r.safe_frac (\ ! map code.frac)) - encodedC (|> r.safe_frac (\ ! map (|>> %.frac code.text)))] + [subjectC (|> r.safe_frac (\ ! each code.frac)) + paramC (|> r.safe_frac (\ ! each code.frac)) + encodedC (|> r.safe_frac (\ ! each (|>> %.frac code.text)))] ($_ _.and (_.test "Can add frac numbers." (check_success+ "lux f64 +" (list paramC subjectC) Frac)) @@ -155,11 +155,11 @@ (def: text Test (do {! r.monad} - [subjectC (|> (r.unicode 5) (\ ! map code.text)) - paramC (|> (r.unicode 5) (\ ! map code.text)) - replacementC (|> (r.unicode 5) (\ ! map code.text)) - fromC (|> r.nat (\ ! map code.nat)) - toC (|> r.nat (\ ! map code.nat))] + [subjectC (|> (r.unicode 5) (\ ! each code.text)) + paramC (|> (r.unicode 5) (\ ! each code.text)) + replacementC (|> (r.unicode 5) (\ ! each code.text)) + fromC (|> r.nat (\ ! each code.nat)) + toC (|> r.nat (\ ! each code.nat))] ($_ _.and (_.test "Can test text equivalence." (check_success+ "lux text =" (list paramC subjectC) Bit)) @@ -180,8 +180,8 @@ (def: io Test (do {! r.monad} - [logC (|> (r.unicode 5) (\ ! map code.text)) - exitC (|> r.int (\ ! map code.int))] + [logC (|> (r.unicode 5) (\ ! each code.text)) + exitC (|> r.int (\ ! each code.int))] ($_ _.and (_.test "Can log messages to standard output." (check_success+ "lux io log" (list logC) Any)) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux index f7b169ea3..f3eb32f4e 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -43,7 +43,7 @@ Test (do {! random.monad} [maskedA //primitive.primitive - temp (|> random.nat (\ ! map (n.% 100))) + temp (|> random.nat (\ ! each (n.% 100))) .let [maskA (analysis.control/case [maskedA [[(#analysis.Bind temp) @@ -53,7 +53,7 @@ (|> maskA (//.phase archive.empty) (phase.result [///bundle.empty synthesis.init]) - (try\map (//primitive.corresponds? maskedA)) + (try\each (//primitive.corresponds? maskedA)) (try.default false))))) (def: let_test @@ -110,7 +110,7 @@ (def: random_member (Random synthesis.Member) (do {! random.monad} - [lefts (|> random.nat (\ ! map (n.% 10))) + [lefts (|> random.nat (\ ! each (n.% 10))) right? random.bit] (in (if right? (#.Right lefts) @@ -119,7 +119,7 @@ (def: random_path (Random (analysis.Tuple synthesis.Member)) (do {! random.monad} - [size_1 (|> random.nat (\ ! map (|>> (n.% 10) ++)))] + [size_1 (|> random.nat (\ ! each (|>> (n.% 10) ++)))] (random.list size_1 ..random_member))) (def: (get_pattern path) @@ -131,13 +131,13 @@ (case member (#.Left lefts) (analysis.pattern/tuple - (list\compose (list.repeated lefts (analysis.pattern/unit)) - (list inner (analysis.pattern/unit)))) + (list\composite (list.repeated lefts (analysis.pattern/unit)) + (list inner (analysis.pattern/unit)))) (#.Right lefts) (analysis.pattern/tuple - (list\compose (list.repeated (++ lefts) (analysis.pattern/unit)) - (list inner))))) + (list\composite (list.repeated (++ lefts) (analysis.pattern/unit)) + (list inner))))) (#analysis.Bind @member) (list.reversed path)) @member]))) @@ -146,9 +146,9 @@ Test (do {! random.monad} [recordA (|> random.nat - (\ ! map (|>> analysis.nat)) + (\ ! each (|>> analysis.nat)) (random.list 10) - (\ ! map (|>> analysis.tuple))) + (\ ! each (|>> analysis.tuple))) pathA ..random_path [pattern @member] (get_pattern pathA) .let [getA (analysis.control/case [recordA [[pattern @@ -184,12 +184,12 @@ (All [a] (-> (Hash a) (Random a) (Random [a a a a a]))) (|> random_element (random.set hash 5) - (\ random.monad map (|>> set.list - (case> (^ (list s0 s1 s2 s3 s4)) - [s0 s1 s2 s3 s4] + (\ random.monad each (|>> set.list + (case> (^ (list s0 s1 s2 s3 s4)) + [s0 s1 s2 s3 s4] - _ - (undefined)))))) + _ + (undefined)))))) (template [<name> <hash> <random> <path> <synthesis> <pattern> <analysis>] [(def: <name> @@ -262,7 +262,7 @@ (def: random_tuple (Random [Path Match]) (do {! random.monad} - [mid_size (\ ! map (n.% 4) random.nat) + [mid_size (\ ! each (n.% 4) random.nat) value/first (random.unicode 1) value/mid (random.list mid_size (random.unicode 1)) @@ -290,9 +290,9 @@ branch (: (-> Nat Bit Text Frac Branch) (function (_ lefts right? value body) {#analysis.when (if right? - (analysis.pattern/tuple (list\compose (list.repeated (++ lefts) (analysis.pattern/unit)) - (list (analysis.pattern/text value)))) - (analysis.pattern/tuple ($_ list\compose + (analysis.pattern/tuple (list\composite (list.repeated (++ lefts) (analysis.pattern/unit)) + (list (analysis.pattern/text value)))) + (analysis.pattern/tuple ($_ list\composite (list.repeated lefts (analysis.pattern/unit)) (list (analysis.pattern/text value) (analysis.pattern/unit))))) @@ -303,15 +303,15 @@ (|> (list.zipped/2 value/mid body/mid) (#.Item [value/first body/first]) list.enumeration - (list\map (function (_ [lefts' [value body]]) - (path lefts' false value body))) + (list\each (function (_ [lefts' [value body]]) + (path lefts' false value body))) list.reversed)) [(branch 0 false value/first body/first) - (list\compose (|> (list.zipped/2 value/mid body/mid) - list.enumeration - (list\map (function (_ [lefts' [value body]]) - (branch (++ lefts') false value body)))) - (list (branch (++ mid_size) true value/last body/last)))]]))) + (list\composite (|> (list.zipped/2 value/mid body/mid) + list.enumeration + (list\each (function (_ [lefts' [value body]]) + (branch (++ lefts') false value body)))) + (list (branch (++ mid_size) true value/last body/last)))]]))) (def: random_complex ($_ random.either @@ -328,7 +328,7 @@ (def: case_test Test (do {! random.monad} - [expected_input (\ ! map (|>> .i64 synthesis.i64) random.nat) + [expected_input (\ ! each (|>> .i64 synthesis.i64) random.nat) [expected_path match] ..random_case] (_.cover [/.synthesize_case] (|> (/.synthesize_case //.phase archive.empty expected_input match) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 6190c05aa..f66e00492 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -53,9 +53,9 @@ (list\mix (function (_ arity_1 body) (case arity_1 0 (#analysis.Function (list) body) - _ (#analysis.Function ($_ list\compose - (list\map (|>> #variable.Foreign) - (list.indices arity_1)) + _ (#analysis.Function ($_ list\composite + (list\each (|>> #variable.Foreign) + (list.indices arity_1)) (list (#variable.Local 1))) body))) body @@ -146,7 +146,7 @@ (def: (random_variable arity output?) (-> Arity Scenario) (do {! random.monad} - [register (\ ! map (|>> (n.% arity) ++) random.nat)] + [register (\ ! each (|>> (n.% arity) ++) random.nat)] (in [(not (n.= 0 register)) (synthesis.variable/local register) (if (n.= arity register) @@ -176,7 +176,7 @@ text_test (random.unicode 1) [loop?_input expected_input actual_input] (random_value false) [loop?_output expected_output actual_output] (random_value output?) - lefts (|> random.nat (\ ! map (n.% 10))) + lefts (|> random.nat (\ ! each (n.% 10))) right? random.bit .let [side|member (if right? (#.Right lefts) @@ -229,10 +229,10 @@ #analysis.value (#analysis.Bind 2)}) #analysis.then actual_output} {#analysis.when (analysis.pattern/tuple - (list\compose (list.repeated lefts (analysis.pattern/unit)) - (if right? - (list (analysis.pattern/unit) (#analysis.Bind 2)) - (list (#analysis.Bind 2) (analysis.pattern/unit))))) + (list\composite (list.repeated lefts (analysis.pattern/unit)) + (if right? + (list (analysis.pattern/unit) (#analysis.Bind 2)) + (list (#analysis.Bind 2) (analysis.pattern/unit))))) #analysis.then actual_output})])]))) (def: (random_let arity random_value output?) @@ -278,7 +278,7 @@ (def: (random_get random_value output?) (-> Scenario Scenario) (do {! random.monad} - [lefts (|> random.nat (\ ! map (n.% 10))) + [lefts (|> random.nat (\ ! each (n.% 10))) right? random.bit [loop?_record expected_record actual_record] (random_value false)] (in [loop?_record @@ -288,10 +288,10 @@ expected_record]) (#analysis.Case actual_record [{#analysis.when (analysis.pattern/tuple - (list\compose (list.repeated lefts (analysis.pattern/unit)) - (if right? - (list (analysis.pattern/unit) (#analysis.Bind 2)) - (list (#analysis.Bind 2) (analysis.pattern/unit))))) + (list\composite (list.repeated lefts (analysis.pattern/unit)) + (if right? + (list (analysis.pattern/unit) (#analysis.Bind 2)) + (list (#analysis.Bind 2) (analysis.pattern/unit))))) #analysis.then (#analysis.Reference (reference.local 2))} (list)])]))) @@ -307,11 +307,11 @@ (do {! random.monad} [resets (random.list arity (random_value false))] (in [true - (synthesis.loop/recur (list\map (|>> product.right product.left) resets)) + (synthesis.loop/recur (list\each (|>> product.right product.left) resets)) (analysis.apply [(#analysis.Reference (case arity 1 (reference.local 0) _ (reference.foreign 0))) - (list\map (|>> product.right product.right) resets)])]))) + (list\each (|>> product.right product.right) resets)])]))) (def: (random_scope arity output?) (-> Arity Scenario) @@ -321,13 +321,13 @@ (in [(list\mix (function (_ new old) (and new old)) true - (list\map product.left resets)) + (list\each product.left resets)) (synthesis.loop/scope {#synthesis.start (++ arity) - #synthesis.inits (list\map (|>> product.right product.left) resets) + #synthesis.inits (list\each (|>> product.right product.left) resets) #synthesis.iteration expected_output}) (analysis.apply [(..n_abstraction arity actual_output) - (list\map (|>> product.right product.right) resets)])]))) + (list\each (|>> product.right product.right) resets)])]))) (def: (random_loop arity random_value output?) (-> Arity Scenario Scenario) @@ -342,10 +342,10 @@ Scenario (do {! random.monad} [[loop?_output expected_output actual_output] (..random_nat output?) - arity (|> random.nat (\ ! map (|>> (n.% 5) ++))) - .let [environment ($_ list\compose - (list\map (|>> #variable.Foreign) - (list.indices arity)) + arity (|> random.nat (\ ! each (|>> (n.% 5) ++))) + .let [environment ($_ list\composite + (list\each (|>> #variable.Foreign) + (list.indices arity)) (list (#variable.Local 1)))]] (in [true (synthesis.function/abstraction @@ -362,16 +362,16 @@ (-> Scenario Scenario) (do {! random.monad} [[loop?_abstraction expected_abstraction actual_abstraction] (..random_nat output?) - arity (|> random.nat (\ ! map (|>> (n.% 5) ++))) + arity (|> random.nat (\ ! each (|>> (n.% 5) ++))) inputs (random.list arity (random_value false))] (in [(list\mix (function (_ new old) (and new old)) loop?_abstraction - (list\map product.left inputs)) + (list\each product.left inputs)) (synthesis.function/apply [expected_abstraction - (list\map (|>> product.right product.left) inputs)]) + (list\each (|>> product.right product.left) inputs)]) (analysis.apply [actual_abstraction - (list\map (|>> product.right product.right) inputs)])]))) + (list\each (|>> product.right product.right) inputs)])]))) (def: (random_function random_value output?) (-> Scenario Scenario) @@ -418,7 +418,7 @@ (def: random_abstraction (Random [Synthesis Analysis]) (do {! random.monad} - [arity (|> random.nat (\ ! map (|>> (n.% 5) ++))) + [arity (|> random.nat (\ ! each (|>> (n.% 5) ++))) [loop? expected_body actual_body] (random_body arity true)] (in [(..n_function loop? arity expected_body) (..n_abstraction arity actual_body)]))) @@ -437,7 +437,7 @@ (def: application Test (do {! random.monad} - [arity (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + [arity (|> random.nat (\ ! each (|>> (n.% 10) (n.max 1)))) funcA //primitive.primitive argsA (random.list arity //primitive.primitive)] (_.cover [/.apply] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index 41dff47e9..63212fe0a 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -31,13 +31,13 @@ (`` ($_ random.either (~~ (template [<synthesis> <random>] [(do {! random.monad} - [example (\ ! map (|>> <synthesis>) <random>)] + [example (\ ! each (|>> <synthesis>) <random>)] (in [next [example example]]))] [//.bit random.bit] - [//.i64 (\ ! map .i64 random.nat)] + [//.i64 (\ ! each .i64 random.nat)] [//.f64 random.frac] [//.text (random.unicode 1)] )) @@ -55,7 +55,7 @@ (def: (variable offset arity next) (Scenario Variable) (let [local (do {! random.monad} - [register (\ ! map (|>> (n.% arity) ++) random.nat)] + [register (\ ! each (|>> (n.% arity) ++) random.nat)] (in [next [(#variable.Local (/.register_optimization offset register)) (#variable.Local register)]]))] @@ -64,7 +64,7 @@ _ ($_ random.either local (do {! random.monad} - [foreign (\ ! map (n.% offset) random.nat)] + [foreign (\ ! each (n.% offset) random.nat)] (in [next [(#variable.Local foreign) (#variable.Foreign foreign)]])))))) @@ -117,19 +117,19 @@ //.path/pop]]) (~~ (template [<path> <random>] [(do {! random.monad} - [example (\ ! map (|>> <path>) <random>)] + [example (\ ! each (|>> <path>) <random>)] (in [next [example example]]))] [//.path/bit random.bit] - [//.path/i64 (\ ! map .i64 random.nat)] + [//.path/i64 (\ ! each .i64 random.nat)] [//.path/f64 random.frac] [//.path/text (random.unicode 1)] )) (~~ (template [<path>] [(do {! random.monad} - [example (\ ! map (|>> <path>) + [example (\ ! each (|>> <path>) (random.or random.nat random.nat))] (in [next @@ -182,7 +182,7 @@ ($_ random.either (do {! random.monad} [[next [recordE recordA]] (..reference offset arity next) - path_length (\ ! map (|>> (n.% 5) ++) random.nat) + path_length (\ ! each (|>> (n.% 5) ++) random.nat) path (random.list path_length random_member)] (in [next [(//.branch/get [path recordE]) @@ -219,7 +219,7 @@ (do {! random.monad} [[next [firstE firstA]] (..variable offset arity next) [next [secondE secondA]] (..variable offset arity next) - arity (\ ! map (n.max 1) random.nat) + arity (\ ! each (n.max 1) random.nat) [next [bodyE bodyA]] (..primitive 0 arity next)] (in [next [(//.function/abstraction @@ -266,17 +266,17 @@ (<| (_.covering /._) ($_ _.and (do {! random.monad} - [expected_offset (\ ! map (|>> (n.% 5) (n.+ 2)) random.nat) - arity (\ ! map (|>> (n.% 5) ++) random.nat) + [expected_offset (\ ! each (|>> (n.% 5) (n.+ 2)) random.nat) + arity (\ ! each (|>> (n.% 5) ++) random.nat) expected_inits (|> random.nat - (\ ! map (|>> .i64 //.i64)) + (\ ! each (|>> .i64 //.i64)) (random.list arity)) [_ [expected iteration]] (..scenario expected_offset arity 0)] (_.cover [/.Transform /.optimization /.register_optimization] (case (/.optimization true expected_offset expected_inits {#//.environment (|> expected_offset list.indices - (list\map (|>> #variable.Local))) + (list\each (|>> #variable.Local))) #//.arity arity #//.body iteration}) (^ (#.Some (//.loop/scope [actual_offset actual_inits diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux index 3a1101011..ec1a6f641 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux @@ -89,8 +89,8 @@ [#////analysis.Unit #////synthesis.Text (r\in ////synthesis.unit)] [#////analysis.Bit #////synthesis.Bit r.bit] - [#////analysis.Nat #////synthesis.I64 (r\map .i64 r.nat)] - [#////analysis.Int #////synthesis.I64 (r\map .i64 r.int)] - [#////analysis.Rev #////synthesis.I64 (r\map .i64 r.rev)] + [#////analysis.Nat #////synthesis.I64 (r\each .i64 r.nat)] + [#////analysis.Int #////synthesis.I64 (r\each .i64 r.int)] + [#////analysis.Rev #////synthesis.I64 (r\each .i64 r.rev)] [#////analysis.Frac #////synthesis.F64 r.frac] [#////analysis.Text #////synthesis.Text (r.unicode 5)])))))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux index 014a77ac2..3c5ff94e7 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux @@ -36,8 +36,8 @@ (def: variant Test (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 10) (n.+ 2)))) - tagA (|> r.nat (\ ! map (n.% size))) + [size (|> r.nat (\ ! each (|>> (n.% 10) (n.+ 2)))) + tagA (|> r.nat (\ ! each (n.% size))) .let [right? (n.= (-- size) tagA) lefts (if right? (-- tagA) @@ -59,7 +59,7 @@ (def: tuple Test (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) + [size (|> r.nat (\ ! each (|>> (n.% 10) (n.max 2)))) membersA (r.list size //primitive.primitive)] (_.test "Can synthesize tuple." (|> (////analysis.tuple membersA) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 690ac7ce2..e817d05c5 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -50,7 +50,7 @@ (<synthesis> value)])))] [bit_scenario synthesis.bit random.bit] - [i64_scenario synthesis.i64 (\ ! map .i64 random.nat)] + [i64_scenario synthesis.i64 (\ ! each .i64 random.nat)] [f64_scenario synthesis.f64 random.frac] [text_scenario synthesis.text (random.unicode 1)] ) @@ -97,8 +97,8 @@ (Scenario Synthesis) (let [registers (dictionary.entries (value@ #necessary context))] (\ random.monad in - [(synthesis.tuple (list\map (|>> product.left synthesis.variable/local) registers)) - (synthesis.tuple (list\map (|>> product.right synthesis.variable/local) registers))]))) + [(synthesis.tuple (list\each (|>> product.left synthesis.variable/local) registers)) + (synthesis.tuple (list\each (|>> product.right synthesis.variable/local) registers))]))) (def: (structure_scenario context) (Scenario Synthesis) @@ -143,7 +143,7 @@ (def: (get_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do {! random.monad} - [length (\ ! map (|>> (n.% 5) ++) random.nat) + [length (\ ! each (|>> (n.% 5) ++) random.nat) path (random.list length ..random_member) [expected_record actual_record] (scenario context)] (in [(synthesis.branch/get [path expected_record]) @@ -187,7 +187,7 @@ (#synthesis.Then actual_then))]))] [#synthesis.Bit random.bit] - [#synthesis.I64 (\ ! map .i64 random.nat)] + [#synthesis.I64 (\ ! each .i64 random.nat)] [#synthesis.F64 random.frac] [#synthesis.Text (random.unicode 1)] ))) @@ -251,16 +251,16 @@ necessary (list.enumeration inits))) context))] - (in [(synthesis.loop/scope [real_start (list\map product.left inits) expected_iteration]) - (synthesis.loop/scope [fake_start (list\map product.right inits) actual_iteration])]))) + (in [(synthesis.loop/scope [real_start (list\each product.left inits) expected_iteration]) + (synthesis.loop/scope [fake_start (list\each product.right inits) actual_iteration])]))) (def: (recur_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do {! random.monad} [_ (in []) resets (random.list ..scope_arity (scenario context))] - (in [(synthesis.loop/recur (list\map product.left resets)) - (synthesis.loop/recur (list\map product.right resets))]))) + (in [(synthesis.loop/recur (list\each product.left resets)) + (synthesis.loop/recur (list\each product.right resets))]))) (def: (loop_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) @@ -274,8 +274,8 @@ (do {! random.monad} [_ (in []) .let [registers (dictionary.entries (value@ #necessary context)) - expected_environment (list\map (|>> product.left #variable.Local) registers) - actual_environment (list\map (|>> product.right #variable.Local) registers)] + expected_environment (list\each (|>> product.left #variable.Local) registers) + actual_environment (list\each (|>> product.right #variable.Local) registers)] [expected_body actual_body] (..primitive_scenario context)] (in [(synthesis.function/abstraction [expected_environment 1 expected_body]) (synthesis.function/abstraction [actual_environment 1 actual_body])]))) @@ -283,12 +283,12 @@ (def: (apply_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do {! random.monad} - [abstraction (\ ! map (|>> synthesis.constant) + [abstraction (\ ! each (|>> synthesis.constant) (random.and (random.unicode 1) (random.unicode 1))) inputs (random.list ..scope_arity (scenario context))] - (in [(synthesis.function/apply [abstraction (list\map product.left inputs)]) - (synthesis.function/apply [abstraction (list\map product.right inputs)])]))) + (in [(synthesis.function/apply [abstraction (list\each product.left inputs)]) + (synthesis.function/apply [abstraction (list\each product.right inputs)])]))) (def: (function_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux index 947170187..9b12fd4a7 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux @@ -27,7 +27,7 @@ (def: name_part^ (Random Text) (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 20) (n.max 1))))] + [size (|> r.nat (\ ! each (|>> (n.% 20) (n.max 1))))] (r.ascii/lower_alpha size))) (def: name^ @@ -38,18 +38,18 @@ (Random Code) (let [numeric^ (: (Random Code) ($_ r.either - (|> r.bit (r\map code.bit)) - (|> r.nat (r\map code.nat)) - (|> r.int (r\map code.int)) - (|> r.rev (r\map code.rev)) - (|> r.safe_frac (r\map code.frac)))) + (|> r.bit (r\each code.bit)) + (|> r.nat (r\each code.nat)) + (|> r.int (r\each code.int)) + (|> r.rev (r\each code.rev)) + (|> r.safe_frac (r\each code.frac)))) textual^ (: (Random Code) ($_ r.either (do r.monad - [size (|> r.nat (r\map (n.% 20)))] - (|> (r.ascii/upper_alpha size) (r\map code.text))) - (|> name^ (r\map code.identifier)) - (|> name^ (r\map code.tag)))) + [size (|> r.nat (r\each (n.% 20)))] + (|> (r.ascii/upper_alpha size) (r\each code.text))) + (|> name^ (r\each code.identifier)) + (|> name^ (r\each code.tag)))) simple^ (: (Random Code) ($_ r.either numeric^ @@ -57,16 +57,16 @@ (r.rec (function (_ code^) (let [multi^ (do r.monad - [size (|> r.nat (r\map (n.% 3)))] + [size (|> r.nat (r\each (n.% 3)))] (r.list size code^)) composite^ (: (Random Code) ($_ r.either - (|> multi^ (r\map code.form)) - (|> multi^ (r\map code.tuple)) + (|> multi^ (r\each code.form)) + (|> multi^ (r\each code.tuple)) (do r.monad - [size (|> r.nat (r\map (n.% 3)))] + [size (|> r.nat (r\each (n.% 3)))] (|> (r.list size (r.and code^ code^)) - (r\map code.record)))))] + (r\each code.record)))))] ($_ r.either simple^ composite^)))))) @@ -110,7 +110,7 @@ (Random Text) (let [char_gen (|> r.nat (r.only (|>> (n.= (`` (char (~~ (static text.new_line))))) not)))] (do r.monad - [size (|> r.nat (r\map (n.% 20)))] + [size (|> r.nat (r\each (n.% 20)))] (r.text char_gen size)))) (def: comment^ diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index 65920eca9..e4f567e49 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -38,7 +38,7 @@ (def: short (Random Text) (do {! random.monad} - [size (|> random.nat (\ ! map (n.% 10)))] + [size (|> random.nat (\ ! each (n.% 10)))] (random.unicode size))) (def: name @@ -52,24 +52,24 @@ (let [pairG (random.and recur recur) un_parameterized (: (Random Type) ($_ random.either - (random\map (|>> #.Primitive) (random.and ..short (random.list 0 recur))) - (random\map (|>> #.Primitive) (random.and ..short (random.list 1 recur))) - (random\map (|>> #.Primitive) (random.and ..short (random.list 2 recur))) - (random\map (|>> #.Sum) pairG) - (random\map (|>> #.Product) pairG) - (random\map (|>> #.Function) pairG) + (random\each (|>> #.Primitive) (random.and ..short (random.list 0 recur))) + (random\each (|>> #.Primitive) (random.and ..short (random.list 1 recur))) + (random\each (|>> #.Primitive) (random.and ..short (random.list 2 recur))) + (random\each (|>> #.Sum) pairG) + (random\each (|>> #.Product) pairG) + (random\each (|>> #.Function) pairG) ))] (case parameters 0 un_parameterized _ (|> random.nat - (random\map (|>> (n.% parameters) #.Parameter)) + (random\each (|>> (n.% parameters) #.Parameter)) (random.either un_parameterized))))))) (def: .public (random parameters) (-> Nat (Random Type)) ($_ random.either - (random\map (/.univ_q parameters) (random' parameters)) - (random\map (/.ex_q parameters) (random' parameters)) + (random\each (/.univ_q parameters) (random' parameters)) + (random\each (/.ex_q parameters) (random' parameters)) )) (def: .public test @@ -93,7 +93,7 @@ (_.cover [/.anonymous] (\ /.equivalence = anonymousT (/.anonymous aliasedT))))) (do {! random.monad} - [size (|> random.nat (\ ! map (n.% 3))) + [size (|> random.nat (\ ! each (n.% 3))) members (|> (..random 0) (random.only (function (_ type) (case type @@ -127,7 +127,7 @@ (|> (/.applied (list Bit) Text) (case> #.None #1 _ #0)))) (do {! random.monad} - [size (|> random.nat (\ ! map (n.% 3))) + [size (|> random.nat (\ ! each (n.% 3))) members (monad.all ! (list.repeated size (..random 0))) extra (|> (..random 0) (random.only (function (_ type) @@ -149,7 +149,7 @@ (n.= (list.size members) (list.size tparams)))) )) (do {! random.monad} - [size (|> random.nat (\ ! map (|>> (n.% 3) ++))) + [size (|> random.nat (\ ! each (|>> (n.% 3) ++))) body_type (|> (..random 0) (random.only (function (_ type) (case type @@ -175,7 +175,7 @@ (|> body_type (/.ex_q size) /.quantified?))) ))) (do {! random.monad} - [depth (|> random.nat (\ ! map (|>> (n.% 3) ++))) + [depth (|> random.nat (\ ! each (|>> (n.% 3) ++))) element_type (|> (..random 0) (random.only (function (_ type) (case type diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index 12370e87a..f4ee4b802 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -44,24 +44,24 @@ (function (_ recur) (let [pairG (random.and recur recur) quantifiedG (random.and (random\in (list)) (type' (++ num_vars))) - random_pair (random.either (random.either (random\map (|>> #.Sum) pairG) - (random\map (|>> #.Product) pairG)) - (random.either (random\map (|>> #.Function) pairG) - (random\map (|>> #.Apply) pairG))) - random_id (let [random_id (random.either (random\map (|>> #.Var) random.nat) - (random\map (|>> #.Ex) random.nat))] + random_pair (random.either (random.either (random\each (|>> #.Sum) pairG) + (random\each (|>> #.Product) pairG)) + (random.either (random\each (|>> #.Function) pairG) + (random\each (|>> #.Apply) pairG))) + random_id (let [random_id (random.either (random\each (|>> #.Var) random.nat) + (random\each (|>> #.Ex) random.nat))] (case num_vars 0 random_id - _ (random.either (random\map (|>> (n.% num_vars) (n.* 2) ++ #.Parameter) random.nat) + _ (random.either (random\each (|>> (n.% num_vars) (n.* 2) ++ #.Parameter) random.nat) random_id))) - random_quantified (random.either (random\map (|>> #.UnivQ) quantifiedG) - (random\map (|>> #.ExQ) quantifiedG))] + random_quantified (random.either (random\each (|>> #.UnivQ) quantifiedG) + (random\each (|>> #.ExQ) quantifiedG))] ($_ random.either - (random\map (|>> #.Primitive) (random.and ..short (random\in (list)))) + (random\each (|>> #.Primitive) (random.and ..short (random\in (list)))) random_pair random_id random_quantified - (random\map (|>> #.Named) (random.and ..name (type' 0))) + (random\each (|>> #.Named) (random.and ..name (type' 0))) ))))) (def: type @@ -416,11 +416,11 @@ (-> Nat (/.Check [Type (List Type) Type])) (do {! /.monad} [[id/head var/head] /.var - var/tail+ (monad.map ! (function (_ _) - (do ! - [[id/T var/tail] /.var] - (in var/tail))) - (list.repeated tail_size /.var)) + var/tail+ (monad.each ! (function (_ _) + (do ! + [[id/T var/tail] /.var] + (in var/tail))) + (list.repeated tail_size /.var)) var/last (monad.mix ! (function (_ var/next var/prev) (do ! [_ (/.check var/prev var/next)] @@ -439,8 +439,8 @@ (succeeds? (do {! /.monad} [[var/head var/tail+ var/last] (..build_ring tail_size) _ (/.check var/head nominal/0) - failures (monad.map ! (|>> (/.check nominal/1) ..verdict) (list& var/head var/tail+)) - successes (monad.map ! (|>> (/.check nominal/0) ..verdict) (list& var/head var/tail+))] + failures (monad.each ! (|>> (/.check nominal/1) ..verdict) (list& var/head var/tail+)) + successes (monad.each ! (|>> (/.check nominal/0) ..verdict) (list& var/head var/tail+))] (/.assertion "" (and (list.every? (bit\= false) failures) (list.every? (bit\= true) successes))))) @@ -450,10 +450,10 @@ [var/head/1 var/tail+/1 var/last/1] (..build_ring tail_size) _ (/.check var/head/0 var/head/1) _ (/.check var/head/0 nominal/0) - .let [all_variables (list\compose (list& var/head/0 var/tail+/0) - (list& var/head/1 var/tail+/1))] - failures (monad.map ! (|>> (/.check nominal/1) ..verdict) all_variables) - successes (monad.map ! (|>> (/.check nominal/0) ..verdict) all_variables)] + .let [all_variables (list\composite (list& var/head/0 var/tail+/0) + (list& var/head/1 var/tail+/1))] + failures (monad.each ! (|>> (/.check nominal/1) ..verdict) all_variables) + successes (monad.each ! (|>> (/.check nominal/0) ..verdict) all_variables)] (/.assertion "" (and (list.every? (bit\= false) failures) (list.every? (bit\= true) successes)))))] (and can_create_rings_of_variables! @@ -616,7 +616,7 @@ [parameter/0 parameter/1] (..non_twins type\= ..nominal) left_name ..name right_name ..name - ring_tail_size (\ ! map (n.% 10) random.nat)] + ring_tail_size (\ ! each (n.% 10) random.nat)] (_.cover [/.check] (and (..handles_nominal_types! name/0 name/1 parameter/0 parameter/1) (..handles_products! name/0 name/1) @@ -636,9 +636,9 @@ (random.rec (function (_ dirty_type) (`` ($_ random.either - (random\map (function (_ id) - (function.constant (#.Ex id))) - random.nat) + (random\each (function (_ id) + (function.constant (#.Ex id))) + random.nat) (do random.monad [module (random.ascii/upper 10) short (random.ascii/upper 10) diff --git a/stdlib/source/test/lux/type/implicit.lux b/stdlib/source/test/lux/type/implicit.lux index f50bd57e7..2e694abf1 100644 --- a/stdlib/source/test/lux/type/implicit.lux +++ b/stdlib/source/test/lux/type/implicit.lux @@ -25,7 +25,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [.let [digit (\ ! map (n.% 10) random.nat)] + [.let [digit (\ ! each (n.% 10) random.nat)] left digit right digit .let [start (n.min left right) @@ -39,8 +39,8 @@ (let [(^open "list\.") (list.equivalence n.equivalence)] (and (bit\= (\ n.equivalence = left right) (/.\\ = left right)) - (list\= (\ list.functor map ++ (enum.range n.enum start end)) - (/.\\ map ++ (enum.range n.enum start end))))) + (list\= (\ list.functor each ++ (enum.range n.enum start end)) + (/.\\ each ++ (enum.range n.enum start end))))) second_order! (/.\\ = @@ -48,7 +48,7 @@ (enum.range n.enum start end)) third_order! - (let [lln (/.\\ map (enum.range n.enum start) + (let [lln (/.\\ each (enum.range n.enum start) (enum.range n.enum start end))] (/.\\ = lln lln))] (and first_order! @@ -56,9 +56,9 @@ third_order!))) (_.cover [/.with] (/.with [n.addition] - (n.= (\ n.addition compose left right) - (/.\\ compose left right)))) + (n.= (\ n.addition composite left right) + (/.\\ composite left right)))) (_.cover [/.implicit:] - (n.= (\ n.multiplication compose left right) - (/.\\ compose left right))) + (n.= (\ n.multiplication composite left right) + (/.\\ composite left right))) )))) diff --git a/stdlib/source/test/lux/type/poly/equivalence.lux b/stdlib/source/test/lux/type/poly/equivalence.lux index 14c763226..5d1953a52 100644 --- a/stdlib/source/test/lux/type/poly/equivalence.lux +++ b/stdlib/source/test/lux/type/poly/equivalence.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant) + [lux (#- Variant Record) ["_" test (#+ Test)] [abstract [monad (#+ do)] @@ -25,24 +25,27 @@ [poly (#+ derived:)]]]]) (type: Variant - (#Case0 Bit) - (#Case1 Int) - (#Case2 Frac)) + (.Variant + (#Case0 Bit) + (#Case1 Int) + (#Case2 Frac))) (type: #rec Recursive - (#Number Frac) - (#Addition Frac Recursive)) + (.Variant + (#Number Frac) + (#Addition Frac Recursive))) (type: Record - {#bit Bit - #int Int - #frac Frac - #text Text - #maybe (Maybe Int) - #list (List Int) - #variant Variant - #tuple [Int Frac Text] - #recursive Recursive}) + (.Record + {#bit Bit + #int Int + #frac Frac + #text Text + #maybe (Maybe Int) + #list (List Int) + #variant Variant + #tuple [Int Frac Text] + #recursive Recursive})) (def: gen_recursive (Random Recursive) @@ -54,8 +57,8 @@ (def: random (Random Record) (do {! random.monad} - [size (\ ! map (n.% 2) random.nat) - .let [gen_int (|> random.int (\ ! map (|>> i.abs (i.% +1,000,000))))]] + [size (\ ! each (n.% 2) random.nat) + .let [gen_int (|> random.int (\ ! each (|>> i.abs (i.% +1,000,000))))]] ($_ random.and random.bit gen_int diff --git a/stdlib/source/test/lux/type/poly/json.lux b/stdlib/source/test/lux/type/poly/json.lux index 16a466ed5..8e09a998a 100644 --- a/stdlib/source/test/lux/type/poly/json.lux +++ b/stdlib/source/test/lux/type/poly/json.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant) + [lux (#- Variant Record) ["_" test (#+ Test)] ["." debug] [abstract @@ -49,28 +49,31 @@ ]]]) (type: Variant - (#Bit Bit) - (#Text Text) - (#Frac Frac)) + (.Variant + (#Bit Bit) + (#Text Text) + (#Frac Frac))) (type: #rec Recursive - (#Number Frac) - (#Addition Frac Recursive)) + (.Variant + (#Number Frac) + (#Addition Frac Recursive))) (type: Record - {#bit Bit - #frac Frac - #text Text - #maybe (Maybe Frac) - #list (List Frac) - #dictionary (d.Dictionary Text Frac) - #variant Variant - #tuple [Bit Text Frac] - #recursive Recursive - ... #instant ti.Instant - ... #duration tdu.Duration - #date tda.Date - #grams (unit.Qty unit.Gram)}) + (.Record + {#bit Bit + #frac Frac + #text Text + #maybe (Maybe Frac) + #list (List Frac) + #dictionary (d.Dictionary Text Frac) + #variant Variant + #tuple [Bit Text Frac] + #recursive Recursive + ... #instant ti.Instant + ... #duration tdu.Duration + #date tda.Date + #grams (unit.Qty unit.Gram)})) (def: gen_recursive (Random Recursive) @@ -82,12 +85,12 @@ (def: qty (All [unit] (Random (unit.Qty unit))) - (\ random.monad map (debug.private unit.in) random.int)) + (\ random.monad each (debug.private unit.in) random.int)) (def: gen_record (Random Record) (do {! random.monad} - [size (\ ! map (n.% 2) random.nat)] + [size (\ ! each (n.% 2) random.nat)] ($_ random.and random.bit random.safe_frac diff --git a/stdlib/source/test/lux/type/quotient.lux b/stdlib/source/test/lux/type/quotient.lux index 3233777c4..806187b03 100644 --- a/stdlib/source/test/lux/type/quotient.lux +++ b/stdlib/source/test/lux/type/quotient.lux @@ -18,7 +18,7 @@ (def: .public (random class super) (All [t c %] (-> (/.Class t c %) (Random t) (Random (/.Quotient t c %)))) - (\ random.monad map (/.quotient class) super)) + (\ random.monad each (/.quotient class) super)) (def: mod_10_class (/.class (|>> (n.% 10) %.nat))) diff --git a/stdlib/source/test/lux/type/refinement.lux b/stdlib/source/test/lux/type/refinement.lux index 5942e2a84..6721399e7 100644 --- a/stdlib/source/test/lux/type/refinement.lux +++ b/stdlib/source/test/lux/type/refinement.lux @@ -29,10 +29,10 @@ (_.for [/.Refined]) (do {! random.monad} [raw random.nat - modulus (\ ! map (|>> (n.% 10) (n.+ 2)) random.nat) + modulus (\ ! each (|>> (n.% 10) (n.+ 2)) random.nat) .let [predicate (: (Predicate Nat) (|>> (n.% modulus) (n.= 0)))] - total_raws (\ ! map (|>> (n.% 20) ++) random.nat) + total_raws (\ ! each (|>> (n.% 20) ++) random.nat) raws (random.list total_raws random.nat)] ($_ _.and (_.for [/.Refiner] @@ -46,23 +46,23 @@ (not (predicate raw)))) (_.cover [/.predicate] (|> (/.refiner predicate modulus) - (maybe\map (|>> /.predicate (same? predicate))) + (maybe\each (|>> /.predicate (same? predicate))) (maybe.else false))) )) (_.cover [/.value] (|> (/.refiner predicate modulus) - (maybe\map (|>> /.value (n.= modulus))) + (maybe\each (|>> /.value (n.= modulus))) (maybe.else false))) (_.cover [/.lifted] (and (|> (/.refiner predicate modulus) - (maybe\map (/.lifted (n.+ modulus))) - maybe\join - (maybe\map (|>> /.value (n.= (n.+ modulus modulus)))) + (maybe\each (/.lifted (n.+ modulus))) + maybe\conjoint + (maybe\each (|>> /.value (n.= (n.+ modulus modulus)))) (maybe.else false)) (|> (/.refiner predicate modulus) - (maybe\map (/.lifted (n.+ (++ modulus)))) - maybe\join - (maybe\map (|>> /.value (n.= (n.+ modulus (++ modulus))))) + (maybe\each (/.lifted (n.+ (++ modulus)))) + maybe\conjoint + (maybe\each (|>> /.value (n.= (n.+ modulus (++ modulus))))) (maybe.else false) not))) (_.cover [/.only] @@ -72,7 +72,7 @@ (list.size actual)) (\ (list.equivalence n.equivalence) = expected - (list\map /.value actual))))) + (list\each /.value actual))))) (_.cover [/.partition] (let [expected (list.only predicate raws) [actual alternative] (/.partition (/.refiner predicate) raws)] @@ -82,7 +82,7 @@ (list.size alternative)) (\ (list.equivalence n.equivalence) = expected - (list\map /.value actual))))) + (list\each /.value actual))))) (_.cover [/.type] (exec (: (Maybe .._type) (.._refiner raw)) diff --git a/stdlib/source/test/lux/type/resource.lux b/stdlib/source/test/lux/type/resource.lux index 88ed4b815..206aa3506 100644 --- a/stdlib/source/test/lux/type/resource.lux +++ b/stdlib/source/test/lux/type/resource.lux @@ -29,8 +29,8 @@ (def: pure Test (monad.do {! random.monad} - [pre (\ ! map %.nat random.nat) - post (\ ! map %.nat random.nat) + [pre (\ ! each %.nat random.nat) + post (\ ! each %.nat random.nat) .let [! identity.monad]] (_.for [/.Linear /.run! /.monad] (`` ($_ _.and @@ -71,8 +71,8 @@ (def: sync Test (monad.do {! random.monad} - [pre (\ ! map %.nat random.nat) - post (\ ! map %.nat random.nat) + [pre (\ ! each %.nat random.nat) + post (\ ! each %.nat random.nat) .let [! io.monad]] (_.for [/.Linear /.run! /.monad] (`` ($_ _.and @@ -114,8 +114,8 @@ (def: async Test (monad.do {! random.monad} - [pre (\ ! map %.nat random.nat) - post (\ ! map %.nat random.nat) + [pre (\ ! each %.nat random.nat) + post (\ ! each %.nat random.nat) .let [! async.monad]] (_.for [/.Linear /.run! /.monad] (`` ($_ _.and diff --git a/stdlib/source/test/lux/type/unit.lux b/stdlib/source/test/lux/type/unit.lux index a3edb2b19..1e1992551 100644 --- a/stdlib/source/test/lux/type/unit.lux +++ b/stdlib/source/test/lux/type/unit.lux @@ -26,9 +26,9 @@ [(def: (<name> range) (-> Nat (Random (/.Qty <type>))) (|> random.int - (\ random.monad map (i.% (.int range))) + (\ random.monad each (i.% (.int range))) (random.only (|>> (i.= +0) not)) - (\ random.monad map (\ <unit> in))))] + (\ random.monad each (\ <unit> in))))] [meter /.Meter /.meter] [second /.Second /.second] @@ -78,7 +78,7 @@ ))))) (syntax: (natural []) - (\ meta.monad map + (\ meta.monad each (|>> code.nat list) meta.seed)) @@ -95,18 +95,18 @@ Test (do {! random.monad} [small (|> random.int - (\ ! map (i.% +1,000)) - (\ ! map (\ /.meter in))) + (\ ! each (i.% +1,000)) + (\ ! each (\ /.meter in))) large (|> random.int - (\ ! map (i.% +1,000)) - (\ ! map (i.* +1,000,000,000)) - (\ ! map (\ /.meter in))) + (\ ! each (i.% +1,000)) + (\ ! each (i.* +1,000,000,000)) + (\ ! each (\ /.meter in))) .let [(^open "meter\.") (: (Equivalence (/.Qty /.Meter)) /.equivalence)] unscaled (|> random.int - (\ ! map (i.% +1,000)) - (\ ! map (i.* (.int how::to))) - (\ ! map (\ /.meter in)))] + (\ ! each (i.% +1,000)) + (\ ! each (i.* (.int how::to))) + (\ ! each (\ /.meter in)))] (_.for [/.Scale] (`` ($_ _.and (~~ (template [<type> <scale>] diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux index 0e7369716..617461ad6 100644 --- a/stdlib/source/test/lux/world/file/watch.lux +++ b/stdlib/source/test/lux/world/file/watch.lux @@ -95,7 +95,7 @@ [_ (\ fs make_directory directory) _ (\ watcher start /.all directory)] (|> (\ watcher poll []) - (\ ! map list.empty?)))) + (\ ! each list.empty?)))) (def: (after_creation! fs watcher expected_path) (-> (//.System Async) (/.Watcher Async) //.Path (Async (Try Bit))) @@ -161,7 +161,7 @@ [directory (random.ascii/alpha 5) .let [/ "/" [fs watcher] (/.mock /)] - expected_path (\ ! map (|>> (format directory /)) + expected_path (\ ! each (|>> (format directory /)) (random.ascii/alpha 5)) data ($binary.random 10)] (in (do {! async.monad} diff --git a/stdlib/source/test/lux/world/input/keyboard.lux b/stdlib/source/test/lux/world/input/keyboard.lux index 865a66a9d..727ea70cf 100644 --- a/stdlib/source/test/lux/world/input/keyboard.lux +++ b/stdlib/source/test/lux/world/input/keyboard.lux @@ -140,7 +140,7 @@ (Random /.Key) (let [count (list.size ..listing)] (do {! random.monad} - [choice (\ ! map (n.% count) random.nat)] + [choice (\ ! each (n.% count) random.nat)] (in (maybe.trusted (list.item choice ..listing)))))) (def: .public test diff --git a/stdlib/source/test/lux/world/net/http/client.lux b/stdlib/source/test/lux/world/net/http/client.lux index 994e2cbf3..cdac7ac43 100644 --- a/stdlib/source/test/lux/world/net/http/client.lux +++ b/stdlib/source/test/lux/world/net/http/client.lux @@ -41,7 +41,7 @@ on_connect random.nat on_options random.nat on_trace random.nat - num_headers (\ ! map (nat.% 10) random.nat) + num_headers (\ ! each (nat.% 10) random.nat) headers (random.dictionary text.hash num_headers (random.ascii/lower 3) (random.ascii/lower 3)) .let [mock (: (/.Client IO) (implementation diff --git a/stdlib/source/test/lux/world/output/video/resolution.lux b/stdlib/source/test/lux/world/output/video/resolution.lux index b6b18505a..fa52ce52c 100644 --- a/stdlib/source/test/lux/world/output/video/resolution.lux +++ b/stdlib/source/test/lux/world/output/video/resolution.lux @@ -47,7 +47,7 @@ (Random /.Resolution) (let [count (list.size ..listing)] (do {! random.monad} - [choice (\ ! map (n.% count) random.nat)] + [choice (\ ! each (n.% count) random.nat)] (in (maybe.trusted (list.item choice ..listing)))))) (def: .public test diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/program.lux index 6f5784daf..05dcac52a 100644 --- a/stdlib/source/test/lux/world/program.lux +++ b/stdlib/source/test/lux/world/program.lux @@ -42,7 +42,7 @@ Test (<| (_.covering /._) (do {! random.monad} - [env_size (\ ! map (|>> (n.% 10) ++) random.nat) + [env_size (\ ! each (|>> (n.% 10) ++) random.nat) environment (..environment env_size) home ..path directory ..path @@ -63,7 +63,7 @@ (list.every? (function (_ [key value]) (|> environment (dictionary.value key) - (maybe\map (text\= value)) + (maybe\each (text\= value)) (maybe.else false))))))))))) (_.cover [/.unknown_environment_variable] (let [program (/.mock environment home directory)] |