From 659537b4ec859f1e705cdd1f82da29ab1a662d94 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 9 Apr 2022 04:10:28 -0400 Subject: De-sigil-ification: * --- .../documentation/lux/control/parser/tree.lux | 20 +-- .../documentation/lux/data/collection/list.lux | 2 +- stdlib/source/documentation/lux/data/product.lux | 20 +-- stdlib/source/documentation/lux/data/sum.lux | 20 +-- stdlib/source/documentation/lux/macro/syntax.lux | 14 +-- stdlib/source/documentation/lux/target/js.lux | 2 +- stdlib/source/documentation/lux/target/python.lux | 2 +- stdlib/source/documentation/lux/target/ruby.lux | 4 +- stdlib/source/documentation/lux/type.lux | 4 +- stdlib/source/documentation/lux/type/abstract.lux | 140 --------------------- stdlib/source/documentation/lux/type/primitive.lux | 132 +++++++++++++++++++ 11 files changed, 176 insertions(+), 184 deletions(-) delete mode 100644 stdlib/source/documentation/lux/type/abstract.lux create mode 100644 stdlib/source/documentation/lux/type/primitive.lux (limited to 'stdlib/source/documentation') diff --git a/stdlib/source/documentation/lux/control/parser/tree.lux b/stdlib/source/documentation/lux/control/parser/tree.lux index 416b9f910..282fcc7af 100644 --- a/stdlib/source/documentation/lux/control/parser/tree.lux +++ b/stdlib/source/documentation/lux/control/parser/tree.lux @@ -1,14 +1,14 @@ (.using - [library - [lux "*" - ["$" documentation {"+" documentation:}] - [data - [text {"+" \n} - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]]) + [library + [lux {"-" left right} + ["$" documentation {"+" documentation:}] + [data + [text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) (documentation: (/.Parser it) "A parser of arbitrary trees.") diff --git a/stdlib/source/documentation/lux/data/collection/list.lux b/stdlib/source/documentation/lux/data/collection/list.lux index 5497350e7..459e1f8c9 100644 --- a/stdlib/source/documentation/lux/data/collection/list.lux +++ b/stdlib/source/documentation/lux/data/collection/list.lux @@ -1,6 +1,6 @@ (.using [library - [lux "*" + [lux {"-" all} ["$" documentation {"+" documentation:}] [control ["<>" parser diff --git a/stdlib/source/documentation/lux/data/product.lux b/stdlib/source/documentation/lux/data/product.lux index 621ea9edb..a437421f5 100644 --- a/stdlib/source/documentation/lux/data/product.lux +++ b/stdlib/source/documentation/lux/data/product.lux @@ -1,14 +1,14 @@ (.using - [library - [lux {"-" nat int rev list type or and} - ["$" documentation {"+" documentation:}] - [data - [text - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]]) + [library + [lux {"-" left right} + ["$" documentation {"+" documentation:}] + [data + [text + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) (documentation: /.left "The left side of a pair.") diff --git a/stdlib/source/documentation/lux/data/sum.lux b/stdlib/source/documentation/lux/data/sum.lux index 7bdd8e54a..8d4a1edc5 100644 --- a/stdlib/source/documentation/lux/data/sum.lux +++ b/stdlib/source/documentation/lux/data/sum.lux @@ -1,14 +1,14 @@ (.using - [library - [lux "*" - ["$" documentation {"+" documentation:}] - [data - [text {"+" \n} - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]]) + [library + [lux {"-" left right} + ["$" documentation {"+" documentation:}] + [data + [text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) (documentation: /.left "Lifts value to the left side of a 2-variant.") diff --git a/stdlib/source/documentation/lux/macro/syntax.lux b/stdlib/source/documentation/lux/macro/syntax.lux index c4867ea7a..664439f72 100644 --- a/stdlib/source/documentation/lux/macro/syntax.lux +++ b/stdlib/source/documentation/lux/macro/syntax.lux @@ -22,13 +22,13 @@ (format \n "A more advanced way to define macros than 'macro:'." \n "The inputs to the macro can be parsed in complex ways through the use of syntax parsers." \n "The macro body is also (implicitly) run in the Meta monad, to save some typing." - \n "Also, the compiler state can be accessed through the *lux* binding.") - [(syntax: .public (object [.let [imports (class_imports *lux*)] - .let [class_vars (list)] - super (opt (super_class_decl^ imports class_vars)) - interfaces (tuple (some (super_class_decl^ imports class_vars))) - constructor_args (constructor_args^ imports class_vars) - methods (some (overriden_method_def^ imports))]) + \n "Also, the compiler state can be accessed through a special binding.") + [(syntax: .public (object lux_state [.let [imports (class_imports lux_state)] + .let [class_vars (list)] + super (opt (super_class_decl^ imports class_vars)) + interfaces (tuple (some (super_class_decl^ imports class_vars))) + constructor_args (constructor_args^ imports class_vars) + methods (some (overriden_method_def^ imports))]) (let [def_code (all text#composite "anon-class:" (spaced (list (super_class_decl$ (maybe.else object_super_class super)) (with_brackets (spaced (list#each super_class_decl$ interfaces))) diff --git a/stdlib/source/documentation/lux/target/js.lux b/stdlib/source/documentation/lux/target/js.lux index 32c800816..744b61310 100644 --- a/stdlib/source/documentation/lux/target/js.lux +++ b/stdlib/source/documentation/lux/target/js.lux @@ -34,7 +34,7 @@ ($.default /.var) ($.default /.at) ($.default /.the) - ($.default /.apply_*) + ($.default /.apply) ($.default /.do) ($.default /.object) ($.default /.,) diff --git a/stdlib/source/documentation/lux/target/python.lux b/stdlib/source/documentation/lux/target/python.lux index 4fa9c05e3..60d5172bd 100644 --- a/stdlib/source/documentation/lux/target/python.lux +++ b/stdlib/source/documentation/lux/target/python.lux @@ -48,7 +48,7 @@ ($.default /.slice) ($.default /.slice_from) ($.default /.dict) - ($.default /.apply/*) + ($.default /.apply) ($.default /.splat_poly) ($.default /.splat_keyword) ($.default /.the) diff --git a/stdlib/source/documentation/lux/target/ruby.lux b/stdlib/source/documentation/lux/target/ruby.lux index f295a437e..0f24c30da 100644 --- a/stdlib/source/documentation/lux/target/ruby.lux +++ b/stdlib/source/documentation/lux/target/ruby.lux @@ -62,8 +62,8 @@ ($.default /.array_range) ($.default /.array) ($.default /.hash) - ($.default /.apply/*) - ($.default /.apply_lambda/*) + ($.default /.apply) + ($.default /.apply_lambda) ($.default /.the) ($.default /.item) ($.default /.?) diff --git a/stdlib/source/documentation/lux/type.lux b/stdlib/source/documentation/lux/type.lux index 957dac26a..f7d1e3f64 100644 --- a/stdlib/source/documentation/lux/type.lux +++ b/stdlib/source/documentation/lux/type.lux @@ -13,7 +13,7 @@ [\\library ["[0]" /]] ["[0]" / "_" - ["[1][0]" abstract] + ["[1][0]" primitive] ["[1][0]" check] ["[1][0]" dynamic] ["[1][0]" implicit] @@ -186,7 +186,7 @@ ..by_example ..let ($.default /.equivalence)] - [/abstract.documentation + [/primitive.documentation /check.documentation /dynamic.documentation /implicit.documentation diff --git a/stdlib/source/documentation/lux/type/abstract.lux b/stdlib/source/documentation/lux/type/abstract.lux deleted file mode 100644 index 4fdf9e3fc..000000000 --- a/stdlib/source/documentation/lux/type/abstract.lux +++ /dev/null @@ -1,140 +0,0 @@ -(.using - [library - [lux {"-" pattern} - ["$" documentation {"+" documentation:}] - [control - ["<>" parser - ["<[0]>" code]]] - [data - ["[0]" text {"+" \n} - ["%" format {"+" format}]]] - [macro - ["[0]" template]]]] - [\\library - ["[0]" /]]) - -(documentation: /.Frame - "Meta-data about an abstract/nominal type in a stack of them.") - -(documentation: /.current - "The currently-being-defined abstract/nominal type.") - -(documentation: /.specific - "A specific abstract/nominal type still being defined somewhere in the scope." - [(specific name)]) - -(template [ <$> ] - [(documentation: - "Type-casting macro for abstract/nominal types." - [(|> value - (is ) - <$> - (is ))])] - - [/.abstraction Representation abstraction Abstraction] - [/.representation Abstraction representation Representation] - ) - -(documentation: /.abstract: - (format "Define abstract/nominal types which hide their representation details." - \n "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others.") - [(abstract: String - Text - - (def: (string value) - (-> Text String) - (abstraction value)) - - (def: (text value) - (-> String Text) - (representation value)))] - ["Type-parameters are optional." - (abstract: (Duplicate a) - [a a] - - (def: (duplicate value) - (All (_ a) (-> a (Duplicate a))) - (abstraction [value value])))] - ["Definitions can be nested." - (abstract: (Single a) - a - - (def: (single value) - (All (_ a) (-> a (Single a))) - (abstraction value)) - - (abstract: (Double a) - [a a] - - (def: (double value) - (All (_ a) (-> a (Double a))) - (abstraction [value value])) - - (def: (single' value) - (All (_ a) (-> a (Single a))) - (abstraction Single [value value])) - - (let [value 0123] - (same? value - (|> value - single' - (representation Single) - double - representation)))))] - ["Type-parameters do not necessarily have to be used in the representation type." - "If they are not used, they become phantom types and can be used to customize types without changing the representation." - (abstract: (JavaScript a) - Text - - (abstract: Expression Any) - (abstract: Statement Any) - - (def: (+ x y) - (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression)) - (abstraction - (format "(" (representation x) "+" (representation y) ")"))) - - (def: (while test body) - (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement)) - (abstraction - (format "while(" (representation test) ") {" - (representation body) - "}"))))]) - -(documentation: /.transmutation - "Transmutes an abstract/nominal type's phantom types." - [(abstract: (JavaScript a) - Text - - (abstract: Expression Any) - (abstract: Statement Any) - - (def: (statement expression) - (-> (JavaScript Expression) (JavaScript Statement)) - (transmutation expression)) - - (def: (statement' expression) - (-> (JavaScript Expression) (JavaScript Statement)) - (transmutation JavaScript expression)))]) - -(documentation: /.pattern - "Pattern-matching macro to easily extract a representation." - [(def: (computation abstraction) - (All (_ a) (-> (Abstract a) ???)) - (let [(pattern value) abstraction] - (foo (bar (baz value)))))]) - -(.def: .public documentation - (.List $.Module) - ($.module /._ - "" - [..Frame - ..current - ..specific - ..abstraction - ..representation - ..abstract: - ..transmutation - ..pattern - ($.default /.no_active_frames)] - [])) diff --git a/stdlib/source/documentation/lux/type/primitive.lux b/stdlib/source/documentation/lux/type/primitive.lux new file mode 100644 index 000000000..e4a180bfc --- /dev/null +++ b/stdlib/source/documentation/lux/type/primitive.lux @@ -0,0 +1,132 @@ +(.using + [library + [lux "*" + ["$" documentation {"+" documentation:}] + [control + ["<>" parser + ["<[0]>" code]]] + [data + ["[0]" text {"+" \n} + ["%" format {"+" format}]]] + [macro + ["[0]" template]]]] + [\\library + ["[0]" /]]) + +(documentation: /.Frame + "Meta-data about an abstract/nominal type in a stack of them.") + +(documentation: /.current + "The currently-being-defined abstract/nominal type.") + +(documentation: /.specific + "A specific abstract/nominal type still being defined somewhere in the scope." + [(specific name)]) + +(template [ <$> ] + [(documentation: + "Type-casting macro for abstract/nominal types." + [(|> value + (is ) + <$> + (is ))])] + + [/.abstraction Representation abstraction Abstraction] + [/.representation Abstraction representation Representation] + ) + +(documentation: /.primitive: + (format "Define abstract/nominal types which hide their representation details." + \n "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others.") + [(primitive: String + Text + + (def: (string value) + (-> Text String) + (abstraction value)) + + (def: (text value) + (-> String Text) + (representation value)))] + ["Type-parameters are optional." + (primitive: (Duplicate a) + [a a] + + (def: (duplicate value) + (All (_ a) (-> a (Duplicate a))) + (abstraction [value value])))] + ["Definitions can be nested." + (primitive: (Single a) + a + + (def: (single value) + (All (_ a) (-> a (Single a))) + (abstraction value)) + + (primitive: (Double a) + [a a] + + (def: (double value) + (All (_ a) (-> a (Double a))) + (abstraction [value value])) + + (def: (single' value) + (All (_ a) (-> a (Single a))) + (abstraction Single [value value])) + + (let [value 0123] + (same? value + (|> value + single' + (representation Single) + double + representation)))))] + ["Type-parameters do not necessarily have to be used in the representation type." + "If they are not used, they become phantom types and can be used to customize types without changing the representation." + (primitive: (JavaScript a) + Text + + (primitive: Expression Any) + (primitive: Statement Any) + + (def: (+ x y) + (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression)) + (abstraction + (format "(" (representation x) "+" (representation y) ")"))) + + (def: (while test body) + (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement)) + (abstraction + (format "while(" (representation test) ") {" + (representation body) + "}"))))]) + +(documentation: /.transmutation + "Transmutes an abstract/nominal type's phantom types." + [(primitive: (JavaScript a) + Text + + (primitive: Expression Any) + (primitive: Statement Any) + + (def: (statement expression) + (-> (JavaScript Expression) (JavaScript Statement)) + (transmutation expression)) + + (def: (statement' expression) + (-> (JavaScript Expression) (JavaScript Statement)) + (transmutation JavaScript expression)))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Frame + ..current + ..specific + ..abstraction + ..representation + ..primitive: + ..transmutation + ($.default /.no_active_frames)] + [])) -- cgit v1.2.3