diff options
Diffstat (limited to '')
27 files changed, 1370 insertions, 26 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:] + [])) |