aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2021-08-25 16:47:50 -0400
committerEduardo Julian2021-08-25 16:47:50 -0400
commitb216900093c905b3b20dd45c69e577b192e2f7a3 (patch)
tree4d6ac7d257752a8c54ca77dd58df9753ce357ab6 /stdlib/source
parent36303d6cb2ce3ab9e36d045b9516c997bd461862 (diff)
Updates to the Lua compiler.
Diffstat (limited to '')
-rw-r--r--stdlib/source/documentation/lux.lux988
-rw-r--r--stdlib/source/documentation/lux/control/function/mixin.lux12
-rw-r--r--stdlib/source/documentation/lux/data/collection/array.lux11
-rw-r--r--stdlib/source/documentation/lux/data/text.lux12
-rw-r--r--stdlib/source/documentation/lux/extension.lux62
-rw-r--r--stdlib/source/documentation/lux/math.lux6
-rw-r--r--stdlib/source/documentation/lux/type.lux189
-rw-r--r--stdlib/source/documentation/lux/type/check.lux2
-rw-r--r--stdlib/source/documentation/lux/type/poly.lux72
-rw-r--r--stdlib/source/documentation/lux/type/quotient.lux52
-rw-r--r--stdlib/source/documentation/lux/type/refinement.lux64
-rw-r--r--stdlib/source/documentation/lux/type/resource.lux118
-rw-r--r--stdlib/source/documentation/lux/type/unit.lux117
-rw-r--r--stdlib/source/documentation/lux/type/variance.lux32
-rw-r--r--stdlib/source/documentation/lux/world.lux33
-rw-r--r--stdlib/source/documentation/lux/world/console.lux43
-rw-r--r--stdlib/source/documentation/lux/world/file.lux76
-rw-r--r--stdlib/source/documentation/lux/world/file/watch.lux58
-rw-r--r--stdlib/source/documentation/lux/world/input/keyboard.lux112
-rw-r--r--stdlib/source/documentation/lux/world/net.lux36
-rw-r--r--stdlib/source/documentation/lux/world/net/http/client.lux54
-rw-r--r--stdlib/source/documentation/lux/world/net/http/status.lux171
-rw-r--r--stdlib/source/documentation/lux/world/net/uri.lux24
-rw-r--r--stdlib/source/documentation/lux/world/output/video/resolution.lux69
-rw-r--r--stdlib/source/documentation/lux/world/program.lux37
-rw-r--r--stdlib/source/documentation/lux/world/shell.lux54
-rw-r--r--stdlib/source/library/lux.lux923
-rw-r--r--stdlib/source/library/lux/abstract/apply.lux15
-rw-r--r--stdlib/source/library/lux/abstract/enum.lux12
-rw-r--r--stdlib/source/library/lux/control/exception.lux8
-rw-r--r--stdlib/source/library/lux/control/function/memo.lux6
-rw-r--r--stdlib/source/library/lux/control/function/mixin.lux6
-rw-r--r--stdlib/source/library/lux/control/io.lux8
-rw-r--r--stdlib/source/library/lux/control/lazy.lux2
-rw-r--r--stdlib/source/library/lux/control/parser/text.lux12
-rw-r--r--stdlib/source/library/lux/data/collection/array.lux13
-rw-r--r--stdlib/source/library/lux/data/collection/dictionary.lux72
-rw-r--r--stdlib/source/library/lux/data/collection/row.lux29
-rw-r--r--stdlib/source/library/lux/data/color.lux8
-rw-r--r--stdlib/source/library/lux/data/format/tar.lux17
-rw-r--r--stdlib/source/library/lux/data/text.lux38
-rw-r--r--stdlib/source/library/lux/data/text/regex.lux7
-rw-r--r--stdlib/source/library/lux/debug.lux2
-rw-r--r--stdlib/source/library/lux/documentation.lux21
-rw-r--r--stdlib/source/library/lux/ffi.js.lux13
-rw-r--r--stdlib/source/library/lux/ffi.jvm.lux13
-rw-r--r--stdlib/source/library/lux/ffi.lua.lux23
-rw-r--r--stdlib/source/library/lux/ffi.php.lux13
-rw-r--r--stdlib/source/library/lux/ffi.py.lux13
-rw-r--r--stdlib/source/library/lux/ffi.rb.lux13
-rw-r--r--stdlib/source/library/lux/ffi.scm.lux13
-rw-r--r--stdlib/source/library/lux/math.lux8
-rw-r--r--stdlib/source/library/lux/math/number/complex.lux10
-rw-r--r--stdlib/source/library/lux/math/number/rev.lux58
-rw-r--r--stdlib/source/library/lux/meta.lux49
-rw-r--r--stdlib/source/library/lux/target/js.lux10
-rw-r--r--stdlib/source/library/lux/target/jvm/bytecode.lux6
-rw-r--r--stdlib/source/library/lux/target/jvm/encoding/unsigned.lux12
-rw-r--r--stdlib/source/library/lux/target/lua.lux2
-rw-r--r--stdlib/source/library/lux/test.lux4
-rw-r--r--stdlib/source/library/lux/time/date.lux20
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux13
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux8
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux40
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux93
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux15
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux51
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux42
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux5
-rw-r--r--stdlib/source/library/lux/type.lux53
-rw-r--r--stdlib/source/library/lux/type/check.lux18
-rw-r--r--stdlib/source/library/lux/type/quotient.lux16
-rw-r--r--stdlib/source/library/lux/type/refinement.lux16
-rw-r--r--stdlib/source/library/lux/type/resource.lux44
-rw-r--r--stdlib/source/library/lux/type/unit.lux19
-rw-r--r--stdlib/source/library/lux/type/variance.lux3
-rw-r--r--stdlib/source/library/lux/world/console.lux6
-rw-r--r--stdlib/source/library/lux/world/file.lux22
-rw-r--r--stdlib/source/library/lux/world/file/watch.lux9
-rw-r--r--stdlib/source/library/lux/world/input/keyboard.lux2
-rw-r--r--stdlib/source/library/lux/world/net.lux3
-rw-r--r--stdlib/source/library/lux/world/net/http/client.lux10
-rw-r--r--stdlib/source/library/lux/world/net/http/route.lux2
-rw-r--r--stdlib/source/library/lux/world/net/http/status.lux23
-rw-r--r--stdlib/source/library/lux/world/net/uri.lux2
-rw-r--r--stdlib/source/library/lux/world/output/video/resolution.lux29
-rw-r--r--stdlib/source/library/lux/world/program.lux3
-rw-r--r--stdlib/source/library/lux/world/shell.lux9
-rw-r--r--stdlib/source/program/aedifex.lux4
-rw-r--r--stdlib/source/program/aedifex/artifact.lux7
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot.lux5
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/stamp.lux5
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/version.lux7
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/version/value.lux5
-rw-r--r--stdlib/source/program/aedifex/artifact/time/date.lux8
-rw-r--r--stdlib/source/program/aedifex/artifact/versioning.lux7
-rw-r--r--stdlib/source/program/aedifex/cli.lux46
-rw-r--r--stdlib/source/program/aedifex/command/build.lux11
-rw-r--r--stdlib/source/program/aedifex/dependency.lux5
-rw-r--r--stdlib/source/program/aedifex/dependency/status.lux9
-rw-r--r--stdlib/source/program/aedifex/input.lux26
-rw-r--r--stdlib/source/program/aedifex/metadata/artifact.lux9
-rw-r--r--stdlib/source/program/aedifex/metadata/snapshot.lux5
-rw-r--r--stdlib/source/program/aedifex/package.lux7
-rw-r--r--stdlib/source/program/aedifex/profile.lux53
-rw-r--r--stdlib/source/program/aedifex/project.lux6
-rw-r--r--stdlib/source/program/aedifex/repository/identity.lux5
-rw-r--r--stdlib/source/program/aedifex/repository/origin.lux5
-rw-r--r--stdlib/source/program/aedifex/runtime.lux5
-rw-r--r--stdlib/source/program/compositor/cli.lux7
-rw-r--r--stdlib/source/program/compositor/static.lux9
-rw-r--r--stdlib/source/test/aedifex/cli.lux10
-rw-r--r--stdlib/source/test/aedifex/input.lux2
-rw-r--r--stdlib/source/test/aedifex/project.lux10
-rw-r--r--stdlib/source/test/lux/control/function/memo.lux4
-rw-r--r--stdlib/source/test/lux/control/function/mixin.lux30
-rw-r--r--stdlib/source/test/lux/data/collection/array.lux49
-rw-r--r--stdlib/source/test/lux/data/text.lux18
-rw-r--r--stdlib/source/test/lux/math.lux4
-rw-r--r--stdlib/source/test/lux/type/check.lux8
126 files changed, 3272 insertions, 1676 deletions
diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux
index 4365ea0eb..a046d1fdc 100644
--- a/stdlib/source/documentation/lux.lux
+++ b/stdlib/source/documentation/lux.lux
@@ -5,7 +5,17 @@
["$" documentation (#+ documentation:)]
["." debug]
[control
- ["." io]]]]
+ ["." io]
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]
+ [collection
+ ["." list]
+ ["." set]]]
+ [macro
+ ["." template]]]]
[\\library
["." /]]
["." / #_
@@ -14,6 +24,7 @@
["#." data]
["#." debug]
["#." documentation]
+ ["#." extension]
["#." ffi]
["#." locale]
["#." macro]
@@ -26,22 +37,988 @@
["#." time]
... ["#." tool] ... TODO: Documentation for this
["#." type]
- ... ["#." world]
- ... ["#." extension]
+ ["#." world]
... ["#." target #_
... <target>]
])
+(documentation: /.prelude_module
+ (format "The name of the prelude module"
+ \n "Value: " (%.text /.prelude_module)))
+
+(documentation: /.Any
+ (format "The type of things whose type is irrelevant."
+ \n "It can be used to write functions or data-structures that can take, or return, anything."))
+
+(documentation: /.Nothing
+ (format "The type of things whose type is undefined."
+ \n "Useful for expressions that cause errors or other 'extraordinary' conditions."))
+
+(documentation: /.List
+ "A potentially empty list of values.")
+
+(documentation: /.Bit
+ "Your standard, run-of-the-mill boolean values (as #0 or #1 bits).")
+
+(documentation: /.I64
+ "64-bit integers without any semantics.")
+
+(documentation: /.Nat
+ (format "Natural numbers (unsigned integers)."
+ \n "They start at zero (0) and extend in the positive direction."))
+
+(documentation: /.Int
+ "Your standard, run-of-the-mill integer numbers.")
+
+(documentation: /.Rev
+ (format "Fractional numbers that live in the interval [0,1)."
+ \n "Useful for probability, and other domains that work within that interval."))
+
+(documentation: /.Frac
+ "Your standard, run-of-the-mill floating-point (fractional) numbers.")
+
+(documentation: /.Text
+ "Your standard, run-of-the-mill string values.")
+
+(documentation: /.Name
+ "A name. It is used as part of Lux syntax to represent identifiers and tags.")
+
+(documentation: /.Maybe
+ "A potentially missing value.")
+
+(documentation: /.Type
+ "This type represents the data-structures that are used to specify types themselves.")
+
+(documentation: /.Location
+ "Locations are for specifying the location of Code nodes in Lux files during compilation.")
+
+(documentation: /.Ann
+ "The type of things that can be annotated with meta-data of arbitrary types.")
+
+(documentation: /.Code
+ "The type of Code nodes for Lux syntax.")
+
+(documentation: /.private
+ "The export policy for private/local definitions.")
+
+(documentation: /.local
+ "The export policy for private/local definitions.")
+
+(documentation: /.public
+ "The export policy for public/global definitions.")
+
+(documentation: /.global
+ "The export policy for public/global definitions.")
+
+(documentation: /.Definition
+ "Represents all the data associated with a definition: its type, its annotations, and its value.")
+
+(documentation: /.Global
+ "Represents all the data associated with a global constant.")
+
+(documentation: /.Either
+ "A choice between two values of different types.")
+
+(documentation: /.Module
+ "All the information contained within a Lux module.")
+
+(documentation: /.Mode
+ "A sign that shows the conditions under which the compiler is running.")
+
+(documentation: /.Info
+ "Information about the current version and type of compiler that is running.")
+
+(documentation: /.Lux
+ (format "Represents the state of the Lux compiler during a run."
+ \n "It is provided to macros during their invocation, so they can access compiler data."
+ \n "Caveat emptor: Avoid fiddling with it, unless you know what you're doing."))
+
+(documentation: /.Meta
+ (format "Computations that can have access to the state of the compiler."
+ \n "These computations may fail, or modify the state of the compiler."))
+
+(documentation: /.Macro
+ "Functions that run at compile-time and allow you to transform and extend the language in powerful ways.")
+
+(documentation: /.comment
+ (format "Throws away any code given to it."
+ \n "Great for commenting-out code, while retaining syntax high-lighting and formatting in your text editor.")
+ [(comment
+ (def: (this will not)
+ (Be Defined)
+ (because it will be (commented out))))])
+
+(documentation: /.All
+ "Universal quantification."
+ [(All [a]
+ (-> a a))]
+ ["A name can be provided, to specify a recursive type."
+ (All List [a]
+ (Or Any
+ [a (List a)]))])
+
+(documentation: /.Ex
+ "Existential quantification."
+ [(Ex [a]
+ [(Codec Text a) a])]
+ ["A name can be provided, to specify a recursive type."
+ (Ex Self [a]
+ [(Codec Text a)
+ a
+ (List (Self a))])])
+
+(documentation: /.->
+ "Function types."
+ ["This is the type of a function that takes 2 Ints and returns an Int."
+ (-> Int Int Int)])
+
+(documentation: /.list
+ "List literals."
+ [(: (List Nat)
+ (list 0 1 2 3))])
+
+(documentation: /.list&
+ "List literals, with the last element being a tail-list."
+ [(: (List Nat)
+ (list& 0 1 2 3
+ (: (List Nat)
+ (list 4 5 6))))])
+
+(documentation: /.Union
+ "Union types."
+ [(Union Bit Nat Text)]
+ [(= Nothing
+ (Union))])
+
+(documentation: /.Tuple
+ "Tuple types."
+ [(Tuple Bit Nat Text)]
+ [(= Any
+ (Tuple))])
+
+(documentation: /.Or
+ "An alias for the Union type constructor."
+ [(= (Union Bit Nat Text)
+ (Or Bit Nat Text))]
+ [(= (Union)
+ (Or))])
+
+(documentation: /.And
+ "An alias for the Tuple type constructor."
+ [(= (Tuple Bit Nat Text)
+ (And Bit Nat Text))]
+ [(= (Tuple)
+ (And))])
+
+(documentation: /._$
+ "Left-association for the application of binary functions over variadic arguments."
+ [(_$ text\composite "Hello, " name ". How are you?")
+ "=>"
+ (text\composite (text\composite "Hello, " name) ". How are you?")])
+
+(documentation: /.$_
+ "Right-association for the application of binary functions over variadic arguments."
+ [($_ text\composite "Hello, " name ". How are you?")
+ "=>"
+ (text\composite "Hello, " (text\composite name ". How are you?"))])
+
+(documentation: /.if
+ "Picks which expression to evaluate based on a bit test value."
+ [(if #1
+ "Oh, yeah!"
+ "Aw hell naw!")
+ "=>"
+ "Oh, yeah!"]
+ [(if #0
+ "Oh, yeah!"
+ "Aw hell naw!")
+ "=>"
+ "Aw hell naw!"])
+
+(documentation: /.primitive
+ "Macro to treat define new primitive types."
+ [(primitive "java.lang.Object")]
+ [(primitive "java.util.List" [(primitive "java.lang.Long")])])
+
+(documentation: /.`
+ (format "Hygienic quasi-quotation as a macro."
+ \n "Unquote (~) and unquote-splice (~+) must also be used as forms."
+ \n "All unprefixed macros will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used.")
+ [(` (def: (~ name)
+ (function ((~' _) (~+ args))
+ (~ body))))])
+
+(documentation: /.`'
+ (format "Unhygienic quasi-quotation as a macro."
+ \n "Unquote (~) and unquote-splice (~+) must also be used as forms.")
+ [(`' (def: (~ name)
+ (function (_ (~+ args))
+ (~ body))))])
+
+(documentation: /.'
+ "Quotation as a macro."
+ [(' YOLO)])
+
+(documentation: /.|>
+ "Piping macro."
+ [(|> elems
+ (list\each int\encoded)
+ (interposed " ")
+ (mix text\composite ""))
+ "=>"
+ (mix text\composite ""
+ (interposed " "
+ (list\each int\encoded
+ elems)))])
+
+(documentation: /.<|
+ "Reverse piping macro."
+ [(<| (mix text\composite "")
+ (interposed " ")
+ (list\each int\encoded)
+ elems)
+ "=>"
+ (mix text\composite ""
+ (interposed " "
+ (list\each int\encoded
+ elems)))])
+
+(documentation: /.template
+ ""
+ ["By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary."
+ (template [<name> <diff>]
+ [(def: .public <name>
+ (-> Int Int)
+ (+ <diff>))]
+ [++ +1]
+ [-- -1])])
+
+(documentation: /.not
+ "Bit negation."
+ [(not #1)
+ "=>"
+ #0]
+ [(not #0)
+ "=>"
+ #1])
+
+(documentation: /.type
+ "Takes a type expression and returns its representation as data-structure."
+ [(type (All [a]
+ (Maybe (List a))))])
+
+(documentation: /.:
+ "The type-annotation macro."
+ [(: (List Int)
+ (list +1 +2 +3))])
+
+(documentation: /.:as
+ "The type-coercion macro."
+ [(:as Dinosaur
+ (list +1 +2 +3))])
+
+(documentation: /.Rec
+ "Parameter-less recursive types."
+ ["A name has to be given to the whole type, to use it within its body."
+ (Rec Int_List
+ (Or Any
+ [Int Int_List]))])
+
+(documentation: /.exec
+ "Sequential execution of expressions (great for side-effects)."
+ [(exec
+ (log! "#1")
+ (log! "#2")
+ (log! "#3")
+ "YOLO")])
+
+(documentation: /.case
+ (format "The pattern-matching macro."
+ \n "Allows the usage of macros within the patterns to provide custom syntax.")
+ [(case (: (List Int)
+ (list +1 +2 +3))
+ (#Item x (#Item y (#Item z #End)))
+ (#Some ($_ * x y z))
+
+ _
+ #None)])
+
+(documentation: /.^
+ (format "Macro-expanding patterns."
+ \n "It's a special macro meant to be used with 'case'.")
+ [(case (: (List Int)
+ (list +1 +2 +3))
+ (^ (list x y z))
+ (#Some ($_ * x y z))
+
+ _
+ #None)])
+
+(documentation: /.^or
+ (format "Or-patterns."
+ \n "It's a special macro meant to be used with 'case'.")
+ [(type: Weekday
+ (Variant
+ #Monday
+ #Tuesday
+ #Wednesday
+ #Thursday
+ #Friday
+ #Saturday
+ #Sunday))
+
+ (def: (weekend? day)
+ (-> Weekday Bit)
+ (case day
+ (^or #Saturday #Sunday)
+ #1
+
+ _
+ #0))])
+
+(documentation: /.let
+ (format "Creates local bindings."
+ \n "Can (optionally) use pattern-matching macros when binding.")
+ [(let [x (foo bar)
+ y (baz quux)]
+ (op x y))])
+
+(documentation: /.function
+ "Syntax for creating functions."
+ [(: (All [a b]
+ (-> a b a))
+ (function (_ x y)
+ x))]
+ ["Allows for giving the function itself a name, for the sake of recursion."
+ (: (-> Nat Nat)
+ (function (factorial n)
+ (case n
+ 0 1
+ _ (* n (factorial (-- n))))))])
+
+(documentation: /.def:
+ "Defines global constants/functions."
+ [(def: branching_exponent
+ Int
+ +5)]
+ ["The type is optional."
+ (def: branching_exponent
+ +5)]
+ [(def: (pair_list pair)
+ (-> [Code Code] (List Code))
+ (let [[left right] pair]
+ (list left right)))]
+ ["Can pattern-match on the inputs to functions."
+ (def: (pair_list [left right])
+ (-> [Code Code] (List Code))
+ (list left right))])
+
+(documentation: /.macro:
+ "Macro-definition macro."
+ [(macro: .public (name_of tokens)
+ (case tokens
+ (^template [<tag>]
+ [(^ (list [_ (<tag> [module name])]))
+ (in (list (` [(~ (text$ module)) (~ (text$ name))])))])
+ ([#Identifier] [#Tag])
+
+ _
+ (failure "Wrong syntax for name_of")))])
+
+(documentation: /.and
+ "Short-circuiting 'and'."
+ [(and #1 #0)
+ "=>"
+ #0]
+ [(and #1 #1)
+ "=>"
+ #1])
+
+(documentation: /.or
+ "Short-circuiting 'or'."
+ [(or #1 #0)
+ "=>"
+ #1]
+ [(or #0 #0)
+ "=>"
+ #0])
+
+(documentation: /.panic!
+ "Causes an error, with the given error message."
+ [(panic! "OH NO!")])
+
+(documentation: /.implementation
+ "Express a value that implements an interface."
+ [(: (Order Int)
+ (implementation
+ (def: &equivalence
+ equivalence)
+ (def: (< reference subject)
+ (< reference subject))
+ ))])
+
+(documentation: /.implementation:
+ "Interface implementation."
+ [(implementation: .public order
+ (Order Int)
+ (def: &equivalence
+ equivalence)
+ (def: (< test subject)
+ (< test subject)))])
+
+(documentation: /.Variant
+ (format "Syntax for defining labelled/tagged sum/union types."
+ \n "WARNING: Only use it within the type: macro.")
+ [(type: Referrals
+ (Variant
+ #All
+ (#Only (List Text))
+ (#Exclude (List Text))
+ #Ignore
+ #Nothing))])
+
+(documentation: /.Record
+ (format "Syntax for defining labelled/slotted product/tuple types."
+ \n "WARNING: Only use it within the type: macro.")
+ [(type: Refer
+ (Record
+ {#refer_defs Referrals
+ #refer_open (List Openings)}))])
+
+(documentation: /.type:
+ "The type-definition macro."
+ [(type: (List a)
+ #End
+ (#Item a (List a)))])
+
+(documentation: /.interface:
+ "Interface definition."
+ [(interface: .public (Order a)
+ (: (Equivalence a)
+ &equivalence)
+ (: (-> a a Bit)
+ <))])
+
+(.template [<name>]
+ [(documentation: <name>
+ "Safe type-casting for I64 values.")]
+
+ [/.i64]
+ [/.nat]
+ [/.int]
+ [/.rev]
+ )
+
+(documentation: /.module_separator
+ (format "Character used to separate the parts of module names."
+ \n "Value: " (%.text /.module_separator)))
+
+(documentation: /.^open
+ (format "Same as the 'open' macro, but meant to be used as a pattern-matching macro for generating local bindings."
+ \n "Takes an 'alias' text for the generated local bindings.")
+ [(def: .public (range enum from to)
+ (All [a] (-> (Enum a) a a (List a)))
+ (let [(^open ".") enum]
+ (loop [end to
+ output #.End]
+ (cond (< end from)
+ (recur (pred end) (#.Item end output))
+
+ (< from end)
+ (recur (succ end) (#.Item end output))
+
+ ... (= end from)
+ (#.Item end output)))))])
+
+(documentation: /.cond
+ "Conditional branching with multiple test conditions."
+ [(cond (even? num) "WHEN even"
+ (odd? num) "WHEN odd"
+ "ELSE")])
+
+(documentation: /.value@
+ "Accesses the value of a record at a given tag."
+ [(value@ #field my_record)]
+ ["Can also work with multiple levels of nesting."
+ (value@ [#foo #bar #baz] my_record)]
+ ["And, if only the slot/path is given, generates an accessor function."
+ (let [getter (value@ [#foo #bar #baz])]
+ (getter my_record))])
+
+(documentation: /.open:
+ "Opens a implementation and generates a definition for each of its members (including nested members)."
+ [(open: "i:." order)
+ "=>"
+ (def: i:= (\ order =))
+ (def: i:< (\ order <))])
+
+(documentation: /.|>>
+ "Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it."
+ [(|>> (list\each int\encoded)
+ (interposed " ")
+ (mix text\composite ""))
+ "=>"
+ (function (_ <it>)
+ (mix text\composite ""
+ (interposed " "
+ (list\each int\encoded <it>))))])
+
+(documentation: /.<<|
+ "Similar to the reverse piping macro, but rather than taking an initial object to work on, creates a function for taking it."
+ [(<<| (mix text\composite "")
+ (interposed " ")
+ (list\each int\encoded))
+ "=>"
+ (function (_ <it>)
+ (mix text\composite ""
+ (interposed " "
+ (list\each int\encoded
+ <it>))))])
+
+(documentation: /.module:
+ "Module-definition macro."
+ [(.module:
+ [lux #*
+ [control
+ ["M" monad #*]]
+ [data
+ maybe
+ ["." name ("#/." codec)]]
+ [macro
+ code]]
+ [//
+ [type ("." equivalence)]])])
+
+(documentation: /.\
+ "Allows accessing the value of a implementation's member."
+ [(\ codec encoded)]
+ ["Also allows using that value as a function."
+ (\ codec encoded +123)])
+
+(documentation: /.with@
+ "Sets the value of a record at a given tag."
+ [(with@ #name "Lux" lang)]
+ ["Can also work with multiple levels of nesting."
+ (with@ [#foo #bar #baz] value my_record)]
+ ["And, if only the slot/path and (optionally) the value are given, generates a mutator function."
+ (let [setter (with@ [#foo #bar #baz] value)]
+ (setter my_record))
+ (let [setter (with@ [#foo #bar #baz])]
+ (setter value my_record))])
+
+(documentation: /.revised@
+ "Modifies the value of a record at a given tag, based on some function."
+ [(revised@ #age ++ person)]
+ ["Can also work with multiple levels of nesting."
+ (revised@ [#foo #bar #baz] func my_record)]
+ ["And, if only the slot/path and (optionally) the value are given, generates a mutator function."
+ (let [updater (revised@ [#foo #bar #baz] func)]
+ (updater my_record))
+ (let [updater (revised@ [#foo #bar #baz])]
+ (updater func my_record))])
+
+(documentation: /.^template
+ "It's similar to template, but meant to be used during pattern-matching."
+ [(def: (reduced env type)
+ (-> (List Type) Type Type)
+ (case type
+ (#.Primitive name params)
+ (#.Primitive name (list\each (reduced env) params))
+
+ (^template [<tag>]
+ [(<tag> left right)
+ (<tag> (reduced env left) (reduced env right))])
+ ([#.Sum] [#.Product])
+
+ (^template [<tag>]
+ [(<tag> left right)
+ (<tag> (reduced env left) (reduced env right))])
+ ([#.Function] [#.Apply])
+
+ (^template [<tag>]
+ [(<tag> old_env def)
+ (case old_env
+ #.End
+ (<tag> env def)
+
+ _
+ type)])
+ ([#.UnivQ] [#.ExQ])
+
+ (#.Parameter idx)
+ (else type (list.item idx env))
+
+ _
+ type
+ ))])
+
+(.template [<name> <doc>]
+ [(documentation: <name>
+ <doc>)]
+
+ [/.++ "Increment function."]
+ [/.-- "Decrement function."]
+ )
+
+(documentation: /.loop
+ (format "Allows arbitrary looping, using the 'recur' form to re-start the loop."
+ \n "Can be used in monadic code to create monadic loops.")
+ [(loop [count +0
+ x init]
+ (if (< +10 count)
+ (recur (++ count) (f x))
+ x))]
+ ["Loops can also be given custom names."
+ (loop my_loop
+ [count +0
+ x init]
+ (if (< +10 count)
+ (my_loop (++ count) (f x))
+ x))])
+
+(documentation: /.^slots
+ "Allows you to extract record members as local variables with the same names."
+ [(let [(^slots [#foo #bar #baz]) quux]
+ (f foo bar baz))])
+
+(documentation: /.with_expansions
+ (format "Controlled macro-expansion."
+ \n "Bind an arbitraty number of Code nodes resulting from macro-expansion to local bindings."
+ \n "Wherever a binding appears, the bound Code nodes will be spliced in there.")
+ [(def: test
+ Test
+ (with_expansions
+ [<tests> (template [<function> <parameter> <expected>]
+ [(cover [<function>]
+ (compare <text>
+ (\ codec encoded <function> <parameter>)))]
+
+ [bit #1 "#1"]
+ [int +123 "+123"]
+ [frac +123.0 "+123.0"]
+ [text "123" "'123'"]
+ [tag ["yolo" "lol"] "#yolo.lol"]
+ [identifier ["yolo" "lol"] "yolo.lol"]
+ [form (list (bit #1)) "(#1)"]
+ [tuple (list (bit #1)) "[#1]"]
+ [record (list [(bit #1) (int +123)]) "{#1 +123}"]
+ )]
+ ($_ and
+ <tests>
+ )))])
+
+(documentation: /.static
+ (format "Resolves the names of definitions to their values at compile-time, assuming their values are either:"
+ \n "* Bit"
+ \n "* Nat"
+ \n "* Int"
+ \n "* Rev"
+ \n "* Frac"
+ \n "* Text")
+ [(def: my_nat 123)
+ (def: my_text "456")
+ (and (case [my_nat my_text]
+ (^ (static [..my_nat ..my_text]))
+ true
+
+ _
+ false)
+ (case [my_nat my_text]
+ (^ [(static ..my_nat) (static ..my_text)])
+ true
+
+ _
+ false))])
+
+(documentation: /.^multi
+ (format "Multi-level pattern matching."
+ \n "Useful in situations where the result of a branch depends on further refinements on the values being matched.")
+ [(case (split (size static) uri)
+ (^multi (#Some [chunk uri'])
+ {(text\= static chunk) #1})
+ (match_uri endpoint? parts' uri')
+
+ _
+ (#Left (format "Static part " (%t static) " does not match URI: " uri)))]
+ ["Short-cuts can be taken when using bit tests."
+ "The example above can be rewritten as..."
+ (case (split (size static) uri)
+ (^multi (#Some [chunk uri'])
+ (text\= static chunk))
+ (match_uri endpoint? parts' uri')
+
+ _
+ (#Left (format "Static part " (%t static) " does not match URI: " uri)))])
+
+(documentation: /.name_of
+ "Given an identifier or a tag, gives back a 2 tuple with the module and name parts, both as Text."
+ [(name_of #.doc)
+ "=>"
+ ["library/lux" "doc"]])
+
+(documentation: /.:parameter
+ (format "WARNING: Please stay away from this macro; it's very likely to be removed in a future version of Lux."
+ "Allows you to refer to the type-variables in a polymorphic function's type, by their index.")
+ ["In the example below, 0 corresponds to the 'a' variable."
+ (def: .public (of_list list)
+ (All [a] (-> (List a) (Row a)))
+ (list\mix add
+ (: (Row (:parameter 0))
+ empty)
+ list))])
+
+(documentation: /.same?
+ "Tests whether the 2 values are identical (not just 'equal')."
+ ["This one should succeed:"
+ (let [value +5]
+ (same? value
+ value))]
+ ["This one should fail:"
+ (same? +5
+ (+ +2 +3))])
+
+(documentation: /.^@
+ "Allows you to simultaneously bind and de-structure a value."
+ [(def: (hash (^@ set [member_hash _]))
+ (list\mix (function (_ elem acc)
+ (+ acc
+ (\ member_hash hash elem)))
+ 0
+ (set.list set)))])
+
+(documentation: /.^|>
+ "Pipes the value being pattern-matched against prior to binding it to a variable."
+ [(case input
+ (^|> value [++ (% 10) (max 1)])
+ (foo value))])
+
+(documentation: /.:expected
+ "Coerces the given expression to the type of whatever is expected."
+ [(: Dinosaur
+ (:expected (: (List Nat)
+ (list 1 2 3))))])
+
+(documentation: /.undefined
+ (format "Meant to be used as a stand-in for functions with undefined implementations."
+ \n "Undefined expressions will type-check against everything, so they make good dummy implementations."
+ \n "However, if an undefined expression is ever evaluated, it will raise a runtime error.")
+ [(def: (square x)
+ (-> Int Int)
+ (undefined))])
+
+(documentation: /.:of
+ "Generates the type corresponding to a given expression."
+ [(let [my_num +123]
+ (:of my_num))
+ "=="
+ Int]
+ [(:of +123)
+ "=="
+ Int])
+
+(documentation: /.template:
+ (format "Define macros in the style of template and ^template."
+ \n "For simple macros that do not need any fancy features.")
+ [(template: (square x)
+ (* x x))])
+
+(documentation: /.as_is
+ (format "Given a (potentially empty) list of codes, just returns them immediately, without any work done."
+ \n "This may seen useless, but it has its utility when dealing with controlled-macro-expansion macros.")
+ [(with_expansions [<operands> (as_is 1
+ 2
+ 3
+ 4)]
+ ($_ + <operands>))])
+
+(documentation: /.char
+ "If given a 1-character text literal, yields the char-code of the sole character."
+ [(: Nat
+ (char "A"))
+ "=>"
+ 65])
+
+(documentation: /.for
+ (format "Selects the appropriate code for a given target-platform when compiling Lux to it."
+ \n "Look-up the available targets in library/lux/target.")
+ [(def: js "JavaScript")
+ (for {"JVM" (do jvm stuff)
+ ..js (do js stuff)}
+ (do default stuff))])
+
+(documentation: /.``
+ (format "Delimits a controlled (spliced) macro-expansion."
+ \n "Uses a (~~) special form to specify where to expand.")
+ [(`` (some expression
+ (~~ (some macro which may yield 0 or more results))))])
+
+(documentation: /.^code
+ "Generates pattern-matching code for Code values in a way that looks like code-templating."
+ [(: (Maybe Nat)
+ (case (` (#0 123 +456.789))
+ (^code (#0 (~ [_ (#.Nat number)]) +456.789))
+ (#.Some number)
+
+ _
+ #.None))])
+
+(documentation: /.false
+ "The boolean FALSE value.")
+
+(documentation: /.true
+ "The boolean TRUE value.")
+
+(documentation: /.:let
+ "Local bindings for types."
+ [(:let [side (Either Int Frac)]
+ (List [side side]))])
+
+(documentation: /.try
+ ""
+ [(: Foo
+ (case (: (Either Text Bar)
+ (try (: Bar
+ (risky computation which may panic))))
+ (#.Right success)
+ (: Foo
+ (do something after success))
+
+ (#.Left error)
+ (: Foo
+ (recover from error))))])
+
(.def: .public documentation
(.List $.Module)
($.module /._
""
- []
+ [..prelude_module
+ ..Any
+ ..Nothing
+ ..List
+ ..Bit
+ ..I64
+ ..Nat
+ ..Int
+ ..Rev
+ ..Frac
+ ..Text
+ ..Name
+ ..Maybe
+ ..Type
+ ..Location
+ ..Ann
+ ..Code
+ ..private
+ ..local
+ ..public
+ ..global
+ ..Definition
+ ..Global
+ ..Either
+ ..Module
+ ..Mode
+ ..Info
+ ..Lux
+ ..Meta
+ ..Macro
+ ..comment
+ ..All
+ ..Ex
+ ..->
+ ..list
+ ..list&
+ ..Union
+ ..Tuple
+ ..Or
+ ..And
+ .._$
+ ..$_
+ ..if
+ ..primitive
+ ..`
+ ..`'
+ ..'
+ ..|>
+ ..<|
+ ..template
+ ..not
+ ..type
+ ..:
+ ..:as
+ ..Rec
+ ..exec
+ ..case
+ ..^
+ ..^or
+ ..let
+ ..function
+ ..def:
+ ..macro:
+ ..and
+ ..or
+ ..panic!
+ ..implementation
+ ..implementation:
+ ..Variant
+ ..Record
+ ..type:
+ ..interface:
+ ..i64
+ ..nat
+ ..int
+ ..rev
+ ..module_separator
+ ..^open
+ ..cond
+ ..value@
+ ..open:
+ ..|>>
+ ..<<|
+ ..module:
+ ..\
+ ..with@
+ ..revised@
+ ..^template
+ ..++
+ ..--
+ ..loop
+ ..^slots
+ ..with_expansions
+ ..static
+ ..^multi
+ ..name_of
+ ..:parameter
+ ..same?
+ ..^@
+ ..^|>
+ ..:expected
+ ..undefined
+ ..:of
+ ..template:
+ ..as_is
+ ..char
+ ..for
+ ..``
+ ..^code
+ ..false
+ ..true
+ ..:let
+ ..try
+ ($.default /.Code')
+ ($.default /.Alias)
+ ($.default /.Bindings)
+ ($.default /.Ref)
+ ($.default /.Scope)
+ ($.default /.Source)
+ ($.default /.Module_State)
+ ($.default /.Type_Context)
+ ($.default /.Macro')]
[/abstract.documentation
/control.documentation
/data.documentation
/debug.documentation
/documentation.documentation
+ /extension.documentation
/ffi.documentation
/locale.documentation
/macro.documentation
@@ -52,7 +1029,8 @@
/target.documentation
/test.documentation
/time.documentation
- /type.documentation]))
+ /type.documentation
+ /world.documentation]))
(program: inputs
(io.io (debug.log! ($.documentation ..documentation))))
diff --git a/stdlib/source/documentation/lux/control/function/mixin.lux b/stdlib/source/documentation/lux/control/function/mixin.lux
index f23f065b0..d0a8c9667 100644
--- a/stdlib/source/documentation/lux/control/function/mixin.lux
+++ b/stdlib/source/documentation/lux/control/function/mixin.lux
@@ -13,16 +13,16 @@
(documentation: /.Mixin
"A partially-defined function which can be mixed with others to inherit their behavior.")
-(documentation: /.mixin
+(documentation: /.fixed
"Given a mixin, produces a normal function."
- [(mixin f)])
+ [(fixed f)])
(documentation: /.nothing
"A mixin that does nothing and just delegates work to the next mixin.")
-(documentation: /.with
+(documentation: /.mixed
"Produces a new mixin, where the behavior of the child can make use of the behavior of the parent."
- [(with parent child)])
+ [(mixed parent child)])
(documentation: /.advice
"Only apply then mixin when the input meets some criterion."
@@ -48,9 +48,9 @@
($.module /._
""
[..Mixin
- ..mixin
+ ..fixed
..nothing
- ..with
+ ..mixed
..advice
..before
..after
diff --git a/stdlib/source/documentation/lux/data/collection/array.lux b/stdlib/source/documentation/lux/data/collection/array.lux
index e36cba1a8..ce1d461c5 100644
--- a/stdlib/source/documentation/lux/data/collection/array.lux
+++ b/stdlib/source/documentation/lux/data/collection/array.lux
@@ -84,12 +84,10 @@
[(of_list xs)])
(documentation: /.list
- "Yields a list with every non-empty item in the array."
- [(list array)])
-
-(documentation: /.list'
- "Like 'list', but uses the 'default' value when encountering an empty cell in the array."
- [(list' default array)])
+ (format "Yields a list with every non-empty item in the array."
+ \n "Can use the optional default value when encountering an empty cell in the array.")
+ [(list #.None array)
+ (list (#.Some default) array)])
(.def: .public documentation
(.List $.Module)
@@ -113,7 +111,6 @@
..clone
..of_list
..list
- ..list'
($.default /.type_name)
($.default /.equivalence)
($.default /.monoid)
diff --git a/stdlib/source/documentation/lux/data/text.lux b/stdlib/source/documentation/lux/data/text.lux
index 7887d97f6..690eacd4b 100644
--- a/stdlib/source/documentation/lux/data/text.lux
+++ b/stdlib/source/documentation/lux/data/text.lux
@@ -27,9 +27,9 @@
"Yields the character at the specified index."
[(char index input)])
-(documentation: /.index'
+(documentation: /.index_since
""
- [(index' from pattern input)])
+ [(index_since from pattern input)])
(documentation: /.index
""
@@ -75,9 +75,9 @@
"Clips a chunk of text from the input at the specified offset and of the specified size."
[(clip offset size input)])
-(documentation: /.clip'
+(documentation: /.clip_since
"Clips the remaining text from the input at the specified offset."
- [(clip' offset input)])
+ [(clip_since offset input)])
(documentation: /.split_at
""
@@ -114,7 +114,7 @@
[..Char
..line_feed
..char
- ..index'
+ ..index_since
..index
..last_index
..starts_with?
@@ -126,7 +126,7 @@
..enclosed
..enclosed'
..clip
- ..clip'
+ ..clip_since
..split_at
..split_by
..all_split_by
diff --git a/stdlib/source/documentation/lux/extension.lux b/stdlib/source/documentation/lux/extension.lux
new file mode 100644
index 000000000..d5b9836e7
--- /dev/null
+++ b/stdlib/source/documentation/lux/extension.lux
@@ -0,0 +1,62 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ ["." debug]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]
+ [collection
+ ["." row]]]
+ [macro
+ ["." template]]
+ ["@" target
+ ["." jvm]]
+ [tool
+ [compiler
+ ["." phase]
+ [language
+ [lux
+ [phase
+ ["." directive]]]]]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.analysis:
+ "Mechanism for defining extensions to Lux's analysis/type-checking infrastructure."
+ [(analysis: ("my analysis" self phase archive [pass_through <code>.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 <analysis>.any])
+ (phase archive pass_through))])
+
+(documentation: /.generation:
+ ""
+ [(generation: ("my generation" self phase archive [pass_through <synthesis>.any])
+ (for {@.jvm
+ (\ phase.monad each (|>> #jvm.Embedded
+ row.row)
+ (phase archive pass_through))}
+ (phase archive pass_through)))])
+
+(documentation: /.directive:
+ ""
+ [(directive: ("my directive" self phase archive [parameters (<>.some <code>.any)])
+ (do phase.monad
+ [.let [_ (debug.log! (format "Successfully installed directive " (%.text self) "!"))]]
+ (in directive.no_requirements)))])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..analysis:
+ ..synthesis:
+ ..generation:
+ ..directive:]
+ []))
diff --git a/stdlib/source/documentation/lux/math.lux b/stdlib/source/documentation/lux/math.lux
index f41afe130..57b56dec2 100644
--- a/stdlib/source/documentation/lux/math.lux
+++ b/stdlib/source/documentation/lux/math.lux
@@ -34,9 +34,9 @@
""
[(atan/2 x y)])
-(documentation: /.log'
+(documentation: /.log_by
""
- [(log' base it)])
+ [(log_by base it)])
(.def: .public documentation
(.List $.Module)
@@ -47,7 +47,7 @@
..tau
..pow
..atan/2
- ..log'
+ ..log_by
($.default /.cos)
($.default /.sin)
($.default /.tan)
diff --git a/stdlib/source/documentation/lux/type.lux b/stdlib/source/documentation/lux/type.lux
index 0ad9a5f51..25d216dca 100644
--- a/stdlib/source/documentation/lux/type.lux
+++ b/stdlib/source/documentation/lux/type.lux
@@ -1,13 +1,13 @@
(.module:
[library
- [lux (#- and)
+ [lux (#- function :as)
["$" documentation (#+ documentation:)]
[control
["<>" parser
["<.>" code]]]
[data
["." text (#+ \n)
- ["%" format (#+ format)]]]
+ ["%" format]]]
[macro
["." template]]]]
[\\library
@@ -17,27 +17,180 @@
["#." check]
["#." dynamic]
["#." implicit]
- ... ["#." poly]
- ... ["#." quotient]
- ... ["#." refinement]
- ... ["#." resource]
- ... ["#." unit]
- ... ["#." variance]
- ])
+ ["#." poly]
+ ["#." quotient]
+ ["#." refinement]
+ ["#." resource]
+ ["#." unit]
+ ["#." variance]])
+
+(template [<name>]
+ [(documentation: <name>
+ "The number of parameters, and the body, of a quantified type."
+ [(<name> type)])]
+
+ [/.flat_univ_q]
+ [/.flat_ex_q]
+ )
+
+(documentation: /.flat_function
+ "The input, and the output of a function type."
+ [(flat_function type)])
+
+(documentation: /.flat_application
+ "The quantified type, and its parameters, for a type-application."
+ [(flat_application type)])
+
+(template [<name>]
+ [(documentation: <name>
+ "The members of a composite type."
+ [(<name> type)])]
+
+ [/.flat_variant]
+ [/.flat_tuple]
+ )
+
+(documentation: /.format
+ "A (readable) textual representable of a type."
+ [(format type)])
+
+(documentation: /.applied
+ "To the extend possible, applies a quantified type to the given parameters."
+ [(applied params func)])
+
+(documentation: /.code
+ (%.format "A representation of a type as code."
+ \n "The code is such that evaluating it would yield the type value.")
+ [(code type)])
+
+(documentation: /.de_aliased
+ "A (potentially named) type that does not have its name shadowed by other names."
+ [(de_aliased type)])
+
+(documentation: /.anonymous
+ "A type without any names covering it."
+ [(anonymous type)])
+
+(template [<name>]
+ [(documentation: <name>
+ "A composite type, constituted by the given member types."
+ [(<name> types)])]
+
+ [/.variant]
+ [/.tuple]
+ )
+
+(documentation: /.function
+ "A function type, with the given inputs and output."
+ [(function inputs output)])
+
+(documentation: /.application
+ "An un-evaluated type application, with the given quantified type, and parameters."
+ [(application params quant)])
+
+(template [<name>]
+ [(documentation: <name>
+ "A quantified type, with the given number of parameters, and body."
+ [(<name> size body)])]
+
+ [/.univ_q]
+ [/.ex_q]
+ )
+
+(documentation: /.quantified?
+ "Only yields #1 for universally or existentially quantified types."
+ [(quantified? type)])
+
+(documentation: /.array
+ "An array type, with the given level of nesting/depth, and the given element type."
+ [(array depth element_type)])
+
+(documentation: /.flat_array
+ "The level of nesting/depth and element type for an array type."
+ [(flat_array type)])
+
+(documentation: /.array?
+ "Is a type an array type?")
+
+(documentation: /.:log!
+ "Logs to the console/terminal the type of an expression."
+ [(:log! (: Foo (foo expression)))
+ "=>"
+ "Expression: (foo expression)"
+ " Type: Foo"
+ (foo expression)])
+
+(documentation: /.:as
+ (%.format "Casts a value to a specific type."
+ \n "The specified type can depend on type variables of the original type of the value."
+ \n "NOTE: Careless use of type-casts is an easy way to introduce bugs. USE WITH CAUTION.")
+ [(: (Bar Bit Nat Text)
+ (:as [a b c]
+ (Foo a [b c])
+ (Bar a b c)
+ (: (Foo Bit [Nat Text])
+ (foo expression))))])
+
+(documentation: /.:sharing
+ "Allows specifing the type of an expression as sharing type-variables with the type of another expression."
+ [(: (Bar Bit Nat Text)
+ (:sharing [a b c]
+ (Foo a [b c])
+ (: (Foo Bit [Nat Text])
+ (foo expression))
+
+ (Bar a b c)
+ (bar expression)))])
+
+(documentation: /.:by_example
+ "Constructs a type that shares type-variables with an expression of some other type."
+ [(: Type
+ (:by_example [a b c]
+ (Foo a [b c])
+ (: (Foo Bit [Nat Text])
+ (foo expression))
+
+ (Bar a b c)))
+ "=>"
+ (.type (Bar Bit Nat Text))])
(.def: .public documentation
(.List $.Module)
($.module /._
- ""
- []
+ "Basic functionality for working with types."
+ [..flat_univ_q
+ ..flat_ex_q
+ ..flat_function
+ ..flat_application
+ ..flat_variant
+ ..flat_tuple
+ ..format
+ ..applied
+ ..code
+ ..de_aliased
+ ..anonymous
+ ..variant
+ ..tuple
+ ..function
+ ..application
+ ..univ_q
+ ..ex_q
+ ..quantified?
+ ..array
+ ..flat_array
+ ..array?
+ ..:log!
+ ..:as
+ ..:sharing
+ ..:by_example
+ ($.default /.equivalence)]
[/abstract.documentation
/check.documentation
/dynamic.documentation
/implicit.documentation
- ... /poly.documentation
- ... /quotient.documentation
- ... /refinement.documentation
- ... /resource.documentation
- ... /unit.documentation
- ... /variance.documentation
- ]))
+ /poly.documentation
+ /quotient.documentation
+ /refinement.documentation
+ /resource.documentation
+ /unit.documentation
+ /variance.documentation]))
diff --git a/stdlib/source/documentation/lux/type/check.lux b/stdlib/source/documentation/lux/type/check.lux
index 3264a87a3..f6f8db6f0 100644
--- a/stdlib/source/documentation/lux/type/check.lux
+++ b/stdlib/source/documentation/lux/type/check.lux
@@ -91,6 +91,6 @@
($.default /.apply)
($.default /.monad)
($.default /.bound?)
- ($.default /.read')
+ ($.default /.peek)
($.default /.read)]
[]))
diff --git a/stdlib/source/documentation/lux/type/poly.lux b/stdlib/source/documentation/lux/type/poly.lux
new file mode 100644
index 000000000..47ea08837
--- /dev/null
+++ b/stdlib/source/documentation/lux/type/poly.lux
@@ -0,0 +1,72 @@
+(.module:
+ [library
+ [lux (#- and)
+ ["$" documentation (#+ documentation:)]
+ [abstract
+ [\\specification
+ ["$." equivalence]
+ ["$." codec]]]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.derived:
+ ""
+ [(type: Variant
+ (.Variant
+ (#Bit Bit)
+ (#Text Text)
+ (#Frac Frac)))
+
+ (type: #rec Recursive
+ (.Variant
+ (#Number Frac)
+ (#Addition Frac Recursive)))
+
+ (type: Record
+ (.Record
+ {#bit Bit
+ #frac Frac
+ #text Text
+ #maybe (Maybe Frac)
+ #list (List Frac)
+ #dictionary (Dictionary Text Frac)
+ #variant Variant
+ #tuple [Bit Text Frac]
+ #recursive Recursive
+ #date Date
+ #grams (Qty Gram)}))
+
+ (derived: equivalence
+ ($equivalence.equivalence
+ Record))
+
+ (: (Equivalence Record)
+ equivalence)
+
+ (derived: codec
+ ($codec.codec
+ Record))
+
+ (: (Codec Json Record)
+ codec)])
+
+(documentation: /.code
+ ""
+ [(code env type)])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..derived:
+ ..code
+ ($.default /.poly:)]
+ []))
diff --git a/stdlib/source/documentation/lux/type/quotient.lux b/stdlib/source/documentation/lux/type/quotient.lux
new file mode 100644
index 000000000..51b9db079
--- /dev/null
+++ b/stdlib/source/documentation/lux/type/quotient.lux
@@ -0,0 +1,52 @@
+(.module:
+ [library
+ [lux (#- type)
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Class
+ "The class knows how to classify/label values that are meant to be equivalent to one another.")
+
+(documentation: /.Quotient
+ (format "A quotient value has been labeled with a class."
+ \n "All equivalent values will belong to the same class."
+ \n "This means all equivalent values possess the same label."))
+
+(documentation: /.quotient
+ ""
+ [(quotient class value)])
+
+(documentation: /.type
+ "The Quotient type associated with a Class type."
+ [(def: even
+ (class even?))
+
+ (def: Even
+ Type
+ (type even))
+
+ (: Even
+ (quotient even 123))])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Class
+ ..Quotient
+ ..quotient
+ ..type
+ ($.default /.class)
+ ($.default /.value)
+ ($.default /.label)
+ ($.default /.equivalence)]
+ []))
diff --git a/stdlib/source/documentation/lux/type/refinement.lux b/stdlib/source/documentation/lux/type/refinement.lux
new file mode 100644
index 000000000..eb7c4b902
--- /dev/null
+++ b/stdlib/source/documentation/lux/type/refinement.lux
@@ -0,0 +1,64 @@
+(.module:
+ [library
+ [lux (#- type)
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Refined
+ "A refined version of another type, using a predicate to select valid instances.")
+
+(documentation: /.Refiner
+ "A selection mechanism for refined instances of a type.")
+
+(documentation: /.refiner
+ ""
+ [(refiner predicate)])
+
+(documentation: /.lifted
+ (format "Yields a function that can work on refined values."
+ \n "Respects the constraints of the refinement.")
+ [(lifted transform)])
+
+(documentation: /.only
+ ""
+ [(only refiner values)])
+
+(documentation: /.partition
+ "Separates refined values from the un-refined ones."
+ [(partition refiner values)])
+
+(documentation: /.type
+ "The Refined type associated with a Refiner type."
+ [(def: even
+ (refiner even?))
+
+ (def: Even
+ Type
+ (type even))
+
+ (: (Maybe Even)
+ (even 123))])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Refined
+ ..Refiner
+ ..refiner
+ ..lifted
+ ..only
+ ..partition
+ ..type
+ ($.default /.value)
+ ($.default /.predicate)]
+ []))
diff --git a/stdlib/source/documentation/lux/type/resource.lux b/stdlib/source/documentation/lux/type/resource.lux
new file mode 100644
index 000000000..653cac853
--- /dev/null
+++ b/stdlib/source/documentation/lux/type/resource.lux
@@ -0,0 +1,118 @@
+(.module:
+ [library
+ [lux (#- and)
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Procedure
+ (format "A computation that takes a sequence of resource access rights as inputs and yields a different sequence as outputs."
+ \n "A procedure yields a result value."
+ \n "A procedure can make use of monadic effects."))
+
+(documentation: /.Linear
+ (format "A procedure that is constant with regards to resource access rights."
+ \n "This means no additional resources will be available after the computation is over."
+ \n "This also means no previously available resources will have been consumed."))
+
+(documentation: /.Affine
+ "A procedure which expands the number of available resources.")
+
+(documentation: /.Relevant
+ "A procedure which reduces the number of available resources.")
+
+(documentation: /.run!
+ ""
+ [(run! monad procedure)])
+
+(documentation: /.lifted
+ ""
+ [(lifted monad procedure)])
+
+(documentation: /.Ordered
+ "The mode of keys which CANNOT be swapped, and for whom order of release/consumption matters.")
+
+(documentation: /.Commutative
+ "The mode of keys which CAN be swapped, and for whom order of release/consumption DOES NOT matters.")
+
+(documentation: /.Key
+ (format "The access right for a resource."
+ \n "Without the key for a resource existing somewhere among the available ambient rights, one cannot use a resource."))
+
+(documentation: /.Res
+ (format "A resource locked by a key."
+ \n "The 'key' represents the right to access/consume a resource."))
+
+(template [<name>]
+ [(documentation: <name>
+ "Makes a value into a resource and adds the key/access-right to it to the ambient keyring for future use."
+ [(<name> monad value)])]
+
+ [/.ordered]
+ [/.commutative]
+ )
+
+(documentation: /.read
+ "Access the value of a resource, so long as its key is available."
+ [(read monad resource)])
+
+(documentation: /.exchange
+ (format "A function that can exchange the keys for resource, so long as they are commutative."
+ \n "This keys will be placed at the front of the keyring in the order they are specified."
+ \n "The specific keys must be specified based of their index into the current keyring.")
+ [(do (monad !)
+ [res|left (commutative ! pre)
+ res|right (commutative ! post)
+ _ ((exchange [1 0]) !)
+ left (read ! res|left)
+ right (read ! res|right)]
+ (in (format left right)))])
+
+(template [<name>]
+ [(documentation: <name>
+ "Group/un-group keys in the keyring into/out-of tuples."
+ [(do (monad !)
+ [res|left (commutative ! pre)
+ res|right (commutative ! post)
+ _ ((group 2) !)
+ _ ((un_group 2) !)
+ right (read ! res|right)
+ left (read ! res|left)]
+ (in (format left right)))])]
+
+ [/.group]
+ [/.un_group]
+ )
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Procedure
+ ..Linear
+ ..Affine
+ ..Relevant
+ ..run!
+ ..lifted
+ ..Ordered
+ ..Commutative
+ ..Key
+ ..Res
+ ..ordered
+ ..commutative
+ ..read
+ ..exchange
+ ..group
+ ..un_group
+ ($.default /.monad)
+ ($.default /.index_cannot_be_repeated)
+ ($.default /.amount_cannot_be_zero)]
+ []))
diff --git a/stdlib/source/documentation/lux/type/unit.lux b/stdlib/source/documentation/lux/type/unit.lux
new file mode 100644
index 000000000..b33a797c6
--- /dev/null
+++ b/stdlib/source/documentation/lux/type/unit.lux
@@ -0,0 +1,117 @@
+(.module:
+ [library
+ [lux (#- and)
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]
+ [math
+ [number
+ ["." ratio]]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Qty
+ "A quantity with an associated unit of measurement.")
+
+(template [<name>]
+ [(documentation: <name>
+ ""
+ [(<name> param subject)])]
+
+ [/.+]
+ [/.-]
+ [/.*]
+ [/./]
+ )
+
+(documentation: /.Unit
+ "A unit of measurement, to qualify numbers with.")
+
+(documentation: /.Scale
+ "A scale of magnitude.")
+
+(documentation: /.Pure
+ "A pure, unit-less quantity.")
+
+(documentation: /.unit:
+ (format "Define a unit of measurement."
+ \n "Both the name of the type, and the name of the Unit implementation must be specified.")
+ [(unit: .public Feet feet)])
+
+(documentation: /.scale:
+ "Define a scale of magnitude."
+ [(scale: .public Bajillion bajillion
+ [1 1,234,567,890])])
+
+(documentation: /.re_scaled
+ ""
+ [(re_scaled from to quantity)])
+
+(template [<type> <scale>]
+ [(`` (documentation: <scale>
+ (let [numerator (value@ [#/.ratio #ratio.numerator] <scale>)
+ denominator (value@ [#/.ratio #ratio.denominator] <scale>)]
+ (format "'" (~~ (template.text [<type>])) "' scale from " (%.nat numerator) " to " (%.nat denominator) "."))))]
+
+ [/.Kilo /.kilo]
+ [/.Mega /.mega]
+ [/.Giga /.giga]
+
+ [/.Milli /.milli]
+ [/.Micro /.micro]
+ [/.Nano /.nano]
+ )
+
+(template [<type>]
+ [(`` (documentation: <type>
+ (format "'" (~~ (template.text [<type>])) "' unit of meaurement.")))]
+
+ [/.Gram]
+ [/.Meter]
+ [/.Litre]
+ [/.Second]
+ )
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Qty
+ ..+
+ ..-
+ ..*
+ ../
+ ..Unit
+ ..Scale
+ ..Pure
+ ..unit:
+ ..scale:
+ ..re_scaled
+ ..kilo
+ ..mega
+ ..giga
+ ..milli
+ ..micro
+ ..nano
+ ..Gram
+ ..Meter
+ ..Litre
+ ..Second
+ ($.default /.pure)
+ ($.default /.number)
+ ($.default /.equivalence)
+ ($.default /.order)
+ ($.default /.enum)
+ ($.default /.Kilo)
+ ($.default /.Mega)
+ ($.default /.Giga)
+ ($.default /.Milli)
+ ($.default /.Micro)
+ ($.default /.Nano)]
+ []))
diff --git a/stdlib/source/documentation/lux/type/variance.lux b/stdlib/source/documentation/lux/type/variance.lux
new file mode 100644
index 000000000..7503f9197
--- /dev/null
+++ b/stdlib/source/documentation/lux/type/variance.lux
@@ -0,0 +1,32 @@
+(.module:
+ [library
+ [lux (#- and)
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Co
+ "A constraint for covariant types.")
+
+(documentation: /.Contra
+ "A constraint for contravariant types.")
+
+(documentation: /.In
+ "A constraint for invariant types.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Co
+ ..Contra
+ ..In]
+ []))
diff --git a/stdlib/source/documentation/lux/world.lux b/stdlib/source/documentation/lux/world.lux
new file mode 100644
index 000000000..834c8cdd5
--- /dev/null
+++ b/stdlib/source/documentation/lux/world.lux
@@ -0,0 +1,33 @@
+(.module:
+ [library
+ [lux #*
+ [program (#+ program:)]
+ ["$" documentation (#+ documentation:)]
+ ["." debug]
+ [control
+ ["." io]]
+ [data
+ [collection
+ ["." list ("#\." monoid)]]]]]
+ ["." / #_
+ ["#." console]
+ ["#." file]
+ ["#." input #_
+ ["#/." keyboard]]
+ ["#." net]
+ ["#." output #_
+ ["#/." video #_
+ ["#/." resolution]]]
+ ["#." program]
+ ["#." shell]])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($_ list\composite
+ /console.documentation
+ /file.documentation
+ /input/keyboard.documentation
+ /net.documentation
+ /output/video/resolution.documentation
+ /program.documentation
+ /shell.documentation))
diff --git a/stdlib/source/documentation/lux/world/console.lux b/stdlib/source/documentation/lux/world/console.lux
new file mode 100644
index 000000000..80841123d
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/console.lux
@@ -0,0 +1,43 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Console
+ "An interface to console/terminal I/O.")
+
+(documentation: /.write_line
+ "Writes the message on the console and appends a new-line/line-feed at the end."
+ [(write_line message console)])
+
+(documentation: /.Mock
+ (format "A mock/simulation of a console."
+ \n "Useful for testing."))
+
+(documentation: /.mock
+ ""
+ [(mock mock init)])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Console
+ ..write_line
+ ..Mock
+ ..mock
+ ($.default /.async)
+ ($.default /.cannot_open)
+ ($.default /.cannot_close)
+ ($.default /.default)]
+ []))
diff --git a/stdlib/source/documentation/lux/world/file.lux b/stdlib/source/documentation/lux/world/file.lux
new file mode 100644
index 000000000..06596ef56
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/file.lux
@@ -0,0 +1,76 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]]
+ ["." / #_
+ ["#." watch]])
+
+(documentation: /.Path
+ "A path to a file or a directory in a file-system.")
+
+(documentation: /.System
+ "An interface to a file-system.")
+
+(documentation: /.parent
+ "If a path represents a nested file/directory, extracts its parent directory."
+ [(parent fs path)])
+
+(documentation: /.name
+ "The un-nested name of a file/directory."
+ [(name fs path)])
+
+(documentation: /.rooted
+ "A nested path for a file/directory, given a root/parent path and a file/directory name within it."
+ [(rooted fs parent child)])
+
+(documentation: /.exists?
+ "Checks if either a file or a directory exists at the given path."
+ [(exists? monad fs path)])
+
+(documentation: /.mock
+ (format "A purely in-memory simulation of a file-system."
+ \n "Useful for testing.")
+ [(mock separator)])
+
+(documentation: /.make_directories
+ (format "Creates the directory specified by the given path."
+ \n "Also, creates every super-directory necessary to make the given path valid.")
+ [(make_directories monad fs path)])
+
+(documentation: /.make_file
+ "Creates a new file with the given content if-and-only-if the file does not already exist."
+ [(make_file monad fs content path)])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Path
+ ..System
+ ..parent
+ ..name
+ ..rooted
+ ..exists?
+ ..mock
+ ..make_directories
+ ..make_file
+ ($.default /.async)
+ ($.default /.cannot_make_file)
+ ($.default /.cannot_find_file)
+ ($.default /.cannot_delete)
+ ($.default /.cannot_make_directory)
+ ($.default /.cannot_find_directory)
+ ($.default /.cannot_read_all_data)
+ ($.default /.cannot_modify_file)
+ ($.default /.default)]
+ [/watch.documentation]))
diff --git a/stdlib/source/documentation/lux/world/file/watch.lux b/stdlib/source/documentation/lux/world/file/watch.lux
new file mode 100644
index 000000000..e310d8d2d
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/file/watch.lux
@@ -0,0 +1,58 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Concern
+ "A particular concern to watch-out for.")
+
+(documentation: /.also
+ ""
+ [(also left right)])
+
+(documentation: /.Watcher
+ "Machinery for watching a file-system for changes to files and directories.")
+
+(documentation: /.polling
+ (format "A simple watcher that works for any file-system."
+ "Polls files and directories to detect changes.")
+ [(polling fs)])
+
+(documentation: /.mock
+ (format "A fake/emulated watcher."
+ \n "Must be given a path separator for the file-system.")
+ [(mock separator)])
+
+(documentation: /.default
+ "The default watcher for the default file-system.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Concern
+ ..also
+ ..Watcher
+ ..polling
+ ..mock
+ ..default
+ ($.default /.creation)
+ ($.default /.creation?)
+ ($.default /.modification)
+ ($.default /.modification?)
+ ($.default /.deletion)
+ ($.default /.deletion?)
+ ($.default /.all)
+ ($.default /.not_being_watched)
+ ($.default /.cannot_poll_a_non_existent_directory)]
+ []))
diff --git a/stdlib/source/documentation/lux/world/input/keyboard.lux b/stdlib/source/documentation/lux/world/input/keyboard.lux
new file mode 100644
index 000000000..8c63ade98
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/input/keyboard.lux
@@ -0,0 +1,112 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Key
+ "A key from a keyboard, identify by a numeric ID.")
+
+(documentation: /.Press
+ "A key-press for a key.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Key
+ ..Press
+ ($.default /.back_space)
+ ($.default /.enter)
+ ($.default /.shift)
+ ($.default /.control)
+ ($.default /.alt)
+ ($.default /.caps_lock)
+ ($.default /.escape)
+ ($.default /.space)
+ ($.default /.page_up)
+ ($.default /.page_down)
+ ($.default /.end)
+ ($.default /.home)
+ ($.default /.left)
+ ($.default /.up)
+ ($.default /.right)
+ ($.default /.down)
+ ($.default /.a)
+ ($.default /.b)
+ ($.default /.c)
+ ($.default /.d)
+ ($.default /.e)
+ ($.default /.f)
+ ($.default /.g)
+ ($.default /.h)
+ ($.default /.i)
+ ($.default /.j)
+ ($.default /.k)
+ ($.default /.l)
+ ($.default /.m)
+ ($.default /.n)
+ ($.default /.o)
+ ($.default /.p)
+ ($.default /.q)
+ ($.default /.r)
+ ($.default /.s)
+ ($.default /.t)
+ ($.default /.u)
+ ($.default /.v)
+ ($.default /.w)
+ ($.default /.x)
+ ($.default /.y)
+ ($.default /.z)
+ ($.default /.num_pad_0)
+ ($.default /.num_pad_1)
+ ($.default /.num_pad_2)
+ ($.default /.num_pad_3)
+ ($.default /.num_pad_4)
+ ($.default /.num_pad_5)
+ ($.default /.num_pad_6)
+ ($.default /.num_pad_7)
+ ($.default /.num_pad_8)
+ ($.default /.num_pad_9)
+ ($.default /.delete)
+ ($.default /.num_lock)
+ ($.default /.scroll_lock)
+ ($.default /.print_screen)
+ ($.default /.insert)
+ ($.default /.windows)
+ ($.default /.f1)
+ ($.default /.f2)
+ ($.default /.f3)
+ ($.default /.f4)
+ ($.default /.f5)
+ ($.default /.f6)
+ ($.default /.f7)
+ ($.default /.f8)
+ ($.default /.f9)
+ ($.default /.f10)
+ ($.default /.f11)
+ ($.default /.f12)
+ ($.default /.f13)
+ ($.default /.f14)
+ ($.default /.f15)
+ ($.default /.f16)
+ ($.default /.f17)
+ ($.default /.f18)
+ ($.default /.f19)
+ ($.default /.f20)
+ ($.default /.f21)
+ ($.default /.f22)
+ ($.default /.f23)
+ ($.default /.f24)
+ ($.default /.release)
+ ($.default /.press)]
+ []))
diff --git a/stdlib/source/documentation/lux/world/net.lux b/stdlib/source/documentation/lux/world/net.lux
new file mode 100644
index 000000000..f6247b2e2
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/net.lux
@@ -0,0 +1,36 @@
+(.module:
+ [library
+ [lux #*
+ [program (#+ program:)]
+ ["$" documentation (#+ documentation:)]
+ ["." debug]
+ [control
+ ["." io]]]]
+ [\\library
+ ["." /]]
+ ["." / #_
+ ["#." uri]
+ ["#." http #_
+ ["#/." client]
+ ["#/." status]]])
+
+(documentation: /.Address
+ "A TCP/IP address.")
+
+(documentation: /.Port
+ "A TCP/IP port.")
+
+(documentation: /.URL
+ "A Uniform Resource Locator.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Address
+ ..Port
+ ..URL
+ ($.default /.Location)]
+ [/uri.documentation
+ /http/client.documentation
+ /http/status.documentation]))
diff --git a/stdlib/source/documentation/lux/world/net/http/client.lux b/stdlib/source/documentation/lux/world/net/http/client.lux
new file mode 100644
index 000000000..3534ebc6a
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/net/http/client.lux
@@ -0,0 +1,54 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Client
+ "A HTTP client capable of issuing requests to a HTTP server.")
+
+(template [<name>]
+ [(documentation: <name>
+ (format "A " (text.upper_cased (template.text [<name>])) " request."))]
+
+ [/.post]
+ [/.get]
+ [/.put]
+ [/.patch]
+ [/.delete]
+ [/.head]
+ [/.connect]
+ [/.options]
+ [/.trace]
+ [/.default]
+ [/.async]
+ [/.headers]
+ )
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Client
+ ..post
+ ..get
+ ..put
+ ..patch
+ ..delete
+ ..head
+ ..connect
+ ..options
+ ..trace
+ ..default
+ ..async
+ ..headers]
+ []))
diff --git a/stdlib/source/documentation/lux/world/net/http/status.lux b/stdlib/source/documentation/lux/world/net/http/status.lux
new file mode 100644
index 000000000..f0623b88d
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/net/http/status.lux
@@ -0,0 +1,171 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(template [<name>]
+ [(documentation: <name>
+ (|> (template.text [<name>])
+ (text.replaced "_" " ")
+ text.upper_cased
+ (format (%.nat <name>) ": ")))]
+
+ ... 1xx Informational response
+ [/.continue]
+ [/.switching_protocols]
+ [/.processing]
+ [/.early_hints]
+
+ ... 2xx Success
+ [/.ok]
+ [/.created]
+ [/.accepted]
+ [/.non_authoritative_information]
+ [/.no_content]
+ [/.reset_content]
+ [/.partial_content]
+ [/.multi_status]
+ [/.already_reported]
+ [/.im_used]
+
+ ... 3xx Redirection
+ [/.multiple_choices]
+ [/.moved_permanently]
+ [/.found]
+ [/.see_other]
+ [/.not_modified]
+ [/.use_proxy]
+ [/.switch_proxy]
+ [/.temporary_redirect]
+ [/.permanent_redirect]
+
+ ... 4xx Client errors
+ [/.bad_request]
+ [/.unauthorized]
+ [/.payment_required]
+ [/.forbidden]
+ [/.not_found]
+ [/.method_not_allowed]
+ [/.not_acceptable]
+ [/.proxy_authentication_required]
+ [/.request_timeout]
+ [/.conflict]
+ [/.gone]
+ [/.length_required]
+ [/.precondition_failed]
+ [/.payload_too_large]
+ [/.uri_too_long]
+ [/.unsupported_media_type]
+ [/.range_not_satisfiable]
+ [/.expectation_failed]
+ [/.im_a_teapot]
+ [/.misdirected_request]
+ [/.unprocessable_entity]
+ [/.locked]
+ [/.failed_dependency]
+ [/.upgrade_required]
+ [/.precondition_required]
+ [/.too_many_requests]
+ [/.request_header_fields_too_large]
+ [/.unavailable_for_legal_reasons]
+
+ ... 5xx Server errors
+ [/.internal_server_error]
+ [/.not_implemented]
+ [/.bad_gateway]
+ [/.service_unavailable]
+ [/.gateway_timeout]
+ [/.http_version_not_supported]
+ [/.variant_also_negotiates]
+ [/.insufficient_storage]
+ [/.loop_detected]
+ [/.not_extended]
+ [/.network_authentication_required]
+ )
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [ ... 1xx Informational response
+ ..continue
+ ..switching_protocols
+ ..processing
+ ..early_hints
+
+ ... 2xx Success
+ ..ok
+ ..created
+ ..accepted
+ ..non_authoritative_information
+ ..no_content
+ ..reset_content
+ ..partial_content
+ ..multi_status
+ ..already_reported
+ ..im_used
+
+ ... 3xx Redirection
+ ..multiple_choices
+ ..moved_permanently
+ ..found
+ ..see_other
+ ..not_modified
+ ..use_proxy
+ ..switch_proxy
+ ..temporary_redirect
+ ..permanent_redirect
+
+ ... 4xx Client errors
+ ..bad_request
+ ..unauthorized
+ ..payment_required
+ ..forbidden
+ ..not_found
+ ..method_not_allowed
+ ..not_acceptable
+ ..proxy_authentication_required
+ ..request_timeout
+ ..conflict
+ ..gone
+ ..length_required
+ ..precondition_failed
+ ..payload_too_large
+ ..uri_too_long
+ ..unsupported_media_type
+ ..range_not_satisfiable
+ ..expectation_failed
+ ..im_a_teapot
+ ..misdirected_request
+ ..unprocessable_entity
+ ..locked
+ ..failed_dependency
+ ..upgrade_required
+ ..precondition_required
+ ..too_many_requests
+ ..request_header_fields_too_large
+ ..unavailable_for_legal_reasons
+
+ ... 5xx Server errors
+ ..internal_server_error
+ ..not_implemented
+ ..bad_gateway
+ ..service_unavailable
+ ..gateway_timeout
+ ..http_version_not_supported
+ ..variant_also_negotiates
+ ..insufficient_storage
+ ..loop_detected
+ ..not_extended
+ ..network_authentication_required]
+ []))
diff --git a/stdlib/source/documentation/lux/world/net/uri.lux b/stdlib/source/documentation/lux/world/net/uri.lux
new file mode 100644
index 000000000..710bf4b7c
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/net/uri.lux
@@ -0,0 +1,24 @@
+(.module:
+ [library
+ [lux #*
+ [program (#+ program:)]
+ ["$" documentation (#+ documentation:)]
+ ["." debug]
+ [control
+ ["." io]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.URI
+ "A Uniform Resource Identifier.")
+
+(documentation: /.separator
+ "A separator for the pieces of a URI.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..URI
+ ..separator]
+ []))
diff --git a/stdlib/source/documentation/lux/world/output/video/resolution.lux b/stdlib/source/documentation/lux/world/output/video/resolution.lux
new file mode 100644
index 000000000..6425902c8
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/output/video/resolution.lux
@@ -0,0 +1,69 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Resolution
+ "A screen resolution.")
+
+(template [<name>]
+ [(documentation: <name>
+ (let [name (|> (template.text [<name>])
+ (text.replaced "/" " ")
+ (text.replaced "_" " ")
+ text.upper_cased)]
+ (format name " resolution: "
+ (%.nat (value@ #/.width <name>))
+ "x" (%.nat (value@ #/.height <name>))
+ ".")))]
+
+ [/.svga]
+ [/.wsvga]
+ [/.xga]
+ [/.xga+]
+ [/.wxga/16:9]
+ [/.wxga/5:3]
+ [/.wxga/16:10]
+ [/.sxga]
+ [/.wxga+]
+ [/.hd+]
+ [/.wsxga+]
+ [/.fhd]
+ [/.wuxga]
+ [/.wqhd]
+ [/.uhd_4k]
+ )
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Resolution
+ ..svga
+ ..wsvga
+ ..xga
+ ..xga+
+ ..wxga/16:9
+ ..wxga/5:3
+ ..wxga/16:10
+ ..sxga
+ ..wxga+
+ ..hd+
+ ..wsxga+
+ ..fhd
+ ..wuxga
+ ..wqhd
+ ..uhd_4k
+ ($.default /.hash)
+ ($.default /.equivalence)]
+ []))
diff --git a/stdlib/source/documentation/lux/world/program.lux b/stdlib/source/documentation/lux/world/program.lux
new file mode 100644
index 000000000..d61db573b
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/program.lux
@@ -0,0 +1,37 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Program
+ "Access to ambient program data and the capacity to exit the program.")
+
+(documentation: /.environment
+ "Assembles the environment variables available to the program."
+ [(environment monad program)])
+
+(documentation: /.mock
+ ""
+ [(mock environment home directory)])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Program
+ ..environment
+ ..mock
+ ($.default /.unknown_environment_variable)
+ ($.default /.async)
+ ($.default /.default)]
+ []))
diff --git a/stdlib/source/documentation/lux/world/shell.lux b/stdlib/source/documentation/lux/world/shell.lux
new file mode 100644
index 000000000..43264c503
--- /dev/null
+++ b/stdlib/source/documentation/lux/world/shell.lux
@@ -0,0 +1,54 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [control
+ ["<>" parser
+ ["<.>" code]]]
+ [data
+ ["." text (#+ \n)
+ ["%" format (#+ format)]]]
+ [macro
+ ["." template]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Exit
+ "A program exit code.")
+
+(documentation: /.Process
+ "The means for communicating with a program/process being executed by the operating system.")
+
+(documentation: /.Command
+ "A command that can be executed by the operating system.")
+
+(documentation: /.Argument
+ "A parameter for a command.")
+
+(documentation: /.Shell
+ "The means for issuing commands to the operating system.")
+
+(documentation: /.Mock
+ "A simulated process.")
+
+(documentation: /.mock
+ ""
+ [(mock mock init)])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..Exit
+ ..Process
+ ..Command
+ ..Argument
+ ..Shell
+ ..Mock
+ ..mock
+ ($.default /.normal)
+ ($.default /.error)
+ ($.default /.async)
+ ($.default /.no_more_output)
+ ($.default /.default)]
+ []))
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 9770f131c..389635abc 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -13,11 +13,6 @@
[dummy_location (9 #1 (0 #0))]
#0)
-("lux def" __paragraph
- ("lux text concat" \n \n)
- [dummy_location (9 #1 (0 #0))]
- #0)
-
("lux def" prelude_module
"library/lux"
[dummy_location (9 #1 (0 #0))]
@@ -30,11 +25,7 @@
(9 #1 ["library/lux" "Any"]
(8 #0 (0 #0) (4 #0 1))))
[dummy_location
- (9 #1 (0 #1 [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 ("lux text concat"
- ("lux text concat" "The type of things whose type is irrelevant." __paragraph)
- "It can be used to write functions or data-structures that can take, or return, anything."))]]
- (0 #0)))]
+ (9 #1 (0 #0))]
#1)
... (type: .public Nothing
@@ -44,11 +35,7 @@
(9 #1 ["library/lux" "Nothing"]
(7 #0 (0 #0) (4 #0 1))))
[dummy_location
- (9 #1 (0 #1 [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 ("lux text concat"
- ("lux text concat" "The type of things whose type is undefined." __paragraph)
- "Useful for expressions that cause errors or other 'extraordinary' conditions."))]]
- (0 #0)))]
+ (9 #1 (0 #0))]
#1)
... (type: .public (List a)
@@ -65,9 +52,7 @@
[dummy_location
(9 #1 (0 #1 [[dummy_location (7 #0 ["library/lux" "type_args"])]
[dummy_location (9 #0 (0 #1 [dummy_location (5 #0 "a")] (0 #0)))]]
- (0 #1 [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "A potentially empty list of values.")]]
- (0 #0))))]
+ (0 #0)))]
["End" "Item"]
#1)
@@ -76,9 +61,7 @@
(9 #1 ["library/lux" "Bit"]
(0 #0 "#Bit" #End)))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "Your standard, run-of-the-mill boolean values (as bits).")]]
- #End))]
+ (9 #1 #End)]
#1)
("lux def" I64
@@ -87,9 +70,7 @@
(7 #0 (0 #0)
(0 #0 "#I64" (#Item (4 #0 1) #End)))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "64-bit integers without any semantics.")]]
- #End))]
+ (9 #1 #End)]
#1)
("lux def" Nat
@@ -97,11 +78,7 @@
(9 #1 ["library/lux" "Nat"]
(0 #0 "#I64" (#Item (0 #0 "#Nat" #End) #End))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 ("lux text concat"
- ("lux text concat" "Natural numbers (unsigned integers)." __paragraph)
- "They start at zero (0) and extend in the positive direction."))]]
- #End))]
+ (9 #1 #End)]
#1)
("lux def" Int
@@ -109,9 +86,7 @@
(9 #1 ["library/lux" "Int"]
(0 #0 "#I64" (#Item (0 #0 "#Int" #End) #End))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "Your standard, run-of-the-mill integer numbers.")]]
- #End))]
+ (9 #1 #End)]
#1)
("lux def" Rev
@@ -119,11 +94,7 @@
(9 #1 ["library/lux" "Rev"]
(0 #0 "#I64" (#Item (0 #0 "#Rev" #End) #End))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 ("lux text concat"
- ("lux text concat" "Fractional numbers that live in the interval [0,1)." __paragraph)
- "Useful for probability, and other domains that work within that interval."))]]
- #End))]
+ (9 #1 #End)]
#1)
("lux def" Frac
@@ -131,9 +102,7 @@
(9 #1 ["library/lux" "Frac"]
(0 #0 "#Frac" #End)))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "Your standard, run-of-the-mill floating-point (fractional) numbers.")]]
- #End))]
+ (9 #1 #End)]
#1)
("lux def" Text
@@ -141,9 +110,7 @@
(9 #1 ["library/lux" "Text"]
(0 #0 "#Text" #End)))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "Your standard, run-of-the-mill string values.")]]
- #End))]
+ (9 #1 #End)]
#1)
("lux def" Name
@@ -151,9 +118,7 @@
(9 #1 ["library/lux" "Name"]
(2 #0 Text Text)))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "A name. It is used as part of Lux syntax to represent identifiers and tags.")]]
- #End))]
+ (9 #1 #End)]
#1)
... (type: .public (Maybe a)
@@ -169,9 +134,7 @@
[dummy_location
(9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])]
[dummy_location (9 #0 (#Item [dummy_location (5 #0 "a")] #End))]]
- (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "A potentially missing value.")]]
- #End)))]
+ #End))]
["None" "Some"]
#1)
@@ -231,11 +194,9 @@
("lux type check type" (9 #0 Type List)))}
("lux type check type" (9 #0 (4 #0 1) (4 #0 0)))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "This type represents the data-structures that are used to specify types themselves.")]]
- (#Item [[dummy_location (7 #0 ["library/lux" "type_rec?"])]
- [dummy_location (0 #0 #1)]]
- #End)))]
+ (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_rec?"])]
+ [dummy_location (0 #0 #1)]]
+ #End))]
["Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"]
#1)
@@ -247,9 +208,7 @@
(#Named ["library/lux" "Location"]
(#Product Text (#Product Nat Nat)))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "Locations are for specifying the location of Code nodes in Lux files during compilation.")]]
- #End))]
+ (9 #1 #End)]
["module" "line" "column"]
#1)
@@ -263,11 +222,9 @@
(#Product (#Parameter 3)
(#Parameter 1)))))
[dummy_location
- (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])]
- [dummy_location (5 #0 "The type of things that can be annotated with meta-data of arbitrary types.")]]
- (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])]
- [dummy_location (9 #0 (#Item [dummy_location (5 #0 "m")] (#Item [dummy_location (5 #0 "v")] #End)))]]
- #End)))]
+ (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])]
+ [dummy_location (9 #0 (#Item [dummy_location (5 #0 "m")] (#Item [dummy_location (5 #0 "v")] #End)))]]
+ #End))]
["meta" "datum"]
#1)
@@ -331,41 +288,31 @@
(#Apply (#Apply w Code') w)}
("lux type check type" (#Apply Location Ann))))
[dummy_location
- (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])]
- [dummy_location (#Text "The type of Code nodes for Lux syntax.")]]
- #End))]
+ (#Record #End)]
#1)
("lux def" private
#0
[dummy_location
- (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])]
- [dummy_location (#Text "The export policy for private/local definitions.")]]
- #End))]
+ (#Record #End)]
#1)
("lux def" public
#1
[dummy_location
- (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])]
- [dummy_location (#Text "The export policy for public/global definitions.")]]
- #End))]
+ (#Record #End)]
#1)
("lux def" local
#0
[dummy_location
- (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])]
- [dummy_location (#Text "The export policy for private/local definitions.")]]
- #End))]
+ (#Record #End)]
#1)
("lux def" global
#1
[dummy_location
- (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])]
- [dummy_location (#Text "The export policy for public/global definitions.")]]
- #End))]
+ (#Record #End)]
#1)
("lux def" _ann
@@ -462,10 +409,8 @@
("lux type check type"
(#Named ["library/lux" "Definition"]
(#Product Bit (#Product Type (#Product Code Any)))))
- (record$ (#Item [(tag$ ["library/lux" "doc"])
- (text$ "Represents all the data associated with a definition: its type, its annotations, and its value.")]
- #End))
- #1)
+ (record$ #End)
+ .public)
... (type: .public Alias
... Name)
@@ -474,7 +419,7 @@
(#Named ["library/lux" "Alias"]
Name))
(record$ #End)
- #1)
+ .public)
... (type: .public Global
... (#Alias Alias)
@@ -483,11 +428,9 @@
(#Named ["library/lux" "Global"]
(#Sum Alias
Definition))
- (record$ (#Item [(tag$ ["library/lux" "doc"])
- (text$ "Represents all the data associated with a global constant.")]
- #End))
+ (record$ #End)
["Alias" "Definition"]
- #1)
+ .public)
... (type: .public (Bindings k v)
... {#counter Nat
@@ -506,7 +449,7 @@
(tuple$ (#Item (text$ "k") (#Item (text$ "v") #End)))]
#End))
["counter" "mappings"]
- #1)
+ .public)
... (type: .public Ref
... (#Local Nat)
@@ -519,7 +462,7 @@
Nat))
(record$ #End)
["Local" "Captured"]
- #1)
+ .public)
... (type: .public Scope
... {#name (List Text)
@@ -538,7 +481,7 @@
(#Apply (#Product Type Ref) (#Apply Text Bindings))))))
(record$ #End)
["name" "inner" "locals" "captured"]
- #1)
+ .public)
("lux def" Code_List
("lux type check type"
@@ -559,11 +502,9 @@
(#Parameter 1)))))
(record$ (#Item [(tag$ ["library/lux" "type_args"])
(tuple$ (#Item (text$ "l") (#Item (text$ "r") #End)))]
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ "A choice between two values of different types.")]
- #End)))
+ #End))
["Left" "Right"]
- #1)
+ .public)
... (type: .public Source
... [Location Nat Text])
@@ -572,7 +513,7 @@
(#Named ["library/lux" "Source"]
(#Product Location (#Product Nat Text))))
(record$ #End)
- #1)
+ .public)
... (type: .public Module_State
... #Active
@@ -590,7 +531,7 @@
Any)))
(record$ #End)
["Active" "Compiled" "Cached"]
- #1)
+ .public)
... (type: .public Module
... {#module_hash Nat
@@ -628,11 +569,9 @@
(#Apply Code Maybe)
Module_State))
))))))
- (record$ (#Item [(tag$ ["library/lux" "doc"])
- (text$ "All the information contained within a Lux module.")]
- #End))
+ (record$ #End)
["module_hash" "module_aliases" "definitions" "imports" "tags" "types" "module_annotations" "module_state"]
- #1)
+ .public)
... (type: .public Type_Context
... {#ex_counter Nat
@@ -649,7 +588,7 @@
List))))
(record$ #End)
["ex_counter" "var_counter" "var_bindings"]
- #1)
+ .public)
... (type: .public Mode
... #Build
@@ -663,11 +602,9 @@
Any
... Interpreter
Any)))
- (record$ (#Item [(tag$ ["library/lux" "doc"])
- (text$ "A sign that shows the conditions under which the compiler is running.")]
- #End))
+ (record$ #End)
["Build" "Eval" "Interpreter"]
- #1)
+ .public)
... (type: .public Info
... {#target Text
@@ -683,11 +620,9 @@
Text
... mode
Mode)))
- (record$ (#Item [(tag$ ["library/lux" "doc"])
- (text$ "Information about the current version and type of compiler that is running.")]
- #End))
+ (record$ #End)
["target" "version" "mode"]
- #1)
+ .public)
... (type: .public Lux
... {#info Info
@@ -750,15 +685,9 @@
... host
Any))))))))))))))}
(#Apply (#Parameter 1) (#Parameter 0))))
- (record$ (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "Represents the state of the Lux compiler during a run." __paragraph)
- ("lux text concat"
- ("lux text concat" "It is provided to macros during their invocation, so they can access compiler data." __paragraph)
- "Caveat emptor: Avoid fiddling with it, unless you know what you're doing.")))]
- #End))
+ (record$ #End)
["info" "source" "location" "current_module" "modules" "scopes" "type_context" "expected" "seed" "scope_type_vars" "extensions" "eval" "host"]
- #1)
+ .public)
... (type: .public (Meta a)
... (-> Lux (Either Text [Lux a])))
@@ -769,14 +698,10 @@
(#Function Lux
(#Apply (#Product Lux (#Parameter 1))
(#Apply Text Either))))))
- (record$ (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "Computations that can have access to the state of the compiler." __paragraph)
- "These computations may fail, or modify the state of the compiler."))]
- (#Item [(tag$ ["library/lux" "type_args"])
- (tuple$ (#Item (text$ "a") #End))]
- #End)))
- #1)
+ (record$ (#Item [(tag$ ["library/lux" "type_args"])
+ (tuple$ (#Item (text$ "a") #End))]
+ #End))
+ .public)
... (type: .public Macro'
... (-> (List Code) (Meta (List Code))))
@@ -785,7 +710,7 @@
(#Named ["library/lux" "Macro'"]
(#Function Code_List (#Apply Code_List Meta))))
(record$ #End)
- #1)
+ .public)
... (type: .public Macro
... (primitive "#Macro"))
@@ -793,10 +718,8 @@
("lux type check type"
(#Named ["library/lux" "Macro"]
(#Primitive "#Macro" #End)))
- (record$ (#Item [(tag$ ["library/lux" "doc"])
- (text$ "Functions that run at compile-time and allow you to transform and extend the language in powerful ways.")]
- #End))
- #1)
+ (record$ #End)
+ .public)
... Base functions & macros
("lux def" in_meta
@@ -988,13 +911,7 @@
#0)
(macro:' .public (comment tokens)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... Throws away any code given to it." __paragraph)
- ("lux text concat"
- ("lux text concat" "... Great for commenting-out code, while retaining syntax high-lighting and formatting in your text editor." __paragraph)
- "(comment +1 +2 +3 +4)")))]
- #End)
+ #End
(in_meta #End))
(macro:' .private ($' tokens)
@@ -1166,15 +1083,7 @@
(list\mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list))
(macro:' .public (All tokens)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... Universal quantification." __paragraph)
- ("lux text concat"
- ("lux text concat" "(All [a] (-> a a))" __paragraph)
- ("lux text concat"
- ("lux text concat" "... A name can be provided, to specify a recursive type." __paragraph)
- "(All List [a] (Union Any [a (List a)]))"))))]
- #End)
+ #End
(let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens)
[self_name tokens]
@@ -1211,15 +1120,7 @@
tokens)))
(macro:' .public (Ex tokens)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... Existential quantification." __paragraph)
- ("lux text concat"
- ("lux text concat" "(Ex [a] [(Codec Text a) a])" __paragraph)
- ("lux text concat"
- ("lux text concat" "... A name can be provided, to specify a recursive type." __paragraph)
- "(Ex Self [a] [(Codec Text a) a (List (Self a))])"))))]
- #End)
+ #End
(let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens)
[self_name tokens]
@@ -1264,13 +1165,7 @@
list))
(macro:' .public (-> tokens)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... Function types:" __paragraph)
- ("lux text concat"
- ("lux text concat" "(-> Int Int Int)" __paragraph)
- "... This is the type of a function that takes 2 Ints and returns an Int.")))]
- #End)
+ #End
({(#Item output inputs)
(in_meta (#Item (list\mix ("lux type check" (#Function Code (#Function Code Code))
(function'' [i o] (form$ (#Item (tag$ ["library/lux" "Function"]) (#Item i (#Item o #End))))))
@@ -1283,11 +1178,7 @@
(list\reversed tokens)))
(macro:' .public (list xs)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... List-construction macro." __paragraph)
- "(list +1 +2 +3)"))]
- #End)
+ #End
(in_meta (#Item (list\mix (function'' [head tail]
(form$ (#Item (tag$ ["library/lux" "Item"])
(#Item (tuple$ (#Item [head (#Item [tail #End])]))
@@ -1297,13 +1188,7 @@
#End)))
(macro:' .public (list& xs)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... List-construction macro, with the last element being a tail-list." __paragraph)
- ("lux text concat"
- ("lux text concat" "... In other words, this macro prepends elements to another list." __paragraph)
- "(list& +1 +2 +3 (list +4 +5 +6))")))]
- #End)
+ #End
({(#Item last init)
(in_meta (list (list\mix (function'' [head tail]
(form$ (list (tag$ ["library/lux" "Item"])
@@ -1316,15 +1201,7 @@
(list\reversed xs)))
(macro:' .public (Union tokens)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... Union types:" __paragraph)
- ("lux text concat"
- ("lux text concat" "(Union Text Int Bit)" __paragraph)
- ("lux text concat"
- ("lux text concat" "... Nothing." __paragraph)
- "(Union)"))))]
- #End)
+ #End
({#End
(in_meta (list (identifier$ ["library/lux" "Nothing"])))
@@ -1335,15 +1212,7 @@
(list\reversed tokens)))
(macro:' .public (Tuple tokens)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... Tuple types:" __paragraph)
- ("lux text concat"
- ("lux text concat" "(Tuple Text Int Bit)" __paragraph)
- ("lux text concat"
- ("lux text concat" "... Any." __paragraph)
- "(&)"))))]
- #End)
+ #End
({#End
(in_meta (list (identifier$ ["library/lux" "Any"])))
@@ -1412,16 +1281,12 @@
tokens))
(def:''' .public Or
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ "An alias for the Union type constructor.")]
- #End)
+ #End
Macro
..Union)
(def:''' .public And
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ "An alias for the Tuple type constructor.")]
- #End)
+ #End
Macro
..Tuple)
@@ -1507,15 +1372,7 @@
(func left right)))
(macro:' .public (_$ tokens)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... Left-association for the application of binary functions over variadic arguments." ..\n)
- ("lux text concat"
- ("lux text concat" "(_$ text\composite ''Hello, '' name ''. How are you?'')" ..\n)
- ("lux text concat"
- ("lux text concat" "... =>" ..\n)
- "(text\composite (text\composite ''Hello, '' name) ''. How are you?'')"))))]
- #End)
+ #End
({(#Item op tokens')
({(#Item first nexts)
(in_meta (list (list\mix (function\flipped (right_associativity op)) first nexts)))
@@ -1529,15 +1386,7 @@
tokens))
(macro:' .public ($_ tokens)
- (#Item [(tag$ ["library/lux" "doc"])
- (text$ ("lux text concat"
- ("lux text concat" "... Right-association for the application of binary functions over variadic arguments." ..\n)
- ("lux text concat"
- ("lux text concat" "($_ text\composite ''Hello, '' name ''. How are you?'')" ..\n)
- ("lux text concat"
- ("lux text concat" "... =>" ..\n)
- "(text\composite ''Hello, '' (text\composite name ''. How are you?''))"))))]
- #End)
+ #End
({(#Item op tokens')
({(#Item last prevs)
(in_meta (list (list\mix (right_associativity op) last prevs)))
@@ -1670,11 +1519,7 @@
xs)))
(macro:' .public (if tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "Picks which expression to evaluate based on a bit test value." __paragraph
- "(if #1 ''Oh, yeah!'' ''Aw hell naw!'')" __paragraph
- "=> ''Oh, yeah!''"))])
+ (list)
({(#Item test (#Item then (#Item else #End)))
(in_meta (list (form$ (list (record$ (list [(bit$ #1) then]
[(bit$ #0) else]))
@@ -1885,11 +1730,7 @@
[replace? token]))
(macro:' .public (primitive tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Macro to treat define new primitive types." __paragraph
- "(primitive ''java.lang.Object'')" __paragraph
- "(primitive ''java.util.List'' [(primitive ''java.lang.Long'')])"))])
+ (list)
({(#Item [_ (#Text class_name)] #End)
(in_meta (list (form$ (list (tag$ ["library/lux" "Primitive"]) (text$ class_name) (tag$ ["library/lux" "End"])))))
@@ -1916,11 +1757,7 @@
state))
(macro:' .public (` tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Hygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph
- "... All unprefixed macros will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used." __paragraph
- "(` (def: (~ name) (function ((~' _) (~+ args)) (~ body))))"))])
+ (list)
({(#Item template #End)
(do meta_monad
[current_module current_module_name
@@ -1934,10 +1771,7 @@
tokens))
(macro:' .public (`' tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph
- "(`' (def: (~ name) (function (_ (~+ args)) (~ body))))"))])
+ (list)
({(#Item template #End)
(do meta_monad
[=template (untemplated #1 "" template)]
@@ -1948,10 +1782,7 @@
tokens))
(macro:' .public (' tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Quotation as a macro." __paragraph
- "(' YOLO)"))])
+ (list)
({(#Item template #End)
(do meta_monad
[=template (untemplated #0 "" template)]
@@ -1962,12 +1793,7 @@
tokens))
(macro:' .public (|> tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Piping macro." __paragraph
- "(|> elems (list\each int\encoded) (interposed '' '') (mix text\composite ''''))" __paragraph
- "... =>" __paragraph
- "(mix text\composite '''' (interposed '' '' (list\each int\encoded elems)))"))])
+ (list)
({(#Item [init apps])
(in_meta (list (list\mix ("lux type check" (-> Code Code Code)
(function' [app acc]
@@ -1988,12 +1814,7 @@
tokens))
(macro:' .public (<| tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Reverse piping macro." __paragraph
- "(<| (mix text\composite '''') (interposed '' '') (list\each int\encoded) elems)" __paragraph
- "... =>" __paragraph
- "(mix text\composite '''' (interposed '' '' (list\each int\encoded elems)))"))])
+ (list)
({(#Item [init apps])
(in_meta (list (list\mix ("lux type check" (-> Code Code Code)
(function' [app acc]
@@ -2122,13 +1943,6 @@
(low_bits sample))
#0))))
-(def:''' .private (n/<= reference sample)
- (list)
- (-> Nat Nat Bit)
- (if (n/< reference sample)
- #1
- ("lux i64 =" reference sample)))
-
(def:''' .private (list\conjoint xs)
#End
(All [a]
@@ -2136,13 +1950,7 @@
(list\mix list\composite #End (list\reversed xs)))
(macro:' .public (template tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." __paragraph
- "(template [<name> <diff>]" ..\n
- " " "[(def: .public <name> (-> Int Int) (+ <diff>))]" __paragraph
- " " "[++ +1]" ..\n
- " " "[-- -1]"))])
+ (list)
({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])])
({[(#Some bindings') (#Some data')]
(let' [apply ("lux type check" (-> Replacement_Environment ($' List Code))
@@ -2267,11 +2075,7 @@
(|> n (n/% div) ("lux i64 =" 0)))
(def:''' .public (not x)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Bit negation." __paragraph
- "(not #1) => #0" __paragraph
- "(not #0) => #1"))])
+ (list)
(-> Bit Bit)
(if x #0 #1))
@@ -2534,10 +2338,7 @@
type))
(macro:' .public (type tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Takes a type expression and returns its representation as data-structure." __paragraph
- "(type (All [a] (Maybe (List a))))"))])
+ (list)
({(#Item type #End)
(do meta_monad
[type+ (full_expansion type)]
@@ -2553,10 +2354,7 @@
tokens))
(macro:' .public (: tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... The type-annotation macro." __paragraph
- "(: (List Int) (list +1 +2 +3))"))])
+ (list)
({(#Item type (#Item value #End))
(in_meta (list (` ("lux type check" (type (~ type)) (~ value)))))
@@ -2565,10 +2363,7 @@
tokens))
(macro:' .public (:as tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... The type-coercion macro." __paragraph
- "(:as Dinosaur (list +1 +2 +3))"))])
+ (list)
({(#Item type (#Item value #End))
(in_meta (list (` ("lux type as" (type (~ type)) (~ value)))))
@@ -2610,11 +2405,6 @@
state))
(macro:' .public (Rec tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Parameter-less recursive types." __paragraph
- "... A name has to be given to the whole type, to use it within its body." __paragraph
- "(Rec Self [Int (List Self)])"))])
({(#Item [_ (#Identifier "" name)] (#Item body #End))
(let' [body' (|> body
nested_quantification
@@ -2626,14 +2416,7 @@
tokens))
(macro:' .public (exec tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Sequential execution of expressions (great for side-effects)." __paragraph
- "(exec" ..\n
- " " "(log! ''#1'')" ..\n
- " " "(log! ''#2'')" ..\n
- " " "(log! ''#3'')" ..\n
- "''YOLO'')"))])
+ (list)
({(#Item value actions)
(let' [dummy (local_identifier$ "")]
(in_meta (list (list\mix ("lux type check" (-> Code Code Code)
@@ -2720,15 +2503,7 @@
branches))
(macro:' .public (case tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... The pattern-matching macro." ..\n
- "... Allows the usage of macros within the patterns to provide custom syntax." ..\n
- "(case (: (List Int) (list +1 +2 +3))" ..\n
- " " "(#Item x (#Item y (#Item z #End)))" ..\n
- " " "(#Some ($_ * x y z))" __paragraph
- " " "_" ..\n
- " " "#None)"))])
+ (list)
({(#Item value branches)
(do meta_monad
[expansion (expander branches)]
@@ -2739,16 +2514,7 @@
tokens))
(macro:' .public (^ tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Macro-expanding patterns." ..\n
- "... It's a special macro meant to be used with 'case'." ..\n
- "(case (: (List Int) (list +1 +2 +3))" ..\n
- " (^ (list x y z))" ..\n
- " (#Some ($_ * x y z))"
- __paragraph
- " _" ..\n
- " #None)"))])
+ (list)
(case tokens
(#Item [_ (#Form (#Item pattern #End))] (#Item body branches))
(do meta_monad
@@ -2764,20 +2530,7 @@
(failure "Wrong syntax for ^ macro")))
(macro:' .public (^or tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Or-patterns." ..\n
- "... It's a special macro meant to be used with 'case'." ..\n
- "(type: Weekday #Monday #Tuesday #Wednesday #Thursday #Friday #Saturday #Sunday)"
- __paragraph
- "(def: (weekend? day)" ..\n
- " (-> Weekday Bit)" ..\n
- " (case day" ..\n
- " (^or #Saturday #Sunday)" ..\n
- " #1"
- __paragraph
- " _" ..\n
- " #0))"))])
+ (list)
(case tokens
(^ (list& [_ (#Form patterns)] body branches))
(case patterns
@@ -2802,13 +2555,7 @@
#0))
(macro:' .public (let tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Creates local bindings." ..\n
- "... Can (optionally) use pattern-matching macros when binding." ..\n
- "(let [x (foo bar)" ..\n
- " y (baz quux)]" ..\n
- " (op x y))"))])
+ (list)
(case tokens
(^ (list [_ (#Tuple bindings)] body))
(if (multiple? 2 (list\size bindings))
@@ -2828,15 +2575,7 @@
(failure "Wrong syntax for let")))
(macro:' .public (function tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Syntax for creating functions." ..\n
- "... Allows for giving the function itself a name, for the sake of recursion." ..\n
- "(: (All [a b] (-> a b a))" ..\n
- " (function (_ x y) x))"
- __paragraph
- "(: (All [a b] (-> a b a))" ..\n
- " (function (constant x y) x))"))])
+ (list)
(case (: (Maybe [Text Code (List Code) Code])
(case tokens
(^ (list [_ (#Form (list& [_ (#Identifier ["" name])] head tail))] body))
@@ -3093,17 +2832,7 @@
))
(macro:' .public (def: tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Defines global constants/functions." ..\n
- "(def: (pair_list pair)" ..\n
- " (-> [Code Code] (List Code))" ..\n
- " (let [[left right] pair]" ..\n
- " (list left right)))"
- __paragraph
- "(def: branching_exponent" ..\n
- " Int" ..\n
- " +5)"))])
+ (list)
(case (definitionP tokens)
(#Some [export_policy name parameters annotations ?type body])
(let [body (case parameters
@@ -3191,18 +2920,7 @@
))
(macro:' .public (macro: tokens)
- (list [(tag$ ["library/lux" "doc"])
- (text$ ($_ "lux text concat"
- "... Macro-definition macro." ..\n
- "(macro: .public (name_of tokens)" ..\n
- " (case tokens" ..\n
- " (^template [<tag>]" ..\n
- " [(^ (list [_ (<tag> [module name])]))" ..\n
- " (in (list (` [(~ (text$ module)) (~ (text$ name))])))])" ..\n
- " ([#Identifier] [#Tag])"
- __paragraph
- " _" ..\n
- " (failure ''Wrong syntax for name_of'')))"))])
+ (list)
(case (macroP tokens)
(#Some [export_policy name args annotations body])
(let [name (local_identifier$ name)
@@ -3238,9 +2956,8 @@
(#Some y)
(#Some y))))
-(template [<name> <form> <message> <documentation>]
+(template [<name> <form> <message>]
[(macro: .public (<name> tokens)
- {#.doc <documentation>}
(case (list\reversed tokens)
(^ (list& last init))
(in_meta (list (list\mix (: (-> Code Code Code)
@@ -3251,28 +2968,18 @@
_
(failure <message>)))]
- [and (if (~ pre) (~ post) #0) "'and' requires >=1 clauses." "Short-circuiting 'and': (and #1 #0 #1) ... => #0"]
- [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses." "Short-circuiting 'or': (or #1 #0 #1) ... => #1"])
+ [and (if (~ pre) (~ post) #0) "'and' requires >=1 clauses."]
+ [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses."])
(def: (index part text)
(-> Text Text (Maybe Nat))
("lux text index" 0 part text))
(def: .public (panic! message)
- {#.doc (text$ ($_ "lux text concat"
- "... Causes an error, with the given error message." ..\n
- "(panic! ''OH NO!'')"))}
(-> Text Nothing)
("lux io error" message))
-(macro: (else tokens state)
- {#.doc (text$ ($_ "lux text concat"
- "... Allows you to provide a default value that will be used" ..\n
- "... if a (Maybe x) value turns out to be #.None."
- __paragraph
- "(else +20 (#.Some +10)) ... => +10"
- __paragraph
- "(else +20 #.None) ... => +20"))}
+(macro: (maybe\else tokens state)
(case tokens
(^ (list else maybe))
(let [g!temp (: Code [dummy_location (#Identifier ["" ""])])
@@ -3285,7 +2992,7 @@
(#Right [state (list code)]))
_
- (#Left "Wrong syntax for else")))
+ (#Left "Wrong syntax for maybe\else")))
(def: (text\all_split_by splitter input)
(-> Text Text (List Text))
@@ -3504,22 +3211,6 @@
(#Left "Not expecting any type.")))))
(macro: .public (implementation tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Express a value that implements an interface." ..\n
- "(: (Order Int)" ..\n
- " (implementation" ..\n
- " (def: &equivalence equivalence)" ..\n
- " (def: (< test subject)" ..\n
- " (< test subject))" ..\n
- " (def: (<= test subject)" ..\n
- " (or (< test subject)" ..\n
- " (= test subject)))" ..\n
- " (def: (> test subject)" ..\n
- " (> test subject))" ..\n
- " (def: (>= test subject)" ..\n
- " (or (> test subject)" ..\n
- " (= test subject)))" ..\n
- " ))"))}
(do meta_monad
[tokens' (monad\each meta_monad expansion tokens)
struct_type ..expected_type
@@ -3572,56 +3263,40 @@
_
(#Item tokens)))
-(def:' .private (implementationP tokens)
- (-> (List Code) (Maybe [Code Text (List Code) (List [Code Code]) Code (List Code)]))
- (|> (do maybe_monad
- [% (enhanced_declarationP tokens)
- .let' [[tokens [export_policy name parameters]] %]
- % (annotationsP tokens)
- .let' [[tokens annotations] %]
- % (anyP tokens)
- .let' [[tokens type] %]
- tokens (remainderP tokens)]
- (in [export_policy name parameters annotations type tokens]))
- ... (^ (list _export_policy _declaration _annotations _type _body))
- ... (^ (list _declaration _annotations _type _body))
- (maybe\else' (do maybe_monad
- [% (enhanced_local_declarationP tokens)
- .let' [[tokens [name parameters]] %]
- % (anyP tokens)
- .let' [[tokens type] %]
- tokens (remainderP tokens)]
- (in [(` ..private) name parameters #End type tokens])))
- ... (^ (list _declaration _type _body))
- (maybe\else' (do maybe_monad
- [% (anyP tokens)
- .let' [[tokens export_policy] %]
- % (enhanced_local_declarationP tokens)
- .let' [[tokens [name parameters]] %]
- % (anyP tokens)
- .let' [[tokens type] %]
- tokens (remainderP tokens)]
- (in [export_policy name parameters #End type tokens])))
- ... (^ (list _export_policy _declaration _type _body))
- ))
+(def: (implementationP tokens)
+ (-> (List Code) (Maybe [Code Text (List Code) (List [Code Code]) Code (List Code)]))
+ (|> (do maybe_monad
+ [% (enhanced_declarationP tokens)
+ .let' [[tokens [export_policy name parameters]] %]
+ % (annotationsP tokens)
+ .let' [[tokens annotations] %]
+ % (anyP tokens)
+ .let' [[tokens type] %]
+ tokens (remainderP tokens)]
+ (in [export_policy name parameters annotations type tokens]))
+ ... (^ (list _export_policy _declaration _annotations _type _body))
+ ... (^ (list _declaration _annotations _type _body))
+ (maybe\else' (do maybe_monad
+ [% (enhanced_local_declarationP tokens)
+ .let' [[tokens [name parameters]] %]
+ % (anyP tokens)
+ .let' [[tokens type] %]
+ tokens (remainderP tokens)]
+ (in [(` ..private) name parameters #End type tokens])))
+ ... (^ (list _declaration _type _body))
+ (maybe\else' (do maybe_monad
+ [% (anyP tokens)
+ .let' [[tokens export_policy] %]
+ % (enhanced_local_declarationP tokens)
+ .let' [[tokens [name parameters]] %]
+ % (anyP tokens)
+ .let' [[tokens type] %]
+ tokens (remainderP tokens)]
+ (in [export_policy name parameters #End type tokens])))
+ ... (^ (list _export_policy _declaration _type _body))
+ ))
(macro: .public (implementation: tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Interface implementation." ..\n
- "(implementation: .public order" ..\n
- " (Order Int)" ..\n
- ..\n
- " (def: &equivalence equivalence)" ..\n
- " (def: (< test subject)" ..\n
- " (< test subject))" ..\n
- " (def: (<= test subject)" ..\n
- " (or (< test subject)" ..\n
- " (= test subject)))" ..\n
- " (def: (> test subject)" ..\n
- " (> test subject))" ..\n
- " (def: (>= test subject)" ..\n
- " (or (> test subject)" ..\n
- " (= test subject))))"))}
(case (implementationP tokens)
(#Some [export_policy name args annotations type definitions])
(let [usage (case args
@@ -3815,12 +3490,6 @@
it))
(macro: .public (type: tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... The type-definition macro." ..\n
- "(type: (List a)" ..\n
- " {#.doc (example (: (List Nat) (list 0 1 2 3)))}" ..\n
- " #End" ..\n
- " (#Item a (List a)))"))}
(case (typeP tokens)
(#Some [export_policy rec? name args meta type_codes])
(do meta_monad
@@ -3899,13 +3568,6 @@
))
(macro: .public (interface: tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Interface definition." ..\n
- "(interface: .public (Order a)" ..\n
- " (: (Equivalence a)" ..\n
- " &equivalence)" ..\n
- " (: (-> a a Bit)" ..\n
- " <))"))}
(case (interfaceP tokens)
(#Some [export_policy name args annotations methods])
(do meta_monad
@@ -3943,7 +3605,6 @@
(template [<name> <to>]
[(def: .public (<name> value)
- {#.doc "Safe type-casting for I64 values."}
(-> (I64 Any) <to>)
(:as <to> value))]
@@ -4074,7 +3735,6 @@
(replaced ..contextual_reference context)))
(def: .public module_separator
- {#.doc "Character used to separate the parts of module names."}
"/")
(def: parallel_hierarchy_sigil
@@ -4478,12 +4138,6 @@
))
(macro: .public (^open tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Same as the 'open' macro, but meant to be used as a pattern-matching macro for generating local bindings." ..\n
- "... Takes an 'alias' text for the generated local bindings." ..\n
- "(def: .public (range (^open ''.'') minimum additional)" ..\n
- " (All [a] (-> (Enum a) a a (List a)))" ..\n
- " (range' <= succ minimum additional))"))}
(case tokens
(^ (list& [_ (#Form (list [_ (#Text alias)]))] body branches))
(do meta_monad
@@ -4529,13 +4183,6 @@
(failure "Wrong syntax for ^open")))
(macro: .public (cond tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Branching structures with multiple test conditions." ..\n
- "(cond (even? num) ''even''" ..\n
- " (odd? num) ''odd''"
- __paragraph
- " ... else_branch" ..\n
- " ''???'')"))}
(if ("lux i64 =" 0 (n/% 2 (list\size tokens)))
(failure "cond requires an uneven number of arguments.")
(case (list\reversed tokens)
@@ -4564,16 +4211,6 @@
(enumeration' 0 xs))
(macro: .public (value@ tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Accesses the value of a record at a given tag." ..\n
- "(value@ #field my_record)"
- __paragraph
- "... Can also work with multiple levels of nesting:" ..\n
- "(value@ [#foo #bar #baz] my_record)"
- __paragraph
- "... And, if only the slot/path is given, generates an accessor function:" ..\n
- "(let [getter (value@ [#foo #bar #baz])]" ..\n
- " (getter my_record))"))}
(case tokens
(^ (list [_ (#Tag slot')] record))
(do meta_monad
@@ -4643,17 +4280,6 @@
#0)))))))
(macro: .public (open: tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Opens a implementation and generates a definition for each of its members (including nested members)."
- __paragraph
- "... For example:" ..\n
- "(open: ''i:.'' number)"
- __paragraph
- "... Will generate:" ..\n
- "(def: i:+ (\ number +))" ..\n
- "(def: i:- (\ number -))" ..\n
- "(def: i:* (\ number *))" ..\n
- "..."))}
(case tokens
(^ (list [_ (#Text alias)] struct))
(case struct
@@ -4686,22 +4312,12 @@
(failure "Wrong syntax for open:")))
(macro: .public (|>> tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n
- "(|>> (list\each int\encoded) (interposed '' '') (mix text\composite ''''))" ..\n
- "... =>" ..\n
- "(function (_ <arg>) (mix text\composite '''' (interposed '' '' (list\each int\encoded <arg>))))"))}
(do meta_monad
[g!_ (..identifier "_")
g!arg (..identifier "arg")]
(in_meta (list (` (function ((~ g!_) (~ g!arg)) (|> (~ g!arg) (~+ tokens))))))))
(macro: .public (<<| tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n
- "(<<| (mix text\composite '''') (interposed '' '') (list\each int\encoded))" ..\n
- "... =>" ..\n
- "(function (_ <arg>) (mix text\composite '''' (interposed '' '' (list\each int\encoded <arg>))))"))}
(do meta_monad
[g!_ (..identifier "_")
g!arg (..identifier "arg")]
@@ -4793,7 +4409,7 @@
(def: (refer_code module_name module_alias' [r_defs r_opens])
(-> Text (Maybe Text) Refer Code)
- (let [module_alias (..else module_name module_alias')
+ (let [module_alias (..maybe\else module_name module_alias')
localizations (: (List Code)
(case r_defs
#All
@@ -4819,23 +4435,6 @@
(~+ openings)))))
(macro: .public (module: tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Module_definition macro."
- __paragraph
- "... Can take optional annotations and allows the specification of modules to import."
- __paragraph
- "... Example" ..\n
- "(.module: {#.doc ''Some documentation...''}" ..\n
- " [lux #*" ..\n
- " [control" ..\n
- " [''M'' monad #*]]" ..\n
- " [data" ..\n
- " maybe" ..\n
- " [''.'' name (''#/.'' codec)]]" ..\n
- " [macro" ..\n
- " code]]" ..\n
- " [//" ..\n
- " [type (''.'' equivalence)]])"))}
(do meta_monad
[.let [[_meta _imports] (: [(List [Code Code]) (List Code)]
(case tokens
@@ -4849,7 +4448,7 @@
.let [=imports (|> imports
(list\each (: (-> Importation Code)
(function (_ [module_name m_alias =refer])
- (` [(~ (text$ module_name)) (~ (text$ (..else "" m_alias)))]))))
+ (` [(~ (text$ module_name)) (~ (text$ (..maybe\else "" m_alias)))]))))
tuple$)
=refers (list\each (: (-> Importation Code)
(function (_ [module_name m_alias =refer])
@@ -4861,12 +4460,6 @@
(in (#Item =module =refers))))
(macro: .public (\ tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Allows accessing the value of a implementation's member." ..\n
- "(\ codec encoded)"
- __paragraph
- "... Also allows using that value as a function." ..\n
- "(\ codec encoded +123)"))}
(case tokens
(^ (list struct [_ (#Identifier member)]))
(in_meta (list (` (let [(^open (~ (text$ ..self_reference))) (~ struct)] (~ (identifier$ member))))))
@@ -4878,16 +4471,6 @@
(failure "Wrong syntax for \")))
(macro: .public (with@ tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Sets the value of a record at a given tag." ..\n
- "(with@ #name ''Lux'' lang)"
- __paragraph
- "... Can also work with multiple levels of nesting:" ..\n
- "(with@ [#foo #bar #baz] value my_record)"
- __paragraph
- "... And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..\n
- "(let [setter (with@ [#foo #bar #baz] value)] (setter my_record))" ..\n
- "(let [setter (with@ [#foo #bar #baz])] (setter value my_record))"))}
(case tokens
(^ (list [_ (#Tag slot')] value record))
(do meta_monad
@@ -4967,16 +4550,6 @@
(failure "Wrong syntax for with@")))
(macro: .public (revised@ tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Modifies the value of a record at a given tag, based on some function." ..\n
- "(revised@ #age ++ person)"
- __paragraph
- "... Can also work with multiple levels of nesting:" ..\n
- "(revised@ [#foo #bar #baz] func my_record)"
- __paragraph
- "... And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..\n
- "(let [updater (revised@ [#foo #bar #baz] func)] (updater my_record))" ..\n
- "(let [updater (revised@ [#foo #bar #baz])] (updater func my_record))"))}
(case tokens
(^ (list [_ (#Tag slot')] fun record))
(do meta_monad
@@ -5042,40 +4615,6 @@
(failure "Wrong syntax for revised@")))
(macro: .public (^template tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... It's similar to template, but meant to be used during pattern-matching." ..\n
- "(def: (reduced env type)" ..\n
- " (-> (List Type) Type Type)" ..\n
- " (case type" ..\n
- " (#.Primitive name params)" ..\n
- " (#.Primitive name (list\each (reduced env) params))"
- __paragraph
- " (^template [<tag>]" ..\n
- " [(<tag> left right)" ..\n
- " (<tag> (reduced env left) (reduced env right))])" ..\n
- " ([#.Sum] [#.Product])"
- __paragraph
- " (^template [<tag>]" ..\n
- " [(<tag> left right)" ..\n
- " (<tag> (reduced env left) (reduced env right))])" ..\n
- " ([#.Function] [#.Apply])"
- __paragraph
- " (^template [<tag>]" ..\n
- " [(<tag> old_env def)" ..\n
- " (case old_env" ..\n
- " #.End" ..\n
- " (<tag> env def)"
- __paragraph
- " _" ..\n
- " type)])" ..\n
- " ([#.UnivQ] [#.ExQ])"
- __paragraph
- " (#.Parameter idx)" ..\n
- " (else type (list.item idx env))"
- __paragraph
- " _" ..\n
- " type" ..\n
- " ))"))}
(case tokens
(^ (list& [_ (#Form (list [_ (#Tuple bindings)]
[_ (#Tuple templates)]))]
@@ -5145,14 +4684,13 @@
_
(#Documentation_Example code)))
-(template [<name> <extension> <doc>]
+(template [<name> <extension>]
[(def: .public <name>
- {#.doc <doc>}
(All [s] (-> (I64 s) (I64 s)))
(|>> (<extension> 1)))]
- [++ "lux i64 +" "Increment function."]
- [-- "lux i64 -" "Decrement function."]
+ [++ "lux i64 +"]
+ [-- "lux i64 -"]
)
(def: tag\encoded
@@ -5232,20 +4770,9 @@
(let [baseline (baseline_column example)
[location _] example
[_ text] (..example_documentation (with@ #column baseline location) baseline example)]
- (text\composite text __paragraph))))
+ (text\composite text "\n\n"))))
(macro: .public (example tokens)
- {#.doc (text$ ($_ "lux text concat"
- "... Creates code documentation, embedding text as comments and properly formatting the forms it's being given."
- __paragraph
- "... For Example:" ..\n
- "(example ''Allows arbitrary looping, using the 'recur' form to re-start the loop.''" ..\n
- " ''Can be used in monadic code to create monadic loops.''" ..\n
- " (loop [count +0" ..\n
- " x init]" ..\n
- " (if (< +10 count)" ..\n
- " (recur (++ count) (f x))" ..\n
- " x)))"))}
(in_meta (list (` [(~ location_code)
(#.Text (~ (|> tokens
(list\each (|>> ..documentation_fragment ..fragment_documentation))
@@ -5298,21 +4825,6 @@
(identifier$ [module name])))
(macro: .public (loop tokens)
- {#.doc (example "Allows arbitrary looping, using the 'recur' form to re-start the loop."
- "Can be used in monadic code to create monadic loops."
- (loop [count +0
- x init]
- (if (< +10 count)
- (recur (++ count) (f x))
- x))
-
- "Loops can also be given custom names."
- (loop my_loop
- [count +0
- x init]
- (if (< +10 count)
- (my_loop (++ count) (f x))
- x)))}
(let [?params (case tokens
(^ (list name [_ (#Tuple bindings)] body))
(#Some [name bindings body])
@@ -5355,10 +4867,6 @@
(failure "Wrong syntax for loop"))))
(macro: .public (^slots tokens)
- {#.doc (example "Allows you to extract record members as local variables with the same names."
- "For example:"
- (let [(^slots [#foo #bar #baz]) quux]
- (f foo bar baz)))}
(case tokens
(^ (list& [_ (#Form (list [_ (#Tuple (list& hslot' tslots'))]))] body branches))
(do meta_monad
@@ -5433,25 +4941,6 @@
(in (list [location (#Record =pairs)])))))
(macro: .public (with_expansions tokens)
- {#.doc (example "Controlled macro-expansion."
- "Bind an arbitraty number of Code nodes resulting from macro-expansion to local bindings."
- "Wherever a binding appears, the bound Code nodes will be spliced in there."
- (test: "Code operations & implementations"
- (with_expansions
- [<tests> (template [<expr> <text>]
- [(compare <text> (\ codec encoded <expr>))]
-
- [(bit #1) "#1"]
- [(int +123) "+123"]
- [(frac +123.0) "+123.0"]
- [(text "123") "'123'"]
- [(tag ["yolo" "lol"]) "#yolo.lol"]
- [(identifier ["yolo" "lol"]) "yolo.lol"]
- [(form (list (bit #1))) "(#1)"]
- [(tuple (list (bit #1))) "[#1]"]
- [(record (list [(bit #1) (int +123)])) "{#1 +123}"]
- )]
- (test_all <tests>))))}
(case tokens
(^ (list& [_ (#Tuple bindings)] bodies))
(case bindings
@@ -5551,27 +5040,6 @@
))
(macro: .public (static tokens)
- {#.doc (example "Resolves the names of definitions to their values at compile-time, assuming their values are either:"
- "* Bit"
- "* Nat"
- "* Int"
- "* Rev"
- "* Frac"
- "* Text"
- (def: my_nat 123)
- (def: my_text "456")
- (and (case [my_nat my_text]
- (^ (static [..my_nat ..my_text]))
- true
-
- _
- false)
- (case [my_nat my_text]
- (^ [(static ..my_nat) (static ..my_text)])
- true
-
- _
- false)))}
(case tokens
(^ (list pattern))
(do meta_monad
@@ -5626,26 +5094,6 @@
(list init_pattern inner_pattern_body)))
(macro: .public (^multi tokens)
- {#.doc (example "Multi-level pattern matching."
- "Useful in situations where the result of a branch depends on further refinements on the values being matched."
- "For example:"
- (case (split (size static) uri)
- (^multi (#Some [chunk uri'])
- {(text\= static chunk) #1})
- (match_uri endpoint? parts' uri')
-
- _
- (#Left (format "Static part " (%t static) " does not match URI: " uri)))
-
- "Short-cuts can be taken when using bit tests."
- "The example above can be rewritten as..."
- (case (split (size static) uri)
- (^multi (#Some [chunk uri'])
- (text\= static chunk))
- (match_uri endpoint? parts' uri')
-
- _
- (#Left (format "Static part " (%t static) " does not match URI: " uri))))}
(case tokens
(^ (list& [_meta (#Form levels)] body next_branches))
(do meta_monad
@@ -5686,10 +5134,6 @@
(text\composite "Wrong syntax for ")))
(macro: .public (name_of tokens)
- {#.doc (example "Given an identifier or a tag, gives back a 2 tuple with the module and name parts, both as Text."
- (name_of #.doc)
- "=>"
- ["library/lux" "doc"])}
(case tokens
(^template [<tag>]
[(^ (list [_ (<tag> [module name])]))
@@ -5709,15 +5153,6 @@
(#Right [state scope_type_vars])))
(macro: .public (:parameter tokens)
- {#.doc (example "NOTE: Please stay away from this macro. It's very likely to be removed in a future version of Lux."
- "Allows you to refer to the type-variables in a polymorphic function's type, by their index."
- "In the example below, 0 corresponds to the 'a' variable."
- (def: .public (of_list list)
- (All [a] (-> (List a) (Row a)))
- (list\mix add
- (: (Row (:parameter 0))
- empty)
- list)))}
(case tokens
(^ (list [_ (#Nat idx)]))
(do meta_monad
@@ -5733,22 +5168,10 @@
(failure (..wrong_syntax_error (name_of ..$)))))
(def: .public (same? reference sample)
- {#.doc (example "Tests whether the 2 values are identical (not just 'equal')."
- "This one should succeed:"
- (let [value +5]
- (same? value value))
-
- "This one should fail:"
- (same? +5 (+ +2 +3)))}
(All [a] (-> a a Bit))
("lux is" reference sample))
(macro: .public (^@ tokens)
- {#.doc (example "Allows you to simultaneously bind and de-structure a value."
- (def: (hash (^@ set [Hash<a> _]))
- (list\mix (function (_ elem acc) (+ (\ Hash<a> hash elem) acc))
- 0
- (to_list set))))}
(case tokens
(^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] pattern))] body branches))
(let [g!whole (local_identifier$ name)]
@@ -5760,10 +5183,6 @@
(failure (..wrong_syntax_error (name_of ..^@)))))
(macro: .public (^|> tokens)
- {#.doc (example "Pipes the value being pattern-matched against prior to binding it to a variable."
- (case input
- (^|> value [++ (% 10) (max 1)])
- (foo value)))}
(case tokens
(^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] [_ (#Tuple steps)]))] body branches))
(let [g!name (local_identifier$ name)]
@@ -5776,10 +5195,6 @@
(failure (..wrong_syntax_error (name_of ..^|>)))))
(macro: .public (:expected tokens)
- {#.doc (example "Coerces the given expression to the type of whatever is expected."
- (: Dinosaur
- (:expected (: (List Nat)
- (list 1 2 3)))))}
(case tokens
(^ (list expr))
(do meta_monad
@@ -5790,18 +5205,11 @@
(failure (..wrong_syntax_error (name_of ..:expected)))))
(def: location
- {#.doc "The location of the current expression being analyzed."}
(Meta Location)
(function (_ compiler)
(#Right [compiler (value@ #location compiler)])))
(macro: .public (undefined tokens)
- {#.doc (example "Meant to be used as a stand-in for functions with undefined implementations."
- "Undefined expressions will type-check against everything, so they make good dummy implementations."
- "However, if an undefined expression is ever evaluated, it will raise a runtime error."
- (def: (square x)
- (-> Int Int)
- (undefined)))}
(case tokens
#End
(do meta_monad
@@ -5815,17 +5223,6 @@
(failure (..wrong_syntax_error (name_of ..undefined)))))
(macro: .public (:of tokens)
- {#.doc (example "Generates the type corresponding to a given expression."
- "Example #1:"
- (let [my_num +123]
- (:of my_num))
- "=="
- Int
- "-------------------"
- "Example #2:"
- (:of +123)
- "=="
- Int)}
(case tokens
(^ (list [_ (#Identifier var_name)]))
(do meta_monad
@@ -5882,10 +5279,6 @@
))
(macro: .public (template: tokens)
- {#.doc (example "Define macros in the style of template and ^template."
- "For simple macros that do not need any fancy features."
- (template: (square x)
- (* x x)))}
(case (templateP tokens)
(#Some [export_policy name args anns input_templates])
(do meta_monad
@@ -5914,21 +5307,9 @@
(failure (..wrong_syntax_error (name_of ..template:)))))
(macro: .public (as_is tokens compiler)
- {#.doc (example "Given a (potentially empty) list of codes, just returns them immediately, without any work done."
- "This may seen useless, but it has its utility when dealing with controlled-macro-expansion macros."
- (with_expansions [<operands> (as_is 1
- 2
- 3
- 4)]
- (+ <operands>)))}
(#Right [compiler tokens]))
(macro: .public (char tokens compiler)
- {#.doc (example "If given a 1-character text literal, yields the char-code of the sole character."
- (: Nat
- (char "A"))
- "=>"
- 65)}
(case tokens
(^multi (^ (list [_ (#Text input)]))
(|> input "lux text size" ("lux i64 =" 1)))
@@ -5989,12 +5370,6 @@
(target_pick target options' default)))))
(macro: .public (for tokens)
- {#.doc (example "Selects the appropriate code for a given target-platform when compiling Lux to it."
- (def: js "JavaScript")
- (for {"JVM" (do jvm stuff)
- ..js (do js stuff)}
- (do default stuff))
- "Look-up the available targets in library/lux/target.")}
(do meta_monad
[target ..target]
(case tokens
@@ -6007,14 +5382,6 @@
_
(failure (..wrong_syntax_error (name_of ..for))))))
-(template [<name>]
- [(def: (<name> [left right])
- (All [left right] (-> [left right] <name>))
- <name>)]
-
- [left]
- [right])
-
(def: (embedded_expansions code)
(-> Code (Meta [(List [Code Code]) Code]))
(case code
@@ -6027,8 +5394,8 @@
[[ann (<tag> parts)]
(do meta_monad
[=parts (monad\each meta_monad embedded_expansions parts)]
- (in [(list\mix list\composite (list) (list\each left =parts))
- [ann (<tag> (list\each right =parts))]]))])
+ (in [(list\mix list\composite (list) (list\each product\left =parts))
+ [ann (<tag> (list\each product\right =parts))]]))])
([#Form] [#Tuple])
[ann (#Record kvs)]
@@ -6042,17 +5409,13 @@
[val_labels val_labelled] =val]]
(in [(list\composite key_labels val_labels) [key_labelled val_labelled]])))
kvs)]
- (in [(list\mix list\composite (list) (list\each left =kvs))
- [ann (#Record (list\each right =kvs))]]))
+ (in [(list\mix list\composite (list) (list\each product\left =kvs))
+ [ann (#Record (list\each product\right =kvs))]]))
_
(in_meta [(list) code])))
(macro: .public (`` tokens)
- {#.doc (example "Delimits a controlled (spliced) macro-expansion."
- "Uses a (~~) special form to specify where to expand."
- (`` (some expression
- (~~ (some macro which may yield 0 or more results)))))}
(case tokens
(^ (list raw))
(do meta_monad
@@ -6146,14 +5509,6 @@
)))
(macro: .public (^code tokens)
- {#.doc (example "Generates pattern-matching code for Code values in a way that looks like code-templating."
- (: (Maybe Nat)
- (case (` (#0 123 +456.789))
- (^code (#0 (~ [_ (#.Nat number)]) +456.789))
- (#.Some number)
-
- _
- #.None)))}
(case tokens
(^ (list& [_meta (#Form (list template))] body branches))
(do meta_monad
@@ -6169,19 +5524,14 @@
(failure (..wrong_syntax_error (name_of ..^code)))))
(def: .public false
- {#.doc "The boolean FALSE value."}
Bit
#0)
(def: .public true
- {#.doc "The boolean TRUE value."}
Bit
#1)
(macro: .public (:let tokens)
- {#.doc (example "Local bindings for types."
- (:let [side (Either Int Frac)]
- (List [side side])))}
(case tokens
(^ (list [_ (#Tuple bindings)] bodyT))
(if (multiple? 2 (list\size bindings))
@@ -6197,17 +5547,6 @@
(..failure (..wrong_syntax_error (name_of ..:let)))))
(macro: .public (try tokens)
- {#.doc (example (: Foo
- (case (: (Either Text Bar)
- (try (: Bar
- (risky computation which may panic))))
- (#.Right success)
- (: Foo
- (do something after success))
-
- (#.Left error)
- (: Foo
- (recover from error)))))}
(case tokens
(^ (list expression))
(do meta_monad
diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux
index 7ca651988..1831db134 100644
--- a/stdlib/source/library/lux/abstract/apply.lux
+++ b/stdlib/source/library/lux/abstract/apply.lux
@@ -1,6 +1,7 @@
(.module:
[library
- [lux #*]]
+ [lux #*
+ ["@" target]]]
[//
[monad (#+ Monad)]
["." functor (#+ Functor)]])
@@ -24,10 +25,14 @@
(def: (on fgx fgf)
... TODO: Switch from this version to the one below (in comments) ASAP.
- (let [fgf' (\ f_apply on
- fgf
- (\ f_monad in (function (_ gf gx) (\ g_apply on gx gf))))]
- (\ f_apply on fgx fgf'))
+ (for {@.old (let [fgf' (\ f_apply on
+ fgf
+ (\ f_monad in (function (_ gf gx) (\ g_apply on gx gf))))]
+ (:expected (\ f_apply on (:expected fgx) (:expected fgf'))))}
+ (let [fgf' (\ f_apply on
+ fgf
+ (\ f_monad in (function (_ gf gx) (\ g_apply on gx gf))))]
+ (\ f_apply on fgx fgf')))
... (let [applyF (\ f_apply on)
... applyG (\ g_apply on)]
... ($_ applyF
diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux
index bb82c2936..5a43d91cd 100644
--- a/stdlib/source/library/lux/abstract/enum.lux
+++ b/stdlib/source/library/lux/abstract/enum.lux
@@ -11,14 +11,14 @@
(def: .public (range enum from to)
(All [a] (-> (Enum a) a a (List a)))
- (let [(^open "/\.") enum]
+ (let [(^open ".") enum]
(loop [end to
output #.End]
- (cond (/\< end from)
- (recur (/\pred end) (#.Item end output))
+ (cond (< end from)
+ (recur (pred end) (#.Item end output))
- (/\< from end)
- (recur (/\succ end) (#.Item end output))
+ (< from end)
+ (recur (succ end) (#.Item end output))
- ... (/\= end from)
+ ... (= end from)
(#.Item end output)))))
diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux
index cf00522fa..bdca98684 100644
--- a/stdlib/source/library/lux/control/exception.lux
+++ b/stdlib/source/library/lux/control/exception.lux
@@ -47,7 +47,7 @@
(let [reference (value@ #label exception)]
(if (text.starts_with? reference error)
(#//.Success (|> error
- (text.clip' (text.size reference))
+ (text.clip_since (text.size reference))
maybe.trusted
then))
(#//.Failure error)))))
@@ -138,9 +138,9 @@
tail))))
(syntax: .public (report [entries (<>.many (<code>.tuple (<>.and <code>.any <code>.any)))])
- (in (list (` ((~! report') (list (~+ (|> entries
- (list\each (function (_ [header message])
- (` [(~ header) (~ message)])))))))))))
+ (in (list (` ((~! ..report') (list (~+ (|> entries
+ (list\each (function (_ [header message])
+ (` [(~ header) (~ message)])))))))))))
(def: .public (listing format entries)
(All [a]
diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux
index 4d89e9778..6245dea04 100644
--- a/stdlib/source/library/lux/control/function/memo.lux
+++ b/stdlib/source/library/lux/control/function/memo.lux
@@ -39,20 +39,20 @@
(All [i o]
(:let [Memory (Dictionary i o)]
(-> (Memo i o) (-> [Memory i] [Memory o]))))
- (let [memo (//.mixin (//.with ..memoization (//.of_recursive memo)))]
+ (let [memo (//.fixed (//.mixed ..memoization (//.of_recursive memo)))]
(function (_ [memory input])
(|> input memo (state.result memory)))))
(def: .public (closed hash memo)
(All [i o]
(-> (Hash i) (Memo i o) (-> i o)))
- (let [memo (//.mixin (//.with ..memoization (//.of_recursive memo)))
+ (let [memo (//.fixed (//.mixed ..memoization (//.of_recursive memo)))
empty (dictionary.empty hash)]
(|>> memo (state.result empty) product.right)))
(def: .public (none hash memo)
(All [i o]
(-> (Hash i) (Memo i o) (-> i o)))
- (let [memo (//.mixin (//.of_recursive memo))
+ (let [memo (//.fixed (//.of_recursive memo))
empty (dictionary.empty hash)]
(|>> memo (state.result empty) product.right)))
diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux
index 4f5013f77..68d2e4bf0 100644
--- a/stdlib/source/library/lux/control/function/mixin.lux
+++ b/stdlib/source/library/lux/control/function/mixin.lux
@@ -12,7 +12,7 @@
(type: .public (Mixin i o)
(-> (-> i o) (-> i o) (-> i o)))
-(def: .public (mixin f)
+(def: .public (fixed f)
(All [i o] (-> (Mixin i o) (-> i o)))
(function (mix input)
((f mix mix) input)))
@@ -22,7 +22,7 @@
(function (_ delegate recur)
delegate))
-(def: .public (with parent child)
+(def: .public (mixed parent child)
(All [i o] (-> (Mixin i o) (Mixin i o) (Mixin i o)))
(function (_ delegate recur)
(parent (child delegate recur) recur)))
@@ -31,7 +31,7 @@
(All [i o] (Monoid (Mixin i o)))
(def: identity ..nothing)
- (def: composite ..with))
+ (def: composite ..mixed))
(def: .public (advice when then)
(All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o)))
diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux
index 4f051e604..b418d435f 100644
--- a/stdlib/source/library/lux/control/io.lux
+++ b/stdlib/source/library/lux/control/io.lux
@@ -39,13 +39,13 @@
(def: .public run!
(All [a] (-> (IO a) a))
- (|>> run!'))
+ (|>> ..run!'))
(implementation: .public functor
(Functor IO)
(def: (each f)
- (|>> run!' f !io)))
+ (|>> ..run!' f !io)))
(implementation: .public apply
(Apply IO)
@@ -53,7 +53,7 @@
(def: &functor ..functor)
(def: (on fa ff)
- (!io ((run!' ff) (run!' fa)))))
+ (!io ((..run!' ff) (..run!' fa)))))
(implementation: .public monad
(Monad IO)
@@ -64,5 +64,5 @@
(|>> !io))
(def: conjoint
- (|>> run!' run!' !io)))
+ (|>> ..run!' ..run!' !io)))
)
diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux
index e12de5bb9..c3a351c71 100644
--- a/stdlib/source/library/lux/control/lazy.lux
+++ b/stdlib/source/library/lux/control/lazy.lux
@@ -42,7 +42,7 @@
(syntax: .public (lazy [expression <code>.any])
(with_identifiers [g!_]
- (in (list (` ((~! lazy') (function ((~ g!_) (~ g!_)) (~ expression))))))))
+ (in (list (` ((~! ..lazy') (function ((~ g!_) (~ g!_)) (~ expression))))))))
(implementation: .public (equivalence (^open "\."))
(All [a] (-> (Equivalence a) (Equivalence (Lazy a))))
diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux
index 24a2f9e3c..2dda427e6 100644
--- a/stdlib/source/library/lux/control/parser/text.lux
+++ b/stdlib/source/library/lux/control/parser/text.lux
@@ -35,20 +35,20 @@
{#basis Offset
#distance Offset}))
-(def: (remaining' offset tape)
+(def: (left_over offset tape)
(-> Offset Text Text)
- (|> tape (/.split_at offset) maybe.trusted product.right))
+ (|> tape (/.clip_since offset) maybe.trusted))
(exception: .public (unconsumed_input {offset Offset} {tape Text})
(exception.report
["Offset" (n\encoded offset)]
["Input size" (n\encoded (/.size tape))]
- ["Remaining input" (remaining' offset tape)]))
+ ["Remaining input" (..left_over offset tape)]))
(exception: .public (expected_to_fail {offset Offset} {tape Text})
(exception.report
["Offset" (n\encoded offset)]
- ["Input" (remaining' offset tape)]))
+ ["Input" (..left_over offset tape)]))
(exception: .public cannot_parse)
(exception: .public cannot_slice)
@@ -125,7 +125,7 @@
(def: .public (this reference)
(-> Text (Parser Any))
(function (_ [offset tape])
- (case (/.index' offset reference tape)
+ (case (/.index_since offset reference tape)
(#.Some where)
(if (n.= offset where)
(#try.Success [[("lux i64 +" (/.size reference) offset) tape]
@@ -155,7 +155,7 @@
(def: .public remaining
(Parser Text)
(function (_ (^@ input [offset tape]))
- (#try.Success [input (remaining' offset tape)])))
+ (#try.Success [input (..left_over offset tape)])))
(def: .public (range bottom top)
(-> Nat Nat (Parser Text))
diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux
index 3ae79571c..1549bae80 100644
--- a/stdlib/source/library/lux/data/collection/array.lux
+++ b/stdlib/source/library/lux/data/collection/array.lux
@@ -275,7 +275,7 @@
Nat
(-- 0))
-(def: .public (list array)
+(def: (list|-default array)
(All [a] (-> (Array a) (List a)))
(loop [idx (-- (size array))
output #.End]
@@ -292,7 +292,7 @@
#.None
output)))))
-(def: .public (list' default array)
+(def: (list|+default default array)
(All [a] (-> a (Array a) (List a)))
(loop [idx (-- (size array))
output #.End]
@@ -305,6 +305,15 @@
(#.Item (maybe.else default (read! idx array))
output)))))
+(def: .public (list default array)
+ (All [a] (-> (Maybe a) (Array a) (List a)))
+ (case default
+ (#.Some default)
+ (list|+default default array)
+
+ #.None
+ (list|-default array)))
+
(implementation: .public (equivalence (^open ",\."))
(All [a] (-> (Equivalence a) (Equivalence (Array a))))
diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux
index e06983307..0828d54e2 100644
--- a/stdlib/source/library/lux/data/collection/dictionary.lux
+++ b/stdlib/source/library/lux/data/collection/dictionary.lux
@@ -145,9 +145,11 @@
(|> array array.clone (array.write! idx value)))
... Creates a clone of the array, with an empty position at index.
-(def: (array\lacks' idx array)
+(def: (array\clear idx array)
(All [a] (-> Index (Array a) (Array a)))
- (|> array array.clone (array.delete! idx)))
+ (|> array
+ array.clone
+ (array.delete! idx)))
... Shrinks a copy of the array by removing the space at index.
(def: (array\lacks idx array)
@@ -284,7 +286,7 @@
... All empty nodes look the same (a #Base node with clean bitmap is
... used).
... So, this test is introduced to detect them.
-(def: (empty?' node)
+(def: (node\empty? node)
(All [k v] (-> (Node k v) Bit))
(`` (case node
(#Base (~~ (static ..clean_bitmap)) _)
@@ -355,18 +357,18 @@
... However, if the Bit_Position has not been used yet, check
... whether this #Base node is ready for a promotion.
(let [base_count (bitmap_size bitmap)]
- (if (n.>= ..promotion_threshold base_count)
- ... If so, promote it to a #Hierarchy node, and add the new
+ (if (n.< ..promotion_threshold base_count)
+ ... If so, resize the #Base node to accommodate the
+ ... new KV-pair.
+ (#Base (with_bit_position bit bitmap)
+ (array\has (base_index bit bitmap) (#.Right [key val]) base))
+ ... Otherwise, promote it to a #Hierarchy node, and add the new
... KV-pair as a singleton node to it.
(#Hierarchy (++ base_count)
(|> base
(promotion node\has key_hash level bitmap)
(array.write! (level_index level hash)
- (node\has (level_up level) hash key val key_hash empty_node))))
- ... Otherwise, just resize the #Base node to accommodate the
- ... new KV-pair.
- (#Base (with_bit_position bit bitmap)
- (array\has (base_index bit bitmap) (#.Right [key val]) base))))))
+ (node\has (level_up level) hash key val key_hash empty_node))))))))
... For #Collisions nodes, compare the hashes.
(#Collisions _hash _colls)
@@ -390,7 +392,7 @@
(node\has level hash key val key_hash)))
))
-(def: (lacks' level hash key key_hash node)
+(def: (node\lacks level hash key key_hash node)
(All [k v] (-> Level Hash_Code k (Hash k) (Node k v) (Node k v)))
(case node
... For #Hierarchy nodes, find out if there's a valid sub-node for
@@ -404,19 +406,19 @@
... But if there is, try to remove the key from the sub-node.
(#.Some sub_node)
- (let [sub_node' (lacks' (level_up level) hash key key_hash sub_node)]
+ (let [sub_node' (node\lacks (level_up level) hash key key_hash sub_node)]
... Then check if a removal was actually done.
(if (same? sub_node sub_node')
... If not, then there's nothing to change here either.
node
... But if the sub_removal yielded an empty sub_node...
- (if (empty?' sub_node')
+ (if (node\empty? sub_node')
... Check if it's due time for a demotion.
- (if (n.<= demotion_threshold h_size)
- ... If so, perform it.
- (#Base (demotion idx [h_size h_array]))
- ... Otherwise, just clear the space.
- (#Hierarchy (-- h_size) (array\lacks' idx h_array)))
+ (if (n.> demotion_threshold h_size)
+ ... If so, just clear the space.
+ (#Hierarchy (-- h_size) (array\clear idx h_array))
+ ... Otherwise, perform it.
+ (#Base (demotion idx [h_size h_array])))
... But if the sub_removal yielded a non_empty node, then
... just update the hiearchy branch.
(#Hierarchy h_size (array\revised idx sub_node' h_array)))))))
@@ -430,13 +432,13 @@
... If set, check if it's a sub_node, and remove the KV
... from it.
(#.Some (#.Left sub_node))
- (let [sub_node' (lacks' (level_up level) hash key key_hash sub_node)]
+ (let [sub_node' (node\lacks (level_up level) hash key key_hash sub_node)]
... Verify that it was removed.
(if (same? sub_node sub_node')
... If not, there's also nothing to change here.
node
... But if it came out empty...
- (if (empty?' sub_node')
+ (if (node\empty? sub_node')
...# ... figure out whether that's the only position left.
(if (only_bit_position? bit bitmap)
... If so, removing it leaves this node empty too.
@@ -482,14 +484,14 @@
(#Collisions _hash (array\lacks idx _colls))))
))
-(def: (value' level hash key key_hash node)
+(def: (node\value level hash key key_hash node)
(All [k v] (-> Level Hash_Code k (Hash k) (Node k v) (Maybe v)))
(case node
... For #Hierarchy nodes, just look-up the key on its children.
(#Hierarchy _size hierarchy)
(case (array.read! (level_index level hash) hierarchy)
#.None #.None
- (#.Some sub_node) (value' (level_up level) hash key key_hash sub_node))
+ (#.Some sub_node) (node\value (level_up level) hash key key_hash sub_node))
... For #Base nodes, check the leaves, and recursively check the branches.
(#Base bitmap base)
@@ -497,7 +499,7 @@
(if (with_bit_position? bit bitmap)
(case (array.read! (base_index bit bitmap) base)
(#.Some (#.Left sub_node))
- (value' (level_up level) hash key key_hash sub_node)
+ (node\value (level_up level) hash key key_hash sub_node)
(#.Some (#.Right [key' val']))
(if (\ key_hash = key key')
@@ -515,16 +517,16 @@
_colls))
))
-(def: (size' node)
+(def: (node\size node)
(All [k v] (-> (Node k v) Nat))
(case node
(#Hierarchy _size hierarchy)
- (array\mix n.+ 0 (array\each size' hierarchy))
+ (array\mix n.+ 0 (array\each node\size hierarchy))
(#Base _ base)
(array\mix n.+ 0 (array\each (function (_ sub_node')
(case sub_node'
- (#.Left sub_node) (size' sub_node)
+ (#.Left sub_node) (node\size sub_node)
(#.Right _) 1))
base))
@@ -532,11 +534,11 @@
(array.size colls)
))
-(def: (entries' node)
+(def: (node\entries node)
(All [k v] (-> (Node k v) (List [k v])))
(case node
(#Hierarchy _size hierarchy)
- (array\mix (function (_ sub_node tail) (list\composite (entries' sub_node) tail))
+ (array\mix (function (_ sub_node tail) (list\composite (node\entries sub_node) tail))
#.End
hierarchy)
@@ -544,7 +546,7 @@
(array\mix (function (_ branch tail)
(case branch
(#.Left sub_node)
- (list\composite (entries' sub_node) tail)
+ (list\composite (node\entries sub_node) tail)
(#.Right [key' val'])
(#.Item [key' val'] tail)))
@@ -578,12 +580,12 @@
(def: .public (lacks key dict)
(All [k v] (-> k (Dictionary k v) (Dictionary k v)))
(let [[key_hash node] dict]
- [key_hash (lacks' root_level (\ key_hash hash key) key key_hash node)]))
+ [key_hash (node\lacks root_level (\ key_hash hash key) key key_hash node)]))
(def: .public (value key dict)
(All [k v] (-> k (Dictionary k v) (Maybe v)))
(let [[key_hash node] dict]
- (value' root_level (\ key_hash hash key) key key_hash node)))
+ (node\value root_level (\ key_hash hash key) key key_hash node)))
(def: .public (key? dict key)
(All [k v] (-> (Dictionary k v) k Bit))
@@ -617,7 +619,7 @@
(def: .public size
(All [k v] (-> (Dictionary k v) Nat))
- (|>> product.right ..size'))
+ (|>> product.right ..node\size))
(def: .public empty?
(All [k v] (-> (Dictionary k v) Bit))
@@ -625,7 +627,7 @@
(def: .public entries
(All [k v] (-> (Dictionary k v) (List [k v])))
- (|>> product.right ..entries'))
+ (|>> product.right ..node\entries))
(def: .public (of_list key_hash kvs)
(All [k v] (-> (Hash k) (List [k v]) (Dictionary k v)))
@@ -700,7 +702,7 @@
#0))
(..entries reference)))))
-(implementation: functor'
+(implementation: node_functor
(All [k] (Functor (Node k)))
(def: (each f fa)
@@ -727,4 +729,4 @@
(All [k] (Functor (Dictionary k)))
(def: (each f fa)
- (revised@ #root (\ ..functor' each f) fa)))
+ (revised@ #root (\ ..node_functor each f) fa)))
diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux
index 6cba59b62..30a2323c4 100644
--- a/stdlib/source/library/lux/data/collection/row.lux
+++ b/stdlib/source/library/lux/data/collection/row.lux
@@ -132,13 +132,13 @@
(array.copy! tail_size 0 tail 0)
(array.write! tail_size val))))
-(def: (has' level idx val hierarchy)
+(def: (hierarchy\has level idx val hierarchy)
(All [a] (-> Level Index a (Hierarchy a) (Hierarchy a)))
(let [sub_idx (branch_idx (i64.right_shifted level idx))]
(case (array.read! sub_idx hierarchy)
(#.Some (#Hierarchy sub_node))
(|> (array.clone hierarchy)
- (array.write! sub_idx (#Hierarchy (has' (level_down level) idx val sub_node))))
+ (array.write! sub_idx (#Hierarchy (hierarchy\has (level_down level) idx val sub_node))))
(^multi (#.Some (#Base base))
(n.= 0 (level_down level)))
@@ -175,17 +175,18 @@
#.Some)
)))
-(def: (list' node)
+(def: (node\list node)
(All [a] (-> (Node a) (List a)))
(case node
(#Base base)
- (array.list base)
+ (array.list #.None base)
(#Hierarchy hierarchy)
(|> hierarchy
- array.list
+ (array.list #.None)
list.reversed
- (list\mix (function (_ sub acc) (list\composite (list' sub) acc))
+ (list\mix (function (_ sub acc)
+ (list\composite (node\list sub) acc))
#.End))))
(type: .public (Row a)
@@ -254,8 +255,7 @@
(def: (base_for idx row)
(All [a] (-> Index (Row a) (Try (Base a))))
(if (within_bounds? row idx)
- (if (n.>= (tail_off (value@ #size row)) idx)
- (#try.Success (value@ #tail row))
+ (if (n.< (tail_off (value@ #size row)) idx)
(loop [level (value@ #level row)
hierarchy (value@ #root row)]
(case [(n.> branching_exponent level)
@@ -270,7 +270,8 @@
(exception.except ..base_was_not_found [])
_
- (exception.except ..incorrect_row_structure []))))
+ (exception.except ..incorrect_row_structure [])))
+ (#try.Success (value@ #tail row)))
(exception.except ..index_out_of_bounds [row idx])))
(def: .public (item idx row)
@@ -288,13 +289,13 @@
(All [a] (-> Nat a (Row a) (Try (Row a))))
(let [row_size (value@ #size row)]
(if (within_bounds? row idx)
- (#try.Success (if (n.>= (tail_off row_size) idx)
+ (#try.Success (if (n.< (tail_off row_size) idx)
+ (revised@ #root (hierarchy\has (value@ #level row) idx val)
+ row)
(revised@ #tail (for {@.old
(: (-> (Base (:parameter 0)) (Base (:parameter 0)))
(|>> array.clone (array.write! (branch_idx idx) val)))}
(|>> array.clone (array.write! (branch_idx idx) val)))
- row)
- (revised@ #root (has' (value@ #level row) idx val)
row)))
(exception.except ..index_out_of_bounds [row idx]))))
@@ -348,8 +349,8 @@
(def: .public (list row)
(All [a] (-> (Row a) (List a)))
- (list\composite (list' (#Hierarchy (value@ #root row)))
- (list' (#Base (value@ #tail row)))))
+ (list\composite (node\list (#Hierarchy (value@ #root row)))
+ (node\list (#Base (value@ #tail row)))))
(def: .public of_list
(All [a] (-> (List a) (Row a)))
diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux
index 3cf8fa6d5..f688297f2 100644
--- a/stdlib/source/library/lux/data/color.lux
+++ b/stdlib/source/library/lux/data/color.lux
@@ -115,16 +115,16 @@
#green (n.max lG rG)
#blue (n.max lB rB)}))))
- (def: (complement' value)
+ (def: (opposite_intensity value)
(-> Nat Nat)
(|> ..top (n.- value)))
(def: .public (complement color)
(-> Color Color)
(let [[red green blue] (:representation color)]
- (:abstraction {#red (complement' red)
- #green (complement' green)
- #blue (complement' blue)})))
+ (:abstraction {#red (opposite_intensity red)
+ #green (opposite_intensity green)
+ #blue (opposite_intensity blue)})))
(implementation: .public subtraction
(Monoid Color)
diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux
index 745acf38d..6aeaa6539 100644
--- a/stdlib/source/library/lux/data/format/tar.lux
+++ b/stdlib/source/library/lux/data/format/tar.lux
@@ -261,9 +261,12 @@
(def: .public (<in> value)
(-> <representation> (Try <type>))
(if (..ascii? value)
- (if (|> value (\ utf8.codec encoded) binary.size (n.<= <size>))
- (#try.Success (:abstraction value))
- (exception.except <exception> [value]))
+ (if (|> value
+ (\ utf8.codec encoded)
+ binary.size
+ (n.> <size>))
+ (exception.except <exception> [value])
+ (#try.Success (:abstraction value)))
(exception.except ..not_ascii [value])))
(def: .public <out>
@@ -519,11 +522,11 @@
(Parser Mode)
(do {! <>.monad}
[value (\ ! each ..from_small ..small_parser)]
- (if (n.<= (:representation ..maximum_mode)
- value)
- (in (:abstraction value))
+ (if (n.> (:representation ..maximum_mode)
+ value)
(<>.lifted
- (exception.except ..invalid_mode [value]))))))
+ (exception.except ..invalid_mode [value]))
+ (in (:abstraction value))))))
)
(def: maximum_content_size
diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux
index daf951a7d..31e42bfa5 100644
--- a/stdlib/source/library/lux/data/text.lux
+++ b/stdlib/source/library/lux/data/text.lux
@@ -56,30 +56,26 @@
(#.Some ("lux text char" index input))
#.None))
-(def: .public (index' from pattern input)
+(def: .public (index_since offset pattern input)
(-> Nat Text Text (Maybe Nat))
- ("lux text index" from pattern input))
+ ("lux text index" offset pattern input))
(def: .public (index pattern input)
(-> Text Text (Maybe Nat))
- (index' 0 pattern input))
+ (index_since 0 pattern input))
-(def: (last_index' from part text)
- (-> Nat Text Text (Maybe Nat))
- (loop [from from
+(def: .public (last_index part text)
+ (-> Text Text (Maybe Nat))
+ (loop [offset 0
output (: (Maybe Nat)
#.None)]
- (let [output' ("lux text index" from part text)]
+ (let [output' ("lux text index" offset part text)]
(case output'
#.None
output
- (#.Some from')
- (recur (++ from') output')))))
-
-(def: .public (last_index part text)
- (-> Text Text (Maybe Nat))
- (last_index' 0 part text))
+ (#.Some offset')
+ (recur (++ offset') output')))))
(def: .public (starts_with? prefix x)
(-> Text Text Bit)
@@ -136,20 +132,20 @@
(def: .public (clip offset size input)
(-> Nat Nat Text (Maybe Text))
- (if (|> size (n.+ offset) (n.<= ("lux text size" input)))
- (#.Some ("lux text clip" offset size input))
- #.None))
+ (if (|> size (n.+ offset) (n.> ("lux text size" input)))
+ #.None
+ (#.Some ("lux text clip" offset size input))))
-(def: .public (clip' offset input)
+(def: .public (clip_since offset input)
(-> Nat Text (Maybe Text))
(let [size ("lux text size" input)]
- (if (n.<= size offset)
- (#.Some ("lux text clip" offset (n.- offset size) input))
- #.None)))
+ (if (n.> size offset)
+ #.None
+ (#.Some ("lux text clip" offset (n.- offset size) input)))))
(def: .public (split_at at x)
(-> Nat Text (Maybe [Text Text]))
- (case [(..clip 0 at x) (..clip' at x)]
+ (case [(..clip 0 at x) (..clip_since at x)]
[(#.Some pre) (#.Some post)]
(#.Some [pre post])
diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux
index 77d4e94e1..fcfb718ab 100644
--- a/stdlib/source/library/lux/data/text/regex.lux
+++ b/stdlib/source/library/lux/data/text/regex.lux
@@ -116,9 +116,10 @@
(def: re_user_class^
(Parser Code)
(do <>.monad
- [_ (in [])
- init re_user_class^'
- rest (<>.some (<>.after (<text>.this "&&") (<text>.enclosed ["[" "]"] re_user_class^')))]
+ [init ..re_user_class^'
+ rest (<>.some (<>.after (<text>.this "&&")
+ (<text>.enclosed ["[" "]"]
+ ..re_user_class^')))]
(in (list\mix (function (_ refinement base)
(` ((~! refine^) (~ refinement) (~ base))))
init
diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux
index 96ccfe30e..c08076bcf 100644
--- a/stdlib/source/library/lux/debug.lux
+++ b/stdlib/source/library/lux/debug.lux
@@ -135,7 +135,7 @@
(~~ (as_is)))]
(`` (|>> (:as (array.Array Any))
<adaption>
- array.list
+ (array.list #.None)
(list\each inspection)
(text.interposed " ")
(text.enclosed ["[" "]"])))))
diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux
index 35cebc0f4..05610b52f 100644
--- a/stdlib/source/library/lux/documentation.lux
+++ b/stdlib/source/library/lux/documentation.lux
@@ -301,13 +301,6 @@
(|>> (text.all_split_by ..expected_separator)
(set.of_list text.hash)))
-(def: (module' name description expected definitions)
- (-> Text Text Text (List Definition) Module)
- {#module name
- #description description
- #expected (..expected expected)
- #definitions definitions})
-
(syntax: .public (module [[name _] ..qualified_identifier
description <code>.any
definitions (<code>.tuple (<>.some <code>.any))
@@ -315,13 +308,13 @@
(do meta.monad
[expected (meta.exports name)]
(in (list (` (: (List Module)
- (list& ((~! ..module')
- (~ (code.text name))
- (~ description)
- (~ (code.text (|> expected
- (list\each product.left)
- ..expected_format)))
- ((~! list.together) (list (~+ definitions))))
+ (list& {#..module (~ (code.text name))
+ #..description (~ description)
+ #..expected ((~! ..expected)
+ (~ (code.text (|> expected
+ (list\each product.left)
+ ..expected_format))))
+ #..definitions ((~! list.together) (list (~+ definitions)))}
($_ (\ (~! list.monoid) (~' composite))
(: (List Module)
(\ (~! list.monoid) (~' identity)))
diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux
index 38a207259..6d1867dfc 100644
--- a/stdlib/source/library/lux/ffi.js.lux
+++ b/stdlib/source/library/lux/ffi.js.lux
@@ -81,12 +81,13 @@
..nullable)))
(type: Common_Method
- {#name Text
- #alias (Maybe Text)
- #inputs (List Nullable)
- #io? Bit
- #try? Bit
- #output Nullable})
+ (Record
+ {#name Text
+ #alias (Maybe Text)
+ #inputs (List Nullable)
+ #io? Bit
+ #try? Bit
+ #output Nullable}))
(type: Static_Method Common_Method)
(type: Virtual_Method Common_Method)
diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux
index d57bde2b1..f7b94e8df 100644
--- a/stdlib/source/library/lux/ffi.jvm.lux
+++ b/stdlib/source/library/lux/ffi.jvm.lux
@@ -715,17 +715,12 @@
(<code>.form (<>.and <code>.local_identifier
annotation_parameters^))))
-(def: annotations^'
- (Parser (List Annotation))
- (do <>.monad
- [_ (<code>.this! (' #ann))]
- (<code>.tuple (<>.some ..annotation^))))
-
(def: annotations^
(Parser (List Annotation))
- (do <>.monad
- [anns?? (<>.maybe ..annotations^')]
- (in (maybe.else (list) anns??))))
+ (<| (<>.else (list))
+ (do <>.monad
+ [_ (<code>.this! (' #ann))]
+ (<code>.tuple (<>.some ..annotation^)))))
(def: (throws_decl^ type_vars)
(-> (List (Type Var)) (Parser (List (Type Class))))
diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux
index 3d14b554f..d8bcfdb42 100644
--- a/stdlib/source/library/lux/ffi.lua.lux
+++ b/stdlib/source/library/lux/ffi.lua.lux
@@ -80,12 +80,13 @@
..nilable)))
(type: Common_Method
- {#name Text
- #alias (Maybe Text)
- #inputs (List Nilable)
- #io? Bit
- #try? Bit
- #output Nilable})
+ (Record
+ {#name Text
+ #alias (Maybe Text)
+ #inputs (List Nilable)
+ #io? Bit
+ #try? Bit
+ #output Nilable}))
(type: Static_Method Common_Method)
(type: Virtual_Method Common_Method)
@@ -315,8 +316,8 @@
(: ..Function
(closure [left right]
(do_something (:as Foo left) (:as Bar right)))))}
- (.:as ..Function
- (`` ("lua function"
- (~~ (template.amount <inputs>))
- (.function (_ [<inputs>])
- <output>)))))
+ [(.:as ..Function
+ (`` ("lua function"
+ (~~ (template.amount <inputs>))
+ (.function (_ [<inputs>])
+ <output>))))])
diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux
index 82208f783..c06124708 100644
--- a/stdlib/source/library/lux/ffi.php.lux
+++ b/stdlib/source/library/lux/ffi.php.lux
@@ -86,12 +86,13 @@
..nullable)))
(type: Common_Method
- {#name Text
- #alias (Maybe Alias)
- #inputs (List Nullable)
- #io? Bit
- #try? Bit
- #output Nullable})
+ (Record
+ {#name Text
+ #alias (Maybe Alias)
+ #inputs (List Nullable)
+ #io? Bit
+ #try? Bit
+ #output Nullable}))
(type: Static_Method Common_Method)
(type: Virtual_Method Common_Method)
diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux
index 3dbd3cc5a..bf455fc2e 100644
--- a/stdlib/source/library/lux/ffi.py.lux
+++ b/stdlib/source/library/lux/ffi.py.lux
@@ -81,12 +81,13 @@
..noneable)))
(type: Common_Method
- {#name Text
- #alias (Maybe Text)
- #inputs (List Noneable)
- #io? Bit
- #try? Bit
- #output Noneable})
+ (Record
+ {#name Text
+ #alias (Maybe Text)
+ #inputs (List Noneable)
+ #io? Bit
+ #try? Bit
+ #output Noneable}))
(type: Static_Method Common_Method)
(type: Virtual_Method Common_Method)
diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux
index 2ba821582..060b3dfea 100644
--- a/stdlib/source/library/lux/ffi.rb.lux
+++ b/stdlib/source/library/lux/ffi.rb.lux
@@ -88,12 +88,13 @@
..nilable)))
(type: Common_Method
- {#name Text
- #alias (Maybe Alias)
- #inputs (List Nilable)
- #io? Bit
- #try? Bit
- #output Nilable})
+ (Record
+ {#name Text
+ #alias (Maybe Alias)
+ #inputs (List Nilable)
+ #io? Bit
+ #try? Bit
+ #output Nilable}))
(type: Static_Method Common_Method)
(type: Virtual_Method Common_Method)
diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux
index 675aadcd1..f8f75f21e 100644
--- a/stdlib/source/library/lux/ffi.scm.lux
+++ b/stdlib/source/library/lux/ffi.scm.lux
@@ -86,12 +86,13 @@
..nilable)))
(type: Common_Method
- {#name Text
- #alias (Maybe Alias)
- #inputs (List Nilable)
- #io? Bit
- #try? Bit
- #output Nilable})
+ (Record
+ {#name Text
+ #alias (Maybe Alias)
+ #inputs (List Nilable)
+ #io? Bit
+ #try? Bit
+ #output Nilable}))
(def: common_method
(Parser Common_Method)
diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux
index a0a31472d..c5fc005c6 100644
--- a/stdlib/source/library/lux/math.lux
+++ b/stdlib/source/library/lux/math.lux
@@ -318,7 +318,7 @@
... ("lux f64 =" +0.0 y)
("lux f64 /" +0.0 +0.0))))
-(def: .public (log' base it)
+(def: .public (log_by base it)
(-> Frac Frac Frac)
("lux f64 /"
(..log base)
@@ -328,9 +328,9 @@
(-> Nat Nat)
(loop [acc 1
it it]
- (if (n.<= 1 it)
- acc
- (recur (n.* it acc) (-- it)))))
+ (if (n.> 1 it)
+ (recur (n.* it acc) (-- it))
+ acc)))
(def: .public (hypotenuse catA catB)
(-> Frac Frac Frac)
diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux
index b3418da98..6687bd043 100644
--- a/stdlib/source/library/lux/math/number/complex.lux
+++ b/stdlib/source/library/lux/math/number/complex.lux
@@ -230,13 +230,13 @@
(-> Complex Complex)
(let [(^slots [#real #imaginary]) input
t (|> input ..abs (f.+ (f.abs real)) (f./ +2.0) (math.pow +0.5))]
- (if (f.>= +0.0 real)
- {#real t
- #imaginary (f./ (f.* +2.0 t)
- imaginary)}
+ (if (f.< +0.0 real)
{#real (f./ (f.* +2.0 t)
(f.abs imaginary))
- #imaginary (f.* t (..with_sign imaginary +1.0))})))
+ #imaginary (f.* t (..with_sign imaginary +1.0))}
+ {#real t
+ #imaginary (f./ (f.* +2.0 t)
+ imaginary)})))
(def: (root/2-1z input)
(-> Complex Complex)
diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux
index a65025c0b..5af0bf3ff 100644
--- a/stdlib/source/library/lux/math/number/rev.lux
+++ b/stdlib/source/library/lux/math/number/rev.lux
@@ -297,31 +297,34 @@
(loop [idx idx
carry 0
output output]
- (if (//int.>= +0 (.int idx))
+ (if (//int.< +0 (.int idx))
+ output
(let [raw (|> (..digit idx output)
(//nat.* 5)
(//nat.+ carry))]
(recur (-- idx)
(//nat./ 10 raw)
- (digits\put! idx (//nat.% 10 raw) output)))
- output)))
+ (digits\put! idx (//nat.% 10 raw) output))))))
(def: (power_digits power)
(-> Nat Digits)
(loop [times power
output (|> (..digits [])
(digits\put! power 1))]
- (if (//int.>= +0 (.int times))
+ (if (//int.< +0 (.int times))
+ output
(recur (-- times)
- (digits\times_5! power output))
- output)))
+ (digits\times_5! power output)))))
(def: (format digits)
(-> Digits Text)
(loop [idx (-- //i64.width)
all_zeroes? true
output ""]
- (if (//int.>= +0 (.int idx))
+ (if (//int.< +0 (.int idx))
+ (if all_zeroes?
+ "0"
+ output)
(let [digit (..digit idx digits)]
(if (and (//nat.= 0 digit)
all_zeroes?)
@@ -330,30 +333,28 @@
false
("lux text concat"
(\ //nat.decimal encoded digit)
- output))))
- (if all_zeroes?
- "0"
- output))))
+ output)))))))
(def: (digits\+! param subject)
(-> Digits Digits Digits)
(loop [idx (-- //i64.width)
carry 0
output (..digits [])]
- (if (//int.>= +0 (.int idx))
+ (if (//int.< +0 (.int idx))
+ output
(let [raw ($_ //nat.+
carry
(..digit idx param)
(..digit idx subject))]
(recur (-- idx)
(//nat./ 10 raw)
- (digits\put! idx (//nat.% 10 raw) output)))
- output)))
+ (digits\put! idx (//nat.% 10 raw) output))))))
(def: (text_digits input)
(-> Text (Maybe Digits))
(let [length ("lux text size" input)]
- (if (//nat.<= //i64.width length)
+ (if (//nat.> //i64.width length)
+ #.None
(loop [idx 0
output (..digits [])]
(if (//nat.< length idx)
@@ -364,8 +365,7 @@
(#.Some digit)
(recur (++ idx)
(digits\put! idx digit output)))
- (#.Some output)))
- #.None)))
+ (#.Some output))))))
(def: (digits\< param subject)
(-> Digits Digits Bit)
@@ -380,23 +380,23 @@
(def: (digits\-!' idx param subject)
(-> Nat Nat Digits Digits)
(let [sd (..digit idx subject)]
- (if (//nat.>= param sd)
- (digits\put! idx (//nat.- param sd) subject)
+ (if (//nat.< param sd)
(let [diff (|> sd
(//nat.+ 10)
(//nat.- param))]
(|> subject
(digits\put! idx diff)
- (digits\-!' (-- idx) 1))))))
+ (digits\-!' (-- idx) 1)))
+ (digits\put! idx (//nat.- param sd) subject))))
(def: (digits\-! param subject)
(-> Digits Digits Digits)
(loop [idx (-- //i64.width)
output subject]
- (if (//int.>= +0 (.int idx))
+ (if (//int.< +0 (.int idx))
+ output
(recur (-- idx)
- (digits\-!' idx (..digit idx param) output))
- output)))
+ (digits\-!' idx (..digit idx param) output)))))
(implementation: .public decimal
(Codec Text Rev)
@@ -410,16 +410,15 @@
(let [last_idx (-- //i64.width)]
(loop [idx last_idx
digits (..digits [])]
- (if (//int.>= +0 (.int idx))
+ (if (//int.< +0 (.int idx))
+ ("lux text concat" "." (..format digits))
(if (//i64.one? idx input)
(let [digits' (digits\+! (power_digits (//nat.- idx last_idx))
digits)]
(recur (-- idx)
digits'))
(recur (-- idx)
- digits))
- ("lux text concat" "." (..format digits))
- )))))
+ digits)))))))
(def: (decoded input)
(let [dotted? (case ("lux text index" 0 "." input)
@@ -428,8 +427,9 @@
_
false)
- within_limits? (//nat.<= (++ //i64.width)
- ("lux text size" input))]
+ within_limits? (|> input
+ "lux text size"
+ (//nat.<= (++ //i64.width)))]
(if (and dotted? within_limits?)
(case (|> input ..decimals ..text_digits)
(#.Some digits)
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index 103796a2e..c51425fcc 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -160,37 +160,36 @@
_
(\ ..monad in name)))
-(def: (macro' modules this_module module name)
- (-> (List [Text Module]) Text Text Text
- (Maybe Macro))
- (do maybe.monad
- [$module (plist.value module modules)
- definition (: (Maybe Global)
- (|> (: Module $module)
- (value@ #.definitions)
- (plist.value name)))]
- (case definition
- (#.Alias [r_module r_name])
- (macro' modules this_module r_module r_name)
-
- (#.Definition [exported? def_type def_anns def_value])
- (if (macro_type? def_type)
- (#.Some (:as Macro def_value))
- #.None))))
-
(def: .public (macro full_name)
(-> Name (Meta (Maybe Macro)))
(do ..monad
[[module name] (..normal full_name)]
(: (Meta (Maybe Macro))
(function (_ lux)
- (let [macro (case (..current_module_name lux)
- (#try.Failure error)
- #.None
-
- (#try.Success [_ this_module])
- (macro' (value@ #.modules lux) this_module module name))]
- (#try.Success [lux macro]))))))
+ (#try.Success [lux
+ (case (..current_module_name lux)
+ (#try.Failure error)
+ #.None
+
+ (#try.Success [_ this_module])
+ (let [modules (value@ #.modules lux)]
+ (loop [module module
+ name name]
+ (do maybe.monad
+ [$module (plist.value module modules)
+ definition (: (Maybe Global)
+ (|> $module
+ (: Module)
+ (value@ #.definitions)
+ (plist.value name)))]
+ (case definition
+ (#.Alias [r_module r_name])
+ (recur r_module r_name)
+
+ (#.Definition [exported? def_type def_anns def_value])
+ (if (macro_type? def_type)
+ (#.Some (:as Macro def_value))
+ #.None))))))])))))
(def: .public seed
(Meta Nat)
diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux
index 7a1f5b3bc..a2b83491d 100644
--- a/stdlib/source/library/lux/target/js.lux
+++ b/stdlib/source/library/lux/target/js.lux
@@ -307,10 +307,6 @@
(-> Var Expression Statement)
(:abstraction (format "var " (:representation name) " = " (:representation value) ..statement_suffix)))
- (def: .public (set' name value)
- (-> Location Expression Expression)
- (:abstraction (..expression (format (:representation name) " = " (:representation value)))))
-
(def: .public (set name value)
(-> Location Expression Statement)
(:abstraction (format (:representation name) " = " (:representation value) ..statement_suffix)))
@@ -323,13 +319,9 @@
(-> Expression Statement)
(:abstraction (format "return " (:representation value) ..statement_suffix)))
- (def: .public (delete' value)
- (-> Location Expression)
- (:abstraction (format "delete " (:representation value))))
-
(def: .public (delete value)
(-> Location Statement)
- (:abstraction (format (:representation (delete' value)) ..statement_suffix)))
+ (:abstraction (format "delete " (:representation value) ..statement_suffix)))
(def: .public (if test then! else!)
(-> Expression Statement Statement Statement)
diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux
index 7e56004c3..1fe22ef1a 100644
--- a/stdlib/source/library/lux/target/jvm/bytecode.lux
+++ b/stdlib/source/library/lux/target/jvm/bytecode.lux
@@ -700,9 +700,9 @@
[jump (\ ! each //signed.value
(/address.jump @from @to))]
(let [big? (n.> (//unsigned.value //unsigned.maximum/2)
- (.nat (i.* (if (i.>= +0 jump)
- +1
- -1)
+ (.nat (i.* (if (i.< +0 jump)
+ -1
+ +1)
jump)))]
(if big?
(\ ! each (|>> #.Left) (//signed.s4 jump))
diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux
index 8a889a1ad..c294201b6 100644
--- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux
+++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux
@@ -74,9 +74,9 @@
(def: .public (<constructor> value)
(-> Nat (Try <name>))
- (if (n.<= (:representation <maximum>) value)
- (#try.Success (:abstraction value))
- (exception.except ..value_exceeds_the_maximum [(name_of <name>) value <maximum>])))
+ (if (n.> (:representation <maximum>) value)
+ (exception.except ..value_exceeds_the_maximum [(name_of <name>) value <maximum>])
+ (#try.Success (:abstraction value))))
(def: .public (<+> parameter subject)
(-> <name> <name> (Try <name>))
@@ -88,9 +88,9 @@
(-> <name> <name> (Try <name>))
(let [parameter' (:representation parameter)
subject' (:representation subject)]
- (if (n.<= subject' parameter')
- (#try.Success (:abstraction (n.- parameter' subject')))
- (exception.except ..subtraction_cannot_yield_negative_value [(name_of <name>) parameter subject]))))
+ (if (n.> subject' parameter')
+ (exception.except ..subtraction_cannot_yield_negative_value [(name_of <name>) parameter subject])
+ (#try.Success (:abstraction (n.- parameter' subject'))))))
(def: .public (<max> left right)
(-> <name> <name> <name>)
diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux
index 7a057f870..b307e8a79 100644
--- a/stdlib/source/library/lux/target/lua.lux
+++ b/stdlib/source/library/lux/target/lua.lux
@@ -159,7 +159,7 @@
(text.enclosed ["{" "}"])
:abstraction))
- (def: .public (nth idx array)
+ (def: .public (item idx array)
(-> Expression Expression Access)
(:abstraction (format (:representation array) "[" (:representation idx) "]")))
diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux
index afe40ea8b..b5275fa01 100644
--- a/stdlib/source/library/lux/test.lux
+++ b/stdlib/source/library/lux/test.lux
@@ -212,9 +212,9 @@
%.frac
(text.replaced/1 "+" ""))]
(|> raw
- (text.clip 0 (if (f.>= +10.0 done_percent)
- 5 ... XX.XX
+ (text.clip 0 (if (f.< +10.0 done_percent)
4 ... X.XX
+ 5 ... XX.XX
))
(maybe.else raw)
(text.suffix "%"))))))]
diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux
index 7009c54eb..559638614 100644
--- a/stdlib/source/library/lux/time/date.lux
+++ b/stdlib/source/library/lux/time/date.lux
@@ -44,10 +44,10 @@
(//month.leap_year_days month)
(//month.days month)))
-(def: (day_is_within_limits? year month day)
+(def: (invalid_day? year month day)
(-> Year Month Nat Bit)
- (and (n.>= ..minimum_day day)
- (n.<= (..month_days year month) day)))
+ (or (n.< ..minimum_day day)
+ (n.> (..month_days year month) day)))
(exception: .public (invalid_day {year Year} {month Month} {day Nat})
(exception.report
@@ -77,13 +77,13 @@
(def: .public (date year month day_of_month)
(-> Year Month Nat (Try Date))
- (if (..day_is_within_limits? year month day_of_month)
+ (if (..invalid_day? year month day_of_month)
+ (exception.except ..invalid_day [year month day_of_month])
(#try.Success
(:abstraction
{#year year
#month month
- #day day_of_month}))
- (exception.except ..invalid_day [year month day_of_month])))
+ #day day_of_month}))))
(def: .public epoch
Date
@@ -163,10 +163,10 @@
(Parser Nat)
(do <>.monad
[value ..section_parser]
- (if (and (n.>= <minimum> value)
- (n.<= <maximum> value))
- (in value)
- (<>.lifted (exception.except <exception> [value])))))]
+ (if (or (n.< <minimum> value)
+ (n.> <maximum> value))
+ (<>.lifted (exception.except <exception> [value]))
+ (in value))))]
[1 12 month_parser invalid_month]
)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux
index d5b6529f0..5532c5977 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux
@@ -84,7 +84,7 @@
(#.Var id)
(do ///.monad
[?caseT' (//type.with_env
- (check.read' id))]
+ (check.peek id))]
(.case ?caseT'
(#.Some caseT')
(recur envs caseT')
@@ -110,7 +110,7 @@
(do ///.monad
[funcT' (//type.with_env
(do check.monad
- [?funct' (check.read' funcT_id)]
+ [?funct' (check.peek funcT_id)]
(.case ?funct'
(#.Some funct')
(in funct')
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux
index 31ed0f394..36c5f193f 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux
@@ -48,12 +48,13 @@
... way, while the other tags cover more specific cases for bits
... and variants.
(type: .public #rec Coverage
- #Partial
- (#Bit Bit)
- (#Variant (Maybe Nat) (Dictionary Nat Coverage))
- (#Seq Coverage Coverage)
- (#Alt Coverage Coverage)
- #Exhaustive)
+ (.Variant
+ #Partial
+ (#Bit Bit)
+ (#Variant (Maybe Nat) (Dictionary Nat Coverage))
+ (#Seq Coverage Coverage)
+ (#Alt Coverage Coverage)
+ #Exhaustive))
(def: .public (exhaustive? coverage)
(-> Coverage Bit)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux
index 931e27eeb..a499b5df4 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux
@@ -71,7 +71,7 @@
(#.Var id)
(do !
[?expectedT' (//type.with_env
- (check.read' id))]
+ (check.peek id))]
(case ?expectedT'
(#.Some expectedT')
(recur expectedT')
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux
index 36ddce2e2..366a92cad 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux
@@ -167,7 +167,7 @@
(#.Var infer_id)
(do ///.monad
[?inferT' (//type.with_env
- (check.read' infer_id))]
+ (check.peek infer_id))]
(case ?inferT'
(#.Some inferT')
(general archive analyse inferT' args)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux
index 76781c92a..f44670a38 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux
@@ -119,7 +119,7 @@
(#.Var id)
(do !
[?expectedT' (//type.with_env
- (check.read' id))]
+ (check.peek id))]
(case ?expectedT'
(#.Some expectedT')
(//type.with_type expectedT'
@@ -145,7 +145,7 @@
(#.Var funT_id)
(do !
[?funT' (//type.with_env
- (check.read' funT_id))]
+ (check.peek funT_id))]
(case ?funT'
(#.Some funT')
(//type.with_type (#.Apply inputT funT')
@@ -209,7 +209,7 @@
(#.Var id)
(do !
[?expectedT' (//type.with_env
- (check.read' id))]
+ (check.peek id))]
(case ?expectedT'
(#.Some expectedT')
(//type.with_type expectedT'
@@ -239,7 +239,7 @@
(#.Var funT_id)
(do !
[?funT' (//type.with_env
- (check.read' funT_id))]
+ (check.peek funT_id))]
(case ?funT'
(#.Some funT')
(//type.with_type (#.Apply inputT funT')
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
index b1b57e1ff..ef87ca48a 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -189,17 +189,19 @@
)
(type: Member
- {#class External
- #member Text})
+ (Record
+ {#class External
+ #member Text}))
(def: member
(Parser Member)
($_ <>.and <code>.text <code>.text))
(type: Method_Signature
- {#method .Type
- #deprecated? Bit
- #exceptions (List .Type)})
+ (Record
+ {#method .Type
+ #deprecated? Bit
+ #exceptions (List .Type)}))
(template [<name>]
[(exception: .public (<name> {type .Type})
@@ -1079,11 +1081,12 @@
objectA)))))]))
(type: Method_Style
- #Static
- #Abstract
- #Virtual
- #Special
- #Interface)
+ (Variant
+ #Static
+ #Abstract
+ #Virtual
+ #Special
+ #Interface))
(def: (check_method aliasing class method_name method_style inputsJT method)
(-> Aliasing (java/lang/Class java/lang/Object) Text Method_Style (List (Type Value)) java/lang/reflect/Method (Operation Bit))
@@ -1246,8 +1249,9 @@
exceptionsT]))))
(type: Evaluation
- (#Pass Method_Signature)
- (#Hint Method_Signature))
+ (Variant
+ (#Pass Method_Signature)
+ (#Hint Method_Signature)))
(template [<name> <tag>]
[(def: <name>
@@ -1597,10 +1601,11 @@
)
(type: .public Visibility
- #Public
- #Private
- #Protected
- #Default)
+ (Variant
+ #Public
+ #Private
+ #Protected
+ #Default))
(type: .public Finality Bit)
(type: .public Strictness Bit)
@@ -2022,7 +2027,8 @@
))))))
(type: .public (Method_Definition a)
- (#Overriden_Method (Overriden_Method a)))
+ (Variant
+ (#Overriden_Method (Overriden_Method a))))
(def: .public parameter_types
(-> (List (Type Var)) (Check (List [(Type Var) .Type])))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
index 11605c1d5..0c812936b 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
@@ -19,7 +19,7 @@
[number
["f" frac]]]
["@" target
- ["_" lua (#+ Expression)]]]]
+ ["_" lua (#+ Expression Statement)]]]]
["." //// #_
["/" bundle]
["/#" // #_
@@ -28,12 +28,18 @@
[extension (#+ Nullary Unary Binary Trinary
nullary unary binary trinary)]
["//" lua #_
- ["#." runtime (#+ Operation Phase Handler Bundle Generator)]]]
+ ["#." runtime (#+ Operation Phase Phase! Handler Bundle Generator)]
+ ["#." primitive]
+ ["#." structure]
+ ["#." reference]
+ ["#." case]
+ ["#." loop]
+ ["#." function]]]
[//
- [synthesis (#+ %synthesis)]
+ ["." synthesis (#+ %synthesis)]
["." generation]
[///
- ["#" phase]]]]])
+ ["#" phase ("#\." monad)]]]]])
(def: .public (custom [parser handler])
(All [s]
@@ -49,7 +55,51 @@
(/////.except extension.invalid_syntax [extension_name %synthesis input]))))
(template: (!unary function)
- (|>> list _.apply/* (|> (_.var function))))
+ [(|>> list _.apply/* (|> (_.var function)))])
+
+(def: .public (statement expression archive synthesis)
+ Phase!
+ (case synthesis
+ ... TODO: Get rid of this ASAP
+ (#synthesis.Extension "lux syntax char case!" parameters)
+ (do /////.monad
+ [body (expression archive synthesis)]
+ (in (:as Statement body)))
+
+ (^template [<tag>]
+ [(^ (<tag> value))
+ (/////\each _.return (expression archive synthesis))])
+ ([synthesis.bit]
+ [synthesis.i64]
+ [synthesis.f64]
+ [synthesis.text]
+ [synthesis.variant]
+ [synthesis.tuple]
+ [#synthesis.Reference]
+ [synthesis.branch/get]
+ [synthesis.function/apply]
+ [#synthesis.Extension])
+
+ (^ (synthesis.branch/case case))
+ (//case.case! statement expression archive case)
+
+ (^ (synthesis.branch/let let))
+ (//case.let! statement expression archive let)
+
+ (^ (synthesis.branch/if if))
+ (//case.if! statement expression archive if)
+
+ (^ (synthesis.loop/scope scope))
+ (do /////.monad
+ [[inits scope!] (//loop.scope! statement expression archive false scope)]
+ (in scope!))
+
+ (^ (synthesis.loop/recur updates))
+ (//loop.recur! statement expression archive updates)
+
+ (^ (synthesis.function/abstraction abstraction))
+ (/////\each _.return (//function.function statement expression archive abstraction))
+ ))
... TODO: Get rid of this ASAP
(def: lux::syntax_char_case!
@@ -62,12 +112,12 @@
(function (_ extension_name phase archive [input else conditionals])
(do {! /////.monad}
[inputG (phase archive input)
- elseG (phase archive else)
+ else! (..statement phase archive else)
@input (\ ! each _.var (generation.identifier "input"))
- conditionalsG (: (Operation (List [Expression Expression]))
+ conditionals! (: (Operation (List [Expression Statement]))
(monad.each ! (function (_ [chars branch])
(do !
- [branchG (phase archive branch)]
+ [branch! (..statement phase archive branch)]
(in [(|> chars
(list\each (|>> .int _.int (_.= @input)))
(list\mix (function (_ clause total)
@@ -75,14 +125,23 @@
clause
(_.or clause total)))
_.nil))
- branchG])))
+ branch!])))
conditionals))
- .let [closure (_.closure (list @input)
- (list\mix (function (_ [test then] else)
- (_.if test (_.return then) else))
- (_.return elseG)
- conditionalsG))]]
- (in (_.apply/1 closure inputG))))]))
+ ... .let [closure (_.closure (list @input)
+ ... (list\mix (function (_ [test then] else)
+ ... (_.if test (_.return then) else))
+ ... (_.return elseG)
+ ... conditionalsG))]
+ ]
+ ... (in (_.apply/1 closure inputG))
+ (in (<| (:as Expression)
+ (: Statement)
+ ($_ _.then
+ (_.set (list @input) inputG)
+ (list\mix (function (_ [test then!] else!)
+ (_.if test then! else!))
+ else!
+ conditionals!))))))]))
(def: lux_procs
Bundle
@@ -98,8 +157,8 @@
(/.install "and" (binary (product.uncurried _.bit_and)))
(/.install "or" (binary (product.uncurried _.bit_or)))
(/.install "xor" (binary (product.uncurried _.bit_xor)))
- (/.install "left-shift" (binary (product.uncurried //runtime.i64//left_shift)))
- (/.install "right-shift" (binary (product.uncurried //runtime.i64//right_shift)))
+ (/.install "left-shift" (binary (product.uncurried //runtime.i64//left_shifted)))
+ (/.install "right-shift" (binary (product.uncurried //runtime.i64//right_shifted)))
(/.install "=" (binary (product.uncurried _.=)))
(/.install "+" (binary (product.uncurried _.+)))
(/.install "-" (binary (product.uncurried _.-)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
index 78e4d7a4a..16ac4b882 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
@@ -140,13 +140,14 @@
... _ (generation.save! (product.right artifact_id) #.None closure)
]
... (in (_.apply/* @closure dependencies))
- (in (:as (Expression Any)
- ($_ _.then
- (_.set (list @input) inputG)
- (list\mix (function (_ [test then!] else!)
- (_.if test then! else!))
- else!
- conditionals!))))))]))
+ (in (<| (:as (Expression Any))
+ (: (Statement Any))
+ ($_ _.then
+ (_.set (list @input) inputG)
+ (list\mix (function (_ [test then!] else!)
+ (_.if test then! else!))
+ else!
+ conditionals!))))))]))
(def: lux_procs
Bundle
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
index 6579de615..b76af26be 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
@@ -601,12 +601,12 @@
(_.apply/1 (_.var "Math.log"))
(_./ (_.var "Math.LN2"))
(_.apply/1 (_.var "Math.ceil"))))
- (_.define delta (_.? (_.<= (_.i32 +48) log2)
- (_.i32 +1)
+ (_.define delta (_.? (_.> (_.i32 +48) log2)
(_.apply/2 (_.var "Math.pow")
(_.i32 +2)
(_.- (_.i32 +48)
- log2))))
+ log2))
+ (_.i32 +1)))
(_.define approximate_result approximate_result')
(_.define approximate_remainder approx_remainder)
(_.while (_.or (negative? approximate_remainder)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux
index 59dc82f3c..05fa66ca8 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux
@@ -8,7 +8,7 @@
[target
["_" lua]]]]
["." / #_
- [runtime (#+ Phase Phase!)]
+ [runtime (#+ Phase)]
["#." primitive]
["#." structure]
["#." reference]
@@ -18,7 +18,10 @@
["/#" // #_
["#." reference]
["/#" // #_
- ["#." extension]
+ ["#." extension
+ [generation
+ [lua
+ ["#/." common]]]]
["/#" // #_
[analysis (#+)]
["." synthesis]
@@ -27,44 +30,6 @@
[reference (#+)
[variable (#+)]]]]]]])
-(def: (statement expression archive synthesis)
- Phase!
- (case synthesis
- (^template [<tag>]
- [(^ (<tag> value))
- (//////phase\each _.return (expression archive synthesis))])
- ([synthesis.bit]
- [synthesis.i64]
- [synthesis.f64]
- [synthesis.text]
- [synthesis.variant]
- [synthesis.tuple]
- [#synthesis.Reference]
- [synthesis.branch/get]
- [synthesis.function/apply]
- [#synthesis.Extension])
-
- (^ (synthesis.branch/case case))
- (/case.case! statement expression archive case)
-
- (^ (synthesis.branch/let let))
- (/case.let! statement expression archive let)
-
- (^ (synthesis.branch/if if))
- (/case.if! statement expression archive if)
-
- (^ (synthesis.loop/scope scope))
- (do //////phase.monad
- [[inits scope!] (/loop.scope! statement expression archive false scope)]
- (in scope!))
-
- (^ (synthesis.loop/recur updates))
- (/loop.recur! statement expression archive updates)
-
- (^ (synthesis.function/abstraction abstraction))
- (//////phase\each _.return (/function.function statement expression archive abstraction))
- ))
-
(exception: .public cannot_recur_as_an_expression)
(def: (expression archive synthesis)
@@ -88,7 +53,7 @@
(//reference.reference /reference.system archive value)
(^ (synthesis.branch/case case))
- (/case.case ..statement expression archive case)
+ (/case.case ///extension/common.statement expression archive case)
(^ (synthesis.branch/let let))
(/case.let expression archive let)
@@ -100,13 +65,13 @@
(/case.get expression archive get)
(^ (synthesis.loop/scope scope))
- (/loop.scope ..statement expression archive scope)
+ (/loop.scope ///extension/common.statement expression archive scope)
(^ (synthesis.loop/recur updates))
(//////phase.except ..cannot_recur_as_an_expression [])
(^ (synthesis.function/abstraction abstraction))
- (/function.function ..statement expression archive abstraction)
+ (/function.function ///extension/common.statement expression archive abstraction)
(^ (synthesis.function/apply application))
(/function.apply expression archive application)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
index 0d96c3150..f88bc1d3a 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
@@ -1,6 +1,6 @@
(.module:
[library
- [lux (#- function)
+ [lux (#- Tuple Variant function)
[abstract
["." monad (#+ do)]]
[control
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux
index 59d70ae69..ebb503f26 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux
@@ -1,6 +1,6 @@
(.module:
[library
- [lux #*
+ [lux (#- Tuple Variant)
[abstract
["." monad (#+ do)]]
[target
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux
index 5d91dbde7..26c962945 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux
@@ -180,10 +180,10 @@
(runtime: (i64::unsigned_low input)
(with_vars [low]
($_ _.then
- (_.set! low (|> input (_.item (_.string ..i64_low_field))))
- (_.if (|> low (_.>= (_.int +0)))
- low
- (|> low (_.+ f2^32))))))
+ (_.set! low (_.item (_.string ..i64_low_field) input))
+ (_.if (_.< (_.int +0) low)
+ (_.+ f2^32 low)
+ low))))
(runtime: (i64::float input)
(let [high (|> input
@@ -423,9 +423,10 @@
(i64::new high low))])
(let [low (|> (i64_high input)
(i64::arithmetic_right_shifted_32 (|> shift (_.- (_.int +32)))))
- high (_.if (|> (i64_high input) (_.>= (_.int +0)))
- (_.int +0)
- (_.int -1))]
+ high (_.if (_.< (_.int +0)
+ (i64_high input))
+ (_.int -1)
+ (_.int +0))]
(i64::new high low)))))
(runtime: (i64::/ param subject)
@@ -485,10 +486,10 @@
(_.var "floor"))
calc_approximate_result (i64::of_float approximate)
calc_approximate_remainder (|> approximate_result (i64::* param))
- delta (_.if (|> (_.float +48.0) (_.<= log2))
- (_.float +1.0)
+ delta (_.if (_.> log2 (_.float +48.0))
(_.** (|> log2 (_.- (_.float +48.0)))
- (_.float +2.0)))]
+ (_.float +2.0))
+ (_.float +1.0))]
($_ _.then
(_.set! approximate (_.apply (list (_.float +1.0) calc_rough_estimate)
(_.var "max")))
@@ -722,15 +723,6 @@
(-> Expression Expression)
(|>> (_.+ (_.int +1))))
-(template [<name> <top_cmp>]
- [(def: (<name> top value)
- (-> Expression Expression Expression)
- (|> (|> value (_.>= (_.int +0)))
- (_.and (|> value (<top_cmp> top)))))]
-
- [within? _.<]
- )
-
(def: (text_clip start end text)
(-> Expression Expression Expression Expression)
(_.apply (list text start end)
@@ -745,7 +737,7 @@
($_ _.then
(_.set! startF (i64::float start))
(_.set! subjectL (text_length subject))
- (_.if (|> startF (within? subjectL))
+ (_.if (_.< subjectL startF)
($_ _.then
(_.set! idx (|> (_.apply_kw (list param (_.if (|> startF (_.= (_.int +0)))
subject
@@ -765,7 +757,7 @@
($_ _.then
(_.set! length (_.length text))
(_.set! to (_.+ additional minimum))
- (_.if (within? length to)
+ (_.if (_.< length to)
(..some (text_clip (++ minimum) (++ to) text))
..none))))
@@ -775,7 +767,7 @@
(_.var "utf8ToInt")))
(runtime: (text::char text idx)
- (_.if (|> idx (within? (_.length text)))
+ (_.if (_.< (_.length text) idx)
($_ _.then
(_.set! idx (++ idx))
(..some (i64::of_float (char_at idx text))))
@@ -791,9 +783,9 @@
(def: (check_index_out_of_bounds array idx body)
(-> Expression Expression Expression Expression)
- (_.if (|> idx (_.<= (_.length array)))
- body
- (_.stop (_.string "Array index out of bounds!"))))
+ (_.if (_.> (_.length array) idx)
+ (_.stop (_.string "Array index out of bounds!"))
+ body))
(runtime: (array::new size)
(with_vars [output]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux
index 75e27d5bf..b6544e285 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux
@@ -317,8 +317,9 @@
"Invalid expression for pattern-matching.")
(type: .public Storage
- {#bindings (Set Register)
- #dependencies (Set Variable)})
+ (Record
+ {#bindings (Set Register)
+ #dependencies (Set Variable)}))
(def: empty
Storage
diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux
index fb2baf861..60aebf7e9 100644
--- a/stdlib/source/library/lux/type.lux
+++ b/stdlib/source/library/lux/type.lux
@@ -1,5 +1,4 @@
(.module:
- {#.doc "Basic functionality for working with types."}
[library
[lux (#- function :as)
["@" target]
@@ -30,7 +29,6 @@
(template [<name> <tag>]
[(def: .public (<name> type)
- {#.doc (example "The number of parameters, and the body, of a quantified type.")}
(-> Type [Nat Type])
(loop [num_args 0
type type]
@@ -46,7 +44,6 @@
)
(def: .public (flat_function type)
- {#.doc (example "The input, and the output of a function type.")}
(-> Type [(List Type) Type])
(case type
(#.Function in out')
@@ -57,7 +54,6 @@
[(list) type]))
(def: .public (flat_application type)
- {#.doc (example "The quantified type, and its parameters, for a type-application.")}
(-> Type [Type (List Type)])
(case type
(#.Apply arg func')
@@ -69,7 +65,6 @@
(template [<name> <tag>]
[(def: .public (<name> type)
- {#.doc (example "The members of a composite type.")}
(-> Type (List Type))
(case type
(<tag> left right)
@@ -83,7 +78,6 @@
)
(def: .public (format type)
- {#.doc (example "A (readable) textual representable of a type.")}
(-> Type Text)
(case type
(#.Primitive name params)
@@ -227,7 +221,6 @@
))))
(def: .public (applied params func)
- {#.doc (example "To the extend possible, applies a quantified type to the given parameters.")}
(-> (List Type) Type (Maybe Type))
(case params
#.End
@@ -252,8 +245,6 @@
#.None)))
(def: .public (code type)
- {#.doc (example "A representation of a type as code."
- "The code is such that evaluating it would yield the type value.")}
(-> Type Code)
(case type
(#.Primitive name params)
@@ -282,7 +273,6 @@
))
(def: .public (de_aliased type)
- {#.doc (example "A (potentially named) type that does not have its name shadowed by other names.")}
(-> Type Type)
(case type
(#.Named _ (#.Named name type'))
@@ -292,7 +282,6 @@
type))
(def: .public (anonymous type)
- {#.doc (example "A type without any names covering it.")}
(-> Type Type)
(case type
(#.Named name type')
@@ -303,7 +292,6 @@
(template [<name> <base> <ctor>]
[(def: .public (<name> types)
- {#.doc (example "A composite type, constituted by the given member types.")}
(-> (List Type) Type)
(case types
#.End
@@ -320,7 +308,6 @@
)
(def: .public (function inputs output)
- {#.doc (example "A function type, with the given inputs and output.")}
(-> (List Type) Type Type)
(case inputs
#.End
@@ -330,7 +317,6 @@
(#.Function input (function inputs' output))))
(def: .public (application params quant)
- {#.doc (example "An un-evaluated type application, with the given quantified type, and parameters.")}
(-> (List Type) Type Type)
(case params
#.End
@@ -341,7 +327,6 @@
(template [<name> <tag>]
[(def: .public (<name> size body)
- {#.doc (example "A quantified type, with the given number of parameters, and body.")}
(-> Nat Type Type)
(case size
0 body
@@ -352,7 +337,6 @@
)
(def: .public (quantified? type)
- {#.doc (example "Only yields #1 for universally or existentially quantified types.")}
(-> Type Bit)
(case type
(#.Named [module name] _type)
@@ -370,7 +354,6 @@
#0))
(def: .public (array depth element_type)
- {#.doc (example "An array type, with the given level of nesting/depth, and the given element type.")}
(-> Nat Type Type)
(case depth
0 element_type
@@ -380,7 +363,6 @@
(#.Primitive array.type_name))))
(def: .public (flat_array type)
- {#.doc (example "The level of nesting/depth and element type for an array type.")}
(-> Type [Nat Type])
(case type
(^multi (^ (#.Primitive name (list element_type)))
@@ -392,7 +374,6 @@
[0 type]))
(def: .public array?
- {#.doc (example "Is a type an array type?")}
(-> Type Bit)
(|>> ..flat_array
product.left
@@ -408,12 +389,6 @@
(syntax: .public (:log! [input (<>.or (<>.and <code>.identifier
(<>.maybe (<>.after (<code>.identifier! ..secret_marker) <code>.any)))
<code>.any)])
- {#.doc (example "Logs to the console/terminal the type of an expression."
- (:log! (: Foo (foo expression)))
- "=>"
- "Expression: (foo expression)"
- " Type: Foo"
- (foo expression))}
(case input
(#.Left [valueN valueC])
(do meta.monad
@@ -445,15 +420,6 @@
input <code>.any
output <code>.any
value (<>.maybe <code>.any)])
- {#.doc (example "Casts a value to a specific type."
- "The specified type can depend on type variables of the original type of the value."
- (: (Bar Bit Nat Text)
- (:as [a b c]
- (Foo a [b c])
- (Bar a b c)
- (: (Foo Bit [Nat Text])
- (foo expression))))
- "NOTE: Careless use of type-casts is an easy way to introduce bugs. USE WITH CAUTION.")}
(let [casterC (` (: (All [(~+ (list\each code.local_identifier type_vars))]
(-> (~ input) (~ output)))
(|>> :expected)))]
@@ -477,15 +443,6 @@
(syntax: .public (:sharing [type_vars ..type_parameters
exemplar ..typed
computation ..typed])
- {#.doc (example "Allows specifing the type of an expression as sharing type-variables with the type of another expression."
- (: (Bar Bit Nat Text)
- (:sharing [a b c]
- (Foo a [b c])
- (: (Foo Bit [Nat Text])
- (foo expression))
-
- (Bar a b c)
- (bar expression))))}
(macro.with_identifiers [g!_]
(let [shareC (` (: (All [(~+ (list\each code.local_identifier type_vars))]
(-> (~ (value@ #type exemplar))
@@ -497,16 +454,6 @@
(syntax: .public (:by_example [type_vars ..type_parameters
exemplar ..typed
extraction <code>.any])
- {#.doc (example "Constructs a type that shares type-variables with an expression of some other type."
- (: Type
- (:by_example [a b c]
- (Foo a [b c])
- (: (Foo Bit [Nat Text])
- (foo expression))
-
- (Bar a b c)))
- "=>"
- (.type (Bar Bit Nat Text)))}
(in (list (` (:of ((~! :sharing)
[(~+ (list\each code.local_identifier type_vars))]
diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux
index 2d57a12d7..aaac468d1 100644
--- a/stdlib/source/library/lux/type/check.lux
+++ b/stdlib/source/library/lux/type/check.lux
@@ -204,13 +204,13 @@
(exception.except ..unknown_type_var id))))]
[bound? Bit false true]
- [read' (Maybe Type) #.None (#.Some bound)]
+ [peek (Maybe Type) #.None (#.Some bound)]
)
(def: .public (read id)
(-> Var (Check Type))
(do ..monad
- [?type (read' id)]
+ [?type (peek id)]
(case ?type
(#.Some type)
(in type)
@@ -270,7 +270,7 @@
(case funcT
(#.Var func_id)
(do ..monad
- [?funcT' (read' func_id)]
+ [?funcT' (peek func_id)]
(case ?funcT'
(#.Some funcT')
(on argT funcT')
@@ -369,7 +369,7 @@
_ (monad.each ! (re_bind type) (set.list ring))]
then)
(do ..monad
- [?bound (read' id)]
+ [?bound (peek id)]
(else (maybe.else (#.Var id) ?bound)))))
... TODO: "link/2" can be optimized...
@@ -546,11 +546,12 @@
(def: (with exception parameter check)
(All [e a] (-> (Exception e) e (Check a) (Check a)))
- (|>> check (exception.with exception parameter)))
+ (|>> check
+ (exception.with exception parameter)))
... TODO: "check'" can be optimized...
+... Type-check to ensure that the 'expected' type subsumes the 'actual' type.
(def: (check' assumptions expected actual)
- {#.doc "Type-check to ensure that the 'expected' type subsumes the 'actual' type."}
(Checker Type)
(if (for {@.php false} ... TODO: Remove this once JPHP is gone.
(same? expected actual))
@@ -664,7 +665,8 @@
(def: .public (subsumes? expected actual)
(-> Type Type Bit)
- (case (..result ..fresh_context (..check' (list) expected actual))
+ (case (..result ..fresh_context
+ (..check expected actual))
(#try.Failure _)
false
@@ -697,7 +699,7 @@
(#.Var id)
(do ..monad
- [?actualT (read' id)]
+ [?actualT (peek id)]
(case ?actualT
(#.Some actualT)
(clean actualT)
diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux
index be7663444..42da7c4d7 100644
--- a/stdlib/source/library/lux/type/quotient.lux
+++ b/stdlib/source/library/lux/type/quotient.lux
@@ -12,7 +12,7 @@
abstract]]])
(abstract: .public (Class t c %)
- {#.doc (example "The class knows how to classify/label values that are meant to be equivalent to one another.")}
+ {}
(-> t c)
@@ -23,9 +23,7 @@
(|>> :abstraction))
(abstract: .public (Quotient t c %)
- {#.doc (example "A quotient value has been labeled with a class."
- "All equivalent values will belong to the same class."
- "This means all equivalent values possess the same label.")}
+ {}
(Record
{#value t
@@ -50,16 +48,6 @@
)
(syntax: .public (type [class <code>.any])
- {#.doc (example "The Quotient type associated with a Class type."
- (def: even
- (class even?))
-
- (def: Even
- Type
- (type even))
-
- (: Even
- (quotient even 123)))}
(with_identifiers [g!t g!c g!%]
(in (list (` ((~! type.:by_example)
[(~ g!t) (~ g!c) (~ g!%)]
diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux
index 2ab800d2c..03d064acc 100644
--- a/stdlib/source/library/lux/type/refinement.lux
+++ b/stdlib/source/library/lux/type/refinement.lux
@@ -12,14 +12,13 @@
abstract]]])
(abstract: .public (Refined t %)
- {#.doc "A refined version of another type, using a predicate to select valid instances."}
+ {}
(Record
{#value t
#predicate (Predicate t)})
(type: .public (Refiner t %)
- {#.doc (example "A selection mechanism for refined instances of a type.")}
(-> t (Maybe (Refined t %))))
(def: .public (refiner predicate)
@@ -42,8 +41,6 @@
)
(def: .public (lifted transform)
- {#.doc (example "Yields a function that can work on refined values."
- "Respects the constraints of the refinement.")}
(All [t %]
(-> (-> t t)
(-> (Refined t %) (Maybe (Refined t %)))))
@@ -72,7 +69,6 @@
(only refiner tail))))
(def: .public (partition refiner values)
- {#.doc (example "Separates refined values from the un-refined ones.")}
(All [t %]
(-> (Refiner t %) (List t) [(List (Refined t %)) (List t)]))
(case values
@@ -91,16 +87,6 @@
(#.Item head no)]))))
(syntax: .public (type [refiner <code>.any])
- {#.doc (example "The Refined type associated with a Refiner type."
- (def: even
- (refiner even?))
-
- (def: Even
- Type
- (type even))
-
- (: (Maybe Even)
- (even 123)))}
(macro.with_identifiers [g!t g!%]
(in (list (` ((~! type.:by_example) [(~ g!t) (~ g!%)]
(..Refiner (~ g!t) (~ g!%))
diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux
index 796bf4e4d..b07f56303 100644
--- a/stdlib/source/library/lux/type/resource.lux
+++ b/stdlib/source/library/lux/type/resource.lux
@@ -26,25 +26,17 @@
abstract]]])
(type: .public (Procedure monad input output value)
- {#.doc (example "A computation that takes a sequence of resource access rights as inputs and yields a different sequence as outputs."
- "A procedure yields a result value."
- "A procedure can make use of monadic effects.")}
(-> input (monad [output value])))
(type: .public (Linear monad value)
- {#.doc (example "A procedure that is constant with regards to resource access rights."
- "This means no additional resources will be available after the computation is over."
- "This also means no previously available resources will have been consumed.")}
(All [keys]
(Procedure monad keys keys value)))
(type: .public (Affine monad permissions value)
- {#.doc (example "A procedure which expands the number of available resources.")}
(All [keys]
(Procedure monad keys [permissions keys] value)))
(type: .public (Relevant monad permissions value)
- {#.doc (example "A procedure which reduces the number of available resources.")}
(All [keys]
(Procedure monad [permissions keys] keys value)))
@@ -74,17 +66,11 @@
[output procedure]
(in [keys output]))))
-(abstract: .public Ordered
- {#.doc (example "The mode of keys which CANNOT be swapped, and for whom order of release/consumption matters.")}
- Any)
-
-(abstract: .public Commutative
- {#.doc (example "The mode of keys which CAN be swapped, and for whom order of release/consumption DOES NOT matters.")}
- Any)
+(abstract: .public Ordered {} Any)
+(abstract: .public Commutative {} Any)
(abstract: .public (Key mode key)
- {#.doc (example "The access right for a resource."
- "Without the key for a resource existing somewhere among the available ambient rights, one cannot use a resource.")}
+ {}
Any
@@ -98,14 +84,12 @@
))
(abstract: .public (Res key value)
- {#.doc (example "A resource locked by a key."
- "The 'key' represents the right to access/consume a resource.")}
+ {}
value
(template [<name> <mode> <key>]
[(def: .public (<name> monad value)
- {#.doc (example "Makes a value into a resource and adds the key/access-right to it to the ambient keyring for future use.")}
(All [! v] (Ex [k] (-> (Monad !) v (Affine ! (Key <mode> k) (Res k v)))))
(function (_ keys)
(\ monad in [[(<key> []) keys] (:abstraction value)])))]
@@ -115,7 +99,6 @@
)
(def: .public (read monad resource)
- {#.doc (example "Access the value of a resource, so long as its key is available.")}
(All [! v k m]
(-> (Monad !) (Res k v) (Relevant ! (Key m k) v)))
(function (_ [key keys])
@@ -148,16 +131,6 @@
(\ monad in [context []])))
(syntax: .public (exchange [swaps ..indices])
- {#.doc (example "A function that can exchange the keys for resource, so long as they are commutative."
- "This keys will be placed at the front of the keyring in the order they are specified."
- "The specific keys must be specified based of their index into the current keyring."
- (do (..monad !)
- [res|left (commutative ! pre)
- res|right (commutative ! post)
- _ ((exchange [1 0]) !)
- left (read ! res|left)
- right (read ! res|right)]
- (in (format left right))))}
(macro.with_identifiers [g!_ g!context g!!]
(case swaps
#.End
@@ -197,15 +170,6 @@
(template [<name> <from> <to>]
[(syntax: .public (<name> [amount ..amount])
- {#.doc (example "Group/un-group keys in the keyring into/out-of tuples."
- (do (..monad !)
- [res|left (commutative ! pre)
- res|right (commutative ! post)
- _ ((group 2) !)
- _ ((un_group 2) !)
- right (read ! res|right)
- left (read ! res|left)]
- (in (format left right))))}
(macro.with_identifiers [g!_ g!context g!!]
(do {! meta.monad}
[g!keys (|> (macro.identifier "keys")
diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux
index e18af25b0..c4f1e5e58 100644
--- a/stdlib/source/library/lux/type/unit.lux
+++ b/stdlib/source/library/lux/type/unit.lux
@@ -28,7 +28,7 @@
abstract]]])
(abstract: .public (Qty unit)
- {#.doc (example "A quantity with an associated unit of measurement.")}
+ {}
Int
@@ -62,14 +62,12 @@
)
(interface: .public (Unit a)
- {#.doc (example "A unit of measurement, to qualify numbers with.")}
(: (-> Int (Qty a))
in)
(: (-> (Qty a) Int)
out))
(interface: .public (Scale s)
- {#.doc (example "A scale of magnitude.")}
(: (All [u] (-> (Qty u) (Qty (s u))))
scale)
(: (All [u] (-> (Qty (s u)) (Qty u)))
@@ -78,7 +76,6 @@
ratio))
(type: .public Pure
- {#.doc (example "A pure, unit-less quantity.")}
(Qty Any))
(def: .public pure
@@ -95,10 +92,6 @@
<code>.local_identifier
<code>.local_identifier
(<>.else |annotations|.empty |annotations|.parser)))])
- {#.doc (example "Define a unit of measurement."
- "Both the name of the type, and the name of the Unit implementation must be specified."
- (unit: .public Feet feet
- {#.doc (example "Optional annotations.")}))}
(do meta.monad
[@ meta.current_module_name
.let [g!type (code.local_identifier type_name)]]
@@ -131,10 +124,6 @@
<code>.local_identifier
..scale
(<>.else |annotations|.empty |annotations|.parser)))])
- {#.doc (example "Define a scale of magnitude."
- (scale: .public Bajillion bajillion
- [1 1,234,567,890]
- {#.doc (example "Optional annotations.")}))}
(do meta.monad
[.let [(^slots [#ratio.numerator #ratio.denominator]) ratio]
@ meta.current_module_name
@@ -176,8 +165,7 @@
(template [<type> <from> <to>]
[(`` (scale: .public <type>
(~~ (implementation_name <type>))
- [<from> <to>]
- {#.doc (example (~~ (template.text ["'" <type> "' scale from " <from> " to " <to> "."])))}))]
+ [<from> <to>]))]
[Kilo 1 1,000]
[Mega 1 1,000,000]
@@ -190,8 +178,7 @@
(template [<type>]
[(`` (unit: .public <type>
- (~~ (implementation_name <type>))
- {#.doc (example (~~ (template.text ["'" <type> "' unit of meaurement."])))}))]
+ (~~ (implementation_name <type>))))]
[Gram]
[Meter]
diff --git a/stdlib/source/library/lux/type/variance.lux b/stdlib/source/library/lux/type/variance.lux
index 8502ec6fa..2a7d65267 100644
--- a/stdlib/source/library/lux/type/variance.lux
+++ b/stdlib/source/library/lux/type/variance.lux
@@ -3,13 +3,10 @@
[lux #*]])
(type: .public (Co t)
- {#.doc (example "A constraint for covariant types.")}
(-> Any t))
(type: .public (Contra t)
- {#.doc (example "A constraint for contravariant types.")}
(-> t Any))
(type: .public (In t)
- {#.doc (example "A constraint for invariant types.")}
(-> t t))
diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux
index 4f52cacb1..02d4ee299 100644
--- a/stdlib/source/library/lux/world/console.lux
+++ b/stdlib/source/library/lux/world/console.lux
@@ -17,8 +17,6 @@
["%" format (#+ format)]]]]])
(interface: .public (Console !)
- {#.doc (example "An interface to console/terminal I/O.")}
-
(: (-> [] (! (Try Char)))
read)
(: (-> [] (! (Try Text)))
@@ -101,14 +99,10 @@
(as_is)))
(def: .public (write_line message console)
- {#.doc (example "Writes the message on the console and appends a new-line/line-feed at the end.")}
(All [!] (-> Text (Console !) (! (Try Any))))
(\ console write (format message text.new_line)))
(interface: .public (Mock s)
- {#.doc (example "A mock/simulation of a console."
- "Useful for testing.")}
-
(: (-> s (Try [s Char]))
on_read)
(: (-> s (Try [s Text]))
diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux
index 08bffdb97..d9676e54e 100644
--- a/stdlib/source/library/lux/world/file.lux
+++ b/stdlib/source/library/lux/world/file.lux
@@ -36,12 +36,9 @@
["." duration]]]])
(type: .public Path
- {#.doc (example "A path to a file or a directory in a file-system.")}
Text)
(`` (interface: .public (System !)
- {#.doc (example "An interface to a file-system.")}
-
(: Text
separator)
@@ -93,14 +90,12 @@
(in [parent child])))))
(def: .public (parent fs path)
- {#.doc (example "If a path represents a nested file/directory, extracts its parent directory.")}
(All [!] (-> (System !) Path (Maybe Path)))
(|> path
(..un_rooted fs)
(maybe\each product.left)))
(def: .public (name fs path)
- {#.doc (example "The un-nested name of a file/directory.")}
(All [!] (-> (System !) Path Text))
(|> path
(..un_rooted fs)
@@ -142,7 +137,6 @@
)))
(def: .public (rooted fs parent child)
- {#.doc (example "A nested path for a file/directory, given a root/parent path and a file/directory name within it.")}
(All [!] (-> (System !) Path Text Path))
(format parent (\ fs separator) child))
@@ -236,7 +230,7 @@
(case ?children
(#.Some children)
(|> children
- array.list
+ (array.list #.None)
(monad.only ! (|>> <method>))
(\ ! each (monad.each ! (|>> java/io/File::getAbsolutePath)))
(\ ! conjoint))
@@ -455,7 +449,7 @@
subs (with_async write! (Try (Array ffi.String))
(Fs::readdir [path (..value_callback write!)] node_fs))]
(|> subs
- array.list
+ (array.list #.None)
(list\each (|>> (format path ..js_separator)))
(monad.each ! (function (_ sub)
(\ ! each (|>> (<method> []) [sub])
@@ -602,7 +596,7 @@
(let [! (try.with io.monad)]
(|> path
os::listdir
- (\ ! each (|>> array.list
+ (\ ! each (|>> (array.list #.None)
(list\each (|>> (format path ..python_separator)))
(monad.each ! (function (_ sub)
(\ ! each (|>> [sub]) (<method> [sub]))))
@@ -729,7 +723,7 @@
[self (RubyDir::open [path])
children (RubyDir::children [] self)
output (loop [input (|> children
- array.list
+ (array.list #.None)
(list\each (|>> (format path ..ruby_separator))))
output (: (List ..Path)
(list))]
@@ -922,7 +916,7 @@
... (do {! (try.with io.monad)}
... [children (..scandir [path])]
... (loop [input (|> children
- ... array.list
+ ... (array.list #.None)
... (list.only (function (_ child)
... (not (or (text\= "." child)
... (text\= ".." child))))))
@@ -991,7 +985,6 @@
(as_is)))
(def: .public (exists? monad fs path)
- {#.doc (example "Checks if either a file or a directory exists at the given path.")}
(All [!] (-> (Monad !) (System !) Path (! Bit)))
(do monad
[verdict (\ fs file? path)]
@@ -1178,8 +1171,6 @@
(recur sub_directory tail)))))))
(def: .public (mock separator)
- {#.doc (example "A purely in-memory simulation of a file-system."
- "Useful for testing.")}
(-> Text (System Async))
(let [store (stm.var ..empty_mock)]
(`` (implementation
@@ -1328,8 +1319,6 @@
(\ fs make_directory path))))
(def: .public (make_directories monad fs path)
- {#.doc (example "Creates the directory specified by the given path."
- "Also, creates every super-directory necessary to make the given path valid.")}
(All [!] (-> (Monad !) (System !) Path (! (Try Any))))
(let [rooted? (text.starts_with? (\ fs separator) path)
segments (text.all_split_by (\ fs separator) path)]
@@ -1362,7 +1351,6 @@
(in (#try.Failure error)))))))))
(def: .public (make_file monad fs content path)
- {#.doc (example "Creates a new file with the given content if-and-only-if the file does not already exist.")}
(All [!] (-> (Monad !) (System !) Binary Path (! (Try Any))))
(do monad
[? (\ fs file? path)]
diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux
index 35dfb894d..581beba6d 100644
--- a/stdlib/source/library/lux/world/file/watch.lux
+++ b/stdlib/source/library/lux/world/file/watch.lux
@@ -33,7 +33,7 @@
["." //])
(abstract: .public Concern
- {#.doc (example "A particular concern to watch-out for.")}
+ {}
(Record
{#creation Bit
@@ -84,8 +84,6 @@
)
(interface: .public (Watcher !)
- {#.doc (example "Machinery for watching a file-system for changes to files and directories.")}
-
(: (-> Concern //.Path (! (Try Any)))
start)
(: (-> //.Path (! (Try Concern)))
@@ -188,8 +186,6 @@
deletions]])))
(def: .public (polling fs)
- {#.doc (example "A simple watcher that works for any file-system."
- "Polls files and directories to detect changes.")}
(-> (//.System Async) (Watcher Async))
(let [tracker (: (Var Directory_Tracker)
(stm.var (dictionary.empty text.hash)))]
@@ -262,8 +258,6 @@
)))
(def: .public (mock separator)
- {#.doc (example "A fake/emulated watcher."
- "Must be given a path separator for the file-system.")}
(-> Text [(//.System Async) (Watcher Async)])
(let [fs (//.mock separator)]
[fs
@@ -415,7 +409,6 @@
))
(def: .public default
- {#.doc (example "The default watcher for the default file-system.")}
(IO (Try (Watcher Async)))
(do (try.with io.monad)
[watcher (java/nio/file/FileSystem::newWatchService
diff --git a/stdlib/source/library/lux/world/input/keyboard.lux b/stdlib/source/library/lux/world/input/keyboard.lux
index e33e8c4a7..b22f9b792 100644
--- a/stdlib/source/library/lux/world/input/keyboard.lux
+++ b/stdlib/source/library/lux/world/input/keyboard.lux
@@ -3,7 +3,6 @@
[lux #*]])
(type: .public Key
- {#.doc (example "A key from a keyboard, identify by a numeric ID.")}
Nat)
(template [<code> <name>]
@@ -99,7 +98,6 @@
)
(type: .public Press
- {#.doc (example "A key-press for a key.")}
(Record
{#pressed? Bit
#input Key}))
diff --git a/stdlib/source/library/lux/world/net.lux b/stdlib/source/library/lux/world/net.lux
index fae3c1f78..606202f9b 100644
--- a/stdlib/source/library/lux/world/net.lux
+++ b/stdlib/source/library/lux/world/net.lux
@@ -3,15 +3,12 @@
[lux (#- Location)]])
(type: .public Address
- {#.doc (example "A TCP/IP address.")}
Text)
(type: .public Port
- {#.doc (example "A TCP/IP port.")}
Nat)
(type: .public URL
- {#.doc (example "A Uniform Resource Locator.")}
Text)
(type: .public Location
diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux
index eaf97a16e..4790ab3c5 100644
--- a/stdlib/source/library/lux/world/net/http/client.lux
+++ b/stdlib/source/library/lux/world/net/http/client.lux
@@ -31,24 +31,16 @@
[// (#+ URL)]])
(interface: .public (Client !)
- {#.doc (example "A HTTP client capable of issuing requests to a HTTP server.")}
-
(: (-> //.Method URL //.Headers (Maybe Binary)
(! (Try (//.Response !))))
request))
-(syntax: (method_name [[_ name] <code>.tag])
- (in (list (code.text (text.upper_cased name)))))
-
(syntax: (method_function [[_ name] <code>.tag])
(in (list (code.local_identifier (text.lower_cased name)))))
(template [<method>]
- [(with_expansions [<name> (method_function <method>)
- <method_name> (method_name <method>)
- <documentation> (template.text ["A " <method_name> " request."])]
+ [(with_expansions [<name> (method_function <method>)]
(def: .public (<name> url headers data client)
- {#.doc (example <documentation>)}
(All [!]
(-> URL //.Headers (Maybe Binary) (Client !)
(! (Try (//.Response !)))))
diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux
index 9689e3414..c3bcd9be6 100644
--- a/stdlib/source/library/lux/world/net/http/route.lux
+++ b/stdlib/source/library/lux/world/net/http/route.lux
@@ -58,7 +58,7 @@
(server [identification
protocol
(revised@ #//.uri
- (|>> (text.clip' (text.size path)) maybe.trusted)
+ (|>> (text.clip_since (text.size path)) maybe.trusted)
resource)
message])
(async.resolved //response.not_found))))
diff --git a/stdlib/source/library/lux/world/net/http/status.lux b/stdlib/source/library/lux/world/net/http/status.lux
index b0111e660..e7810c7fa 100644
--- a/stdlib/source/library/lux/world/net/http/status.lux
+++ b/stdlib/source/library/lux/world/net/http/status.lux
@@ -1,28 +1,13 @@
(.module:
[library
- [lux #*
- [control
- [parser
- ["<.>" code]]]
- [data
- ["." text]]
- [macro
- [syntax (#+ syntax:)]
- ["." code]
- ["." template]]]]
+ [lux #*]]
[// (#+ Status)])
-(syntax: (status_description [name <code>.local_identifier])
- (in (list (code.text (text.replaced "_" " " name)))))
-
... https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
(template [<status> <name>]
- [(with_expansions [<description> (status_description <name>)
- <documentation> (template.text [<status> ": " <description>])]
- (def: .public <name>
- {#.doc <documentation>}
- Status
- <status>))]
+ [(def: .public <name>
+ Status
+ <status>)]
... 1xx Informational response
[100 continue]
diff --git a/stdlib/source/library/lux/world/net/uri.lux b/stdlib/source/library/lux/world/net/uri.lux
index 84df2b716..b25d6c40e 100644
--- a/stdlib/source/library/lux/world/net/uri.lux
+++ b/stdlib/source/library/lux/world/net/uri.lux
@@ -4,9 +4,7 @@
... https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
(type: .public URI
- {#.doc (example "A Uniform Resource Identifier.")}
Text)
(def: .public separator
- {#.doc (example "A separator for the pieces of a URI.")}
"/")
diff --git a/stdlib/source/library/lux/world/output/video/resolution.lux b/stdlib/source/library/lux/world/output/video/resolution.lux
index 973cdac9b..8bf8a1bd7 100644
--- a/stdlib/source/library/lux/world/output/video/resolution.lux
+++ b/stdlib/source/library/lux/world/output/video/resolution.lux
@@ -4,22 +4,13 @@
[abstract
[equivalence (#+ Equivalence)]
[hash (#+ Hash)]]
- [control
- [parser
- ["<.>" code]]]
[data
- ["." product]
- ["." text]]
- [macro
- [syntax (#+ syntax:)]
- ["." code]
- ["." template]]
+ ["." product]]
[math
[number
["." nat]]]]])
(type: .public Resolution
- {#.doc (example "A screen resolution.")}
(Record
{#width Nat
#height Nat}))
@@ -32,22 +23,12 @@
(Equivalence Resolution)
(\ ..hash &equivalence))
-(syntax: (description [name <code>.local_identifier])
- (in (list (|> name
- (text.replaced "/" " ")
- (text.replaced "_" " ")
- text.upper_cased
- code.text))))
-
... https://en.wikipedia.org/wiki/Display_resolution#Common_display_resolutions
(template [<name> <width> <height>]
- [(with_expansions [<description> (..description <name>)
- <documentation> (template.text [<description> " resolution: " <width> "x" <height> "."])]
- (def: .public <name>
- {#.doc <documentation>}
- Resolution
- {#width <width>
- #height <height>}))]
+ [(def: .public <name>
+ Resolution
+ {#width <width>
+ #height <height>})]
[svga 800 600]
[wsvga 1024 600]
diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux
index 6262649aa..00aa1553d 100644
--- a/stdlib/source/library/lux/world/program.lux
+++ b/stdlib/source/library/lux/world/program.lux
@@ -40,8 +40,6 @@
["Name" (%.text name)]))
(interface: .public (Program !)
- {#.doc (example "Access to ambient program data and the capacity to exit the program.")}
-
(: (-> Any (! (List Text)))
available_variables)
(: (-> Text (! (Try Text)))
@@ -54,7 +52,6 @@
exit))
(def: .public (environment monad program)
- {#.doc (example "Assembles the environment variables available to the program.")}
(All [!] (-> (Monad !) (Program !) (! Environment)))
(do {! monad}
[variables (\ program available_variables [])
diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux
index 209c161bd..470ac4cd2 100644
--- a/stdlib/source/library/lux/world/shell.lux
+++ b/stdlib/source/library/lux/world/shell.lux
@@ -34,7 +34,6 @@
[file (#+ Path)]])
(type: .public Exit
- {#.doc (example "A program exit code.")}
Int)
(template [<code> <name>]
@@ -47,8 +46,6 @@
)
(interface: .public (Process !)
- {#.doc (example "The means for communicating with a program/process being executed by the operating system.")}
-
(: (-> [] (! (Try Text)))
read)
(: (-> [] (! (Try Text)))
@@ -76,16 +73,12 @@
)))))
(type: .public Command
- {#.doc (example "A command that can be executed by the operating system.")}
Text)
(type: .public Argument
- {#.doc (example "A parameter for a command.")}
Text)
(interface: .public (Shell !)
- {#.doc (example "The means for issuing commands to the operating system.")}
-
(: (-> [Environment Path Command (List Argument)] (! (Try (Process !))))
execute))
@@ -315,8 +308,6 @@
(as_is)))
(interface: .public (Mock s)
- {#.doc (example "A simulated process.")}
-
(: (-> s (Try [s Text]))
on_read)
(: (-> s (Try [s Text]))
diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux
index 0637d36b8..2e557839b 100644
--- a/stdlib/source/program/aedifex.lux
+++ b/stdlib/source/program/aedifex.lux
@@ -124,7 +124,7 @@
(..fail! error))))
(\ io.monad in [])))
-(program: [[profile operation] /cli.command]
+(program: [[profiles operation] /cli.command]
(do {! io.monad}
[?console console.default]
(case (try\each console.async ?console)
@@ -139,7 +139,7 @@
_
(do !
- [?profile (/input.read io.monad file.default profile)]
+ [?profile (/input.read io.monad file.default profiles)]
(case ?profile
(#try.Failure error)
(..fail! error)
diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux
index 8aca29ea0..9645ba1f8 100644
--- a/stdlib/source/program/aedifex/artifact.lux
+++ b/stdlib/source/program/aedifex/artifact.lux
@@ -26,9 +26,10 @@
Text)
(type: .public Artifact
- {#group Group
- #name Name
- #version Version})
+ (Record
+ {#group Group
+ #name Name
+ #version Version}))
(def: .public hash
(Hash Artifact)
diff --git a/stdlib/source/program/aedifex/artifact/snapshot.lux b/stdlib/source/program/aedifex/artifact/snapshot.lux
index 133b6c4cc..936419788 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot.lux
@@ -16,8 +16,9 @@
["#." stamp (#+ Stamp)]])
(type: .public Snapshot
- #Local
- (#Remote Stamp))
+ (Variant
+ #Local
+ (#Remote Stamp)))
(implementation: any_equivalence
(Equivalence Any)
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
index 609de1013..d8d1e6bbc 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
@@ -17,8 +17,9 @@
["#." build (#+ Build)]])
(type: .public Stamp
- {#time Time
- #build Build})
+ (Record
+ {#time Time
+ #build Build}))
(def: .public equivalence
(Equivalence Stamp)
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/version.lux b/stdlib/source/program/aedifex/artifact/snapshot/version.lux
index 13f2b5692..aa2994958 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/version.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/version.lux
@@ -18,9 +18,10 @@
["#." time (#+ Time)]])
(type: .public Version
- {#extension Type
- #value Text
- #updated Time})
+ (Record
+ {#extension Type
+ #value Text
+ #updated Time}))
(def: .public equivalence
(Equivalence Version)
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux
index 63681a3fe..cfcf3be09 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux
@@ -12,8 +12,9 @@
["#." stamp]])
(type: .public Value
- {#version Text
- #snapshot Snapshot})
+ (Record
+ {#version Text
+ #snapshot Snapshot}))
(def: .public equivalence
(Equivalence Value)
diff --git a/stdlib/source/program/aedifex/artifact/time/date.lux b/stdlib/source/program/aedifex/artifact/time/date.lux
index c3c0b9cc1..ca309e382 100644
--- a/stdlib/source/program/aedifex/artifact/time/date.lux
+++ b/stdlib/source/program/aedifex/artifact/time/date.lux
@@ -50,10 +50,10 @@
(def: .public (date raw)
(-> date.Date (Try Date))
(let [year (|> raw date.year year.value)]
- (if (and (i.>= ..min_year year)
- (i.<= ..max_year year))
- (#try.Success (:abstraction raw))
- (exception.except ..year_is_out_of_range [(date.year raw)]))))
+ (if (or (i.< ..min_year year)
+ (i.> ..max_year year))
+ (exception.except ..year_is_out_of_range [(date.year raw)])
+ (#try.Success (:abstraction raw)))))
(def: .public value
(-> Date date.Date)
diff --git a/stdlib/source/program/aedifex/artifact/versioning.lux b/stdlib/source/program/aedifex/artifact/versioning.lux
index 886e89491..38001bfe2 100644
--- a/stdlib/source/program/aedifex/artifact/versioning.lux
+++ b/stdlib/source/program/aedifex/artifact/versioning.lux
@@ -30,9 +30,10 @@
["#/." version (#+ Version)]]])
(type: .public Versioning
- {#snapshot Snapshot
- #last_updated //time.Time
- #versions (List Version)})
+ (Record
+ {#snapshot Snapshot
+ #last_updated //time.Time
+ #versions (List Version)}))
(def: .public init
{#snapshot #//snapshot.Local
diff --git a/stdlib/source/program/aedifex/cli.lux b/stdlib/source/program/aedifex/cli.lux
index 87ad9938a..b51a0d1f1 100644
--- a/stdlib/source/program/aedifex/cli.lux
+++ b/stdlib/source/program/aedifex/cli.lux
@@ -2,7 +2,8 @@
[library
[lux (#- Name)
[abstract
- [equivalence (#+ Equivalence)]]
+ [equivalence (#+ Equivalence)]
+ [monad (#+ do)]]
[control
["<>" parser
["." cli (#+ Parser)]]]
@@ -16,8 +17,9 @@
["/" profile (#+ Name)]])
(type: .public Compilation
- #Build
- #Test)
+ (Variant
+ #Build
+ #Test))
(implementation: any_equivalence
(Equivalence Any)
@@ -36,14 +38,15 @@
(cli.this "test")))
(type: .public Command
- #Version
- #Clean
- #POM
- #Dependencies
- #Install
- (#Deploy Text Identity)
- (#Compilation Compilation)
- (#Auto Compilation))
+ (Variant
+ #Version
+ #Clean
+ #POM
+ #Dependencies
+ #Install
+ (#Deploy Text Identity)
+ (#Compilation Compilation)
+ (#Auto Compilation)))
(def: .public equivalence
(Equivalence Command)
@@ -86,12 +89,15 @@
))
(def: .public command
- (Parser [Name Command])
- ($_ <>.either
- (<>.after (cli.this "with")
- ($_ <>.and
- cli.any
- ..command'))
- (\ <>.monad each (|>> [/.default])
- ..command')
- ))
+ (Parser [(List Name) Command])
+ (<>.rec
+ (function (_ command)
+ ($_ <>.either
+ (<>.after (cli.this "with")
+ (do <>.monad
+ [head cli.any
+ [tail command] command]
+ (in [(#.Item head tail) command])))
+ (\ <>.monad each (|>> [(list /.default)])
+ ..command')
+ ))))
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index bf7c95870..ff4ace158 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -74,11 +74,12 @@
(exception: .public no_specified_program)
(type: .public Compiler
- (#JVM Dependency)
- (#JS Dependency)
- (#Python Dependency)
- (#Lua Dependency)
- (#Ruby Dependency))
+ (Variant
+ (#JVM Dependency)
+ (#JS Dependency)
+ (#Python Dependency)
+ (#Lua Dependency)
+ (#Ruby Dependency)))
(def: (remove_dependency dependency)
(-> Dependency (-> Resolution Resolution))
diff --git a/stdlib/source/program/aedifex/dependency.lux b/stdlib/source/program/aedifex/dependency.lux
index b1a23c0de..e1602990d 100644
--- a/stdlib/source/program/aedifex/dependency.lux
+++ b/stdlib/source/program/aedifex/dependency.lux
@@ -14,8 +14,9 @@
[type (#+ Type)]]])
(type: .public Dependency
- {#artifact Artifact
- #type Type})
+ (Record
+ {#artifact Artifact
+ #type Type}))
(def: .public hash
(Hash Dependency)
diff --git a/stdlib/source/program/aedifex/dependency/status.lux b/stdlib/source/program/aedifex/dependency/status.lux
index 2c2e13fd8..eac5c9fd0 100644
--- a/stdlib/source/program/aedifex/dependency/status.lux
+++ b/stdlib/source/program/aedifex/dependency/status.lux
@@ -11,10 +11,11 @@
["#." hash (#+ Hash SHA-1 MD5)]])
(type: .public Status
- #Unverified
- (#Partial (Either (Hash SHA-1)
- (Hash MD5)))
- (#Verified (Hash SHA-1) (Hash MD5)))
+ (Variant
+ #Unverified
+ (#Partial (Either (Hash SHA-1)
+ (Hash MD5)))
+ (#Verified (Hash SHA-1) (Hash MD5))))
(implementation: any_equivalence
(Equivalence Any)
diff --git a/stdlib/source/program/aedifex/input.lux b/stdlib/source/program/aedifex/input.lux
index 27591c709..43edc3404 100644
--- a/stdlib/source/program/aedifex/input.lux
+++ b/stdlib/source/program/aedifex/input.lux
@@ -1,8 +1,9 @@
(.module:
[library
- [lux #*
+ [lux (#- Name)
[abstract
- [monad (#+ Monad do)]]
+ ["." monad (#+ Monad do)]
+ ["." mix]]
[control
[pipe (#+ do>)]
["." try (#+ Try)]
@@ -12,7 +13,9 @@
[binary (#+ Binary)]
["." text
[encoding
- ["." utf8]]]]
+ ["." utf8]]]
+ [collection
+ ["." list]]]
[meta
["." location]]
[tool
@@ -23,7 +26,7 @@
[world
["." file]]]]
["." // #_
- [profile (#+ Profile)]
+ ["#." profile (#+ Name Profile)]
["#." project (#+ Project)]
["#." parser]])
@@ -46,11 +49,14 @@
[..lux_parser]
[(list) (<code>.result //parser.project)])))
-(def: .public (read monad fs profile)
- (All [!] (-> (Monad !) (file.System !) Text (! (Try Profile))))
+(def: .public (read monad fs profiles)
+ (All [!] (-> (Monad !) (file.System !) (List Name) (! (Try Profile))))
(|> //project.file
(\ fs read)
- (\ monad each (|>> (do> try.monad
- []
- [..project_parser]
- [(//project.profile profile)])))))
+ (\ monad each
+ (function (_ it)
+ (do {! try.monad}
+ [it it
+ it (..project_parser it)
+ it (monad.each ! (//project.profile it) profiles)]
+ (in (mix.with_monoid //profile.monoid list.mix it)))))))
diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux
index 85fe747bd..3a6ffb74f 100644
--- a/stdlib/source/program/aedifex/metadata/artifact.lux
+++ b/stdlib/source/program/aedifex/metadata/artifact.lux
@@ -39,10 +39,11 @@
["#." artifact (#+ Group Name Version Artifact)]]])
(type: .public Metadata
- {#group Group
- #name Name
- #versions (List Version)
- #last_updated Instant})
+ (Record
+ {#group Group
+ #name Name
+ #versions (List Version)
+ #last_updated Instant}))
(def: (pad value)
(-> Nat Text)
diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux
index 3a3464cd6..d5e9483bf 100644
--- a/stdlib/source/program/aedifex/metadata/snapshot.lux
+++ b/stdlib/source/program/aedifex/metadata/snapshot.lux
@@ -46,8 +46,9 @@
["#/." stamp]]]]])
(type: .public Metadata
- {#artifact Artifact
- #versioning Versioning})
+ (Record
+ {#artifact Artifact
+ #versioning Versioning}))
(template [<definition> <tag>]
[(def: <definition> xml.Tag ["" <tag>])]
diff --git a/stdlib/source/program/aedifex/package.lux b/stdlib/source/program/aedifex/package.lux
index 6a3a71f6d..49aa2867e 100644
--- a/stdlib/source/program/aedifex/package.lux
+++ b/stdlib/source/program/aedifex/package.lux
@@ -29,9 +29,10 @@
["#." origin (#+ Origin)]]])
(type: .public Package
- {#origin Origin
- #library [Binary Status]
- #pom [XML Binary Status]})
+ (Record
+ {#origin Origin
+ #library [Binary Status]
+ #pom [XML Binary Status]}))
(template [<name> <tag>]
[(def: .public (<name> package)
diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux
index 264bc9015..b861e1601 100644
--- a/stdlib/source/program/aedifex/profile.lux
+++ b/stdlib/source/program/aedifex/profile.lux
@@ -38,8 +38,9 @@
#dependency.type type.jvm_library})
(type: .public Distribution
- #Repo
- #Manual)
+ (Variant
+ #Repo
+ #Manual))
(implementation: distribution_equivalence
(Equivalence Distribution)
@@ -99,13 +100,14 @@
Developer)
(type: .public Info
- {#url (Maybe URL)
- #scm (Maybe SCM)
- #description (Maybe Text)
- #licenses (List License)
- #organization (Maybe Organization)
- #developers (List Developer)
- #contributors (List Contributor)})
+ (Record
+ {#url (Maybe URL)
+ #scm (Maybe SCM)
+ #description (Maybe Text)
+ #licenses (List License)
+ #organization (Maybe Organization)
+ #developers (List Developer)
+ #contributors (List Contributor)}))
(def: info_equivalence
(Equivalence Info)
@@ -154,22 +156,23 @@
"")
(type: .public Profile
- {#parents (List Name)
- #identity (Maybe Artifact)
- #info (Maybe Info)
- #repositories (Set Address)
- #dependencies (Set Dependency)
- #compiler Dependency
- #sources (Set Source)
- #target Target
- #program (Maybe Module)
- #test (Maybe Module)
- #deploy_repositories (Dictionary Text Address)
- #java Runtime
- #js Runtime
- #python Runtime
- #lua Runtime
- #ruby Runtime})
+ (Record
+ {#parents (List Name)
+ #identity (Maybe Artifact)
+ #info (Maybe Info)
+ #repositories (Set Address)
+ #dependencies (Set Dependency)
+ #compiler Dependency
+ #sources (Set Source)
+ #target Target
+ #program (Maybe Module)
+ #test (Maybe Module)
+ #deploy_repositories (Dictionary Text Address)
+ #java Runtime
+ #js Runtime
+ #python Runtime
+ #lua Runtime
+ #ruby Runtime}))
(def: .public equivalence
(Equivalence Profile)
diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux
index 4f6da6d62..581c899a7 100644
--- a/stdlib/source/program/aedifex/project.lux
+++ b/stdlib/source/program/aedifex/project.lux
@@ -71,6 +71,6 @@
#.None
(exception.except ..unknown_profile [name])))
-(def: .public (profile name project)
- (-> Name Project (Try Profile))
- (..profile' (set.empty text.hash) project name))
+(def: .public profile
+ (-> Project Name (Try Profile))
+ (..profile' (set.empty text.hash)))
diff --git a/stdlib/source/program/aedifex/repository/identity.lux b/stdlib/source/program/aedifex/repository/identity.lux
index 4201123c0..533b4fb4e 100644
--- a/stdlib/source/program/aedifex/repository/identity.lux
+++ b/stdlib/source/program/aedifex/repository/identity.lux
@@ -18,8 +18,9 @@
Text)
(type: .public Identity
- {#user User
- #password Password})
+ (Record
+ {#user User
+ #password Password}))
(def: .public equivalence
(Equivalence Identity)
diff --git a/stdlib/source/program/aedifex/repository/origin.lux b/stdlib/source/program/aedifex/repository/origin.lux
index b850bf21f..845592762 100644
--- a/stdlib/source/program/aedifex/repository/origin.lux
+++ b/stdlib/source/program/aedifex/repository/origin.lux
@@ -11,8 +11,9 @@
[net (#+ URL)]]]])
(type: .public Origin
- (#Local Path)
- (#Remote URL))
+ (Variant
+ (#Local Path)
+ (#Remote URL)))
(def: .public equivalence
(Equivalence Origin)
diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux
index addfd4a52..bdf81da78 100644
--- a/stdlib/source/program/aedifex/runtime.lux
+++ b/stdlib/source/program/aedifex/runtime.lux
@@ -15,8 +15,9 @@
["." file]]]])
(type: .public Runtime
- {#program Text
- #parameters (List Text)})
+ (Record
+ {#program Text
+ #parameters (List Text)}))
(def: .public equivalence
(Equivalence Runtime)
diff --git a/stdlib/source/program/compositor/cli.lux b/stdlib/source/program/compositor/cli.lux
index 394869517..a7a02ed0f 100644
--- a/stdlib/source/program/compositor/cli.lux
+++ b/stdlib/source/program/compositor/cli.lux
@@ -32,9 +32,10 @@
[(List Source) Target])
(type: .public Service
- (#Compilation Compilation)
- (#Interpretation Compilation)
- (#Export Export))
+ (Variant
+ (#Compilation Compilation)
+ (#Interpretation Compilation)
+ (#Export Export)))
(template [<name> <long> <type>]
[(def: <name>
diff --git a/stdlib/source/program/compositor/static.lux b/stdlib/source/program/compositor/static.lux
index 1208687b3..498842248 100644
--- a/stdlib/source/program/compositor/static.lux
+++ b/stdlib/source/program/compositor/static.lux
@@ -6,7 +6,8 @@
[file (#+ Path)]]]])
(type: .public Static
- {#host Target
- #host_module_extension Text
- #target Path
- #artifact_extension Text})
+ (Record
+ {#host Target
+ #host_module_extension Text
+ #target Path
+ #artifact_extension Text}))
diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux
index 45ec92f4e..9712d8a93 100644
--- a/stdlib/source/test/aedifex/cli.lux
+++ b/stdlib/source/test/aedifex/cli.lux
@@ -12,7 +12,9 @@
[parser
["." cli]]]
[data
- ["." text ("#\." equivalence)]]
+ ["." text]
+ [collection
+ ["." list]]]
[math
["." random (#+ Random) ("#\." monad)]]]]
[\\program
@@ -74,8 +76,8 @@
(|> expected
..format
(cli.result /.command)
- (case> (#try.Success [name actual])
- (and (text\= //.default name)
+ (case> (#try.Success [names actual])
+ (and (\ (list.equivalence text.equivalence) = (list //.default) names)
(\ /.equivalence = expected actual))
(#try.Failure error)
@@ -92,7 +94,7 @@
(list& "with" expected_profile)
(cli.result /.command)
(case> (#try.Success [actual_profile actual_command])
- (and (text\= expected_profile actual_profile)
+ (and (\ (list.equivalence text.equivalence) = (list expected_profile //.default) actual_profile)
(\ /.equivalence = expected_command actual_command))
(#try.Failure error)
diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux
index 993e67088..905075adc 100644
--- a/stdlib/source/test/aedifex/input.lux
+++ b/stdlib/source/test/aedifex/input.lux
@@ -56,7 +56,7 @@
(\ utf8.codec encoded))]
_ (\ fs write profile //project.file)
actual (: (Async (Try Profile))
- (/.read async.monad fs //.default))]
+ (/.read async.monad fs (list //.default)))]
(in (\ //.equivalence =
(|> expected
(revised@ #//.sources ..with_default_source)
diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux
index ebf37db81..c11444355 100644
--- a/stdlib/source/test/aedifex/project.lux
+++ b/stdlib/source/test/aedifex/project.lux
@@ -73,24 +73,24 @@
(/.project sub_name (with@ #//.parents (list super_name) sub_profile)))]]
($_ _.and
(_.cover [/.profile]
- (and (|> (/.profile super_name project)
+ (and (|> (/.profile project super_name)
(try\each (\ //.equivalence = super_profile))
(try.else false))
- (|> (/.profile dummy_name project)
+ (|> (/.profile project dummy_name)
(try\each (\ //.equivalence = dummy_profile))
(try.else false))
- (|> (/.profile sub_name project)
+ (|> (/.profile project sub_name)
(try\each (\ //.equivalence = (\ //.monoid composite sub_profile super_profile)))
(try.else false))))
(_.cover [/.unknown_profile]
- (case (/.profile fake_name project)
+ (case (/.profile project fake_name)
(#try.Success _)
false
(#try.Failure error)
(exception.match? /.unknown_profile error)))
(_.cover [/.circular_dependency]
- (case (/.profile sub_name circular)
+ (case (/.profile circular sub_name)
(#try.Success _)
false
diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux
index ca4d06e2d..266952896 100644
--- a/stdlib/source/test/lux/control/function/memo.lux
+++ b/stdlib/source/test/lux/control/function/memo.lux
@@ -101,8 +101,8 @@
memo_is_faster!
incrementalism_is_faster!)))))
(_.cover [/.memoization]
- (let [memo (<| //.mixin
- (//.with /.memoization)
+ (let [memo (<| //.fixed
+ (//.mixed /.memoization)
(: (//.Mixin Nat (State (Dictionary Nat Nat) Nat))
(function (factorial delegate recur input)
(case input
diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux
index 533f88072..51c1157bc 100644
--- a/stdlib/source/test/lux/control/function/mixin.lux
+++ b/stdlib/source/test/lux/control/function/mixin.lux
@@ -31,8 +31,8 @@
.let [equivalence (: (Equivalence (/.Mixin Nat Nat))
(implementation
(def: (= left right)
- (n.= ((/.mixin left) input)
- ((/.mixin right) input)))))
+ (n.= ((/.fixed left) input)
+ ((/.fixed right) input)))))
generator (: (Random (/.Mixin Nat Nat))
(do !
[output random.nat]
@@ -47,15 +47,15 @@
(_.for [/.monoid]
($monoid.spec equivalence /.monoid generator))
- (_.cover [/.mixin]
- (let [factorial (/.mixin
+ (_.cover [/.fixed]
+ (let [factorial (/.fixed
(function (_ delegate recur input)
(case input
(^or 0 1) 1
_ (n.* input (recur (-- input))))))]
(n.= expected
(factorial input))))
- (_.cover [/.with]
+ (_.cover [/.mixed]
(let [bottom (: (/.Mixin Nat Nat)
(function (_ delegate recur input)
(case input
@@ -64,7 +64,7 @@
multiplication (: (/.Mixin Nat Nat)
(function (_ delegate recur input)
(n.* input (recur (-- input)))))
- factorial (/.mixin (/.with bottom multiplication))]
+ factorial (/.fixed (/.mixed bottom multiplication))]
(n.= expected
(factorial input))))
(_.cover [/.nothing]
@@ -73,8 +73,8 @@
(case input
(^or 0 1) 1
_ (n.* input (delegate (-- input))))))
- left (/.mixin (/.with /.nothing loop))
- right (/.mixin (/.with loop /.nothing))]
+ left (/.fixed (/.mixed /.nothing loop))
+ right (/.fixed (/.mixed loop /.nothing))]
(and (n.= expected
(left input))
(n.= expected
@@ -91,8 +91,8 @@
multiplication (: (/.Mixin Nat Nat)
(function (_ delegate recur input)
(n.* input (recur (-- input)))))
- factorial (/.mixin (/.with (/.advice bottom? bottom)
- multiplication))]
+ factorial (/.fixed (/.mixed (/.advice bottom? bottom)
+ multiplication))]
(n.= expected
(factorial input))))
(_.cover [/.before]
@@ -104,8 +104,8 @@
(function (_ delegate recur input)
(function (_ state)
[state (n.+ state input)])))
- function (/.mixin (/.with (/.before state.monad implant)
- meld))]
+ function (/.fixed (/.mixed (/.before state.monad implant)
+ meld))]
(n.= (n.+ shift input)
(|> input function (state.result dummy) product.right))))
(_.cover [/.after]
@@ -117,14 +117,14 @@
(function (_ delegate recur input)
(function (_ state)
[state (n.+ state input)])))
- function (/.mixin (/.with (/.after state.monad implant)
- meld))]
+ function (/.fixed (/.mixed (/.after state.monad implant)
+ meld))]
(n.= (n.+ dummy input)
(|> input function (state.result dummy) product.right))))
))
(_.for [/.Recursive]
(_.cover [/.of_recursive]
- (let [factorial (/.mixin
+ (let [factorial (/.fixed
(/.of_recursive
(function (_ recur input)
(case input
diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux
index 03ff479ff..08064ff74 100644
--- a/stdlib/source/test/lux/data/collection/array.lux
+++ b/stdlib/source/test/lux/data/collection/array.lux
@@ -59,7 +59,7 @@
(_.cover [/.example]
(\ (maybe.equivalence n.equivalence) =
(/.example n.even? the_array)
- (list.example n.even? (/.list the_array))))
+ (list.example n.even? (/.list #.None the_array))))
(_.cover [/.example+]
(case [(/.example n.even? the_array)
(/.example+ (function (_ idx member)
@@ -81,11 +81,11 @@
false))
(_.cover [/.every?]
(\ bit.equivalence =
- (list.every? n.even? (/.list the_array))
+ (list.every? n.even? (/.list #.None the_array))
(/.every? n.even? the_array)))
(_.cover [/.any?]
(\ bit.equivalence =
- (list.any? n.even? (/.list the_array))
+ (list.any? n.even? (/.list #.None the_array))
(/.any? n.even? the_array)))
)))
@@ -182,12 +182,24 @@
(n.= size (n.+ (/.occupancy the_array)
(/.vacancy the_array)))))))
(do !
- [the_list (random.list size random.nat)]
+ [the_list (random.list size random.nat)
+ .let [the_array (/.clone the_array)
+ members (|> the_array (/.list #.None) (set.of_list n.hash))]
+ default (random.only (function (_ value)
+ (not (or (n.even? value)
+ (set.member? members value))))
+ random.nat)]
(_.cover [/.of_list /.list]
- (and (|> the_list /.of_list /.list
+ (and (|> the_list /.of_list (/.list #.None)
(\ (list.equivalence n.equivalence) = the_list))
- (|> the_array /.list /.of_list
- (\ (/.equivalence n.equivalence) = the_array)))))
+ (|> the_array (/.list #.None) /.of_list
+ (\ (/.equivalence n.equivalence) = the_array))
+ (exec
+ (/.filter! n.even? the_array)
+ (list.every? (function (_ value)
+ (or (n.even? value)
+ (same? default value)))
+ (/.list (#.Some default) the_array))))))
(do !
[amount (\ ! each (n.% (++ size)) random.nat)]
(_.cover [/.copy!]
@@ -195,31 +207,18 @@
(/.empty size))]
(exec (/.copy! amount 0 the_array 0 copy)
(\ (list.equivalence n.equivalence) =
- (list.first amount (/.list the_array))
- (/.list copy))))))
+ (list.first amount (/.list #.None the_array))
+ (/.list #.None copy))))))
(_.cover [/.clone]
(let [clone (/.clone the_array)]
(and (not (same? the_array clone))
(\ (/.equivalence n.equivalence) = the_array clone))))
(let [the_array (/.clone the_array)
- evens (|> the_array /.list (list.only n.even?))
- odds (|> the_array /.list (list.only n.odd?))]
+ evens (|> the_array (/.list #.None) (list.only n.even?))
+ odds (|> the_array (/.list #.None) (list.only n.odd?))]
(_.cover [/.filter!]
(exec (/.filter! n.even? the_array)
(and (n.= (list.size evens) (/.occupancy the_array))
(n.= (list.size odds) (/.vacancy the_array))
- (|> the_array /.list (\ (list.equivalence n.equivalence) = evens))))))
- (do !
- [.let [the_array (/.clone the_array)
- members (|> the_array /.list (set.of_list n.hash))]
- default (random.only (function (_ value)
- (not (or (n.even? value)
- (set.member? members value))))
- random.nat)]
- (_.cover [/.list']
- (exec (/.filter! n.even? the_array)
- (list.every? (function (_ value)
- (or (n.even? value)
- (same? default value)))
- (/.list' default the_array)))))
+ (|> the_array (/.list #.None) (\ (list.equivalence n.equivalence) = evens))))))
))))
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index df0c6000c..aa30ee356 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -96,22 +96,22 @@
(|> (/.index outer (\ /.monoid composite inner outer))
(maybe.else fake_index)
(n.= 1))))
- (_.cover [/.index']
+ (_.cover [/.index_since]
(let [full (\ /.monoid composite inner outer)]
- (and (|> (/.index' 0 inner full)
+ (and (|> (/.index_since 0 inner full)
(maybe.else fake_index)
(n.= 0))
- (|> (/.index' 1 inner full)
+ (|> (/.index_since 1 inner full)
(maybe.else fake_index)
(n.= fake_index))
- (|> (/.index' 0 outer full)
+ (|> (/.index_since 0 outer full)
(maybe.else fake_index)
(n.= 1))
- (|> (/.index' 1 outer full)
+ (|> (/.index_since 1 outer full)
(maybe.else fake_index)
(n.= 1))
- (|> (/.index' 2 outer full)
+ (|> (/.index_since 2 outer full)
(maybe.else fake_index)
(n.= fake_index)))))
(_.cover [/.last_index]
@@ -297,11 +297,11 @@
_
#0)))
- (_.cover [/.clip /.clip']
+ (_.cover [/.clip /.clip_since]
(|> [(/.clip 0 sizeL sample)
(/.clip sizeL (n.- sizeL (/.size sample)) sample)
- (/.clip' sizeL sample)
- (/.clip' 0 sample)]
+ (/.clip_since sizeL sample)
+ (/.clip_since 0 sample)]
(case> [(#.Right _l) (#.Right _r) (#.Right _r') (#.Right _f)]
(and (/\= sampleL _l)
(/\= sampleR _r)
diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux
index da5cfd057..ca72f6882 100644
--- a/stdlib/source/test/lux/math.lux
+++ b/stdlib/source/test/lux/math.lux
@@ -98,11 +98,11 @@
(|> sample /.exp /.log (f.approximately? +0.000000000000001 sample)))
(_.cover [/.e]
(~= +1.0 (/.log /.e)))
- (_.cover [/.pow /.log']
+ (_.cover [/.pow /.log_by]
(let [sample (f.abs sample)]
(|> sample
(/.pow power)
- (/.log' sample)
+ (/.log_by sample)
(~= power))))
))
(do {! random.monad}
diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux
index f4ee4b802..4674890ca 100644
--- a/stdlib/source/test/lux/type/check.lux
+++ b/stdlib/source/test/lux/type/check.lux
@@ -220,10 +220,10 @@
(do random.monad
[nominal (random.ascii/upper 10)
.let [expected (#.Primitive nominal (list))]]
- (_.cover [/.read']
+ (_.cover [/.peek]
(and (|> (do /.monad
[[var_id var_type] /.var]
- (/.read' var_id))
+ (/.peek var_id))
(/.result /.fresh_context)
(case> (#try.Success #.None) true
_ false))
@@ -231,14 +231,14 @@
[[var_id var/0] /.var
[_ var/1] /.var
_ (/.check var/0 var/1)]
- (/.read' var_id))
+ (/.peek var_id))
(/.result /.fresh_context)
(case> (#try.Success #.None) true
_ false))
(|> (do /.monad
[[var_id var_type] /.var
_ (/.bind expected var_id)]
- (/.read' var_id))
+ (/.peek var_id))
(/.result /.fresh_context)
(case> (#try.Success (#.Some actual))
(same? expected actual)