diff options
Diffstat (limited to 'stdlib/source/documentation/lux/data')
15 files changed, 1592 insertions, 0 deletions
diff --git a/stdlib/source/documentation/lux/data/binary.lux b/stdlib/source/documentation/lux/data/binary.lux new file mode 100644 index 000000000..c740e6660 --- /dev/null +++ b/stdlib/source/documentation/lux/data/binary.lux @@ -0,0 +1,91 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Binary + "A binary BLOB of data.") + +(documentation: /.empty + "A fresh/empty binary BLOB of the specified size." + [(empty size)]) + +(documentation: /.aggregate + "" + [(aggregate f init binary)]) + +(documentation: /.read/8! + "Read 1 byte (8 bits) at the given index." + [(read/8! index binary)]) + +(documentation: /.read/16! + "Read 2 bytes (16 bits) at the given index." + [(read/16! index binary)]) + +(documentation: /.read/32! + "Read 4 bytes (32 bits) at the given index." + [(read/32! index binary)]) + +(documentation: /.read/64! + "Read 8 bytes (64 bits) at the given index." + [(read/64! index binary)]) + +(documentation: /.write/8! + "Write 1 byte (8 bits) at the given index." + [(write/8! index value binary)]) + +(documentation: /.write/16! + "Write 2 bytes (16 bits) at the given index." + [(write/16! index value binary)]) + +(documentation: /.write/32! + "Write 4 bytes (32 bits) at the given index." + [(write/32! index value binary)]) + +(documentation: /.write/64! + "Write 8 bytes (64 bits) at the given index." + [(write/64! index value binary)]) + +(documentation: /.copy + "Mutates the target binary BLOB by copying bytes from the source BLOB to it." + [(copy bytes source_offset source target_offset target)]) + +(documentation: /.slice + "Yields a subset of the binary BLOB, so long as the specified range is valid." + [(slice offset length binary)]) + +(documentation: /.after + "Yields a binary BLOB with at most the specified number of bytes removed." + [(after bytes binary)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Binary + ..empty + ..aggregate + ..read/8! + ..read/16! + ..read/32! + ..read/64! + ..write/8! + ..write/16! + ..write/32! + ..write/64! + ..copy + ..slice + ..after + ($.default /.index_out_of_bounds) + ($.default /.slice_out_of_bounds) + ($.default /.size) + ($.default /.equivalence) + ($.default /.monoid)] + [])) diff --git a/stdlib/source/documentation/lux/data/bit.lux b/stdlib/source/documentation/lux/data/bit.lux new file mode 100644 index 000000000..e1379b85c --- /dev/null +++ b/stdlib/source/documentation/lux/data/bit.lux @@ -0,0 +1,31 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.complement + (format "Generates the complement of a predicate." + \n "That is a predicate that returns the oposite of the original predicate.")) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..complement + ($.default /.no) + ($.default /.yes) + ($.default /.off) + ($.default /.on) + ($.default /.equivalence) + ($.default /.hash) + ($.default /.disjunction) + ($.default /.conjunction) + ($.default /.codec)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection.lux b/stdlib/source/documentation/lux/data/collection.lux new file mode 100644 index 000000000..e96f59465 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection.lux @@ -0,0 +1,40 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list]]]]] + ["." / #_ + ["#." array] + ["#." bits] + ["#." dictionary] + ["#." list] + ["#." queue] + ["#." row] + ["#." sequence] + ... ["#." stack] + ... ["#." set + ... ["#/." multi] + ... ["#/." ordered]] + ... ["#." tree + ... ["#/." finger] + ... ["#/." zipper]] + ]) + +(.def: .public documentation + (.List $.Module) + (list.together + (list /array.documentation + /bits.documentation + /dictionary.documentation + /list.documentation + /queue.documentation + /row.documentation + /sequence.documentation + ... /stack.documentation + ... /set.documentation + ... /tree.documentation + ))) diff --git a/stdlib/source/documentation/lux/data/collection/array.lux b/stdlib/source/documentation/lux/data/collection/array.lux new file mode 100644 index 000000000..3bf22b587 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/array.lux @@ -0,0 +1,124 @@ +(.module: + [library + [lux (#- example list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Array + "Mutable arrays.") + +(documentation: /.empty + "An empty array of the specified size." + [(empty size)]) + +(documentation: /.size + "" + [(size array)]) + +(documentation: /.read! + "" + [(read! index array)]) + +(documentation: /.write! + "Mutate the array by writing a value to the specified index." + [(write! index value array)]) + +(documentation: /.delete! + "Mutate the array by deleting the value at the specified index." + [(delete! index array)]) + +(documentation: /.contains? + "" + [(contains? index array)]) + +(documentation: /.update! + "Mutate the array by updating the value at the specified index." + [(update! index transform array)]) + +(documentation: /.upsert! + (format "Mutate the array by updating the value at the specified index." + \n "If there is no value, update and write the default value given.") + [(upsert! index default transform array)]) + +(documentation: /.copy! + "Writes the contents of one array into the other." + [(copy! length src_start src_array dest_start dest_array)]) + +(documentation: /.occupancy + "Finds out how many cells in an array are occupied." + [(occupancy array)]) + +(documentation: /.vacancy + "Finds out how many cells in an array are vacant." + [(vacancy array)]) + +(documentation: /.filter! + "Delete every item of the array that fails to satisfy the predicate." + [(filter! p xs)]) + +(documentation: /.example + "Yields the first item in the array that satisfies the predicate." + [(example p xs)]) + +(documentation: /.example+ + "Just like 'example', but with access to the index of each value." + [(example+ p xs)]) + +(documentation: /.clone + "Yields a shallow clone of the array." + [(clone xs)]) + +(documentation: /.of_list + "" + [(of_list xs)]) + +(documentation: /.list + "Yields a list with every non-empty item in the array." + [(list array)]) + +(documentation: /.list' + "Like 'list', but uses the 'default' value when encountering an empty cell in the array." + [(list' default array)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Array + ..empty + ..size + ..read! + ..write! + ..delete! + ..contains? + ..update! + ..upsert! + ..copy! + ..occupancy + ..vacancy + ..filter! + ..example + ..example+ + ..clone + ..of_list + ..list + ..list' + ($.default /.type_name) + ($.default /.equivalence) + ($.default /.monoid) + ($.default /.functor) + ($.default /.fold) + ($.default /.every?) + ($.default /.any?)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/bits.lux b/stdlib/source/documentation/lux/data/collection/bits.lux new file mode 100644 index 000000000..f5fe95dc3 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/bits.lux @@ -0,0 +1,86 @@ +(.module: + [library + [lux (#- or and not) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Bits + "A bit-map.") + +(documentation: /.size + "Measures the size of a bit-map by counting all the 1s in the bit-map." + [(size bits)]) + +(documentation: /.capacity + "" + [(capacity bits)]) + +(documentation: /.bit + "" + [(bit index bits)]) + +(template [<name>] + [(documentation: <name> + "" + [(<name> index input)])] + + [/.one] + [/.zero] + [/.flipped] + ) + +(documentation: /.intersects? + "" + [(intersects? reference sample)]) + +(documentation: /.not + "" + [(not input)]) + +(template [<name>] + [(documentation: <name> + "" + [(<name> param subject)])] + + [/.and] + [/.or] + [/.xor] + ) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Bits + ..size + ..capacity + ..bit + + ..one + ..zero + ..flipped + + ..intersects? + ..not + + ..and + ..or + ..xor + + ($.default /.Chunk) + ($.default /.chunk_size) + ($.default /.empty) + ($.default /.empty?) + ($.default /.equivalence)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/dictionary.lux b/stdlib/source/documentation/lux/data/collection/dictionary.lux new file mode 100644 index 000000000..95d2f998a --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/dictionary.lux @@ -0,0 +1,107 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." ordered] + ["#." plist]]) + +(documentation: /.Dictionary + "A dictionary implemented as a Hash-Array Mapped Trie (HAMT).") + +(documentation: /.empty + "An empty dictionary." + [(empty key_hash)]) + +(documentation: /.has + "" + [(has key val dict)]) + +(documentation: /.lacks + "" + [(lacks key dict)]) + +(documentation: /.value + "" + [(value key dict)]) + +(documentation: /.key? + "" + [(key? dict key)]) + +(documentation: /.has' + "Only puts the KV-pair if the key is not already present." + [(has' key val dict)]) + +(documentation: /.revised + "Transforms the value located at key (if available), using the given function." + [(revised key f dict)]) + +(documentation: /.revised' + (format "Updates the value at the key; if it exists." + \n "Otherwise, puts a value by applying the function to a default.") + [(revised' key default f dict)]) + +(documentation: /.of_list + "" + [(of_list key_hash kvs)]) + +(documentation: /.merged + (format "Merges 2 dictionaries." + \n "If any collisions with keys occur, the values of dict2 will overwrite those of dict1.") + [(merged dict2 dict1)]) + +(documentation: /.merged_with + (format "Merges 2 dictionaries." + \n "If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1.") + [(merged_with f dict2 dict1)]) + +(documentation: /.re_bound + "If there is a value under 'from_key', remove 'from_key' and store the value under 'to_key'." + [(re_bound from_key to_key dict)]) + +(documentation: /.sub + "A sub-dictionary, with only the specified keys." + [(sub keys dict)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Dictionary + ..empty + ..has + ..lacks + ..value + ..key? + ..has' + ..revised + ..revised' + ..of_list + ..merged + ..merged_with + ..re_bound + ..sub + ($.default /.key_hash) + ($.default /.key_already_exists) + ($.default /.size) + ($.default /.empty?) + ($.default /.entries) + ($.default /.keys) + ($.default /.values) + ($.default /.equivalence) + ($.default /.functor)] + [/ordered.documentation + /plist.documentation])) diff --git a/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux b/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux new file mode 100644 index 000000000..adbb1303f --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux @@ -0,0 +1,84 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Dictionary + "A dictionary data-structure with ordered entries.") + +(documentation: /.empty + "An empty dictionary, employing the given order." + [(empty order)]) + +(documentation: /.value + "" + [(value key dict)]) + +(documentation: /.key? + "" + [(key? dict key)]) + +(template [<name>] + [(`` (documentation: <name> + (format "Yields value under the " (~~ (template.text [<name>])) "imum key.") + [(<name> dict)]))] + + [/.min] + [/.max] + ) + +(documentation: /.size + "" + [(size dict)]) + +(documentation: /.has + "" + [(has key value dict)]) + +(documentation: /.lacks + "" + [(lacks key dict)]) + +(documentation: /.revised + "" + [(revised key transform dict)]) + +(documentation: /.of_list + "" + [(of_list order list)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Dictionary + ..empty + ..value + ..key? + + ..min + ..max + + ..size + ..has + ..lacks + ..revised + ..of_list + ($.default /.empty?) + ($.default /.entries) + ($.default /.keys) + ($.default /.values) + ($.default /.equivalence)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/dictionary/plist.lux b/stdlib/source/documentation/lux/data/collection/dictionary/plist.lux new file mode 100644 index 000000000..2450cc9eb --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/dictionary/plist.lux @@ -0,0 +1,58 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.PList + (format "A property list." + \n "It's a simple dictionary-like structure with Text keys.")) + +(documentation: /.value + "" + [(value key properties)]) + +(documentation: /.contains? + "" + [(contains? key properties)]) + +(documentation: /.has + "" + [(has key val properties)]) + +(documentation: /.revised + "" + [(revised key f properties)]) + +(documentation: /.lacks + "" + [(lacks key properties)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..PList + ..value + ..contains? + ..has + ..revised + ..lacks + ($.default /.empty) + ($.default /.size) + ($.default /.empty?) + ($.default /.keys) + ($.default /.values) + ($.default /.equivalence)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/list.lux b/stdlib/source/documentation/lux/data/collection/list.lux new file mode 100644 index 000000000..1050ab7ce --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/list.lux @@ -0,0 +1,239 @@ +(.module: + [library + [lux (#- example) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.aggregates + "" + [(aggregates f init inputs)]) + +(documentation: /.reversed + "" + [(reversed xs)]) + +(documentation: /.only + "A list with only values that satisfy the predicate." + [(only keep? xs)]) + +(documentation: /.partition + "Divide the list into all elements that satisfy a predicate, and all elements that do not." + [(partition satisfies? list)]) + +(documentation: /.pairs + (format "Cut the list into pairs of 2." + \n "Caveat emptor: If the list has an un-even number of elements, the last one will be skipped.") + [(pairs xs)]) + +(template [<name>] + [(documentation: <name> + "" + [(<name> n xs)])] + + [/.first] + [/.after] + ) + +(template [<name>] + [(documentation: <name> + "" + [(<name> predicate xs)])] + + [/.while] + [/.until] + ) + +(documentation: /.split_at + "" + [(split_at n xs)]) + +(documentation: /.split_when + "Segment the list by using a predicate to tell when to cut." + [(split_when predicate xs)]) + +(documentation: /.sub + "Segment the list into sub-lists of (at most) the given size." + [(sub size list)]) + +(documentation: /.repeated + "A list of the value x, repeated n times." + [(repeated n x)]) + +(documentation: /.iterations + "Generates a list element by element until the function returns #.None." + [(iterations f x)]) + +(documentation: /.one + "" + [(one check xs)]) + +(documentation: /.all + "" + [(all check xs)]) + +(documentation: /.example + "Yields the first value in the list that satisfies the predicate." + [(example predicate xs)]) + +(documentation: /.interposed + "Puts a value between every two elements in the list." + [(interposed sep xs)]) + +(documentation: /.size + "" + [(size list)]) + +(template [<name>] + [(documentation: <name> + "" + [(<name> predicate items)])] + + [/.every?] + [/.any?] + ) + +(documentation: /.item + "Fetches the element at the specified index." + [(item i xs)]) + +(documentation: /.sorted + "A list ordered by a comparison function." + [(sorted < xs)]) + +(documentation: /.empty? + "" + [(empty? xs)]) + +(documentation: /.member? + "" + [(member? eq xs x)]) + +(template [<name> <doc>] + [(documentation: <name> + <doc> + [(<name> xs)])] + + [/.head "Yields the first element of a list."] + [/.tail "For a list of size N, yields the N-1 elements after the first one."] + ) + +(documentation: /.indices + "Produces all the valid indices for a given size." + [(indices size)]) + +(documentation: /.zipped + "Create list zippers with the specified number of input lists." + [(def: zipped/2 (zipped 2)) + (def: zipped/3 (zipped 3)) + (zipped/3 xs ys zs) + ((zipped 3) xs ys zs)]) + +(documentation: /.zipped_with + "Create list zippers with the specified number of input lists." + [(def: zipped_with/2 (zipped_with 2)) + (def: zipped_with/3 (zipped_with 3)) + (zipped_with/2 + xs ys) + ((zipped_with 2) + xs ys)]) + +(documentation: /.last + "" + [(last xs)]) + +(documentation: /.inits + (format "For a list of size N, yields the first N-1 elements." + \n "Will yield a #.None for empty lists.") + [(inits xs)]) + +(documentation: /.together + "The sequential combination of all the lists.") + +(documentation: /.with + "Enhances a monad with List functionality." + [(with monad)]) + +(documentation: /.lifted + "Wraps a monadic value with List machinery." + [(lifted monad)]) + +(documentation: /.enumeration + "Pairs every element in the list with its index, starting at 0." + [(enumeration xs)]) + +(documentation: /.when + "Can be used as a guard in (co)monadic be/do expressions." + [(do monad + [value (do_something 1 2 3) + /.when (passes_test? value)] + (do_something_else 4 5 6))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..aggregates + ..reversed + ..only + ..partition + ..pairs + + ..first + ..after + + ..while + ..until + + ..split_at + ..split_when + ..sub + ..repeated + ..iterations + ..one + ..all + ..example + ..interposed + ..size + + ..every? + ..any? + + ..item + ..sorted + ..empty? + ..member? + + ..head + ..tail + + ..indices + ..zipped + ..zipped_with + ..last + ..inits + ..together + ..with + ..lifted + ..enumeration + ..when + ($.default /.fold) + ($.default /.equivalence) + ($.default /.hash) + ($.default /.monoid) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.zipped/2) + ($.default /.zipped/3) + ($.default /.zipped_with/2) + ($.default /.zipped_with/3)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/queue.lux b/stdlib/source/documentation/lux/data/collection/queue.lux new file mode 100644 index 000000000..5b866fe90 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/queue.lux @@ -0,0 +1,62 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." priority]]) + +(documentation: /.Queue + "A first-in, first-out sequential data-structure.") + +(documentation: /.of_list + "" + [(of_list entries)]) + +(documentation: /.list + "" + [(list queue)]) + +(documentation: /.front + "Yields the first value in the queue, if any.") + +(documentation: /.member? + "" + [(member? equivalence queue member)]) + +(documentation: /.next + "" + [(next queue)]) + +(documentation: /.end + "" + [(end val queue)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Queue + ..of_list + ..list + ..front + ..member? + ..next + ..end + ($.default /.empty) + ($.default /.size) + ($.default /.empty?) + ($.default /.equivalence) + ($.default /.functor)] + [/priority.documentation])) diff --git a/stdlib/source/documentation/lux/data/collection/queue/priority.lux b/stdlib/source/documentation/lux/data/collection/queue/priority.lux new file mode 100644 index 000000000..e62869ecd --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/queue/priority.lux @@ -0,0 +1,41 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.member? + "" + [(member? equivalence queue member)]) + +(documentation: /.end + "" + [(end priority value queue)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..member? + ..end + ($.default /.Priority) + ($.default /.max) + ($.default /.min) + ($.default /.Queue) + ($.default /.empty) + ($.default /.front) + ($.default /.size) + ($.default /.next) + ($.default /.empty?)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/row.lux b/stdlib/source/documentation/lux/data/collection/row.lux new file mode 100644 index 000000000..e72e8974e --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/row.lux @@ -0,0 +1,86 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Row + "A sequential data-structure with fast random access.") + +(documentation: /.suffix + "" + [(suffix val row)]) + +(documentation: /.within_bounds? + "Determines whether the index is within the bounds of the row." + [(within_bounds? row idx)]) + +(documentation: /.item + "" + [(item idx row)]) + +(documentation: /.has + "" + [(has idx val row)]) + +(documentation: /.revised + "" + [(revised idx f row)]) + +(documentation: /.prefix + "" + [(prefix row)]) + +(documentation: /.list + "" + [(list row)]) + +(documentation: /.member? + "" + [(member? equivalence row val)]) + +(documentation: /.row + "Row literals." + [(: (Row Nat) + (row 12 34 56 78 90))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Row + ..suffix + ..within_bounds? + ..item + ..has + ..revised + ..prefix + ..list + ..member? + ..row + ($.default /.empty) + ($.default /.size) + ($.default /.index_out_of_bounds) + ($.default /.of_list) + ($.default /.empty?) + ($.default /.equivalence) + ($.default /.fold) + ($.default /.monoid) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.reversed) + ($.default /.every?) + ($.default /.any?)] + [])) diff --git a/stdlib/source/documentation/lux/data/collection/sequence.lux b/stdlib/source/documentation/lux/data/collection/sequence.lux new file mode 100644 index 000000000..64e976155 --- /dev/null +++ b/stdlib/source/documentation/lux/data/collection/sequence.lux @@ -0,0 +1,98 @@ +(.module: + [library + [lux (#- list) + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Sequence + "An infinite sequence of values.") + +(documentation: /.iterations + "A stateful way of infinitely calculating the values of a sequence." + [(iterations step init)]) + +(documentation: /.repeated + "Repeat a value forever." + [(repeated x)]) + +(documentation: /.cycle + (format "Go over the elements of a list forever." + \n "The list should not be empty.") + [(cycle [start next])]) + +(documentation: /.item + "" + [(item idx sequence)]) + +(template [<taker> <dropper>] + [(documentation: <taker> + "" + [(<taker> pred xs)]) + (documentation: <dropper> + "" + [(<dropper> pred xs)])] + + [/.while /.until] + [/.first /.after] + ) + +(template [<splitter>] + [(documentation: <splitter> + "" + [(<splitter> pred xs)])] + + [/.split_when] + [/.split_at] + ) + +(documentation: /.only + "A new sequence only with items that satisfy the predicate." + [(only predicate sequence)]) + +(documentation: /.partition + (format "Split a sequence in two based on a predicate." + \n "The left side contains all entries for which the predicate is #1." + \n "The right side contains all entries for which the predicate is #0.") + [(partition left? xs)]) + +(documentation: /.^sequence& + (format "Allows destructuring of sequences in pattern-matching expressions." + \n "Caveat emptor: Only use it for destructuring, and not for testing values within the sequences.") + [(let [(^sequence& x y z _tail) (some_sequence_func +1 +2 +3)] + (func x y z))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Sequence + ..iterations + ..repeated + ..cycle + ..item + + ..while ..until + ..first ..after + + ..split_when + ..split_at + + ..only + ..partition + ..^sequence& + ($.default /.head) + ($.default /.tail) + ($.default /.functor) + ($.default /.comonad)] + [])) diff --git a/stdlib/source/documentation/lux/data/color.lux b/stdlib/source/documentation/lux/data/color.lux new file mode 100644 index 000000000..96a44b6ed --- /dev/null +++ b/stdlib/source/documentation/lux/data/color.lux @@ -0,0 +1,126 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] + [\\library + ["." /]] + ["." / #_ + ["#." named]]) + +(documentation: /.RGB + "Red-Green-Blue color format.") + +(documentation: /.HSL + "Hue-Saturation-Lightness color format.") + +(documentation: /.CMYK + "Cyan-Magenta-Yellow-Key color format.") + +(documentation: /.HSB + "Hue-Saturation-Brightness color format.") + +(documentation: /.Color + "A color value, independent of color format.") + +(documentation: /.complement + "The opposite color." + [(complement color)]) + +(documentation: /.interpolated + "" + [(interpolated ratio end start)]) + +(template [<name>] + [(documentation: <name> + "" + [(<name> ratio color)])] + + [/.darker] + [/.brighter] + [/.saturated] + [/.un_saturated] + ) + +(syntax: (palette_documentation [[_ name] <code>.identifier]) + (in (list (code.text (format "A " (text.replaced "_" "-" name) " palette."))))) + +(documentation: /.analogous + (palette_documentation /.analogous) + [(analogous spread variations color)]) + +(documentation: /.monochromatic + (palette_documentation /.monochromatic) + [(monochromatic spread variations color)]) + +(documentation: /.Alpha + "The degree of transparency of a pigment.") + +(documentation: /.transparent + "The maximum degree of transparency.") + +(documentation: /.translucent + "The average degree of transparency.") + +(documentation: /.opaque + "The minimum degree of transparency.") + +(documentation: /.Pigment + "A color with some degree of transparency.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..RGB + ..HSL + ..CMYK + ..HSB + ..Color + ..complement + ..interpolated + + ..darker + ..brighter + ..saturated + ..un_saturated + + ..analogous + ..monochromatic + ..Alpha + ..transparent + ..translucent + ..opaque + ..Pigment + ($.default /.of_rgb) + ($.default /.rgb) + ($.default /.equivalence) + ($.default /.hash) + ($.default /.black) + ($.default /.white) + ($.default /.addition) + ($.default /.subtraction) + ($.default /.hsl) + ($.default /.of_hsl) + ($.default /.hsb) + ($.default /.of_hsb) + ($.default /.cmyk) + ($.default /.of_cmyk) + ($.default /.gray_scale) + ($.default /.triad) + ($.default /.clash) + ($.default /.split_complement) + ($.default /.square) + ($.default /.tetradic) + ($.default /.Spread) + ($.default /.Palette)] + [/named.documentation])) diff --git a/stdlib/source/documentation/lux/data/color/named.lux b/stdlib/source/documentation/lux/data/color/named.lux new file mode 100644 index 000000000..6f9a080eb --- /dev/null +++ b/stdlib/source/documentation/lux/data/color/named.lux @@ -0,0 +1,319 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]] + [math + [number + ["." nat ("#\." hex)]]]]] + [\\library + ["." / + ["/#" //]]]) + +(template [<name>] + [(documentation: <name> + (let [[red green blue] (//.rgb <name>) + [_ name] (name_of <name>)] + (format "R:" (nat\encode red) + " G:" (nat\encode green) + " B:" (nat\encode blue) + " | " (text.replaced "_" " " name))))] + + [/.alice_blue] + [/.antique_white] + [/.aqua] + [/.aquamarine] + [/.azure] + [/.beige] + [/.bisque] + [/.black] + [/.blanched_almond] + [/.blue] + [/.blue_violet] + [/.brown] + [/.burly_wood] + [/.cadet_blue] + [/.chartreuse] + [/.chocolate] + [/.coral] + [/.cornflower_blue] + [/.cornsilk] + [/.crimson] + [/.cyan] + [/.dark_blue] + [/.dark_cyan] + [/.dark_goldenrod] + [/.dark_gray] + [/.dark_green] + [/.dark_khaki] + [/.dark_magenta] + [/.dark_olive_green] + [/.dark_orange] + [/.dark_orchid] + [/.dark_red] + [/.dark_salmon] + [/.dark_sea_green] + [/.dark_slate_blue] + [/.dark_slate_gray] + [/.dark_turquoise] + [/.dark_violet] + [/.deep_pink] + [/.deep_sky_blue] + [/.dim_gray] + [/.dodger_blue] + [/.fire_brick] + [/.floral_white] + [/.forest_green] + [/.fuchsia] + [/.gainsboro] + [/.ghost_white] + [/.gold] + [/.goldenrod] + [/.gray] + [/.green] + [/.green_yellow] + [/.honey_dew] + [/.hot_pink] + [/.indian_red] + [/.indigo] + [/.ivory] + [/.khaki] + [/.lavender] + [/.lavender_blush] + [/.lawn_green] + [/.lemon_chiffon] + [/.light_blue] + [/.light_coral] + [/.light_cyan] + [/.light_goldenrod_yellow] + [/.light_gray] + [/.light_green] + [/.light_pink] + [/.light_salmon] + [/.light_sea_green] + [/.light_sky_blue] + [/.light_slate_gray] + [/.light_steel_blue] + [/.light_yellow] + [/.lime] + [/.lime_green] + [/.linen] + [/.magenta] + [/.maroon] + [/.medium_aquamarine] + [/.medium_blue] + [/.medium_orchid] + [/.medium_purple] + [/.medium_sea_green] + [/.medium_slate_blue] + [/.medium_spring_green] + [/.medium_turquoise] + [/.medium_violet_red] + [/.midnight_blue] + [/.mint_cream] + [/.misty_rose] + [/.moccasin] + [/.navajo_white] + [/.navy] + [/.old_lace] + [/.olive] + [/.olive_drab] + [/.orange] + [/.orange_red] + [/.orchid] + [/.pale_goldenrod] + [/.pale_green] + [/.pale_turquoise] + [/.pale_violet_red] + [/.papaya_whip] + [/.peach_puff] + [/.peru] + [/.pink] + [/.plum] + [/.powder_blue] + [/.purple] + [/.rebecca_purple] + [/.red] + [/.rosy_brown] + [/.royal_blue] + [/.saddle_brown] + [/.salmon] + [/.sandy_brown] + [/.sea_green] + [/.sea_shell] + [/.sienna] + [/.silver] + [/.sky_blue] + [/.slate_blue] + [/.slate_gray] + [/.snow] + [/.spring_green] + [/.steel_blue] + [/.tan] + [/.teal] + [/.thistle] + [/.tomato] + [/.turquoise] + [/.violet] + [/.wheat] + [/.white] + [/.white_smoke] + [/.yellow] + [/.yellow_green] + ) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..alice_blue + ..antique_white + ..aqua + ..aquamarine + ..azure + ..beige + ..bisque + ..black + ..blanched_almond + ..blue + ..blue_violet + ..brown + ..burly_wood + ..cadet_blue + ..chartreuse + ..chocolate + ..coral + ..cornflower_blue + ..cornsilk + ..crimson + ..cyan + ..dark_blue + ..dark_cyan + ..dark_goldenrod + ..dark_gray + ..dark_green + ..dark_khaki + ..dark_magenta + ..dark_olive_green + ..dark_orange + ..dark_orchid + ..dark_red + ..dark_salmon + ..dark_sea_green + ..dark_slate_blue + ..dark_slate_gray + ..dark_turquoise + ..dark_violet + ..deep_pink + ..deep_sky_blue + ..dim_gray + ..dodger_blue + ..fire_brick + ..floral_white + ..forest_green + ..fuchsia + ..gainsboro + ..ghost_white + ..gold + ..goldenrod + ..gray + ..green + ..green_yellow + ..honey_dew + ..hot_pink + ..indian_red + ..indigo + ..ivory + ..khaki + ..lavender + ..lavender_blush + ..lawn_green + ..lemon_chiffon + ..light_blue + ..light_coral + ..light_cyan + ..light_goldenrod_yellow + ..light_gray + ..light_green + ..light_pink + ..light_salmon + ..light_sea_green + ..light_sky_blue + ..light_slate_gray + ..light_steel_blue + ..light_yellow + ..lime + ..lime_green + ..linen + ..magenta + ..maroon + ..medium_aquamarine + ..medium_blue + ..medium_orchid + ..medium_purple + ..medium_sea_green + ..medium_slate_blue + ..medium_spring_green + ..medium_turquoise + ..medium_violet_red + ..midnight_blue + ..mint_cream + ..misty_rose + ..moccasin + ..navajo_white + ..navy + ..old_lace + ..olive + ..olive_drab + ..orange + ..orange_red + ..orchid + ..pale_goldenrod + ..pale_green + ..pale_turquoise + ..pale_violet_red + ..papaya_whip + ..peach_puff + ..peru + ..pink + ..plum + ..powder_blue + ..purple + ..rebecca_purple + ..red + ..rosy_brown + ..royal_blue + ..saddle_brown + ..salmon + ..sandy_brown + ..sea_green + ..sea_shell + ..sienna + ..silver + ..sky_blue + ..slate_blue + ..slate_gray + ..snow + ..spring_green + ..steel_blue + ..tan + ..teal + ..thistle + ..tomato + ..turquoise + ..violet + ..wheat + ..white + ..white_smoke + ..yellow + ..yellow_green] + [])) |