From e853e9340d41724a86c9c0a837d86b2764bfcbab Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 30 Jun 2022 13:26:43 -0400 Subject: Better naming for measure/quantity types. --- stdlib/source/documentation/lux/debug.lux | 118 +++-- stdlib/source/documentation/lux/documentation.lux | 62 +-- stdlib/source/documentation/lux/extension.lux | 55 +- stdlib/source/documentation/lux/ffi.js.lux | 91 ++-- stdlib/source/documentation/lux/ffi.jvm.lux | 579 ++++++++++------------ stdlib/source/documentation/lux/ffi.lua.lux | 30 +- stdlib/source/documentation/lux/ffi.old.lux | 462 ++++++++--------- stdlib/source/documentation/lux/ffi.py.lux | 72 ++- stdlib/source/documentation/lux/ffi.rb.lux | 49 +- stdlib/source/documentation/lux/program.lux | 28 +- stdlib/source/documentation/lux/static.lux | 92 ++-- stdlib/source/documentation/lux/test.lux | 199 ++++---- stdlib/source/documentation/lux/type/unit.lux | 6 +- 13 files changed, 834 insertions(+), 1009 deletions(-) (limited to 'stdlib/source/documentation') diff --git a/stdlib/source/documentation/lux/debug.lux b/stdlib/source/documentation/lux/debug.lux index 5a60f7012..b560b35fe 100644 --- a/stdlib/source/documentation/lux/debug.lux +++ b/stdlib/source/documentation/lux/debug.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except private) - ["$" documentation (.only documentation:)] + ["$" documentation] [data ["[0]" text (.only \n) ["%" \\format (.only format)]]] @@ -10,71 +10,65 @@ [\\library ["[0]" /]]) -(documentation: /.inspection - "A best-effort attempt to generate a textual representation of a value, without knowing its type." - [(inspection value)]) +(.def .public documentation + (.List $.Module) + ($.module /._ + "" + [($.default /.cannot_represent_value) + ($.default /.type_hole) + ($.default /.unknown_local_binding) -(documentation: /.representation - "A best-effort attempt to generate a textual representation of a value, while knowing its type." - [(representation type value)]) + ($.documentation /.inspection + "A best-effort attempt to generate a textual representation of a value, without knowing its type." + [(inspection value)]) -(documentation: /.private - "Allows access to un-exported definitions in other modules." - ["Module A" - (def .private (secret_definition input) - (-> ??? ???) - (foo (bar (baz input)))) - "Module B" - ((/.private secret_definition) my_input)]) + ($.documentation /.representation + "A best-effort attempt to generate a textual representation of a value, while knowing its type." + [(representation type value)]) -(documentation: /.log! - "Prints/writes a message to standard output." - [(log! message)]) + ($.documentation /.private + "Allows access to un-exported definitions in other modules." + ["Module A" + (def .private (secret_definition input) + (-> ??? ???) + (foo (bar (baz input)))) + "Module B" + ((/.private secret_definition) my_input)]) -(documentation: /.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]) + ($.documentation /.log! + "Prints/writes a message to standard output." + [(log! message)]) -(documentation: /.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" - []]) + ($.documentation /.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]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [..inspection - ..representation - ..private - ..log! - ..hole - ..here - ($.default /.cannot_represent_value) - ($.default /.type_hole) - ($.default /.unknown_local_binding)] + ($.documentation /.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 c720ae97a..bdebfab7e 100644 --- a/stdlib/source/documentation/lux/documentation.lux +++ b/stdlib/source/documentation/lux/documentation.lux @@ -9,41 +9,31 @@ [\\library ["[0]" /]]) -(/.documentation: /.default - "" - [(is /.Definition - (default ..definition))]) +(with_expansions [ (/.documentation /.default + "" + [(is /.Definition + (default ..definition))]) + (/.documentation /.documentation + "" + []) + (these (/.default /.unqualified_symbol) + (/.default /.Definition) + (/.default /.Module) + (/.default /.documentation) -(/.documentation: /.documentation: - "" - [(documentation: /.default - "" - [(is /.Definition - (default ..definition))])]) + + )] + (.def .public documentation + (.List /.Module) + (/.module /._ + "" + [ -(/.documentation: /.module - "" - [(is (.List /.Module) - (module /._ - "" - [..default - ..documentation: - ..module - (/.default /.unqualified_symbol) - (/.default /.Definition) - (/.default /.Module) - (/.default /.documentation)] - []))]) - -(.def .public documentation - (.List /.Module) - (/.module /._ - "" - [..default - ..documentation: - ..module - (/.default /.unqualified_symbol) - (/.default /.Definition) - (/.default /.Module) - (/.default /.documentation)] - [])) + (/.documentation /.module + "" + [(is (.List /.Module) + (module /._ + "" + [] + []))])] + []))) diff --git a/stdlib/source/documentation/lux/extension.lux b/stdlib/source/documentation/lux/extension.lux index 5dd79df31..729abbec5 100644 --- a/stdlib/source/documentation/lux/extension.lux +++ b/stdlib/source/documentation/lux/extension.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except) - ["$" documentation (.only documentation:)] + ["$" documentation] ["[0]" debug] [data [text @@ -12,8 +12,6 @@ ["[0]" template] ["[0]" code ["<[1]>" \\parser]]] - ["@" target - ["[0]" jvm]] [tool [compiler ["[0]" phase] @@ -24,38 +22,29 @@ [\\library ["[0]" /]]) -(documentation: /.analysis - "Mechanism for defining extensions to Lux's analysis/type-checking infrastructure." - [(analysis ("my analysis" self phase archive [pass_through .any]) - (phase archive pass_through))]) - -(documentation: /.synthesis - "Mechanism for defining extensions to Lux's synthesis/optimization infrastructure." - [(synthesis ("my synthesis" self phase archive [pass_through .any]) - (phase archive pass_through))]) - -(documentation: /.generation - "" - [(generation ("my generation" self phase archive [pass_through .any]) - (for @.jvm - (at phase.monad each (|>> {jvm.#Embedded} - sequence.sequence) - (phase archive pass_through)) - (phase archive pass_through)))]) - -(documentation: /.declaration - "" - [(declaration ("my declaration" self phase archive [parameters (<>.some .any)]) - (do phase.monad - [.let [_ (debug.log! (format "Successfully installed declaration " (%.text self) "!"))]] - (in declaration.no_requirements)))]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..analysis - ..synthesis - ..generation - ..declaration] + [($.documentation /.analysis + "Mechanism for defining extensions to Lux's analysis/type-checking infrastructure." + [(analysis ("my analysis" self phase archive [pass_through .any]) + (phase archive pass_through))]) + + ($.documentation /.synthesis + "Mechanism for defining extensions to Lux's synthesis/optimization infrastructure." + [(synthesis ("my synthesis" self phase archive [pass_through .any]) + (phase archive pass_through))]) + + ($.documentation /.generation + "" + [(generation ("my generation" self phase archive [pass_through .any]) + (phase archive pass_through))]) + + ($.documentation /.declaration + "" + [(declaration ("my declaration" self phase archive [parameters (<>.some .any)]) + (do phase.monad + [.let [_ (debug.log! (format "Successfully installed declaration " (%.text self) "!"))]] + (in declaration.no_requirements)))])] [])) diff --git a/stdlib/source/documentation/lux/ffi.js.lux b/stdlib/source/documentation/lux/ffi.js.lux index 6797208c8..71bf8062d 100644 --- a/stdlib/source/documentation/lux/ffi.js.lux +++ b/stdlib/source/documentation/lux/ffi.js.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except int char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data ["[0]" text (.only \n) ["%" \\format (.only format)]]] @@ -10,56 +10,11 @@ [\\library ["[0]" /]]) -(documentation: /.null - "The null pointer.") - -(documentation: /.import - "Easily import types, methods, functions and constants." - [(import Uint8Array - "[1]::[0]") - - (import TextEncoder - "[1]::[0]" - (new [/.String]) - (encode [/.String] Uint8Array)) - - (import TextDecoder - "[1]::[0]" - (new [/.String]) - (decode [/.String] String))]) - -(documentation: /.type_of - "The type of an object, as text." - [(= "boolean" - (type_of #1))] - [(= "number" - (type_of +123.456))] - [(= "string" - (type_of "789"))] - [(= "function" - (type_of (function (_ value) value)))]) - -(documentation: /.constant - "Allows using definitions from the JavaScript host platform." - [(constant .Frac [Math PI])]) - -(documentation: /.closure - (format "Allows defining closures/anonymous-functions in the form that JavaScript expects." - \n "This is useful for adapting Lux functions for usage by JavaScript code.") - [(is /.Function - (closure [left right] - (do_something (as Foo left) (as Bar right))))]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..null - ..import - ..type_of - ..constant - ..closure - ($.default (/.Object brand)) + [($.default (/.Object brand)) ($.default /.Function) ($.default /.Symbol) ($.default /.Null) @@ -70,5 +25,45 @@ ($.default /.null?) ($.default /.on_browser?) ($.default /.on_nashorn?) - ($.default /.on_node_js?)] + ($.default /.on_node_js?) + + ($.documentation /.null + "The null pointer.") + + ($.documentation /.import + "Easily import types, methods, functions and constants." + [(import Uint8Array + "[1]::[0]") + + (import TextEncoder + "[1]::[0]" + (new [/.String]) + (encode [/.String] Uint8Array)) + + (import TextDecoder + "[1]::[0]" + (new [/.String]) + (decode [/.String] String))]) + + ($.documentation /.type_of + "The type of an object, as text." + [(= "boolean" + (type_of #1))] + [(= "number" + (type_of +123.456))] + [(= "string" + (type_of "789"))] + [(= "function" + (type_of (function (_ value) value)))]) + + ($.documentation /.constant + "Allows using definitions from the JavaScript host platform." + [(constant .Frac [Math PI])]) + + ($.documentation /.closure + (format "Allows defining closures/anonymous-functions in the form that JavaScript expects." + \n "This is useful for adapting Lux functions for usage by JavaScript code.") + [(is /.Function + (closure [left right] + (do_something (as Foo left) (as Bar right))))])] [])) diff --git a/stdlib/source/documentation/lux/ffi.jvm.lux b/stdlib/source/documentation/lux/ffi.jvm.lux index da10cb3d6..436c252b6 100644 --- a/stdlib/source/documentation/lux/ffi.jvm.lux +++ b/stdlib/source/documentation/lux/ffi.jvm.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except int char is as) - ["$" documentation (.only documentation:)] + ["$" documentation] [data ["[0]" text (.only \n) ["%" \\format (.only format)]]] @@ -10,324 +10,259 @@ [\\library ["[0]" /]]) -(with_template [] - [(`` (documentation: - (format "The type of a (boxed) " (~~ (template.text [])) " object.")))] - - [/.Boolean] - [/.Byte] - [/.Short] - [/.Integer] - [/.Long] - [/.Float] - [/.Double] - [/.Character] - ) - -(with_template [] - [(`` (documentation: - (format "The type of an (unboxed) " (~~ (template.text [])) " value.")))] - - [/.boolean] - [/.byte] - [/.short] - [/.int] - [/.long] - [/.float] - [/.double] - [/.char] - ) - -(with_template [ ] - [(`` (documentation: - "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] - ) - -(documentation: /.class - "Allows defining JVM classes in Lux code." - [(class "final" (TestClass A) [Runnable] - ... Fields - ("private" foo boolean) - ("private" bar A) - ("private" baz java/lang/Object) - ... Methods - ("public" [] (new [value A]) [] - (exec - (:= ::foo #1) - (:= ::bar value) - (:= ::baz "") - [])) - ("public" (virtual) java/lang/Object - "") - ("public" "static" (static) java/lang/Object - "") - (Runnable [] (run) void - []) - ) - - "The tuple corresponds to parent interfaces." - "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." - "Fields and methods defined in the class can be used with special syntax." - "For example:" - "::resolved, for accessing the 'resolved' field." - "(:= ::resolved #1) for modifying it." - "(::new! []) for calling the class's constructor." - "(::resolve! container [value]) for calling the 'resolve' method."]) - -(documentation: /.interface - "Allows defining JVM interfaces." - [(interface TestInterface - ([] foo [boolean String] void "throws" [Exception]))]) - -(documentation: /.object - "Allows defining anonymous classes." - ["The 1st tuple corresponds to class-level type-variables." - "The 2nd tuple corresponds to parent interfaces." - "The 3rd tuple corresponds to arguments to the super class constructor." - "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." - (object [] [Runnable] - [] - (Runnable [] (run self) void - (exec - (do_something some_value) - [])))]) - -(documentation: /.null - "The null pointer." - [(null)]) - -(documentation: /.null? - "Test for the null pointer." - [(= true - (null? (null)))] - [(= false - (null? "YOLO"))]) - -(documentation: /.??? - "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." - [(= (??? (is java/lang/String (null))) - {.#None})] - [(= (??? "YOLO") - {.#Some "YOLO"})]) - -(documentation: /.!!! - (format "Takes a (Maybe ObjectType) and returns a ObjectType." - \n "A .#None would get translated into a (null).") - [(= (null) - (!!! (??? (is java/lang/Thread (null)))))] - [(= "foo" - (!!! (??? "foo")))]) - -(documentation: /.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})]) - -(documentation: /.synchronized - "Evaluates body, while holding a lock on a given object." - [(synchronized object_to_be_locked - (exec - (do something) - (dosomething else) - (finish the computation)))]) - -(documentation: /.do_to - "Call a variety of methods on an object. Then, return the object." - [(do_to object - (ClassName::method1 arg0 arg1 arg2) - (ClassName::method2 arg3 arg4 arg5))]) - -(documentation: /.import - "Allows importing JVM classes, and using them as types." - ["Their methods, fields and enum options can also be imported." - (import java/lang/Object - "[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]) - -(documentation: /.array - "Create an array of the given type, with the given size." - [(array java/lang/Object 10)]) - -(documentation: /.length - "Gives the length of an array." - [(length my_array)]) - -(documentation: /.read! - "Loads an element from an array." - [(read! 10 my_array)]) - -(documentation: /.write! - "Stores an element into an array." - [(write! 10 my_object my_array)]) - -(documentation: /.class_for - "Loads the class as a java.lang.Class object." - [(class_for java/lang/String)]) - -(documentation: /.type - "" - [(is Type - (type java/lang/String))]) - -(documentation: /.is - "" - [(is java/lang/Object - (is java/lang/String - ???))]) - -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [..Boolean - ..Byte - ..Short - ..Integer - ..Long - ..Float - ..Double - ..Character - - ..boolean - ..byte - ..short - ..int - ..long - ..float - ..double - ..char - - ..byte_to_long - ..short_to_long - ..double_to_int - ..double_to_long - ..double_to_float - ..float_to_int - ..float_to_long - ..float_to_double - ..int_to_byte - ..int_to_short - ..int_to_long - ..int_to_float - ..int_to_double - ..int_to_char - ..long_to_byte - ..long_to_short - ..long_to_int - ..long_to_float - ..long_to_double - ..char_to_byte - ..char_to_short - ..char_to_int - ..char_to_long - ..long_to_char - ..byte_to_int - ..short_to_int - ..byte_to_char - ..short_to_char - - ..class - ..interface - ..object - ..null - ..null? - ..??? - ..!!! - ..as - ..synchronized - ..do_to - ..import - ..array - ..length - ..read! - ..write! - ..class_for - ..type - ..is - ($.default /.Privacy) - ($.default /.State) - ($.default /.Inheritance) - ($.default /.class_names_cannot_contain_periods) - ($.default /.class_name_cannot_be_a_type_variable) - ($.default /.cannot_convert_to_jvm_type) - ($.default /.cannot_cast_to_non_object)] - [])) +(`` (.def .public documentation + (.List $.Module) + ($.module /._ + "" + [($.default /.Privacy) + ($.default /.State) + ($.default /.Inheritance) + ($.default /.class_names_cannot_contain_periods) + ($.default /.class_name_cannot_be_a_type_variable) + ($.default /.cannot_convert_to_jvm_type) + ($.default /.cannot_cast_to_non_object) + + (~~ (with_template [] + [(`` ($.documentation + (format "The type of a (boxed) " (~~ (template.text [])) " object.")))] + + [/.Boolean] + [/.Byte] + [/.Short] + [/.Integer] + [/.Long] + [/.Float] + [/.Double] + [/.Character] + )) + + (~~ (with_template [] + [(`` ($.documentation + (format "The type of an (unboxed) " (~~ (template.text [])) " value.")))] + + [/.boolean] + [/.byte] + [/.short] + [/.int] + [/.long] + [/.float] + [/.double] + [/.char] + )) + + (~~ (with_template [ ] + [(`` ($.documentation + "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] + )) + + ($.documentation /.class + "Allows defining JVM classes in Lux code." + [(class "final" (TestClass A) [Runnable] + ... Fields + ("private" foo boolean) + ("private" bar A) + ("private" baz java/lang/Object) + ... Methods + ("public" [] (new [value A]) [] + (exec + (:= ::foo #1) + (:= ::bar value) + (:= ::baz "") + [])) + ("public" (virtual) java/lang/Object + "") + ("public" "static" (static) java/lang/Object + "") + (Runnable [] (run) void + []) + ) + + "The tuple corresponds to parent interfaces." + "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." + "Fields and methods defined in the class can be used with special syntax." + "For example:" + "::resolved, for accessing the 'resolved' field." + "(:= ::resolved #1) for modifying it." + "(::new! []) for calling the class's constructor." + "(::resolve! container [value]) for calling the 'resolve' method."]) + + ($.documentation /.interface + "Allows defining JVM interfaces." + [(interface TestInterface + ([] foo [boolean String] void "throws" [Exception]))]) + + ($.documentation /.object + "Allows defining anonymous classes." + ["The 1st tuple corresponds to class-level type-variables." + "The 2nd tuple corresponds to parent interfaces." + "The 3rd tuple corresponds to arguments to the super class constructor." + "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." + (object [] [Runnable] + [] + (Runnable [] (run self) void + (exec + (do_something some_value) + [])))]) + + ($.documentation /.null + "The null pointer." + [(null)]) + + ($.documentation /.null? + "Test for the null pointer." + [(= true + (null? (null)))] + [(= false + (null? "YOLO"))]) + + ($.documentation /.??? + "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." + [(= (??? (is java/lang/String (null))) + {.#None})] + [(= (??? "YOLO") + {.#Some "YOLO"})]) + + ($.documentation /.!!! + (format "Takes a (Maybe ObjectType) and returns a ObjectType." + \n "A .#None would get translated into a (null).") + [(= (null) + (!!! (??? (is java/lang/Thread (null)))))] + [(= "foo" + (!!! (??? "foo")))]) + + ($.documentation /.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})]) + + ($.documentation /.synchronized + "Evaluates body, while holding a lock on a given object." + [(synchronized object_to_be_locked + (exec + (do something) + (dosomething else) + (finish the computation)))]) + + ($.documentation /.do_to + "Call a variety of methods on an object. Then, return the object." + [(do_to object + (ClassName::method1 arg0 arg1 arg2) + (ClassName::method2 arg3 arg4 arg5))]) + + ($.documentation /.import + "Allows importing JVM classes, and using them as types." + ["Their methods, fields and enum options can also be imported." + (import java/lang/Object + "[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]) + + ($.documentation /.array + "Create an array of the given type, with the given size." + [(array java/lang/Object 10)]) + + ($.documentation /.length + "Gives the length of an array." + [(length my_array)]) + + ($.documentation /.read! + "Loads an element from an array." + [(read! 10 my_array)]) + + ($.documentation /.write! + "Stores an element into an array." + [(write! 10 my_object my_array)]) + + ($.documentation /.class_for + "Loads the class as a java.lang.Class object." + [(class_for java/lang/String)]) + + ($.documentation /.type + "" + [(is Type + (type java/lang/String))]) + + ($.documentation /.is + "" + [(is java/lang/Object + (is java/lang/String + ???))])] + []))) diff --git a/stdlib/source/documentation/lux/ffi.lua.lux b/stdlib/source/documentation/lux/ffi.lua.lux index 5edd5c9e0..4b5e478de 100644 --- a/stdlib/source/documentation/lux/ffi.lua.lux +++ b/stdlib/source/documentation/lux/ffi.lua.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except int char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data ["[0]" text (.only \n) ["%" \\format (.only format)]]] @@ -10,29 +10,27 @@ [\\library ["[0]" /]]) -(documentation: /.import - "Easily import types, methods, functions and constants." - [(import (os/getenv [..String] "io" "?" ..String))]) - -(documentation: /.closure - (format "Allows defining closures/anonymous-functions in the form that Lua expects." - \n "This is useful for adapting Lux functions for usage by Lua code.") - [(is ..Function - (closure [left right] - (do_something (as Foo left) (as Bar right))))]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..import - ..closure - ($.default (/.Object brand)) + [($.default (/.Object brand)) ($.default /.Nil) ($.default /.Function) ($.default /.Table) ($.default /.Boolean) ($.default /.Integer) ($.default /.Float) - ($.default /.String)] + ($.default /.String) + + ($.documentation /.import + "Easily import types, methods, functions and constants." + [(import (os/getenv [..String] "io" "?" ..String))]) + + ($.documentation /.closure + (format "Allows defining closures/anonymous-functions in the form that Lua expects." + \n "This is useful for adapting Lux functions for usage by Lua code.") + [(is ..Function + (closure [left right] + (do_something (as Foo left) (as Bar right))))])] [])) diff --git a/stdlib/source/documentation/lux/ffi.old.lux b/stdlib/source/documentation/lux/ffi.old.lux index 805f9ec8c..460e8512e 100644 --- a/stdlib/source/documentation/lux/ffi.old.lux +++ b/stdlib/source/documentation/lux/ffi.old.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except int char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data ["[0]" text (.only \n) ["%" \\format (.only format)]]] @@ -10,253 +10,213 @@ [\\library ["[0]" /]]) -(with_template [ ] - [(documentation: - "Type converter.")] - - [/.byte_to_long "java.lang.Byte" "java.lang.Long"] - - [/.short_to_long "java.lang.Short" "java.lang.Long"] - - [/.double_to_int "java.lang.Double" "java.lang.Integer"] - [/.double_to_long "java.lang.Double" "java.lang.Long"] - [/.double_to_float "java.lang.Double" "java.lang.Float"] - - [/.float_to_int "java.lang.Float" "java.lang.Integer"] - [/.float_to_long "java.lang.Float" "java.lang.Long"] - [/.float_to_double "java.lang.Float" "java.lang.Double"] - - [/.int_to_byte "java.lang.Integer" "java.lang.Byte"] - [/.int_to_short "java.lang.Integer" "java.lang.Short"] - [/.int_to_long "java.lang.Integer" "java.lang.Long"] - [/.int_to_float "java.lang.Integer" "java.lang.Float"] - [/.int_to_double "java.lang.Integer" "java.lang.Double"] - [/.int_to_char "java.lang.Integer" "java.lang.Character"] - - [/.long_to_byte "java.lang.Long" "java.lang.Byte"] - [/.long_to_short "java.lang.Long" "java.lang.Short"] - [/.long_to_int "java.lang.Long" "java.lang.Integer"] - [/.long_to_float "java.lang.Long" "java.lang.Float"] - [/.long_to_double "java.lang.Long" "java.lang.Double"] - - [/.char_to_byte "java.lang.Character" "java.lang.Byte"] - [/.char_to_short "java.lang.Character" "java.lang.Short"] - [/.char_to_int "java.lang.Character" "java.lang.Integer"] - [/.char_to_long "java.lang.Character" "java.lang.Long"] - ) - -(documentation: /.class - "Allows defining JVM classes in Lux code." - [(class "final" (TestClass A) [Runnable] - ... Fields - ("private" foo boolean) - ("private" bar A) - ("private" baz java/lang/Object) - ... Methods - ("public" [] (new [value A]) [] - (exec - (:= ::foo #1) - (:= ::bar value) - (:= ::baz "") - [])) - ("public" (virtual) java/lang/Object - "") - ("public" "static" (static) java/lang/Object - "") - (Runnable [] (run) void - [])) - "The tuple corresponds to parent interfaces." - "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." - "Fields and methods defined in the class can be used with special syntax." - "For example:" - "::resolved, for accessing the 'resolved' field." - "(:= ::resolved #1) for modifying it." - "(::new! []) for calling the class's constructor." - "(::resolve! container [value]) for calling the 'resolve' method."]) - -(documentation: /.interface - "Allows defining JVM interfaces." - [(interface TestInterface - ([] foo [boolean String] void "throws" [Exception]))]) - -(documentation: /.object - "Allows defining anonymous classes." - ["The 1st tuple corresponds to class-level type-variables." - "The 2nd tuple corresponds to parent interfaces." - "The 3rd tuple corresponds to arguments to the super class constructor." - "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." - (object [] [Runnable] - [] - (Runnable [] (run self) void - (exec (do_something some_value) - [])))]) - -(documentation: /.null - "Null object reference." - (null)) - -(documentation: /.null? - "Test for null object reference." - [(= (null? (null)) - true)] - [(= (null? "YOLO") - false)]) - -(documentation: /.??? - "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." - [(= (??? (is java/lang/String (null))) - {.#None})] - [(= (??? "YOLO") - {.#Some "YOLO"})]) - -(documentation: /.!!! - "Takes a (Maybe ObjectType) and returns a ObjectType." - [(= "foo" - (!!! (??? "foo")))] - ["A .#None would get translated into a (null)." - (= (null) - (!!! (??? (is java/lang/Thread (null)))))]) - -(documentation: /.check - (format "Checks whether an object is an instance of a particular class." - \n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.") - [(case (check java/lang/String "YOLO") - {.#Some value_as_string} - {.#None})]) - -(documentation: /.synchronized - "Evaluates body, while holding a lock on a given object." - [(synchronized object_to_be_locked - (exec - (do something) - (do_something else) - (finish the computation)))]) - -(documentation: /.do_to - "Call a variety of methods on an object. Then, return the object." - [(do_to object - (ClassName::method0 arg0 arg1 arg2) - (ClassName::method1 arg3 arg4 arg5))]) - -(documentation: /.import - (format "Allows importing JVM classes, and using them as types." - \n "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-parameters." - "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]) - -(documentation: /.array - "Create an array of the given type, with the given size." - [(array java/lang/Object 10)]) - -(documentation: /.length - "Gives the length of an array." - [(length my_array)]) - -(documentation: /.read! - "Loads an element from an array." - [(read! 10 my_array)]) - -(documentation: /.write! - "Stores an element into an array." - [(write! 10 my_object my_array)]) - -(documentation: /.class_for - "Loads the class as a java.lang.Class object." - [(is (Primitive "java.lang.Class" ["java.lang.Object"]) - (class_for java/lang/String))]) - -(documentation: /.type - "" - [(is .Type - (type java/lang/String))]) - -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [..byte_to_long - ..short_to_long - ..double_to_int - ..double_to_long - ..double_to_float - ..float_to_int - ..float_to_long - ..float_to_double - ..int_to_byte - ..int_to_short - ..int_to_long - ..int_to_float - ..int_to_double - ..int_to_char - ..long_to_byte - ..long_to_short - ..long_to_int - ..long_to_float - ..long_to_double - ..char_to_byte - ..char_to_short - ..char_to_int - ..char_to_long - ..class - ..interface - ..object - ..null - ..null? - ..??? - ..!!! - ..check - ..synchronized - ..do_to - ..import - ..array - ..length - ..read! - ..write! - ..class_for - ..type - ($.default /.Privacy) - ($.default /.State) - ($.default /.Inheritance)] - [])) +(`` (.def .public documentation + (.List $.Module) + ($.module /._ + "" + [($.default /.Privacy) + ($.default /.State) + ($.default /.Inheritance) + + (~~ (with_template [ ] + [($.documentation + "Type converter.")] + + [/.byte_to_long "java.lang.Byte" "java.lang.Long"] + + [/.short_to_long "java.lang.Short" "java.lang.Long"] + + [/.double_to_int "java.lang.Double" "java.lang.Integer"] + [/.double_to_long "java.lang.Double" "java.lang.Long"] + [/.double_to_float "java.lang.Double" "java.lang.Float"] + + [/.float_to_int "java.lang.Float" "java.lang.Integer"] + [/.float_to_long "java.lang.Float" "java.lang.Long"] + [/.float_to_double "java.lang.Float" "java.lang.Double"] + + [/.int_to_byte "java.lang.Integer" "java.lang.Byte"] + [/.int_to_short "java.lang.Integer" "java.lang.Short"] + [/.int_to_long "java.lang.Integer" "java.lang.Long"] + [/.int_to_float "java.lang.Integer" "java.lang.Float"] + [/.int_to_double "java.lang.Integer" "java.lang.Double"] + [/.int_to_char "java.lang.Integer" "java.lang.Character"] + + [/.long_to_byte "java.lang.Long" "java.lang.Byte"] + [/.long_to_short "java.lang.Long" "java.lang.Short"] + [/.long_to_int "java.lang.Long" "java.lang.Integer"] + [/.long_to_float "java.lang.Long" "java.lang.Float"] + [/.long_to_double "java.lang.Long" "java.lang.Double"] + + [/.char_to_byte "java.lang.Character" "java.lang.Byte"] + [/.char_to_short "java.lang.Character" "java.lang.Short"] + [/.char_to_int "java.lang.Character" "java.lang.Integer"] + [/.char_to_long "java.lang.Character" "java.lang.Long"] + )) + + ($.documentation /.class + "Allows defining JVM classes in Lux code." + [(class "final" (TestClass A) [Runnable] + ... Fields + ("private" foo boolean) + ("private" bar A) + ("private" baz java/lang/Object) + ... Methods + ("public" [] (new [value A]) [] + (exec + (:= ::foo #1) + (:= ::bar value) + (:= ::baz "") + [])) + ("public" (virtual) java/lang/Object + "") + ("public" "static" (static) java/lang/Object + "") + (Runnable [] (run) void + [])) + "The tuple corresponds to parent interfaces." + "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." + "Fields and methods defined in the class can be used with special syntax." + "For example:" + "::resolved, for accessing the 'resolved' field." + "(:= ::resolved #1) for modifying it." + "(::new! []) for calling the class's constructor." + "(::resolve! container [value]) for calling the 'resolve' method."]) + + ($.documentation /.interface + "Allows defining JVM interfaces." + [(interface TestInterface + ([] foo [boolean String] void "throws" [Exception]))]) + + ($.documentation /.object + "Allows defining anonymous classes." + ["The 1st tuple corresponds to class-level type-variables." + "The 2nd tuple corresponds to parent interfaces." + "The 3rd tuple corresponds to arguments to the super class constructor." + "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." + (object [] [Runnable] + [] + (Runnable [] (run self) void + (exec (do_something some_value) + [])))]) + + ($.documentation /.null + "Null object reference." + (null)) + + ($.documentation /.null? + "Test for null object reference." + [(= (null? (null)) + true)] + [(= (null? "YOLO") + false)]) + + ($.documentation /.??? + "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." + [(= (??? (is java/lang/String (null))) + {.#None})] + [(= (??? "YOLO") + {.#Some "YOLO"})]) + + ($.documentation /.!!! + "Takes a (Maybe ObjectType) and returns a ObjectType." + [(= "foo" + (!!! (??? "foo")))] + ["A .#None would get translated into a (null)." + (= (null) + (!!! (??? (is java/lang/Thread (null)))))]) + + ($.documentation /.check + (format "Checks whether an object is an instance of a particular class." + \n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.") + [(case (check java/lang/String "YOLO") + {.#Some value_as_string} + {.#None})]) + + ($.documentation /.synchronized + "Evaluates body, while holding a lock on a given object." + [(synchronized object_to_be_locked + (exec + (do something) + (do_something else) + (finish the computation)))]) + + ($.documentation /.do_to + "Call a variety of methods on an object. Then, return the object." + [(do_to object + (ClassName::method0 arg0 arg1 arg2) + (ClassName::method1 arg3 arg4 arg5))]) + + ($.documentation /.import + (format "Allows importing JVM classes, and using them as types." + \n "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-parameters." + "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]) + + ($.documentation /.array + "Create an array of the given type, with the given size." + [(array java/lang/Object 10)]) + + ($.documentation /.length + "Gives the length of an array." + [(length my_array)]) + + ($.documentation /.read! + "Loads an element from an array." + [(read! 10 my_array)]) + + ($.documentation /.write! + "Stores an element into an array." + [(write! 10 my_object my_array)]) + + ($.documentation /.class_for + "Loads the class as a java.lang.Class object." + [(is (Primitive "java.lang.Class" ["java.lang.Object"]) + (class_for java/lang/String))]) + + ($.documentation /.type + "" + [(is .Type + (type java/lang/String))])] + []))) diff --git a/stdlib/source/documentation/lux/ffi.py.lux b/stdlib/source/documentation/lux/ffi.py.lux index 3feb67e74..0d5a5771f 100644 --- a/stdlib/source/documentation/lux/ffi.py.lux +++ b/stdlib/source/documentation/lux/ffi.py.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except int char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data ["[0]" text (.only \n) ["%" \\format (.only format)]]] @@ -10,50 +10,48 @@ [\\library ["[0]" /]]) -(documentation: /.import - "Easily import types, methods, functions and constants." - [(import os - "[1]::[0]" - ("static" F_OK Integer) - ("static" R_OK Integer) - ("static" W_OK Integer) - ("static" X_OK Integer) - - ("static" mkdir [String] "io" "try" "?" Any) - ("static" access [String Integer] "io" "try" Boolean) - ("static" remove [String] "io" "try" "?" Any) - ("static" rmdir [String] "io" "try" "?" Any) - ("static" rename [String String] "io" "try" "?" Any) - ("static" listdir [String] "io" "try" (Array String))) - - (import os/path - "[1]::[0]" - ("static" isfile [String] "io" "try" Boolean) - ("static" isdir [String] "io" "try" Boolean) - ("static" sep String) - ("static" getsize [String] "io" "try" Integer) - ("static" getmtime [String] "io" "try" Float))]) - -(documentation: /.lambda - (format "Allows defining closures/anonymous-functions in the form that Python expects." - \n "This is useful for adapting Lux functions for usage by Python code.") - [(is ..Function - (lambda [left right] - (do_something (as Foo left) - (as Bar right))))]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..import - ..lambda - ($.default (/.Object brand)) + [($.default (/.Object brand)) ($.default /.None) ($.default /.Dict) ($.default /.Function) ($.default /.Boolean) ($.default /.Integer) ($.default /.Float) - ($.default /.String)] + ($.default /.String) + + ($.documentation /.import + "Easily import types, methods, functions and constants." + [(import os + "[1]::[0]" + ("static" F_OK Integer) + ("static" R_OK Integer) + ("static" W_OK Integer) + ("static" X_OK Integer) + + ("static" mkdir [String] "io" "try" "?" Any) + ("static" access [String Integer] "io" "try" Boolean) + ("static" remove [String] "io" "try" "?" Any) + ("static" rmdir [String] "io" "try" "?" Any) + ("static" rename [String String] "io" "try" "?" Any) + ("static" listdir [String] "io" "try" (Array String))) + + (import os/path + "[1]::[0]" + ("static" isfile [String] "io" "try" Boolean) + ("static" isdir [String] "io" "try" Boolean) + ("static" sep String) + ("static" getsize [String] "io" "try" Integer) + ("static" getmtime [String] "io" "try" Float))]) + + ($.documentation /.lambda + (format "Allows defining closures/anonymous-functions in the form that Python expects." + \n "This is useful for adapting Lux functions for usage by Python code.") + [(is ..Function + (lambda [left right] + (do_something (as Foo left) + (as Bar right))))])] [])) diff --git a/stdlib/source/documentation/lux/ffi.rb.lux b/stdlib/source/documentation/lux/ffi.rb.lux index 86cff83d3..3ea02446e 100644 --- a/stdlib/source/documentation/lux/ffi.rb.lux +++ b/stdlib/source/documentation/lux/ffi.rb.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except int char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data ["[0]" text (.only \n) ["%" \\format (.only format)]]] @@ -10,36 +10,35 @@ [\\library ["[0]" /]]) -(documentation: /.import - "Easily import types, methods, functions and constants." - [(import Stat - "[1]::[0]" - (executable? [] Bit) - (size Int)) - - (import File "as" RubyFile - "[1]::[0]" - ("static" SEPARATOR ..String) - ("static" open [Path ..String] "io" "try" RubyFile) - ("static" stat [Path] "io" "try" Stat) - ("static" delete [Path] "io" "try" Int) - ("static" file? [Path] "io" "try" Bit) - ("static" directory? [Path] "io" "try" Bit) - - (read [] "io" "try" Binary) - (write [Binary] "io" "try" Int) - (flush [] "io" "try" "?" Any) - (close [] "io" "try" "?" Any))]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..import - ($.default (/.Object brand)) + [($.default (/.Object brand)) ($.default /.Nil) ($.default /.Function) ($.default /.Integer) ($.default /.Float) - ($.default /.String)] + ($.default /.String) + + ($.documentation /.import + "Easily import types, methods, functions and constants." + [(import Stat + "[1]::[0]" + (executable? [] Bit) + (size Int)) + + (import File "as" RubyFile + "[1]::[0]" + ("static" SEPARATOR ..String) + ("static" open [Path ..String] "io" "try" RubyFile) + ("static" stat [Path] "io" "try" Stat) + ("static" delete [Path] "io" "try" Int) + ("static" file? [Path] "io" "try" Bit) + ("static" directory? [Path] "io" "try" Bit) + + (read [] "io" "try" Binary) + (write [Binary] "io" "try" Int) + (flush [] "io" "try" "?" Any) + (close [] "io" "try" "?" Any))])] [])) diff --git a/stdlib/source/documentation/lux/program.lux b/stdlib/source/documentation/lux/program.lux index e6301fc55..fc830b881 100644 --- a/stdlib/source/documentation/lux/program.lux +++ b/stdlib/source/documentation/lux/program.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except) - ["$" documentation (.only documentation:)] + ["$" documentation] [control ["[0]" io]] [data @@ -12,22 +12,20 @@ [\\library ["[0]" /]]) -(documentation: /.program: - "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)." - ["Can take a list of all the input parameters to the program." - (program: all_arguments - (do io.monad - [foo (initialize program)] - (do_something_with all_arguments)))] - ["Can also parse them using CLI parsers from the library/lux/control/parser/cli module." - (program: [config configuration_parser] - (do io.monad - [data (initialize program with config)] - (do_something_with data)))]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..program:] + [($.documentation /.program: + "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)." + ["Can take a list of all the input parameters to the program." + (program: all_arguments + (do io.monad + [foo (initialize program)] + (do_something_with all_arguments)))] + ["Can also parse them using CLI parsers from the library/lux/control/parser/cli module." + (program: [config configuration_parser] + (do io.monad + [data (initialize program with config)] + (do_something_with data)))])] [])) diff --git a/stdlib/source/documentation/lux/static.lux b/stdlib/source/documentation/lux/static.lux index aa11a339e..08b82e86c 100644 --- a/stdlib/source/documentation/lux/static.lux +++ b/stdlib/source/documentation/lux/static.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except nat int rev) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text ["%" \\format (.only format)]] @@ -10,59 +10,47 @@ [\\library ["[0]" /]]) -(with_template [ ] - [(documentation: - (%.code (' ( - (is - (value generating expression))))))] +(`` (.def .public documentation + (.List $.Module) + ($.module /._ + "" + [(~~ (with_template [ ] + [($.documentation + (%.code (' ( + (is + (value generating expression))))))] - [/.nat .Nat] - [/.int .Int] - [/.rev .Rev] - [/.frac .Frac] - [/.text .Text] - ) + [/.nat .Nat] + [/.int .Int] + [/.rev .Rev] + [/.frac .Frac] + [/.text .Text] + )) -(documentation: /.literal - "" - [(/.literal - (is (-> ??? Code) - format) - (is ??? - (value generating expression)))]) + ($.documentation /.literal + "" + [(/.literal + (is (-> ??? Code) + format) + (is ??? + (value generating expression)))]) -(with_template [ ] - [(documentation: - (%.code (' (is - ()))))] + (~~ (with_template [ ] + [($.documentation + (%.code (' (is + ()))))] - [/.random_nat .Nat] - [/.random_int .Int] - [/.random_rev .Rev] - [/.random_frac .Frac] - ) + [/.random_nat .Nat] + [/.random_int .Int] + [/.random_rev .Rev] + [/.random_frac .Frac] + )) -(documentation: /.random - "" - [(/.random - (is (-> ??? Code) - format) - (is (Random ???) - (random data generator)))]) - -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [..nat - ..int - ..rev - ..frac - ..text - ..literal - ..random_nat - ..random_int - ..random_rev - ..random_frac - ..random] - [])) + ($.documentation /.random + "" + [(/.random + (is (-> ??? Code) + format) + (is (Random ???) + (random data generator)))])] + []))) diff --git a/stdlib/source/documentation/lux/test.lux b/stdlib/source/documentation/lux/test.lux index b9196ae25..f15eacf9d 100644 --- a/stdlib/source/documentation/lux/test.lux +++ b/stdlib/source/documentation/lux/test.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except and for) - ["$" documentation (.only documentation:)] + ["$" documentation] [data ["[0]" text (.only \n) ["%" \\format (.only format)]]] @@ -10,116 +10,97 @@ [\\library ["[0]" /]]) -(documentation: /.Tally - "A record of successes and failures while executing tests.") - -(documentation: /.Assertion - "An asynchronous operation that yields test results.") - -(documentation: /.Test - "A test that relies on random data generation to thoroughly cover different scenarios.") - -(documentation: /.and' - "Sequencing combinator (for assertions)." - [(and' left right)]) - -(documentation: /.and - "Sequencing combinator." - [(and left right)]) - -(documentation: /.context - "Adds a contextual description to a test's documentation." - [(context description)]) - -(documentation: /.failure - "A failing test, with a given error message.") - -(documentation: /.assertion - "Check that a condition is #1, and fail with the given message otherwise." - [(assertion message condition)]) - -(documentation: /.property - "Check that a condition is #1, and fail with the given message otherwise." - [(property message condition)]) - -(documentation: /.lifted - "" - [(lifted message random)]) - -(documentation: /.Seed - "The seed value used for random testing (if that feature is used).") - -(documentation: /.seed - (format "Execute the given test with a specific seed value." - \n "This allows you to reproduce a failing test case as many times as you want while debugging.") - [(seed value test)]) - -(documentation: /.times - (format "Allows executing a test several times." - \n "By doing this, it's possible to thoroughly test code with many different scenarios." - \n "This assumes that random data generation is being used in tests instead of fixed/constant inputs.") - [(times amount test)]) - -(documentation: /.run! - (format "Executes a test, and exits the program with either a successful or a failing exit code." - \n "WARNING: This procedure is only meant to be used in (program: ...) forms.") - [(run! test)]) - -(documentation: /.coverage' - (format "Specifies a test as covering one or more definitions." - \n "Adds to the test tally information to track which definitions have been tested.") - [(coverage' [definition/0 definition/1 ,,, definition/N] - (is Bit - (some "computation")))]) - -(documentation: /.coverage - (format "Specifies a test as covering one or more definitions." - \n "Adds to the test tally information to track which definitions have been tested.") - [(coverage [definition/0 definition/1 ,,, definition/N] - (is Bit - (some "computation")))]) - -(documentation: /.for - (format "Specifies a context for tests as covering one or more definitions." - \n "Adds to the test tally information to track which definitions have been tested.") - [(for [definition/0 definition/1 ,,, definition/N] - (is Test - some_test))]) - -(documentation: /.covering - (format "Specifies the module being covered by a test." - \n "Adds tracking information to the tally to know which exported definitions in the module need to be covered.") - [(covering .._ - (is Test - some_test))]) - -(documentation: /.in_parallel - "Executes multiple tests in parallel (if the host platform supports it) to take advantage of multiple cores." - [(in_parallel tests)]) - (.def .public documentation (.List $.Module) ($.module /._ "Tools for unit & property-based/generative testing." - [..Tally - ..Assertion - ..Test - ..and' - ..and - ..context - ..failure - ..assertion - ..property - ..lifted - ..Seed - ..seed - ..times - ..run! - ..coverage' - ..coverage - ..for - ..covering - ..in_parallel - ($.default /.must_try_test_at_least_once) - ($.default /.error_during_execution)] + [($.default /.must_try_test_at_least_once) + ($.default /.error_during_execution) + + ($.documentation /.Tally + "A record of successes and failures while executing tests.") + + ($.documentation /.Assertion + "An asynchronous operation that yields test results.") + + ($.documentation /.Test + "A test that relies on random data generation to thoroughly cover different scenarios.") + + ($.documentation /.and' + "Sequencing combinator (for assertions)." + [(and' left right)]) + + ($.documentation /.and + "Sequencing combinator." + [(and left right)]) + + ($.documentation /.context + "Adds a contextual description to a test's documentation." + [(context description)]) + + ($.documentation /.failure + "A failing test, with a given error message.") + + ($.documentation /.assertion + "Check that a condition is #1, and fail with the given message otherwise." + [(assertion message condition)]) + + ($.documentation /.property + "Check that a condition is #1, and fail with the given message otherwise." + [(property message condition)]) + + ($.documentation /.lifted + "" + [(lifted message random)]) + + ($.documentation /.Seed + "The seed value used for random testing (if that feature is used).") + + ($.documentation /.seed + (format "Execute the given test with a specific seed value." + \n "This allows you to reproduce a failing test case as many times as you want while debugging.") + [(seed value test)]) + + ($.documentation /.times + (format "Allows executing a test several times." + \n "By doing this, it's possible to thoroughly test code with many different scenarios." + \n "This assumes that random data generation is being used in tests instead of fixed/constant inputs.") + [(times amount test)]) + + ($.documentation /.run! + (format "Executes a test, and exits the program with either a successful or a failing exit code." + \n "WARNING: This procedure is only meant to be used in (program: ...) forms.") + [(run! test)]) + + ($.documentation /.coverage' + (format "Specifies a test as covering one or more definitions." + \n "Adds to the test tally information to track which definitions have been tested.") + [(coverage' [definition/0 definition/1 ,,, definition/N] + (is Bit + (some "computation")))]) + + ($.documentation /.coverage + (format "Specifies a test as covering one or more definitions." + \n "Adds to the test tally information to track which definitions have been tested.") + [(coverage [definition/0 definition/1 ,,, definition/N] + (is Bit + (some "computation")))]) + + ($.documentation /.for + (format "Specifies a context for tests as covering one or more definitions." + \n "Adds to the test tally information to track which definitions have been tested.") + [(for [definition/0 definition/1 ,,, definition/N] + (is Test + some_test))]) + + ($.documentation /.covering + (format "Specifies the module being covered by a test." + \n "Adds tracking information to the tally to know which exported definitions in the module need to be covered.") + [(covering .._ + (is Test + some_test))]) + + ($.documentation /.in_parallel + "Executes multiple tests in parallel (if the host platform supports it) to take advantage of multiple cores." + [(in_parallel tests)])] [])) diff --git a/stdlib/source/documentation/lux/type/unit.lux b/stdlib/source/documentation/lux/type/unit.lux index 204154496..c7f4948ab 100644 --- a/stdlib/source/documentation/lux/type/unit.lux +++ b/stdlib/source/documentation/lux/type/unit.lux @@ -37,7 +37,7 @@ ($.default /.*) ($.default /./) - ($.documentation (/.Qty unit) + ($.documentation (/.Measure unit) "A quantity with an associated unit of measurement.") ($.documentation (/.Unit unit) @@ -47,7 +47,7 @@ "A scale of magnitude.") ($.documentation /.Pure - "A pure, unit-less quantity.") + "A pure, unit-less measure.") ($.documentation /.unit (format "Define a unit of measurement." @@ -60,7 +60,7 @@ ($.documentation /.re_scaled "" - [(re_scaled from to quantity)]) + [(re_scaled from to measure)]) (~~ (with_template [ ] [(`` ($.documentation -- cgit v1.2.3