diff options
Diffstat (limited to '')
10 files changed, 205 insertions, 200 deletions
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> |