diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/documentation/lux/meta/type/primitive.lux | 157 |
1 files changed, 80 insertions, 77 deletions
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))))) ))) |