aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2022-11-07 18:52:46 -0400
committerEduardo Julian2022-11-07 18:52:46 -0400
commitcb572295c9a73330531e07f3f6a92b3bb2434514 (patch)
treeae14be0a53235971d897c033879e3d4512ffde68 /stdlib
parent13c594758482bac0a7550bcb89cfeda8c5f0a1f3 (diff)
Can now mark definitions as deprecated in their documentation.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/documentation/lux.lux957
-rw-r--r--stdlib/source/documentation/lux/abstract/codec.lux10
-rw-r--r--stdlib/source/documentation/lux/abstract/comonad.lux8
-rw-r--r--stdlib/source/documentation/lux/abstract/enum.lux2
-rw-r--r--stdlib/source/documentation/lux/abstract/equivalence.lux2
-rw-r--r--stdlib/source/documentation/lux/abstract/interval.lux2
-rw-r--r--stdlib/source/documentation/lux/abstract/mix.lux2
-rw-r--r--stdlib/source/documentation/lux/abstract/monad.lux18
-rw-r--r--stdlib/source/documentation/lux/control.lux2
-rw-r--r--stdlib/source/documentation/lux/control/concatenative.lux84
-rw-r--r--stdlib/source/documentation/lux/control/concurrency/async.lux22
-rw-r--r--stdlib/source/documentation/lux/control/concurrency/frp.lux10
-rw-r--r--stdlib/source/documentation/lux/control/concurrency/semaphore.lux10
-rw-r--r--stdlib/source/documentation/lux/control/concurrency/stm.lux8
-rw-r--r--stdlib/source/documentation/lux/control/concurrency/thread.lux2
-rw-r--r--stdlib/source/documentation/lux/control/continuation.lux20
-rw-r--r--stdlib/source/documentation/lux/control/exception.lux37
-rw-r--r--stdlib/source/documentation/lux/control/function.lux18
-rw-r--r--stdlib/source/documentation/lux/control/function/contract.lux8
-rw-r--r--stdlib/source/documentation/lux/control/function/memo.lux6
-rw-r--r--stdlib/source/documentation/lux/control/function/mixin.lux12
-rw-r--r--stdlib/source/documentation/lux/control/function/mutual.lux46
-rw-r--r--stdlib/source/documentation/lux/control/io.lux6
-rw-r--r--stdlib/source/documentation/lux/control/lazy.lux2
-rw-r--r--stdlib/source/documentation/lux/control/maybe.lux25
-rw-r--r--stdlib/source/documentation/lux/control/parser.lux50
-rw-r--r--stdlib/source/documentation/lux/control/pipe.lux98
-rw-r--r--stdlib/source/documentation/lux/control/reader.lux6
-rw-r--r--stdlib/source/documentation/lux/control/region.lux10
-rw-r--r--stdlib/source/documentation/lux/control/security/capability.lux19
-rw-r--r--stdlib/source/documentation/lux/control/security/policy.lux42
-rw-r--r--stdlib/source/documentation/lux/control/state.lux20
-rw-r--r--stdlib/source/documentation/lux/control/thread.lux10
-rw-r--r--stdlib/source/documentation/lux/control/try.lux18
-rw-r--r--stdlib/source/documentation/lux/control/writer.lux6
-rw-r--r--stdlib/source/documentation/lux/data/binary.lux44
-rw-r--r--stdlib/source/documentation/lux/data/collection/array.lux36
-rw-r--r--stdlib/source/documentation/lux/data/collection/bits.lux10
-rw-r--r--stdlib/source/documentation/lux/data/collection/dictionary.lux26
-rw-r--r--stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux16
-rw-r--r--stdlib/source/documentation/lux/data/collection/list.lux74
-rw-r--r--stdlib/source/documentation/lux/data/collection/list/property.lux10
-rw-r--r--stdlib/source/documentation/lux/data/collection/queue.lux10
-rw-r--r--stdlib/source/documentation/lux/data/collection/queue/priority.lux4
-rw-r--r--stdlib/source/documentation/lux/data/collection/sequence.lux20
-rw-r--r--stdlib/source/documentation/lux/data/collection/set.lux10
-rw-r--r--stdlib/source/documentation/lux/data/collection/set/multi.lux12
-rw-r--r--stdlib/source/documentation/lux/data/collection/set/ordered.lux12
-rw-r--r--stdlib/source/documentation/lux/data/collection/stack.lux6
-rw-r--r--stdlib/source/documentation/lux/data/collection/stream.lux16
-rw-r--r--stdlib/source/documentation/lux/data/collection/tree.lux20
-rw-r--r--stdlib/source/documentation/lux/data/collection/tree/finger.lux12
-rw-r--r--stdlib/source/documentation/lux/data/collection/tree/zipper.lux8
-rw-r--r--stdlib/source/documentation/lux/data/color.lux8
-rw-r--r--stdlib/source/documentation/lux/data/format/json.lux45
-rw-r--r--stdlib/source/documentation/lux/data/format/xml.lux10
-rw-r--r--stdlib/source/documentation/lux/data/product.lux10
-rw-r--r--stdlib/source/documentation/lux/data/sum.lux4
-rw-r--r--stdlib/source/documentation/lux/data/text.lux78
-rw-r--r--stdlib/source/documentation/lux/data/text/escape.lux12
-rw-r--r--stdlib/source/documentation/lux/data/text/regex.lux114
-rw-r--r--stdlib/source/documentation/lux/data/text/unicode/block.lux4
-rw-r--r--stdlib/source/documentation/lux/data/text/unicode/set.lux4
-rw-r--r--stdlib/source/documentation/lux/debug.lux74
-rw-r--r--stdlib/source/documentation/lux/documentation.lux38
-rw-r--r--stdlib/source/documentation/lux/documentation/remember.lux (renamed from stdlib/source/documentation/lux/control/remember.lux)30
-rw-r--r--stdlib/source/documentation/lux/ffi.js.lux46
-rw-r--r--stdlib/source/documentation/lux/ffi.jvm.lux242
-rw-r--r--stdlib/source/documentation/lux/ffi.lua.lux8
-rw-r--r--stdlib/source/documentation/lux/ffi.old.lux221
-rw-r--r--stdlib/source/documentation/lux/ffi.py.lux47
-rw-r--r--stdlib/source/documentation/lux/ffi.rb.lux33
-rw-r--r--stdlib/source/documentation/lux/math/infix.lux47
-rw-r--r--stdlib/source/documentation/lux/math/logic/continuous.lux2
-rw-r--r--stdlib/source/documentation/lux/math/logic/fuzzy.lux16
-rw-r--r--stdlib/source/documentation/lux/math/modular.lux4
-rw-r--r--stdlib/source/documentation/lux/math/modulus.lux11
-rw-r--r--stdlib/source/documentation/lux/math/number.lux7
-rw-r--r--stdlib/source/documentation/lux/math/number/complex.lux7
-rw-r--r--stdlib/source/documentation/lux/math/number/frac.lux24
-rw-r--r--stdlib/source/documentation/lux/math/number/i64.lux14
-rw-r--r--stdlib/source/documentation/lux/math/number/int.lux14
-rw-r--r--stdlib/source/documentation/lux/math/number/ratio.lux7
-rw-r--r--stdlib/source/documentation/lux/math/number/rev.lux16
-rw-r--r--stdlib/source/documentation/lux/math/random.lux28
-rw-r--r--stdlib/source/documentation/lux/meta.lux54
-rw-r--r--stdlib/source/documentation/lux/meta/code.lux10
-rw-r--r--stdlib/source/documentation/lux/meta/compiler/language/lux/analysis.lux4
-rw-r--r--stdlib/source/documentation/lux/meta/compiler/language/lux/synthesis.lux8
-rw-r--r--stdlib/source/documentation/lux/meta/extension.lux20
-rw-r--r--stdlib/source/documentation/lux/meta/location.lux4
-rw-r--r--stdlib/source/documentation/lux/meta/macro.lux78
-rw-r--r--stdlib/source/documentation/lux/meta/macro/local.lux2
-rw-r--r--stdlib/source/documentation/lux/meta/macro/syntax.lux26
-rw-r--r--stdlib/source/documentation/lux/meta/macro/syntax/declaration.lux7
-rw-r--r--stdlib/source/documentation/lux/meta/macro/syntax/definition.lux4
-rw-r--r--stdlib/source/documentation/lux/meta/macro/syntax/export.lux4
-rw-r--r--stdlib/source/documentation/lux/meta/macro/template.lux57
-rw-r--r--stdlib/source/documentation/lux/meta/static.lux20
-rw-r--r--stdlib/source/documentation/lux/meta/type.lux100
-rw-r--r--stdlib/source/documentation/lux/meta/type/check.lux16
-rw-r--r--stdlib/source/documentation/lux/meta/type/dynamic.lux8
-rw-r--r--stdlib/source/documentation/lux/meta/type/implicit.lux38
-rw-r--r--stdlib/source/documentation/lux/meta/type/poly.lux2
-rw-r--r--stdlib/source/documentation/lux/meta/type/primitive.lux157
-rw-r--r--stdlib/source/documentation/lux/meta/type/quotient.lux17
-rw-r--r--stdlib/source/documentation/lux/meta/type/refinement.lux25
-rw-r--r--stdlib/source/documentation/lux/meta/type/resource.lux36
-rw-r--r--stdlib/source/documentation/lux/meta/type/unit.lux6
-rw-r--r--stdlib/source/documentation/lux/program.lux38
-rw-r--r--stdlib/source/documentation/lux/test/property.lux34
-rw-r--r--stdlib/source/documentation/lux/test/tally.lux2
-rw-r--r--stdlib/source/documentation/lux/test/unit.lux22
-rw-r--r--stdlib/source/documentation/lux/world/console.lux4
-rw-r--r--stdlib/source/documentation/lux/world/environment.lux8
-rw-r--r--stdlib/source/documentation/lux/world/file.lux14
-rw-r--r--stdlib/source/documentation/lux/world/file/watch.lux6
-rw-r--r--stdlib/source/documentation/lux/world/locale.lux2
-rw-r--r--stdlib/source/documentation/lux/world/net.lux6
-rw-r--r--stdlib/source/documentation/lux/world/net/uri.lux4
-rw-r--r--stdlib/source/documentation/lux/world/shell.lux2
-rw-r--r--stdlib/source/documentation/lux/world/time.lux6
-rw-r--r--stdlib/source/documentation/lux/world/time/date.lux2
-rw-r--r--stdlib/source/documentation/lux/world/time/duration.lux2
-rw-r--r--stdlib/source/documentation/lux/world/time/instant.lux10
-rw-r--r--stdlib/source/documentation/lux/world/time/month.lux4
-rw-r--r--stdlib/source/documentation/lux/world/time/year.lux4
-rw-r--r--stdlib/source/library/lux/control/aspect.lux8
-rw-r--r--stdlib/source/library/lux/documentation.lux81
-rw-r--r--stdlib/source/library/lux/meta.lux14
-rw-r--r--stdlib/source/library/lux/test/unit.lux2
-rw-r--r--stdlib/source/library/lux/world/net/http/route.lux77
-rw-r--r--stdlib/source/library/lux/world/net/http/server.lux193
-rw-r--r--stdlib/source/specification/lux/abstract/hash.lux18
-rw-r--r--stdlib/source/test/lux/control/aspect.lux8
-rw-r--r--stdlib/source/test/lux/world/net.lux4
-rw-r--r--stdlib/source/test/lux/world/net/http/server.lux393
137 files changed, 2596 insertions, 2244 deletions
diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux
index c9225a539..84fb5c9d7 100644
--- a/stdlib/source/documentation/lux.lux
+++ b/stdlib/source/documentation/lux.lux
@@ -131,370 +131,383 @@
($.definition /.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))))])
+ ($.example (comment
+ (def (this will not)
+ (Be Defined)
+ (because it will be (commented out))))))
($.definition /.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)]))])
+
+ ($.example (All (_ a)
+ (-> a a)))
+
+ ($.comment "A name can be provided, to specify a recursive type.")
+ ($.example (All (List a)
+ (Or Any
+ [a (List a)]))))
($.definition /.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))])])
+
+ ($.example (Ex (_ a)
+ [(Codec Text a) a]))
+
+ ($.comment "A name can be provided, to specify a recursive type.")
+ ($.example (Ex (Self a)
+ [(Codec Text a)
+ a
+ (List (Self a))])))
))
(def all_2/4
(List $.Documentation)
(list ($.definition /.->
"Function types."
- ["This is the type of a function that takes 2 Ints and returns an Int."
- (-> Int Int Int)])
+ ($.comment "This is the type of a function that takes 2 Ints and returns an Int.")
+ ($.example (-> Int Int Int)))
($.definition /.list
"List literals."
- [(is (List Nat)
- (list 0 1 2 3))])
+ ($.example (is (List Nat)
+ (list 0 1 2 3))))
($.definition /.Union
"Union types."
- [(Union Bit Nat Text)]
- [(= Nothing
- (Union))])
+ ($.example (Union Bit Nat Text))
+ ($.example (= Nothing
+ (Union))))
($.definition /.Tuple
"Tuple types."
- [(Tuple Bit Nat Text)]
- [(= Any
- (Tuple))])
+ ($.example (Tuple Bit Nat Text))
+ ($.example (= Any
+ (Tuple))))
($.definition /.Or
"An alias for the Union type constructor."
- [(= (Union Bit Nat Text)
- (Or Bit Nat Text))]
- [(= (Union)
- (Or))])
+ ($.example (= (Union Bit Nat Text)
+ (Or Bit Nat Text)))
+ ($.example (= (Union)
+ (Or))))
($.definition /.And
"An alias for the Tuple type constructor."
- [(= (Tuple Bit Nat Text)
- (And Bit Nat Text))]
- [(= (Tuple)
- (And))])
+ ($.example (= (Tuple Bit Nat Text)
+ (And Bit Nat Text)))
+ ($.example (= (Tuple)
+ (And))))
($.definition /.left
"Left-association for the application of binary functions over variadic arguments."
- [(left text#composite "Hello, " name ". How are you?")
- "=>"
- (text#composite (text#composite "Hello, " name) ". How are you?")])
+
+ ($.example (left text#composite "Hello, " name ". How are you?"))
+ ($.comment "=>")
+ ($.example (text#composite (text#composite "Hello, " name) ". How are you?")))
($.definition /.all
"Right-association for the application of binary functions over variadic arguments."
- [(all text#composite "Hello, " name ". How are you?")
- "=>"
- (text#composite "Hello, " (text#composite name ". How are you?"))])
+ ($.example (all text#composite "Hello, " name ". How are you?"))
+ ($.comment "=>")
+ ($.example (text#composite "Hello, " (text#composite name ". How are you?"))))
($.definition /.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!"])
+ ($.example (if #1
+ "Oh, yeah!"
+ "Aw hell naw!"))
+ ($.comment "=>")
+ ($.example "Oh, yeah!")
+
+ ($.example (if #0
+ "Oh, yeah!"
+ "Aw hell naw!"))
+ ($.comment "=>")
+ ($.example "Aw hell naw!"))
($.definition /.Primitive
"Macro to treat define new primitive types."
- [(Primitive "java.lang.Object")]
- [(Primitive "java.util.List" [(Primitive "java.lang.Long")])])
+ ($.example (Primitive "java.lang.Object"))
+ ($.example (Primitive "java.util.List" [(Primitive "java.lang.Long")])))
($.definition /.`
(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))))])
+ ($.example (` (def (, name)
+ (function ((,' _) (,* args))
+ (, body))))))
($.definition /.`'
(format "Unhygienic quasi-quotation as a macro."
\n "Unquote (,) and unquote-splice (,*) must also be used as forms.")
- [(`' (def (, name)
- (function (_ (,* args))
- (, body))))])
+ ($.example (`' (def (, name)
+ (function (_ (,* args))
+ (, body))))))
($.definition /.'
"Quotation as a macro."
- [(' YOLO)])
+ ($.example (' YOLO)))
($.definition /.|>
"Piping macro."
- [(|> elems
- (list#each int#encoded)
- (interposed " ")
- (mix text#composite ""))
- "=>"
- (mix text#composite ""
- (interposed " "
- (list#each int#encoded
- elems)))])
+ ($.example (|> elems
+ (list#each int#encoded)
+ (interposed " ")
+ (mix text#composite "")))
+ ($.comment "=>")
+ ($.example (mix text#composite ""
+ (interposed " "
+ (list#each int#encoded
+ elems)))))
($.definition /.<|
"Reverse piping macro."
- [(<| (mix text#composite "")
- (interposed " ")
- (list#each int#encoded)
- elems)
- "=>"
- (mix text#composite ""
- (interposed " "
- (list#each int#encoded
- elems)))])
+ ($.example (<| (mix text#composite "")
+ (interposed " ")
+ (list#each int#encoded)
+ elems))
+ ($.comment "=>")
+ ($.example (mix text#composite ""
+ (interposed " "
+ (list#each int#encoded
+ elems)))))
($.definition /.template
""
- ["By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary."
- (with_template [<name> <diff>]
- [(def .public <name>
- (-> Int Int)
- (+ <diff>))]
-
- [++ +1]
- [-- -1]
- )])
+ ($.comment "By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary.")
+ ($.example (with_template [<name> <diff>]
+ [(def .public <name>
+ (-> Int Int)
+ (+ <diff>))]
+
+ [++ +1]
+ [-- -1]
+ )))
))
(`` (def all_3/4
(List $.Documentation)
(list ($.definition /.not
"Bit negation."
- [(not #1)
- "=>"
- #0]
- [(not #0)
- "=>"
- #1])
+ ($.example (not #1))
+ ($.comment "=>")
+ ($.example #0)
+
+ ($.example (not #0))
+ ($.comment "=>")
+ ($.example #1))
($.definition /.type
"Takes a type expression and returns its representation as data-structure."
- [(type_literal (All (_ a)
- (Maybe (List a))))])
+ ($.example (type_literal (All (_ a)
+ (Maybe (List a))))))
($.definition /.is
"The type-annotation macro."
- [(is (List Int)
- (list +1 +2 +3))])
+ ($.example (is (List Int)
+ (list +1 +2 +3))))
($.definition /.as
"The type-coercion macro."
- [(as Dinosaur
- (list +1 +2 +3))])
+ ($.example (as Dinosaur
+ (list +1 +2 +3))))
($.definition /.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]))]
- ["Can also be used with type and labelled-type definitions."
- (type Type
- (Rec @
- (Variant
- {#Primitive Text (List @)}
- {#Sum @ @}
- {#Product @ @}
- {#Function @ @}
- {#Parameter Nat}
- {#Var Nat}
- {#Ex Nat}
- {#UnivQ (List @) @}
- {#ExQ (List @) @}
- {#Apply @ @}
- {#Named Symbol @})))])
+ ($.comment "A name has to be given to the whole type, to use it within its body.")
+ ($.example (Rec Int_List
+ (Or Any
+ [Int Int_List])))
+
+ ($.comment "Can also be used with type and labelled-type definitions.")
+ ($.example (type Type
+ (Rec @
+ (Variant
+ {#Primitive Text (List @)}
+ {#Sum @ @}
+ {#Product @ @}
+ {#Function @ @}
+ {#Parameter Nat}
+ {#Var Nat}
+ {#Ex Nat}
+ {#UnivQ (List @) @}
+ {#ExQ (List @) @}
+ {#Apply @ @}
+ {#Named Symbol @})))))
($.definition /.exec
"Sequential execution of expressions (great for side-effects)."
- [(exec
- (log! "#1")
- (log! "#2")
- (log! "#3")
- "YOLO")])
+ ($.example (exec
+ (log! "#1")
+ (log! "#2")
+ (log! "#3")
+ "YOLO")))
($.definition /.when
(format "The pattern-matching macro."
\n "Allows the usage of macros within the patterns to provide custom syntax.")
- [(when (is (List Int)
- (list +1 +2 +3))
- {#Item x {#Item y {#Item z {#End}}}}
- {#Some (all * x y z)}
+ ($.example (when (is (List Int)
+ (list +1 +2 +3))
+ {#Item x {#Item y {#Item z {#End}}}}
+ {#Some (all * x y z)}
- _
- {#None})])
+ _
+ {#None})))
($.definition /.pattern
(format "Macro-expanding patterns."
\n "It's a special macro meant to be used with 'when'.")
- [(when (is (List Int)
- (list +1 +2 +3))
- (list x y z)
- {#Some (all * x y z)}
+ ($.example (when (is (List Int)
+ (list +1 +2 +3))
+ (list x y z)
+ {#Some (all * x y z)}
- _
- {#None})])
+ _
+ {#None})))
... ($.definition /.^or
... (format "Or-patterns."
... \n "It's a special macro meant to be used with 'when'.")
- ... [(type Weekday
- ... (Variant
- ... {#Monday}
- ... {#Tuesday}
- ... {#Wednesday}
- ... {#Thursday}
- ... {#Friday}
- ... {#Saturday}
- ... {#Sunday}))
-
- ... (def (weekend? day)
- ... (-> Weekday Bit)
- ... (when day
- ... (^or {#Saturday} {#Sunday})
- ... true
-
- ... _
- ... false))])
+ ... ($.example (type Weekday
+ ... (Variant
+ ... {#Monday}
+ ... {#Tuesday}
+ ... {#Wednesday}
+ ... {#Thursday}
+ ... {#Friday}
+ ... {#Saturday}
+ ... {#Sunday})))
+ ... ($.example (def (weekend? day)
+ ... (-> Weekday Bit)
+ ... (when day
+ ... (^or {#Saturday} {#Sunday})
+ ... true
+
+ ... _
+ ... false))))
($.definition /.let
(format "Creates local bindings."
\n "Can (optionally) use pattern-matching macros when binding.")
- [(let [x (foo bar)
- y (baz quux)]
- (op x y))])
+ ($.example (let [x (foo bar)
+ y (baz quux)]
+ (op x y))))
($.definition /.function
"Syntax for creating functions."
- [(is (All (_ a b)
- (-> a b a))
- (function (_ x y)
- x))]
- ["Allows for giving the function itself a name, for the sake of recursion."
- (is (-> Nat Nat)
- (function (factorial n)
- (when n
- 0 1
- _ (* n (factorial (-- n))))))])
+ ($.example (is (All (_ a b)
+ (-> a b a))
+ (function (_ x y)
+ x)))
+
+ ($.comment "Allows for giving the function itself a name, for the sake of recursion.")
+ ($.example (is (-> Nat Nat)
+ (function (factorial n)
+ (when n
+ 0 1
+ _ (* n (factorial (-- n))))))))
($.definition /.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))])
+ ($.example (def branching_exponent
+ Int
+ +5))
+
+ ($.comment "The type is optional.")
+ ($.example (def branching_exponent
+ +5))
+
+ ($.example (def (pair_list pair)
+ (-> [Code Code] (List Code))
+ (let [[left right] pair]
+ (list left right))))
+
+ ($.comment "Can pattern-match on the inputs to functions.")
+ ($.example (def (pair_list [left right])
+ (-> [Code Code] (List Code))
+ (list left right))))
($.definition /.macro
"Macro-definition macro."
- [(def .public symbol
- (macro (_ tokens)
- (when tokens
- (^with_template [<tag>]
- [(list [_ {<tag> [module name]}])
- (in (list (` [(, (text$ module)) (, (text$ name))])))])
- ([#Symbol])
-
- _
- (failure "Wrong syntax for symbol"))))])
+ ($.example (def .public symbol
+ (macro (_ tokens)
+ (when tokens
+ (^with_template [<tag>]
+ [(list [_ {<tag> [module name]}])
+ (in (list (` [(, (text$ module)) (, (text$ name))])))])
+ ([#Symbol])
+
+ _
+ (failure "Wrong syntax for symbol"))))))
($.definition /.and
"Short-circuiting 'and'."
- [(and #1 #0)
- "=>"
- #0]
- [(and #1 #1)
- "=>"
- #1])
+ ($.example (and #1 #0))
+ ($.comment "=>")
+ ($.example #0)
+
+ ($.example (and #1 #1))
+ ($.comment "=>")
+ ($.example #1))
($.definition /.or
"Short-circuiting 'or'."
- [(or #1 #0)
- "=>"
- #1]
- [(or #0 #0)
- "=>"
- #0])
+ ($.example (or #1 #0))
+ ($.comment "=>")
+ ($.example #1)
+
+ ($.example (or #0 #0))
+ ($.comment "=>")
+ ($.example #0))
($.definition /.panic!
"Causes an error, with the given error message."
- [(panic! "OH NO!")])
+ ($.example (panic! "OH NO!")))
($.definition /.implementation
"Express a value that implements an interface."
- [(is (Order Int)
- (implementation
- (def equivalence
- equivalence)
- (def (< reference subject)
- (< reference subject))
- ))])
+ ($.example (is (Order Int)
+ (implementation
+ (def equivalence
+ equivalence)
+ (def (< reference subject)
+ (< reference subject))
+ ))))
($.definition /.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}))])
+ ($.example (type Referrals
+ (Variant
+ {#All}
+ {#Only (List Text)}
+ {#Exclude (List Text)}
+ {#Ignore}
+ {#Nothing}))))
($.definition /.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)]))])
+ ($.example (type Refer
+ (Record
+ [#refer_defs Referrals
+ #refer_open (List Openings)]))))
($.definition /.type
"The type-definition macro."
- [(type (List a)
- {#End}
- {#Item a (List a)})])
+ ($.example (type (List a)
+ {#End}
+ {#Item a (List a)})))
($.definition /.Interface
"Interface definition."
- [(type .public (Order a)
- (Interface
- (is (Equivalence a)
- equivalence)
- (is (-> a a Bit)
- <)))])
+ ($.example (type .public (Order a)
+ (Interface
+ (is (Equivalence a)
+ equivalence)
+ (is (-> a a Bit)
+ <)))))
(,, (with_template [<name>]
[($.definition <name>
@@ -513,144 +526,151 @@
($.definition /.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 "[0]") enum]
- (loop (again [end to
- output {.#End}])
- (cond (< end from)
- (again (pred end) {.#Item end output})
+ ($.example (def .public (range enum from to)
+ (All (_ a) (-> (Enum a) a a (List a)))
+ (let [(open "[0]") enum]
+ (loop (again [end to
+ output {.#End}])
+ (cond (< end from)
+ (again (pred end) {.#Item end output})
- (< from end)
- (again (succ end) {.#Item end output})
+ (< from end)
+ (again (succ end) {.#Item end output})
- ... (= end from)
- {.#Item end output}))))])
+ ... (= end from)
+ {.#Item end output}))))))
($.definition /.cond
"Conditional branching with multiple test conditions."
- [(cond (even? num) "WHEN even"
- (odd? num) "WHEN odd"
- "ELSE")])
+ ($.example (cond (even? num) "WHEN even"
+ (odd? num) "WHEN odd"
+ "ELSE")))
($.definition /.the
"Accesses the value of a record at a given tag."
- [(the #field my_record)]
- ["Can also work with multiple levels of nesting."
- (the [#foo #bar #baz] my_record)]
- ["And, if only the slot/path is given, generates an accessor function."
- (let [getter (the [#foo #bar #baz])]
- (getter my_record))])
+ ($.example (the #field my_record))
+
+ ($.comment "Can also work with multiple levels of nesting.")
+ ($.example (the [#foo #bar #baz] my_record))
+
+ ($.comment "And, if only the slot/path is given, generates an accessor function.")
+ ($.example (let [getter (the [#foo #bar #baz])]
+ (getter my_record))))
($.definition /.use
"Opens a implementation and generates a definition for each of its members (including nested members)."
- [(use "i:[0]" order)
- "=>"
- (def i:= (at order =))
- (def i:< (at order <))])
+ ($.example (use "i:[0]" order))
+ ($.comment "=>")
+ ($.example (def i:= (at order =)))
+ ($.example (def i:< (at order <))))
($.definition /.|>>
"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>))))])
+ ($.example (|>> (list#each int#encoded)
+ (interposed " ")
+ (mix text#composite "")))
+ ($.comment "=>")
+ ($.example (function (_ <it>)
+ (mix text#composite ""
+ (interposed " "
+ (list#each int#encoded <it>))))))
($.definition /.<<|
"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>))))])
+ ($.example (<<| (mix text#composite "")
+ (interposed " ")
+ (list#each int#encoded)))
+ ($.comment "=>")
+ ($.example (function (_ <it>)
+ (mix text#composite ""
+ (interposed " "
+ (list#each int#encoded
+ <it>))))))
($.definition /.require
"Module-definition macro."
- [(.require
- [lux (.except)
- [control
- ["M" monad (.except)]]
- [data
- maybe
- ["[0]" name (.use "[1]#[0]" codec)]]
- [macro
- code]]
- [//
- [type (.use "[0]" equivalence)]])])
+ ($.example (.require
+ [lux (.except)
+ [control
+ ["M" monad (.except)]]
+ [data
+ maybe
+ ["[0]" name (.use "[1]#[0]" codec)]]
+ [macro
+ code]]
+ [//
+ [type (.use "[0]" equivalence)]])))
($.definition /.at
"Allows accessing the value of a implementation's member."
- [(at codec encoded)]
- ["Also allows using that value as a function."
- (at codec encoded +123)])
+ ($.example (at codec encoded))
+
+ ($.comment "Also allows using that value as a function.")
+ ($.example (at codec encoded +123)))
($.definition /.has
"Sets the value of a record at a given tag."
- [(has #name "Lux" lang)]
- ["Can also work with multiple levels of nesting."
- (has [#foo #bar #baz] value my_record)]
- ["And, if only the slot/path and (optionally) the value are given, generates a mutator function."
- (let [setter (has [#foo #bar #baz] value)]
- (setter my_record))
- (let [setter (has [#foo #bar #baz])]
- (setter value my_record))])
+ ($.example (has #name "Lux" lang))
+
+ ($.comment "Can also work with multiple levels of nesting.")
+ ($.example (has [#foo #bar #baz] value my_record))
+
+ ($.comment "And, if only the slot/path and (optionally) the value are given, generates a mutator function.")
+ ($.example (let [setter (has [#foo #bar #baz] value)]
+ (setter my_record)))
+ ($.example (let [setter (has [#foo #bar #baz])]
+ (setter value my_record))))
)))
(`` (def all_4/4
(List $.Documentation)
(list ($.definition /.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))])
+ ($.example (revised #age ++ person))
+
+ ($.comment "Can also work with multiple levels of nesting.")
+ ($.example (revised [#foo #bar #baz] func my_record))
+
+ ($.comment "And, if only the slot/path and (optionally) the value are given, generates a mutator function.")
+ ($.example (let [updater (revised [#foo #bar #baz] func)]
+ (updater my_record)))
+ ($.example (let [updater (revised [#foo #bar #baz])]
+ (updater func my_record))))
... ($.definition /.^template
... "It's similar to template, but meant to be used during pattern-matching."
- ... [(def (reduced env type)
- ... (-> (List Type) Type Type)
- ... (when type
- ... {.#Primitive name params}
- ... {.#Primitive name (list#each (reduced env) params)}
-
- ... (^with_template [<tag>]
- ... [{<tag> left right}
- ... {<tag> (reduced env left) (reduced env right)}])
- ... ([.#Sum] [.#Product])
-
- ... (^with_template [<tag>]
- ... [{<tag> left right}
- ... {<tag> (reduced env left) (reduced env right)}])
- ... ([.#Function] [.#Apply])
-
- ... (^with_template [<tag>]
- ... [{<tag> old_env def}
- ... (when old_env
- ... {.#End}
- ... {<tag> env def}
-
- ... _
- ... type)])
- ... ([.#UnivQ] [.#ExQ])
-
- ... {.#Parameter idx}
- ... (else type (list.item idx env))
-
- ... _
- ... type
- ... ))])
+ ... ($.example (def (reduced env type)
+ ... (-> (List Type) Type Type)
+ ... (when type
+ ... {.#Primitive name params}
+ ... {.#Primitive name (list#each (reduced env) params)}
+
+ ... (^with_template [<tag>]
+ ... [{<tag> left right}
+ ... {<tag> (reduced env left) (reduced env right)}])
+ ... ([.#Sum] [.#Product])
+
+ ... (^with_template [<tag>]
+ ... [{<tag> left right}
+ ... {<tag> (reduced env left) (reduced env right)}])
+ ... ([.#Function] [.#Apply])
+
+ ... (^with_template [<tag>]
+ ... [{<tag> old_env def}
+ ... (when old_env
+ ... {.#End}
+ ... {<tag> env def}
+
+ ... _
+ ... type)])
+ ... ([.#UnivQ] [.#ExQ])
+
+ ... {.#Parameter idx}
+ ... (else type (list.item idx env))
+
+ ... _
+ ... type
+ ... ))))
(,, (with_template [<name> <doc>]
[($.definition <name>
@@ -663,41 +683,42 @@
($.definition /.loop
(format "Allows arbitrary looping, using the 'again' form to re-start the loop."
\n "Can be used in monadic code to create monadic loops.")
- [(loop (again [count +0
- x init])
- (if (< +10 count)
- (again (++ 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))])
+ ($.example (loop (again [count +0
+ x init])
+ (if (< +10 count)
+ (again (++ count) (f x))
+ x)))
+
+ ($.comment "Loops can also be given custom names.")
+ ($.example (loop (my_loop [count +0
+ x init])
+ (if (< +10 count)
+ (my_loop (++ count) (f x))
+ x))))
($.definition /.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> (with_template [<function> <parameter> <expected>]
- [(cover [<function>]
- (compare <text>
- (at codec encoded <function> <parameter>)))]
-
- [bit #1 "#1"]
- [int +123 "+123"]
- [frac +123.0 "+123.0"]
- [text "123" "'123'"]
- [symbol ["yolo" "lol"] "yolo.lol"]
- [form (list (bit #1)) "(#1)"]
- [tuple (list (bit #1)) "[#1]"]
- )]
- (all and
- <tests>
- )))])
+ ($.example (def test
+ Test
+ (with_expansions
+ [<tests> (with_template [<function> <parameter> <expected>]
+ [(cover [<function>]
+ (compare <text>
+ (at codec encoded <function> <parameter>)))]
+
+ [bit #1 "#1"]
+ [int +123 "+123"]
+ [frac +123.0 "+123.0"]
+ [text "123" "'123'"]
+ [symbol ["yolo" "lol"] "yolo.lol"]
+ [form (list (bit #1)) "(#1)"]
+ [tuple (list (bit #1)) "[#1]"]
+ )]
+ (all and
+ <tests>
+ )))))
($.definition /.static
(format "Resolves the names of definitions to their values at compile-time, assuming their values are either:"
@@ -707,155 +728,157 @@
\n "* Rev"
\n "* Frac"
\n "* Text")
- [(def my_nat 123)
- (def my_text "456")
- (and (when [my_nat my_text]
- (static [..my_nat ..my_text])
- true
+ ($.example (def my_nat 123))
+ ($.example (def my_text "456"))
+ ($.example (and (when [my_nat my_text]
+ (static [..my_nat ..my_text])
+ true
- _
- false)
- (when [my_nat my_text]
- [(static ..my_nat) (static ..my_text)]
- true
+ _
+ false)
+ (when [my_nat my_text]
+ [(static ..my_nat) (static ..my_text)]
+ true
- _
- false))])
+ _
+ false))))
... ($.definition /.^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.")
- ... [(when (split (size static) uri)
- ... (^multi {#Some [chunk uri']}
- ... [(text#= static chunk) .true])
- ... (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..."
- ... (when (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)})])
+ ... ($.example (when (split (size static) uri)
+ ... (^multi {#Some [chunk uri']}
+ ... [(text#= static chunk) .true])
+ ... (match_uri endpoint? parts' uri')
+
+ ... _
+ ... {#Left (format "Static part " (%t static) " does not match URI: " uri)}))
+
+ ... ($.comment "Short-cuts can be taken when using bit tests.")
+ ... ($.comment "The example above can be rewritten as...")
+ ... ($.example (when (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)})))
($.definition /.symbol
"Gives back a 2 tuple with the module and name parts, both as Text."
- [(symbol ..#doc)
- "=>"
- ["documentation/lux" "#doc"]])
+ ($.example (symbol ..#doc))
+ ($.comment "=>")
+ ($.example ["documentation/lux" "#doc"]))
($.definition /.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) (Sequence a)))
- (list#mix add
- (is (Sequence (parameter 0))
- empty)
- list))])
+ ($.comment "In the example below, 0 corresponds to the 'a' variable.")
+ ($.example (def .public (of_list list)
+ (All (_ a) (-> (List a) (Sequence a)))
+ (list#mix add
+ (is (Sequence (parameter 0))
+ empty)
+ list))))
($.definition /.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))])
+ ($.comment "This one should succeed:")
+ ($.example (let [value +5]
+ (same? value
+ value)))
+
+ ($.comment "This one should fail:")
+ ($.example (same? +5
+ (+ +2 +3))))
... ($.definition /.^let
... "Allows you to simultaneously bind and de-structure a value."
- ... [(def (hash (^let set [member_hash _]))
- ... (list#mix (function (_ elem acc)
- ... (+ acc
- ... (at member_hash hash elem)))
- ... 0
- ... (set.list set)))])
+ ... ($.example (def (hash (^let set [member_hash _]))
+ ... (list#mix (function (_ elem acc)
+ ... (+ acc
+ ... (at member_hash hash elem)))
+ ... 0
+ ... (set.list set)))))
... ($.definition /.^|>
... "Pipes the value being pattern-matched against prior to binding it to a variable."
- ... [(when input
- ... (^|> value [++ (% 10) (max 1)])
- ... (foo value))])
+ ... ($.example (when input
+ ... (^|> value [++ (% 10) (max 1)])
+ ... (foo value))))
($.definition /.as_expected
"Coerces the given expression to the type of whatever is expected."
- [(is Dinosaur
- (as_expected (is (List Nat)
- (list 1 2 3))))])
+ ($.example (is Dinosaur
+ (as_expected (is (List Nat)
+ (list 1 2 3))))))
($.definition /.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))])
+ ($.example (def (square x)
+ (-> Int Int)
+ (undefined))))
($.definition /.type_of
"Generates the type corresponding to a given expression."
- [(let [my_num +123]
- (type_of my_num))
- "=="
- Int]
- [(type_of +123)
- "=="
- Int])
+ ($.example (let [my_num +123]
+ (type_of my_num)))
+ ($.comment "==")
+ ($.example Int)
+
+ ($.example (type_of +123))
+ ($.comment "==")
+ ($.example Int))
($.definition /.template
(format "Define macros in the style of with_template."
\n "For simple macros that do not need any fancy features.")
- [(def square
- (template (square x)
- (* x x)))])
+ ($.example (def square
+ (template (square x)
+ (* x x)))))
($.definition /.these
(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> (these 1
- 2
- 3
- 4)]
- (all + <operands>))])
+ ($.example (with_expansions [<operands> (these 1
+ 2
+ 3
+ 4)]
+ (all + <operands>))))
($.definition /.char
"If given a 1-character text literal, yields the char-code of the sole character."
- [(is Nat
- (char "A"))
- "=>"
- 65])
+ ($.example (is Nat
+ (char "A")))
+ ($.comment "=>")
+ ($.example 65))
($.definition /.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))])
+ ($.example (def js
+ "JavaScript"))
+ ($.example (for "JVM" (do jvm stuff)
+ js (do js stuff)
+ (do default stuff))))
($.definition /.``
(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))))])
+ ($.example (`` (some expression
+ (,, (some macro which may yield 0 or more results))))))
... ($.definition /.^code
... "Generates pattern-matching code for Code values in a way that looks like code-templating."
- ... [(is (Maybe Nat)
- ... (when (` (#0 123 +456.789))
- ... (^code (#0 (, [_ {.#Nat number}]) +456.789))
- ... {.#Some number}
+ ... ($.example (is (Maybe Nat)
+ ... (when (` (#0 123 +456.789))
+ ... (^code (#0 (, [_ {.#Nat number}]) +456.789))
+ ... {.#Some number}
- ... _
- ... {.#None}))])
+ ... _
+ ... {.#None}))))
($.definition /.false
"The boolean FALSE value.")
@@ -865,17 +888,17 @@
($.definition /.try
""
- [(is Foo
- (when (is (Either Text Bar)
- (try (is Bar
- (risky computation which may panic))))
- {.#Right success}
- (is Foo
- (do something after success))
-
- {.#Left error}
- (is Foo
- (recover from error))))])
+ ($.example (is Foo
+ (when (is (Either Text Bar)
+ (try (is Bar
+ (risky computation which may panic))))
+ {.#Right success}
+ (is Foo
+ (do something after success))
+
+ {.#Left error}
+ (is Foo
+ (recover from error))))))
($.definition (/.Code' w))
($.definition /.Alias)
diff --git a/stdlib/source/documentation/lux/abstract/codec.lux b/stdlib/source/documentation/lux/abstract/codec.lux
index b83ba092a..58c565e60 100644
--- a/stdlib/source/documentation/lux/abstract/codec.lux
+++ b/stdlib/source/documentation/lux/abstract/codec.lux
@@ -15,8 +15,8 @@
($.definition /.composite
"Codec composition."
- [(is (Codec c a)
- (composite (is (Codec c b)
- cb_codec)
- (is (Codec b a)
- ba_codec)))])))
+ ($.example (is (Codec c a)
+ (composite (is (Codec c b)
+ cb_codec)
+ (is (Codec b a)
+ ba_codec)))))))
diff --git a/stdlib/source/documentation/lux/abstract/comonad.lux b/stdlib/source/documentation/lux/abstract/comonad.lux
index dd4fbc2e0..b54df4835 100644
--- a/stdlib/source/documentation/lux/abstract/comonad.lux
+++ b/stdlib/source/documentation/lux/abstract/comonad.lux
@@ -22,9 +22,9 @@
($.definition /.be
"A co-monadic parallel to the 'do' macro."
- [(let [square (function (_ n) (* n n))]
- (be comonad
- [inputs (iterate ++ +2)]
- (square (out inputs))))])
+ ($.example (let [square (function (_ n) (* n n))]
+ (be comonad
+ [inputs (iterate ++ +2)]
+ (square (out inputs))))))
/free.documentation))
diff --git a/stdlib/source/documentation/lux/abstract/enum.lux b/stdlib/source/documentation/lux/abstract/enum.lux
index 4895c3543..e507e069c 100644
--- a/stdlib/source/documentation/lux/abstract/enum.lux
+++ b/stdlib/source/documentation/lux/abstract/enum.lux
@@ -15,4 +15,4 @@
($.definition /.range
"An inclusive [from, to] range of values."
- [(range enum from to)])))
+ ($.example (range enum from to)))))
diff --git a/stdlib/source/documentation/lux/abstract/equivalence.lux b/stdlib/source/documentation/lux/abstract/equivalence.lux
index dd00470b8..782d996c8 100644
--- a/stdlib/source/documentation/lux/abstract/equivalence.lux
+++ b/stdlib/source/documentation/lux/abstract/equivalence.lux
@@ -20,4 +20,4 @@
($.definition /.rec
"A recursive equivalence combinator."
- [(rec recursive_equivalence)])))
+ ($.example (rec recursive_equivalence)))))
diff --git a/stdlib/source/documentation/lux/abstract/interval.lux b/stdlib/source/documentation/lux/abstract/interval.lux
index 0cb58df71..49e1e7894 100644
--- a/stdlib/source/documentation/lux/abstract/interval.lux
+++ b/stdlib/source/documentation/lux/abstract/interval.lux
@@ -36,7 +36,7 @@
($.definition /.singleton
"An interval where both top and bottom are the same value."
- [(singleton enum elem)])
+ ($.example (singleton enum elem)))
($.definition /.borders?
"Where a value is at the border of an interval.")
diff --git a/stdlib/source/documentation/lux/abstract/mix.lux b/stdlib/source/documentation/lux/abstract/mix.lux
index d20c7b77e..1a002a077 100644
--- a/stdlib/source/documentation/lux/abstract/mix.lux
+++ b/stdlib/source/documentation/lux/abstract/mix.lux
@@ -18,4 +18,4 @@
($.definition /.with_monoid
"Mix a mixable structure using the monoid's identity as the initial value."
- [(with_monoid monoid mix value)])))
+ ($.example (with_monoid monoid mix value)))))
diff --git a/stdlib/source/documentation/lux/abstract/monad.lux b/stdlib/source/documentation/lux/abstract/monad.lux
index 45404fc1b..82b70aec8 100644
--- a/stdlib/source/documentation/lux/abstract/monad.lux
+++ b/stdlib/source/documentation/lux/abstract/monad.lux
@@ -23,30 +23,30 @@
($.definition /.do
"Macro for easy concatenation of monadic operations."
- [(do monad
- [y (f1 x)
- z (f2 z)]
- (in (f3 z)))])
+ ($.example (do monad
+ [y (f1 x)
+ z (f2 z)]
+ (in (f3 z)))))
($.definition /.then
"Apply a function with monadic effects to a monadic value and yield a new monadic value."
- [(then monad function)])
+ ($.example (then monad function)))
($.definition /.all
"Run all the monadic values in the list and produce a list of the base values."
- [(all monad)])
+ ($.example (all monad)))
($.definition /.each
"Apply a monadic function to all values in a list."
- [(each monad function items)])
+ ($.example (each monad function items)))
($.definition /.only
"Filter the values in a list with a monadic function."
- [(only monad predicate items)])
+ ($.example (only monad predicate items)))
($.definition /.mix
"Mix a list with a monadic function."
- [(mix monad function initial_value items)])
+ ($.example (mix monad function initial_value items)))
/free.documentation
))
diff --git a/stdlib/source/documentation/lux/control.lux b/stdlib/source/documentation/lux/control.lux
index 0dd79c795..cd0a43d44 100644
--- a/stdlib/source/documentation/lux/control.lux
+++ b/stdlib/source/documentation/lux/control.lux
@@ -20,7 +20,6 @@
["[1][0]" pipe]
["[1][0]" reader]
["[1][0]" region]
- ["[1][0]" remember]
["[1][0]" security]
["[1][0]" state]
["[1][0]" thread]
@@ -42,7 +41,6 @@
/pipe.documentation
/reader.documentation
/region.documentation
- /remember.documentation
/security.documentation
/state.documentation
/thread.documentation
diff --git a/stdlib/source/documentation/lux/control/concatenative.lux b/stdlib/source/documentation/lux/control/concatenative.lux
index e72231627..95ddfc520 100644
--- a/stdlib/source/documentation/lux/control/concatenative.lux
+++ b/stdlib/source/documentation/lux/control/concatenative.lux
@@ -80,22 +80,22 @@
($.definition /.=>
"Concatenative function types."
- [(=> [Nat] [Nat])]
- [(All (_ a)
- (-> a (=> [] [a])))]
- [(All (_ t)
- (=> [t] []))]
- [(All (_ a b c)
- (=> [a b c] [b c a]))]
- [(All (_ ,,,0 ,,,1)
- (=> [then (=> ,,,0 ,,,1)
- else (=> ,,,0 ,,,1)]
- ,,,0 [Bit then else] ,,,1))])
+ ($.example (=> [Nat] [Nat]))
+ ($.example (All (_ a)
+ (-> a (=> [] [a]))))
+ ($.example (All (_ t)
+ (=> [t] [])))
+ ($.example (All (_ a b c)
+ (=> [a b c] [b c a])))
+ ($.example (All (_ ,,,0 ,,,1)
+ (=> [then (=> ,,,0 ,,,1)
+ else (=> ,,,0 ,,,1)]
+ ,,,0 [Bit then else] ,,,1))))
($.definition /.apply
"A generator for functions that turn arity N functions into arity N concatenative functions."
- [(is (=> [Nat] [Nat])
- ((apply 1) ++))])
+ ($.example (is (=> [Nat] [Nat])
+ ((apply 1) ++))))
(,, (with_template [<arity>]
[(with_expansions [<name> (template.symbol [/._] ["apply_" <arity>])
@@ -140,11 +140,11 @@
($.definition /.if
"If expression."
- [(same? "then"
- (/.value (|>> (push true)
- (push "then")
- (push "else")
- if)))])
+ ($.example (same? "then"
+ (/.value (|>> (push true)
+ (push "then")
+ (push "else")
+ if)))))
($.definition /.call
"Executes an anonymous block on the stack.")
@@ -160,39 +160,39 @@
($.definition /.do
"Do-while loop expression."
- [(n.= (++ sample)
- (/.value (|>> (push sample)
- (push (push false))
- (push (|>> (push 1) n/+))
- do while)))])
+ ($.example (n.= (++ sample)
+ (/.value (|>> (push sample)
+ (push (push false))
+ (push (|>> (push 1) n/+))
+ do while)))))
($.definition /.while
"While loop expression."
- [(n.= (n.+ distance start)
- (/.value (|>> (push start)
- (push (|>> dup
- (push start) n/-
- (push distance) n/<))
- (push (|>> (push 1) n/+))
- while)))])
+ ($.example (n.= (n.+ distance start)
+ (/.value (|>> (push start)
+ (push (|>> dup
+ (push start) n/-
+ (push distance) n/<))
+ (push (|>> (push 1) n/+))
+ while)))))
($.definition /.compose
"Function composition."
- [(n.= (n.+ 2 sample)
- (/.value (|>> (push sample)
- (push (|>> (push 1) n/+))
- (push (|>> (push 1) n/+))
- compose
- call)))])
+ ($.example (n.= (n.+ 2 sample)
+ (/.value (|>> (push sample)
+ (push (|>> (push 1) n/+))
+ (push (|>> (push 1) n/+))
+ compose
+ call)))))
($.definition /.partial
"Partial application."
- [(n.= (n.+ sample sample)
- (/.value (|>> (push sample)
- (push sample)
- (push n/+)
- partial
- call)))])
+ ($.example (n.= (n.+ sample sample)
+ (/.value (|>> (push sample)
+ (push sample)
+ (push n/+)
+ partial
+ call)))))
($.definition /.?
"Choose the top value when #0 and the second-to-top when #1.")
diff --git a/stdlib/source/documentation/lux/control/concurrency/async.lux b/stdlib/source/documentation/lux/control/concurrency/async.lux
index f05e501b0..d561e6d4c 100644
--- a/stdlib/source/documentation/lux/control/concurrency/async.lux
+++ b/stdlib/source/documentation/lux/control/concurrency/async.lux
@@ -26,55 +26,55 @@
($.definition /.resolved
"Produces an async that has already been resolved to the given value."
- [(resolved value)])
+ ($.example (resolved value)))
($.definition /.async
"Creates a fresh async that has not been resolved yet."
- [(async _)])
+ ($.example (async _)))
($.definition /.value
"Polls an async for its value.")
($.definition /.upon!
"Executes the given function as soon as the async has been resolved."
- [(upon! function async)])
+ ($.example (upon! function async)))
($.definition /.resolved?
"Checks whether an async's value has already been resolved.")
($.definition /.and
"Combines the results of both asyncs, in-order."
- [(and left right)])
+ ($.example (and left right)))
($.definition /.or
(format "Yields the results of whichever async gets resolved first."
\n "You can tell which one was resolved first through pattern-matching.")
- [(or left right)])
+ ($.example (or left right)))
($.definition /.either
(format "Yields the results of whichever async gets resolved first."
\n "You cannot tell which one was resolved first.")
- [(either left right)])
+ ($.example (either left right)))
($.definition /.schedule!
(format "Runs an I/O computation on its own thread (after a specified delay)."
\n "Returns an async that will eventually host its result.")
- [(schedule! milli_seconds computation)])
+ ($.example (schedule! milli_seconds computation)))
($.definition /.future
(format "Runs an I/O computation on its own thread."
\n "Returns an async that will eventually host its result.")
- [(future computation)])
+ ($.example (future computation)))
($.definition /.after
"Delivers a value after a certain period has passed."
- [(after milli_seconds value)])
+ ($.example (after milli_seconds value)))
($.definition /.delay
"An async that will be resolved after the specified amount of milli-seconds."
- [(delay milli_seconds)])
+ ($.example (delay milli_seconds)))
($.definition /.within
"Wait for an async to be resolved within the specified amount of milli-seconds."
- [(within milli_seconds async)])
+ ($.example (within milli_seconds async)))
))
diff --git a/stdlib/source/documentation/lux/control/concurrency/frp.lux b/stdlib/source/documentation/lux/control/concurrency/frp.lux
index f22587e37..7334340f5 100644
--- a/stdlib/source/documentation/lux/control/concurrency/frp.lux
+++ b/stdlib/source/documentation/lux/control/concurrency/frp.lux
@@ -33,7 +33,7 @@
($.definition /.channel
"Creates a brand-new channel and hands it over, along with the sink to write to it."
- [(channel _)])
+ ($.example (channel _)))
($.definition (/.Subscriber it)
"A function that can receive every value fed into a channel.")
@@ -41,17 +41,17 @@
($.definition /.only
(format "Produces a new channel based on the old one, only with values"
\n "that pass the test.")
- [(only pass? channel)])
+ ($.example (only pass? channel)))
($.definition /.of_async
"A one-element channel containing the output from an async."
- [(of_async async)])
+ ($.example (of_async async)))
($.definition /.mix
"Asynchronous mix over channels."
- [(mix f init channel)])
+ ($.example (mix f init channel)))
($.definition /.sequential
"Transforms the given list into a channel with the same elements."
- [(sequential milli_seconds values)])
+ ($.example (sequential milli_seconds values)))
))
diff --git a/stdlib/source/documentation/lux/control/concurrency/semaphore.lux b/stdlib/source/documentation/lux/control/concurrency/semaphore.lux
index 757bb8692..86d302ce4 100644
--- a/stdlib/source/documentation/lux/control/concurrency/semaphore.lux
+++ b/stdlib/source/documentation/lux/control/concurrency/semaphore.lux
@@ -21,27 +21,27 @@
($.definition /.semaphore
""
- [(semaphore initial_open_positions)])
+ ($.example (semaphore initial_open_positions)))
($.definition /.wait!
(format "Wait on a semaphore until there are open positions."
\n "After finishing your work, you must 'signal' to the semaphore that you're done.")
- [(wait! semaphore)])
+ ($.example (wait! semaphore)))
($.definition /.signal!
"Signal to a semaphore that you're done with your work, and that there is a new open position."
- [(signal! semaphore)])
+ ($.example (signal! semaphore)))
($.definition /.Mutex
"A mutual-exclusion lock that can only be acquired by one process at a time.")
($.definition /.mutex
"Creates a brand-new mutex."
- [(mutex _)])
+ ($.example (mutex _)))
($.definition /.synchronize!
"Runs the procedure with exclusive control of the mutex."
- [(synchronize! mutex procedure)])
+ ($.example (synchronize! mutex procedure)))
($.definition /.limit
"Produce a limit for a barrier.")
diff --git a/stdlib/source/documentation/lux/control/concurrency/stm.lux b/stdlib/source/documentation/lux/control/concurrency/stm.lux
index afa5e4744..90f704e5a 100644
--- a/stdlib/source/documentation/lux/control/concurrency/stm.lux
+++ b/stdlib/source/documentation/lux/control/concurrency/stm.lux
@@ -24,22 +24,22 @@
($.definition /.var
"Creates a new STM var, with a default value."
- [(var value)])
+ ($.example (var value)))
($.definition /.changes
"Creates a channel that will receive all changes to the value of the given var."
- [(changes target)])
+ ($.example (changes target)))
($.definition (/.STM it)
"A computation which updates a transaction and produces a value.")
($.definition /.update
"Update a var's value, and return a tuple with the old and the new values."
- [(update function var)])
+ ($.example (update function var)))
($.definition /.commit!
(format "Commits a transaction and returns its result (asynchronously)."
\n "Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first."
\n "For this reason, it's important to note that transactions must be free from side-effects, such as I/O.")
- [(commit! procedure)])
+ ($.example (commit! procedure)))
))
diff --git a/stdlib/source/documentation/lux/control/concurrency/thread.lux b/stdlib/source/documentation/lux/control/concurrency/thread.lux
index ec9e89ee1..bba721d0e 100644
--- a/stdlib/source/documentation/lux/control/concurrency/thread.lux
+++ b/stdlib/source/documentation/lux/control/concurrency/thread.lux
@@ -18,5 +18,5 @@
($.definition /.schedule!
"Executes an I/O procedure after some milli-seconds."
- [(schedule! milli_seconds action)])
+ ($.example (schedule! milli_seconds action)))
))
diff --git a/stdlib/source/documentation/lux/control/continuation.lux b/stdlib/source/documentation/lux/control/continuation.lux
index c1baa45bd..18dd0ff89 100644
--- a/stdlib/source/documentation/lux/control/continuation.lux
+++ b/stdlib/source/documentation/lux/control/continuation.lux
@@ -25,23 +25,23 @@
($.definition /.continued
"Continues a continuation thunk."
- [(continued next cont)])
+ ($.example (continued next cont)))
($.definition /.result
"Forces a continuation thunk to be evaluated."
- [(result cont)])
+ ($.example (result cont)))
($.definition /.with_current
"Call with current continuation."
- [(with_current
- (function (_ go)
- (do /.monad
- [.let [nexus (function (nexus val)
- (go [nexus val]))]
- _ (go [nexus init])]
- (in (undefined)))))])
+ ($.example (with_current
+ (function (_ go)
+ (do /.monad
+ [.let [nexus (function (nexus val)
+ (go [nexus val]))]
+ _ (go [nexus init])]
+ (in (undefined)))))))
($.definition /.pending
"Turns any expression into a function that is pending a continuation."
- [(pending (some_function some_input))])
+ ($.example (pending (some_function some_input))))
))
diff --git a/stdlib/source/documentation/lux/control/exception.lux b/stdlib/source/documentation/lux/control/exception.lux
index 27e2a28d5..00162335b 100644
--- a/stdlib/source/documentation/lux/control/exception.lux
+++ b/stdlib/source/documentation/lux/control/exception.lux
@@ -20,49 +20,50 @@
($.definition /.match?
"Is this exception the cause of the error message?"
- [(match? exception error)])
+ ($.example (match? exception error)))
($.definition /.when
(format "If a particular exception is detected on a possibly-erroneous value, handle it."
\n "If no exception was detected, or a different one from the one being checked, then pass along the original value.")
- [(when exception then try)])
+ ($.example (when exception then try)))
($.definition /.otherwise
"If no handler could be found to catch the exception, then run a function as a last-resort measure."
- [(otherwise else try)])
+ ($.example (otherwise else try)))
($.definition /.error
"Constructs an error message from an exception."
- [(error exception message)])
+ ($.example (error exception message)))
($.definition /.except
"Decorate an error message with an Exception and lift it into the error-handling context."
- [(except exception message)])
+ ($.example (except exception message)))
($.definition /.def
(format "Define a new exception type."
\n "It mostly just serves as a way to tag error messages for later catching.")
- ["Simple case:"
- (/.def .public some_exception)]
- ["Complex case:"
- (/.def .public [arbitrary type variables] (some_exception [optional arguments])
- (/.Exception [Text Int])
- optional_body)])
+ ($.comment "Simple case:")
+ ($.example (/.def .public some_exception))
+
+ ($.comment "Complex case:")
+ ($.example (/.def .public [arbitrary type variables] (some_exception [optional arguments])
+ (/.Exception [Text Int])
+ optional_body)))
($.definition /.report
"An error report."
- [(is Text
- (report (list ["Row 0" value/0]
- ["Row 1" value/1]
- ,,,
- ["Row N" value/N])))])
+ ($.example (is Text
+ (report (list ["Row 0" value/0]
+ ["Row 1" value/1]
+ ,,,
+ ["Row N" value/N])))))
($.definition /.listing
(format "A numbered report of the entries on a list."
\n "NOTE: 0-based numbering.")
- [(listing format entries)])
+ ($.example (listing format entries)))
($.definition /.with
"If a computation fails, prepends the exception to the error."
- [(with exception message computation)])
+ ($.example (with exception message computation)))
))
diff --git a/stdlib/source/documentation/lux/control/function.lux b/stdlib/source/documentation/lux/control/function.lux
index 237844ab2..fc46bee14 100644
--- a/stdlib/source/documentation/lux/control/function.lux
+++ b/stdlib/source/documentation/lux/control/function.lux
@@ -26,27 +26,27 @@
($.definition /.identity
(format "Identity function."
\n "Does nothing to its argument and just returns it.")
- [(same? (identity value)
- value)])
+ ($.example (same? (identity value)
+ value)))
($.definition /.composite
"Function composition."
- [(= ((composite f g) "foo")
- (f (g "foo")))])
+ ($.example (= ((composite f g) "foo")
+ (f (g "foo")))))
($.definition /.constant
"Create constant functions."
- [(= ((constant "foo") "bar")
- "foo")])
+ ($.example (= ((constant "foo") "bar")
+ "foo")))
($.definition /.flipped
"Flips the order of the arguments of a function."
- [(= ((flipped f) "foo" "bar")
- (f "bar" "foo"))])
+ ($.example (= ((flipped f) "foo" "bar")
+ (f "bar" "foo"))))
($.definition /.on
"Simple 1-argument function application."
- [(on input function)])
+ ($.example (on input function)))
(all list#composite
/contract.documentation
diff --git a/stdlib/source/documentation/lux/control/function/contract.lux b/stdlib/source/documentation/lux/control/function/contract.lux
index ad91f818d..d801bc441 100644
--- a/stdlib/source/documentation/lux/control/function/contract.lux
+++ b/stdlib/source/documentation/lux/control/function/contract.lux
@@ -20,14 +20,14 @@
(format "Pre-conditions."
\n "Given a test and an expression to run, only runs the expression if the test passes."
\n "Otherwise, an error is raised.")
- [(pre (i.= +4 (i.+ +2 +2))
- (foo +123 +456 +789))])
+ ($.example (pre (i.= +4 (i.+ +2 +2))
+ (foo +123 +456 +789))))
($.definition /.post
(format "Post-conditions."
\n "Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate."
\n "If the predicate returns #1, returns the value of the expression."
\n "Otherwise, an error is raised.")
- [(post i.even?
- (i.+ +2 +2))])
+ ($.example (post i.even?
+ (i.+ +2 +2))))
))
diff --git a/stdlib/source/documentation/lux/control/function/memo.lux b/stdlib/source/documentation/lux/control/function/memo.lux
index dcbda3a2d..83c4a234a 100644
--- a/stdlib/source/documentation/lux/control/function/memo.lux
+++ b/stdlib/source/documentation/lux/control/function/memo.lux
@@ -18,15 +18,15 @@
($.definition /.open
"Memoization where the memoized results can be re-used accross invocations."
- [(open memo)])
+ ($.example (open memo)))
($.definition /.closed
(format "Memoization confined to a single invocation to the function (not counting any subsequent recursive invocations)."
\n "Memoized results will be re-used during recursive invocations, but cannot be accessed after the main invocation has ended.")
- [(closed hash memo)])
+ ($.example (closed hash memo)))
($.definition /.none
(format "No memoization at all."
\n "This is useful as a test control when measuring the effect of using memoization.")
- [(none hash memo)])
+ ($.example (none hash memo)))
))
diff --git a/stdlib/source/documentation/lux/control/function/mixin.lux b/stdlib/source/documentation/lux/control/function/mixin.lux
index 9ed15bf09..4f7e45fed 100644
--- a/stdlib/source/documentation/lux/control/function/mixin.lux
+++ b/stdlib/source/documentation/lux/control/function/mixin.lux
@@ -20,31 +20,31 @@
($.definition /.fixed
"Given a mixin, produces a normal function."
- [(fixed f)])
+ ($.example (fixed f)))
($.definition /.nothing
"A mixin that does nothing and just delegates work to the next mixin.")
($.definition /.mixed
"Produces a new mixin, where the behavior of the child can make use of the behavior of the parent."
- [(mixed parent child)])
+ ($.example (mixed parent child)))
($.definition /.advice
"Only apply then mixin when the input meets some criterion."
- [(advice when then)])
+ ($.example (advice when then)))
($.definition /.before
"Executes an action before doing the main work."
- [(before monad action)])
+ ($.example (before monad action)))
($.definition /.after
"Executes an action after doing the main work."
- [(after monad action)])
+ ($.example (after monad action)))
($.definition (/.Recursive input output)
"An indirectly recursive function.")
($.definition /.of_recursive
"Transform an indirectly recursive function into a mixin."
- [(of_recursive recursive)])
+ ($.example (of_recursive recursive)))
))
diff --git a/stdlib/source/documentation/lux/control/function/mutual.lux b/stdlib/source/documentation/lux/control/function/mutual.lux
index 58fb34b97..59170783e 100644
--- a/stdlib/source/documentation/lux/control/function/mutual.lux
+++ b/stdlib/source/documentation/lux/control/function/mutual.lux
@@ -15,32 +15,32 @@
($.definition /.let
"Locally-defined mutually-recursive functions."
- [(let [(even? number)
- (-> Nat Bit)
- (when number
- 0 true
- _ (odd? (-- number)))
+ ($.example (let [(even? number)
+ (-> Nat Bit)
+ (when number
+ 0 true
+ _ (odd? (-- number)))
- (odd? number)
- (-> Nat Bit)
- (when number
- 0 false
- _ (even? (-- number)))]
- (and (even? 4)
- (odd? 5)))])
+ (odd? number)
+ (-> Nat Bit)
+ (when number
+ 0 false
+ _ (even? (-- number)))]
+ (and (even? 4)
+ (odd? 5)))))
($.definition /.def
"Globally-defined mutually-recursive functions."
- [(def
- [.public (even? number)
- (-> Nat Bit)
- (when number
- 0 true
- _ (odd? (-- number)))]
+ ($.example (def
+ [.public (even? number)
+ (-> Nat Bit)
+ (when number
+ 0 true
+ _ (odd? (-- number)))]
- [.public (odd? number)
- (-> Nat Bit)
- (when number
- 0 false
- _ (even? (-- number)))])])
+ [.public (odd? number)
+ (-> Nat Bit)
+ (when number
+ 0 false
+ _ (even? (-- number)))])))
))
diff --git a/stdlib/source/documentation/lux/control/io.lux b/stdlib/source/documentation/lux/control/io.lux
index 2e650626b..0e40e42f2 100644
--- a/stdlib/source/documentation/lux/control/io.lux
+++ b/stdlib/source/documentation/lux/control/io.lux
@@ -23,9 +23,9 @@
($.definition /.io
(format "Delays the evaluation of an expression, by wrapping it in an IO 'thunk'."
\n "Great for wrapping effectful computations (which will not be performed until the IO is 'run!').")
- [(io (exec
- (log! msg)
- "Some value..."))])
+ ($.example (io (exec
+ (log! msg)
+ "Some value..."))))
($.definition /.run!
"A way to execute IO computations and perform their side-effects.")
diff --git a/stdlib/source/documentation/lux/control/lazy.lux b/stdlib/source/documentation/lux/control/lazy.lux
index 5e8d22e27..0a47c0faa 100644
--- a/stdlib/source/documentation/lux/control/lazy.lux
+++ b/stdlib/source/documentation/lux/control/lazy.lux
@@ -25,5 +25,5 @@
($.definition /.lazy
"Specifies a lazy value by providing the expression that computes it."
- [(lazy eager_computation)])
+ ($.example (lazy eager_computation)))
))
diff --git a/stdlib/source/documentation/lux/control/maybe.lux b/stdlib/source/documentation/lux/control/maybe.lux
index 0f22bcba5..1d4ef6c27 100644
--- a/stdlib/source/documentation/lux/control/maybe.lux
+++ b/stdlib/source/documentation/lux/control/maybe.lux
@@ -24,29 +24,30 @@
($.definition /.lifted
"Wraps a monadic value with Maybe machinery."
- [(lifted monad)])
+ ($.example (lifted monad)))
($.definition /.else
(format "Allows you to provide a default value that will be used"
\n "if a (Maybe x) value turns out to be .#None."
\n "Note: the expression for the default value will not be computed if the base computation succeeds.")
- [(else +20 {.#Some +10})
- "=>"
- +10]
- [(else +20 {.#None})
- "=>"
- +20])
+ ($.example (else +20 {.#Some +10}))
+ ($.comment "=>")
+ ($.example +10)
+
+ ($.example (else +20 {.#None}))
+ ($.comment "=>")
+ ($.example +20))
($.definition /.trusted
(format "Assumes that a Maybe value is a .#Some and yields its value."
\n "Raises/throws a runtime error otherwise."
\n "WARNING: Use with caution.")
- [(trusted trusted_computation)])
+ ($.example (trusted trusted_computation)))
($.definition /.when
"Can be used as a guard in (co)monadic be/do expressions."
- [(do monad
- [value (do_something 1 2 3)
- .when (passes_test? value)]
- (do_something_else 4 5 6))])
+ ($.example (do monad
+ [value (do_something 1 2 3)
+ .when (passes_test? value)]
+ (do_something_else 4 5 6))))
))
diff --git a/stdlib/source/documentation/lux/control/parser.lux b/stdlib/source/documentation/lux/control/parser.lux
index 1ece53c07..ba7a726b2 100644
--- a/stdlib/source/documentation/lux/control/parser.lux
+++ b/stdlib/source/documentation/lux/control/parser.lux
@@ -22,107 +22,107 @@
($.definition /.assertion
"Fails with the given message if the test is #0."
- [(assertion message test)])
+ ($.example (assertion message test)))
($.definition /.maybe
"Optionality combinator."
- [(maybe parser)])
+ ($.example (maybe parser)))
($.definition /.result
(format "Executes the parser on the input."
\n "Does not verify that all of the input has been consumed by the parser."
\n "Returns both the parser's output, and a value that represents the remaining input.")
- [(result parser input)])
+ ($.example (result parser input)))
($.definition /.and
"Sequencing combinator."
- [(and first second)])
+ ($.example (and first second)))
($.definition /.or
"Heterogeneous alternative combinator."
- [(or left right)])
+ ($.example (or left right)))
($.definition /.either
"Homogeneous alternative combinator."
- [(either this that)])
+ ($.example (either this that)))
($.definition /.some
"0-or-more combinator."
- [(some parser)])
+ ($.example (some parser)))
($.definition /.many
"1-or-more combinator."
- [(many parser)])
+ ($.example (many parser)))
($.definition /.exactly
"Parse exactly N times."
- [(exactly amount parser)])
+ ($.example (exactly amount parser)))
($.definition /.at_least
"Parse at least N times."
- [(at_least amount parser)])
+ ($.example (at_least amount parser)))
($.definition /.at_most
"Parse at most N times."
- [(at_most amount parser)])
+ ($.example (at_most amount parser)))
($.definition /.between
""
- [(between minimum additional parser)])
+ ($.example (between minimum additional parser)))
($.definition /.separated_by
"Parses instances of 'parser' that are separated by instances of 'separator'."
- [(separated_by separator parser)])
+ ($.example (separated_by separator parser)))
($.definition /.not
"Only succeeds when the underlying parser fails."
- [(not parser)])
+ ($.example (not parser)))
($.definition /.failure
"Always fail with this 'message'."
- [(failure message)])
+ ($.example (failure message)))
($.definition /.lifted
"Lift a potentially failed computation into a parser."
- [(lifted operation)])
+ ($.example (lifted operation)))
($.definition /.else
"If the given parser fails, returns the default value."
- [(else value parser)])
+ ($.example (else value parser)))
($.definition /.remaining
"Yield the remaining input (without consuming it).")
($.definition /.rec
"Combinator for recursive parsers."
- [(rec parser)])
+ ($.example (rec parser)))
($.definition /.after
"Run the parser after another one (whose output is ignored)."
- [(after param subject)])
+ ($.example (after param subject)))
($.definition /.before
"Run the parser before another one (whose output is ignored)."
- [(before param subject)])
+ ($.example (before param subject)))
($.definition /.only
"Only succeed when the parser's output passes a test."
- [(only test parser)])
+ ($.example (only test parser)))
($.definition /.parses?
"Ignore a parser's output and just verify that it succeeds."
- [(parses? parser)])
+ ($.example (parses? parser)))
($.definition /.parses
"Ignore a parser's output and just execute it."
- [(parses parser)])
+ ($.example (parses parser)))
($.definition /.speculative
(format "Executes a parser, without actually consuming the input."
\n "That way, the same input can be consumed again by another parser.")
- [(speculative parser)])
+ ($.example (speculative parser)))
($.definition /.codec
"Decode the output of a parser using a codec."
- [(codec codec parser)])
+ ($.example (codec codec parser)))
))
diff --git a/stdlib/source/documentation/lux/control/pipe.lux b/stdlib/source/documentation/lux/control/pipe.lux
index ff4d7a4fb..d9d1ef15f 100644
--- a/stdlib/source/documentation/lux/control/pipe.lux
+++ b/stdlib/source/documentation/lux/control/pipe.lux
@@ -15,83 +15,83 @@
($.definition /.new
"Ignores the piped argument, and begins a new pipe."
- [(n.= 1
- (|> 20
- (n.* 3)
- (n.+ 4)
- (new 0 [++])))])
+ ($.example (n.= 1
+ (|> 20
+ (n.* 3)
+ (n.+ 4)
+ (new 0 [++])))))
($.definition /.let
"Gives a name to the piped-argument, within the given expression."
- [(n.= 10
- (|> 5
- (let x (n.+ x x))))])
+ ($.example (n.= 10
+ (|> 5
+ (let x (n.+ x x))))))
($.definition /.cond
(format "Branching for pipes."
\n "Both the tests and the bodies are piped-code, and must be given inside a tuple.")
- [(|> +5
- (cond [i.even?] [(i.* +2)]
- [i.odd?] [(i.* +3)]
- [(new -1 [])]))])
+ ($.example (|> +5
+ (cond [i.even?] [(i.* +2)]
+ [i.odd?] [(i.* +3)]
+ [(new -1 [])]))))
($.definition /.if
"If-branching."
- [(same? (if (n.even? sample)
- "even"
- "odd")
- (|> sample
- (if [n.even?]
- [(new "even" [])]
- [(new "odd" [])])))])
+ ($.example (same? (if (n.even? sample)
+ "even"
+ "odd")
+ (|> sample
+ (if [n.even?]
+ [(new "even" [])]
+ [(new "odd" [])])))))
($.definition /.while
(format "While loops for pipes."
\n "Both the testing and calculating steps are pipes and must be given inside tuples.")
- [(|> +1
- (while [(i.< +10)]
- [++]))])
+ ($.example (|> +1
+ (while [(i.< +10)]
+ [++]))))
($.definition /.do
(format "Monadic pipes."
\n "Each steps in the monadic computation is a pipe and must be given inside a tuple.")
- [(|> +5
- (do identity.monad
- [(i.* +3)]
- [(i.+ +4)]
- [++]))])
+ ($.example (|> +5
+ (do identity.monad
+ [(i.* +3)]
+ [(i.+ +4)]
+ [++]))))
($.definition /.exec
(format "Non-updating pipes."
\n "Will generate piped computations, but their results will not be used in the larger scope.")
- [(|> +5
- (exec [.nat %n log!])
- (i.* +10))])
+ ($.example (|> +5
+ (exec [.nat %n log!])
+ (i.* +10))))
($.definition /.tuple
(format "Parallel branching for pipes."
\n "Allows to run multiple pipelines for a value and gives you a tuple of the outputs.")
- [(|> +5
- (tuple [(i.* +10)]
- [-- (i./ +2)]
- [i#encoded]))
- "=>"
- [+50 +2 "+5"]])
+ ($.example (|> +5
+ (tuple [(i.* +10)]
+ [-- (i./ +2)]
+ [i#encoded])))
+ ($.comment "=>")
+ ($.example [+50 +2 "+5"]))
($.definition /.when
(format "Pattern-matching for pipes."
\n "The bodies of each branch are NOT pipes; just regular values.")
- [(|> +5
- (when
- +0 "zero"
- +1 "one"
- +2 "two"
- +3 "three"
- +4 "four"
- +5 "five"
- +6 "six"
- +7 "seven"
- +8 "eight"
- +9 "nine"
- _ "???"))])
+ ($.example (|> +5
+ (when
+ +0 "zero"
+ +1 "one"
+ +2 "two"
+ +3 "three"
+ +4 "four"
+ +5 "five"
+ +6 "six"
+ +7 "seven"
+ +8 "eight"
+ +9 "nine"
+ _ "???"))))
))
diff --git a/stdlib/source/documentation/lux/control/reader.lux b/stdlib/source/documentation/lux/control/reader.lux
index 33f324843..e25658e77 100644
--- a/stdlib/source/documentation/lux/control/reader.lux
+++ b/stdlib/source/documentation/lux/control/reader.lux
@@ -25,15 +25,15 @@
($.definition /.local
"Run computation with a locally-modified environment."
- [(local change proc)])
+ ($.example (local change proc)))
($.definition /.result
"Executes the reader against the given environment."
- [(result env proc)])
+ ($.example (result env proc)))
($.definition /.with
"Monad transformer for Reader."
- [(with monad)])
+ ($.example (with monad)))
($.definition /.lifted
"Lift monadic values to the Reader wrapper.")
diff --git a/stdlib/source/documentation/lux/control/region.lux b/stdlib/source/documentation/lux/control/region.lux
index bd80295d6..5c624b3c5 100644
--- a/stdlib/source/documentation/lux/control/region.lux
+++ b/stdlib/source/documentation/lux/control/region.lux
@@ -24,21 +24,21 @@
($.definition /.run!
"Executes a region-based computation, with a side-effect determined by the monad."
- [(run! monad computation)])
+ ($.example (run! monad computation)))
($.definition /.acquire!
"Acquire a resource while pairing it a function that knows how to reclaim it."
- [(acquire! monad cleaner value)])
+ ($.example (acquire! monad cleaner value)))
($.definition /.failure
"Immediately fail with this 'message'."
- [(failure monad error)])
+ ($.example (failure monad error)))
($.definition /.except
"Fail by throwing/raising an exception."
- [(except monad exception message)])
+ ($.example (except monad exception message)))
($.definition /.lifted
"Lift an effectful computation into a region-based computation."
- [(lifted monad operation)])
+ ($.example (lifted monad operation)))
))
diff --git a/stdlib/source/documentation/lux/control/security/capability.lux b/stdlib/source/documentation/lux/control/security/capability.lux
index cbd415861..3f89141dd 100644
--- a/stdlib/source/documentation/lux/control/security/capability.lux
+++ b/stdlib/source/documentation/lux/control/security/capability.lux
@@ -19,20 +19,19 @@
($.definition /.use
"Applies a capability against its required input."
- [(use capability input)])
+ ($.example (use capability input)))
($.definition /.capability
"Defines a capability as a unique type, and a constructor for instances."
- [(capability (Can_Duplicate a)
- (can_duplicate a [a a]))
-
- (let [capability (can_duplicate
- (function (_ value)
- [value value]))
- [left right] (..use capability 123)]
- (same? left right))])
+ ($.example (capability (Can_Duplicate a)
+ (can_duplicate a [a a])))
+ ($.example (let [capability (can_duplicate
+ (function (_ value)
+ [value value]))
+ [left right] (..use capability 123)]
+ (same? left right))))
($.definition /.async
"Converts a synchronous I/O-based capability into an asynchronous capability."
- [(async capability)])
+ ($.example (async capability)))
))
diff --git a/stdlib/source/documentation/lux/control/security/policy.lux b/stdlib/source/documentation/lux/control/security/policy.lux
index a05987aee..69ab2c821 100644
--- a/stdlib/source/documentation/lux/control/security/policy.lux
+++ b/stdlib/source/documentation/lux/control/security/policy.lux
@@ -40,34 +40,32 @@
($.definition /.delegation
"Delegating policy capacities."
- [(delegation downgrade upgrade)])
+ ($.example (delegation downgrade upgrade)))
($.definition (/.Context brand scope %)
"A computational context with an associated policy privilege.")
($.definition /.with_policy
"Activates a security context with the priviledge to enforce it's policy."
- [(type Password
- (Private Text))
-
- (type (Policy %)
- (Interface
- (is (-> Text (Password %))
- password)
- (is (-> (Password %) Text)
- unsafe)))
-
- (def (policy _)
- (Ex (_ %) (-> Any (Policy %)))
- (with_policy
- (is (Context Privacy Policy)
- (function (_ (open "%::."))
- (implementation
- (def (password value)
- (%::can_upgrade value))
- (def (unsafe password)
- (%::can_downgrade password)))))))]
- [(with_policy context)])
+ ($.example (type Password
+ (Private Text)))
+ ($.example (type (Policy %)
+ (Interface
+ (is (-> Text (Password %))
+ password)
+ (is (-> (Password %) Text)
+ unsafe))))
+ ($.example (def (policy _)
+ (Ex (_ %) (-> Any (Policy %)))
+ (with_policy
+ (is (Context Privacy Policy)
+ (function (_ (open "%::."))
+ (implementation
+ (def (password value)
+ (%::can_upgrade value))
+ (def (unsafe password)
+ (%::can_downgrade password))))))))
+ ($.example (with_policy context)))
($.definition /.Privacy
(format "A security context for privacy."
diff --git a/stdlib/source/documentation/lux/control/state.lux b/stdlib/source/documentation/lux/control/state.lux
index 5784561df..70bc019fd 100644
--- a/stdlib/source/documentation/lux/control/state.lux
+++ b/stdlib/source/documentation/lux/control/state.lux
@@ -25,44 +25,44 @@
($.definition /.put
"Set the new state."
- [(put new_state)])
+ ($.example (put new_state)))
($.definition /.update
"Compute the new state."
- [(update change)])
+ ($.example (update change)))
($.definition /.use
"Run a function on the current state."
- [(use user)])
+ ($.example (use user)))
($.definition /.local
"Run the computation with a locally-modified state."
- [(local change action)])
+ ($.example (local change action)))
($.definition /.result
"Run a stateful computation."
- [(result state action)])
+ ($.example (result state action)))
($.definition /.while
"A stateful while loop."
- [(while condition body)])
+ ($.example (while condition body)))
($.definition /.do_while
"A stateful do-while loop."
- [(do_while condition body)])
+ ($.example (do_while condition body)))
($.definition /.+State
"Stateful computations decorated by a monad.")
($.definition /.result'
"Execute a stateful computation decorated by a monad."
- [(result' state action)])
+ ($.example (result' state action)))
($.definition /.with
"A monad transformer to create composite stateful computations."
- [(with monad)])
+ ($.example (with monad)))
($.definition /.lifted
"Lift monadic values to the +State wrapper."
- [(lifted monad ma)])
+ ($.example (lifted monad ma)))
))
diff --git a/stdlib/source/documentation/lux/control/thread.lux b/stdlib/source/documentation/lux/control/thread.lux
index 46f716a46..ba02996f6 100644
--- a/stdlib/source/documentation/lux/control/thread.lux
+++ b/stdlib/source/documentation/lux/control/thread.lux
@@ -25,24 +25,24 @@
($.definition /.box
"A brand-new box initialized to the given value."
- [(box init)])
+ ($.example (box init)))
($.definition /.read!
"Reads the current value in the box."
- [(read! box)])
+ ($.example (read! box)))
($.definition /.write!
"Mutates the value in the box."
- [(write! value box)])
+ ($.example (write! value box)))
($.definition /.result
"Executes the imperative thread in a self-contained way."
- [(result thread)])
+ ($.example (result thread)))
($.definition /.io
"Transforms the imperative thread into an I/O computation.")
($.definition /.update!
"Update a box's value by applying a function to it."
- [(update! f box)])
+ ($.example (update! f box)))
))
diff --git a/stdlib/source/documentation/lux/control/try.lux b/stdlib/source/documentation/lux/control/try.lux
index 0019ec86c..73af005ee 100644
--- a/stdlib/source/documentation/lux/control/try.lux
+++ b/stdlib/source/documentation/lux/control/try.lux
@@ -23,32 +23,32 @@
($.definition /.with
"Enhances a monad with error-handling functionality."
- [(with monad)])
+ ($.example (with monad)))
($.definition /.lifted
"Wraps a monadic value with error-handling machinery."
- [(lifted monad)])
+ ($.example (lifted monad)))
($.definition /.trusted
(format "Assumes a Try value succeeded, and yields its value."
\n "If it didn't, raises the error as a runtime error."
\n "WARNING: Use with caution.")
- [(trusted try)])
+ ($.example (trusted try)))
($.definition /.maybe
""
- [(maybe try)])
+ ($.example (maybe try)))
($.definition /.of_maybe
""
- [(of_maybe maybe)])
+ ($.example (of_maybe maybe)))
($.definition /.else
(format "Allows you to provide a default value that will be used"
\n "if a (Try x) value turns out to be #Failure."
\n "Note: the expression for the default value will not be computed if the base computation succeeds.")
- [(= "bar"
- (else "foo" {/.#Success "bar"}))]
- [(= "foo"
- (else "foo" {/.#Failure "KABOOM!"}))])
+ ($.example (= "bar"
+ (else "foo" {/.#Success "bar"})))
+ ($.example (= "foo"
+ (else "foo" {/.#Failure "KABOOM!"}))))
))
diff --git a/stdlib/source/documentation/lux/control/writer.lux b/stdlib/source/documentation/lux/control/writer.lux
index 36417304f..d69b068d1 100644
--- a/stdlib/source/documentation/lux/control/writer.lux
+++ b/stdlib/source/documentation/lux/control/writer.lux
@@ -22,13 +22,13 @@
($.definition /.write
"Write a value to the log."
- [(write message)])
+ ($.example (write message)))
($.definition /.with
"Enhances a monad with Writer functionality."
- [(with monoid monad)])
+ ($.example (with monoid monad)))
($.definition /.lifted
"Wraps a monadic value with Writer machinery."
- [(lifted monoid monad)])
+ ($.example (lifted monoid monad)))
))
diff --git a/stdlib/source/documentation/lux/data/binary.lux b/stdlib/source/documentation/lux/data/binary.lux
index b5bb6660a..14d84dc55 100644
--- a/stdlib/source/documentation/lux/data/binary.lux
+++ b/stdlib/source/documentation/lux/data/binary.lux
@@ -40,7 +40,7 @@
($.definition \\parser.segment
"Parses a chunk of data of a given size."
- [(segment size)])
+ ($.example (segment size)))
(,, (with_template [<size> <name>]
[($.definition <name>
@@ -74,11 +74,11 @@
($.definition \\parser.list
"Parses an arbitrarily long list of values."
- [(list value)])
+ ($.example (list value)))
($.definition \\parser.set
""
- [(set hash value)]))]
+ ($.example (set hash value))))]
(list.partial ($.module \\parser._
"")
@@ -92,7 +92,7 @@
($.definition \\parser.result
"Runs a parser and checks that all the binary data was read by it."
- [(result parser input)])
+ ($.example (result parser input)))
($.definition \\parser.end?
"Checks whether there is no more data to read.")
@@ -150,7 +150,7 @@
($.definition \\format.segment
"Writes at most 'size' bytes of an input binary blob."
- [(segment size)]))]
+ ($.example (segment size))))]
(list.partial ($.module \\format._
"")
@@ -173,19 +173,19 @@
($.definition \\format.result
"Yields a binary blob with all the information written to it."
- [(result format value)])
+ ($.example (result format value)))
($.definition \\format.or
""
- [(or left right)])
+ ($.example (or left right)))
($.definition \\format.and
""
- [(and pre post)])
+ ($.example (and pre post)))
($.definition \\format.rec
"A combinator for recursive formats."
- [(rec body)])
+ ($.example (rec body)))
specific
)))
@@ -206,55 +206,55 @@
($.definition /.empty
"A fresh/empty binary BLOB of the specified size."
- [(empty size)])
+ ($.example (empty size)))
($.definition /.mix
""
- [(mix f init binary)])
+ ($.example (mix f init binary)))
($.definition /.bits_8
"Read 1 byte (8 bits) at the given index."
- [(bits_8 index binary)])
+ ($.example (bits_8 index binary)))
($.definition /.bits_16
"Read 2 bytes (16 bits) at the given index."
- [(bits_16 index binary)])
+ ($.example (bits_16 index binary)))
($.definition /.bits_32
"Read 4 bytes (32 bits) at the given index."
- [(bits_32 index binary)])
+ ($.example (bits_32 index binary)))
($.definition /.bits_64
"Read 8 bytes (64 bits) at the given index."
- [(bits_64 index binary)])
+ ($.example (bits_64 index binary)))
($.definition /.has_8!
"Write 1 byte (8 bits) at the given index."
- [(has_8! index value binary)])
+ ($.example (has_8! index value binary)))
($.definition /.has_16!
"Write 2 bytes (16 bits) at the given index."
- [(has_16! index value binary)])
+ ($.example (has_16! index value binary)))
($.definition /.has_32!
"Write 4 bytes (32 bits) at the given index."
- [(has_32! index value binary)])
+ ($.example (has_32! index value binary)))
($.definition /.has_64!
"Write 8 bytes (64 bits) at the given index."
- [(has_64! index value binary)])
+ ($.example (has_64! index value binary)))
($.definition /.copy!
"Mutates the target binary BLOB by copying bytes from the source BLOB to it."
- [(copy! bytes source_offset source target_offset target)])
+ ($.example (copy! bytes source_offset source target_offset target)))
($.definition /.slice
"Yields a subset of the binary BLOB, so long as the specified range is valid."
- [(slice offset length binary)])
+ ($.example (slice offset length binary)))
($.definition /.after
"Yields a binary BLOB with at most the specified number of bytes removed."
- [(after bytes binary)])
+ ($.example (after bytes binary)))
(all list#composite
..\\format
diff --git a/stdlib/source/documentation/lux/data/collection/array.lux b/stdlib/source/documentation/lux/data/collection/array.lux
index e821b976c..0f2c5094f 100644
--- a/stdlib/source/documentation/lux/data/collection/array.lux
+++ b/stdlib/source/documentation/lux/data/collection/array.lux
@@ -28,72 +28,72 @@
($.definition /.empty
"An empty array of the specified size."
- [(empty size)])
+ ($.example (empty size)))
($.definition /.size
""
- [(size array)])
+ ($.example (size array)))
($.definition /.item
""
- [(item index array)])
+ ($.example (item index array)))
($.definition /.has!
"Mutate the array by writing a value to the specified index."
- [(has! index value array)])
+ ($.example (has! index value array)))
($.definition /.lacks!
"Mutate the array by deleting the value at the specified index."
- [(lacks! index array)])
+ ($.example (lacks! index array)))
($.definition /.has?
""
- [(has? index array)])
+ ($.example (has? index array)))
($.definition /.revised!
"Mutate the array by updating the value at the specified index."
- [(revised! index transform array)])
+ ($.example (revised! index transform array)))
($.definition /.upsert!
(format "Mutate the array by updating the value at the specified index."
\n "If there is no value, update and write the default value given.")
- [(upsert! index default transform array)])
+ ($.example (upsert! index default transform array)))
($.definition /.copy!
"Writes the contents of one array into the other."
- [(copy! length src_start src_array dest_start dest_array)])
+ ($.example (copy! length src_start src_array dest_start dest_array)))
($.definition /.occupancy
"Finds out how many cells in an array are occupied."
- [(occupancy array)])
+ ($.example (occupancy array)))
($.definition /.vacancy
"Finds out how many cells in an array are vacant."
- [(vacancy array)])
+ ($.example (vacancy array)))
($.definition /.only!
"Delete every item of the array that fails to satisfy the predicate."
- [(only! p xs)])
+ ($.example (only! p xs)))
($.definition /.example
"Yields the first item in the array that satisfies the predicate."
- [(example p xs)])
+ ($.example (example p xs)))
($.definition /.example'
"Just like 'example', but with access to the index of each value."
- [(example' p xs)])
+ ($.example (example' p xs)))
($.definition /.clone
"Yields a shallow clone of the array."
- [(clone xs)])
+ ($.example (clone xs)))
($.definition /.of_list
""
- [(of_list xs)])
+ ($.example (of_list xs)))
($.definition /.list
(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)])
+ ($.example (list {.#None} array))
+ ($.example (list {.#Some default} array)))
))
diff --git a/stdlib/source/documentation/lux/data/collection/bits.lux b/stdlib/source/documentation/lux/data/collection/bits.lux
index 296d9f087..98e02080f 100644
--- a/stdlib/source/documentation/lux/data/collection/bits.lux
+++ b/stdlib/source/documentation/lux/data/collection/bits.lux
@@ -27,21 +27,21 @@
($.definition /.size
"Measures the size of a bit-map by counting all the 1s in the bit-map."
- [(size bits)])
+ ($.example (size bits)))
($.definition /.capacity
""
- [(capacity bits)])
+ ($.example (capacity bits)))
($.definition /.bit
""
- [(bit index bits)])
+ ($.example (bit index bits)))
($.definition /.intersects?
""
- [(intersects? reference sample)])
+ ($.example (intersects? reference sample)))
($.definition /.not
""
- [(not input)])
+ ($.example (not input)))
))
diff --git a/stdlib/source/documentation/lux/data/collection/dictionary.lux b/stdlib/source/documentation/lux/data/collection/dictionary.lux
index da8bd13e8..eaabd8c26 100644
--- a/stdlib/source/documentation/lux/data/collection/dictionary.lux
+++ b/stdlib/source/documentation/lux/data/collection/dictionary.lux
@@ -32,58 +32,58 @@
($.definition /.empty
"An empty dictionary."
- [(empty key_hash)])
+ ($.example (empty key_hash)))
($.definition /.has
""
- [(has key val dict)])
+ ($.example (has key val dict)))
($.definition /.lacks
""
- [(lacks key dict)])
+ ($.example (lacks key dict)))
($.definition /.value
""
- [(value key dict)])
+ ($.example (value key dict)))
($.definition /.key?
""
- [(key? dict key)])
+ ($.example (key? dict key)))
($.definition /.has'
"Only puts the KV-pair if the key is not already present."
- [(has' key val dict)])
+ ($.example (has' key val dict)))
($.definition /.revised
"Transforms the value located at key (if available), using the given function."
- [(revised key f dict)])
+ ($.example (revised key f dict)))
($.definition /.revised'
(format "Updates the value at the key; if it exists."
\n "Otherwise, puts a value by applying the function to a default.")
- [(revised' key default f dict)])
+ ($.example (revised' key default f dict)))
($.definition /.of_list
""
- [(of_list key_hash kvs)])
+ ($.example (of_list key_hash kvs)))
($.definition /.composite
(format "Merges 2 dictionaries."
\n "If any collisions with keys occur, the values of dict2 will overwrite those of dict1.")
- [(composite dict2 dict1)])
+ ($.example (composite dict2 dict1)))
($.definition /.composite_with
(format "Merges 2 dictionaries."
\n "If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1.")
- [(composite_with f dict2 dict1)])
+ ($.example (composite_with f dict2 dict1)))
($.definition /.re_bound
"If there is a value under 'from_key', remove 'from_key' and store the value under 'to_key'."
- [(re_bound from_key to_key dict)])
+ ($.example (re_bound from_key to_key dict)))
($.definition /.sub
"A sub-dictionary, with only the specified keys."
- [(sub keys dict)])
+ ($.example (sub keys dict)))
/ordered.documentation
))
diff --git a/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux b/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux
index d44fe0863..a9da85140 100644
--- a/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux
+++ b/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux
@@ -27,15 +27,15 @@
($.definition /.empty
"An empty dictionary, employing the given order."
- [(empty order)])
+ ($.example (empty order)))
($.definition /.value
""
- [(value key dict)])
+ ($.example (value key dict)))
($.definition /.key?
""
- [(key? dict key)])
+ ($.example (key? dict key)))
(,, (with_template [<name>]
[(`` ($.definition <name>
@@ -47,21 +47,21 @@
($.definition /.size
""
- [(size dict)])
+ ($.example (size dict)))
($.definition /.has
""
- [(has key value dict)])
+ ($.example (has key value dict)))
($.definition /.lacks
""
- [(lacks key dict)])
+ ($.example (lacks key dict)))
($.definition /.revised
""
- [(revised key transform dict)])
+ ($.example (revised key transform dict)))
($.definition /.of_list
""
- [(of_list order list)])
+ ($.example (of_list order list)))
)))
diff --git a/stdlib/source/documentation/lux/data/collection/list.lux b/stdlib/source/documentation/lux/data/collection/list.lux
index 9726f5d39..8d75d3a63 100644
--- a/stdlib/source/documentation/lux/data/collection/list.lux
+++ b/stdlib/source/documentation/lux/data/collection/list.lux
@@ -14,17 +14,17 @@
(List $.Documentation)
(let [zipped (list ($.definition /.zipped
"Create list zippers with the specified number of input lists."
- [(def zipped_2 (zipped 2))
- (def zipped_3 (zipped 3))
- (zipped_3 xs ys zs)
- ((zipped 3) xs ys zs)])
+ ($.example (def zipped_2 (zipped 2)))
+ ($.example (def zipped_3 (zipped 3)))
+ ($.example (zipped_3 xs ys zs))
+ ($.example ((zipped 3) xs ys zs)))
($.definition /.zipped_with
"Create list zippers with the specified number of input lists."
- [(def zipped_with_2 (zipped_with 2))
- (def zipped_with_3 (zipped_with 3))
- (zipped_with_2 + xs ys)
- ((zipped_with 2) + xs ys)])
+ ($.example (def zipped_with_2 (zipped_with 2)))
+ ($.example (def zipped_with_3 (zipped_with 3)))
+ ($.example (zipped_with_2 + xs ys))
+ ($.example ((zipped_with 2) + xs ys)))
($.definition /.zipped_2)
($.definition /.zipped_3)
@@ -50,79 +50,79 @@
($.definition /.mixes
""
- [(mixes f init inputs)])
+ ($.example (mixes f init inputs)))
($.definition /.reversed
""
- [(reversed xs)])
+ ($.example (reversed xs)))
($.definition /.only
"A list with only values that satisfy the predicate."
- [(only keep? xs)])
+ ($.example (only keep? xs)))
($.definition /.partition
"Divide the list into all elements that satisfy a predicate, and all elements that do not."
- [(partition satisfies? list)])
+ ($.example (partition satisfies? list)))
($.definition /.pairs
"Cut the list into pairs of 2."
- [(pairs list)])
+ ($.example (pairs list)))
($.definition /.split_at
""
- [(split_at n xs)])
+ ($.example (split_at n xs)))
($.definition /.split_when
"Segment the list by using a predicate to tell when to cut."
- [(split_when predicate xs)])
+ ($.example (split_when predicate xs)))
($.definition /.sub
"Segment the list into sub-lists of (at most) the given size."
- [(sub size list)])
+ ($.example (sub size list)))
($.definition /.repeated
"A list of the value x, repeated n times."
- [(repeated n x)])
+ ($.example (repeated n x)))
($.definition /.iterations
"Generates a list element by element until the function returns .#None."
- [(iterations f x)])
+ ($.example (iterations f x)))
($.definition /.one
""
- [(one check xs)])
+ ($.example (one check xs)))
($.definition /.all
""
- [(all check xs)])
+ ($.example (all check xs)))
($.definition /.example
"Yields the first value in the list that satisfies the predicate."
- [(example predicate xs)])
+ ($.example (example predicate xs)))
($.definition /.interposed
"Puts a value between every two elements in the list."
- [(interposed sep xs)])
+ ($.example (interposed sep xs)))
($.definition /.size
""
- [(size list)])
+ ($.example (size list)))
($.definition /.item
"Fetches the element at the specified index."
- [(item i xs)])
+ ($.example (item i xs)))
($.definition /.sorted
"A list ordered by a comparison function."
- [(sorted < xs)])
+ ($.example (sorted < xs)))
($.definition /.empty?
""
- [(empty? xs)])
+ ($.example (empty? xs)))
($.definition /.member?
""
- [(member? eq xs x)])
+ ($.example (member? eq xs x)))
(,, (with_template [<name> <doc>]
[($.definition <name>
@@ -134,38 +134,38 @@
($.definition /.indices
"Produces all the valid indices for a given size."
- [(indices size)])
+ ($.example (indices size)))
($.definition /.last
""
- [(last xs)])
+ ($.example (last xs)))
($.definition /.inits
(format "For a list of size N, yields the first N-1 elements."
\n "Will yield a .#None for empty lists.")
- [(inits xs)])
+ ($.example (inits xs)))
($.definition /.together
"The sequential combination of all the lists.")
($.definition /.with
"Enhances a monad with List functionality."
- [(with monad)])
+ ($.example (with monad)))
($.definition /.lifted
"Wraps a monadic value with List machinery."
- [(lifted monad)])
+ ($.example (lifted monad)))
($.definition /.enumeration
"Pairs every element in the list with its index, starting at 0."
- [(enumeration xs)])
+ ($.example (enumeration xs)))
($.definition /.when
"Can be used as a guard in (co)monadic be/do expressions."
- [(do monad
- [value (do_something 1 2 3)
- .when (passes_test? value)]
- (do_something_else 4 5 6))])
+ ($.example (do monad
+ [value (do_something 1 2 3)
+ .when (passes_test? value)]
+ (do_something_else 4 5 6))))
(all /#composite
zipped
diff --git a/stdlib/source/documentation/lux/data/collection/list/property.lux b/stdlib/source/documentation/lux/data/collection/list/property.lux
index c2d694d62..faa7a79a1 100644
--- a/stdlib/source/documentation/lux/data/collection/list/property.lux
+++ b/stdlib/source/documentation/lux/data/collection/list/property.lux
@@ -26,21 +26,21 @@
($.definition /.value
""
- [(value key properties)])
+ ($.example (value key properties)))
($.definition /.contains?
""
- [(contains? key properties)])
+ ($.example (contains? key properties)))
($.definition /.has
""
- [(has key val properties)])
+ ($.example (has key val properties)))
($.definition /.revised
""
- [(revised key f properties)])
+ ($.example (revised key f properties)))
($.definition /.lacks
""
- [(lacks key properties)])
+ ($.example (lacks key properties)))
))
diff --git a/stdlib/source/documentation/lux/data/collection/queue.lux b/stdlib/source/documentation/lux/data/collection/queue.lux
index 44dd7f209..87d5bf4db 100644
--- a/stdlib/source/documentation/lux/data/collection/queue.lux
+++ b/stdlib/source/documentation/lux/data/collection/queue.lux
@@ -26,26 +26,26 @@
($.definition /.of_list
""
- [(of_list entries)])
+ ($.example (of_list entries)))
($.definition /.list
""
- [(list queue)])
+ ($.example (list queue)))
($.definition /.front
"Yields the first value in the queue, if any.")
($.definition /.member?
""
- [(member? equivalence queue member)])
+ ($.example (member? equivalence queue member)))
($.definition /.next
""
- [(next queue)])
+ ($.example (next queue)))
($.definition /.end
""
- [(end val queue)])
+ ($.example (end val queue)))
/priority.documentation
))
diff --git a/stdlib/source/documentation/lux/data/collection/queue/priority.lux b/stdlib/source/documentation/lux/data/collection/queue/priority.lux
index e08056fe3..8a61d7122 100644
--- a/stdlib/source/documentation/lux/data/collection/queue/priority.lux
+++ b/stdlib/source/documentation/lux/data/collection/queue/priority.lux
@@ -22,9 +22,9 @@
($.definition /.member?
""
- [(member? equivalence queue member)])
+ ($.example (member? equivalence queue member)))
($.definition /.end
""
- [(end priority value queue)])
+ ($.example (end priority value queue)))
))
diff --git a/stdlib/source/documentation/lux/data/collection/sequence.lux b/stdlib/source/documentation/lux/data/collection/sequence.lux
index 5dbbe420f..0d6e71629 100644
--- a/stdlib/source/documentation/lux/data/collection/sequence.lux
+++ b/stdlib/source/documentation/lux/data/collection/sequence.lux
@@ -30,38 +30,38 @@
($.definition /.suffix
""
- [(suffix val sequence)])
+ ($.example (suffix val sequence)))
($.definition /.within_bounds?
"Determines whether the index is within the bounds of the sequence."
- [(within_bounds? sequence idx)])
+ ($.example (within_bounds? sequence idx)))
($.definition /.item
""
- [(item idx sequence)])
+ ($.example (item idx sequence)))
($.definition /.has
""
- [(has idx val sequence)])
+ ($.example (has idx val sequence)))
($.definition /.revised
""
- [(revised idx f sequence)])
+ ($.example (revised idx f sequence)))
($.definition /.prefix
""
- [(prefix sequence)])
+ ($.example (prefix sequence)))
($.definition /.list
""
- [(list sequence)])
+ ($.example (list sequence)))
($.definition /.member?
""
- [(member? equivalence sequence val)])
+ ($.example (member? equivalence sequence val)))
($.definition /.sequence
"Sequence literals."
- [(is (Sequence Nat)
- (sequence 12 34 56 78 90))])
+ ($.example (is (Sequence Nat)
+ (sequence 12 34 56 78 90))))
))
diff --git a/stdlib/source/documentation/lux/data/collection/set.lux b/stdlib/source/documentation/lux/data/collection/set.lux
index 94ad8e8d9..f9033964f 100644
--- a/stdlib/source/documentation/lux/data/collection/set.lux
+++ b/stdlib/source/documentation/lux/data/collection/set.lux
@@ -35,23 +35,23 @@
($.definition /.has
""
- [(has elem set)])
+ ($.example (has elem set)))
($.definition /.difference
""
- [(difference sub base)])
+ ($.example (difference sub base)))
($.definition /.intersection
""
- [(intersection filter base)])
+ ($.example (intersection filter base)))
($.definition /.sub?
""
- [(sub? super sub)])
+ ($.example (sub? super sub)))
($.definition /.super?
""
- [(super? sub super)])
+ ($.example (super? sub super)))
(all list#composite
/multi.documentation
diff --git a/stdlib/source/documentation/lux/data/collection/set/multi.lux b/stdlib/source/documentation/lux/data/collection/set/multi.lux
index 8c84efe56..1f9cd1e98 100644
--- a/stdlib/source/documentation/lux/data/collection/set/multi.lux
+++ b/stdlib/source/documentation/lux/data/collection/set/multi.lux
@@ -31,27 +31,27 @@
($.definition /.has
""
- [(has multiplicity elem set)])
+ ($.example (has multiplicity elem set)))
($.definition /.lacks
""
- [(lacks multiplicity elem set)])
+ ($.example (lacks multiplicity elem set)))
($.definition /.multiplicity
""
- [(multiplicity set elem)])
+ ($.example (multiplicity set elem)))
($.definition /.sub?
"Is 'subject' a sub-set of 'reference'?"
- [(sub? reference subject)])
+ ($.example (sub? reference subject)))
($.definition /.support
"A set of the unique (non repeated) members."
- [(support set)])
+ ($.example (support set)))
($.definition /.member?
""
- [(member? set elem)])
+ ($.example (member? set elem)))
($.definition /.super?
"Is 'subject' a super-set of 'reference'?")
diff --git a/stdlib/source/documentation/lux/data/collection/set/ordered.lux b/stdlib/source/documentation/lux/data/collection/set/ordered.lux
index 82f29e9d9..d3abe10a4 100644
--- a/stdlib/source/documentation/lux/data/collection/set/ordered.lux
+++ b/stdlib/source/documentation/lux/data/collection/set/ordered.lux
@@ -29,25 +29,25 @@
($.definition /.member?
""
- [(member? set elem)])
+ ($.example (member? set elem)))
($.definition /.has
""
- [(has elem set)])
+ ($.example (has elem set)))
($.definition /.lacks
""
- [(lacks elem set)])
+ ($.example (lacks elem set)))
($.definition /.difference
""
- [(difference param subject)])
+ ($.example (difference param subject)))
($.definition /.sub?
"Is 'sub' a sub-set of 'super'?"
- [(sub? super sub)])
+ ($.example (sub? super sub)))
($.definition /.super?
"Is 'super' a super-set of 'sub'?"
- [(super? sub super)])
+ ($.example (super? sub super)))
))
diff --git a/stdlib/source/documentation/lux/data/collection/stack.lux b/stdlib/source/documentation/lux/data/collection/stack.lux
index e882391c7..9364c54c0 100644
--- a/stdlib/source/documentation/lux/data/collection/stack.lux
+++ b/stdlib/source/documentation/lux/data/collection/stack.lux
@@ -24,13 +24,13 @@
($.definition /.value
"Yields the top value in the stack, if any."
- [(value stack)])
+ ($.example (value stack)))
($.definition /.next
""
- [(next stack)])
+ ($.example (next stack)))
($.definition /.top
""
- [(top value stack)])
+ ($.example (top value stack)))
))
diff --git a/stdlib/source/documentation/lux/data/collection/stream.lux b/stdlib/source/documentation/lux/data/collection/stream.lux
index d32960d0d..cef25618b 100644
--- a/stdlib/source/documentation/lux/data/collection/stream.lux
+++ b/stdlib/source/documentation/lux/data/collection/stream.lux
@@ -29,33 +29,33 @@
($.definition /.iterations
"A stateful way of infinitely calculating the values of a stream."
- [(iterations step init)])
+ ($.example (iterations step init)))
($.definition /.repeated
"Repeat a value forever."
- [(repeated x)])
+ ($.example (repeated x)))
($.definition /.cycle
"Go over the elements of a list forever."
- [(cycle [start next])])
+ ($.example (cycle [start next])))
($.definition /.item
""
- [(item idx stream)])
+ ($.example (item idx stream)))
($.definition /.only
"A new stream only with items that satisfy the predicate."
- [(only predicate stream)])
+ ($.example (only predicate stream)))
($.definition /.partition
(format "Split a stream in two based on a predicate."
\n "The left side contains all entries for which the predicate is #1."
\n "The right side contains all entries for which the predicate is #0.")
- [(partition left? xs)])
+ ($.example (partition left? xs)))
($.definition /.pattern
(format "Allows destructuring of streams in pattern-matching expressions."
\n "Caveat emptor: Only use it for destructuring, and not for testing values within the streams.")
- [(let [(pattern x y z _tail) (some_stream_func +1 +2 +3)]
- (func x y z))])
+ ($.example (let [(pattern x y z _tail) (some_stream_func +1 +2 +3)]
+ (func x y z))))
))
diff --git a/stdlib/source/documentation/lux/data/collection/tree.lux b/stdlib/source/documentation/lux/data/collection/tree.lux
index ef03b419c..35108c6c5 100644
--- a/stdlib/source/documentation/lux/data/collection/tree.lux
+++ b/stdlib/source/documentation/lux/data/collection/tree.lux
@@ -26,11 +26,11 @@
($.definition \\parser.result'
"Applies the parser against a tree zipper."
- [(result' parser zipper)])
+ ($.example (result' parser zipper)))
($.definition \\parser.result
"Applies the parser against a tree."
- [(result parser tree)])
+ ($.example (result parser tree)))
($.definition \\parser.value
"Yields the value inside the current tree node.")
@@ -70,23 +70,23 @@
($.definition /.flat
"All the leaf values of the tree, in order."
- [(flat tree)])
+ ($.example (flat tree)))
($.definition /.leaf
""
- [(leaf value)])
+ ($.example (leaf value)))
($.definition /.branch
""
- [(branch value children)])
+ ($.example (branch value children)))
($.definition /.tree
"Tree literals."
- [(is (Tree Nat)
- (tree 12
- {34 {}
- 56 {}
- 78 {90 {}}}))])
+ ($.example (is (Tree Nat)
+ (tree 12
+ {34 {}
+ 56 {}
+ 78 {90 {}}}))))
(all list#composite
..\\parser
diff --git a/stdlib/source/documentation/lux/data/collection/tree/finger.lux b/stdlib/source/documentation/lux/data/collection/tree/finger.lux
index dacba465b..08ca4d639 100644
--- a/stdlib/source/documentation/lux/data/collection/tree/finger.lux
+++ b/stdlib/source/documentation/lux/data/collection/tree/finger.lux
@@ -24,25 +24,25 @@
($.definition /.builder
"A new builder using the given monoid."
- [(builder monoid)])
+ ($.example (builder monoid)))
($.definition /.value
""
- [(value tree)])
+ ($.example (value tree)))
($.definition /.tags
""
- [(tags tree)])
+ ($.example (tags tree)))
($.definition /.values
""
- [(values tree)])
+ ($.example (values tree)))
($.definition /.one
"Finds one value that meets the predicate."
- [(one predicate tree)])
+ ($.example (one predicate tree)))
($.definition /.exists?
"Verifies that a value exists which meets the predicate."
- [(exists? predicate tree)])
+ ($.example (exists? predicate tree)))
))
diff --git a/stdlib/source/documentation/lux/data/collection/tree/zipper.lux b/stdlib/source/documentation/lux/data/collection/tree/zipper.lux
index 052f816fb..c4a3d730c 100644
--- a/stdlib/source/documentation/lux/data/collection/tree/zipper.lux
+++ b/stdlib/source/documentation/lux/data/collection/tree/zipper.lux
@@ -42,17 +42,17 @@
($.definition /.set
""
- [(set value zipper)])
+ ($.example (set value zipper)))
($.definition /.update
""
- [(update transform zipper)])
+ ($.example (update transform zipper)))
($.definition /.interpose
""
- [(interpose value zipper)])
+ ($.example (interpose value zipper)))
($.definition /.adopt
""
- [(adopt value zipper)])
+ ($.example (adopt value zipper)))
))
diff --git a/stdlib/source/documentation/lux/data/color.lux b/stdlib/source/documentation/lux/data/color.lux
index a1ffc67fb..77162cec2 100644
--- a/stdlib/source/documentation/lux/data/color.lux
+++ b/stdlib/source/documentation/lux/data/color.lux
@@ -55,11 +55,11 @@
($.definition /.complement
"The opposite color."
- [(complement color)])
+ ($.example (complement color)))
($.definition /.interpolated
""
- [(interpolated ratio end start)]))
+ ($.example (interpolated ratio end start))))
alpha (list ($.definition /.Alpha
"The degree of transparency of a pigment.")
@@ -76,11 +76,11 @@
($.definition /.analogous
(palette_documentation /.analogous)
- [(analogous spread variations color)])
+ ($.example (analogous spread variations color)))
($.definition /.monochromatic
(palette_documentation /.monochromatic)
- [(monochromatic spread variations color)])
+ ($.example (monochromatic spread variations color)))
(,, (with_template [<name>]
[(`` ($.definition <name>
diff --git a/stdlib/source/documentation/lux/data/format/json.lux b/stdlib/source/documentation/lux/data/format/json.lux
index 48a62f2e0..b65139927 100644
--- a/stdlib/source/documentation/lux/data/format/json.lux
+++ b/stdlib/source/documentation/lux/data/format/json.lux
@@ -30,7 +30,7 @@
($.definition \\parser.result
(format "Executes the parser against a JSON object."
\n "Verifies that all of the JSON was consumed by the parser.")
- [(result parser json)])
+ ($.example (result parser json)))
($.definition \\parser.any
"Just returns the JSON input without applying any logic.")
@@ -58,21 +58,21 @@
($.definition \\parser.nullable
"Enhances parser by adding NULL-handling."
- [(nullable parser)])
+ ($.example (nullable parser)))
($.definition \\parser.array
"Parses the contents of a JSON array."
- [(array parser)])
+ ($.example (array parser)))
($.definition \\parser.object
(format "Parses the contents of a JSON object."
\n "Use this with the 'field' combinator.")
- [(object parser)])
+ ($.example (object parser)))
($.definition \\parser.field
(format "Parses a field inside a JSON object."
\n "Use this inside the 'object' combinator.")
- [(field field_name parser)])
+ ($.example (field field_name parser)))
($.definition \\parser.dictionary
"Parses a dictionary-like JSON object.")
@@ -99,30 +99,35 @@
($.definition /.json
"A simple way to produce JSON literals."
- ["null"
- (json #null)]
- ["true"
- (json #1)]
- ["123.456"
- (json +123.456)]
- ["'this is a string'"
- (json "this is a string")]
- ["['this' 'is' 'an' 'array']"
- (json ["this" "is" "an" "array"])]
- ["{'this' 'is', 'an' 'object'}"
- (json {"this" "is" "an" "object"})])
+ ($.comment "null")
+ ($.example (json #null))
+
+ ($.comment "true")
+ ($.example (json #1))
+
+ ($.comment "123.456")
+ ($.example (json +123.456))
+
+ ($.comment "'this is a string'")
+ ($.example (json "this is a string"))
+
+ ($.comment "['this' 'is' 'an' 'array']")
+ ($.example (json ["this" "is" "an" "array"]))
+
+ ($.comment "{'this' 'is', 'an' 'object'}")
+ ($.example (json {"this" "is" "an" "object"})))
($.definition /.fields
"Get all the fields in a JSON object."
- [(fields json)])
+ ($.example (fields json)))
($.definition /.field
"A JSON object field getter."
- [(field key json)])
+ ($.example (field key json)))
($.definition /.has
"A JSON object field setter."
- [(has key value json)])
+ ($.example (has key value json)))
(,, (with_template [<name> <desc>]
[($.definition <name>
diff --git a/stdlib/source/documentation/lux/data/format/xml.lux b/stdlib/source/documentation/lux/data/format/xml.lux
index 22c80ea1f..2803820b5 100644
--- a/stdlib/source/documentation/lux/data/format/xml.lux
+++ b/stdlib/source/documentation/lux/data/format/xml.lux
@@ -29,7 +29,7 @@
($.definition \\parser.result
(format "Applies a parser against a stream of XML documents."
\n "Verifies that all of the inputs are consumed by the parser.")
- [(result parser documents)])
+ ($.example (result parser documents)))
($.definition \\parser.text
"Yields text from a text node.")
@@ -39,18 +39,18 @@
($.definition \\parser.attribute
"Yields the value of an attribute in the current node."
- [(attribute name)])
+ ($.example (attribute name)))
($.definition \\parser.node
"Parses the contents of the next node if the tag matches."
- [(node expected parser)])
+ ($.example (node expected parser)))
($.definition \\parser.any
"Yields the next node.")
($.definition \\parser.somewhere
"Applies the parser somewhere among the remaining inputs; instead of demanding that the parser succeeds against the immediate inputs."
- [(somewhere parser)])
+ ($.example (somewhere parser)))
))
(def .public documentation
@@ -70,7 +70,7 @@
($.definition /.tag
"The text format of a XML tag."
- [(tag name)])
+ ($.example (tag name)))
($.definition /.attribute
"The text format of a XML attribute.")
diff --git a/stdlib/source/documentation/lux/data/product.lux b/stdlib/source/documentation/lux/data/product.lux
index a589fdd9c..cde31272a 100644
--- a/stdlib/source/documentation/lux/data/product.lux
+++ b/stdlib/source/documentation/lux/data/product.lux
@@ -24,21 +24,21 @@
($.definition /.curried
"Converts a 2-argument function into nested single-argument functions."
- [(curried f)])
+ ($.example (curried f)))
($.definition /.uncurried
"Converts nested single-argument functions into a 2-argument function."
- [(uncurried f)])
+ ($.example (uncurried f)))
($.definition /.swapped
""
- [(swapped [left right])])
+ ($.example (swapped [left right])))
($.definition /.then
"Apply functions to both sides of a pair."
- [(then f g)])
+ ($.example (then f g)))
($.definition /.forked
"Yields a pair by applying both functions to a single value."
- [(forked f g)])
+ ($.example (forked f g)))
))
diff --git a/stdlib/source/documentation/lux/data/sum.lux b/stdlib/source/documentation/lux/data/sum.lux
index 973522394..be67f1bf4 100644
--- a/stdlib/source/documentation/lux/data/sum.lux
+++ b/stdlib/source/documentation/lux/data/sum.lux
@@ -27,9 +27,9 @@
($.definition /.either
"Applies a function to either side of a 2-variant."
- [(either on_left on_right)])
+ ($.example (either on_left on_right)))
($.definition /.then
"Applies functions to both sides of a 2-variant."
- [(then on_left on_right)])
+ ($.example (then on_left on_right)))
))
diff --git a/stdlib/source/documentation/lux/data/text.lux b/stdlib/source/documentation/lux/data/text.lux
index c544cc551..13ecdeaff 100644
--- a/stdlib/source/documentation/lux/data/text.lux
+++ b/stdlib/source/documentation/lux/data/text.lux
@@ -73,7 +73,7 @@
($.definition \\format.format
"Text interpolation."
- [(format "Static part " (text static) " does not match URI: " uri)])
+ ($.example (format "Static part " (text static) " does not match URI: " uri)))
(all list#composite
specific
@@ -93,7 +93,7 @@
($.definition \\parser.character_does_not_satisfy_predicate))
specific (list ($.definition \\parser.range
"Only yields characters within a range."
- [(range bottom top)])
+ ($.example (range bottom top)))
(,, (with_template [<name> <desc>]
[($.definition <name>
@@ -131,7 +131,7 @@
($.definition \\parser.result
(format "Executes a parser against a block of text."
\n "Verifies that the entire input has been processed.")
- [(result parser input)])
+ ($.example (result parser input)))
($.definition \\parser.offset
"Yields the current offset into the input.")
@@ -152,7 +152,7 @@
($.definition \\parser.this
"Checks that a specific text shows up in the input."
- [(this reference)])
+ ($.example (this reference)))
($.definition \\parser.end
"Ensure the parser's input is empty.")
@@ -181,15 +181,15 @@
($.definition \\parser.satisfies
"Yields characters that satisfy a predicate."
- [(satisfies parser)])
+ ($.example (satisfies parser)))
($.definition \\parser.and
"Yields the outputs of both parsers composed together."
- [(and left right)])
+ ($.example (and left right)))
($.definition \\parser.and!
"Yields the outputs of both parsers composed together (as a slice)."
- [(and! left right)])
+ ($.example (and! left right)))
(,, (with_template [<text> <slice>]
[(`` ($.definition <text>
@@ -214,27 +214,27 @@
($.definition \\parser.between
""
- [(between minimum additional parser)])
+ ($.example (between minimum additional parser)))
($.definition \\parser.between!
""
- [(between! minimum additional parser)])
+ ($.example (between! minimum additional parser)))
($.definition \\parser.enclosed
""
- [(enclosed [start end] parser)])
+ ($.example (enclosed [start end] parser)))
($.definition \\parser.local
"Applies a parser against the given input."
- [(local local_input parser)])
+ ($.example (local local_input parser)))
($.definition \\parser.slice
"Converts a slice to a block of text."
- [(slice parser)])
+ ($.example (slice parser)))
($.definition \\parser.then
"Embeds a text parser into an arbitrary parser that yields text."
- [(then structured text)])
+ ($.example (then structured text)))
(all list#composite
exception
@@ -244,14 +244,14 @@
(def .public documentation
(List $.Documentation)
- (let [character (list ($.definition /.Char
- "A character code number.")
+ (let [character (list ... ($.definition /.Char
+ ... "A character code number.")
- ($.definition /.char
- "Yields the character at the specified index."
- [(char index input)])
+ ... ($.definition /.char
+ ... "Yields the character at the specified index."
+ ... ($.example (char index input)))
- ($.definition /.of_char)
+ ... ($.definition /.of_char)
($.definition /.\0)
($.definition /.null)
@@ -280,23 +280,23 @@
($.definition /.starts_with?
""
- [(starts_with? prefix x)])
+ ($.example (starts_with? prefix x)))
($.definition /.ends_with?
""
- [(ends_with? postfix x)])
+ ($.example (ends_with? postfix x)))
($.definition /.enclosed_by?
""
- [(enclosed_by? boundary value)])
+ ($.example (enclosed_by? boundary value)))
($.definition /.contains?
""
- [(contains? sub text)])
+ ($.example (contains? sub text)))
($.definition /.space?
"Checks whether the character is white-space."
- [(space? char)]))]
+ ($.example (space? char))))]
(list.partial ($.module /._
"")
@@ -313,63 +313,63 @@
($.definition /.index_since
""
- [(index_since from pattern input)])
+ ($.example (index_since from pattern input)))
($.definition /.index
""
- [(index pattern input)])
+ ($.example (index pattern input)))
($.definition /.last_index
""
- [(last_index part text)])
+ ($.example (last_index part text)))
($.definition /.prefix
""
- [(prefix param subject)])
+ ($.example (prefix param subject)))
($.definition /.suffix
""
- [(suffix param subject)])
+ ($.example (suffix param subject)))
($.definition /.enclosed
"Surrounds the given content text with left and right side additions."
- [(enclosed [left right] content)])
+ ($.example (enclosed [left right] content)))
($.definition /.enclosed'
"Surrounds the given content text with the same boundary text."
- [(enclosed' boundary content)])
+ ($.example (enclosed' boundary content)))
($.definition /.clip
"Clips a chunk of text from the input at the specified offset and of the specified size."
- [(clip offset size input)])
+ ($.example (clip offset size input)))
($.definition /.clip_since
"Clips the remaining text from the input at the specified offset."
- [(clip_since offset input)])
+ ($.example (clip_since offset input)))
($.definition /.split_at
""
- [(split_at at x)])
+ ($.example (split_at at x)))
($.definition /.split_by
""
- [(split_by token sample)])
+ ($.example (split_by token sample)))
($.definition /.all_split_by
""
- [(all_split_by token sample)])
+ ($.example (all_split_by token sample)))
($.definition /.replaced_once
""
- [(replaced_once pattern replacement template)])
+ ($.example (replaced_once pattern replacement template)))
($.definition /.replaced
""
- [(replaced pattern replacement template)])
+ ($.example (replaced pattern replacement template)))
($.definition /.interposed
""
- [(interposed separator texts)])
+ ($.example (interposed separator texts)))
(all list#composite
character
diff --git a/stdlib/source/documentation/lux/data/text/escape.lux b/stdlib/source/documentation/lux/data/text/escape.lux
index 5b85c8359..cd3ded777 100644
--- a/stdlib/source/documentation/lux/data/text/escape.lux
+++ b/stdlib/source/documentation/lux/data/text/escape.lux
@@ -20,17 +20,17 @@
($.definition /.escaped
"Yields a escaped version of the text."
- [(escaped text)])
+ ($.example (escaped text)))
($.definition /.un_escaped
(format "Yields an un-escaped text."
\n "Fails if it was improperly escaped.")
- [(un_escaped text)])
+ ($.example (un_escaped text)))
($.definition /.literal
"If given a escaped text literal, expands to an un-escaped version."
- [(/.literal "Line 1\nLine 2")
- "=>"
- (format "Line 1" \n
- "Line 2")])
+ ($.example (/.literal "Line 1\nLine 2"))
+ ($.comment "=>")
+ ($.example (format "Line 1" \n
+ "Line 2")))
))
diff --git a/stdlib/source/documentation/lux/data/text/regex.lux b/stdlib/source/documentation/lux/data/text/regex.lux
index 8de3d70e7..cd785ab77 100644
--- a/stdlib/source/documentation/lux/data/text/regex.lux
+++ b/stdlib/source/documentation/lux/data/text/regex.lux
@@ -17,60 +17,72 @@
($.definition /.regex
"Create lexers using regular-expression syntax."
- ["Literals"
- (regex "a")]
- ["Wildcards"
- (regex ".")]
- ["Escaping"
- (regex "\.")]
- ["Character classes"
- (regex "\d")
- (regex "\p{Lower}")
- (regex "[abc]")
- (regex "[a-z]")
- (regex "[a-zA-Z]")
- (regex "[a-z&&[def]]")]
- ["Negation"
- (regex "[^abc]")
- (regex "[^a-z]")
- (regex "[^a-zA-Z]")
- (regex "[a-z&&[^bc]]")
- (regex "[a-z&&[^m-p]]")]
- ["Combinations"
- (regex "aa")
- (regex "a?")
- (regex "a*")
- (regex "a+")]
- ["Specific amounts"
- (regex "a{2}")]
- ["At least"
- (regex "a{1,}")]
- ["At most"
- (regex "a{,1}")]
- ["Between"
- (regex "a{1,2}")]
- ["Groups"
- (regex "a(.)c")
- (regex "a(b+)c")
- (regex "(\d{3})-(\d{3})-(\d{4})")
- (regex "(\d{3})-(?:\d{3})-(\d{4})")
- (regex "(?<code>\d{3})-\k<code>-(\d{4})")
- (regex "(?<code>\d{3})-\k<code>-(\d{4})-\0")
- (regex "(\d{3})-((\d{3})-(\d{4}))")]
- ["Alternation"
- (regex "a|b")
- (regex "a(.)(.)|b(.)(.)")])
+
+ ($.comment "Literals")
+ ($.example (regex "a"))
+
+ ($.comment "Wildcards")
+ ($.example (regex "."))
+
+ ($.comment "Escaping")
+ ($.example (regex "\."))
+
+ ($.comment "Character classes")
+ ($.example (regex "\d"))
+ ($.example (regex "\p{Lower}"))
+ ($.example (regex "[abc]"))
+ ($.example (regex "[a-z]"))
+ ($.example (regex "[a-zA-Z]"))
+ ($.example (regex "[a-z&&[def]]"))
+
+ ($.comment "Negation")
+ ($.example (regex "[^abc]"))
+ ($.example (regex "[^a-z]"))
+ ($.example (regex "[^a-zA-Z]"))
+ ($.example (regex "[a-z&&[^bc]]"))
+ ($.example (regex "[a-z&&[^m-p]]"))
+
+ ($.comment "Combinations")
+ ($.example (regex "aa"))
+ ($.example (regex "a?"))
+ ($.example (regex "a*"))
+ ($.example (regex "a+"))
+
+ ($.comment "Specific amounts")
+ ($.example (regex "a{2}"))
+
+ ($.comment "At least")
+ ($.example (regex "a{1,}"))
+
+ ($.comment "At most")
+ ($.example (regex "a{,1}"))
+
+ ($.comment "Between")
+ ($.example (regex "a{1,2}"))
+
+ ($.comment "Groups")
+ ($.example (regex "a(.)c"))
+ ($.example (regex "a(b+)c"))
+ ($.example (regex "(\d{3})-(\d{3})-(\d{4})"))
+ ($.example (regex "(\d{3})-(?:\d{3})-(\d{4})"))
+ ($.example (regex "(?<code>\d{3})-\k<code>-(\d{4})"))
+ ($.example (regex "(?<code>\d{3})-\k<code>-(\d{4})-\0"))
+ ($.example (regex "(\d{3})-((\d{3})-(\d{4}))"))
+
+ ($.comment "Alternation")
+ ($.example (regex "a|b"))
+ ($.example (regex "a(.)(.)|b(.)(.)")))
($.definition /.pattern
"Allows you to test text against regular expressions."
- [(when some_text
- (pattern "(\d{3})-(\d{3})-(\d{4})"
- [_ country_code area_code place_code])
- do_some_thing_when_number
+ ($.example (when some_text
+ (pattern "(\d{3})-(\d{3})-(\d{4})"
+ [_ country_code area_code place_code])
+ do_some_thing_when_number
- (pattern "\w+")
- do_some_thing_when_word
+ (pattern "\w+")
+ do_some_thing_when_word
- _
- do_something_else)])
+ _
+ do_something_else)))
))
diff --git a/stdlib/source/documentation/lux/data/text/unicode/block.lux b/stdlib/source/documentation/lux/data/text/unicode/block.lux
index 78002e97c..667c66fef 100644
--- a/stdlib/source/documentation/lux/data/text/unicode/block.lux
+++ b/stdlib/source/documentation/lux/data/text/unicode/block.lux
@@ -179,11 +179,11 @@
($.definition /.block
""
- [(block start additional)])
+ ($.example (block start additional)))
($.definition /.within?
""
- [(within? block char)])
+ ($.example (within? block char)))
(all list#composite
all_1/4
diff --git a/stdlib/source/documentation/lux/data/text/unicode/set.lux b/stdlib/source/documentation/lux/data/text/unicode/set.lux
index 68fbb3446..6d75868c5 100644
--- a/stdlib/source/documentation/lux/data/text/unicode/set.lux
+++ b/stdlib/source/documentation/lux/data/text/unicode/set.lux
@@ -31,9 +31,9 @@
($.definition /.set
""
- [(set [head tail])])
+ ($.example (set [head tail])))
($.definition /.member?
""
- [(member? set character)])
+ ($.example (member? set character)))
))
diff --git a/stdlib/source/documentation/lux/debug.lux b/stdlib/source/documentation/lux/debug.lux
index b32c68fc7..8c71814cb 100644
--- a/stdlib/source/documentation/lux/debug.lux
+++ b/stdlib/source/documentation/lux/debug.lux
@@ -19,55 +19,59 @@
($.definition /.inspection
"A best-effort attempt to generate a textual representation of a value, without knowing its type."
- [(inspection value)])
+ ($.example (inspection value)))
($.definition /.representation
"A best-effort attempt to generate a textual representation of a value, while knowing its type."
- [(representation type value)])
+ ($.example (representation type value)))
($.definition /.private
"Allows access to un-exported definitions in other modules."
- ["Module A"
- (def .private (secret_definition input)
- (-> ??? ???)
- (foo (bar (baz input))))
- "Module B"
- ((/.private secret_definition) my_input)])
+
+ ($.comment "Module A")
+ ($.example (def .private (secret_definition input)
+ (-> ??? ???)
+ (foo (bar (baz input)))))
+
+ ($.comment "Module B")
+ ($.example ((/.private secret_definition) my_input)))
($.definition /.log!
"Prints/writes a message to standard output."
- [(log! message)])
+ ($.example (log! message)))
($.definition /.hole
(format "A typed 'hole'."
\n "Reveals the type expected of the expression that should go in the hole.")
- [(is (-> Nat Text)
- (function (_ number)
- (hole)))
- "=>"
- .Text])
+ ($.example (is (-> Nat Text)
+ (function (_ number)
+ (hole))))
+ ($.comment "=>")
+ ($.example .Text))
($.definition /.here
"Shows the names and values of local bindings available around the call to 'here'."
- [(let [foo 123
- bar +456
- baz +789.0]
- (is Any
- (here)))
- "=>"
- "foo: +123"
- "bar: +456"
- "baz: +789.0"
- []]
- ["Can optionally be given a list of definitions to focus on."
- "These definitions to focus on can include custom format to represent the values."
- (let [foo 123
- bar +456
- baz +789.0]
- (is Any
- (here [foo %.nat] baz)))
- "=>"
- "foo: 123"
- "baz: +789.0"
- []])
+
+ ($.example (let [foo 123
+ bar +456
+ baz +789.0]
+ (is Any
+ (here))))
+ ($.comment "=>")
+ ($.comment "foo: +123")
+ ($.comment "bar: +456")
+ ($.comment "baz: +789.0")
+ ($.example [])
+
+ ($.comment "Can optionally be given a list of definitions to focus on.")
+ ($.comment "These definitions to focus on can include custom format to represent the values.")
+ ($.example (let [foo 123
+ bar +456
+ baz +789.0]
+ (is Any
+ (here [foo %.nat] baz))))
+ ($.comment "=>")
+ ($.comment "foo: 123")
+ ($.comment "baz: +789.0")
+ ($.example []))
))
diff --git a/stdlib/source/documentation/lux/documentation.lux b/stdlib/source/documentation/lux/documentation.lux
index 2a65b298e..bf9a2e436 100644
--- a/stdlib/source/documentation/lux/documentation.lux
+++ b/stdlib/source/documentation/lux/documentation.lux
@@ -3,17 +3,21 @@
[lux (.except)
[data
["[0]" text (.only \n)
- ["%" \\format (.only format)]]]]]
+ ["%" \\format (.only format)]]
+ [collection
+ ["[0]" list]]]]]
[\\library
- ["[0]" /]])
+ ["[0]" /]]
+ ["[0]" /
+ ["[1][0]" remember]])
(with_expansions [<documentation> (/.definition /.definition)
<documentation> (/.definition /.definition
""
- [<documentation>])
+ (/.example <documentation>))
<documentation> (/.definition /.definition
""
- [<documentation>])
+ (/.example <documentation>))
<all> (these (/.definition /.unqualified_symbol)
(/.definition /.Definition)
(/.definition /.Module)
@@ -22,16 +26,18 @@
<documentation>)]
(def .public documentation
(List /.Documentation)
- (list (/.module /._
- "")
+ (list.together
+ (list (list (/.module /._
+ "")
- <all>
-
- (/.definition /.module
- ""
- [(is (.List /.Module)
- (module /._
- ""
- [<all>]
- []))])
- )))
+ <all>
+
+ (/.definition /.module
+ ""
+ (/.example (is (.List /.Module)
+ (module /._
+ ""
+ [<all>]
+ []))))
+ )
+ /remember.documentation))))
diff --git a/stdlib/source/documentation/lux/control/remember.lux b/stdlib/source/documentation/lux/documentation/remember.lux
index f25d2e038..d5db9331c 100644
--- a/stdlib/source/documentation/lux/control/remember.lux
+++ b/stdlib/source/documentation/lux/documentation/remember.lux
@@ -18,27 +18,27 @@
($.definition /.remember
(format "A message with an expiration date."
\n "Can have an optional piece of code to focus on.")
- [(remember "2022-04-01"
- "Do this, that and the other.")]
- [(remember "2022-04-01"
- "Improve the performace."
- (some (complicated (computation 123))))])
+ ($.example (remember "2022-04-01"
+ "Do this, that and the other."))
+ ($.example (remember "2022-04-01"
+ "Improve the performace."
+ (some (complicated (computation 123))))))
($.definition /.to_do
(format "A TODO message with an expiration date."
\n "Can have an optional piece of code to focus on.")
- [(to_do "2022-04-01"
- "Do this, that and the other.")]
- [(to_do "2022-04-01"
- "Improve the performace."
- (some (complicated (computation 123))))])
+ ($.example (to_do "2022-04-01"
+ "Do this, that and the other."))
+ ($.example (to_do "2022-04-01"
+ "Improve the performace."
+ (some (complicated (computation 123))))))
($.definition /.fix_me
(format "A FIXME message with an expiration date."
\n "Can have an optional piece of code to focus on.")
- [(fix_me "2022-04-01"
- "Do this, that and the other.")]
- [(fix_me "2022-04-01"
- "Improve the performace."
- (some (complicated (computation 123))))])
+ ($.example (fix_me "2022-04-01"
+ "Do this, that and the other."))
+ ($.example (fix_me "2022-04-01"
+ "Improve the performace."
+ (some (complicated (computation 123))))))
))
diff --git a/stdlib/source/documentation/lux/ffi.js.lux b/stdlib/source/documentation/lux/ffi.js.lux
index 980ad9a6e..b3860d6a1 100644
--- a/stdlib/source/documentation/lux/ffi.js.lux
+++ b/stdlib/source/documentation/lux/ffi.js.lux
@@ -31,38 +31,36 @@
($.definition /.import
"Easily import types, methods, functions and constants."
- [(import Uint8Array
- "[1]::[0]")
-
- (import TextEncoder
- "[1]::[0]"
- (new [/.String])
- (encode [/.String] Uint8Array))
-
- (import TextDecoder
- "[1]::[0]"
- (new [/.String])
- (decode [/.String] String))])
+ ($.example (import Uint8Array
+ "[1]::[0]"))
+ ($.example (import TextEncoder
+ "[1]::[0]"
+ (new [/.String])
+ (encode [/.String] Uint8Array)))
+ ($.example (import TextDecoder
+ "[1]::[0]"
+ (new [/.String])
+ (decode [/.String] String))))
($.definition /.type_of
"The type of an object, as text."
- [(= "boolean"
- (type_of true))]
- [(= "number"
- (type_of +123.456))]
- [(= "string"
- (type_of "789"))]
- [(= "function"
- (type_of (function (_ value) value)))])
+ ($.example (= "boolean"
+ (type_of true)))
+ ($.example (= "number"
+ (type_of +123.456)))
+ ($.example (= "string"
+ (type_of "789")))
+ ($.example (= "function"
+ (type_of (function (_ value) value)))))
($.definition /.global
"Allows using definitions from the JavaScript host platform."
- [(global .Frac [Math PI])])
+ ($.example (global .Frac [Math PI])))
($.definition /.function
(format "Allows defining closures/anonymous-functions in the form that JavaScript expects."
\n "This is useful for adapting Lux functions for usage by JavaScript code.")
- [(is /.Function
- (function [left right]
- (do_something (as Foo left) (as Bar right))))])
+ ($.example (is /.Function
+ (function [left right]
+ (do_something (as Foo left) (as Bar right))))))
))
diff --git a/stdlib/source/documentation/lux/ffi.jvm.lux b/stdlib/source/documentation/lux/ffi.jvm.lux
index ca1841a0b..d05e9e72d 100644
--- a/stdlib/source/documentation/lux/ffi.jvm.lux
+++ b/stdlib/source/documentation/lux/ffi.jvm.lux
@@ -95,176 +95,180 @@
($.definition /.class
"Allows defining JVM classes in Lux code."
- [(class "final" (TestClass A) [Runnable]
- ... Fields
- ("private" foo boolean)
- ("private" bar A)
- ("private" baz java/lang/Object)
- ... Methods
- ("public" [] (new [value A]) []
- (exec
- (:= ::foo true)
- (:= ::bar value)
- (:= ::baz "")
- []))
- ("public" (virtual) java/lang/Object
- "")
- ("public" "static" (static) java/lang/Object
- "")
- (Runnable [] (run) void
- [])
- )
-
- "The tuple corresponds to parent interfaces."
- "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed."
- "Fields and methods defined in the class can be used with special syntax."
- "For example:"
- "::resolved, for accessing the 'resolved' field."
- "(:= ::resolved true) for modifying it."
- "(::new! []) for calling the class's constructor."
- "(::resolve! container [value]) for calling the 'resolve' method."])
+ ($.example (class "final" (TestClass A) [Runnable]
+ ... Fields
+ ("private" foo boolean)
+ ("private" bar A)
+ ("private" baz java/lang/Object)
+ ... Methods
+ ("public" [] (new [value A]) []
+ (exec
+ (:= ::foo true)
+ (:= ::bar value)
+ (:= ::baz "")
+ []))
+ ("public" (virtual) java/lang/Object
+ "")
+ ("public" "static" (static) java/lang/Object
+ "")
+ (Runnable [] (run) void
+ [])
+ ))
+ ($.comment "The tuple corresponds to parent interfaces.")
+ ($.comment "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed.")
+ ($.comment "Fields and methods defined in the class can be used with special syntax.")
+ ($.comment "For example:")
+ ($.comment "::resolved, for accessing the 'resolved' field.")
+ ($.comment "(:= ::resolved true) for modifying it.")
+ ($.comment "(::new! []) for calling the class's constructor.")
+ ($.comment "(::resolve! container [value]) for calling the 'resolve' method."))
($.definition /.interface
"Allows defining JVM interfaces."
- [(interface TestInterface
- ([] foo [boolean String] void "throws" [Exception]))])
+ ($.example (interface TestInterface
+ ([] foo [boolean String] void "throws" [Exception]))))
($.definition /.object
"Allows defining anonymous classes."
- ["The 1st tuple corresponds to class-level type-variables."
- "The 2nd tuple corresponds to parent interfaces."
- "The 3rd tuple corresponds to arguments to the super class constructor."
- "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed."
- (object [] [Runnable]
- []
- (Runnable [] (run self) void
- (exec
- (do_something some_value)
- [])))])
+ ($.comment "The 1st tuple corresponds to class-level type-variables.")
+ ($.comment "The 2nd tuple corresponds to parent interfaces.")
+ ($.comment "The 3rd tuple corresponds to arguments to the super class constructor.")
+ ($.comment "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed.")
+ ($.example (object [] [Runnable]
+ []
+ (Runnable [] (run self) void
+ (exec
+ (do_something some_value)
+ [])))))
($.definition /.null
"The null pointer."
- [(null)])
+ ($.example (null)))
($.definition /.null?
"Test for the null pointer."
- [(= true
- (null? (null)))]
- [(= false
- (null? "YOLO"))])
+ ($.example (= true
+ (null? (null))))
+ ($.example (= false
+ (null? "YOLO"))))
($.definition /.???
"Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
- [(= (??? (is java/lang/String (null)))
- {.#None})]
- [(= (??? "YOLO")
- {.#Some "YOLO"})])
+ ($.example (= (??? (is java/lang/String (null)))
+ {.#None}))
+ ($.example (= (??? "YOLO")
+ {.#Some "YOLO"})))
($.definition /.!!!
(format "Takes a (Maybe ObjectType) and returns a ObjectType."
\n "A .#None would get translated into a (null).")
- [(= (null)
- (!!! (??? (is java/lang/Thread (null)))))]
- [(= "foo"
- (!!! (??? "foo")))])
+ ($.example (= (null)
+ (!!! (??? (is java/lang/Thread (null))))))
+ ($.example (= "foo"
+ (!!! (??? "foo")))))
($.definition /.as
(format "Checks whether an object is an instance of a particular class."
\n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.")
- [(when (as String "YOLO")
- {.#Some value_as_string}
- {.#None})])
+ ($.example (when (as String "YOLO")
+ {.#Some value_as_string}
+ {.#None})))
($.definition /.synchronized
"Evaluates body, while holding a lock on a given object."
- [(synchronized object_to_be_locked
- (exec
- (do something)
- (dosomething else)
- (finish the computation)))])
+ ($.example (synchronized object_to_be_locked
+ (exec
+ (do something)
+ (dosomething else)
+ (finish the computation)))))
($.definition /.to
"Call a variety of methods on an object. Then, return the object."
- [(to object
- (ClassName::method1 arg0 arg1 arg2)
- (ClassName::method2 arg3 arg4 arg5))])
+ ($.example (to object
+ (ClassName::method1 arg0 arg1 arg2)
+ (ClassName::method2 arg3 arg4 arg5))))
($.definition /.import
"Allows importing JVM classes, and using them as types."
- ["Their methods, fields and enum options can also be imported."
- (import java/lang/Object
- "[1]::[0]"
- (new [])
- (equals [java/lang/Object] boolean)
- (wait [int] "io" "try" void))]
- ["Special options can also be given for the return values."
- "'?' means that the values will be returned inside a Maybe type. That way, null becomes .#None."
- "'try' means that the computation might throw an exception, and the return value will be wrapped by the Try type."
- "'io' means the computation has side effects, and will be wrapped by the IO type."
- "These options must show up in the following order ['io' 'try' '?'] (although, each option can be used independently)."
- (import java/lang/String
- "[1]::[0]"
- (new [[byte]])
- ("static" valueOf [char] java/lang/String)
- ("static" valueOf "as" int_valueOf [int] java/lang/String))
-
- (import (java/util/List e)
- "[1]::[0]"
- (size [] int)
- (get [int] e))
-
- (import (java/util/ArrayList a)
- "[1]::[0]"
- ([T] toArray [[T]] [T]))]
- ["The class-type that is generated is of the fully-qualified name."
- "This avoids a clash between the java.util.List type, and Lux's own List type."
- "All enum options to be imported must be specified."
- (import java/lang/Character$UnicodeScript
- "[1]::[0]"
- ("enum" ARABIC CYRILLIC LATIN))]
- ["It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars."
- "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
- (import (lux/concurrency/async/JvmAsync A)
- "[1]::[0]"
- (resolve [A] boolean)
- (poll [] A)
- (wasResolved [] boolean)
- (waitOn [lux/Function] void)
- ("static" [A] make [A] (lux/concurrency/async/JvmAsync A)))]
- ["Also, the names of the imported members will look like Class::member"
- (java/lang/Object::new [])
- (java/lang/Object::equals [other_object] my_object)
- (java/util/List::size [] my_list)
- java/lang/Character$UnicodeScript::LATIN])
+
+ ($.comment "Their methods, fields and enum options can also be imported.")
+ ($.example (import java/lang/Object
+ "[1]::[0]"
+ (new [])
+ (equals [java/lang/Object] boolean)
+ (wait [int] "io" "try" void)))
+
+ ($.comment "Special options can also be given for the return values.")
+ ($.comment "'?' means that the values will be returned inside a Maybe type. That way, null becomes .#None.")
+ ($.comment "'try' means that the computation might throw an exception, and the return value will be wrapped by the Try type.")
+ ($.comment "'io' means the computation has side effects, and will be wrapped by the IO type.")
+ ($.comment "These options must show up in the following order ['io' 'try' '?'] (although, each option can be used independently).")
+ ($.example (import java/lang/String
+ "[1]::[0]"
+ (new [[byte]])
+ ("static" valueOf [char] java/lang/String)
+ ("static" valueOf "as" int_valueOf [int] java/lang/String)))
+
+ ($.example (import (java/util/List e)
+ "[1]::[0]"
+ (size [] int)
+ (get [int] e)))
+
+ ($.example (import (java/util/ArrayList a)
+ "[1]::[0]"
+ ([T] toArray [[T]] [T])))
+
+ ($.comment "The class-type that is generated is of the fully-qualified name.")
+ ($.comment "This avoids a clash between the java.util.List type, and Lux's own List type.")
+ ($.comment "All enum options to be imported must be specified.")
+ ($.example (import java/lang/Character$UnicodeScript
+ "[1]::[0]"
+ ("enum" ARABIC CYRILLIC LATIN)))
+
+ ($.comment "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars.")
+ ($.comment "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes).")
+ ($.example (import (lux/concurrency/async/JvmAsync A)
+ "[1]::[0]"
+ (resolve [A] boolean)
+ (poll [] A)
+ (wasResolved [] boolean)
+ (waitOn [lux/Function] void)
+ ("static" [A] make [A] (lux/concurrency/async/JvmAsync A))))
+
+ ($.comment "Also, the names of the imported members will look like Class::member")
+ ($.example (java/lang/Object::new []))
+ ($.example (java/lang/Object::equals [other_object] my_object))
+ ($.example (java/util/List::size [] my_list))
+ ($.example java/lang/Character$UnicodeScript::LATIN))
($.definition /.array
"Create an array of the given type, with the given size."
- [(array java/lang/Object 10)])
+ ($.example (array java/lang/Object 10)))
($.definition /.length
"Gives the length of an array."
- [(length my_array)])
+ ($.example (length my_array)))
($.definition /.read!
"Loads an element from an array."
- [(read! 10 my_array)])
+ ($.example (read! 10 my_array)))
($.definition /.write!
"Stores an element into an array."
- [(write! 10 my_object my_array)])
+ ($.example (write! 10 my_object my_array)))
($.definition /.class_for
"Loads the class as a java.lang.Class object."
- [(class_for java/lang/String)])
+ ($.example (class_for java/lang/String)))
($.definition /.type
""
- [(is Type
- (type java/lang/String))])
+ ($.example (is Type
+ (type java/lang/String))))
($.definition /.is
""
- [(is java/lang/Object
- (is java/lang/String
- ???))])
+ ($.example (is java/lang/Object
+ (is java/lang/String
+ ???))))
)))
diff --git a/stdlib/source/documentation/lux/ffi.lua.lux b/stdlib/source/documentation/lux/ffi.lua.lux
index b4713841f..9f11805e8 100644
--- a/stdlib/source/documentation/lux/ffi.lua.lux
+++ b/stdlib/source/documentation/lux/ffi.lua.lux
@@ -24,12 +24,12 @@
($.definition /.import
"Easily import types, methods, functions and constants."
- [(import (os/getenv [..String] "io" "?" ..String))])
+ ($.example (import (os/getenv [..String] "io" "?" ..String))))
($.definition /.function
(format "Allows defining closures/anonymous-functions in the form that Lua expects."
\n "This is useful for adapting Lux functions for usage by Lua code.")
- [(is ..Function
- (function [left right]
- (do_something (as Foo left) (as Bar right))))])
+ ($.example (is ..Function
+ (function [left right]
+ (do_something (as Foo left) (as Bar right))))))
))
diff --git a/stdlib/source/documentation/lux/ffi.old.lux b/stdlib/source/documentation/lux/ffi.old.lux
deleted file mode 100644
index 2400b4f37..000000000
--- a/stdlib/source/documentation/lux/ffi.old.lux
+++ /dev/null
@@ -1,221 +0,0 @@
-(.require
- [library
- [lux (.except)
- ["$" documentation]
- [data
- ["[0]" text (.only \n)
- ["%" \\format (.only format)]]]]]
- [\\library
- ["[0]" /]])
-
-(`` (def .public documentation
- (List $.Documentation)
- (list ($.module /._
- "")
-
- ($.definition /.Privacy)
- ($.definition /.State)
- ($.definition /.Inheritance)
-
- (,, (with_template [<name> <from> <to>]
- [($.definition <name>
- "Type converter.")]
-
- [/.byte_to_long "java.lang.Byte" "java.lang.Long"]
-
- [/.short_to_long "java.lang.Short" "java.lang.Long"]
-
- [/.double_to_int "java.lang.Double" "java.lang.Integer"]
- [/.double_to_long "java.lang.Double" "java.lang.Long"]
- [/.double_to_float "java.lang.Double" "java.lang.Float"]
-
- [/.float_to_int "java.lang.Float" "java.lang.Integer"]
- [/.float_to_long "java.lang.Float" "java.lang.Long"]
- [/.float_to_double "java.lang.Float" "java.lang.Double"]
-
- [/.int_to_byte "java.lang.Integer" "java.lang.Byte"]
- [/.int_to_short "java.lang.Integer" "java.lang.Short"]
- [/.int_to_long "java.lang.Integer" "java.lang.Long"]
- [/.int_to_float "java.lang.Integer" "java.lang.Float"]
- [/.int_to_double "java.lang.Integer" "java.lang.Double"]
- [/.int_to_char "java.lang.Integer" "java.lang.Character"]
-
- [/.long_to_byte "java.lang.Long" "java.lang.Byte"]
- [/.long_to_short "java.lang.Long" "java.lang.Short"]
- [/.long_to_int "java.lang.Long" "java.lang.Integer"]
- [/.long_to_float "java.lang.Long" "java.lang.Float"]
- [/.long_to_double "java.lang.Long" "java.lang.Double"]
-
- [/.char_to_byte "java.lang.Character" "java.lang.Byte"]
- [/.char_to_short "java.lang.Character" "java.lang.Short"]
- [/.char_to_int "java.lang.Character" "java.lang.Integer"]
- [/.char_to_long "java.lang.Character" "java.lang.Long"]
- ))
-
- ($.definition /.class
- "Allows defining JVM classes in Lux code."
- [(class "final" (TestClass A) [Runnable]
- ... Fields
- ("private" foo boolean)
- ("private" bar A)
- ("private" baz java/lang/Object)
- ... Methods
- ("public" [] (new [value A]) []
- (exec
- (:= ::foo true)
- (:= ::bar value)
- (:= ::baz "")
- []))
- ("public" (virtual) java/lang/Object
- "")
- ("public" "static" (static) java/lang/Object
- "")
- (Runnable [] (run) void
- []))
- "The tuple corresponds to parent interfaces."
- "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed."
- "Fields and methods defined in the class can be used with special syntax."
- "For example:"
- "::resolved, for accessing the 'resolved' field."
- "(:= ::resolved true) for modifying it."
- "(::new! []) for calling the class's constructor."
- "(::resolve! container [value]) for calling the 'resolve' method."])
-
- ($.definition /.interface
- "Allows defining JVM interfaces."
- [(interface TestInterface
- ([] foo [boolean String] void "throws" [Exception]))])
-
- ($.definition /.object
- "Allows defining anonymous classes."
- ["The 1st tuple corresponds to class-level type-variables."
- "The 2nd tuple corresponds to parent interfaces."
- "The 3rd tuple corresponds to arguments to the super class constructor."
- "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed."
- (object [] [Runnable]
- []
- (Runnable [] (run self) void
- (exec (do_something some_value)
- [])))])
-
- ($.definition /.null
- "Null object reference."
- (null))
-
- ($.definition /.null?
- "Test for null object reference."
- [(= (null? (null))
- true)]
- [(= (null? "YOLO")
- false)])
-
- ($.definition /.???
- "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
- [(= (??? (is java/lang/String (null)))
- {.#None})]
- [(= (??? "YOLO")
- {.#Some "YOLO"})])
-
- ($.definition /.!!!
- "Takes a (Maybe ObjectType) and returns a ObjectType."
- [(= "foo"
- (!!! (??? "foo")))]
- ["A .#None would get translated into a (null)."
- (= (null)
- (!!! (??? (is java/lang/Thread (null)))))])
-
- ($.definition /.check
- (format "Checks whether an object is an instance of a particular class."
- \n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.")
- [(when (check java/lang/String "YOLO")
- {.#Some value_as_string}
- {.#None})])
-
- ($.definition /.synchronized
- "Evaluates body, while holding a lock on a given object."
- [(synchronized object_to_be_locked
- (exec
- (do something)
- (do_something else)
- (finish the computation)))])
-
- ($.definition /.to
- "Call a variety of methods on an object. Then, return the object."
- [(to object
- (ClassName::method0 arg0 arg1 arg2)
- (ClassName::method1 arg3 arg4 arg5))])
-
- ($.definition /.import
- (format "Allows importing JVM classes, and using them as types."
- \n "Their methods, fields and enum options can also be imported.")
- [(import java/lang/Object
- "[1]::[0]"
- (new [])
- (equals [java/lang/Object] boolean)
- (wait [int] "io" "try" void))]
- ["Special options can also be given for the return values."
- "'?' means that the values will be returned inside a Maybe type. That way, null becomes .#None."
- "'try' means that the computation might throw an exception, and the return value will be wrapped by the Try type."
- "'io' means the computation has side effects, and will be wrapped by the IO type."
- "These options must show up in the following order ['io' 'try' '?'] (although, each option can be used independently)."
- (import java/lang/String
- "[1]::[0]"
- (new [[byte]])
- ("static" valueOf [char] java/lang/String)
- ("static" valueOf "as" int_valueOf [int] java/lang/String))
-
- (import (java/util/List e)
- "[1]::[0]"
- (size [] int)
- (get [int] e))
-
- (import (java/util/ArrayList a)
- "[1]::[0]"
- ([T] toArray [[T]] [T]))]
- ["The class-type that is generated is of the fully-qualified name."
- "This avoids a clash between the java.util.List type, and Lux's own List type."
- "All enum options to be imported must be specified."
- (import java/lang/Character$UnicodeScript
- "[1]::[0]"
- ("enum" ARABIC CYRILLIC LATIN))]
- ["It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-parameters."
- "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
- (import (lux/concurrency/async/JvmAsync A)
- "[1]::[0]"
- (resolve [A] boolean)
- (poll [] A)
- (wasResolved [] boolean)
- (waitOn [lux/Function] void)
- ("static" [A] make [A] (lux/concurrency/async/JvmAsync A)))]
- ["Also, the names of the imported members will look like Class::member"
- (java/lang/Object::new [])
- (java/lang/Object::equals [other_object] my_object)
- (java/util/List::size [] my_list)
- java/lang/Character$UnicodeScript::LATIN])
-
- ($.definition /.array
- "Create an array of the given type, with the given size."
- [(array java/lang/Object 10)])
-
- ($.definition /.length
- "Gives the length of an array."
- [(length my_array)])
-
- ($.definition /.read!
- "Loads an element from an array."
- [(read! 10 my_array)])
-
- ($.definition /.write!
- "Stores an element into an array."
- [(write! 10 my_object my_array)])
-
- ($.definition /.class_for
- "Loads the class as a java.lang.Class object."
- [(is (Primitive "java.lang.Class" ["java.lang.Object"])
- (class_for java/lang/String))])
-
- ($.definition /.type
- ""
- [(is .Type
- (type java/lang/String))])
- )))
diff --git a/stdlib/source/documentation/lux/ffi.py.lux b/stdlib/source/documentation/lux/ffi.py.lux
index f73c5eb83..786c4b987 100644
--- a/stdlib/source/documentation/lux/ffi.py.lux
+++ b/stdlib/source/documentation/lux/ffi.py.lux
@@ -24,33 +24,32 @@
($.definition /.import
"Easily import types, methods, functions and constants."
- [(import os
- "[1]::[0]"
- ("static" F_OK Integer)
- ("static" R_OK Integer)
- ("static" W_OK Integer)
- ("static" X_OK Integer)
+ ($.example (import os
+ "[1]::[0]"
+ ("static" F_OK Integer)
+ ("static" R_OK Integer)
+ ("static" W_OK Integer)
+ ("static" X_OK Integer)
- ("static" mkdir [String] "io" "try" "?" Any)
- ("static" access [String Integer] "io" "try" Boolean)
- ("static" remove [String] "io" "try" "?" Any)
- ("static" rmdir [String] "io" "try" "?" Any)
- ("static" rename [String String] "io" "try" "?" Any)
- ("static" listdir [String] "io" "try" (Array String)))
-
- (import os/path
- "[1]::[0]"
- ("static" isfile [String] "io" "try" Boolean)
- ("static" isdir [String] "io" "try" Boolean)
- ("static" sep String)
- ("static" getsize [String] "io" "try" Integer)
- ("static" getmtime [String] "io" "try" Float))])
+ ("static" mkdir [String] "io" "try" "?" Any)
+ ("static" access [String Integer] "io" "try" Boolean)
+ ("static" remove [String] "io" "try" "?" Any)
+ ("static" rmdir [String] "io" "try" "?" Any)
+ ("static" rename [String String] "io" "try" "?" Any)
+ ("static" listdir [String] "io" "try" (Array String))))
+ ($.example (import os/path
+ "[1]::[0]"
+ ("static" isfile [String] "io" "try" Boolean)
+ ("static" isdir [String] "io" "try" Boolean)
+ ("static" sep String)
+ ("static" getsize [String] "io" "try" Integer)
+ ("static" getmtime [String] "io" "try" Float))))
($.definition /.function
(format "Allows defining closures/anonymous-functions in the form that Python expects."
\n "This is useful for adapting Lux functions for usage by Python code.")
- [(is ..Function
- (function [left right]
- (do_something (as Foo left)
- (as Bar right))))])
+ ($.example (is ..Function
+ (function [left right]
+ (do_something (as Foo left)
+ (as Bar right))))))
))
diff --git a/stdlib/source/documentation/lux/ffi.rb.lux b/stdlib/source/documentation/lux/ffi.rb.lux
index bc3f482c1..b6ef778c0 100644
--- a/stdlib/source/documentation/lux/ffi.rb.lux
+++ b/stdlib/source/documentation/lux/ffi.rb.lux
@@ -22,22 +22,21 @@
($.definition /.import
"Easily import types, methods, functions and constants."
- [(import Stat
- "[1]::[0]"
- (executable? [] Bit)
- (size Int))
+ ($.example (import Stat
+ "[1]::[0]"
+ (executable? [] Bit)
+ (size Int)))
+ ($.example (import File "as" RubyFile
+ "[1]::[0]"
+ ("static" SEPARATOR ..String)
+ ("static" open [Path ..String] "io" "try" RubyFile)
+ ("static" stat [Path] "io" "try" Stat)
+ ("static" delete [Path] "io" "try" Int)
+ ("static" file? [Path] "io" "try" Bit)
+ ("static" directory? [Path] "io" "try" Bit)
- (import File "as" RubyFile
- "[1]::[0]"
- ("static" SEPARATOR ..String)
- ("static" open [Path ..String] "io" "try" RubyFile)
- ("static" stat [Path] "io" "try" Stat)
- ("static" delete [Path] "io" "try" Int)
- ("static" file? [Path] "io" "try" Bit)
- ("static" directory? [Path] "io" "try" Bit)
-
- (read [] "io" "try" Binary)
- (write [Binary] "io" "try" Int)
- (flush [] "io" "try" "?" Any)
- (close [] "io" "try" "?" Any))])
+ (read [] "io" "try" Binary)
+ (write [Binary] "io" "try" Int)
+ (flush [] "io" "try" "?" Any)
+ (close [] "io" "try" "?" Any))))
))
diff --git a/stdlib/source/documentation/lux/math/infix.lux b/stdlib/source/documentation/lux/math/infix.lux
index 89731c8ab..5b3d00381 100644
--- a/stdlib/source/documentation/lux/math/infix.lux
+++ b/stdlib/source/documentation/lux/math/infix.lux
@@ -19,25 +19,30 @@
\n "If you want your binary function to work well with it."
\n "Then take the argument to the right (y) as your first argument,"
\n "and take the argument to the left (x) as your second argument.")
- ["Binary functions"
- (infix [x * +10])
- "=>"
- (* +10 x)]
- ["Nested infix"
- (infix [[x + y] * [x - y]])
- "=>"
- (* (- y x) (+ y x))]
- ["Unary functions"
- (infix [sin [x + y]])
- "=>"
- (sin (+ y x))]
- ["Also works with logic"
- (infix [[x < y] and [y < z]])
- "=>"
- (and (< z y)
- (< y x))]
- ["Forms are left as-is"
- (infix [(* 3 9) gcd 450])
- "=>"
- (gcd 450 (* 3 9))])
+
+ ($.comment "Binary functions")
+ ($.example (infix [x * +10]))
+ ($.comment "=>")
+ ($.example (* +10 x))
+
+ ($.comment "Nested infix")
+ ($.example (infix [[x + y] * [x - y]]))
+ ($.comment "=>")
+ ($.example (* (- y x) (+ y x)))
+
+ ($.comment "Unary functions")
+ ($.example (infix [sin [x + y]]))
+ ($.comment "=>")
+ ($.example (sin (+ y x)))
+
+ ($.comment "Also works with logic")
+ ($.example (infix [[x < y] and [y < z]]))
+ ($.comment "=>")
+ ($.example (and (< z y)
+ (< y x)))
+
+ ($.comment "Forms are left as-is")
+ ($.example (infix [(* 3 9) gcd 450]))
+ ($.comment "=>")
+ ($.example (gcd 450 (* 3 9))))
))
diff --git a/stdlib/source/documentation/lux/math/logic/continuous.lux b/stdlib/source/documentation/lux/math/logic/continuous.lux
index f6198bfeb..b25fa3cf0 100644
--- a/stdlib/source/documentation/lux/math/logic/continuous.lux
+++ b/stdlib/source/documentation/lux/math/logic/continuous.lux
@@ -26,5 +26,5 @@
($.definition /.implies
""
- [(implies consequent antecedent)])
+ ($.example (implies consequent antecedent)))
))
diff --git a/stdlib/source/documentation/lux/math/logic/fuzzy.lux b/stdlib/source/documentation/lux/math/logic/fuzzy.lux
index 19e0d1ef0..fdd0f6c0c 100644
--- a/stdlib/source/documentation/lux/math/logic/fuzzy.lux
+++ b/stdlib/source/documentation/lux/math/logic/fuzzy.lux
@@ -26,33 +26,33 @@
($.definition /.membership
""
- [(membership set elem)])
+ ($.example (membership set elem)))
($.definition /.difference
""
- [(difference sub base)])
+ ($.example (difference sub base)))
($.definition /.of_predicate
""
- [(of_predicate predicate)])
+ ($.example (of_predicate predicate)))
($.definition /.predicate
""
- [(predicate treshold set)])
+ ($.example (predicate treshold set)))
($.definition /.gradient
""
- [(gradient from to)])
+ ($.example (gradient from to)))
($.definition /.triangle
""
- [(triangle bottom middle top)])
+ ($.example (triangle bottom middle top)))
($.definition /.trapezoid
""
- [(trapezoid bottom middle_bottom middle_top top)])
+ ($.example (trapezoid bottom middle_bottom middle_top top)))
($.definition /.cut
""
- [(cut treshold set)])
+ ($.example (cut treshold set)))
))
diff --git a/stdlib/source/documentation/lux/math/modular.lux b/stdlib/source/documentation/lux/math/modular.lux
index e084f6942..64d76ae02 100644
--- a/stdlib/source/documentation/lux/math/modular.lux
+++ b/stdlib/source/documentation/lux/math/modular.lux
@@ -41,9 +41,9 @@
($.definition /.modular
""
- [(modular modulus value)])
+ ($.example (modular modulus value)))
($.definition /.adapter
""
- [(adapter reference subject)])
+ ($.example (adapter reference subject)))
))
diff --git a/stdlib/source/documentation/lux/math/modulus.lux b/stdlib/source/documentation/lux/math/modulus.lux
index d699b1a18..d8be85b50 100644
--- a/stdlib/source/documentation/lux/math/modulus.lux
+++ b/stdlib/source/documentation/lux/math/modulus.lux
@@ -24,12 +24,13 @@
($.definition /.congruent?
""
- [(congruent? modulus reference subject)])
+ ($.example (congruent? modulus reference subject)))
($.definition /.literal
""
- ["Success!"
- (literal 123)]
- ["Failure!"
- (literal 0)])
+ ($.comment "Success!")
+ ($.example (literal 123))
+
+ ($.comment "Failure!")
+ ($.example (literal 0)))
))
diff --git a/stdlib/source/documentation/lux/math/number.lux b/stdlib/source/documentation/lux/math/number.lux
index f414ab616..641fe5e1c 100644
--- a/stdlib/source/documentation/lux/math/number.lux
+++ b/stdlib/source/documentation/lux/math/number.lux
@@ -29,9 +29,10 @@
(,, (with_template [<name> <encoding> <no_commas> <with_commas>]
[($.definition <name>
(format "Given syntax for a " <encoding> " number, generates a Nat, an Int, a Rev or a Frac.")
- [<no_commas>]
- ["Allows for the presence of commas (,) among the digits."
- <with_commas>])]
+ ($.example <no_commas>)
+
+ ($.comment "Allows for the presence of commas (,) among the digits.")
+ ($.example <with_commas>))]
[/.bin "binary" (bin "11001001") (bin "11,00,10,01")]
[/.oct "octal" (oct "615243") (oct "615,243")]
diff --git a/stdlib/source/documentation/lux/math/number/complex.lux b/stdlib/source/documentation/lux/math/number/complex.lux
index 2df1f2a71..239a6eddf 100644
--- a/stdlib/source/documentation/lux/math/number/complex.lux
+++ b/stdlib/source/documentation/lux/math/number/complex.lux
@@ -55,7 +55,8 @@
($.definition /.complex
"Complex literals."
- [(complex real imaginary)]
- ["The imaginary part can be omitted if it's +0.0."
- (complex real)])
+ ($.example (complex real imaginary))
+
+ ($.comment "The imaginary part can be omitted if it's +0.0.")
+ ($.example (complex real)))
))
diff --git a/stdlib/source/documentation/lux/math/number/frac.lux b/stdlib/source/documentation/lux/math/number/frac.lux
index d543143f6..b65bc0936 100644
--- a/stdlib/source/documentation/lux/math/number/frac.lux
+++ b/stdlib/source/documentation/lux/math/number/frac.lux
@@ -49,15 +49,15 @@
($.definition /.pow
""
- [(pow param subject)])
+ ($.example (pow param subject)))
($.definition /.atan_2
""
- [(atan_2 x y)])
+ ($.example (atan_2 x y)))
($.definition /.log_by
""
- [(log_by base it)])
+ ($.example (log_by base it)))
))
(`` (def .public documentation
@@ -93,23 +93,23 @@
($.definition /.=
"Frac(tion) equivalence."
- [(= reference sample)])
+ ($.example (= reference sample)))
($.definition /.<
"Frac(tion) less-than."
- [(< reference sample)])
+ ($.example (< reference sample)))
($.definition /.<=
"Frac(tion) less-than or equal."
- [(<= reference sample)])
+ ($.example (<= reference sample)))
($.definition /.>
"Frac(tion) greater-than."
- [(> reference sample)])
+ ($.example (> reference sample)))
($.definition /.>=
"Frac(tion) greater-than or equal."
- [(>= reference sample)])
+ ($.example (>= reference sample)))
(,, (with_template [<name> <doc>]
[($.definition <name>
@@ -124,7 +124,7 @@
($.definition /./%
""
- [(/% param subject)])
+ ($.example (/% param subject)))
(,, (with_template [<name> <doc>]
[($.definition <name>
@@ -145,15 +145,15 @@
($.definition /.not_a_number?
"Tests whether a frac is actually not-a-number."
- [(not_a_number? it)])
+ ($.example (not_a_number? it)))
($.definition /.approximately?
""
- [(approximately? margin_of_error standard value)])
+ ($.example (approximately? margin_of_error standard value)))
($.definition /.mod
""
- [(mod divisor dividend)])
+ ($.example (mod divisor dividend)))
..math
)))
diff --git a/stdlib/source/documentation/lux/math/number/i64.lux b/stdlib/source/documentation/lux/math/number/i64.lux
index 644c6e7e3..2180fcffd 100644
--- a/stdlib/source/documentation/lux/math/number/i64.lux
+++ b/stdlib/source/documentation/lux/math/number/i64.lux
@@ -43,7 +43,7 @@
($.definition /.bit
"A mask with only a specific bit set."
- [(bit position)])
+ ($.example (bit position)))
($.definition /.sign
"A mask for the sign bit of ints.")
@@ -53,11 +53,11 @@
($.definition /.mask
"Mask a block of bits of the specified size."
- [(mask amount_of_bits)])
+ ($.example (mask amount_of_bits)))
($.definition /.ones
"Count the number of 1s in a bit-map."
- [(ones it)])
+ ($.example (ones it)))
(,, (with_template [<name> <doc>]
[($.definition <name>
@@ -70,20 +70,20 @@
($.definition /.one?
""
- [(one? index input)])
+ ($.example (one? index input)))
($.definition /.zero?
""
- [(zero? index input)])
+ ($.example (zero? index input)))
($.definition /.region
"A mask for a block of bits of the given size, starting at the given offset."
- [(region offset size)])
+ ($.example (region offset size)))
($.definition (/.Sub width)
"A sub-space of I64 with a reduce amount of bits.")
($.definition /.sub
"Given a width in the interval (0,64), yields an implementation for integers of that width."
- [(sub width)])
+ ($.example (sub width)))
)))
diff --git a/stdlib/source/documentation/lux/math/number/int.lux b/stdlib/source/documentation/lux/math/number/int.lux
index f7805842d..187cfd5e4 100644
--- a/stdlib/source/documentation/lux/math/number/int.lux
+++ b/stdlib/source/documentation/lux/math/number/int.lux
@@ -36,23 +36,23 @@
($.definition /.=
"Int(eger) equivalence."
- [(= reference sample)])
+ ($.example (= reference sample)))
($.definition /.<
"Int(eger) less-than."
- [(< reference sample)])
+ ($.example (< reference sample)))
($.definition /.<=
"Int(eger) less-than or equal."
- [(<= reference sample)])
+ ($.example (<= reference sample)))
($.definition /.>
"Int(eger) greater-than."
- [(> reference sample)])
+ ($.example (> reference sample)))
($.definition /.>=
"Int(eger) greater-than or equal."
- [(>= reference sample)])
+ ($.example (>= reference sample)))
(,, (with_template [<name> <doc>]
[($.definition <name>
@@ -86,7 +86,7 @@
($.definition /.mod
(format "Integer modulo."
\n "Note: The modulo and the remainder are not the same.")
- [(mod divisor dividend)])
+ ($.example (mod divisor dividend)))
($.definition /.gcd
"Greatest Common Divisor.")
@@ -99,5 +99,5 @@
($.definition /.right_shifted
"Signed/arithmetic bitwise right-shift."
- [(right_shifted parameter subject)])
+ ($.example (right_shifted parameter subject)))
)))
diff --git a/stdlib/source/documentation/lux/math/number/ratio.lux b/stdlib/source/documentation/lux/math/number/ratio.lux
index e74805a90..6d93e699e 100644
--- a/stdlib/source/documentation/lux/math/number/ratio.lux
+++ b/stdlib/source/documentation/lux/math/number/ratio.lux
@@ -36,7 +36,8 @@
($.definition /.ratio
"Rational literals."
- [(ratio numerator denominator)]
- ["The denominator can be omitted if it is 1."
- (ratio numerator)])
+ ($.example (ratio numerator denominator))
+
+ ($.comment "The denominator can be omitted if it is 1.")
+ ($.example (ratio numerator)))
))
diff --git a/stdlib/source/documentation/lux/math/number/rev.lux b/stdlib/source/documentation/lux/math/number/rev.lux
index 323ccc467..d22c6c40e 100644
--- a/stdlib/source/documentation/lux/math/number/rev.lux
+++ b/stdlib/source/documentation/lux/math/number/rev.lux
@@ -43,23 +43,23 @@
($.definition /.=
"Rev(olution) equivalence."
- [(= reference sample)])
+ ($.example (= reference sample)))
($.definition /.<
"Rev(olution) less-than."
- [(< reference sample)])
+ ($.example (< reference sample)))
($.definition /.<=
"Rev(olution) less-than or equal."
- [(<= reference sample)])
+ ($.example (<= reference sample)))
($.definition /.>
"Rev(olution) greater-than."
- [(> reference sample)])
+ ($.example (> reference sample)))
($.definition /.>=
"Rev(olution) greater-than or equal."
- [(>= reference sample)])
+ ($.example (>= reference sample)))
(,, (with_template [<name> <doc>]
[($.definition <name>
@@ -83,13 +83,13 @@
($.definition /.up
""
- [(up scale subject)])
+ ($.example (up scale subject)))
($.definition /.down
""
- [(down scale subject)])
+ ($.example (down scale subject)))
($.definition /.reciprocal
"Rev(olution) reciprocal of a Nat(ural)."
- [(reciprocal numerator)])
+ ($.example (reciprocal numerator)))
)))
diff --git a/stdlib/source/documentation/lux/math/random.lux b/stdlib/source/documentation/lux/math/random.lux
index dd2b077cd..7b6911bb6 100644
--- a/stdlib/source/documentation/lux/math/random.lux
+++ b/stdlib/source/documentation/lux/math/random.lux
@@ -27,12 +27,12 @@
($.definition /.alphabetic)
($.definition /.alpha_numeric)
($.definition /.numeric)
- ($.definition /.upper_case)
- ($.definition /.lower_case)
+ ($.definition /.upper_cased)
+ ($.definition /.lower_cased)
($.definition /.text
""
- [(text char_gen size)]))]
+ ($.example (text char_gen size))))]
(list.partial ($.module /._
"Pseudo-random number generation (PRNG) algorithms.")
@@ -65,47 +65,47 @@
($.definition /.only
"Retries the generator until the output satisfies a predicate."
- [(only pred gen)])
+ ($.example (only pred gen)))
($.definition /.one
""
- [(one check random)])
+ ($.example (one check random)))
($.definition /.refined
"Retries the generator until the output can be refined."
- [(refined refiner gen)])
+ ($.example (refined refiner gen)))
($.definition /.and
"Sequencing combinator."
- [(and left right)])
+ ($.example (and left right)))
($.definition /.or
"Heterogeneous alternative combinator."
- [(or left right)])
+ ($.example (or left right)))
($.definition /.either
"Homogeneous alternative combinator."
- [(either left right)])
+ ($.example (either left right)))
($.definition /.rec
"A combinator for producing recursive random generators."
- [(rec gen)])
+ ($.example (rec gen)))
($.definition /.set
""
- [(set hash size value_gen)])
+ ($.example (set hash size value_gen)))
($.definition /.dictionary
""
- [(dictionary hash size key_gen value_gen)])
+ ($.example (dictionary hash size key_gen value_gen)))
($.definition /.result
""
- [(result prng calc)])
+ ($.example (result prng calc)))
($.definition /.prng
""
- [(prng update return)])
+ ($.example (prng update return)))
($.definition /.pcg_32
(format "An implementation of the PCG32 algorithm."
diff --git a/stdlib/source/documentation/lux/meta.lux b/stdlib/source/documentation/lux/meta.lux
index cc37ca4bf..329a5703d 100644
--- a/stdlib/source/documentation/lux/meta.lux
+++ b/stdlib/source/documentation/lux/meta.lux
@@ -41,7 +41,7 @@
(List $.Documentation)
(let [query (list ($.definition /.module
"Looks-up a module with the given name."
- [(module name)])
+ ($.example (module name)))
($.definition /.current_module_name
"The name of the module currently being compiled, if any.")
@@ -51,7 +51,7 @@
($.definition /.macro
"Looks-up a macro known by the given name."
- [(macro full_name)])
+ ($.example (macro full_name)))
($.definition /.seed
(format "The current value of a number tracked by the compiler."
@@ -60,51 +60,51 @@
($.definition /.module_exists?
""
- [(module_exists? module)])
+ ($.example (module_exists? module)))
($.definition /.var_type
"Looks-up the type of a local variable somewhere in the environment."
- [(var_type name)])
+ ($.example (var_type name)))
($.definition /.definition
"Looks-up a definition's whole data in the available modules (including the current one)."
- [(definition name)])
+ ($.example (definition name)))
($.definition /.export
(format "Looks-up a definition in the available modules (including the current one)."
\n "The look-up only succeeds if the definition has been exported.")
- [(export name)])
+ ($.example (export name)))
($.definition /.definition_type
"Looks-up a definition's type in the available modules (including the current one)."
- [(definition_type name)])
+ ($.example (definition_type name)))
($.definition /.type
"Looks-up the type of either a local variable or a definition."
- [(type name)])
+ ($.example (type name)))
($.definition /.type_definition
"Finds the value of a type definition (such as Int, Any or Lux)."
- [(type_definition name)])
+ ($.example (type_definition name)))
($.definition /.globals
"The entire list of globals in a module (including the non-exported/private ones)."
- [(globals module)])
+ ($.example (globals module)))
($.definition /.definitions
"The entire list of definitions in a module (including the non-exported/private ones)."
- [(definitions module)])
+ ($.example (definitions module)))
($.definition /.exports
"All the exported definitions in a module."
- [(exports module_name)])
+ ($.example (exports module_name)))
($.definition /.modules
"All the available modules (including the current one).")
($.definition /.tags_of
"All the tags associated with a type definition."
- [(tags_of type_name)])
+ ($.example (tags_of type_name)))
($.definition /.location
"The location of the current expression being analyzed.")
@@ -114,27 +114,27 @@
($.definition /.imported_modules
"All the modules imported by a specified module."
- [(imported_modules module_name)])
+ ($.example (imported_modules module_name)))
($.definition /.imported_by?
""
- [(imported_by? import module)])
+ ($.example (imported_by? import module)))
($.definition /.imported?
"Checks if the given module has been imported by the current module."
- [(imported? import)])
+ ($.example (imported? import)))
($.definition /.tag
"Given a tag, finds out what is its index, its related tag-list and its associated type."
- [(tag tag_name)])
+ ($.example (tag tag_name)))
($.definition /.slot
"Given a slot, finds out what is its index, its related slot-list and its associated type."
- [(slot slot_name)])
+ ($.example (slot slot_name)))
($.definition /.tag_lists
"All the tag-lists defined in a module, with their associated types."
- [(tag_lists module)])
+ ($.example (tag_lists module)))
($.definition /.locals
"All the local variables currently in scope, separated in different scopes.")
@@ -150,23 +150,23 @@
($.definition /.result'
(format "Evaluates a computation that depends on Lux's compiler state."
\n "Also returns a (potentially modified) compiler state.")
- [(result' lux action)])
+ ($.example (result' lux action)))
($.definition /.result
"Evaluates a computation that depends on Lux's compiler state."
- [(result lux action)])
+ ($.example (result lux action)))
($.definition /.either
"Pick whichever computation succeeds."
- [(either left right)])
+ ($.example (either left right)))
($.definition /.assertion
"Fails with the given message if the test is #0."
- [(assertion message test)])
+ ($.example (assertion message test)))
($.definition /.failure
"Fails with the given error message."
- [(failure error)]))]
+ ($.example (failure error))))]
(list.partial ($.module /._
"Functions for extracting information from the state of the compiler.")
@@ -177,15 +177,15 @@
($.definition /.normal
(format "If given a name without a module prefix, gives it the current module's name as prefix."
\n "Otherwise, returns the name as-is.")
- [(normal name)])
+ ($.example (normal name)))
($.definition /.de_aliased
"Given an aliased definition's name, returns the original definition being referenced."
- [(de_aliased def_name)])
+ ($.example (de_aliased def_name)))
($.definition /.eval
""
- [(eval type code)])
+ ($.example (eval type code)))
(list.together
(list query
diff --git a/stdlib/source/documentation/lux/meta/code.lux b/stdlib/source/documentation/lux/meta/code.lux
index 65e083e02..7ecef2b60 100644
--- a/stdlib/source/documentation/lux/meta/code.lux
+++ b/stdlib/source/documentation/lux/meta/code.lux
@@ -42,7 +42,7 @@
($.definition \\parser.this
"Ensures the given Code is the next input."
- [(this code)])
+ ($.example (this code)))
(,, (with_template [<query> <check> <desc>]
[($.definition <query>
@@ -70,15 +70,15 @@
($.definition \\parser.result
"Executes a parser against a stream of code, and verifies all the inputs are consumed."
- [(result parser inputs)])
+ ($.example (result parser inputs)))
($.definition \\parser.locally
"Runs parser against the given list of inputs."
- [(locally inputs parser)])
+ ($.example (locally inputs parser)))
($.definition \\parser.not
"Yields the next Code token if the parser fails."
- [(not expected_to_fail)])
+ ($.example (not expected_to_fail)))
($.definition \\parser.next
"Yields the next Code token without consuming it from the input stream.")
@@ -108,7 +108,7 @@
($.definition /.replaced
""
- [(replaced original substitute ast)])
+ ($.example (replaced original substitute ast)))
..\\parser
))
diff --git a/stdlib/source/documentation/lux/meta/compiler/language/lux/analysis.lux b/stdlib/source/documentation/lux/meta/compiler/language/lux/analysis.lux
index bb478f3e9..dc6f198f8 100644
--- a/stdlib/source/documentation/lux/meta/compiler/language/lux/analysis.lux
+++ b/stdlib/source/documentation/lux/meta/compiler/language/lux/analysis.lux
@@ -27,7 +27,7 @@
($.definition \\parser.result
"Executes a parser and makes sure no inputs go unconsumed."
- [(result parser input)])
+ ($.example (result parser input)))
($.definition \\parser.any
"Matches any value, without discrimination.")
@@ -57,7 +57,7 @@
($.definition \\parser.tuple
"Parses only within the context of a tuple's contents."
- [(tuple parser)])
+ ($.example (tuple parser)))
)))
(def .public documentation
diff --git a/stdlib/source/documentation/lux/meta/compiler/language/lux/synthesis.lux b/stdlib/source/documentation/lux/meta/compiler/language/lux/synthesis.lux
index 1ecf3f88b..12e3a24e2 100644
--- a/stdlib/source/documentation/lux/meta/compiler/language/lux/synthesis.lux
+++ b/stdlib/source/documentation/lux/meta/compiler/language/lux/synthesis.lux
@@ -31,7 +31,7 @@
($.definition \\parser.result
(format "Executes the parser against the inputs."
\n "Ensures all inputs are consumed by the parser.")
- [(result parser input)])
+ ($.example (result parser input)))
($.definition \\parser.any
"Yields a synthesis node without subjecting it to any analysis.")
@@ -59,15 +59,15 @@
($.definition \\parser.tuple
"Parses the contents of a tuple."
- [(tuple parser)])
+ ($.example (tuple parser)))
($.definition \\parser.function
"Parses the body of a function with the 'expected' arity."
- [(function expected parser)])
+ ($.example (function expected parser)))
($.definition \\parser.loop
"Parses the initial values and the body of a loop."
- [(loop init_parsers iteration_parser)])
+ ($.example (loop init_parsers iteration_parser)))
)))
(def all_templates
diff --git a/stdlib/source/documentation/lux/meta/extension.lux b/stdlib/source/documentation/lux/meta/extension.lux
index e0ce6b4b0..f27a7c7a0 100644
--- a/stdlib/source/documentation/lux/meta/extension.lux
+++ b/stdlib/source/documentation/lux/meta/extension.lux
@@ -29,23 +29,23 @@
($.definition /.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))])
+ ($.example (analysis ("my analysis" self phase archive [pass_through <code>.any])
+ (phase archive pass_through))))
($.definition /.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))])
+ ($.example (synthesis ("my synthesis" self phase archive [pass_through <analysis>.any])
+ (phase archive pass_through))))
($.definition /.generation
""
- [(generation ("my generation" self phase archive [pass_through <synthesis>.any])
- (phase archive pass_through))])
+ ($.example (generation ("my generation" self phase archive [pass_through <synthesis>.any])
+ (phase archive pass_through))))
($.definition /.declaration
""
- [(declaration ("my declaration" self phase archive [parameters (<>.some <code>.any)])
- (do phase.monad
- [.let [_ (debug.log! (format "Successfully installed declaration " (%.text self) "!"))]]
- (in declaration.no_requirements)))])
+ ($.example (declaration ("my declaration" self phase archive [parameters (<>.some <code>.any)])
+ (do phase.monad
+ [.let [_ (debug.log! (format "Successfully installed declaration " (%.text self) "!"))]]
+ (in declaration.no_requirements)))))
))
diff --git a/stdlib/source/documentation/lux/meta/location.lux b/stdlib/source/documentation/lux/meta/location.lux
index e7e7ef30a..28493faf6 100644
--- a/stdlib/source/documentation/lux/meta/location.lux
+++ b/stdlib/source/documentation/lux/meta/location.lux
@@ -19,9 +19,9 @@
($.definition /.here
"The Location of the current form."
- [(here)])
+ ($.example (here)))
($.definition /.with
""
- [(with location error)])
+ ($.example (with location error)))
))
diff --git a/stdlib/source/documentation/lux/meta/macro.lux b/stdlib/source/documentation/lux/meta/macro.lux
index bde4fd2f4..648fa6a6b 100644
--- a/stdlib/source/documentation/lux/meta/macro.lux
+++ b/stdlib/source/documentation/lux/meta/macro.lux
@@ -22,79 +22,81 @@
... ($.definition /.single_expansion
... (format "Given code that requires applying a macro, does it once and returns the result."
... \n "Otherwise, returns the code as-is.")
- ... [(single_expansion syntax)])
+ ... ($.example (single_expansion syntax)))
... ($.definition /.expansion
... (format "Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left."
... \n "Otherwise, returns the code as-is.")
- ... [(expansion syntax)])
+ ... ($.example (expansion syntax)))
... ($.definition /.full_expansion
... "Expands all macro-calls everywhere recursively, until only primitive/base code remains."
- ... [(full_expansion syntax)])
+ ... ($.example (full_expansion syntax)))
($.definition /.symbol
(format "Generates a unique name as a Code node (ready to be used in code templates)."
\n "A prefix can be given (or just be empty text) to better identify the code for debugging purposes.")
- [(symbol prefix)])
+ ($.example (symbol prefix)))
($.definition /.wrong_syntax_error
"A generic error message for macro syntax failures.")
($.definition /.with_symbols
"Creates new symbols and offers them to the body expression."
- [(def synchronized
- (syntax (_ [lock any
- body any])
- (with_symbols [g!lock g!body g!_]
- (in (list (` (let [(, g!lock) (, lock)
- (, g!_) ("jvm monitorenter" (, g!lock))
- (, g!body) (, body)
- (, g!_) ("jvm monitorexit" (, g!lock))]
- (, g!body))))))))])
+ ($.example (def synchronized
+ (syntax (_ [lock any
+ body any])
+ (with_symbols [g!lock g!body g!_]
+ (in (list (` (let [(, g!lock) (, lock)
+ (, g!_) ("jvm monitorenter" (, g!lock))
+ (, g!body) (, body)
+ (, g!_) ("jvm monitorexit" (, g!lock))]
+ (, g!body))))))))))
... ($.definition /.one_expansion
... "Works just like expand, except that it ensures that the output is a single Code token."
- ... [(one_expansion token)])
+ ... ($.example (one_expansion token)))
... ($.definition /.log_single_expansion!
... (format "Performs a macro-expansion and logs the resulting code."
... \n "You can either use the resulting code, or omit them."
... \n "By omitting them, this macro produces nothing (just like the lux.comment macro).")
- ... [(log_single_expansion!
- ... (def (foo bar baz)
- ... (-> Int Int Int)
- ... (int.+ bar baz)))
- ... (log_single_expansion! "omit"
- ... (def (foo bar baz)
- ... (-> Int Int Int)
- ... (int.+ bar baz)))])
+ ... ($.example (log_single_expansion!
+ ... (def (foo bar baz)
+ ... (-> Int Int Int)
+ ... (int.+ bar baz))))
+ ... ($.example (log_single_expansion! "omit"
+ ... (def (foo bar baz)
+ ... (-> Int Int Int)
+ ... (int.+ bar baz)))))
... ($.definition /.log_expansion!
... (format "Performs a macro-expansion and logs the resulting code."
... \n "You can either use the resulting code, or omit them."
... \n "By omitting them, this macro produces nothing (just like the lux.comment macro).")
- ... [(log_expansion!
- ... (def (foo bar baz)
- ... (-> Int Int Int)
- ... (int.+ bar baz)))
- ... (log_expansion! "omit"
- ... (def (foo bar baz)
- ... (-> Int Int Int)
- ... (int.+ bar baz)))])
+
+ ... ($.example (log_expansion!
+ ... (def (foo bar baz)
+ ... (-> Int Int Int)
+ ... (int.+ bar baz))))
+ ... ($.example (log_expansion! "omit"
+ ... (def (foo bar baz)
+ ... (-> Int Int Int)
+ ... (int.+ bar baz)))))
... ($.definition /.log_full_expansion!
... (format "Performs a macro-expansion and logs the resulting code."
... \n "You can either use the resulting code, or omit them."
... \n "By omitting them, this macro produces nothing (just like the lux.comment macro).")
- ... [(log_full_expansion!
- ... (def (foo bar baz)
- ... (-> Int Int Int)
- ... (int.+ bar baz)))
- ... (log_full_expansion! "omit"
- ... (def (foo bar baz)
- ... (-> Int Int Int)
- ... (int.+ bar baz)))])
+
+ ... ($.example (log_full_expansion!
+ ... (def (foo bar baz)
+ ... (-> Int Int Int)
+ ... (int.+ bar baz))))
+ ... ($.example (log_full_expansion! "omit"
+ ... (def (foo bar baz)
+ ... (-> Int Int Int)
+ ... (int.+ bar baz)))))
(all list#composite
/local.documentation
diff --git a/stdlib/source/documentation/lux/meta/macro/local.lux b/stdlib/source/documentation/lux/meta/macro/local.lux
index 47248b372..36821e6d9 100644
--- a/stdlib/source/documentation/lux/meta/macro/local.lux
+++ b/stdlib/source/documentation/lux/meta/macro/local.lux
@@ -24,5 +24,5 @@
\n "Yields code that can be placed either as expression or as declarations."
\n "This code un-installs the macros."
\n "NOTE: Always use this code once to clean-up..")
- [(push macros)])
+ ($.example (push macros)))
))
diff --git a/stdlib/source/documentation/lux/meta/macro/syntax.lux b/stdlib/source/documentation/lux/meta/macro/syntax.lux
index 4f924ea38..4b9710faa 100644
--- a/stdlib/source/documentation/lux/meta/macro/syntax.lux
+++ b/stdlib/source/documentation/lux/meta/macro/syntax.lux
@@ -28,19 +28,19 @@
\n "The inputs to the macro can be parsed in complex ways through the use of syntax parsers."
\n "The macro body is also (implicitly) run in the Meta monad, to save some typing."
\n "Also, the compiler state can be accessed through a special binding.")
- [(def .public object
- (syntax (_ lux_state [.let [imports (class_imports lux_state)]
- .let [class_vars (list)]
- super (opt (super_class_decl^ imports class_vars))
- interfaces (tuple (some (super_class_decl^ imports class_vars)))
- constructor_args (constructor_args^ imports class_vars)
- methods (some (overriden_method_def^ imports))])
- (let [def_code (all text#composite "anon-class:"
- (spaced (list (super_class_decl$ (maybe.else object_super_class super))
- (with_brackets (spaced (list#each super_class_decl$ interfaces)))
- (with_brackets (spaced (list#each constructor_arg$ constructor_args)))
- (with_brackets (spaced (list#each (method_def$ id) methods))))))]
- (in (list (` ((, (code.text def_code)))))))))])
+ ($.example (def .public object
+ (syntax (_ lux_state [.let [imports (class_imports lux_state)]
+ .let [class_vars (list)]
+ super (opt (super_class_decl^ imports class_vars))
+ interfaces (tuple (some (super_class_decl^ imports class_vars)))
+ constructor_args (constructor_args^ imports class_vars)
+ methods (some (overriden_method_def^ imports))])
+ (let [def_code (all text#composite "anon-class:"
+ (spaced (list (super_class_decl$ (maybe.else object_super_class super))
+ (with_brackets (spaced (list#each super_class_decl$ interfaces)))
+ (with_brackets (spaced (list#each constructor_arg$ constructor_args)))
+ (with_brackets (spaced (list#each (method_def$ id) methods))))))]
+ (in (list (` ((, (code.text def_code)))))))))))
(all list#composite
/check.documentation
diff --git a/stdlib/source/documentation/lux/meta/macro/syntax/declaration.lux b/stdlib/source/documentation/lux/meta/macro/syntax/declaration.lux
index 77290d620..725545e96 100644
--- a/stdlib/source/documentation/lux/meta/macro/syntax/declaration.lux
+++ b/stdlib/source/documentation/lux/meta/macro/syntax/declaration.lux
@@ -23,7 +23,8 @@
($.definition /.parser
"A parser for declaration syntax."
- ["Such as:"
- quux
- (foo bar baz)])
+
+ ($.comment "Such as:")
+ ($.example quux)
+ ($.example (foo bar baz)))
))
diff --git a/stdlib/source/documentation/lux/meta/macro/syntax/definition.lux b/stdlib/source/documentation/lux/meta/macro/syntax/definition.lux
index e429ba035..08a7d5b08 100644
--- a/stdlib/source/documentation/lux/meta/macro/syntax/definition.lux
+++ b/stdlib/source/documentation/lux/meta/macro/syntax/definition.lux
@@ -24,9 +24,9 @@
($.definition /.parser
"A reader that first macro-expands and then analyses the input Code, to ensure it is a definition."
- [(parser compiler)])
+ ($.example (parser compiler)))
($.definition /.typed
"Only works for typed definitions."
- [(typed compiler)])
+ ($.example (typed compiler)))
))
diff --git a/stdlib/source/documentation/lux/meta/macro/syntax/export.lux b/stdlib/source/documentation/lux/meta/macro/syntax/export.lux
index 10191449c..4b7437339 100644
--- a/stdlib/source/documentation/lux/meta/macro/syntax/export.lux
+++ b/stdlib/source/documentation/lux/meta/macro/syntax/export.lux
@@ -17,7 +17,7 @@
($.definition /.default)
- ($.definition /.parser
+ ($.definition /.with
""
- [(parser un_exported)])
+ ($.example (with un_exported)))
))
diff --git a/stdlib/source/documentation/lux/meta/macro/template.lux b/stdlib/source/documentation/lux/meta/macro/template.lux
index 4ef001ef4..688558043 100644
--- a/stdlib/source/documentation/lux/meta/macro/template.lux
+++ b/stdlib/source/documentation/lux/meta/macro/template.lux
@@ -19,48 +19,49 @@
($.definition /.spliced
""
- [(spliced [a b c d])
- "=>"
- a
- b
- c
- d])
+ ($.example (spliced [a b c d]))
+ ($.comment "=>")
+ ($.example a)
+ ($.example b)
+ ($.example c)
+ ($.example d))
($.definition /.amount
""
- [(amount [a b c d])
- "=>"
- 4])
+ ($.example (amount [a b c d]))
+ ($.comment "=>")
+ ($.example 4))
($.definition /.with_locals
"Creates names for local bindings aliased by the names you choose."
- [(with_locals [my_var]
- (let [my_var 123]
- (text [my_var])))
- "=>"
- "__gensym__my_var506"])
+ ($.example (with_locals [my_var]
+ (let [my_var 123]
+ (text [my_var]))))
+ ($.comment "=>")
+ ($.example "__gensym__my_var506"))
($.definition /.text
"A text literal made by concatenating pieces of code."
- [(text [#0 123 +456 +789.0 "abc" .def ..ghi])
- "=>"
- "#0123+456+789.0abcdefghi"])
+ ($.example (text [#0 123 +456 +789.0 "abc" .def ..ghi]))
+ ($.comment "=>")
+ ($.example "#0123+456+789.0abcdefghi"))
($.definition /.symbol
(format "An symbol made by concatenating pieces of code."
\n "The (optional) module part and the short part are specified independently.")
- [(symbol ["abc" .def ..ghi])
- "=>"
- abcdefghi]
- [(symbol [.def] ["abc" .def ..ghi])
- "=>"
- .abcdefghi])
+ ($.example (symbol ["abc" .def ..ghi]))
+ ($.comment "=>")
+ ($.example abcdefghi)
+
+ ($.example (symbol [.def] ["abc" .def ..ghi]))
+ ($.comment "=>")
+ ($.example .abcdefghi))
($.definition /.let
"Lexically-bound templates."
- [(let [(!square <root>)
- [(* <root> <root>)]]
- (def (square root)
- (-> Nat Nat)
- (!square root)))])
+ ($.example (let [(!square <root>)
+ [(* <root> <root>)]]
+ (def (square root)
+ (-> Nat Nat)
+ (!square root)))))
))
diff --git a/stdlib/source/documentation/lux/meta/static.lux b/stdlib/source/documentation/lux/meta/static.lux
index cd5168c83..b2179dcba 100644
--- a/stdlib/source/documentation/lux/meta/static.lux
+++ b/stdlib/source/documentation/lux/meta/static.lux
@@ -27,11 +27,11 @@
($.definition /.literal
""
- [(/.literal
- (is (-> ??? Code)
- format)
- (is ???
- (value generating expression)))]))
+ ($.example (/.literal
+ (is (-> ??? Code)
+ format)
+ (is ???
+ (value generating expression))))))
random (list (,, (with_template [<name> <type>]
[($.definition <name>
(%.code (' (is <type>
@@ -45,11 +45,11 @@
($.definition /.random
""
- [(/.random
- (is (-> ??? Code)
- format)
- (is (Random ???)
- (random data generator)))]))]
+ ($.example (/.random
+ (is (-> ??? Code)
+ format)
+ (is (Random ???)
+ (random data generator))))))]
(list.partial ($.module /._
"")
diff --git a/stdlib/source/documentation/lux/meta/type.lux b/stdlib/source/documentation/lux/meta/type.lux
index 4e2d13faa..292b084f2 100644
--- a/stdlib/source/documentation/lux/meta/type.lux
+++ b/stdlib/source/documentation/lux/meta/type.lux
@@ -61,7 +61,7 @@
($.definition \\parser.result
(format "Applies a parser against a type."
\n "Verifies that the parser fully consumes the type's information.")
- [(result poly type)])
+ ($.example (result poly type)))
($.definition \\parser.env
"Yields the current parsing environment.")
@@ -74,11 +74,11 @@
($.definition \\parser.local
"Apply a parser to the given inputs."
- [(local types poly)])
+ ($.example (local types poly)))
($.definition \\parser.with_extension
""
- [(with_extension type poly)])
+ ($.example (with_extension type poly)))
(,, (with_template [<name>]
[(`` ($.definition <name>
@@ -90,15 +90,15 @@
($.definition \\parser.polymorphic
""
- [(polymorphic poly)])
+ ($.example (polymorphic poly)))
($.definition \\parser.function
"Parses a function's inputs and output."
- [(function in_poly out_poly)])
+ ($.example (function in_poly out_poly)))
($.definition \\parser.applied
"Parses a type application."
- [(applied poly)])
+ ($.example (applied poly)))
(,, (with_template [<name> <doc>]
[($.definition <name>
@@ -111,11 +111,11 @@
($.definition \\parser.argument
""
- [(argument env idx)])
+ ($.example (argument env idx)))
($.definition \\parser.this_parameter
""
- [(this_parameter id)])
+ ($.example (this_parameter id)))
($.definition \\parser.existential
"Yields an existential type.")
@@ -125,7 +125,7 @@
($.definition \\parser.recursive
""
- [(recursive poly)])
+ ($.example (recursive poly)))
)))
(`` (def .public documentation
@@ -145,11 +145,11 @@
($.definition /.flat_function
"The input, and the output of a function type."
- [(flat_function type)])
+ ($.example (flat_function type)))
($.definition /.flat_application
"The quantified type, and its parameters, for a type-application."
- [(flat_application type)])
+ ($.example (flat_application type)))
(,, (with_template [<name>]
[($.definition <name>
@@ -161,24 +161,24 @@
($.definition /.format
"A (readable) textual representable of a type."
- [(format type)])
+ ($.example (format type)))
($.definition /.applied
"To the extend possible, applies a quantified type to the given parameters."
- [(applied params func)])
+ ($.example (applied params func)))
($.definition /.code
(%.format "A representation of a type as code."
\n "The code is such that evaluating it would yield the type value.")
- [(code type)])
+ ($.example (code type)))
($.definition /.de_aliased
"A (potentially named) type that does not have its name shadowed by other names."
- [(de_aliased type)])
+ ($.example (de_aliased type)))
($.definition /.anonymous
"A type without any names covering it."
- [(anonymous type)])
+ ($.example (anonymous type)))
(,, (with_template [<name>]
[($.definition <name>
@@ -190,11 +190,11 @@
($.definition /.function
"A function type, with the given inputs and output."
- [(function inputs output)])
+ ($.example (function inputs output)))
($.definition /.application
"An un-evaluated type application, with the given quantified type, and parameters."
- [(application params quant)])
+ ($.example (application params quant)))
(,, (with_template [<name>]
[($.definition <name>
@@ -206,63 +206,65 @@
($.definition /.quantified?
"Only yields #1 for universally or existentially quantified types."
- [(quantified? type)])
+ ($.example (quantified? type)))
($.definition /.array
"An array type, with the given level of nesting/depth, and the given element type."
- [(array depth element_type)])
+ ($.example (array depth element_type)))
($.definition /.flat_array
"The level of nesting/depth and element type for an array type."
- [(flat_array type)])
+ ($.example (flat_array type)))
($.definition /.array?
"Is a type an array type?")
($.definition /.log!
"Logs to the console/terminal the type of an expression."
- [(log! (is Foo (foo expression)))
- "=>"
- "Expression: (foo expression)"
- " Type: Foo"
- (foo expression)])
+
+ ($.example (log! (is Foo (foo expression))))
+ ($.comment "=>")
+ ($.comment "Expression: (foo expression)")
+ ($.comment " Type: Foo")
+ ($.example (foo expression)))
($.definition /.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.")
- [(is (Bar Bit Nat Text)
- (as [a b c]
- (Foo a [b c])
- (Bar a b c)
- (is (Foo Bit [Nat Text])
- (foo expression))))])
+ ($.example (is (Bar Bit Nat Text)
+ (as [a b c]
+ (Foo a [b c])
+ (Bar a b c)
+ (is (Foo Bit [Nat Text])
+ (foo expression))))))
($.definition /.sharing
"Allows specifing the type of an expression as sharing type-variables with the type of another expression."
- [(is (Bar Bit Nat Text)
- (sharing [a b c]
- (is (Foo a [b c])
- (is (Foo Bit [Nat Text])
- (foo expression)))
- (is (Bar a b c)
- (bar expression))))])
+ ($.example (is (Bar Bit Nat Text)
+ (sharing [a b c]
+ (is (Foo a [b c])
+ (is (Foo Bit [Nat Text])
+ (foo expression)))
+ (is (Bar a b c)
+ (bar expression))))))
($.definition /.by_example
"Constructs a type that shares type-variables with an expression of some other type."
- [(is Type
- (by_example [a b c]
- (is (Foo a [b c])
- (is (Foo Bit [Nat Text])
- (foo expression)))
- (Bar a b c)))
- "=>"
- (.type_literal (Bar Bit Nat Text))])
+
+ ($.example (is Type
+ (by_example [a b c]
+ (is (Foo a [b c])
+ (is (Foo Bit [Nat Text])
+ (foo expression)))
+ (Bar a b c))))
+ ($.comment "=>")
+ ($.example (.type_literal (Bar Bit Nat Text))))
($.definition /.let
"Local bindings for types."
- [(let [side (Either Int Frac)]
- (List [side side]))])
+ ($.example (let [side (Either Int Frac)]
+ (List [side side]))))
(all list#composite
..\\parser
diff --git a/stdlib/source/documentation/lux/meta/type/check.lux b/stdlib/source/documentation/lux/meta/type/check.lux
index 55cbfd5b1..82fd02c56 100644
--- a/stdlib/source/documentation/lux/meta/type/check.lux
+++ b/stdlib/source/documentation/lux/meta/type/check.lux
@@ -33,19 +33,19 @@
($.definition /.result
""
- [(result context proc)])
+ ($.example (result context proc)))
($.definition /.failure
""
- [(failure message)])
+ ($.example (failure message)))
($.definition /.assertion
""
- [(assertion message test)])
+ ($.example (assertion message test)))
($.definition /.except
""
- [(except exception message)])
+ ($.example (except exception message)))
($.definition /.existential
"A brand-new existential type.")
@@ -53,7 +53,7 @@
($.definition /.bind
(format "Attemmpts to buy a type-variable."
\n "Fails if the variable has been bound already.")
- [(bind type id)])
+ ($.example (bind type id)))
($.definition /.var
"A brand-new (unbound) type-variable.")
@@ -63,16 +63,16 @@
($.definition /.check
"Type-check to ensure that the 'expected' type subsumes the 'actual' type."
- [(check expected actual)])
+ ($.example (check expected actual)))
($.definition /.subsumes?
"A simple type-checking function that just returns a yes/no answer."
- [(subsumes? expected actual)])
+ ($.example (subsumes? expected actual)))
($.definition /.context
"The current state of the type-checking context.")
($.definition /.clean
"Resolves every bound type-variable to yield a new type that is as resolved as possible."
- [(clean inputT)])
+ ($.example (clean inputT)))
))
diff --git a/stdlib/source/documentation/lux/meta/type/dynamic.lux b/stdlib/source/documentation/lux/meta/type/dynamic.lux
index af54272d6..18db9468f 100644
--- a/stdlib/source/documentation/lux/meta/type/dynamic.lux
+++ b/stdlib/source/documentation/lux/meta/type/dynamic.lux
@@ -21,11 +21,11 @@
($.definition /.dynamic
""
- [(is Dynamic
- (dynamic 123))])
+ ($.example (is Dynamic
+ (dynamic 123))))
($.definition /.static
""
- [(is (try.Try Nat)
- (static Nat (dynamic 123)))])
+ ($.example (is (try.Try Nat)
+ (static Nat (dynamic 123)))))
))
diff --git a/stdlib/source/documentation/lux/meta/type/implicit.lux b/stdlib/source/documentation/lux/meta/type/implicit.lux
index 54ded8081..4803008c0 100644
--- a/stdlib/source/documentation/lux/meta/type/implicit.lux
+++ b/stdlib/source/documentation/lux/meta/type/implicit.lux
@@ -25,28 +25,30 @@
\n "a compile-time error will be raised, to alert the user."
\n \n "Caveat emptor: You need to make sure to import the module of any implementation you want to use."
\n "Otherwise, this macro will not find it.")
- ["Nat equivalence"
- (at number.equivalence = x y)
- (a/an = x y)]
- ["Can optionally add the prefix of the module where the signature was defined."
- (a/an equivalence.= x y)]
- ["(List Nat) equivalence"
- (a/an =
- (list.indices 10)
- (list.indices 10))]
- ["(Functor List) each"
- (a/an each ++ (list.indices 10))])
+ ($.example ($.comment "Nat equivalence"))
+ ($.example (at number.equivalence = x y))
+ ($.example (a/an = x y))
+
+ ($.comment "Can optionally add the prefix of the module where the signature was defined.")
+ ($.example (a/an equivalence.= x y))
+
+ ($.comment "(List Nat) equivalence")
+ ($.example (a/an =
+ (list.indices 10)
+ (list.indices 10)))
+
+ ($.comment "(Functor List) each")
+ ($.example (a/an each ++ (list.indices 10))))
($.definition /.with
"Establish lexical bindings for implementations that will be prioritized over non-lexically-bound implementations."
- [(with [n.addition]
- (n.= (at n.addition composite left right)
- (a/an composite left right)))])
+ ($.example (with [n.addition]
+ (n.= (at n.addition composite left right)
+ (a/an composite left right)))))
($.definition /.implicitly
"Establish local definitions for implementations that will be prioritized over foreign definitions."
- [(implicitly n.multiplication)
-
- (n.= (at n.multiplication composite left right)
- (a/an composite left right))])
+ ($.example (implicitly n.multiplication))
+ ($.example (n.= (at n.multiplication composite left right)
+ (a/an composite left right))))
))
diff --git a/stdlib/source/documentation/lux/meta/type/poly.lux b/stdlib/source/documentation/lux/meta/type/poly.lux
index fb33e6236..b781bb5c8 100644
--- a/stdlib/source/documentation/lux/meta/type/poly.lux
+++ b/stdlib/source/documentation/lux/meta/type/poly.lux
@@ -21,5 +21,5 @@
($.definition /.code
""
- [(code env type)])
+ ($.example (code env type)))
))
diff --git a/stdlib/source/documentation/lux/meta/type/primitive.lux b/stdlib/source/documentation/lux/meta/type/primitive.lux
index 04a751666..036489d22 100644
--- a/stdlib/source/documentation/lux/meta/type/primitive.lux
+++ b/stdlib/source/documentation/lux/meta/type/primitive.lux
@@ -21,15 +21,15 @@
($.definition /.specific
"A specific abstract/nominal type still being defined somewhere in the scope."
- [(specific name)])
+ ($.example (specific name)))
(,, (with_template [<name> <from> <$> <to>]
[($.definition <name>
"Type-casting macro for abstract/nominal types."
- [(|> value
- (is <from>)
- <$>
- (is <to>))])]
+ ($.example (|> value
+ (is <from>)
+ <$>
+ (is <to>))))]
[/.abstraction Representation abstraction Abstraction]
[/.representation Abstraction representation Representation]
@@ -38,82 +38,85 @@
($.definition /.def
(format "Define abstract/nominal types which hide their representation details."
\n "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others.")
- [(/.def String
- Text
-
- (.def (string value)
- (-> Text String)
- (abstraction value))
-
- (.def (text value)
- (-> String Text)
- (representation value)))]
- ["Type-parameters are optional."
- (/.def (Duplicate a)
- [a a]
-
- (.def (duplicate value)
- (All (_ a) (-> a (Duplicate a)))
- (abstraction [value value])))]
- ["Definitions can be nested."
- (/.def (Single a)
- a
-
- (.def (single value)
- (All (_ a) (-> a (Single a)))
- (abstraction value))
-
- (/.def (Double a)
- [a a]
-
- (.def (double value)
- (All (_ a) (-> a (Double a)))
- (abstraction [value value]))
-
- (.def (single' value)
- (All (_ a) (-> a (Single a)))
- (abstraction Single [value value]))
-
- (let [value 0123]
- (same? value
- (|> value
- single'
- (representation Single)
- double
- representation)))))]
- ["Type-parameters do not necessarily have to be used in the representation type."
- "If they are not used, they become phantom types and can be used to customize types without changing the representation."
- (/.def (JavaScript a)
- Text
-
- (/.def Expression Any)
- (/.def Statement Any)
-
- (.def (+ x y)
- (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression))
- (abstraction
- (format "(" (representation x) "+" (representation y) ")")))
-
- (.def (while test body)
- (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement))
- (abstraction
- (format "while(" (representation test) ") {"
- (representation body)
- "}"))))])
+ ($.example (/.def String
+ Text
+
+ (.def (string value)
+ (-> Text String)
+ (abstraction value))
+
+ (.def (text value)
+ (-> String Text)
+ (representation value))))
+
+ ($.comment "Type-parameters are optional.")
+ ($.example (/.def (Duplicate a)
+ [a a]
+
+ (.def (duplicate value)
+ (All (_ a) (-> a (Duplicate a)))
+ (abstraction [value value]))))
+
+ ($.comment "Definitions can be nested.")
+ ($.example (/.def (Single a)
+ a
+
+ (.def (single value)
+ (All (_ a) (-> a (Single a)))
+ (abstraction value))
+
+ (/.def (Double a)
+ [a a]
+
+ (.def (double value)
+ (All (_ a) (-> a (Double a)))
+ (abstraction [value value]))
+
+ (.def (single' value)
+ (All (_ a) (-> a (Single a)))
+ (abstraction Single [value value]))
+
+ (let [value 0123]
+ (same? value
+ (|> value
+ single'
+ (representation Single)
+ double
+ representation))))))
+
+ ($.comment "Type-parameters do not necessarily have to be used in the representation type.")
+ ($.comment "If they are not used, they become phantom types and can be used to customize types without changing the representation.")
+ ($.example (/.def (JavaScript a)
+ Text
+
+ (/.def Expression Any)
+ (/.def Statement Any)
+
+ (.def (+ x y)
+ (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression))
+ (abstraction
+ (format "(" (representation x) "+" (representation y) ")")))
+
+ (.def (while test body)
+ (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement))
+ (abstraction
+ (format "while(" (representation test) ") {"
+ (representation body)
+ "}"))))))
($.definition /.transmutation
"Transmutes an abstract/nominal type's phantom types."
- [(/.def (JavaScript a)
- Text
+ ($.example (/.def (JavaScript a)
+ Text
- (/.def Expression Any)
- (/.def Statement Any)
+ (/.def Expression Any)
+ (/.def Statement Any)
- (.def (statement expression)
- (-> (JavaScript Expression) (JavaScript Statement))
- (transmutation expression))
+ (.def (statement expression)
+ (-> (JavaScript Expression) (JavaScript Statement))
+ (transmutation expression))
- (.def (statement' expression)
- (-> (JavaScript Expression) (JavaScript Statement))
- (transmutation JavaScript expression)))])
+ (.def (statement' expression)
+ (-> (JavaScript Expression) (JavaScript Statement))
+ (transmutation JavaScript expression)))))
)))
diff --git a/stdlib/source/documentation/lux/meta/type/quotient.lux b/stdlib/source/documentation/lux/meta/type/quotient.lux
index e374a11c5..07d3c0751 100644
--- a/stdlib/source/documentation/lux/meta/type/quotient.lux
+++ b/stdlib/source/documentation/lux/meta/type/quotient.lux
@@ -28,17 +28,16 @@
($.definition /.quotient
""
- [(quotient class value)])
+ ($.example (quotient class value)))
($.definition /.type
"The Quotient type associated with a Class type."
- [(def even
- (class even?))
- (def Even
- Type
- (type even))
-
- (is Even
- (quotient even 123))])
+ ($.example (def even
+ (class even?)))
+ ($.example (def Even
+ Type
+ (type even)))
+ ($.example (is Even
+ (quotient even 123))))
))
diff --git a/stdlib/source/documentation/lux/meta/type/refinement.lux b/stdlib/source/documentation/lux/meta/type/refinement.lux
index 0b9601f1e..104a57b3e 100644
--- a/stdlib/source/documentation/lux/meta/type/refinement.lux
+++ b/stdlib/source/documentation/lux/meta/type/refinement.lux
@@ -24,30 +24,29 @@
($.definition /.refiner
""
- [(refiner predicate)])
+ ($.example (refiner predicate)))
($.definition /.lifted
(format "Yields a function that can work on refined values."
\n "Respects the constraints of the refinement.")
- [(lifted transform)])
+ ($.example (lifted transform)))
($.definition /.only
""
- [(only refiner values)])
+ ($.example (only refiner values)))
($.definition /.partition
"Separates refined values from the un-refined ones."
- [(partition refiner values)])
+ ($.example (partition refiner values)))
($.definition /.type
"The Refined type associated with a Refiner type."
- [(def even
- (refiner even?))
-
- (def Even
- Type
- (type even))
-
- (is (Maybe Even)
- (even 123))])
+
+ ($.example (def even
+ (refiner even?)))
+ ($.example (def Even
+ Type
+ (type even)))
+ ($.example (is (Maybe Even)
+ (even 123))))
))
diff --git a/stdlib/source/documentation/lux/meta/type/resource.lux b/stdlib/source/documentation/lux/meta/type/resource.lux
index ed1f271f3..c8e34ab6e 100644
--- a/stdlib/source/documentation/lux/meta/type/resource.lux
+++ b/stdlib/source/documentation/lux/meta/type/resource.lux
@@ -35,11 +35,11 @@
($.definition /.run!
""
- [(run! monad procedure)])
+ ($.example (run! monad procedure)))
($.definition /.lifted
""
- [(lifted monad procedure)])
+ ($.example (lifted monad procedure)))
($.definition /.Ordered
"The mode of keys which CANNOT be swapped, and for whom order of release/consumption matters.")
@@ -65,31 +65,31 @@
($.definition /.read
"Access the value of a resource, so long as its key is available."
- [(read monad resource)])
+ ($.example (read monad resource)))
($.definition /.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)))])
+ ($.example (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)))))
(,, (with_template [<name>]
[($.definition <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)))])]
+ ($.example (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]
diff --git a/stdlib/source/documentation/lux/meta/type/unit.lux b/stdlib/source/documentation/lux/meta/type/unit.lux
index 606184c7a..67157d892 100644
--- a/stdlib/source/documentation/lux/meta/type/unit.lux
+++ b/stdlib/source/documentation/lux/meta/type/unit.lux
@@ -54,15 +54,15 @@
($.definition /.unit
(format "Define a unit of measurement."
\n "Both the name of the type, and the name of the Unit implementation must be specified.")
- [(def feet (unit []))])
+ ($.example (def feet (unit []))))
... ($.definition /.scale
... "Define a scale of magnitude."
- ... [(def bajillion (scale [1 1,234,567,890]))])
+ ... ($.example (def bajillion (scale [1 1,234,567,890]))))
... ($.definition /.re_scaled
... ""
- ... [(re_scaled from to measure)])
+ ... ($.example (re_scaled from to measure)))
... (,, (with_template [<type> <scale>]
... [(`` ($.definition <scale>
diff --git a/stdlib/source/documentation/lux/program.lux b/stdlib/source/documentation/lux/program.lux
index d0ea5d8ac..365f2f478 100644
--- a/stdlib/source/documentation/lux/program.lux
+++ b/stdlib/source/documentation/lux/program.lux
@@ -22,33 +22,33 @@
($.definition \\parser.result
"Executes the parser and verifies that all inputs are processed."
- [(result parser inputs)])
+ ($.example (result parser inputs)))
($.definition \\parser.any
"Just returns the next input without applying any logic.")
($.definition \\parser.parse
"Parses the next input with a parsing function."
- [(parse parser)])
+ ($.example (parse parser)))
($.definition \\parser.this
"Checks that a token is in the inputs."
- [(this reference)])
+ ($.example (this reference)))
($.definition \\parser.somewhere
"Given a parser, tries to parse it somewhere in the inputs (i.e. not necessarily parsing the immediate inputs)."
- [(somewhere cli)])
+ ($.example (somewhere cli)))
($.definition \\parser.end
"Ensures there are no more inputs.")
($.definition \\parser.named
"Parses a named parameter and yields its value."
- [(named name value)])
+ ($.example (named name value)))
($.definition \\parser.parameter
"Parses a parameter that can have either a short or a long name."
- [(parameter [short long] value)])
+ ($.example (parameter [short long] value)))
))
(def .public documentation
@@ -58,18 +58,20 @@
($.definition /.program
"Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)."
- ["Can take a list of all the input parameters to the program."
- (def _
- (program all_arguments
- (do io.monad
- [foo (initialize program)]
- (do_something_with all_arguments))))]
- ["Can also parse them using CLI parsers from the library/lux/control/parser/cli module."
- (def _
- (program [config configuration_parser]
- (do io.monad
- [data (initialize program with config)]
- (do_something_with data))))])
+
+ ($.comment "Can take a list of all the input parameters to the program.")
+ ($.example (def _
+ (program all_arguments
+ (do io.monad
+ [foo (initialize program)]
+ (do_something_with all_arguments)))))
+
+ ($.comment "Can also parse them using CLI parsers from the library/lux/control/parser/cli module.")
+ ($.example (def _
+ (program [config configuration_parser]
+ (do io.monad
+ [data (initialize program with config)]
+ (do_something_with data))))))
..\\parser
))
diff --git a/stdlib/source/documentation/lux/test/property.lux b/stdlib/source/documentation/lux/test/property.lux
index b21fef1ec..6f7eca5a6 100644
--- a/stdlib/source/documentation/lux/test/property.lux
+++ b/stdlib/source/documentation/lux/test/property.lux
@@ -21,11 +21,11 @@
($.definition /.and
"Sequencing combinator."
- [(and left right)])
+ ($.example (and left right)))
($.definition /.context
"Adds a contextual description to a test's documentation."
- [(context description)])
+ ($.example (context description)))
($.definition /.failure
"A failing test, with a given error message.")
@@ -34,11 +34,11 @@
($.definition /.test
"Check that a condition is #1, and fail with the given message otherwise."
- [(test message condition)])
+ ($.example (test message condition)))
($.definition /.lifted
""
- [(lifted message random)])
+ ($.example (lifted message random)))
($.definition /.Seed
"The seed value used for random testing (if that feature is used).")
@@ -46,41 +46,41 @@
($.definition /.seed
(format "Execute the given test with a specific seed value."
\n "This allows you to reproduce a failing test case as many times as you want while debugging.")
- [(seed value test)])
+ ($.example (seed value test)))
($.definition /.times
(format "Allows executing a test several times."
\n "By doing this, it's possible to thoroughly test code with many different scenarios."
\n "This assumes that random data generation is being used in tests instead of fixed/constant inputs.")
- [(times amount test)])
+ ($.example (times amount test)))
($.definition /.run!
(format "Executes a test, and exits the program with either a successful or a failing exit code."
\n "WARNING: This procedure is only meant to be used in (program ...) forms.")
- [(run! test)])
+ ($.example (run! test)))
($.definition /.coverage
(format "Specifies a test as covering one or more definitions."
\n "Adds to the test tally information to track which definitions have been tested.")
- [(coverage [definition/0 definition/1 ,,, definition/N]
- (is Bit
- (some "computation")))])
+ ($.example (coverage [definition/0 definition/1 ,,, definition/N]
+ (is Bit
+ (some "computation")))))
($.definition /.for
(format "Specifies a context for tests as covering one or more definitions."
\n "Adds to the test tally information to track which definitions have been tested.")
- [(for [definition/0 definition/1 ,,, definition/N]
- (is Test
- some_test))])
+ ($.example (for [definition/0 definition/1 ,,, definition/N]
+ (is Test
+ some_test))))
($.definition /.covering
(format "Specifies the module being covered by a test."
\n "Adds tracking information to the tally to know which exported definitions in the module need to be covered.")
- [(covering .._
- (is Test
- some_test))])
+ ($.example (covering .._
+ (is Test
+ some_test))))
($.definition /.in_parallel
"Executes multiple tests in parallel (if the host platform supports it) to take advantage of multiple cores."
- [(in_parallel tests)])
+ ($.example (in_parallel tests)))
))
diff --git a/stdlib/source/documentation/lux/test/tally.lux b/stdlib/source/documentation/lux/test/tally.lux
index a13267544..56a10acee 100644
--- a/stdlib/source/documentation/lux/test/tally.lux
+++ b/stdlib/source/documentation/lux/test/tally.lux
@@ -18,7 +18,7 @@
($.definition /.and
""
- [(and left right)])
+ ($.example (and left right)))
($.definition /.empty)
($.definition /.success)
diff --git a/stdlib/source/documentation/lux/test/unit.lux b/stdlib/source/documentation/lux/test/unit.lux
index 2b5e9441a..e3d8b492a 100644
--- a/stdlib/source/documentation/lux/test/unit.lux
+++ b/stdlib/source/documentation/lux/test/unit.lux
@@ -18,32 +18,32 @@
($.definition /.and
"Sequencing combinator."
- [(and left right)])
+ ($.example (and left right)))
($.definition /.test
"Check that a condition is #1, and fail with the given message otherwise."
- [(test message condition)])
+ ($.example (test message condition)))
($.definition /.coverage
(format "Specifies a test as covering one or more definitions."
\n "Adds to the test tally information to track which definitions have been tested.")
- [(coverage [definition/0 definition/1 ,,, definition/N]
- (is Bit
- (some "computation")))])
+ ($.example (coverage [definition/0 definition/1 ,,, definition/N]
+ (is Bit
+ (some "computation")))))
($.definition /.for
(format "Specifies a context for tests as covering one or more definitions."
\n "Adds to the test tally information to track which definitions have been tested.")
- [(for [definition/0 definition/1 ,,, definition/N]
- (is Test
- some_test))])
+ ($.example (for [definition/0 definition/1 ,,, definition/N]
+ (is Test
+ some_test))))
($.definition /.covering
(format "Specifies the module being covered by a test."
\n "Adds tracking information to the tally to know which exported definitions in the module need to be covered.")
- [(covering .._
- (is Test
- some_test))])
+ ($.example (covering .._
+ (is Test
+ some_test))))
($.definition /.context)
($.definition /.success)
diff --git a/stdlib/source/documentation/lux/world/console.lux b/stdlib/source/documentation/lux/world/console.lux
index 77e62fac9..e38a8ea20 100644
--- a/stdlib/source/documentation/lux/world/console.lux
+++ b/stdlib/source/documentation/lux/world/console.lux
@@ -26,7 +26,7 @@
($.definition /.write_line
"Writes the message on the console and appends a new-line/line-feed at the end."
- [(write_line message console)])
+ ($.example (write_line message console)))
($.definition (/.Mock s)
(format "A mock/simulation of a console."
@@ -34,5 +34,5 @@
($.definition /.mock
""
- [(mock mock init)])
+ ($.example (mock mock init)))
))))
diff --git a/stdlib/source/documentation/lux/world/environment.lux b/stdlib/source/documentation/lux/world/environment.lux
index 6aa8ccf55..fd3056c1f 100644
--- a/stdlib/source/documentation/lux/world/environment.lux
+++ b/stdlib/source/documentation/lux/world/environment.lux
@@ -32,12 +32,12 @@
($.definition \\parser.property
""
- [(property name)])
+ ($.example (property name)))
($.definition \\parser.result
(format "Executes a parser against the given environment variables."
\n "Does not check whether all environment variables were parsed, since they're usually an open set.")
- [(result parser environment)])
+ ($.example (result parser environment)))
))
(def .public documentation
@@ -54,11 +54,11 @@
($.definition /.environment
"Assembles the environment variables available to the program."
- [(environment monad program)])
+ ($.example (environment monad program)))
($.definition /.mock
""
- [(mock environment home directory)])
+ ($.example (mock environment home directory)))
..\\parser
))
diff --git a/stdlib/source/documentation/lux/world/file.lux b/stdlib/source/documentation/lux/world/file.lux
index d5df3bca6..ec5999640 100644
--- a/stdlib/source/documentation/lux/world/file.lux
+++ b/stdlib/source/documentation/lux/world/file.lux
@@ -36,33 +36,33 @@
($.definition /.parent
"If a path represents a nested file/directory, extracts its parent directory."
- [(parent fs path)])
+ ($.example (parent fs path)))
($.definition /.name
"The un-nested name of a file/directory."
- [(name fs path)])
+ ($.example (name fs path)))
($.definition /.rooted
"A nested path for a file/directory, given a root/parent path and a file/directory name within it."
- [(rooted fs parent child)])
+ ($.example (rooted fs parent child)))
($.definition /.exists?
"Checks if either a file or a directory exists at the given path."
- [(exists? monad fs path)])
+ ($.example (exists? monad fs path)))
($.definition /.mock
(format "A purely in-memory simulation of a file-system."
\n "Useful for testing.")
- [(mock separator)])
+ ($.example (mock separator)))
($.definition /.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)])
+ ($.example (make_directories monad fs path)))
($.definition /.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)])
+ ($.example (make_file monad fs content path)))
/watch.documentation
))))
diff --git a/stdlib/source/documentation/lux/world/file/watch.lux b/stdlib/source/documentation/lux/world/file/watch.lux
index 7ef28a451..1fee00179 100644
--- a/stdlib/source/documentation/lux/world/file/watch.lux
+++ b/stdlib/source/documentation/lux/world/file/watch.lux
@@ -30,7 +30,7 @@
($.definition /.and
""
- [(and left right)])
+ ($.example (and left right)))
($.definition (/.Watcher !)
"Machinery for watching a file-system for changes to files and directories.")
@@ -38,12 +38,12 @@
($.definition /.polling
(format "A simple watcher that works for any file-system."
"Polls files and directories to detect changes.")
- [(polling fs)])
+ ($.example (polling fs)))
($.definition /.mock
(format "A fake/emulated watcher."
\n "Must be given a path separator for the file-system.")
- [(mock separator)])
+ ($.example (mock separator)))
(,, (for @.jvm (,, (these ($.definition /.default
"The default watcher for the default file-system.")))
diff --git a/stdlib/source/documentation/lux/world/locale.lux b/stdlib/source/documentation/lux/world/locale.lux
index 00d97af75..b3f9edcb4 100644
--- a/stdlib/source/documentation/lux/world/locale.lux
+++ b/stdlib/source/documentation/lux/world/locale.lux
@@ -27,7 +27,7 @@
($.definition /.locale
""
- [(locale language territory encoding)])
+ ($.example (locale language territory encoding)))
(list.together
(list /language.documentation
diff --git a/stdlib/source/documentation/lux/world/net.lux b/stdlib/source/documentation/lux/world/net.lux
index 65d6c4316..5669e3de9 100644
--- a/stdlib/source/documentation/lux/world/net.lux
+++ b/stdlib/source/documentation/lux/world/net.lux
@@ -21,13 +21,13 @@
(list.partial ($.module /._
"")
- ($.definition /.Location)
+ ($.definition /.Host)
($.definition /.Address
"A TCP/IP address.")
- ($.definition /.Port
- "A TCP/IP port.")
+ ... ($.definition /.Port
+ ... "A TCP/IP port.")
($.definition /.URL
"A Uniform Resource Locator.")
diff --git a/stdlib/source/documentation/lux/world/net/uri.lux b/stdlib/source/documentation/lux/world/net/uri.lux
index a3cd0ecac..bfff9183e 100644
--- a/stdlib/source/documentation/lux/world/net/uri.lux
+++ b/stdlib/source/documentation/lux/world/net/uri.lux
@@ -16,6 +16,6 @@
($.definition /.URI
"A Uniform Resource Identifier.")
- ($.definition /.separator
- "A separator for the pieces of a URI.")
+ ... ($.definition /.separator
+ ... "A separator for the pieces of a URI.")
))
diff --git a/stdlib/source/documentation/lux/world/shell.lux b/stdlib/source/documentation/lux/world/shell.lux
index 7be466440..9c9a7c34f 100644
--- a/stdlib/source/documentation/lux/world/shell.lux
+++ b/stdlib/source/documentation/lux/world/shell.lux
@@ -42,5 +42,5 @@
($.definition /.mock
""
- [(mock mock init)])
+ ($.example (mock mock init)))
))))
diff --git a/stdlib/source/documentation/lux/world/time.lux b/stdlib/source/documentation/lux/world/time.lux
index de12b24a0..5b629ebdc 100644
--- a/stdlib/source/documentation/lux/world/time.lux
+++ b/stdlib/source/documentation/lux/world/time.lux
@@ -50,18 +50,18 @@
($.definition /.of_millis
""
- [(of_millis milli_seconds)])
+ ($.example (of_millis milli_seconds)))
($.definition /.Clock
"A clock marking the specific hour, minute, second, and milli-second in a day.")
($.definition /.clock
""
- [(clock time)])
+ ($.example (clock time)))
($.definition /.time
""
- [(time clock)])
+ ($.example (time clock)))
($.definition /.codec
(format "Based on ISO 8601."
diff --git a/stdlib/source/documentation/lux/world/time/date.lux b/stdlib/source/documentation/lux/world/time/date.lux
index af7765e36..c63a8bcad 100644
--- a/stdlib/source/documentation/lux/world/time/date.lux
+++ b/stdlib/source/documentation/lux/world/time/date.lux
@@ -31,7 +31,7 @@
($.definition /.date
"A date, within the allowed limits."
- [(date year month day_of_month)])
+ ($.example (date year month day_of_month)))
($.definition /.codec
(format "Based on ISO 8601."
diff --git a/stdlib/source/documentation/lux/world/time/duration.lux b/stdlib/source/documentation/lux/world/time/duration.lux
index a8dc682d2..37aeeca54 100644
--- a/stdlib/source/documentation/lux/world/time/duration.lux
+++ b/stdlib/source/documentation/lux/world/time/duration.lux
@@ -44,5 +44,5 @@
($.definition /.difference
""
- [(difference from to)])
+ ($.example (difference from to)))
))
diff --git a/stdlib/source/documentation/lux/world/time/instant.lux b/stdlib/source/documentation/lux/world/time/instant.lux
index 71efafd6c..34d224379 100644
--- a/stdlib/source/documentation/lux/world/time/instant.lux
+++ b/stdlib/source/documentation/lux/world/time/instant.lux
@@ -27,19 +27,19 @@
($.definition /.span
""
- [(span from to)])
+ ($.example (span from to)))
($.definition /.after
""
- [(after duration instant)])
+ ($.example (after duration instant)))
($.definition /.relative
""
- [(relative instant)])
+ ($.example (relative instant)))
($.definition /.absolute
""
- [(absolute offset)])
+ ($.example (absolute offset)))
($.definition /.epoch
"The instant corresponding to 1970-01-01T00:00:00Z.")
@@ -53,5 +53,5 @@
($.definition /.of_date_time
""
- [(of_date_time date time)])
+ ($.example (of_date_time date time)))
))
diff --git a/stdlib/source/documentation/lux/world/time/month.lux b/stdlib/source/documentation/lux/world/time/month.lux
index 60f1dcdea..b73668801 100644
--- a/stdlib/source/documentation/lux/world/time/month.lux
+++ b/stdlib/source/documentation/lux/world/time/month.lux
@@ -28,11 +28,11 @@
($.definition /.days
"The amount of days of a month."
- [(days month)])
+ ($.example (days month)))
($.definition /.leap_year_days
"The amount of days of a month (in a leap year)."
- [(leap_year_days month)])
+ ($.example (leap_year_days month)))
($.definition /.year
"All the months, ordered by when they come in a year.")
diff --git a/stdlib/source/documentation/lux/world/time/year.lux b/stdlib/source/documentation/lux/world/time/year.lux
index 370c1cd2b..114299fed 100644
--- a/stdlib/source/documentation/lux/world/time/year.lux
+++ b/stdlib/source/documentation/lux/world/time/year.lux
@@ -31,7 +31,7 @@
($.definition /.year
"A valid year in the gregorian calendar, if possible."
- [(year value)])
+ ($.example (year value)))
($.definition /.days
"The amount of days in a typical year.")
@@ -41,7 +41,7 @@
($.definition /.leaps
"The number of leap years in a period of years."
- [(leaps year)])
+ ($.example (leaps year)))
($.definition /.codec
(format "Based on ISO 8601."
diff --git a/stdlib/source/library/lux/control/aspect.lux b/stdlib/source/library/lux/control/aspect.lux
index eda6a78c7..df37fce28 100644
--- a/stdlib/source/library/lux/control/aspect.lux
+++ b/stdlib/source/library/lux/control/aspect.lux
@@ -35,16 +35,10 @@
(type .public (Advice value)
(-> value value))
-(type .public After
- Advice)
-
-(type .public (Around input output)
- (Advice (-> input output)))
-
(def .public (before pre)
(All (_ input output)
(-> (-> input input)
- (Around input output)))
+ (Advice (-> input output))))
(function (_ it input)
(it (pre input))))
diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux
index da27d4a1a..200daa9eb 100644
--- a/stdlib/source/library/lux/documentation.lux
+++ b/stdlib/source/library/lux/documentation.lux
@@ -1,6 +1,7 @@
(.require
[library
- [lux (.except Definition Module Declaration #Definition #module)
+ [lux (.except Definition Module Declaration #Definition #module comment)
+ ["[0]" debug]
[abstract
[monad (.only do)]
["[0]" enum]]
@@ -133,22 +134,30 @@
[syntax.open_tuple syntax.close_tuple .#Tuple])
))
-(def blank_line
- Text
- (format \n \n))
-
-(def (fragment_documentation module fragment)
- (-> Text Fragment Text)
- (when fragment
- {#Comment comment}
- (format "... " comment)
-
- {#Code example}
- (let [reference_column (..reference_column example)
- [location _] example]
- (|> example
- (..code_documentation module (has .#column reference_column location) reference_column)
- product.right))))
+(def .public (comment it module)
+ (-> Text
+ (-> Text (Markdown Block)))
+ (<| (md.code "clojure")
+ (format "... " it)))
+
+(def (example' it module)
+ (-> Code
+ (-> Text (Markdown Block)))
+ (<| (md.code "clojure")
+ (let [reference_column (..reference_column it)
+ [location _] it]
+ (|> it
+ (..code_documentation module (has .#column reference_column location) reference_column)
+ product.right))))
+
+(def .public example
+ (template (_ it)
+ [((debug.private ..example') (' it))]))
+
+(def .public (deprecated when module)
+ (-> Text
+ (-> Text (Markdown Block)))
+ (md.paragraph (md.text (format "Deprecated: " when))))
(def parameter_type_name
(-> Nat Text)
@@ -455,30 +464,6 @@
_
(in name))))
-(def example_separator
- Code
- (let [c/01 "...."
- c/04 (format c/01 c/01 c/01 c/01)
- c_16 (format c/04 c/04 c/04 c/04)]
- (code.text (format blank_line
- c_16 \n c_16
- blank_line))))
-
-(.type Example
- (List Fragment))
-
-(def example
- (Parser Example)
- (<code>.tuple (<>.many ..fragment)))
-
-(def (example_documentation module example)
- (-> Text Example Code)
- (|> example
- (list#each (..fragment_documentation module))
- (list.interposed ..blank_line)
- (text.interposed "")
- code.text))
-
(.type Declaration
[Symbol (List Text)])
@@ -527,9 +512,10 @@
(def definition_documentation
(syntax (_ [[name parameters] ..declaration
description ..description
- examples (<>.some ..example)])
+ examples (<>.some <code>.any)])
(do meta.monad
- [minimal (expansion.single (` (..minimal_definition_documentation
+ [.let [module (product.left name)]
+ minimal (expansion.single (` (..minimal_definition_documentation
((, (code.symbol name))
(,* (list#each code.local parameters))))))]
(in (list (` (all md.then
@@ -549,10 +535,11 @@
(list)
_
- (list (` (<| (md.code "clojure")
- (%.format (,* (|> examples
- (list#each (..example_documentation (product.left name)))
- (list.interposed ..example_separator))))))))))
+ (list (` (all md.then
+ (,* (list#each (function (_ example)
+ (` ((, example) (, (code.text module)))))
+ examples))
+ ))))))
))))))
(.type .public Definition
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index cade6f127..21a2db376 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -510,12 +510,20 @@
{.#Default _}
{.#None}))
it)]]
- (monad.each ! (function (_ [name exported? it])
+ (monad.each ! (function (again [name [exported? it]])
(when it
{.#Left de_aliased}
(do !
- [de_aliased (export de_aliased)]
- (in [name [exported? de_aliased]]))
+ [[_ definition] (..definition de_aliased)]
+ (when definition
+ {.#Alias de_aliased}
+ (again [name [exported? {.#Left de_aliased}]])
+
+ {.#Definition definition}
+ (in [name [exported? definition]])
+
+ {.#Default _}
+ (undefined)))
{.#Right definition}
(in [name [exported? definition]])))
diff --git a/stdlib/source/library/lux/test/unit.lux b/stdlib/source/library/lux/test/unit.lux
index 14b09f014..86df9efd0 100644
--- a/stdlib/source/library/lux/test/unit.lux
+++ b/stdlib/source/library/lux/test/unit.lux
@@ -152,7 +152,7 @@
test <code>.any])
(do meta.monad
[.let [module (symbol.module module)]
- definitions (meta.definitions module)
+ definitions (meta.resolved_globals module)
.let [coverage (|> definitions
(list#mix (function (_ [short [exported? _]] aggregate)
(if exported?
diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux
deleted file mode 100644
index bcb7aa4a8..000000000
--- a/stdlib/source/library/lux/world/net/http/route.lux
+++ /dev/null
@@ -1,77 +0,0 @@
-(.require
- [library
- [lux (.except or)
- [control
- [monad (.only do)]
- ["[0]" maybe]
- [concurrency
- ["[0]" async]]]
- [data
- ["[0]" text]
- [number
- ["n" nat]]]
- [meta
- [macro
- ["^" pattern]]]]]
- ["[0]" // (.only URI Server)
- ["[1][0]" status]
- ["[1][0]" response]])
-
-(with_template [<scheme> <name>]
- [(def .public (<name> server)
- (-> Server Server)
- (function (_ (^.let request [identification protocol resource message]))
- (when (the //.#scheme protocol)
- {<scheme>}
- (server request)
-
- _
- (async.resolved //response.not_found))))]
-
- [//.#HTTP http]
- [//.#HTTPS https]
- )
-
-(with_template [<method> <name>]
- [(def .public (<name> server)
- (-> Server Server)
- (function (_ (^.let request [identification protocol resource message]))
- (when (the //.#method resource)
- {<method>}
- (server request)
-
- _
- (async.resolved //response.not_found))))]
-
- [//.#Get get]
- [//.#Post post]
- [//.#Put put]
- [//.#Patch patch]
- [//.#Delete delete]
- [//.#Head head]
- [//.#Connect connect]
- [//.#Options options]
- [//.#Trace trace]
- )
-
-(def .public (uri path server)
- (-> URI Server Server)
- (function (_ [identification protocol resource message])
- (if (text.starts_with? path (the //.#uri resource))
- (server [identification
- protocol
- (revised //.#uri
- (|>> (text.clip_since (text.size path)) maybe.trusted)
- resource)
- message])
- (async.resolved //response.not_found))))
-
-(def .public (or primary alternative)
- (-> Server Server Server)
- (function (_ request)
- (do async.monad
- [response (primary request)
- .let [[status message] response]]
- (if (n.= //status.not_found status)
- (alternative request)
- (in response)))))
diff --git a/stdlib/source/library/lux/world/net/http/server.lux b/stdlib/source/library/lux/world/net/http/server.lux
new file mode 100644
index 000000000..43c2b7816
--- /dev/null
+++ b/stdlib/source/library/lux/world/net/http/server.lux
@@ -0,0 +1,193 @@
+(.require
+ [library
+ [lux (.except or static)
+ [abstract
+ ["[0]" monad (.only Monad do)]]
+ [control
+ ["[0]" maybe]
+ ["[0]" try (.only Try)]]
+ [data
+ ["[0]" text (.only)
+ [encoding
+ ["[0]" utf8 (.use "[1]#[0]" codec)]]]
+ [collection
+ ["[0]" list (.use "[1]#[0]" functor mix)]
+ ["[0]" dictionary]]
+ [format
+ ["[0]" json (.only JSON) (.use "[1]#[0]" codec)
+ ["?[1]" \\parser]]]]
+ [math
+ [number
+ ["n" nat]]]
+ [meta
+ [macro
+ ["^" pattern]]]
+ [world
+ ["[0]" environment
+ ["?[1]" \\parser]]]]]
+ ["[0]" // (.only Body)
+ ["[0]" status]
+ ["[0]" cookie]
+ ["[0]" request (.only Request)]
+ ["[0]" response (.only Response)]
+ [//
+ [uri (.only URI)
+ ["[0]" scheme (.use "[1]#[0]" equivalence)]
+ ["[0]" query (.use "[1]#[0]" codec)]]]])
+
+(type .public (Server !)
+ (-> (Monad !) (Request !)
+ (! (Response !))))
+
+(with_template [<scheme> <name>]
+ [(def .public (<name> server)
+ (All (_ !)
+ (-> (Server !)
+ (Server !)))
+ (function (_ ! request)
+ (if (scheme#= <scheme> (the [request.#protocol //.#scheme] request))
+ (server ! request)
+ (at ! in (response.not_found !)))))]
+
+ [scheme.http http]
+ [scheme.https https]
+ )
+
+(with_template [<method> <name>]
+ [(def .public (<name> server)
+ (All (_ !)
+ (-> (Server !)
+ (Server !)))
+ (function (_ ! request)
+ (when (the [request.#resource //.#method] request)
+ {<method>}
+ (server ! request)
+
+ _
+ (at ! in (response.not_found !)))))]
+
+ [//.#Get get]
+ [//.#Post post]
+ [//.#Put put]
+ [//.#Patch patch]
+ [//.#Delete delete]
+ [//.#Head head]
+ [//.#Connect connect]
+ [//.#Options options]
+ [//.#Trace trace]
+ )
+
+(def .public (uri path server)
+ (All (_ !)
+ (-> URI (Server !)
+ (Server !)))
+ (function (_ ! request)
+ (if (text.starts_with? path (the [request.#resource //.#uri] request))
+ (server ! (revised [request.#resource //.#uri]
+ (|>> (text.clip_since (text.size path))
+ maybe.trusted)
+ request))
+ (at ! in (response.not_found !)))))
+
+(def .public (or primary alternative)
+ (All (_ !)
+ (-> (Server !) (Server !)
+ (Server !)))
+ (function (_ ! request)
+ (do !
+ [response (primary ! request)
+ .let [[status message] response]]
+ (if (n.= status.not_found status)
+ (alternative ! request)
+ (in response)))))
+
+(def .public (static response)
+ (All (_ !)
+ (-> (Response !)
+ (Server !)))
+ (function (_ ! request)
+ (at ! in response)))
+
+(def (body_text ! body)
+ (All (_ !)
+ (-> (Monad !) (Body !)
+ (! (Try Text))))
+ (do !
+ [blob (body {.#None})]
+ (in (do try.monad
+ [[_ blob] blob]
+ (utf8#decoded blob)))))
+
+(def (failure !)
+ (All (_ !)
+ (-> (Monad !)
+ (Response !)))
+ (response.bad_request ! ""))
+
+(def .public (query parser server)
+ (All (_ ! of)
+ (-> (?environment.Parser of) (-> of (Server !))
+ (Server !)))
+ (function (_ ! request)
+ (let [full (the [request.#resource //.#uri] request)
+ [uri query] (|> full
+ (text.split_by "?")
+ (maybe.else [full ""]))]
+ (when (do try.monad
+ [query (query#decoded query)
+ input (?environment.result parser query)]
+ (in [(has [request.#resource //.#uri] uri request)
+ input]))
+ {try.#Success [request input]}
+ (server input ! request)
+
+ {try.#Failure error}
+ (at ! in (..failure !))))))
+
+(def .public (text server)
+ (All (_ !)
+ (-> (-> Text (Server !))
+ (Server !)))
+ (function (_ ! request)
+ (do !
+ [?raw (body_text ! (the [request.#message //.#body] request))]
+ (when ?raw
+ {try.#Success content}
+ (server content ! request)
+
+ {try.#Failure error}
+ (at ! in (..failure !))))))
+
+(def .public (form parser server)
+ (All (_ ! of)
+ (-> (?environment.Parser of) (-> of (Server !))
+ (Server !)))
+ (function (_ ! request)
+ (do !
+ [?body (body_text ! (the [request.#message //.#body] request))]
+ (when (do try.monad
+ [body ?body
+ form (query#decoded body)]
+ (?environment.result parser form))
+ {try.#Success input}
+ (server input ! request)
+
+ {try.#Failure error}
+ (at ! in (..failure !))))))
+
+(def .public (json parser server)
+ (All (_ ! of)
+ (-> (?json.Parser of) (-> of (Server !))
+ (Server !)))
+ (function (_ ! request)
+ (do !
+ [?raw (body_text ! (the [request.#message //.#body] request))]
+ (when (do try.monad
+ [raw ?raw
+ content (json#decoded raw)]
+ (?json.result parser content))
+ {try.#Success input}
+ (server input ! request)
+
+ {try.#Failure error}
+ (at ! in (..failure !))))))
diff --git a/stdlib/source/specification/lux/abstract/hash.lux b/stdlib/source/specification/lux/abstract/hash.lux
index d95fef663..2b6aa5cd6 100644
--- a/stdlib/source/specification/lux/abstract/hash.lux
+++ b/stdlib/source/specification/lux/abstract/hash.lux
@@ -2,7 +2,9 @@
[library
[lux (.except)
[abstract
- [monad (.only do)]]
+ [monad (.only do)]
+ [\\specification
+ ["[0]S" equivalence]]]
[math
["[0]" random (.only Random)]
[number
@@ -12,12 +14,16 @@
[\\library
["[0]" /]])
-(def .public (spec (open "_#[0]") random)
+(def .public (spec (open "/#[0]") random)
(All (_ a) (-> (/.Hash a) (Random a) Test))
(do random.monad
[parameter random
subject random]
- (_.coverage [/.Hash]
- (if (_#= parameter subject)
- (n.= (_#hash parameter) (_#hash subject))
- true))))
+ (all _.and
+ (_.for [/.equivalence]
+ (equivalenceS.spec /#equivalence random))
+ (_.coverage [/.Hash /.hash]
+ (if (/#= parameter subject)
+ (n.= (/#hash parameter) (/#hash subject))
+ true))
+ )))
diff --git a/stdlib/source/test/lux/control/aspect.lux b/stdlib/source/test/lux/control/aspect.lux
index a98d83918..badd4ba8d 100644
--- a/stdlib/source/test/lux/control/aspect.lux
+++ b/stdlib/source/test/lux/control/aspect.lux
@@ -23,7 +23,7 @@
["[0]" /]])
(def (double it)
- (/.After Nat)
+ (/.Advice Nat)
(n.+ it it))
(def can_double
@@ -41,7 +41,7 @@
(all n.+ it it it))
(def pre_double
- (/.Around Nat Nat)
+ (/.Advice (-> Nat Nat))
(/.before ..double))
(def after_aspect
@@ -77,7 +77,7 @@
(all _.and
(_.for [/.with]
(all _.and
- (_.for [/.Advice /.After]
+ (_.for [/.Advice]
(_.for [/.Reference /.#name /.#type
/.Scenario /.#Global /.#Local]
(all _.and
@@ -89,7 +89,7 @@
(n.= (double ..global)
(/.with ..after_aspect
..global))))))
- (_.coverage [/.Around /.before]
+ (_.coverage [/.before]
(n.= (triple (double local))
(/.with ..before_aspect
(triple local))))
diff --git a/stdlib/source/test/lux/world/net.lux b/stdlib/source/test/lux/world/net.lux
index ea22fbca4..695308c40 100644
--- a/stdlib/source/test/lux/world/net.lux
+++ b/stdlib/source/test/lux/world/net.lux
@@ -19,7 +19,8 @@
["[1]/[0]" status]
["[1]/[0]" version]
["[1]/[0]" response]
- ["[1]/[0]" request]]])
+ ["[1]/[0]" request]
+ ["[1]/[0]" server]]])
(def .public test
Test
@@ -43,6 +44,7 @@
/http/version.test
/http/response.test
/http/request.test
+ /http/server.test
/uri.test
)))
diff --git a/stdlib/source/test/lux/world/net/http/server.lux b/stdlib/source/test/lux/world/net/http/server.lux
new file mode 100644
index 000000000..63f0d76ed
--- /dev/null
+++ b/stdlib/source/test/lux/world/net/http/server.lux
@@ -0,0 +1,393 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only Monad do)]]
+ [control
+ ["[0]" try]
+ [concurrency
+ ["[0]" async (.only Async)]]]
+ [data
+ ["[0]" text (.use "[1]#[0]" equivalence)
+ ["%" \\format]
+ [encoding
+ ["[0]" utf8 (.use "[1]#[0]" codec)]]]
+ ["[0]" binary (.only Binary) (.use "[1]#[0]" equivalence)
+ ["[1]T" \\test]]
+ [collection
+ ["[0]" dictionary]]
+ [format
+ ["[0]" json (.use "[1]#[0]" equivalence codec)
+ ["?[1]" \\parser]
+ ["[1]T" \\test]]]]
+ [math
+ ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
+ [number
+ ["n" nat]]]
+ [test
+ ["_" property (.only Test)]
+ ["[0]" unit]]
+ [world
+ ["[0]" environment
+ ["?[1]" \\parser]]]]]
+ [\\library
+ ["[0]" / (.only)
+ ["/[1]" // (.only)
+ ["[0]" header]
+ ["[0]" response]
+ ["[0]" request (.only Request)]
+ ["[0]" version
+ ["[1]T" \\test]]
+ ["[0]" status (.only)
+ ["[1]T" \\test]]
+ ["/[1]" // (.only)
+ ["[0]" mime (.only)
+ ["[1]T" \\test]]
+ ["[0]" uri (.only)
+ ["[0]" query]
+ ["[0]" scheme (.only)
+ ["[1]T" \\test]]
+ ["[0]" port
+ ["[1]T" \\test]]]]]]])
+
+(def address
+ (Random ///.Address)
+ (all random.and
+ (random.lower_cased 1)
+ portT.random
+ ))
+
+(def identification
+ (Random //.Identification)
+ (all random.and
+ ..address
+ ..address
+ ))
+
+(def protocol
+ (Random //.Protocol)
+ (all random.and
+ versionT.random
+ schemeT.random
+ ))
+
+(def method
+ (Random //.Method)
+ (all random.either
+ (random#in {//.#Post})
+ (random#in {//.#Get})
+ (random#in {//.#Put})
+ (random#in {//.#Patch})
+ (random#in {//.#Delete})
+ (random#in {//.#Head})
+ (random#in {//.#Connect})
+ (random#in {//.#Options})
+ (random#in {//.#Trace})
+ ))
+
+(def resource
+ (Random //.Resource)
+ (all random.and
+ ..method
+ (random.lower_cased 2)
+ ))
+
+(def (message ! body)
+ (All (_ !)
+ (-> (Monad !) Binary
+ (Random (//.Message !))))
+ (all random.and
+ (random#in header.empty)
+ (random#in (function (_ _)
+ (at ! in {try.#Success [(binary.size body) body]})))
+ ))
+
+(def data
+ (Random [Nat Binary])
+ (do random.monad
+ [size (random#each (n.% 10) random.nat)
+ data (random.upper_cased size)]
+ (in [size (utf8#encoded data)])))
+
+(def (request !)
+ (All (_ !)
+ (-> (Monad !)
+ (Random (/.Request !))))
+ (all random.and
+ ..identification
+ ..protocol
+ ..resource
+ (do random.monad
+ [[_ data] ..data]
+ (message ! data))
+ ))
+
+(def scheme_test
+ Test
+ (<| (do [! random.monad]
+ [expected_request (..request async.monad)
+ expected_status statusT.random
+ expected_mime mimeT.random
+ [expected_data_size expected_data] ..data
+ .let [expected_server (is /.Server
+ (function (_ ! request)
+ (at ! in (response.content ! expected_status expected_mime expected_data))))]])
+ (`` (all _.and
+ (,, (with_template [<server> <scheme>]
+ [(in (do [! async.monad]
+ [good_response (let [expected_request (has [request.#protocol //.#scheme] <scheme> expected_request)]
+ (<server> expected_server ! expected_request))
+ good_body ((the [response.#message //.#body] good_response) {.#None})
+
+ bad_response (let [expected_request (has [request.#protocol //.#scheme] scheme.file expected_request)]
+ (<server> expected_server ! expected_request))]
+ (unit.coverage [<server>]
+ (and (n.= expected_status
+ (the response.#status good_response))
+ (when good_body
+ {try.#Success [actual_data_size actual_data]}
+ (and (n.= expected_data_size actual_data_size)
+ (binary#= expected_data actual_data))
+
+ {try.#Failure error}
+ false)
+
+ (n.= status.not_found
+ (the response.#status bad_response))
+ ))))]
+
+ [/.http scheme.http]
+ [/.https scheme.https]
+ ))
+ ))))
+
+(def method_test
+ Test
+ (<| (do [! random.monad]
+ [expected_request (..request async.monad)
+ expected_status statusT.random
+ expected_mime mimeT.random
+ [expected_data_size expected_data] ..data
+ .let [expected_server (is /.Server
+ (function (_ ! request)
+ (at ! in (response.content ! expected_status expected_mime expected_data))))]])
+ (`` (all _.and
+ (,, (with_template [<server> <correct_method> <incorrect_method>]
+ [(in (do [! async.monad]
+ [good_response (let [expected_request (has [request.#resource //.#method] {<correct_method>} expected_request)]
+ (<server> expected_server ! expected_request))
+ good_body ((the [response.#message //.#body] good_response) {.#None})
+
+ bad_response (let [expected_request (has [request.#resource //.#method] {<incorrect_method>} expected_request)]
+ (<server> expected_server ! expected_request))]
+ (unit.coverage [<server>]
+ (and (n.= expected_status
+ (the response.#status good_response))
+ (when good_body
+ {try.#Success [actual_data_size actual_data]}
+ (and (n.= expected_data_size actual_data_size)
+ (binary#= expected_data actual_data))
+
+ {try.#Failure error}
+ false)
+
+ (n.= status.not_found
+ (the response.#status bad_response))
+ ))))]
+
+ [/.get //.#Get //.#Trace]
+ [/.post //.#Post //.#Trace]
+ [/.put //.#Put //.#Trace]
+ [/.patch //.#Patch //.#Trace]
+ [/.delete //.#Delete //.#Trace]
+ [/.head //.#Head //.#Trace]
+ [/.connect //.#Connect //.#Trace]
+ [/.options //.#Options //.#Trace]
+ [/.trace //.#Trace //.#Get]
+ ))
+ ))))
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [expected_request (..request async.monad)
+ expected_status statusT.random
+ expected_mime mimeT.random
+ [expected_data_size expected_data] ..data
+ .let [expected_server (is /.Server
+ (function (_ ! request)
+ (at ! in (response.content ! expected_status expected_mime expected_data))))]])
+ (_.for [/.Server])
+ (`` (all _.and
+ ..scheme_test
+ ..method_test
+ (do !
+ [bad_uri (random.upper_cased 2)
+ good_uri (random.upper_cased 3)]
+ (in (do [! async.monad]
+ [good_response (let [expected_request (has [request.#resource //.#uri] good_uri expected_request)]
+ (/.uri good_uri expected_server ! expected_request))
+ good_body ((the [response.#message //.#body] good_response) {.#None})
+
+ bad_response (let [expected_request (has [request.#resource //.#uri] bad_uri expected_request)]
+ (/.uri good_uri expected_server ! expected_request))]
+ (unit.coverage [/.uri]
+ (and (n.= expected_status
+ (the response.#status good_response))
+ (when good_body
+ {try.#Success [actual_data_size actual_data]}
+ (and (n.= expected_data_size actual_data_size)
+ (binary#= expected_data actual_data))
+
+ {try.#Failure error}
+ false)
+
+ (n.= status.not_found
+ (the response.#status bad_response))
+ )))))
+ (in (do [! async.monad]
+ [.let [server (is /.Server
+ (/.or (/.http expected_server)
+ (/.https expected_server)))]
+ http_response (server ! (has [request.#protocol //.#scheme] scheme.http expected_request))
+ http_body ((the [response.#message //.#body] http_response) {.#None})
+
+ https_response (server ! (has [request.#protocol //.#scheme] scheme.https expected_request))
+ https_body ((the [response.#message //.#body] https_response) {.#None})
+
+ bad_response (server ! (has [request.#protocol //.#scheme] scheme.file expected_request))]
+ (unit.coverage [/.or]
+ (let [correct_http_status!
+ (n.= expected_status
+ (the response.#status http_response))
+
+ correct_http_body!
+ (when http_body
+ {try.#Success [actual_data_size actual_data]}
+ (and (n.= expected_data_size actual_data_size)
+ (binary#= expected_data actual_data))
+
+ {try.#Failure error}
+ false)
+
+ correct_https_status!
+ (n.= expected_status
+ (the response.#status https_response))
+
+ correct_https_body!
+ (when https_body
+ {try.#Success [actual_data_size actual_data]}
+ (and (n.= expected_data_size actual_data_size)
+ (binary#= expected_data actual_data))
+
+ {try.#Failure error}
+ false)
+
+ not_found!
+ (n.= status.not_found
+ (the response.#status bad_response))]
+ (and correct_http_status!
+ correct_http_body!
+
+ correct_https_status!
+ correct_https_body!
+
+ not_found!)))))
+ (in (do [! async.monad]
+ [.let [server (is (/.Server Async)
+ (/.static (response.content ! expected_status expected_mime expected_data)))]
+ response (server ! (has [request.#protocol //.#scheme] scheme.http expected_request))
+ body ((the [response.#message //.#body] response) {.#None})]
+ (unit.coverage [/.static]
+ (and (n.= expected_status
+ (the response.#status response))
+ (when body
+ {try.#Success [actual_data_size actual_data]}
+ (and (n.= expected_data_size actual_data_size)
+ (binary#= expected_data actual_data))
+
+ {try.#Failure error}
+ false)
+ ))))
+ (do !
+ [path (random.upper_cased 4)
+ expected_property (random.lower_cased 5)
+ expected_value (random.lower_cased 6)
+ .let [uri (uri.uri scheme.http {.#None} path
+ {.#Some (|> query.empty
+ (dictionary.has expected_property expected_value))}
+ {.#None})]]
+ (in (do [! async.monad]
+ [.let [server (is (/.Server Async)
+ (/.query (?environment.property expected_property)
+ (function (_ actual_value)
+ (/.static (response.text ! actual_value)))))]
+ response (server ! (request.uri uri expected_request))
+ body ((the [response.#message //.#body] response) {.#None})]
+ (unit.coverage [/.query]
+ (and (n.= status.ok
+ (the response.#status response))
+ (<| (try.else false)
+ (do try.monad
+ [[_ actual_value] body
+ actual_value (utf8#decoded actual_value)]
+ (in (text#= expected_value actual_value))))
+ )))))
+ (do !
+ [expected (random.lower_cased 7)]
+ (in (do [! async.monad]
+ [.let [server (is (/.Server Async)
+ (/.text (function (_ actual)
+ (/.static (response.text ! actual)))))]
+ response (server ! (request.text ! expected))
+ body ((the [response.#message //.#body] response) {.#None})]
+ (unit.coverage [/.text]
+ (and (n.= status.ok
+ (the response.#status response))
+ (<| (try.else false)
+ (do try.monad
+ [[_ actual] body
+ actual (utf8#decoded actual)]
+ (in (text#= expected actual))))
+ )))))
+ (do !
+ [expected jsonT.random]
+ (in (do [! async.monad]
+ [.let [server (is (/.Server Async)
+ (/.json ?json.any
+ (function (_ actual)
+ (/.static (response.json ! actual)))))]
+ response (server ! (request.json ! expected))
+ body ((the [response.#message //.#body] response) {.#None})]
+ (unit.coverage [/.json]
+ (and (n.= status.ok
+ (the response.#status response))
+ (<| (try.else false)
+ (do try.monad
+ [[_ actual] body
+ actual (utf8#decoded actual)
+ actual (json#decoded actual)]
+ (in (json#= expected actual))))
+ )))))
+ (do !
+ [expected_property (random.lower_cased 8)
+ expected_value (random.lower_cased 9)]
+ (in (do [! async.monad]
+ [.let [server (is (/.Server Async)
+ (/.form (?environment.property expected_property)
+ (function (_ actual_value)
+ (/.static (response.text ! actual_value)))))]
+ response (server ! (request.form ! (|> query.empty
+ (dictionary.has expected_property expected_value))))
+ body ((the [response.#message //.#body] response) {.#None})]
+ (unit.coverage [/.form]
+ (and (n.= status.ok
+ (the response.#status response))
+ (<| (try.else false)
+ (do try.monad
+ [[_ actual_value] body
+ actual_value (utf8#decoded actual_value)]
+ (in (text#= expected_value actual_value))))
+ )))))
+ ))))