aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation
diff options
context:
space:
mode:
authorEduardo Julian2021-09-08 03:08:13 -0400
committerEduardo Julian2021-09-08 03:08:13 -0400
commit392582885500d8201bbe502943ca4b02c5c77ac0 (patch)
tree6e7410546048547560c767dba9c303d3f2f9597a /stdlib/source/documentation
parent609cc6c16e75c13d87183c38245136fa038b0496 (diff)
Normalized the syntax of "abstract:" and "actor:".
Diffstat (limited to '')
-rw-r--r--stdlib/source/documentation/lux/control/concurrency/actor.lux38
-rw-r--r--stdlib/source/documentation/lux/type/abstract.lux106
2 files changed, 64 insertions, 80 deletions
diff --git a/stdlib/source/documentation/lux/control/concurrency/actor.lux b/stdlib/source/documentation/lux/control/concurrency/actor.lux
index 240b1aefe..1bbb4febe 100644
--- a/stdlib/source/documentation/lux/control/concurrency/actor.lux
+++ b/stdlib/source/documentation/lux/control/concurrency/actor.lux
@@ -47,35 +47,31 @@
\n "but allows the actor to handle previous mail."))
(with_expansions [<examples> (as_is (actor: .public (stack a)
- {}
-
(List a)
- ((on_mail mail state self)
- (do (try.with async.monad)
- [.let [_ (debug.log! "BEFORE")]
- output (mail state self)
- .let [_ (debug.log! "AFTER")]]
- (in output)))
+ [((on_mail mail state self)
+ (do (try.with async.monad)
+ [.let [_ (debug.log! "BEFORE")]
+ output (mail state self)
+ .let [_ (debug.log! "AFTER")]]
+ (in output)))
- (message: .public (push {value a} state self)
- (List a)
- (let [state' (#.Item value state)]
- (async.resolved (#try.Success [state' state'])))))
+ (message: .public (push {value a} state self)
+ (List a)
+ (let [state' (#.Item value state)]
+ (async.resolved (#try.Success [state' state']))))])
(actor: .public counter
- {}
-
Nat
- (message: .public (count! {increment Nat} state self)
- Any
- (let [state' (n.+ increment state)]
- (async.resolved (#try.Success [state' state']))))
+ [(message: .public (count! {increment Nat} state self)
+ Any
+ (let [state' (n.+ increment state)]
+ (async.resolved (#try.Success [state' state']))))
- (message: .public (read! state self)
- Nat
- (async.resolved (#try.Success [state state])))))]
+ (message: .public (read! state self)
+ Nat
+ (async.resolved (#try.Success [state state])))]))]
(documentation: /.actor:
(format "Defines a named actor, with its behavior and internal state."
\n "Messages for the actor must be defined after the on_mail handler.")
diff --git a/stdlib/source/documentation/lux/type/abstract.lux b/stdlib/source/documentation/lux/type/abstract.lux
index a0bf8147b..b1a945167 100644
--- a/stdlib/source/documentation/lux/type/abstract.lux
+++ b/stdlib/source/documentation/lux/type/abstract.lux
@@ -41,95 +41,83 @@
(format "Define abstract/nominal types which hide their representation details."
\n "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others.")
[(abstract: String
- {}
-
Text
- (def: (string value)
- (-> Text String)
- (:abstraction value))
+ [(def: (string value)
+ (-> Text String)
+ (:abstraction value))
- (def: (text value)
- (-> String Text)
- (:representation value)))]
+ (def: (text value)
+ (-> String Text)
+ (:representation value))])]
["Type-parameters are optional."
(abstract: (Duplicate a)
- {}
-
[a a]
- (def: (duplicate value)
- (All (_ a) (-> a (Duplicate a)))
- (:abstraction [value value])))]
+ [(def: (duplicate value)
+ (All (_ a) (-> a (Duplicate a)))
+ (:abstraction [value value]))])]
["Definitions can be nested."
(abstract: (Single a)
- {}
-
a
- (def: (single value)
- (All (_ a) (-> a (Single a)))
- (:abstraction value))
+ [(def: (single value)
+ (All (_ a) (-> a (Single a)))
+ (:abstraction value))
- (abstract: (Double a)
- {}
+ (abstract: (Double a)
+ [a a]
- [a a]
+ [(def: (double value)
+ (All (_ a) (-> a (Double a)))
+ (:abstraction [value value]))
- (def: (double value)
- (All (_ a) (-> a (Double a)))
- (:abstraction [value value]))
+ (def: (single' value)
+ (All (_ a) (-> a (Single a)))
+ (:abstraction Single [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)))))]
+ (let [value 0123]
+ (same? value
+ (|> value
+ single'
+ (:representation Single)
+ double
+ :representation)))])])]
["Type-parameters do not necessarily have to be used in the representation type."
"If they are not used, they become phantom types and can be used to customize types without changing the representation."
(abstract: (JavaScript a)
- {}
-
Text
- (abstract: Expression {} Any)
- (abstract: Statement {} Any)
+ [(abstract: Expression Any [])
+ (abstract: Statement Any [])
- (def: (+ x y)
- (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression))
- (:abstraction
- (format "(" (:representation x) "+" (:representation y) ")")))
+ (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)
- "}"))))])
+ (def: (while test body)
+ (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement))
+ (:abstraction
+ (format "while(" (:representation test) ") {"
+ (:representation body)
+ "}")))])])
(documentation: /.:transmutation
"Transmutes an abstract/nominal type's phantom types."
[(abstract: (JavaScript a)
- {}
-
Text
- (abstract: Expression {} Any)
- (abstract: Statement {} Any)
+ [(abstract: Expression Any [])
+ (abstract: 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))])])
(documentation: /.^:representation
"Pattern-matching macro to easily extract a representation."