From 2d125c27e1ceb0adc14fd82f6984b70a12eda650 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 28 Jul 2022 18:58:20 -0400 Subject: Extracted test-coverage machinery into its own module. --- stdlib/source/documentation/lux/debug.lux | 115 ++--- stdlib/source/documentation/lux/documentation.lux | 27 +- stdlib/source/documentation/lux/ffi.jvm.lux | 515 +++++++++++---------- stdlib/source/documentation/lux/math.lux | 27 +- stdlib/source/documentation/lux/math/infix.lux | 67 +-- stdlib/source/documentation/lux/math/logic.lux | 6 +- .../documentation/lux/math/logic/continuous.lux | 39 +- .../source/documentation/lux/math/logic/fuzzy.lux | 97 ++-- stdlib/source/documentation/lux/math/modular.lux | 79 ++-- stdlib/source/documentation/lux/math/modulus.lux | 45 +- stdlib/source/documentation/lux/math/number.lux | 59 +-- .../documentation/lux/math/number/complex.lux | 99 ++-- .../source/documentation/lux/math/number/frac.lux | 289 ++++++------ .../source/documentation/lux/math/number/i16.lux | 25 +- .../source/documentation/lux/math/number/i32.lux | 25 +- .../source/documentation/lux/math/number/i64.lux | 159 +++---- stdlib/source/documentation/lux/math/number/i8.lux | 25 +- .../source/documentation/lux/math/number/int.lux | 187 ++++---- .../source/documentation/lux/math/number/nat.lux | 109 ++--- .../source/documentation/lux/math/number/ratio.lux | 61 +-- .../source/documentation/lux/math/number/rev.lux | 147 +++--- stdlib/source/documentation/lux/math/random.lux | 221 ++++----- stdlib/source/library/lux/test.lux | 20 +- stdlib/source/library/lux/test/coverage.lux | 46 ++ stdlib/source/library/lux/test/unit.lux | 49 +- stdlib/source/test/lux/meta/target/python.lux | 6 +- 26 files changed, 1292 insertions(+), 1252 deletions(-) create mode 100644 stdlib/source/library/lux/test/coverage.lux (limited to 'stdlib') diff --git a/stdlib/source/documentation/lux/debug.lux b/stdlib/source/documentation/lux/debug.lux index 480af7a9e..b32c68fc7 100644 --- a/stdlib/source/documentation/lux/debug.lux +++ b/stdlib/source/documentation/lux/debug.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,65 +8,66 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.cannot_represent_value) - ($.definition /.type_hole) - ($.definition /.unknown_local_binding) +(def .public documentation + (.List $.Documentation) + (list ($.module /._ + "") - ($.definition /.inspection - "A best-effort attempt to generate a textual representation of a value, without knowing its type." - [(inspection value)]) + ($.definition /.cannot_represent_value) + ($.definition /.type_hole) + ($.definition /.unknown_local_binding) - ($.definition /.representation - "A best-effort attempt to generate a textual representation of a value, while knowing its type." - [(representation type value)]) + ($.definition /.inspection + "A best-effort attempt to generate a textual representation of a value, without knowing its type." + [(inspection value)]) - ($.definition /.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)]) + ($.definition /.representation + "A best-effort attempt to generate a textual representation of a value, while knowing its type." + [(representation type value)]) - ($.definition /.log! - "Prints/writes a message to standard output." - [(log! message)]) + ($.definition /.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)]) - ($.definition /.hole - (format "A typed 'hole'." - \n "Reveals the type expected of the expression that should go in the hole.") - [(is (-> Nat Text) - (function (_ number) - (hole))) - "=>" - .Text]) + ($.definition /.log! + "Prints/writes a message to standard output." + [(log! message)]) - ($.definition /.here - "Shows the names and values of local bindings available around the call to 'here'." - [(let [foo 123 - bar +456 - baz +789.0] - (is 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] - (is Any - (here [foo %.nat] baz))) - "=>" - "foo: 123" - "baz: +789.0" - []])] - [])) + ($.definition /.hole + (format "A typed 'hole'." + \n "Reveals the type expected of the expression that should go in the hole.") + [(is (-> Nat Text) + (function (_ number) + (hole))) + "=>" + .Text]) + + ($.definition /.here + "Shows the names and values of local bindings available around the call to 'here'." + [(let [foo 123 + bar +456 + baz +789.0] + (is 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] + (is Any + (here [foo %.nat] baz))) + "=>" + "foo: 123" + "baz: +789.0" + []]) + )) diff --git a/stdlib/source/documentation/lux/documentation.lux b/stdlib/source/documentation/lux/documentation.lux index 28034082e..2a65b298e 100644 --- a/stdlib/source/documentation/lux/documentation.lux +++ b/stdlib/source/documentation/lux/documentation.lux @@ -20,17 +20,18 @@ (/.definition /.definition) )] - (.def .public documentation - (.List /.Module) - (/.module /._ - "" - [ + (def .public documentation + (List /.Documentation) + (list (/.module /._ + "") - (/.definition /.module - "" - [(is (.List /.Module) - (module /._ - "" - [] - []))])] - []))) + + + (/.definition /.module + "" + [(is (.List /.Module) + (module /._ + "" + [] + []))]) + ))) diff --git a/stdlib/source/documentation/lux/ffi.jvm.lux b/stdlib/source/documentation/lux/ffi.jvm.lux index 376d9958d..52b551378 100644 --- a/stdlib/source/documentation/lux/ffi.jvm.lux +++ b/stdlib/source/documentation/lux/ffi.jvm.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except int char is as) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -11,259 +11,260 @@ [\\library ["[0]" /]]) -(`` (.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.Privacy) - ($.definition /.State) - ($.definition /.Inheritance) - ($.definition /.class_names_cannot_contain_periods) - ($.definition /.class_name_cannot_be_a_type_variable) - ($.definition /.cannot_convert_to_jvm_type) - ($.definition /.cannot_cast_to_non_object) - - (,, (with_template [] - [(`` ($.definition - (format "The type of a (boxed) " (,, (template.text [])) " object.")))] - - [/.Boolean] - [/.Byte] - [/.Short] - [/.Integer] - [/.Long] - [/.Float] - [/.Double] - [/.Character] - )) - - (,, (with_template [] - [(`` ($.definition - (format "The type of an (unboxed) " (,, (template.text [])) " value.")))] - - [/.boolean] - [/.byte] - [/.short] - [/.int] - [/.long] - [/.float] - [/.double] - [/.char] - )) - - (,, (with_template [ ] - [(`` ($.definition - "Type converter."))] - - [/.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] - )) - - ($.definition /.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 true) - (:= ::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 true) for modifying it." - "(::new! []) for calling the class's constructor." - "(::resolve! container [value]) for calling the 'resolve' method."]) - - ($.definition /.interface - "Allows defining JVM interfaces." - [(interface TestInterface - ([] foo [boolean String] void "throws" [Exception]))]) - - ($.definition /.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) - [])))]) - - ($.definition /.null - "The null pointer." - [(null)]) - - ($.definition /.null? - "Test for the null pointer." - [(= true - (null? (null)))] - [(= false - (null? "YOLO"))]) - - ($.definition /.??? - "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." - [(= (??? (is java/lang/String (null))) - {.#None})] - [(= (??? "YOLO") - {.#Some "YOLO"})]) - - ($.definition /.!!! - (format "Takes a (Maybe ObjectType) and returns a ObjectType." - \n "A .#None would get translated into a (null).") - [(= (null) - (!!! (??? (is java/lang/Thread (null)))))] - [(= "foo" - (!!! (??? "foo")))]) - - ($.definition /.as - (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 (as String "YOLO") - {.#Some value_as_string} - {.#None})]) - - ($.definition /.synchronized - "Evaluates body, while holding a lock on a given object." - [(synchronized object_to_be_locked - (exec - (do something) - (dosomething else) - (finish the computation)))]) - - ($.definition /.to - "Call a variety of methods on an object. Then, return the object." - [(to object - (ClassName::method1 arg0 arg1 arg2) - (ClassName::method2 arg3 arg4 arg5))]) - - ($.definition /.import - "Allows importing JVM classes, and using them as types." - ["Their methods, fields and enum options can also be imported." - (import java/lang/Object - "[1]::[0]" - (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 - "[1]::[0]" - (new [[byte]]) - ("static" valueOf [char] java/lang/String) - ("static" valueOf "as" int_valueOf [int] java/lang/String)) - - (import (java/util/List e) - "[1]::[0]" - (size [] int) - (get [int] e)) - - (import (java/util/ArrayList a) - "[1]::[0]" - ([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 - "[1]::[0]" - ("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) - "[1]::[0]" - (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]) - - ($.definition /.array - "Create an array of the given type, with the given size." - [(array java/lang/Object 10)]) - - ($.definition /.length - "Gives the length of an array." - [(length my_array)]) - - ($.definition /.read! - "Loads an element from an array." - [(read! 10 my_array)]) - - ($.definition /.write! - "Stores an element into an array." - [(write! 10 my_object my_array)]) - - ($.definition /.class_for - "Loads the class as a java.lang.Class object." - [(class_for java/lang/String)]) - - ($.definition /.type - "" - [(is Type - (type java/lang/String))]) - - ($.definition /.is - "" - [(is java/lang/Object - (is java/lang/String - ???))])] - []))) +(`` (def .public documentation + (List $.Documentation) + (list ($.module /._ + "") + + ($.definition /.Privacy) + ($.definition /.State) + ($.definition /.Inheritance) + ($.definition /.class_names_cannot_contain_periods) + ($.definition /.class_name_cannot_be_a_type_variable) + ($.definition /.cannot_convert_to_jvm_type) + ($.definition /.cannot_cast_to_non_object) + + (,, (with_template [] + [(`` ($.definition + (format "The type of a (boxed) " (,, (template.text [])) " object.")))] + + [/.Boolean] + [/.Byte] + [/.Short] + [/.Integer] + [/.Long] + [/.Float] + [/.Double] + [/.Character] + )) + + (,, (with_template [] + [(`` ($.definition + (format "The type of an (unboxed) " (,, (template.text [])) " value.")))] + + [/.boolean] + [/.byte] + [/.short] + [/.int] + [/.long] + [/.float] + [/.double] + [/.char] + )) + + (,, (with_template [ ] + [(`` ($.definition + "Type converter."))] + + [/.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] + )) + + ($.definition /.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 true) + (:= ::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 true) for modifying it." + "(::new! []) for calling the class's constructor." + "(::resolve! container [value]) for calling the 'resolve' method."]) + + ($.definition /.interface + "Allows defining JVM interfaces." + [(interface TestInterface + ([] foo [boolean String] void "throws" [Exception]))]) + + ($.definition /.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) + [])))]) + + ($.definition /.null + "The null pointer." + [(null)]) + + ($.definition /.null? + "Test for the null pointer." + [(= true + (null? (null)))] + [(= false + (null? "YOLO"))]) + + ($.definition /.??? + "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." + [(= (??? (is java/lang/String (null))) + {.#None})] + [(= (??? "YOLO") + {.#Some "YOLO"})]) + + ($.definition /.!!! + (format "Takes a (Maybe ObjectType) and returns a ObjectType." + \n "A .#None would get translated into a (null).") + [(= (null) + (!!! (??? (is java/lang/Thread (null)))))] + [(= "foo" + (!!! (??? "foo")))]) + + ($.definition /.as + (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 (as String "YOLO") + {.#Some value_as_string} + {.#None})]) + + ($.definition /.synchronized + "Evaluates body, while holding a lock on a given object." + [(synchronized object_to_be_locked + (exec + (do something) + (dosomething else) + (finish the computation)))]) + + ($.definition /.to + "Call a variety of methods on an object. Then, return the object." + [(to object + (ClassName::method1 arg0 arg1 arg2) + (ClassName::method2 arg3 arg4 arg5))]) + + ($.definition /.import + "Allows importing JVM classes, and using them as types." + ["Their methods, fields and enum options can also be imported." + (import java/lang/Object + "[1]::[0]" + (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 + "[1]::[0]" + (new [[byte]]) + ("static" valueOf [char] java/lang/String) + ("static" valueOf "as" int_valueOf [int] java/lang/String)) + + (import (java/util/List e) + "[1]::[0]" + (size [] int) + (get [int] e)) + + (import (java/util/ArrayList a) + "[1]::[0]" + ([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 + "[1]::[0]" + ("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) + "[1]::[0]" + (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]) + + ($.definition /.array + "Create an array of the given type, with the given size." + [(array java/lang/Object 10)]) + + ($.definition /.length + "Gives the length of an array." + [(length my_array)]) + + ($.definition /.read! + "Loads an element from an array." + [(read! 10 my_array)]) + + ($.definition /.write! + "Stores an element into an array." + [(write! 10 my_object my_array)]) + + ($.definition /.class_for + "Loads the class as a java.lang.Class object." + [(class_for java/lang/String)]) + + ($.definition /.type + "" + [(is Type + (type java/lang/String))]) + + ($.definition /.is + "" + [(is java/lang/Object + (is java/lang/String + ???))]) + ))) diff --git a/stdlib/source/documentation/lux/math.lux b/stdlib/source/documentation/lux/math.lux index 9453ec02d..7819d6779 100644 --- a/stdlib/source/documentation/lux/math.lux +++ b/stdlib/source/documentation/lux/math.lux @@ -6,7 +6,7 @@ [text ["%" \\format (.only format)]] [collection - ["[0]" list]]]]] + ["[0]" list (.use "[1]#[0]" monoid)]]]]] ["[0]" / ["[1][0]" infix] ["[1][0]" modulus] @@ -17,14 +17,17 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [] - [/infix.documentation - /modulus.documentation - /modular.documentation - /number.documentation - /logic.documentation - /random.documentation])) +(def .public documentation + (List $.Documentation) + (list.partial ($.module /._ + "") + + (all list#composite + /infix.documentation + /modulus.documentation + /modular.documentation + /number.documentation + /logic.documentation + /random.documentation + ) + )) diff --git a/stdlib/source/documentation/lux/math/infix.lux b/stdlib/source/documentation/lux/math/infix.lux index 0e7b51380..89731c8ab 100644 --- a/stdlib/source/documentation/lux/math/infix.lux +++ b/stdlib/source/documentation/lux/math/infix.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,35 +8,36 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.infix - (format "Infix math syntax." - \n "The rules for infix syntax are simple." - \n "If you want your binary function to work well with it." - \n "Then take the argument to the right (y) as your first argument," - \n "and take the argument to the left (x) as your second argument.") - ["Binary functions" - (infix [x * +10]) - "=>" - (* +10 x)] - ["Nested infix" - (infix [[x + y] * [x - y]]) - "=>" - (* (- y x) (+ y x))] - ["Unary functions" - (infix [sin [x + y]]) - "=>" - (sin (+ y x))] - ["Also works with logic" - (infix [[x < y] and [y < z]]) - "=>" - (and (< z y) - (< y x))] - ["Forms are left as-is" - (infix [(* 3 9) gcd 450]) - "=>" - (gcd 450 (* 3 9))])] - [])) +(def .public documentation + (List $.Documentation) + (list ($.module /._ + "") + + ($.definition /.infix + (format "Infix math syntax." + \n "The rules for infix syntax are simple." + \n "If you want your binary function to work well with it." + \n "Then take the argument to the right (y) as your first argument," + \n "and take the argument to the left (x) as your second argument.") + ["Binary functions" + (infix [x * +10]) + "=>" + (* +10 x)] + ["Nested infix" + (infix [[x + y] * [x - y]]) + "=>" + (* (- y x) (+ y x))] + ["Unary functions" + (infix [sin [x + y]]) + "=>" + (sin (+ y x))] + ["Also works with logic" + (infix [[x < y] and [y < z]]) + "=>" + (and (< z y) + (< y x))] + ["Forms are left as-is" + (infix [(* 3 9) gcd 450]) + "=>" + (gcd 450 (* 3 9))]) + )) diff --git a/stdlib/source/documentation/lux/math/logic.lux b/stdlib/source/documentation/lux/math/logic.lux index 105055859..982ddcd1a 100644 --- a/stdlib/source/documentation/lux/math/logic.lux +++ b/stdlib/source/documentation/lux/math/logic.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except char) + [lux (.except) ["$" documentation] [data [text @@ -11,8 +11,8 @@ ["[1][0]" continuous] ["[1][0]" fuzzy]]) -(.def .public documentation - (.List $.Module) +(def .public documentation + (List $.Documentation) (all list#composite /continuous.documentation /fuzzy.documentation diff --git a/stdlib/source/documentation/lux/math/logic/continuous.lux b/stdlib/source/documentation/lux/math/logic/continuous.lux index f134a7236..f6198bfeb 100644 --- a/stdlib/source/documentation/lux/math/logic/continuous.lux +++ b/stdlib/source/documentation/lux/math/logic/continuous.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,22 +8,23 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - (format "Continuous logic using Rev values." - \n "Continuous logic is logic in the interval [0,1] instead of just the binary #0 and #1 options." - \n "Because Rev is being used, the interval is actual [0,1).") - [($.definition /.false) - ($.definition /.true) - ($.definition /.or) - ($.definition /.disjunction) - ($.definition /.and) - ($.definition /.conjunction) - ($.definition /.not) - ($.definition /.=) +(def .public documentation + (.List $.Documentation) + (list ($.module /._ + (format "Continuous logic using Rev values." + \n "Continuous logic is logic in the interval [0,1] instead of just the binary #0 and #1 options." + \n "Because Rev is being used, the interval is actual [0,1).")) - ($.definition /.implies - "" - [(implies consequent antecedent)])] - [])) + ($.definition /.false) + ($.definition /.true) + ($.definition /.or) + ($.definition /.disjunction) + ($.definition /.and) + ($.definition /.conjunction) + ($.definition /.not) + ($.definition /.=) + + ($.definition /.implies + "" + [(implies consequent antecedent)]) + )) diff --git a/stdlib/source/documentation/lux/math/logic/fuzzy.lux b/stdlib/source/documentation/lux/math/logic/fuzzy.lux index 222e6b086..19e0d1ef0 100644 --- a/stdlib/source/documentation/lux/math/logic/fuzzy.lux +++ b/stdlib/source/documentation/lux/math/logic/fuzzy.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,50 +8,51 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "Fuzzy logic, implemented on top of the Rev type." - [($.definition /.functor) - ($.definition /.empty) - ($.definition /.full) - ($.definition /.union) - ($.definition /.intersection) - ($.definition /.complement) - ($.definition /.of_set) - - ($.definition (/.Fuzzy it) - "A fuzzy set.") - - ($.definition /.membership - "" - [(membership set elem)]) - - ($.definition /.difference - "" - [(difference sub base)]) - - ($.definition /.of_predicate - "" - [(of_predicate predicate)]) - - ($.definition /.predicate - "" - [(predicate treshold set)]) - - ($.definition /.gradient - "" - [(gradient from to)]) - - ($.definition /.triangle - "" - [(triangle bottom middle top)]) - - ($.definition /.trapezoid - "" - [(trapezoid bottom middle_bottom middle_top top)]) - - ($.definition /.cut - "" - [(cut treshold set)])] - [])) +(def .public documentation + (.List $.Documentation) + (list ($.module /._ + "Fuzzy logic, implemented on top of the Rev type.") + + ($.definition /.functor) + ($.definition /.empty) + ($.definition /.full) + ($.definition /.union) + ($.definition /.intersection) + ($.definition /.complement) + ($.definition /.of_set) + + ($.definition (/.Fuzzy it) + "A fuzzy set.") + + ($.definition /.membership + "" + [(membership set elem)]) + + ($.definition /.difference + "" + [(difference sub base)]) + + ($.definition /.of_predicate + "" + [(of_predicate predicate)]) + + ($.definition /.predicate + "" + [(predicate treshold set)]) + + ($.definition /.gradient + "" + [(gradient from to)]) + + ($.definition /.triangle + "" + [(triangle bottom middle top)]) + + ($.definition /.trapezoid + "" + [(trapezoid bottom middle_bottom middle_top top)]) + + ($.definition /.cut + "" + [(cut treshold set)]) + )) diff --git a/stdlib/source/documentation/lux/math/modular.lux b/stdlib/source/documentation/lux/math/modular.lux index e78063d0a..e084f6942 100644 --- a/stdlib/source/documentation/lux/math/modular.lux +++ b/stdlib/source/documentation/lux/math/modular.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,41 +8,42 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.modulus) - ($.definition /.value) - ($.definition /.incorrect_modulus) - ($.definition /.codec) - - ($.definition /.=) - ($.definition /.<) - ($.definition /.<=) - ($.definition /.>) - ($.definition /.>=) - - ($.definition /.equivalence) - ($.definition /.order) - - ($.definition /.+) - ($.definition /.-) - ($.definition /.*) - - ($.definition /.addition) - ($.definition /.multiplication) - ($.definition /.inverse) - ($.definition /.moduli_are_not_equal) - - ($.definition (/.Mod %) - "A number under a modulus.") - - ($.definition /.modular - "" - [(modular modulus value)]) - - ($.definition /.adapter - "" - [(adapter reference subject)])] - [])) +(def .public documentation + (List $.Documentation) + (list ($.module /._ + "") + + ($.definition /.modulus) + ($.definition /.value) + ($.definition /.incorrect_modulus) + ($.definition /.codec) + + ($.definition /.=) + ($.definition /.<) + ($.definition /.<=) + ($.definition /.>) + ($.definition /.>=) + + ($.definition /.equivalence) + ($.definition /.order) + + ($.definition /.+) + ($.definition /.-) + ($.definition /.*) + + ($.definition /.addition) + ($.definition /.multiplication) + ($.definition /.inverse) + ($.definition /.moduli_are_not_equal) + + ($.definition (/.Mod %) + "A number under a modulus.") + + ($.definition /.modular + "" + [(modular modulus value)]) + + ($.definition /.adapter + "" + [(adapter reference subject)]) + )) diff --git a/stdlib/source/documentation/lux/math/modulus.lux b/stdlib/source/documentation/lux/math/modulus.lux index 76e071559..d699b1a18 100644 --- a/stdlib/source/documentation/lux/math/modulus.lux +++ b/stdlib/source/documentation/lux/math/modulus.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,27 +8,28 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.zero_cannot_be_a_modulus) - ($.definition /.modulus) - ($.definition /.divisor) - ($.definition /.=) +(def .public documentation + (List $.Documentation) + (list ($.module /._ + "") - ($.definition (/.Modulus %) - (format "A number used as a modulus in modular arithmetic." - \n "It cannot be 0.")) + ($.definition /.zero_cannot_be_a_modulus) + ($.definition /.modulus) + ($.definition /.divisor) + ($.definition /.=) - ($.definition /.congruent? - "" - [(congruent? modulus reference subject)]) + ($.definition (/.Modulus %) + (format "A number used as a modulus in modular arithmetic." + \n "It cannot be 0.")) - ($.definition /.literal - "" - ["Success!" - (literal 123)] - ["Failure!" - (literal 0)])] - [])) + ($.definition /.congruent? + "" + [(congruent? modulus reference subject)]) + + ($.definition /.literal + "" + ["Success!" + (literal 123)] + ["Failure!" + (literal 0)]) + )) diff --git a/stdlib/source/documentation/lux/math/number.lux b/stdlib/source/documentation/lux/math/number.lux index a16b5a53c..f414ab616 100644 --- a/stdlib/source/documentation/lux/math/number.lux +++ b/stdlib/source/documentation/lux/math/number.lux @@ -1,10 +1,12 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) - ["%" \\format (.only format)]]]]] + ["%" \\format (.only format)]] + [collection + ["[0]" list (.use "[1]#[0]" monoid)]]]]] [\\library ["[0]" /]] ["[0]" / @@ -19,28 +21,33 @@ ["[1][0]" ratio] ["[1][0]" complex]]) -(`` (.def .public documentation - (.List $.Module) - ($.module /._ - "" - [(,, (with_template [ ] - [($.definition - (format "Given syntax for a " " number, generates a Nat, an Int, a Rev or a Frac.") - [] - ["Allows for the presence of commas (,) among the digits." - ])] +(`` (def .public documentation + (List $.Documentation) + (list.partial ($.module /._ + "") - [/.bin "binary" (bin "11001001") (bin "11,00,10,01")] - [/.oct "octal" (oct "615243") (oct "615,243")] - [/.hex "hexadecimal" (hex "deadBEEF") (hex "dead,BEEF")] - ))] - [/i8.documentation - /i16.documentation - /i32.documentation - /i64.documentation - /nat.documentation - /int.documentation - /rev.documentation - /frac.documentation - /ratio.documentation - /complex.documentation]))) + (,, (with_template [ ] + [($.definition + (format "Given syntax for a " " number, generates a Nat, an Int, a Rev or a Frac.") + [] + ["Allows for the presence of commas (,) among the digits." + ])] + + [/.bin "binary" (bin "11001001") (bin "11,00,10,01")] + [/.oct "octal" (oct "615243") (oct "615,243")] + [/.hex "hexadecimal" (hex "deadBEEF") (hex "dead,BEEF")] + )) + + (all list#composite + /i8.documentation + /i16.documentation + /i32.documentation + /i64.documentation + /nat.documentation + /int.documentation + /rev.documentation + /frac.documentation + /ratio.documentation + /complex.documentation + ) + ))) diff --git a/stdlib/source/documentation/lux/math/number/complex.lux b/stdlib/source/documentation/lux/math/number/complex.lux index b47992832..2df1f2a71 100644 --- a/stdlib/source/documentation/lux/math/number/complex.lux +++ b/stdlib/source/documentation/lux/math/number/complex.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,53 +8,54 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "Complex arithmetic." - [($.definition /.i) - ($.definition /.+one) - ($.definition /.-one) - ($.definition /.zero) - ($.definition /.not_a_number?) - ($.definition /.=) - ($.definition /.+) - ($.definition /.-) - ($.definition /.equivalence) - ($.definition /.opposite) - ($.definition /.signum) - ($.definition /.conjugate) - ($.definition /.*') - ($.definition /.*) - ($.definition /./) - ($.definition /./') - ($.definition /.%) - ($.definition /.cos) - ($.definition /.cosh) - ($.definition /.sin) - ($.definition /.sinh) - ($.definition /.tan) - ($.definition /.tanh) - ($.definition /.abs) - ($.definition /.exp) - ($.definition /.log) - ($.definition /.pow) - ($.definition /.pow') - ($.definition /.root_2) - ($.definition /.reciprocal) - ($.definition /.acos) - ($.definition /.asin) - ($.definition /.atan) - ($.definition /.argument) - ($.definition /.roots) - ($.definition /.approximately?) +(def .public documentation + (.List $.Documentation) + (list ($.module /._ + "Complex arithmetic.") - ($.definition /.Complex - "A complex number.") + ($.definition /.i) + ($.definition /.+one) + ($.definition /.-one) + ($.definition /.zero) + ($.definition /.not_a_number?) + ($.definition /.=) + ($.definition /.+) + ($.definition /.-) + ($.definition /.equivalence) + ($.definition /.opposite) + ($.definition /.signum) + ($.definition /.conjugate) + ($.definition /.*') + ($.definition /.*) + ($.definition /./) + ($.definition /./') + ($.definition /.%) + ($.definition /.cos) + ($.definition /.cosh) + ($.definition /.sin) + ($.definition /.sinh) + ($.definition /.tan) + ($.definition /.tanh) + ($.definition /.abs) + ($.definition /.exp) + ($.definition /.log) + ($.definition /.pow) + ($.definition /.pow') + ($.definition /.root_2) + ($.definition /.reciprocal) + ($.definition /.acos) + ($.definition /.asin) + ($.definition /.atan) + ($.definition /.argument) + ($.definition /.roots) + ($.definition /.approximately?) - ($.definition /.complex - "Complex literals." - [(complex real imaginary)] - ["The imaginary part can be omitted if it's +0.0." - (complex real)])] - [])) + ($.definition /.Complex + "A complex number.") + + ($.definition /.complex + "Complex literals." + [(complex real imaginary)] + ["The imaginary part can be omitted if it's +0.0." + (complex real)]) + )) diff --git a/stdlib/source/documentation/lux/math/number/frac.lux b/stdlib/source/documentation/lux/math/number/frac.lux index 67b334fd3..5094916d2 100644 --- a/stdlib/source/documentation/lux/math/number/frac.lux +++ b/stdlib/source/documentation/lux/math/number/frac.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,146 +8,147 @@ [\\library ["[0]" /]]) -(`` (.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.positive?) - ($.definition /.negative?) - ($.definition /.zero?) - ($.definition /.opposite) - ($.definition /.abs) - ($.definition /.signum) - ($.definition /.nat) - ($.definition /.int) - ($.definition /.rev) - ($.definition /.equivalence) - ($.definition /.order) - ($.definition /.smallest) - ($.definition /.biggest) - ($.definition /.addition) - ($.definition /.multiplication) - ($.definition /.minimum) - ($.definition /.maximum) - ($.definition /.number?) - ($.definition /.decimal) - ($.definition /.bits) - ($.definition /.of_bits) - ($.definition /.binary) - ($.definition /.octal) - ($.definition /.hex) - ($.definition /.hash) - - ($.definition /.cos) - ($.definition /.sin) - ($.definition /.tan) - ($.definition /.acos) - ($.definition /.asin) - ($.definition /.atan) - ($.definition /.exp) - ($.definition /.log) - ($.definition /.ceil) - ($.definition /.floor) - ($.definition /.root_2) - ($.definition /.root_3) - ($.definition /.round) - ($.definition /.factorial) - ($.definition /.hypotenuse) - ($.definition /.sinh) - ($.definition /.csch) - ($.definition /.cosh) - ($.definition /.sech) - ($.definition /.tanh) - ($.definition /.coth) - ($.definition /.asinh) - ($.definition /.acosh) - ($.definition /.atanh) - ($.definition /.acoth) - ($.definition /.asech) - ($.definition /.acsch) - - ($.definition /.= - "Frac(tion) equivalence." - [(= reference sample)]) - - ($.definition /.< - "Frac(tion) less-than." - [(< reference sample)]) - - ($.definition /.<= - "Frac(tion) less-than or equal." - [(<= reference sample)]) - - ($.definition /.> - "Frac(tion) greater-than." - [(> reference sample)]) - - ($.definition /.>= - "Frac(tion) greater-than or equal." - [(>= reference sample)]) - - (,, (with_template [ ] - [($.definition - )] - - [/.+ "Frac(tion) addition."] - [/.- "Frac(tion) substraction."] - [/.* "Frac(tion) multiplication."] - [/./ "Frac(tion) division."] - [/.% "Frac(tion) remainder."] - )) - - ($.definition /./% - "" - [(/% param subject)]) - - (,, (with_template [ ] - [($.definition - )] - - [/.min "Frac(tion) minimum."] - [/.max "Frac(tion) minimum."] - )) - - (,, (with_template [ ] - [($.definition - )] - - [/.not_a_number "Not a number."] - [/.positive_infinity "Positive infinity."] - [/.negative_infinity "Negative infinity."] - )) - - ($.definition /.not_a_number? - "Tests whether a frac is actually not-a-number." - [(not_a_number? it)]) - - ($.definition /.approximately? - "" - [(approximately? margin_of_error standard value)]) - - ($.definition /.mod - "" - [(mod divisor dividend)]) - - ($.definition /.e - "The base of the natural logarithm.") - - ($.definition /.pi - "The ratio of a circle's circumference to its diameter.") - - ($.definition /.tau - "The ratio of a circle's circumference to its radius.") - - ($.definition /.pow - "" - [(pow param subject)]) - - ($.definition /.atan_2 - "" - [(atan_2 x y)]) - - ($.definition /.log_by - "" - [(log_by base it)])] - []))) +(`` (def .public documentation + (.List $.Documentation) + (list ($.module /._ + "") + + ($.definition /.positive?) + ($.definition /.negative?) + ($.definition /.zero?) + ($.definition /.opposite) + ($.definition /.abs) + ($.definition /.signum) + ($.definition /.nat) + ($.definition /.int) + ($.definition /.rev) + ($.definition /.equivalence) + ($.definition /.order) + ($.definition /.smallest) + ($.definition /.biggest) + ($.definition /.addition) + ($.definition /.multiplication) + ($.definition /.minimum) + ($.definition /.maximum) + ($.definition /.number?) + ($.definition /.decimal) + ($.definition /.bits) + ($.definition /.of_bits) + ($.definition /.binary) + ($.definition /.octal) + ($.definition /.hex) + ($.definition /.hash) + + ($.definition /.cos) + ($.definition /.sin) + ($.definition /.tan) + ($.definition /.acos) + ($.definition /.asin) + ($.definition /.atan) + ($.definition /.exp) + ($.definition /.log) + ($.definition /.ceil) + ($.definition /.floor) + ($.definition /.root_2) + ($.definition /.root_3) + ($.definition /.round) + ($.definition /.factorial) + ($.definition /.hypotenuse) + ($.definition /.sinh) + ($.definition /.csch) + ($.definition /.cosh) + ($.definition /.sech) + ($.definition /.tanh) + ($.definition /.coth) + ($.definition /.asinh) + ($.definition /.acosh) + ($.definition /.atanh) + ($.definition /.acoth) + ($.definition /.asech) + ($.definition /.acsch) + + ($.definition /.= + "Frac(tion) equivalence." + [(= reference sample)]) + + ($.definition /.< + "Frac(tion) less-than." + [(< reference sample)]) + + ($.definition /.<= + "Frac(tion) less-than or equal." + [(<= reference sample)]) + + ($.definition /.> + "Frac(tion) greater-than." + [(> reference sample)]) + + ($.definition /.>= + "Frac(tion) greater-than or equal." + [(>= reference sample)]) + + (,, (with_template [ ] + [($.definition + )] + + [/.+ "Frac(tion) addition."] + [/.- "Frac(tion) substraction."] + [/.* "Frac(tion) multiplication."] + [/./ "Frac(tion) division."] + [/.% "Frac(tion) remainder."] + )) + + ($.definition /./% + "" + [(/% param subject)]) + + (,, (with_template [ ] + [($.definition + )] + + [/.min "Frac(tion) minimum."] + [/.max "Frac(tion) minimum."] + )) + + (,, (with_template [ ] + [($.definition + )] + + [/.not_a_number "Not a number."] + [/.positive_infinity "Positive infinity."] + [/.negative_infinity "Negative infinity."] + )) + + ($.definition /.not_a_number? + "Tests whether a frac is actually not-a-number." + [(not_a_number? it)]) + + ($.definition /.approximately? + "" + [(approximately? margin_of_error standard value)]) + + ($.definition /.mod + "" + [(mod divisor dividend)]) + + ($.definition /.e + "The base of the natural logarithm.") + + ($.definition /.pi + "The ratio of a circle's circumference to its diameter.") + + ($.definition /.tau + "The ratio of a circle's circumference to its radius.") + + ($.definition /.pow + "" + [(pow param subject)]) + + ($.definition /.atan_2 + "" + [(atan_2 x y)]) + + ($.definition /.log_by + "" + [(log_by base it)]) + ))) diff --git a/stdlib/source/documentation/lux/math/number/i16.lux b/stdlib/source/documentation/lux/math/number/i16.lux index 63a53e2f7..29ee5c5c7 100644 --- a/stdlib/source/documentation/lux/math/number/i16.lux +++ b/stdlib/source/documentation/lux/math/number/i16.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,15 +8,16 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.equivalence) - ($.definition /.width) - ($.definition /.i16) - ($.definition /.i64) +(def .public documentation + (List $.Documentation) + (list ($.module /._ + "") - ($.definition /.I16 - "A 16-bit integer.")] - [])) + ($.definition /.equivalence) + ($.definition /.width) + ($.definition /.i16) + ($.definition /.i64) + + ($.definition /.I16 + "A 16-bit integer.") + )) diff --git a/stdlib/source/documentation/lux/math/number/i32.lux b/stdlib/source/documentation/lux/math/number/i32.lux index a0f912eab..7415545e1 100644 --- a/stdlib/source/documentation/lux/math/number/i32.lux +++ b/stdlib/source/documentation/lux/math/number/i32.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,15 +8,16 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.equivalence) - ($.definition /.width) - ($.definition /.i32) - ($.definition /.i64) +(def .public documentation + (List $.Documentation) + (list ($.module /._ + "") - ($.definition /.I32 - "A 32-bit integer.")] - [])) + ($.definition /.equivalence) + ($.definition /.width) + ($.definition /.i32) + ($.definition /.i64) + + ($.definition /.I32 + "A 32-bit integer.") + )) diff --git a/stdlib/source/documentation/lux/math/number/i64.lux b/stdlib/source/documentation/lux/math/number/i64.lux index 2f7909ac2..644c6e7e3 100644 --- a/stdlib/source/documentation/lux/math/number/i64.lux +++ b/stdlib/source/documentation/lux/math/number/i64.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except or and not) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,81 +8,82 @@ [\\library ["[0]" /]]) -(`` (.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.bits_per_byte) - ($.definition /.bytes_per_i64) - ($.definition /.width) - ($.definition /.false) - ($.definition /.true) - ($.definition /.equivalence) - ($.definition /.hash) - ($.definition /.disjunction) - ($.definition /.conjunction) - ($.definition /.reversed) - ($.definition /.left_rotated) - ($.definition /.right_rotated) - - (,, (with_template [ ] - [($.definition - )] - - [/.or "Bitwise or."] - [/.xor "Bitwise xor."] - [/.and "Bitwise and."] - - [/.left_shifted "Bitwise left-shift."] - [/.right_shifted "Unsigned/logic bitwise right-shift."] - )) - - ($.definition /.Mask - "A pattern of bits that can be imposed on I64 values.") - - ($.definition /.bit - "A mask with only a specific bit set." - [(bit position)]) - - ($.definition /.sign - "A mask for the sign bit of ints.") - - ($.definition /.not - "Bitwise negation.") - - ($.definition /.mask - "Mask a block of bits of the specified size." - [(mask amount_of_bits)]) - - ($.definition /.ones - "Count the number of 1s in a bit-map." - [(ones it)]) - - (,, (with_template [ ] - [($.definition - )] - - [/.zero "Clear bit at the given index."] - [/.one "Set bit at given index."] - [/.flipped "Flip bit at given index."] - )) - - ($.definition /.one? - "" - [(one? index input)]) - - ($.definition /.zero? - "" - [(zero? index input)]) - - ($.definition /.region - "A mask for a block of bits of the given size, starting at the given offset." - [(region offset size)]) - - ($.definition (/.Sub width) - "A sub-space of I64 with a reduce amount of bits.") - - ($.definition /.sub - "Given a width in the interval (0,64), yields an implementation for integers of that width." - [(sub width)])] - []))) +(`` (def .public documentation + (List $.Documentation) + (list ($.module /._ + "") + + ($.definition /.bits_per_byte) + ($.definition /.bytes_per_i64) + ($.definition /.width) + ($.definition /.false) + ($.definition /.true) + ($.definition /.equivalence) + ($.definition /.hash) + ($.definition /.disjunction) + ($.definition /.conjunction) + ($.definition /.reversed) + ($.definition /.left_rotated) + ($.definition /.right_rotated) + + (,, (with_template [ ] + [($.definition + )] + + [/.or "Bitwise or."] + [/.xor "Bitwise xor."] + [/.and "Bitwise and."] + + [/.left_shifted "Bitwise left-shift."] + [/.right_shifted "Unsigned/logic bitwise right-shift."] + )) + + ($.definition /.Mask + "A pattern of bits that can be imposed on I64 values.") + + ($.definition /.bit + "A mask with only a specific bit set." + [(bit position)]) + + ($.definition /.sign + "A mask for the sign bit of ints.") + + ($.definition /.not + "Bitwise negation.") + + ($.definition /.mask + "Mask a block of bits of the specified size." + [(mask amount_of_bits)]) + + ($.definition /.ones + "Count the number of 1s in a bit-map." + [(ones it)]) + + (,, (with_template [ ] + [($.definition + )] + + [/.zero "Clear bit at the given index."] + [/.one "Set bit at given index."] + [/.flipped "Flip bit at given index."] + )) + + ($.definition /.one? + "" + [(one? index input)]) + + ($.definition /.zero? + "" + [(zero? index input)]) + + ($.definition /.region + "A mask for a block of bits of the given size, starting at the given offset." + [(region offset size)]) + + ($.definition (/.Sub width) + "A sub-space of I64 with a reduce amount of bits.") + + ($.definition /.sub + "Given a width in the interval (0,64), yields an implementation for integers of that width." + [(sub width)]) + ))) diff --git a/stdlib/source/documentation/lux/math/number/i8.lux b/stdlib/source/documentation/lux/math/number/i8.lux index f2bbc58f6..122c3030d 100644 --- a/stdlib/source/documentation/lux/math/number/i8.lux +++ b/stdlib/source/documentation/lux/math/number/i8.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,15 +8,16 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.equivalence) - ($.definition /.width) - ($.definition /.i8) - ($.definition /.i64) +(def .public documentation + (List $.Documentation) + (list ($.module /._ + "") - ($.definition /.I8 - "A 8-bit integer.")] - [])) + ($.definition /.equivalence) + ($.definition /.width) + ($.definition /.i8) + ($.definition /.i64) + + ($.definition /.I8 + "A 8-bit integer.") + )) diff --git a/stdlib/source/documentation/lux/math/number/int.lux b/stdlib/source/documentation/lux/math/number/int.lux index c70ddafad..f7805842d 100644 --- a/stdlib/source/documentation/lux/math/number/int.lux +++ b/stdlib/source/documentation/lux/math/number/int.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,95 +8,96 @@ [\\library ["[0]" /]]) -(`` (.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.positive?) - ($.definition /.negative?) - ($.definition /.zero?) - ($.definition /.even?) - ($.definition /.odd?) - ($.definition /.co_prime?) - ($.definition /.frac) - ($.definition /.equivalence) - ($.definition /.order) - ($.definition /.enum) - ($.definition /.interval) - ($.definition /.addition) - ($.definition /.multiplication) - ($.definition /.maximum) - ($.definition /.minimum) - ($.definition /.binary) - ($.definition /.octal) - ($.definition /.decimal) - ($.definition /.hex) - ($.definition /.hash) - - ($.definition /.= - "Int(eger) equivalence." - [(= reference sample)]) - - ($.definition /.< - "Int(eger) less-than." - [(< reference sample)]) - - ($.definition /.<= - "Int(eger) less-than or equal." - [(<= reference sample)]) - - ($.definition /.> - "Int(eger) greater-than." - [(> reference sample)]) - - ($.definition /.>= - "Int(eger) greater-than or equal." - [(>= reference sample)]) - - (,, (with_template [ ] - [($.definition - )] - - [/.min "Int(eger) minimum."] - [/.max "Int(eger) maximum."] - )) - - (,, (with_template [ ] - [($.definition - )] - - [/.+ "Int(eger) addition."] - [/.- "Int(eger) substraction."] - [/.* "Int(eger) multiplication."] - [/./ "Int(eger) division."] - [/.% "Int(eger) remainder."] - [/./% "Int(eger) [division remainder]."] - )) - - ($.definition /.opposite - "A value of equal magnitude and opposite sign.") - - ($.definition /.abs - "A value of equal magnitude and positive sign.") - - ($.definition /.signum - "A value (either -1, 0 or +0) which represents the sign.") - - ($.definition /.mod - (format "Integer modulo." - \n "Note: The modulo and the remainder are not the same.") - [(mod divisor dividend)]) - - ($.definition /.gcd - "Greatest Common Divisor.") - - ($.definition /.extended_gcd - "Extended euclidean algorithm.") - - ($.definition /.lcm - "Least Common Multiple.") - - ($.definition /.right_shifted - "Signed/arithmetic bitwise right-shift." - [(right_shifted parameter subject)])] - []))) +(`` (def .public documentation + (List $.Documentation) + (list ($.module /._ + "") + + ($.definition /.positive?) + ($.definition /.negative?) + ($.definition /.zero?) + ($.definition /.even?) + ($.definition /.odd?) + ($.definition /.co_prime?) + ($.definition /.frac) + ($.definition /.equivalence) + ($.definition /.order) + ($.definition /.enum) + ($.definition /.interval) + ($.definition /.addition) + ($.definition /.multiplication) + ($.definition /.maximum) + ($.definition /.minimum) + ($.definition /.binary) + ($.definition /.octal) + ($.definition /.decimal) + ($.definition /.hex) + ($.definition /.hash) + + ($.definition /.= + "Int(eger) equivalence." + [(= reference sample)]) + + ($.definition /.< + "Int(eger) less-than." + [(< reference sample)]) + + ($.definition /.<= + "Int(eger) less-than or equal." + [(<= reference sample)]) + + ($.definition /.> + "Int(eger) greater-than." + [(> reference sample)]) + + ($.definition /.>= + "Int(eger) greater-than or equal." + [(>= reference sample)]) + + (,, (with_template [ ] + [($.definition + )] + + [/.min "Int(eger) minimum."] + [/.max "Int(eger) maximum."] + )) + + (,, (with_template [ ] + [($.definition + )] + + [/.+ "Int(eger) addition."] + [/.- "Int(eger) substraction."] + [/.* "Int(eger) multiplication."] + [/./ "Int(eger) division."] + [/.% "Int(eger) remainder."] + [/./% "Int(eger) [division remainder]."] + )) + + ($.definition /.opposite + "A value of equal magnitude and opposite sign.") + + ($.definition /.abs + "A value of equal magnitude and positive sign.") + + ($.definition /.signum + "A value (either -1, 0 or +0) which represents the sign.") + + ($.definition /.mod + (format "Integer modulo." + \n "Note: The modulo and the remainder are not the same.") + [(mod divisor dividend)]) + + ($.definition /.gcd + "Greatest Common Divisor.") + + ($.definition /.extended_gcd + "Extended euclidean algorithm.") + + ($.definition /.lcm + "Least Common Multiple.") + + ($.definition /.right_shifted + "Signed/arithmetic bitwise right-shift." + [(right_shifted parameter subject)]) + ))) diff --git a/stdlib/source/documentation/lux/math/number/nat.lux b/stdlib/source/documentation/lux/math/number/nat.lux index 72e7773c3..677393fdd 100644 --- a/stdlib/source/documentation/lux/math/number/nat.lux +++ b/stdlib/source/documentation/lux/math/number/nat.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,56 +8,57 @@ [\\library ["[0]" /]]) -(`` (.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /.co_prime?) - ($.definition /.even?) - ($.definition /.odd?) - ($.definition /.frac) - ($.definition /.equivalence) - ($.definition /.order) - ($.definition /.enum) - ($.definition /.interval) - ($.definition /.addition) - ($.definition /.multiplication) - ($.definition /.minimum) - ($.definition /.maximum) - ($.definition /.binary) - ($.definition /.octal) - ($.definition /.hex) - ($.definition /.decimal) - ($.definition /.hash) - - (,, (with_template [ ] - [($.definition - )] - - [/.= "Nat(ural) equivalence."] - [/.+ "Nat(ural) addition."] - [/.- "Nat(ural) substraction."] - [/.< "Nat(ural) less-than."] - [/.<= "Nat(ural) less-than or equal."] - [/.> "Nat(ural) greater-than."] - [/.>= "Nat(ural) greater-than or equal."] - [/.* "Nat(ural) multiplication."] - [/./ "Nat(ural) division."] - [/./% "Nat(ural) [division remainder]."] - [/.% "Nat(ural) remainder."] - )) - - (,, (with_template [ ] - [($.definition - )] - - [/.min "Nat(ural) minimum."] - [/.max "Nat(ural) maximum."] - )) - - ($.definition /.gcd - "Greatest Common Divisor.") - - ($.definition /.lcm - "Least Common Multiple.")] - []))) +(`` (def .public documentation + (List $.Documentation) + (list ($.module /._ + "") + + ($.definition /.co_prime?) + ($.definition /.even?) + ($.definition /.odd?) + ($.definition /.frac) + ($.definition /.equivalence) + ($.definition /.order) + ($.definition /.enum) + ($.definition /.interval) + ($.definition /.addition) + ($.definition /.multiplication) + ($.definition /.minimum) + ($.definition /.maximum) + ($.definition /.binary) + ($.definition /.octal) + ($.definition /.hex) + ($.definition /.decimal) + ($.definition /.hash) + + (,, (with_template [ ] + [($.definition + )] + + [/.= "Nat(ural) equivalence."] + [/.+ "Nat(ural) addition."] + [/.- "Nat(ural) substraction."] + [/.< "Nat(ural) less-than."] + [/.<= "Nat(ural) less-than or equal."] + [/.> "Nat(ural) greater-than."] + [/.>= "Nat(ural) greater-than or equal."] + [/.* "Nat(ural) multiplication."] + [/./ "Nat(ural) division."] + [/./% "Nat(ural) [division remainder]."] + [/.% "Nat(ural) remainder."] + )) + + (,, (with_template [ ] + [($.definition + )] + + [/.min "Nat(ural) minimum."] + [/.max "Nat(ural) maximum."] + )) + + ($.definition /.gcd + "Greatest Common Divisor.") + + ($.definition /.lcm + "Least Common Multiple.") + ))) diff --git a/stdlib/source/documentation/lux/math/number/ratio.lux b/stdlib/source/documentation/lux/math/number/ratio.lux index 4857d55fe..e74805a90 100644 --- a/stdlib/source/documentation/lux/math/number/ratio.lux +++ b/stdlib/source/documentation/lux/math/number/ratio.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,34 +8,35 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "Rational numbers." - [($.definition /.nat) - ($.definition /.=) - ($.definition /.equivalence) - ($.definition /.<) - ($.definition /.<=) - ($.definition /.>) - ($.definition /.>=) - ($.definition /.order) - ($.definition /.+) - ($.definition /.-) - ($.definition /.*) - ($.definition /./) - ($.definition /.%) - ($.definition /.reciprocal) - ($.definition /.codec) - ($.definition /.addition) - ($.definition /.multiplication) +(def .public documentation + (List $.Documentation) + (list ($.module /._ + "Rational numbers.") - ($.definition /.Ratio - "An unsigned ratio of numbers.") + ($.definition /.nat) + ($.definition /.=) + ($.definition /.equivalence) + ($.definition /.<) + ($.definition /.<=) + ($.definition /.>) + ($.definition /.>=) + ($.definition /.order) + ($.definition /.+) + ($.definition /.-) + ($.definition /.*) + ($.definition /./) + ($.definition /.%) + ($.definition /.reciprocal) + ($.definition /.codec) + ($.definition /.addition) + ($.definition /.multiplication) - ($.definition /.ratio - "Rational literals." - [(ratio numerator denominator)] - ["The denominator can be omitted if it is 1." - (ratio numerator)])] - [])) + ($.definition /.Ratio + "An unsigned ratio of numbers.") + + ($.definition /.ratio + "Rational literals." + [(ratio numerator denominator)] + ["The denominator can be omitted if it is 1." + (ratio numerator)]) + )) diff --git a/stdlib/source/documentation/lux/math/number/rev.lux b/stdlib/source/documentation/lux/math/number/rev.lux index 0b629eb7d..323ccc467 100644 --- a/stdlib/source/documentation/lux/math/number/rev.lux +++ b/stdlib/source/documentation/lux/math/number/rev.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except private) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,87 +8,88 @@ [\\library ["[0]" /]]) -(`` (.def .public documentation - (.List $.Module) - ($.module /._ - "" - [($.definition /./1) - ($.definition /./2) - ($.definition /./4) - ($.definition /./8) - ($.definition /./16) - ($.definition /./32) - ($.definition /./64) - ($.definition /./128) - ($.definition /./256) - ($.definition /./512) - ($.definition /./1024) - ($.definition /./2048) - ($.definition /./4096) - ($.definition /./%) - ($.definition /.frac) - ($.definition /.equivalence) - ($.definition /.hash) - ($.definition /.order) - ($.definition /.enum) - ($.definition /.interval) - ($.definition /.addition) - ($.definition /.maximum) - ($.definition /.minimum) - ($.definition /.binary) - ($.definition /.octal) - ($.definition /.hex) - ($.definition /.decimal) +(`` (def .public documentation + (List $.Documentation) + (list ($.module /._ + "") - ($.definition /.= - "Rev(olution) equivalence." - [(= reference sample)]) + ($.definition /./1) + ($.definition /./2) + ($.definition /./4) + ($.definition /./8) + ($.definition /./16) + ($.definition /./32) + ($.definition /./64) + ($.definition /./128) + ($.definition /./256) + ($.definition /./512) + ($.definition /./1024) + ($.definition /./2048) + ($.definition /./4096) + ($.definition /./%) + ($.definition /.frac) + ($.definition /.equivalence) + ($.definition /.hash) + ($.definition /.order) + ($.definition /.enum) + ($.definition /.interval) + ($.definition /.addition) + ($.definition /.maximum) + ($.definition /.minimum) + ($.definition /.binary) + ($.definition /.octal) + ($.definition /.hex) + ($.definition /.decimal) - ($.definition /.< - "Rev(olution) less-than." - [(< reference sample)]) + ($.definition /.= + "Rev(olution) equivalence." + [(= reference sample)]) - ($.definition /.<= - "Rev(olution) less-than or equal." - [(<= reference sample)]) + ($.definition /.< + "Rev(olution) less-than." + [(< reference sample)]) - ($.definition /.> - "Rev(olution) greater-than." - [(> reference sample)]) + ($.definition /.<= + "Rev(olution) less-than or equal." + [(<= reference sample)]) - ($.definition /.>= - "Rev(olution) greater-than or equal." - [(>= reference sample)]) + ($.definition /.> + "Rev(olution) greater-than." + [(> reference sample)]) - (,, (with_template [ ] - [($.definition - )] + ($.definition /.>= + "Rev(olution) greater-than or equal." + [(>= reference sample)]) - [/.min "Rev(olution) minimum."] - [/.max "Rev(olution) maximum."] - )) + (,, (with_template [ ] + [($.definition + )] - (,, (with_template [ ] - [($.definition - )] + [/.min "Rev(olution) minimum."] + [/.max "Rev(olution) maximum."] + )) - [/.+ "Rev(olution) addition."] - [/.- "Rev(olution) substraction."] - [/.* "Rev(olution) multiplication."] - [/./ "Rev(olution) division."] - [/.% "Rev(olution) remainder."] - [/.ratio "Ratio between two rev(olution)s."] - )) + (,, (with_template [ ] + [($.definition + )] - ($.definition /.up - "" - [(up scale subject)]) + [/.+ "Rev(olution) addition."] + [/.- "Rev(olution) substraction."] + [/.* "Rev(olution) multiplication."] + [/./ "Rev(olution) division."] + [/.% "Rev(olution) remainder."] + [/.ratio "Ratio between two rev(olution)s."] + )) - ($.definition /.down - "" - [(down scale subject)]) + ($.definition /.up + "" + [(up scale subject)]) - ($.definition /.reciprocal - "Rev(olution) reciprocal of a Nat(ural)." - [(reciprocal numerator)])] - []))) + ($.definition /.down + "" + [(down scale subject)]) + + ($.definition /.reciprocal + "Rev(olution) reciprocal of a Nat(ural)." + [(reciprocal numerator)]) + ))) diff --git a/stdlib/source/documentation/lux/math/random.lux b/stdlib/source/documentation/lux/math/random.lux index 1ff5a15a2..d9c6ef729 100644 --- a/stdlib/source/documentation/lux/math/random.lux +++ b/stdlib/source/documentation/lux/math/random.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except or and nat int rev) + [lux (.except) ["$" documentation] [data ["[0]" text (.only \n) @@ -8,112 +8,113 @@ [\\library ["[0]" /]]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "Pseudo-random number generation (PRNG) algorithms." - [($.definition /.functor) - ($.definition /.apply) - ($.definition /.monad) - - ($.definition /.bit) - ($.definition /.i64) - ($.definition /.nat) - ($.definition /.int) - ($.definition /.rev) - ($.definition /.frac) - ($.definition /.char) - - ($.definition /.unicode) - ($.definition /.ascii) - ($.definition /.alphabetic) - ($.definition /.alpha_numeric) - ($.definition /.numeric) - ($.definition /.upper_case) - ($.definition /.lower_case) - - ($.definition /.ratio) - ($.definition /.complex) - - ($.definition /.maybe) - ($.definition /.list) - ($.definition /.sequence) - ($.definition /.array) - ($.definition /.queue) - ($.definition /.stack) - - ($.definition /.instant) - ($.definition /.date) - ($.definition /.time) - ($.definition /.duration) - ($.definition /.month) - ($.definition /.day) - - ($.definition /.PRNG - "An abstract way to represent any PRNG.") - - ($.definition (/.Random it) - "A producer of random values based on a PRNG.") - - ($.definition /.only - "Retries the generator until the output satisfies a predicate." - [(only pred gen)]) - - ($.definition /.one - "" - [(one check random)]) - - ($.definition /.refined - "Retries the generator until the output can be refined." - [(refined refiner gen)]) - - ($.definition /.safe_frac - "A number in the interval [0.0,1.0].") - - ($.definition /.text - "" - [(text char_gen size)]) - - ($.definition /.and - "Sequencing combinator." - [(and left right)]) - - ($.definition /.or - "Heterogeneous alternative combinator." - [(or left right)]) - - ($.definition /.either - "Homogeneous alternative combinator." - [(either left right)]) - - ($.definition /.rec - "A combinator for producing recursive random generators." - [(rec gen)]) - - ($.definition /.set - "" - [(set hash size value_gen)]) - - ($.definition /.dictionary - "" - [(dictionary hash size key_gen value_gen)]) - - ($.definition /.result - "" - [(result prng calc)]) - - ($.definition /.prng - "" - [(prng update return)]) - - ($.definition /.pcg_32 - (format "An implementation of the PCG32 algorithm." - \n "For more information, please see: http://www.pcg-random.org/")) - - ($.definition /.xoroshiro_128+ - (format "An implementation of the Xoroshiro128+ algorithm." - \n "For more information, please see: http://xoroshiro.di.unimi.it/")) - - ($.definition /.split_mix_64 - "An implementation of the SplitMix64 algorithm.")] - [])) +(def .public documentation + (List $.Documentation) + (list ($.module /._ + "Pseudo-random number generation (PRNG) algorithms.") + + ($.definition /.functor) + ($.definition /.apply) + ($.definition /.monad) + + ($.definition /.bit) + ($.definition /.i64) + ($.definition /.nat) + ($.definition /.int) + ($.definition /.rev) + ($.definition /.frac) + ($.definition /.char) + + ($.definition /.unicode) + ($.definition /.ascii) + ($.definition /.alphabetic) + ($.definition /.alpha_numeric) + ($.definition /.numeric) + ($.definition /.upper_case) + ($.definition /.lower_case) + + ($.definition /.ratio) + ($.definition /.complex) + + ($.definition /.maybe) + ($.definition /.list) + ($.definition /.sequence) + ($.definition /.array) + ($.definition /.queue) + ($.definition /.stack) + + ($.definition /.instant) + ($.definition /.date) + ($.definition /.time) + ($.definition /.duration) + ($.definition /.month) + ($.definition /.day) + + ($.definition /.PRNG + "An abstract way to represent any PRNG.") + + ($.definition (/.Random it) + "A producer of random values based on a PRNG.") + + ($.definition /.only + "Retries the generator until the output satisfies a predicate." + [(only pred gen)]) + + ($.definition /.one + "" + [(one check random)]) + + ($.definition /.refined + "Retries the generator until the output can be refined." + [(refined refiner gen)]) + + ($.definition /.safe_frac + "A number in the interval [0.0,1.0].") + + ($.definition /.text + "" + [(text char_gen size)]) + + ($.definition /.and + "Sequencing combinator." + [(and left right)]) + + ($.definition /.or + "Heterogeneous alternative combinator." + [(or left right)]) + + ($.definition /.either + "Homogeneous alternative combinator." + [(either left right)]) + + ($.definition /.rec + "A combinator for producing recursive random generators." + [(rec gen)]) + + ($.definition /.set + "" + [(set hash size value_gen)]) + + ($.definition /.dictionary + "" + [(dictionary hash size key_gen value_gen)]) + + ($.definition /.result + "" + [(result prng calc)]) + + ($.definition /.prng + "" + [(prng update return)]) + + ($.definition /.pcg_32 + (format "An implementation of the PCG32 algorithm." + \n "For more information, please see: http://www.pcg-random.org/")) + + ($.definition /.xoroshiro_128+ + (format "An implementation of the Xoroshiro128+ algorithm." + \n "For more information, please see: http://xoroshiro.di.unimi.it/")) + + ($.definition /.split_mix_64 + "An implementation of the SplitMix64 algorithm.") + )) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index eafb394a5..411c6c1c7 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -3,9 +3,8 @@ [lux (.except and for) ["[0]" debug] [abstract - ["[0]" monad (.only do)]] + [monad (.only do)]] [control - ["<>" parser] ["[0]" pipe] ["[0]" maybe] ["[0]" try] @@ -20,7 +19,7 @@ ["%" \\format (.only format)]] [collection ["[0]" list (.use "[1]#[0]" functor mix)] - ["[0]" set (.only Set)] + ["[0]" set] ["[0]" dictionary ["[1]" ordered (.only Dictionary)]]]] [math @@ -28,21 +27,22 @@ [number (.only hex) ["n" nat] ["f" frac]]] - ["[0]" meta (.only) + [meta ["@" target] ["[0]" symbol] - ["[0]" code (.only) + ["[0]" code ["<[1]>" \\parser]] - [macro (.only with_symbols) + [macro [syntax (.only syntax)]]] [world ["[0]" environment] ["[0]" console] [time - ["[0]" instant] - ["[0]" duration (.only Duration)]]]]] + [duration (.only Duration)] + ["[0]" instant]]]]] [/ - ["//" unit]]) + ["//" unit] + ["[0]" coverage (.only Coverage)]]) (type .public Test (Random //.Test)) @@ -134,7 +134,7 @@ (the //.#expected tally)) unexpected (set.difference (the //.#expected tally) (the //.#actual tally)) - report (is (-> //.Coverage Text) + report (is (-> Coverage Text) (|>> set.list (list.sorted (at symbol.order <)) (exception.listing %.symbol))) diff --git a/stdlib/source/library/lux/test/coverage.lux b/stdlib/source/library/lux/test/coverage.lux new file mode 100644 index 000000000..efc2644a6 --- /dev/null +++ b/stdlib/source/library/lux/test/coverage.lux @@ -0,0 +1,46 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)]] + [data + ["[0]" text (.only) + ["%" \\format]] + [collection + ["[0]" list (.use "[1]#[0]" mix functor)] + ["[0]" set (.only Set)]]] + ["[0]" meta (.only) + ["[0]" symbol] + ["[0]" code (.only) + ["<[1]>" \\parser]] + [macro + [syntax (.only syntax)]]]]]) + +(type .public Coverage + (Set Symbol)) + +(def .public of + (let [symbol (is (-> Symbol Code) + (function (_ symbol) + (` (is Symbol + [(, (code.text (symbol.module symbol))) + (, (code.text (symbol.short symbol)))]))))] + (syntax (_ [name .symbol]) + (do meta.monad + [_ (meta.export name)] + (in (list (symbol name))))))) + +(def separator + Text + (text.of_char 31)) + +(def .public encoded + (-> (List Text) Text) + (text.interposed ..separator)) + +(def .public (decoded module encoding) + (-> Text Text Coverage) + (|> encoding + (text.all_split_by ..separator) + (list#each (|>> [module])) + (set.of_list symbol.hash))) diff --git a/stdlib/source/library/lux/test/unit.lux b/stdlib/source/library/lux/test/unit.lux index 0077c18a9..0e90bb46c 100644 --- a/stdlib/source/library/lux/test/unit.lux +++ b/stdlib/source/library/lux/test/unit.lux @@ -22,10 +22,9 @@ ["[0]" code (.only) ["<[1]>" \\parser]] [macro - [syntax (.only syntax)]]]]]) - -(type .public Coverage - (Set Symbol)) + [syntax (.only syntax)]]]]] + [// + ["[0]" coverage (.only Coverage)]]) (type .public Tally (Record @@ -121,40 +120,6 @@ (%.Format Symbol) (|>> %.symbol (format ..clean_up_marker))) -(def .public reference - (let [symbol (is (-> Symbol Code) - (function (_ symbol) - (` (is Symbol - [(, (code.text (symbol.module symbol))) - (, (code.text (symbol.short symbol)))]))))] - (syntax (_ [name .symbol]) - (do meta.monad - [_ (meta.export name)] - (in (list (symbol name))))))) - -(def coverage_separator - Text - (text.of_char 31)) - -(def encoded_coverage - (-> (List Text) Text) - (list#mix (function (_ short aggregate) - (case aggregate - "" short - _ (format aggregate ..coverage_separator short))) - "")) - -(def (coverage_definitions module encoding) - (-> Text Text Coverage) - (loop (again [remaining encoding - output (set.of_list symbol.hash (list))]) - (case (text.split_by ..coverage_separator remaining) - {.#Some [head tail]} - (again tail (set.has [module head] output)) - - {.#None} - (set.has [module remaining] output)))) - (def .public (with_coverage coverage condition) (-> (List Symbol) Bit Test) (let [message (|> coverage @@ -170,7 +135,7 @@ (syntax (_ [coverage (.tuple (<>.many .any)) condition .any]) (let [coverage (list#each (function (_ definition) - (` (..reference (, definition)))) + (` (coverage.of (, definition)))) coverage)] (in (list (` (..with_coverage (is (.List .Symbol) (.list (,* coverage))) @@ -191,7 +156,7 @@ (syntax (_ [coverage (.tuple (<>.many .any)) test .any]) (let [coverage (list#each (function (_ definition) - (` (..reference (, definition)))) + (` (coverage.of (, definition)))) coverage)] (in (list (` (..for' (is (.List .Symbol) (.list (,* coverage))) @@ -199,7 +164,7 @@ (def .public (covering' module coverage test) (-> Text Text Test Test) - (let [coverage (..coverage_definitions module coverage)] + (let [coverage (coverage.decoded module coverage)] (|> (..context' module test) (async#each (function (_ [tally documentation]) [(revised #expected (set.union coverage) tally) @@ -219,5 +184,5 @@ {.#Item short aggregate} aggregate)) {.#End}) - ..encoded_coverage)]] + coverage.encoded)]] (in (list (` (..covering' (, (code.text module)) (, (code.text coverage)) (, test)))))))) diff --git a/stdlib/source/test/lux/meta/target/python.lux b/stdlib/source/test/lux/meta/target/python.lux index 8c553dc2d..4181f5f2e 100644 --- a/stdlib/source/test/lux/meta/target/python.lux +++ b/stdlib/source/test/lux/meta/target/python.lux @@ -5,14 +5,14 @@ ["[0]" ffi] [abstract [monad (.only do)] - ["[0]" predicate] [\\specification ["$[0]" equivalence] ["$[0]" hash]]] [control - ["[0]" function] ["[0]" maybe (.use "[1]#[0]" functor)] - ["[0]" try (.only Try) (.use "[1]#[0]" functor)]] + ["[0]" try (.only Try) (.use "[1]#[0]" functor)] + ["[0]" function (.only) + ["[0]" predicate]]] [data ["[0]" bit (.use "[1]#[0]" equivalence)] ["[0]" text (.use "[1]#[0]" equivalence) -- cgit v1.2.3