diff options
Diffstat (limited to '')
49 files changed, 2009 insertions, 434 deletions
diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux index 987d9cce5..2376510b5 100644 --- a/stdlib/source/documentation/lux.lux +++ b/stdlib/source/documentation/lux.lux @@ -12,21 +12,21 @@ ["#." abstract] ["#." control] ["#." data] - ... ["#." debug] - ... ["#." documentation] + ["#." debug] + ["#." documentation] + ["#." ffi] ... ["#." locale] ... ["#." macro ... ["#/." code]] ... ["#." math] ... ["#." meta] - ... ["#." program] + ["#." program] ... ["#." target] ... ["#." test] ... ["#." time] ... ... ["#." tool] ... TODO: Update & expand tests for this ... ["#." type] ... ["#." world] - ... ["#." ffi] ... ["#." extension] ... ["#." target #_ ... <target>] @@ -49,7 +49,12 @@ [..:of] [/abstract.documentation /control.documentation - /data.documentation])) + /data.documentation + /debug.documentation + /documentation.documentation + /ffi.documentation + + /program.documentation])) (program: inputs (io.io (debug.log! ($.documentation ..documentation)))) diff --git a/stdlib/source/documentation/lux/data.lux b/stdlib/source/documentation/lux/data.lux index 0939016a1..0187c2a51 100644 --- a/stdlib/source/documentation/lux/data.lux +++ b/stdlib/source/documentation/lux/data.lux @@ -12,17 +12,12 @@ ["#." bit] ["#." collection] ["#." color] - ... ["#." identity] - ... ["#." name] - ... ["#." product] - ... ["#." sum] - ... ["#." text] - ... ["#." format #_ - ... ["#/." binary] - ... ["#/." json] - ... ["#/." tar] - ... ["#/." xml]] - ]) + ["#." format] + ["#." identity] + ["#." name] + ["#." product] + ["#." sum] + ["#." text]]) (.def: .public documentation (.List $.Module) @@ -31,10 +26,10 @@ /bit.documentation /collection.documentation /color.documentation - ... /identity.documentation - ... /name.documentation - ... /product.documentation - ... /sum.documentation - ... /text.documentation - ... /format.documentation + /format.documentation + /identity.documentation + /name.documentation + /product.documentation + /sum.documentation + /text.documentation ))) diff --git a/stdlib/source/documentation/lux/data/format.lux b/stdlib/source/documentation/lux/data/format.lux new file mode 100644 index 000000000..9758699e5 --- /dev/null +++ b/stdlib/source/documentation/lux/data/format.lux @@ -0,0 +1,23 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list]]]]] + ["." / #_ + ["#." binary] + ["#." json] + ["#." tar] + ["#." xml]]) + +(.def: .public documentation + (.List $.Module) + (list.together + (list /binary.documentation + /json.documentation + /tar.documentation + /xml.documentation + ))) diff --git a/stdlib/source/documentation/lux/data/format/binary.lux b/stdlib/source/documentation/lux/data/format/binary.lux new file mode 100644 index 000000000..229f262b0 --- /dev/null +++ b/stdlib/source/documentation/lux/data/format/binary.lux @@ -0,0 +1,93 @@ +(.module: + [library + [lux (#- nat int rev list type or and) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Mutation + "A mutation of binary data, tracking where in the data to transform.") + +(documentation: /.Specification + "A description of how to transform binary data.") + +(documentation: /.no_op + "A specification for empty binary data.") + +(documentation: /.instance + "Given a specification of how to construct binary data, yields a binary blob that matches it.") + +(documentation: /.Writer + "An operation that knows how to write information into a binary blob.") + +(documentation: /.result + "Yields a binary blob with all the information written to it." + [(result writer value)]) + +(documentation: /.or + "" + [(or left right)]) + +(documentation: /.and + "" + [(and pre post)]) + +(documentation: /.rec + "A combinator for recursive writers." + [(rec body)]) + +(documentation: /.segment + "Writes at most 'size' bytes of an input binary blob." + [(segment size)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Mutation + ..Specification + ..no_op + ..instance + ..Writer + ..result + ..or + ..and + ..rec + ..segment + ($.default /.monoid) + ($.default /.bits/8) + ($.default /.bits/16) + ($.default /.bits/32) + ($.default /.bits/64) + ($.default /.any) + ($.default /.bit) + ($.default /.nat) + ($.default /.int) + ($.default /.rev) + ($.default /.frac) + ($.default /.binary/8) + ($.default /.binary/16) + ($.default /.binary/32) + ($.default /.binary/64) + ($.default /.utf8/8) + ($.default /.utf8/16) + ($.default /.utf8/32) + ($.default /.utf8/64) + ($.default /.text) + ($.default /.row/8) + ($.default /.row/16) + ($.default /.row/32) + ($.default /.row/64) + ($.default /.maybe) + ($.default /.list) + ($.default /.set) + ($.default /.name) + ($.default /.type) + ($.default /.location) + ($.default /.code)] + [])) diff --git a/stdlib/source/documentation/lux/data/format/json.lux b/stdlib/source/documentation/lux/data/format/json.lux new file mode 100644 index 000000000..5b55ad75d --- /dev/null +++ b/stdlib/source/documentation/lux/data/format/json.lux @@ -0,0 +1,75 @@ +(.module: + [library + [lux (#- nat int rev list type or and) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.json + "A simple way to produce JSON literals." + [(json #null)] + [(json #1)] + [(json +123.456)] + [(json "this is a string")] + [(json ["this" "is" "an" "array"])] + [(json {"this" "is" + "an" "object"})]) + +(documentation: /.fields + "Get all the fields in a JSON object." + [(fields json)]) + +(documentation: /.field + "A JSON object field getter." + [(field key json)]) + +(documentation: /.has + "A JSON object field setter." + [(has key value json)]) + +(template [<name> <desc>] + [(documentation: <name> + (format "A JSON object field getter for " <desc> ".") + [(<name> key json)])] + + [/.boolean_field "booleans"] + [/.number_field "numbers"] + [/.string_field "strings"] + [/.array_field "arrays"] + [/.object_field "objects"] + ) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + (format "Functionality for reading and writing values in the JSON format." + \n "For more information, please see: http://www.json.org/") + [..json + ..fields + ..field + ..has + + ..boolean_field + ..number_field + ..string_field + ..array_field + ..object_field + + ($.default /.Null) + ($.default /.Boolean) + ($.default /.Number) + ($.default /.String) + ($.default /.JSON) + ($.default /.Array) + ($.default /.Object) + ($.default /.null?) + ($.default /.object) + ($.default /.equivalence) + ($.default /.format) + ($.default /.codec)] + [])) diff --git a/stdlib/source/documentation/lux/data/format/tar.lux b/stdlib/source/documentation/lux/data/format/tar.lux new file mode 100644 index 000000000..85b658b59 --- /dev/null +++ b/stdlib/source/documentation/lux/data/format/tar.lux @@ -0,0 +1,89 @@ +(.module: + [library + [lux (#- nat int rev list type or and) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [($.default /.not_a_small_number) + ($.default /.small_limit) + ($.default /.Small) + ($.default /.small) + ($.default /.from_small) + + ($.default /.not_a_big_number) + ($.default /.big_limit) + ($.default /.Big) + ($.default /.big) + ($.default /.from_big) + + ($.default /.wrong_character) + ($.default /.not_ascii) + ($.default /.name_size) + ($.default /.path_size) + + ($.default /.Name) + ($.default /.name_is_too_long) + ($.default /.name) + ($.default /.from_name) + ($.default /.anonymous) + + ($.default /.Path) + ($.default /.path_is_too_long) + ($.default /.path) + ($.default /.from_path) + ($.default /.no_path) + + ($.default /.invalid_link_flag) + ($.default /.Mode) + ($.default /.mode) + ($.default /.and) + ($.default /.invalid_mode) + + ($.default /.none) + + ($.default /.execute_by_other) + ($.default /.write_by_other) + ($.default /.read_by_other) + + ($.default /.execute_by_group) + ($.default /.write_by_group) + ($.default /.read_by_group) + + ($.default /.execute_by_owner) + ($.default /.write_by_owner) + ($.default /.read_by_owner) + + ($.default /.save_text) + ($.default /.set_group_id_on_execution) + ($.default /.set_user_id_on_execution) + + ($.default /.Content) + ($.default /.content) + ($.default /.data) + ($.default /.ID) + ($.default /.no_id) + ($.default /.Owner) + ($.default /.Ownership) + ($.default /.File) + ($.default /.Normal) + ($.default /.Symbolic_Link) + ($.default /.Directory) + ($.default /.Contiguous) + ($.default /.Entry) + ($.default /.Tar) + ($.default /.writer) + ($.default /.wrong_checksum) + ($.default /.wrong_link_flag) + ($.default /.invalid_end_of_archive) + ($.default /.parser)] + [])) diff --git a/stdlib/source/documentation/lux/data/format/xml.lux b/stdlib/source/documentation/lux/data/format/xml.lux new file mode 100644 index 000000000..d02722170 --- /dev/null +++ b/stdlib/source/documentation/lux/data/format/xml.lux @@ -0,0 +1,36 @@ +(.module: + [library + [lux (#- nat int rev list type or and) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.attributes + "An empty set of XML attributes.") + +(documentation: /.tag + "The text format of a XML tag." + [(tag name)]) + +(documentation: /.attribute + "The text format of a XML attribute.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..attributes + ..tag + ..attribute + ($.default /.Tag) + ($.default /.Attribute) + ($.default /.Attrs) + ($.default /.XML) + ($.default /.codec) + ($.default /.equivalence)] + [])) diff --git a/stdlib/source/documentation/lux/data/identity.lux b/stdlib/source/documentation/lux/data/identity.lux new file mode 100644 index 000000000..b67f8470b --- /dev/null +++ b/stdlib/source/documentation/lux/data/identity.lux @@ -0,0 +1,25 @@ +(.module: + [library + [lux (#- nat int rev list type or and) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Identity + "A value, as is, without any extra structure super-imposed on it.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Identity + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.comonad)] + [])) diff --git a/stdlib/source/documentation/lux/data/name.lux b/stdlib/source/documentation/lux/data/name.lux new file mode 100644 index 000000000..1cf422bcf --- /dev/null +++ b/stdlib/source/documentation/lux/data/name.lux @@ -0,0 +1,29 @@ +(.module: + [library + [lux (#- nat int rev list type or and) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.module + "The module part of a name.") + +(documentation: /.short + "The short part of a name.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..module + ..short + ($.default /.hash) + ($.default /.equivalence) + ($.default /.order) + ($.default /.codec)] + [])) diff --git a/stdlib/source/documentation/lux/data/product.lux b/stdlib/source/documentation/lux/data/product.lux new file mode 100644 index 000000000..78d0d5aaa --- /dev/null +++ b/stdlib/source/documentation/lux/data/product.lux @@ -0,0 +1,52 @@ +(.module: + [library + [lux (#- nat int rev list type or and) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.left + "The left side of a pair.") + +(documentation: /.right + "The right side of a pair.") + +(documentation: /.curried + "Converts a 2-argument function into nested single-argument functions." + [(curried f)]) + +(documentation: /.uncurried + "Converts nested single-argument functions into a 2-argument function." + [(uncurried f)]) + +(documentation: /.swapped + "" + [(swapped [left right])]) + +(documentation: /.then + "Apply functions to both sides of a pair." + [(then f g)]) + +(documentation: /.forked + "Yields a pair by applying both functions to a single value." + [(forked f g)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..left + ..right + ..curried + ..uncurried + ..swapped + ..then + ..forked + ($.default /.equivalence) + ($.default /.hash)] + [])) diff --git a/stdlib/source/documentation/lux/data/sum.lux b/stdlib/source/documentation/lux/data/sum.lux new file mode 100644 index 000000000..5db8a4df3 --- /dev/null +++ b/stdlib/source/documentation/lux/data/sum.lux @@ -0,0 +1,40 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.left + "Lifts value to the left side of a 2-variant.") + +(documentation: /.right + "Lifts value to the right side of a 2-variant.") + +(documentation: /.either + "Applies a function to either side of a 2-variant." + [(either on_left on_right)]) + +(documentation: /.then + "Applies functions to both sides of a 2-variant." + [(then on_left on_right)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "Functionality for working with variants (particularly 2-variants)." + [..left + ..right + ..either + ..then + ($.default /.lefts) + ($.default /.rights) + ($.default /.partition) + ($.default /.equivalence) + ($.default /.hash)] + [])) diff --git a/stdlib/source/documentation/lux/data/text.lux b/stdlib/source/documentation/lux/data/text.lux new file mode 100644 index 000000000..51c28a5ef --- /dev/null +++ b/stdlib/source/documentation/lux/data/text.lux @@ -0,0 +1,27 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list]]]]] + ["." / #_ + ["#." buffer] + ["#." encoding] + ["#." escape] + ["#." format] + ["#." regex] + ["#." unicode]]) + +(.def: .public documentation + (.List $.Module) + (list.together + (list /buffer.documentation + /encoding.documentation + /escape.documentation + /format.documentation + /regex.documentation + /unicode.documentation + ))) diff --git a/stdlib/source/documentation/lux/data/text/buffer.lux b/stdlib/source/documentation/lux/data/text/buffer.lux new file mode 100644 index 000000000..b392992f1 --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/buffer.lux @@ -0,0 +1,25 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Buffer + "Immutable text buffer for efficient text concatenation.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Buffer + ($.default /.empty) + ($.default /.then) + ($.default /.size) + ($.default /.text)] + [])) diff --git a/stdlib/source/documentation/lux/data/text/encoding.lux b/stdlib/source/documentation/lux/data/text/encoding.lux new file mode 100644 index 000000000..b0cef359b --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/encoding.lux @@ -0,0 +1,318 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." utf8]]) + +(documentation: /.Encoding + "Encoding formats for text.") + +(template [<name>] + [(documentation: <name> + (format "'" (/.name <name>) "' text encoding. "))] + + [/.ascii] + + [/.ibm_037] + [/.ibm_273] + [/.ibm_277] + [/.ibm_278] + [/.ibm_280] + [/.ibm_284] + [/.ibm_285] + [/.ibm_290] + [/.ibm_297] + [/.ibm_300] + [/.ibm_420] + [/.ibm_424] + [/.ibm_437] + [/.ibm_500] + [/.ibm_737] + [/.ibm_775] + [/.ibm_833] + [/.ibm_834] + [/.ibm_838] + [/.ibm_850] + [/.ibm_852] + [/.ibm_855] + [/.ibm_856] + [/.ibm_857] + [/.ibm_858] + [/.ibm_860] + [/.ibm_861] + [/.ibm_862] + [/.ibm_863] + [/.ibm_864] + [/.ibm_865] + [/.ibm_866] + [/.ibm_868] + [/.ibm_869] + [/.ibm_870] + [/.ibm_871] + [/.ibm_874] + [/.ibm_875] + [/.ibm_918] + [/.ibm_921] + [/.ibm_922] + [/.ibm_930] + [/.ibm_933] + [/.ibm_935] + [/.ibm_937] + [/.ibm_939] + [/.ibm_942] + [/.ibm_942c] + [/.ibm_943] + [/.ibm_943c] + [/.ibm_948] + [/.ibm_949] + [/.ibm_949c] + [/.ibm_950] + [/.ibm_964] + [/.ibm_970] + [/.ibm_1006] + [/.ibm_1025] + [/.ibm_1026] + [/.ibm_1046] + [/.ibm_1047] + [/.ibm_1097] + [/.ibm_1098] + [/.ibm_1112] + [/.ibm_1122] + [/.ibm_1123] + [/.ibm_1124] + [/.ibm_1140] + [/.ibm_1141] + [/.ibm_1142] + [/.ibm_1143] + [/.ibm_1144] + [/.ibm_1145] + [/.ibm_1146] + [/.ibm_1147] + [/.ibm_1148] + [/.ibm_1149] + [/.ibm_1166] + [/.ibm_1364] + [/.ibm_1381] + [/.ibm_1383] + [/.ibm_33722] + + [/.iso_2022_cn] + [/.iso2022_cn_cns] + [/.iso2022_cn_gb] + [/.iso_2022_jp] + [/.iso_2022_jp_2] + [/.iso_2022_kr] + [/.iso_8859_1] + [/.iso_8859_2] + [/.iso_8859_3] + [/.iso_8859_4] + [/.iso_8859_5] + [/.iso_8859_6] + [/.iso_8859_7] + [/.iso_8859_8] + [/.iso_8859_9] + [/.iso_8859_11] + [/.iso_8859_13] + [/.iso_8859_15] + + [/.mac_arabic] + [/.mac_central_europe] + [/.mac_croatian] + [/.mac_cyrillic] + [/.mac_dingbat] + [/.mac_greek] + [/.mac_hebrew] + [/.mac_iceland] + [/.mac_roman] + [/.mac_romania] + [/.mac_symbol] + [/.mac_thai] + [/.mac_turkish] + [/.mac_ukraine] + + [/.utf_8] + [/.utf_16] + [/.utf_32] + + [/.windows_31j] + [/.windows_874] + [/.windows_949] + [/.windows_950] + [/.windows_1250] + [/.windows_1252] + [/.windows_1251] + [/.windows_1253] + [/.windows_1254] + [/.windows_1255] + [/.windows_1256] + [/.windows_1257] + [/.windows_1258] + [/.windows_iso2022jp] + [/.windows_50220] + [/.windows_50221] + + [/.cesu_8] + [/.koi8_r] + [/.koi8_u] + ) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Encoding + + ..ascii + + ..ibm_037 + ..ibm_273 + ..ibm_277 + ..ibm_278 + ..ibm_280 + ..ibm_284 + ..ibm_285 + ..ibm_290 + ..ibm_297 + ..ibm_300 + ..ibm_420 + ..ibm_424 + ..ibm_437 + ..ibm_500 + ..ibm_737 + ..ibm_775 + ..ibm_833 + ..ibm_834 + ..ibm_838 + ..ibm_850 + ..ibm_852 + ..ibm_855 + ..ibm_856 + ..ibm_857 + ..ibm_858 + ..ibm_860 + ..ibm_861 + ..ibm_862 + ..ibm_863 + ..ibm_864 + ..ibm_865 + ..ibm_866 + ..ibm_868 + ..ibm_869 + ..ibm_870 + ..ibm_871 + ..ibm_874 + ..ibm_875 + ..ibm_918 + ..ibm_921 + ..ibm_922 + ..ibm_930 + ..ibm_933 + ..ibm_935 + ..ibm_937 + ..ibm_939 + ..ibm_942 + ..ibm_942c + ..ibm_943 + ..ibm_943c + ..ibm_948 + ..ibm_949 + ..ibm_949c + ..ibm_950 + ..ibm_964 + ..ibm_970 + ..ibm_1006 + ..ibm_1025 + ..ibm_1026 + ..ibm_1046 + ..ibm_1047 + ..ibm_1097 + ..ibm_1098 + ..ibm_1112 + ..ibm_1122 + ..ibm_1123 + ..ibm_1124 + ..ibm_1140 + ..ibm_1141 + ..ibm_1142 + ..ibm_1143 + ..ibm_1144 + ..ibm_1145 + ..ibm_1146 + ..ibm_1147 + ..ibm_1148 + ..ibm_1149 + ..ibm_1166 + ..ibm_1364 + ..ibm_1381 + ..ibm_1383 + ..ibm_33722 + + ..iso_2022_cn + ..iso2022_cn_cns + ..iso2022_cn_gb + ..iso_2022_jp + ..iso_2022_jp_2 + ..iso_2022_kr + ..iso_8859_1 + ..iso_8859_2 + ..iso_8859_3 + ..iso_8859_4 + ..iso_8859_5 + ..iso_8859_6 + ..iso_8859_7 + ..iso_8859_8 + ..iso_8859_9 + ..iso_8859_11 + ..iso_8859_13 + ..iso_8859_15 + + ..mac_arabic + ..mac_central_europe + ..mac_croatian + ..mac_cyrillic + ..mac_dingbat + ..mac_greek + ..mac_hebrew + ..mac_iceland + ..mac_roman + ..mac_romania + ..mac_symbol + ..mac_thai + ..mac_turkish + ..mac_ukraine + + ..utf_8 + ..utf_16 + ..utf_32 + + ..windows_31j + ..windows_874 + ..windows_949 + ..windows_950 + ..windows_1250 + ..windows_1252 + ..windows_1251 + ..windows_1253 + ..windows_1254 + ..windows_1255 + ..windows_1256 + ..windows_1257 + ..windows_1258 + ..windows_iso2022jp + ..windows_50220 + ..windows_50221 + + ..cesu_8 + ..koi8_r + ..koi8_u + + ($.default /.name)] + [/utf8.documentation])) diff --git a/stdlib/source/documentation/lux/data/text/encoding/utf8.lux b/stdlib/source/documentation/lux/data/text/encoding/utf8.lux new file mode 100644 index 000000000..cfe8aee01 --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/encoding/utf8.lux @@ -0,0 +1,18 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [($.default /.codec)] + [])) diff --git a/stdlib/source/documentation/lux/data/text/escape.lux b/stdlib/source/documentation/lux/data/text/escape.lux new file mode 100644 index 000000000..e9c8637fb --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/escape.lux @@ -0,0 +1,40 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.escaped + "Yields a escaped version of the text." + [(escaped text)]) + +(documentation: /.un_escaped + (format "Yields an un-escaped text." + \n "Fails if it was improperly escaped.") + [(un_escaped text)]) + +(documentation: /.literal + "If given a escaped text literal, expands to an un-escaped version." + [(/.literal "Line 1\nLine 2") + "=>" + (format "Line 1" \n + "Line 2")]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..escaped + ..un_escaped + ..literal + ($.default /.escapable?) + ($.default /.dangling_escape) + ($.default /.invalid_escape) + ($.default /.invalid_unicode_escape)] + [])) diff --git a/stdlib/source/documentation/lux/data/text/format.lux b/stdlib/source/documentation/lux/data/text/format.lux new file mode 100644 index 000000000..4f823901e --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/format.lux @@ -0,0 +1,68 @@ +(.module: + [library + [lux (#- nat int rev type list) + ["$" documentation (#+ documentation:)] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Format + "A way to produce readable text from values.") + +(documentation: /.format + "Text interpolation." + [(format "Static part " (text static) " does not match URI: " uri)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Format + ..format + ($.default /.functor) + + ($.default /.bit) + ($.default /.nat) + ($.default /.int) + ($.default /.rev) + ($.default /.frac) + ($.default /.text) + + ($.default /.ratio) + ($.default /.name) + ($.default /.location) + ($.default /.code) + ($.default /.type) + + ($.default /.instant) + ($.default /.duration) + ($.default /.date) + ($.default /.time) + ($.default /.day) + ($.default /.month) + + ($.default /.xml) + ($.default /.json) + + ($.default /.nat/2) + ($.default /.nat/8) + ($.default /.nat/10) + ($.default /.nat/16) + ($.default /.int/2) + ($.default /.int/8) + ($.default /.int/10) + ($.default /.int/16) + ($.default /.rev/2) + ($.default /.rev/8) + ($.default /.rev/10) + ($.default /.rev/16) + ($.default /.frac/2) + ($.default /.frac/8) + ($.default /.frac/10) + ($.default /.frac/16) + + ($.default /.mod) + ($.default /.list) + ($.default /.maybe)] + [])) diff --git a/stdlib/source/documentation/lux/data/text/regex.lux b/stdlib/source/documentation/lux/data/text/regex.lux new file mode 100644 index 000000000..2538af472 --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/regex.lux @@ -0,0 +1,79 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.regex + "Create lexers using regular-expression syntax." + ["Literals" + (regex "a")] + ["Wildcards" + (regex ".")] + ["Escaping" + (regex "\.")] + ["Character classes" + (regex "\d") + (regex "\p{Lower}") + (regex "[abc]") + (regex "[a-z]") + (regex "[a-zA-Z]") + (regex "[a-z&&[def]]")] + ["Negation" + (regex "[^abc]") + (regex "[^a-z]") + (regex "[^a-zA-Z]") + (regex "[a-z&&[^bc]]") + (regex "[a-z&&[^m-p]]")] + ["Combinations" + (regex "aa") + (regex "a?") + (regex "a*") + (regex "a+")] + ["Specific amounts" + (regex "a{2}")] + ["At least" + (regex "a{1,}")] + ["At most" + (regex "a{,1}")] + ["Between" + (regex "a{1,2}")] + ["Groups" + (regex "a(.)c") + (regex "a(b+)c") + (regex "(\d{3})-(\d{3})-(\d{4})") + (regex "(\d{3})-(?:\d{3})-(\d{4})") + (regex "(?<code>\d{3})-\k<code>-(\d{4})") + (regex "(?<code>\d{3})-\k<code>-(\d{4})-\0") + (regex "(\d{3})-((\d{3})-(\d{4}))")] + ["Alternation" + (regex "a|b") + (regex "a(.)(.)|b(.)(.)")]) + +(documentation: /.^regex + "Allows you to test text against regular expressions." + [(case some_text + (^regex "(\d{3})-(\d{3})-(\d{4})" + [_ country_code area_code place_code]) + do_some_thing_when_number + + (^regex "\w+") + do_some_thing_when_word + + _ + do_something_else)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..regex + ..^regex + ($.default /.incorrect_quantification)] + [])) diff --git a/stdlib/source/documentation/lux/data/text/unicode.lux b/stdlib/source/documentation/lux/data/text/unicode.lux new file mode 100644 index 000000000..b170ae516 --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/unicode.lux @@ -0,0 +1,19 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list]]]]] + ["." / #_ + ["#." block] + ["#." set]]) + +(.def: .public documentation + (.List $.Module) + (list.together + (list /block.documentation + /set.documentation + ))) diff --git a/stdlib/source/documentation/lux/data/text/unicode/block.lux b/stdlib/source/documentation/lux/data/text/unicode/block.lux new file mode 100644 index 000000000..703ac9f58 --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/unicode/block.lux @@ -0,0 +1,265 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]] + [math + [number + ["." nat ("#\." hex)]]]]] + [\\library + ["." /]]) + +(documentation: /.Block + "A block of valid unicode characters.") + +(documentation: /.block + "" + [(block start additional)]) + +(documentation: /.within? + "" + [(within? block char)]) + +(template [<name>] + [(documentation: <name> + (let [[_ name] (name_of <name>)] + (format (nat\encode (/.start <name>)) + "-" (nat\encode (/.end <name>)) + " | " (text.replaced "_" " " name))))] + + [/.basic_latin] + [/.latin_1_supplement] + [/.latin_extended_a] + [/.latin_extended_b] + [/.ipa_extensions] + [/.spacing_modifier_letters] + [/.combining_diacritical_marks] + [/.greek_and_coptic] + [/.cyrillic] + [/.cyrillic_supplementary] + [/.armenian] + [/.hebrew] + [/.arabic] + [/.syriac] + [/.thaana] + [/.devanagari] + [/.bengali] + [/.gurmukhi] + [/.gujarati] + [/.oriya] + [/.tamil] + [/.telugu] + [/.kannada] + [/.malayalam] + [/.sinhala] + [/.thai] + [/.lao] + [/.tibetan] + [/.myanmar] + [/.georgian] + [/.hangul_jamo] + [/.ethiopic] + [/.cherokee] + [/.unified_canadian_aboriginal_syllabics] + [/.ogham] + [/.runic] + [/.tagalog] + [/.hanunoo] + [/.buhid] + [/.tagbanwa] + [/.khmer] + [/.mongolian] + [/.limbu] + [/.tai_le] + [/.khmer_symbols] + [/.phonetic_extensions] + [/.latin_extended_additional] + [/.greek_extended] + [/.general_punctuation] + [/.superscripts_and_subscripts] + [/.currency_symbols] + [/.combining_diacritical_marks_for_symbols] + [/.letterlike_symbols] + [/.number_forms] + [/.arrows] + [/.mathematical_operators] + [/.miscellaneous_technical] + [/.control_pictures] + [/.optical_character_recognition] + [/.enclosed_alphanumerics] + [/.box_drawing] + [/.block_elements] + [/.geometric_shapes] + [/.miscellaneous_symbols] + [/.dingbats] + [/.miscellaneous_mathematical_symbols_a] + [/.supplemental_arrows_a] + [/.braille_patterns] + [/.supplemental_arrows_b] + [/.miscellaneous_mathematical_symbols_b] + [/.supplemental_mathematical_operators] + [/.miscellaneous_symbols_and_arrows] + [/.cjk_radicals_supplement] + [/.kangxi_radicals] + [/.ideographic_description_characters] + [/.cjk_symbols_and_punctuation] + [/.hiragana] + [/.katakana] + [/.bopomofo] + [/.hangul_compatibility_jamo] + [/.kanbun] + [/.bopomofo_extended] + [/.katakana_phonetic_extensions] + [/.enclosed_cjk_letters_and_months] + [/.cjk_compatibility] + [/.cjk_unified_ideographs_extension_a] + [/.yijing_hexagram_symbols] + [/.cjk_unified_ideographs] + [/.yi_syllables] + [/.yi_radicals] + [/.hangul_syllables] + [/.high_surrogates] + [/.high_private_use_surrogates] + [/.low_surrogates] + [/.private_use_area] + [/.cjk_compatibility_ideographs] + [/.alphabetic_presentation_forms] + [/.arabic_presentation_forms_a] + [/.variation_selectors] + [/.combining_half_marks] + [/.cjk_compatibility_forms] + [/.small_form_variants] + [/.arabic_presentation_forms_b] + [/.halfwidth_and_fullwidth_forms] + [/.specials] + [/.basic_latin/decimal] + [/.basic_latin/upper] + [/.basic_latin/lower] + ) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Block + ..block + ..within? + ..basic_latin + ..latin_1_supplement + ..latin_extended_a + ..latin_extended_b + ..ipa_extensions + ..spacing_modifier_letters + ..combining_diacritical_marks + ..greek_and_coptic + ..cyrillic + ..cyrillic_supplementary + ..armenian + ..hebrew + ..arabic + ..syriac + ..thaana + ..devanagari + ..bengali + ..gurmukhi + ..gujarati + ..oriya + ..tamil + ..telugu + ..kannada + ..malayalam + ..sinhala + ..thai + ..lao + ..tibetan + ..myanmar + ..georgian + ..hangul_jamo + ..ethiopic + ..cherokee + ..unified_canadian_aboriginal_syllabics + ..ogham + ..runic + ..tagalog + ..hanunoo + ..buhid + ..tagbanwa + ..khmer + ..mongolian + ..limbu + ..tai_le + ..khmer_symbols + ..phonetic_extensions + ..latin_extended_additional + ..greek_extended + ..general_punctuation + ..superscripts_and_subscripts + ..currency_symbols + ..combining_diacritical_marks_for_symbols + ..letterlike_symbols + ..number_forms + ..arrows + ..mathematical_operators + ..miscellaneous_technical + ..control_pictures + ..optical_character_recognition + ..enclosed_alphanumerics + ..box_drawing + ..block_elements + ..geometric_shapes + ..miscellaneous_symbols + ..dingbats + ..miscellaneous_mathematical_symbols_a + ..supplemental_arrows_a + ..braille_patterns + ..supplemental_arrows_b + ..miscellaneous_mathematical_symbols_b + ..supplemental_mathematical_operators + ..miscellaneous_symbols_and_arrows + ..cjk_radicals_supplement + ..kangxi_radicals + ..ideographic_description_characters + ..cjk_symbols_and_punctuation + ..hiragana + ..katakana + ..bopomofo + ..hangul_compatibility_jamo + ..kanbun + ..bopomofo_extended + ..katakana_phonetic_extensions + ..enclosed_cjk_letters_and_months + ..cjk_compatibility + ..cjk_unified_ideographs_extension_a + ..yijing_hexagram_symbols + ..cjk_unified_ideographs + ..yi_syllables + ..yi_radicals + ..hangul_syllables + ..high_surrogates + ..high_private_use_surrogates + ..low_surrogates + ..private_use_area + ..cjk_compatibility_ideographs + ..alphabetic_presentation_forms + ..arabic_presentation_forms_a + ..variation_selectors + ..combining_half_marks + ..cjk_compatibility_forms + ..small_form_variants + ..arabic_presentation_forms_b + ..halfwidth_and_fullwidth_forms + ..specials + ..basic_latin/decimal + ..basic_latin/upper + ..basic_latin/lower + ($.default /.monoid) + ($.default /.start) + ($.default /.end) + ($.default /.size) + ($.default /.equivalence) + ($.default /.hash)] + [])) diff --git a/stdlib/source/documentation/lux/data/text/unicode/set.lux b/stdlib/source/documentation/lux/data/text/unicode/set.lux new file mode 100644 index 000000000..55a114882 --- /dev/null +++ b/stdlib/source/documentation/lux/data/text/unicode/set.lux @@ -0,0 +1,42 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.set + "" + [(set [head tail])]) + +(documentation: /.member? + "" + [(member? set character)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..set + ..member? + ($.default /.Set) + ($.default /.composite) + ($.default /.character) + ($.default /.non_character) + ($.default /.full) + ($.default /.start) + ($.default /.end) + ($.default /.equivalence) + + ($.default /.ascii) + ($.default /.ascii/alpha) + ($.default /.ascii/alpha_num) + ($.default /.ascii/numeric) + ($.default /.ascii/upper) + ($.default /.ascii/lower)] + [])) diff --git a/stdlib/source/documentation/lux/debug.lux b/stdlib/source/documentation/lux/debug.lux new file mode 100644 index 000000000..37832c4bf --- /dev/null +++ b/stdlib/source/documentation/lux/debug.lux @@ -0,0 +1,80 @@ +(.module: + [library + [lux (#- private) + ["$" documentation (#+ documentation:)] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.inspection + "A best-effort attempt to generate a textual representation of a value, without knowing its type." + [(inspection value)]) + +(documentation: /.representation + "A best-effort attempt to generate a textual representation of a value, while knowing its type." + [(representation type value)]) + +(documentation: /.private + "Allows access to un-exported definitions in other modules." + ["Module A" + (def: .private (secret_definition input) + (-> ??? ???) + (foo (bar (baz input)))) + "Module B" + ((/.private secret_definition) my_input)]) + +(documentation: /.log! + "Prints/writes a message to standard output." + [(log! message)]) + +(documentation: /.:hole + (format "A typed 'hole'." + \n "Reveals the type expected of the expression that should go in the hole.") + [(: (-> Nat Text) + (function (_ number) + (:hole))) + "=>" + .Text]) + +(documentation: /.here + "Shows the names and values of local bindings available around the call to 'here'." + [(let [foo 123 + bar +456 + baz +789.0] + (: Any + (here))) + "=>" + "foo: +123" + "bar: +456" + "baz: +789.0" + []] + ["Can optionally be given a list of definitions to focus on." + "These definitions to focus on can include custom format to represent the values." + (let [foo 123 + bar +456 + baz +789.0] + (: Any + (here {foo %.nat} baz))) + "=>" + "foo: 123" + "baz: +789.0" + []]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..inspection + ..representation + ..private + ..log! + ..:hole + ..here + ($.default /.cannot_represent_value) + ($.default /.type_hole) + ($.default /.unknown_local_binding)] + [])) diff --git a/stdlib/source/documentation/lux/documentation.lux b/stdlib/source/documentation/lux/documentation.lux new file mode 100644 index 000000000..0c8b0722f --- /dev/null +++ b/stdlib/source/documentation/lux/documentation.lux @@ -0,0 +1,49 @@ +(.module: + [library + [lux #* + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(/.documentation: /.default + "" + [(: /.Definition + (default ..definition))]) + +(/.documentation: /.documentation: + "" + [(documentation: /.default + "" + [(: /.Definition + (default ..definition))])]) + +(/.documentation: /.module + "" + [(: (.List /.Module) + (module /._ + "" + [..default + ..documentation: + ..module + (/.default /.unqualified_identifier) + (/.default /.Definition) + (/.default /.Module) + (/.default /.documentation)] + []))]) + +(.def: .public documentation + (.List /.Module) + (/.module /._ + "" + [..default + ..documentation: + ..module + (/.default /.unqualified_identifier) + (/.default /.Definition) + (/.default /.Module) + (/.default /.documentation)] + [])) diff --git a/stdlib/source/documentation/lux/ffi.lux b/stdlib/source/documentation/lux/ffi.lux new file mode 100644 index 000000000..89829884b --- /dev/null +++ b/stdlib/source/documentation/lux/ffi.lux @@ -0,0 +1,336 @@ +(.module: + [library + [lux (#- int char interface: type :as) + ["$" documentation (#+ documentation:)] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(template [<name>] + [(`` (documentation: <name> + (format "The type of a (boxed) " (~~ (template.text [<name>])) " object.")))] + + [/.Boolean] + [/.Byte] + [/.Short] + [/.Integer] + [/.Long] + [/.Float] + [/.Double] + [/.Character] + ) + +(template [<name>] + [(`` (documentation: <name> + (format "The type of an (unboxed) " (~~ (template.text [<name>])) " value.")))] + + [/.boolean] + [/.byte] + [/.short] + [/.int] + [/.long] + [/.float] + [/.double] + [/.char] + ) + +(template [<name> <from> <to>] + [(`` (documentation: <name> + "Type converter." + [(: <to> + (<name> (: <from> foo)))]))] + + [/.byte_to_long Byte Long] + + [/.short_to_long Short Long] + + [/.double_to_int Double Integer] + [/.double_to_long Double Long] + [/.double_to_float Double Float] + + [/.float_to_int Float Integer] + [/.float_to_long Float Long] + [/.float_to_double Float Double] + + [/.int_to_byte Integer Byte] + [/.int_to_short Integer Short] + [/.int_to_long Integer Long] + [/.int_to_float Integer Float] + [/.int_to_double Integer Double] + [/.int_to_char Integer Character] + + [/.long_to_byte Long Byte] + [/.long_to_short Long Short] + [/.long_to_int Long Integer] + [/.long_to_float Long Float] + [/.long_to_double Long Double] + + [/.char_to_byte Character Byte] + [/.char_to_short Character Short] + [/.char_to_int Character Integer] + [/.char_to_long Character Long] + + [/.long_to_char Long Character] + [/.byte_to_int Byte Integer] + [/.short_to_int Short Integer] + [/.byte_to_char Byte Character] + [/.short_to_char Short Character] + ) + +(documentation: /.class: + "Allows defining JVM classes in Lux code." + [(class: #final (TestClass A) [Runnable] + ... Fields + (#private foo boolean) + (#private bar A) + (#private baz java/lang/Object) + ... Methods + (#public [] (new [value A]) [] + (exec + (:= ::foo #1) + (:= ::bar value) + (:= ::baz "") + [])) + (#public (virtual) java/lang/Object + "") + (#public #static (static) java/lang/Object + "") + (Runnable [] (run) void + []) + ) + + "The tuple corresponds to parent interfaces." + "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." + "Fields and methods defined in the class can be used with special syntax." + "For example:" + "::resolved, for accessing the 'resolved' field." + "(:= ::resolved #1) for modifying it." + "(::new! []) for calling the class's constructor." + "(::resolve! container [value]) for calling the 'resolve' method."]) + +(documentation: /.interface: + "Allows defining JVM interfaces." + [(interface: TestInterface + ([] foo [boolean String] void #throws [Exception]))]) + +(documentation: /.object + "Allows defining anonymous classes." + ["The 1st tuple corresponds to class-level type-variables." + "The 2nd tuple corresponds to parent interfaces." + "The 3rd tuple corresponds to arguments to the super class constructor." + "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." + (object [] [Runnable] + [] + (Runnable [] (run self) void + (exec + (do_something some_value) + [])))]) + +(documentation: /.null + "The null pointer." + [(null)]) + +(documentation: /.null? + "Test for the null pointer." + [(= true + (null? (null)))] + [(= false + (null? "YOLO"))]) + +(documentation: /.??? + "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." + [(= (??? (: java/lang/String (null))) + #.None)] + [(= (??? "YOLO") + (#.Some "YOLO"))]) + +(documentation: /.!!! + (format "Takes a (Maybe ObjectType) and returns a ObjectType." + \n "A #.None would get translated into a (null).") + [(= (null) + (!!! (??? (: java/lang/Thread (null)))))] + [(= "foo" + (!!! (??? "foo")))]) + +(documentation: /.check + (format "Checks whether an object is an instance of a particular class." + \n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.") + [(case (check String "YOLO") + (#.Some value_as_string) + #.None)]) + +(documentation: /.synchronized + "Evaluates body, while holding a lock on a given object." + [(synchronized object_to_be_locked + (exec + (do something) + (dosomething else) + (finish the computation)))]) + +(documentation: /.do_to + "Call a variety of methods on an object. Then, return the object." + [(do_to object + (ClassName::method1 arg0 arg1 arg2) + (ClassName::method2 arg3 arg4 arg5))]) + +(documentation: /.import: + "Allows importing JVM classes, and using them as types." + ["Their methods, fields and enum options can also be imported." + (import: java/lang/Object + ["#::." + (new []) + (equals [java/lang/Object] boolean) + (wait [int] #io #try void)])] + ["Special options can also be given for the return values." + "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." + "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." + "#io means the computation has side effects, and will be wrapped by the IO type." + "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." + (import: java/lang/String + ["#::." + (new [[byte]]) + (#static valueOf [char] java/lang/String) + (#static valueOf #as int_valueOf [int] java/lang/String)]) + + (import: (java/util/List e) + ["#::." + (size [] int) + (get [int] e)]) + + (import: (java/util/ArrayList a) + ["#::." + ([T] toArray [[T]] [T])])] + ["The class-type that is generated is of the fully-qualified name." + "This avoids a clash between the java.util.List type, and Lux's own List type." + "All enum options to be imported must be specified." + (import: java/lang/Character$UnicodeScript + ["#::." + (#enum ARABIC CYRILLIC LATIN)])] + ["It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars." + "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." + (import: (lux/concurrency/async/JvmAsync A) + ["#::." + (resolve [A] boolean) + (poll [] A) + (wasResolved [] boolean) + (waitOn [lux/Function] void) + (#static [A] make [A] (lux/concurrency/async/JvmAsync A))])] + ["Also, the names of the imported members will look like Class::member" + (java/lang/Object::new []) + (java/lang/Object::equals [other_object] my_object) + (java/util/List::size [] my_list) + java/lang/Character$UnicodeScript::LATIN]) + +(documentation: /.array + "Create an array of the given type, with the given size." + [(array java/lang/Object 10)]) + +(documentation: /.length + "Gives the length of an array." + [(length my_array)]) + +(documentation: /.read! + "Loads an element from an array." + [(read! 10 my_array)]) + +(documentation: /.write! + "Stores an element into an array." + [(write! 10 my_object my_array)]) + +(documentation: /.class_for + "Loads the class as a java.lang.Class object." + [(class_for java/lang/String)]) + +(documentation: /.type + "" + [(: Type + (type java/lang/String))]) + +(documentation: /.:as + "" + [(:as java/lang/Object + (: java/lang/String + ???))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Boolean + ..Byte + ..Short + ..Integer + ..Long + ..Float + ..Double + ..Character + + ..boolean + ..byte + ..short + ..int + ..long + ..float + ..double + ..char + + ..byte_to_long + ..short_to_long + ..double_to_int + ..double_to_long + ..double_to_float + ..float_to_int + ..float_to_long + ..float_to_double + ..int_to_byte + ..int_to_short + ..int_to_long + ..int_to_float + ..int_to_double + ..int_to_char + ..long_to_byte + ..long_to_short + ..long_to_int + ..long_to_float + ..long_to_double + ..char_to_byte + ..char_to_short + ..char_to_int + ..char_to_long + ..long_to_char + ..byte_to_int + ..short_to_int + ..byte_to_char + ..short_to_char + + ..class: + ..interface: + ..object + ..null + ..null? + ..??? + ..!!! + ..check + ..synchronized + ..do_to + ..import: + ..array + ..length + ..read! + ..write! + ..class_for + ..type + ..:as + ($.default /.Privacy) + ($.default /.State) + ($.default /.Inheritance) + ($.default /.class_names_cannot_contain_periods) + ($.default /.class_name_cannot_be_a_type_variable) + ($.default /.unexpected_type_variable) + ($.default /.cannot_convert_to_jvm_type) + ($.default /.cannot_cast_to_non_object)] + [])) diff --git a/stdlib/source/documentation/lux/program.lux b/stdlib/source/documentation/lux/program.lux new file mode 100644 index 000000000..15a916d71 --- /dev/null +++ b/stdlib/source/documentation/lux/program.lux @@ -0,0 +1,33 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [control + ["." io]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.program: + "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)." + ["Can take a list of all the input parameters to the program." + (program: all_arguments + (do io.monad + [foo (initialize program)] + (do_something_with all_arguments)))] + ["Can also parse them using CLI parsers from the library/lux/control/parser/cli module." + (program: [config configuration_parser] + (do io.monad + [data (initialize program with config)] + (do_something_with data)))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..program:] + [])) diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 6c1335fe9..50fe70f4e 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -195,25 +195,35 @@ ({Type_Pair (9 #0 Nothing (7 #0 #End - (1 #0 ... "lux.Primitive" + (1 #0 + ... "lux.Primitive" (2 #0 Text Type_List) - (1 #0 ... "lux.Sum" + (1 #0 + ... "lux.Sum" Type_Pair - (1 #0 ... "lux.Product" + (1 #0 + ... "lux.Product" Type_Pair - (1 #0 ... "lux.Function" + (1 #0 + ... "lux.Function" Type_Pair - (1 #0 ... "lux.Parameter" + (1 #0 + ... "lux.Parameter" Nat - (1 #0 ... "lux.Var" + (1 #0 + ... "lux.Var" Nat - (1 #0 ... "lux.Ex" + (1 #0 + ... "lux.Ex" Nat - (1 #0 ... "lux.UnivQ" + (1 #0 + ... "lux.UnivQ" (2 #0 Type_List Type) - (1 #0 ... "lux.ExQ" + (1 #0 + ... "lux.ExQ" (2 #0 Type_List Type) - (1 #0 ... "lux.Apply" + (1 #0 + ... "lux.Apply" Type_Pair ... "lux.Named" (2 #0 Name Type)))))))))))))} diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index b95df4bfd..a9f69d81e 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -124,7 +124,7 @@ (def: .public (this reference) (-> Text (Parser Any)) (function (_ [offset tape]) - (case (/.index_of' offset reference tape) + (case (/.index' offset reference tape) (#.Some where) (if (n.= offset where) (#try.Success [[("lux i64 +" (/.size reference) offset) tape] diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index 7a6ccadba..bb0510528 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -33,20 +33,16 @@ (|>> (n.* i64.bits_per_byte) i64.mask)) (type: .public Mutation - {#.doc (example "A mutation of binary data, tracking where in the data to transform.")} (-> [Offset Binary] [Offset Binary])) (type: .public Specification - {#.doc (example "A description of how to transform binary data.")} [Size Mutation]) (def: .public no_op - {#.doc (example "A specification for empty binary data.")} Specification [0 function.identity]) (def: .public (instance [size mutation]) - {#.doc (example "Given a specification of how to construct binary data, yields a binary blob that matches it.")} (-> Specification Binary) (|> size binary.empty [0] mutation product.right)) @@ -61,11 +57,9 @@ (|>> mutL mutR)])) (type: .public (Writer a) - {#.doc (example "An operation that knows how to write information into a binary blob.")} (-> a Specification)) (def: .public (result writer value) - {#.doc (example "Yields a binary blob with all the information written to it.")} (All [a] (-> (Writer a) a Binary)) (..instance (writer value))) @@ -110,7 +104,6 @@ (\ ..monoid compose (pre preV) (post postV)))) (def: .public (rec body) - {#.doc (example "A combinator for recursive writers.")} (All [a] (-> (-> (Writer a) (Writer a)) (Writer a))) (function (recur value) (body recur value))) @@ -136,7 +129,6 @@ (|>> frac.bits ..bits/64)) (def: .public (segment size) - {#.doc (example "Writes at most 'size' bytes of an input binary blob.")} (-> Nat (Writer Binary)) (function (_ value) [size diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index c6a7ebef0..ed2643efa 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -1,6 +1,4 @@ (.module: - {#.doc (.example "Functionality for reading and writing values in the JSON format." - "For more information, please see: http://www.json.org/")} [library [lux #* ["." meta (#+ monad)] @@ -68,14 +66,6 @@ (|>> (dictionary.of_list text.hash) #..Object)) (syntax: .public (json [token <code>.any]) - {#.doc (example "A simple way to produce JSON literals." - (json #null) - (json #1) - (json +123.456) - (json "this is a string") - (json ["this" "is" "an" "array"]) - (json {"this" "is" - "an" "object"}))} (let [(^open ".") ..monad wrapper (function (_ x) (` (..json (~ x))))] (case token @@ -111,7 +101,6 @@ (in (list token))))) (def: .public (fields json) - {#.doc "Get all the fields in a JSON object."} (-> JSON (Try (List String))) (case json (#Object obj) @@ -121,7 +110,6 @@ (#try.Failure ($_ text\compose "Cannot get the fields of a non-object.")))) (def: .public (field key json) - {#.doc "A JSON object field getter."} (-> String JSON (Try JSON)) (case json (#Object obj) @@ -136,7 +124,6 @@ (#try.Failure ($_ text\compose "Cannot get field '" key "' on a non-object.")))) (def: .public (has key value json) - {#.doc "A JSON object field setter."} (-> String JSON JSON (Try JSON)) (case json (#Object obj) @@ -145,9 +132,8 @@ _ (#try.Failure ($_ text\compose "Cannot set field '" key "' on a non-object.")))) -(template [<name> <tag> <type> <desc>] +(template [<name> <tag> <type>] [(def: .public (<name> key json) - {#.doc (code.text ($_ text\compose "A JSON object field getter for " <desc> "."))} (-> Text JSON (Try <type>)) (case (field key json) (#try.Success (<tag> value)) @@ -159,11 +145,11 @@ (#try.Failure error) (#try.Failure error)))] - [boolean_field #Boolean Boolean "booleans"] - [number_field #Number Number "numbers"] - [string_field #String String "strings"] - [array_field #Array Array "arrays"] - [object_field #Object Object "objects"] + [boolean_field #Boolean Boolean] + [number_field #Number Number] + [string_field #String String] + [array_field #Array Array] + [object_field #Object Object] ) (implementation: .public equivalence diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index c26a7a751..59a24a875 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -36,7 +36,9 @@ (type: Size Nat) -(def: octal_size Size 8) +(def: octal_size + Size + 8) (def: (octal_padding max_size number) (-> Size Text Text) @@ -729,7 +731,9 @@ (#Directory value) (..directory_writer value) (#Contiguous value) (..contiguous_file_writer value)))) -(def: end_of_archive_size Size (n.* 2 ..block_size)) +(def: end_of_archive_size + Size + (n.* 2 ..block_size)) (def: .public writer (Writer Tar) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index b596734ea..4e358f91d 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -31,7 +31,6 @@ (Dictionary Attribute Text)) (def: .public attributes - {#.doc (example "An empty set of XML attributes.")} Attrs (dictionary.empty name.hash)) @@ -207,14 +206,12 @@ (text.replaced text.double_quote """))) (def: .public (tag [namespace name]) - {#.doc (example "The text format of a XML tag.")} (-> Tag Text) (case namespace "" name _ ($_ text\compose namespace ..namespace_separator name))) (def: .public attribute - {#.doc (example "The text format of a XML attribute.")} (-> Attribute Text) ..tag) diff --git a/stdlib/source/library/lux/data/identity.lux b/stdlib/source/library/lux/data/identity.lux index 1a7f1ec76..72ae09d38 100644 --- a/stdlib/source/library/lux/data/identity.lux +++ b/stdlib/source/library/lux/data/identity.lux @@ -10,7 +10,6 @@ ["." function]]]]) (type: .public (Identity a) - {#.doc (example "A value, as is, without any extra structure super-imposed on it.")} a) (implementation: .public functor diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux index 8373951c4..3dfa6dcce 100644 --- a/stdlib/source/library/lux/data/name.lux +++ b/stdlib/source/library/lux/data/name.lux @@ -13,15 +13,13 @@ ... (type: Name ... [Text Text]) -(template [<name> <doc>] - [(def: .public (<name> name) - {#.doc (example <doc>)} +(template [<name>] + [(def: .public (<name> [module short]) (-> Name Text) - (let [[module short] name] - <name>))] + <name>)] - [module "The module part of a name."] - [short "The short part of a name."] + [module] + [short] ) (def: .public hash diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index aba9488bc..9a3bf40dc 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -6,21 +6,18 @@ [equivalence (#+ Equivalence)] [hash (#+ Hash)]]]]) -(template [<name> <doc>] - [(def: .public (<name> pair) - {#.doc (example <doc>)} +(template [<name>] + [(def: .public (<name> [left right]) (All [left right] (-> [left right] <name>)) - (let [[left right] pair] - <name>))] + <name>)] - [left "The left side of a pair."] - [right "The right side of a pair."] + [left] + [right] ) ... https://en.wikipedia.org/wiki/Currying (def: .public (curried f) - {#.doc (example "Converts a 2-argument function into nested single-argument functions.")} (All [a b c] (-> (-> [a b] c) (-> a b c))) @@ -28,7 +25,6 @@ (f [x y]))) (def: .public (uncurried f) - {#.doc (example "Converts nested single-argument functions into a 2-argument function.")} (All [a b c] (-> (-> a b c) (-> [a b] c))) @@ -36,13 +32,11 @@ (let [[x y] xy] (f x y)))) -(def: .public (swapped xy) - (All [a b] (-> [a b] [b a])) - (let [[x y] xy] - [y x])) +(def: .public (swapped [left right]) + (All [left right] (-> [left right] [right left])) + [right left]) (def: .public (then f g) - {#.doc (example "Apply functions to both sides of a pair.")} (All [a b c d] (-> (-> a c) (-> b d) (-> [a b] [c d]))) @@ -50,7 +44,6 @@ [(f x) (g y)])) (def: .public (forked f g) - {#.doc (example "Yields a pair by applying both functions to a single value.")} (All [a l r] (-> (-> a l) (-> a r) (-> a [l r]))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index f14efa463..193f25a05 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -1,55 +1,49 @@ (.module: - {#.doc "Functionality for working with variants (particularly 2-variants)."} [library [lux #* [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)]]]]) -(template [<right?> <name> <doc>] +(template [<right?> <name>] [(def: .public (<name> value) - {#.doc (example <doc>)} (All [left right] (-> <name> (Or left right))) (0 <right?> value))] - [#0 left - "Lifts value to the left side of a 2-variant."] - [#1 right - "Lifts value to the right side of a 2-variant."]) + [#0 left] + [#1 right]) -(def: .public (either fl fr) - {#.doc (example "Applies a function to either side of a 2-variant.")} +(def: .public (either on_left on_right) (All [a b c] (-> (-> a c) (-> b c) (-> (Or a b) c))) (function (_ input) (case input - (0 #0 l) (fl l) - (0 #1 r) (fr r)))) + (0 #0 l) (on_left l) + (0 #1 r) (on_right r)))) -(def: .public (then fl fr) - {#.doc (example "Applies functions to both sides of a 2-variant.")} +(def: .public (then on_left on_right) (All [l l' r r'] (-> (-> l l') (-> r r') (-> (Or l r) (Or l' r')))) (function (_ input) (case input - (0 #0 l) (0 #0 (fl l)) - (0 #1 r) (0 #1 (fr r))))) + (0 #0 l) (0 #0 (on_left l)) + (0 #1 r) (0 #1 (on_right r))))) (template [<name> <side> <right?>] - [(def: .public (<name> es) + [(def: .public (<name> items) (All [a b] (-> (List (Or a b)) (List <side>))) - (case es + (case items #.End #.End - (#.Item (0 <right?> x) es') - (#.Item [x (<name> es')]) + (#.Item (0 <right?> x) items') + (#.Item [x (<name> items')]) - (#.Item _ es') - (<name> es')))] + (#.Item _ items') + (<name> items')))] [lefts a #0] [rights b #1] diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index baeade224..096c25a9a 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -59,15 +59,15 @@ (#.Some ("lux text char" index input)) #.None)) -(def: .public (index_of' from pattern input) +(def: .public (index' from pattern input) (-> Nat Text Text (Maybe Nat)) ("lux text index" from pattern input)) -(def: .public (index_of pattern input) +(def: .public (index pattern input) (-> Text Text (Maybe Nat)) - (index_of' 0 pattern input)) + (index' 0 pattern input)) -(def: (last_index_of' from part text) +(def: (last_index' from part text) (-> Nat Text Text (Maybe Nat)) (loop [from from output (: (Maybe Nat) @@ -80,13 +80,13 @@ (#.Some from') (recur (++ from') output'))))) -(def: .public (last_index_of part text) +(def: .public (last_index part text) (-> Text Text (Maybe Nat)) - (last_index_of' 0 part text)) + (last_index' 0 part text)) (def: .public (starts_with? prefix x) (-> Text Text Bit) - (case (index_of prefix x) + (case (index prefix x) (#.Some 0) true @@ -95,7 +95,7 @@ (def: .public (ends_with? postfix x) (-> Text Text Bit) - (case (last_index_of postfix x) + (case (last_index postfix x) (#.Some n) (n.= (size x) (n.+ (size postfix) n)) @@ -166,7 +166,7 @@ (def: .public (split_by token sample) (-> Text Text (Maybe [Text Text])) (do maybe.monad - [index (index_of token sample) + [index (index token sample) [pre post'] (split_at index sample) [_ post] (split_at (size token) post')] (in [pre post]))) diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux index 196227220..08f640648 100644 --- a/stdlib/source/library/lux/data/text/buffer.lux +++ b/stdlib/source/library/lux/data/text/buffer.lux @@ -48,7 +48,7 @@ (as_is)))) (`` (abstract: .public Buffer - {#.doc "Immutable text buffer for efficient text concatenation."} + {} (for {@.old [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)] @.jvm [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)] diff --git a/stdlib/source/library/lux/data/text/encoding.lux b/stdlib/source/library/lux/data/text/encoding.lux index 83474b909..fbe70b92d 100644 --- a/stdlib/source/library/lux/data/text/encoding.lux +++ b/stdlib/source/library/lux/data/text/encoding.lux @@ -8,7 +8,7 @@ ... https://en.wikipedia.org/wiki/Character_encoding#Common_character_encodings (abstract: .public Encoding - {#.doc (example "Encoding formats for text.")} + {} Text diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index 89205cbff..dc847995a 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -110,7 +110,6 @@ post_limit])) (def: .public (escaped text) - {#.doc (example "Yields a escaped version of the text.")} (-> Text Text) (loop [offset 0 previous "" @@ -192,8 +191,6 @@ (exception.except ..invalid_unicode_escape [current offset]))) (def: .public (un_escaped text) - {#.doc (example "Yields an un-escaped text." - "Fails if it was improperly escaped.")} (-> Text (Try Text)) (loop [offset 0 previous "" @@ -239,7 +236,6 @@ _ (format previous current)))))) (syntax: .public (literal [literal <code>.text]) - {#.doc (example "If given a escaped text literal, expands to an un-escaped version.")} (case (..un_escaped literal) (#try.Success un_escaped) (in (list (code.text un_escaped))) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index 894dd8321..de6482910 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -40,7 +40,6 @@ ["." type]]]) (type: .public (Format a) - {#.doc "A way to produce readable text from values."} (-> a Text)) (implementation: .public functor @@ -50,8 +49,6 @@ (|>> f fb))) (syntax: .public (format [fragments (<>.many <code>.any)]) - {#.doc (example "Text interpolation." - (format "Static part " (text static) " does not match URI: " uri))} (in (.list (` ($_ "lux text concat" (~+ fragments)))))) (template [<name> <type> <formatter>] diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 3b26dac8e..8c626ed6e 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -410,64 +410,6 @@ (\ <>.monad map product.right (re_alternative^ #1 re_scoped^ current_module))) (syntax: .public (regex [pattern <code>.text]) - {#.doc (example "Create lexers using regular-expression syntax." - "For example:" - - "Literals" - (regex "a") - - "Wildcards" - (regex ".") - - "Escaping" - (regex "\.") - - "Character classes" - (regex "\d") - (regex "\p{Lower}") - (regex "[abc]") - (regex "[a-z]") - (regex "[a-zA-Z]") - (regex "[a-z&&[def]]") - - "Negation" - (regex "[^abc]") - (regex "[^a-z]") - (regex "[^a-zA-Z]") - (regex "[a-z&&[^bc]]") - (regex "[a-z&&[^m-p]]") - - "Combinations" - (regex "aa") - (regex "a?") - (regex "a*") - (regex "a+") - - "Specific amounts" - (regex "a{2}") - - "At least" - (regex "a{1,}") - - "At most" - (regex "a{,1}") - - "Between" - (regex "a{1,2}") - - "Groups" - (regex "a(.)c") - (regex "a(b+)c") - (regex "(\d{3})-(\d{3})-(\d{4})") - (regex "(\d{3})-(?:\d{3})-(\d{4})") - (regex "(?<code>\d{3})-\k<code>-(\d{4})") - (regex "(?<code>\d{3})-\k<code>-(\d{4})-\0") - (regex "(\d{3})-((\d{3})-(\d{4}))") - - "Alternation" - (regex "a|b") - (regex "a(.)(.)|b(.)(.)") - )} (do meta.monad [current_module meta.current_module_name] (case (<text>.result (regex^ current_module) @@ -483,17 +425,6 @@ (syntax: .public (^regex [[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any))) body <code>.any branches (<>.many <code>.any)]) - {#.doc (example "Allows you to test text against regular expressions." - (case some_text - (^regex "(\d{3})-(\d{3})-(\d{4})" - [_ country_code area_code place_code]) - do_some_thing_when_number - - (^regex "\w+") - do_some_thing_when_word - - _ - do_something_else))} (with_identifiers [g!temp] (in (list& (` (^multi (~ g!temp) {((~! <text>.result) (..regex (~ (code.text pattern))) (~ g!temp)) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 95931ff4a..70087d56a 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -6,23 +6,16 @@ [hash (#+ Hash)] [monoid (#+ Monoid)] ["." interval (#+ Interval)]] - [control - [parser - ["<.>" code]]] - [macro - [syntax (#+ syntax:)] - ["." template] - ["." code]] [math [number (#+ hex) ["n" nat ("#\." interval)] ["." i64]]] [type abstract]]] - ["." /// (#+ Char)]) + [/// (#+ Char)]) (abstract: .public Block - {#.doc (example "A block of valid unicode characters.")} + {} (Interval Char) @@ -30,7 +23,9 @@ (Monoid Block) (def: identity - (:abstraction (interval.between n.enum n\top n\bottom))) + (:abstraction + (interval.between n.enum n\top n\bottom))) + (def: (compose left right) (let [left (:representation left) right (:representation right)] @@ -80,18 +75,12 @@ (i64.or (i64.left_shifted 32 (..start value)) (..end value)))) -(syntax: (block_name [name <code>.local_identifier]) - (in (list (code.text (///.replaced "_" " " name))))) - (template [<name> <start> <end>] - [(with_expansions [<block_name> (..block_name <name>) - <documentation> (template.text [<start> "-" <end> " | " <block_name>])] - (def: .public <name> - {#.doc (example <documentation>)} - Block - (let [start (hex <start>) - end (hex <end>)] - (..block start (n.- start end)))))] + [(def: .public <name> + Block + (let [start (hex <start>) + end (hex <end>)] + (..block start (n.- start end))))] ... Normal blocks [basic_latin "0000" "007F"] diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 7a5a9a153..d033bd3f0 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -141,7 +141,6 @@ (text.enclosed ["[" "]"]))))) (def: .public (inspection value) - {#.doc (example "A best-effort attempt to generate a textual representation of a value, without knowing its type.")} Inspector (with_expansions [<jvm> (let [object (:as java/lang/Object value)] (`` (<| (~~ (template [<class> <processing>] @@ -513,7 +512,6 @@ )))) (def: .public (representation type value) - {#.doc (example "A best-effort attempt to generate a textual representation of a value, while knowing its type.")} (-> Type Any (Try Text)) (case (<type>.result ..representation_parser type) (#try.Success representation) @@ -523,20 +521,12 @@ (exception.except ..cannot_represent_value type))) (syntax: .public (private [definition <code>.identifier]) - {#.doc (example "Allows access to un-exported definitions in other modules." - "Module A" - (def: .private (secret_definition input) - (-> ??? ???) - (foo (bar (baz input)))) - "Module B" - ((..private secret_definition) my_input))} (let [[module _] definition] (in (list (` ("lux in-module" (~ (code.text module)) (~ (code.identifier definition)))))))) (def: .public (log! message) - {#.doc "Prints/writes a message to standard output."} (-> Text Any) ("lux io log" message)) @@ -546,11 +536,6 @@ ["Type" (%.type type)])) (syntax: .public (:hole []) - {#.doc (example "A typed 'hole'." - "Reveals the type expected of the expression that should go in the hole." - (: (-> Nat Text) - (function (_ number) - (:hole))))} (do meta.monad [location meta.location expectedT meta.expected_type] @@ -574,29 +559,6 @@ (|> ..target <>.some (<>.else (list))))]) - {#.doc (example "Shows the names and values of local bindings available around the call to 'here'." - (let [foo 123 - bar +456 - baz +789.0] - (: Any - (here))) - "=>" - "foo: +123" - "bar: +456" - "baz: +789.0" - [] - - "Can optionally be given a list of definitions to focus on." - "These definitions to focus on can include custom format to represent the values." - (let [foo 123 - bar +456 - baz +789.0] - (: Any - (here {foo %.nat} baz))) - "=>" - "foo: 123" - "baz: +789.0" - [])} (do {! meta.monad} [location meta.location locals meta.locals diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index bc91e8880..a025b8108 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -56,7 +56,6 @@ (template [<name> <class>] [(`` (def: .public <name> - {#.doc (example (~~ (template.text ["The type of a (boxed) " <name> " object."])))} .Type (#.Primitive <class> #.End)))] @@ -1211,37 +1210,6 @@ annotations ..annotations^ fields (<>.some (..field_decl^ class_vars)) methods (<>.some (..method_def^ class_vars))]) - {#.doc (example "Allows defining JVM classes in Lux code." - "For example:" - (class: #final (TestClass A) [Runnable] - ... Fields - (#private foo boolean) - (#private bar A) - (#private baz java/lang/Object) - ... Methods - (#public [] (new [value A]) [] - (exec - (:= ::foo #1) - (:= ::bar value) - (:= ::baz "") - [])) - (#public (virtual) java/lang/Object - "") - (#public #static (static) java/lang/Object - "") - (Runnable [] (run) void - []) - ) - - "The tuple corresponds to parent interfaces." - "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." - "Fields and methods defined in the class can be used with special syntax." - "For example:" - "::resolved, for accessing the 'resolved' field." - "(:= ::resolved #1) for modifying it." - "(::new! []) for calling the class's constructor." - "(::resolve! container [value]) for calling the 'resolve' method." - )} (do meta.monad [.let [fully_qualified_class_name full_class_name method_parser (: (Parser Code) @@ -1263,9 +1231,6 @@ (<code>.tuple (<>.some (class^ class_vars)))) annotations ..annotations^ members (<>.some (..method_decl^ class_vars))]) - {#.doc (example "Allows defining JVM interfaces." - (interface: TestInterface - ([] foo [boolean String] void #throws [Exception])))} (in (list (` ("jvm class interface" (~ (declaration$ (type.declaration full_class_name class_vars))) [(~+ (list\map class$ supers))] @@ -1279,18 +1244,6 @@ (<code>.tuple (<>.some (class^ class_vars)))) constructor_args (..constructor_args^ class_vars) methods (<>.some ..overriden_method_def^)]) - {#.doc (example "Allows defining anonymous classes." - "The 1st tuple corresponds to class-level type-variables." - "The 2nd tuple corresponds to parent interfaces." - "The 3rd tuple corresponds to arguments to the super class constructor." - "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." - (object [] [Runnable] - [] - (Runnable [] (run self) void - (exec - (do_something some_value) - []))) - )} (in (list (` ("jvm class anonymous" [(~+ (list\map var$ class_vars))] (~ (class$ super)) @@ -1299,25 +1252,13 @@ [(~+ (list\map (method_def$ "" (<>.failure "") super (list)) methods))]))))) (syntax: .public (null []) - {#.doc (example "The null pointer." - (null))} (in (list (` ("jvm object null"))))) (def: .public (null? obj) - {#.doc (example "Test for the null pointer." - (= (null? (null)) - true) - (= (null? "YOLO") - false))} (-> (primitive "java.lang.Object") Bit) ("jvm object null?" obj)) (syntax: .public (??? [expr <code>.any]) - {#.doc (example "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." - (= (??? (: java/lang/String (null))) - #.None) - (= (??? "YOLO") - (#.Some "YOLO")))} (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] (if ("jvm object null?" (~ g!temp)) @@ -1325,12 +1266,6 @@ (#.Some (~ g!temp))))))))) (syntax: .public (!!! [expr <code>.any]) - {#.doc (example "Takes a (Maybe ObjectType) and returns a ObjectType." - "A #.None would get translated into a (null)." - (= (null) - (!!! (??? (: java/lang/Thread (null))))) - (= "foo" - (!!! (??? "foo"))))} (with_identifiers [g!value] (in (list (` ({(#.Some (~ g!value)) (~ g!value) @@ -1341,11 +1276,6 @@ (syntax: .public (check [class (..type^ (list)) unchecked (<>.maybe <code>.any)]) - {#.doc (example "Checks whether an object is an instance of a particular class." - "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes." - (case (check String "YOLO") - (#.Some value_as_string) - #.None))} (with_identifiers [g!_ g!unchecked] (let [class_name (..reflection class) class_type (` (.primitive (~ (code.text class_name)))) @@ -1368,20 +1298,10 @@ (syntax: .public (synchronized [lock <code>.any body <code>.any]) - {#.doc (example "Evaluates body, while holding a lock on a given object." - (synchronized object_to_be_locked - (exec - (do something) - (dosomething else) - (finish the computation))))} (in (list (` ("jvm object synchronized" (~ lock) (~ body)))))) (syntax: .public (do_to [obj <code>.any methods (<>.some partial_call^)]) - {#.doc (example "Call a variety of methods on an object. Then, return the object." - (do_to object - (ClassName::method1 arg0 arg1 arg2) - (ClassName::method2 arg3 arg4 arg5)))} (with_identifiers [g!obj] (in (list (` (let [(~ g!obj) (~ obj)] (exec (~+ (list\map (complete_call$ g!obj) methods)) @@ -1753,57 +1673,6 @@ (syntax: .public (import: [declaration ..declaration^ .let [[class_name class_type_vars] (parser.declaration declaration)] bundles (<>.some (..bundle class_type_vars))]) - {#.doc (example "Allows importing JVM classes, and using them as types." - "Their methods, fields and enum options can also be imported." - (import: java/lang/Object - ["#::." - (new []) - (equals [java/lang/Object] boolean) - (wait [int] #io #try void)]) - - "Special options can also be given for the return values." - "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." - "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." - "#io means the computation has side effects, and will be wrapped by the IO type." - "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." - (import: java/lang/String - ["#::." - (new [[byte]]) - (#static valueOf [char] java/lang/String) - (#static valueOf #as int_valueOf [int] java/lang/String)]) - - (import: (java/util/List e) - ["#::." - (size [] int) - (get [int] e)]) - - (import: (java/util/ArrayList a) - ["#::." - ([T] toArray [[T]] [T])]) - - "The class-type that is generated is of the fully-qualified name." - "This avoids a clash between the java.util.List type, and Lux's own List type." - "All enum options to be imported must be specified." - (import: java/lang/Character$UnicodeScript - ["#::." - (#enum ARABIC CYRILLIC LATIN)]) - - "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars." - "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." - (import: (lux/concurrency/async/JvmAsync A) - ["#::." - (resolve [A] boolean) - (poll [] A) - (wasResolved [] boolean) - (waitOn [lux/Function] void) - (#static [A] make [A] (lux/concurrency/async/JvmAsync A))]) - - "Also, the names of the imported members will look like Class::member" - (java/lang/Object::new []) - (java/lang/Object::equals [other_object] my_object) - (java/util/List::size [] my_list) - java/lang/Character$UnicodeScript::LATIN - )} (do {! meta.monad} [kind (class_kind declaration) =members (|> bundles @@ -1815,13 +1684,11 @@ (syntax: .public (array [type (..type^ (list)) size <code>.any]) - {#.doc (example "Create an array of the given type, with the given size." - (array java/lang/Object 10))} - (let [g!size (` (|> (~ size) - (.: .Nat) - (.:as (.primitive (~ (code.text box.long)))) - "jvm object cast" - "jvm conversion long-to-int"))] + (let [g!size (` (|> (~ size) + (.: .Nat) + (.:as (.primitive (~ (code.text box.long)))) + "jvm object cast" + "jvm conversion long-to-int"))] (`` (cond (~~ (template [<primitive> <array_op>] [(\ type.equivalence = <primitive> type) (in (list (` (<array_op> (~ g!size)))))] @@ -1934,8 +1801,6 @@ <failure>)))) (syntax: .public (length [array <code>.any]) - {#.doc (example "Gives the length of an array." - (length my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -1971,8 +1836,6 @@ (syntax: .public (read! [idx <code>.any array <code>.any]) - {#.doc (example "Loads an element from an array." - (read! 10 my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -2011,8 +1874,6 @@ (syntax: .public (write! [idx <code>.any value <code>.any array <code>.any]) - {#.doc (example "Stores an element into an array." - (write! 10 my_object my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -2050,8 +1911,6 @@ (..write! (~ idx) (~ value) (~ g!array))))))))) (syntax: .public (class_for [type (..type^ (list))]) - {#.doc (example "Loads the class as a java.lang.Class object." - (class_for java/lang/String))} (in (list (` ("jvm object class" (~ (code.text (..reflection type)))))))) (syntax: .public (type [type (..type^ (list))]) diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index 0bb32e7f8..c4d8e1298 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -337,8 +337,8 @@ (: ..Function (lambda [left right] (do_something (:as Foo left) (:as Bar right)))))} - (.:as ..Function - (`` ("python function" - (~~ (template.amount <inputs>)) - (.function (_ [<inputs>]) - <output>))))) + [(.:as ..Function + (`` ("python function" + (~~ (template.amount <inputs>)) + (.function (_ [<inputs>]) + <output>))))]) diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index 3bb42e75f..87e80b27b 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -30,18 +30,6 @@ (syntax: .public (program: [args ..arguments^ body <code>.any]) - {#.doc (example "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)." - "Can take a list of all the input parameters to the program." - "Or, can destructure them using CLI-option combinators from the library/lux/control/parser/cli module." - (program: all_arguments - (do io.monad - [foo (initialize program)] - (do_something_with all_arguments))) - - (program: [config configuration_parser] - (do io.monad - [data (initialize program with config)] - (do_something_with data))))} (with_identifiers [g!program g!args g!_ g!output g!message] (let [initialization+event_loop (` ((~! do) (~! io.monad) 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 a615c00ef..39082e826 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 @@ -160,7 +160,7 @@ (^ (/.function/apply [abstraction arguments])) (do {! maybe.monad} - [arguments' (monad.map maybe.monad (recur false) arguments)] + [arguments' (monad.map ! (recur false) arguments)] (with_expansions [<application> (as_is (do ! [abstraction' (recur false abstraction)] (in (/.function/apply [abstraction' arguments']))))] @@ -176,6 +176,25 @@ _ <application>))) + ... TODO: Stop relying on this custom code. + (^ (#/.Extension ["lux syntax char case!" (list& input else matches)])) + (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) + else (recur return? else)] + (in (#/.Extension ["lux syntax char case!" (list& input else matches)]))) + (#/.Extension [name args]) (|> args (monad.map maybe.monad (recur false)) diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 05925b4e8..2a8dd0951 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -82,7 +82,7 @@ (def: (un_rooted fs path) (All [!] (-> (System !) Path (Maybe [Path Text]))) (let [/ (\ fs separator)] - (case (text.last_index_of / path) + (case (text.last_index / path) #.None #.None diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 51849d1af..832c5a094 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -89,37 +89,37 @@ (let [full (\ /.monoid compose inner outer)] (and (/.contains? inner full) (/.contains? outer full)))) - (_.cover [/.index_of] - (and (|> (/.index_of inner (\ /.monoid compose inner outer)) + (_.cover [/.index] + (and (|> (/.index inner (\ /.monoid compose inner outer)) (maybe.else fake_index) (n.= 0)) - (|> (/.index_of outer (\ /.monoid compose inner outer)) + (|> (/.index outer (\ /.monoid compose inner outer)) (maybe.else fake_index) (n.= 1)))) - (_.cover [/.index_of'] + (_.cover [/.index'] (let [full (\ /.monoid compose inner outer)] - (and (|> (/.index_of' 0 inner full) + (and (|> (/.index' 0 inner full) (maybe.else fake_index) (n.= 0)) - (|> (/.index_of' 1 inner full) + (|> (/.index' 1 inner full) (maybe.else fake_index) (n.= fake_index)) - (|> (/.index_of' 0 outer full) + (|> (/.index' 0 outer full) (maybe.else fake_index) (n.= 1)) - (|> (/.index_of' 1 outer full) + (|> (/.index' 1 outer full) (maybe.else fake_index) (n.= 1)) - (|> (/.index_of' 2 outer full) + (|> (/.index' 2 outer full) (maybe.else fake_index) (n.= fake_index))))) - (_.cover [/.last_index_of] + (_.cover [/.last_index] (let [full ($_ (\ /.monoid compose) outer inner outer)] - (and (|> (/.last_index_of inner full) + (and (|> (/.last_index inner full) (maybe.else fake_index) (n.= 1)) - (|> (/.last_index_of outer full) + (|> (/.last_index outer full) (maybe.else fake_index) (n.= 2))))) ))) @@ -153,7 +153,7 @@ (_.cover [/.char] (case (/.char expected sample) (#.Some char) - (case (/.index_of (/.of_char char) sample) + (case (/.index (/.of_char char) sample) (#.Some actual) (n.= expected actual) |