on master help sign in
Merge pull request #2 from rmariani/test
7f4243drmariani
docs/arvo/internals.md+30−28
@@ -1,6 +1,8 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 22
4sort: 22
5+Title: Internals
4---
6---
5
7
6# Arvo internals
8# Arvo internals
@@ -11,13 +13,13 @@ Arvo is composed of modules called vanes:
11
13
12<hr></hr>
14<hr></hr>
13
15
14−At a high level `%arvo` takes a mess of unix io events and turns them
16+At a high level `%arvo` takes a mess of Unix I/O events and turns them
15into something clean and structured for the programmer.
17into something clean and structured for the programmer.
16
18
17`%arvo` is designed to avoid the usual state of complex event networks:
19`%arvo` is designed to avoid the usual state of complex event networks:
18event spaghetti. We keep track of every event's cause so that we have a
20event spaghetti. We keep track of every event's cause so that we have a
19clear causal chain for every computation. At the bottom of every chain
21clear causal chain for every computation. At the bottom of every chain
20−is a unix io event, such as a network request, terminal input, file
22+is a Unix I/O event, such as a network request, terminal input, file
21sync, or timer event. We push every step in the path the request takes
23sync, or timer event. We push every step in the path the request takes
22onto the chain until we get to the terminal cause of the computation.
24onto the chain until we get to the terminal cause of the computation.
23Then we use this causal stack to route results back to the caller.
25Then we use this causal stack to route results back to the caller.
@@ -29,7 +31,7 @@ The `%arvo` causal stack is called a `++duct`. This is represented
29simply as a list of paths, where each path represents a step in the
31simply as a list of paths, where each path represents a step in the
30causal chain. The first element in the path is the first letter of
32causal chain. The first element in the path is the first letter of
31whichever vane handled that step in the computation, or the empty span
33whichever vane handled that step in the computation, or the empty span
32−for unix.
34+for Unix.
33
35
34Here's a duct that was recently observed in the wild:
36Here's a duct that was recently observed in the wild:
35
37
@@ -44,20 +46,20 @@ Here's a duct that was recently observed in the wild:
44This is the duct the timer vane receives when "timer" sample app asks
46This is the duct the timer vane receives when "timer" sample app asks
45the timer vane to set a timer. This is also the duct over which the
47the timer vane to set a timer. This is also the duct over which the
46response is produced at the specified time. Unix sent a terminal
48response is produced at the specified time. Unix sent a terminal
47−keystroke event (enter), and arvo routed it to %dill(our terminal),
49+keystroke event (enter), and Arvo routed it to `%dill` (our terminal),
48−which passed it on to the %gall app terminal, which sent it to shell,
50+which passed it on to the `%gall` app terminal, which sent it to shell,
49its child, which created a new child (with process id 4), which on
51its child, which created a new child (with process id 4), which on
50startup asked the timer vane to set a timer.
52startup asked the timer vane to set a timer.
51
53
52The timer vane saves this duct, so that when the specified time arrives
54The timer vane saves this duct, so that when the specified time arrives
53−and unix sends a wakeup event to the timer vane, it can produce the
55+and Unix sends a wakeup event to the timer vane, it can produce the
54response on the same duct. This response is routed to the place we
56response on the same duct. This response is routed to the place we
55popped off the top of the duct, i.e. the time app. This app produces the
57popped off the top of the duct, i.e. the time app. This app produces the
56text "ding", which falls down to the shell, which drops it through to
58text "ding", which falls down to the shell, which drops it through to
57the terminal. Terminal drops this down to dill, which converts it into
59the terminal. Terminal drops this down to dill, which converts it into
58−an effect that unix will recognize as a request to print "ding" to the
60+an effect that Unix will recognize as a request to print "ding" to the
59screen. When dill produces this, the last path in the duct has an
61screen. When dill produces this, the last path in the duct has an
60−initial element of the empty span, so this is routed to unix, which
62+initial element of the empty span, so this is routed to Unix, which
61applies the effects.
63applies the effects.
62
64
63This is a call stack, with a crucial feature: the stack is a first-class
65This is a call stack, with a crucial feature: the stack is a first-class
@@ -90,42 +92,42 @@ caller.
90Vanes
92Vanes
91-----
93-----
92
94
93−As shown above, we use arvo proper to route and control the flow of
95+As shown above, we use Arvo proper to route and control the flow of
94−moves. However, arvo proper is rarely directly responsible for
96+moves. However, Arvo proper is rarely directly responsible for
95processing the event data that directly causes the desired outcome of a
97processing the event data that directly causes the desired outcome of a
96move. This event data is contained within a card, which is simply a
98move. This event data is contained within a card, which is simply a
97−`(pair term noun)`. Instead, arvo proper passes the card off to one of
99+`(pair term noun)`. Instead, Arvo proper passes the card off to one of
98its vanes, which each present an interface to clients for a particular
100its vanes, which each present an interface to clients for a particular
99well-defined, stable, and general-purpose piece of functionality.
101well-defined, stable, and general-purpose piece of functionality.
100
102
101As of this writing, we have seven vanes, which each provide the
103As of this writing, we have seven vanes, which each provide the
102following services:
104following services:
103
105
104−- `%ames` name of both our network and the vane that communicates over
106+- `%ames`: the name of both our network and the vane that communicates over
105− it
107+ it.
106−- `%behn` a simple timer
108+- `%behn`: a simple timer.
107−- `%clay` version-controlled, referentially- transparent, and global
109+- `%clay`: our version-controlled, referentially- transparent, and global
108− filesystem
110+ filesystem.
109−- `%dill` terminal driver. Unix sends keyboard events to `%dill` from
111+- `%dill`: a terminal driver. Unix sends keyboard events to `%dill` from
110 either the console or telnet, and `%dill` produces terminal output.
112 either the console or telnet, and `%dill` produces terminal output.
111−- `%eyre` http server. Unix sends http messages to `%eyre`, and
113+- `%eyre`: an http server. Unix sends http messages to `%eyre`, and
112− `%eyre` produces http messages in response
114+ `%eyre` produces http messages in response.
113−- `%ford` handles resources and publishing
115+- `%ford`: handles resources and publishing.
114−- `%gall` manages our userspace applications. `%gall` keeps state and
116+- `%gall`: manages our userspace applications. `%gall` keeps state and
115− manages subscribers
117+ manages subscribers.
116
118
117Cards
119Cards
118-----
120-----
119
121
120Cards are the vane-specific portion of a move. Each vane defines a
122Cards are the vane-specific portion of a move. Each vane defines a
121−protocol for interacting with other vanes (via arvo) by defining four
123+protocol for interacting with other vanes (via Arvo) by defining four
122types of cards: kisses, gifts, notes, and signs.
124types of cards: kisses, gifts, notes, and signs.
123
125
124−When one vane is `%pass`ed a card in its `++kiss`, arvo activates the
126+When one vane is `%pass`ed a card in its `++kiss`, Arvo activates the
125`++call` gate with the card as its argument. To produce a result, the
127`++call` gate with the card as its argument. To produce a result, the
126vane `%give`s one of the cards defined in its `++gift`. If the vane
128vane `%give`s one of the cards defined in its `++gift`. If the vane
127needs to request something of another vane, it `%pass`es it a `++note`
129needs to request something of another vane, it `%pass`es it a `++note`
128−card. When that other vane returns a result, arvo activates the `++take`
130+card. When that other vane returns a result, Arvo activates the `++take`
129gate of the initial vane with one of the cards defined in its `++sign`.
131gate of the initial vane with one of the cards defined in its `++sign`.
130
132
131In other words, there are only four ways of seeing a move: (1) as a
133In other words, there are only four ways of seeing a move: (1) as a
@@ -134,12 +136,12 @@ seen by the callee, a `++kiss`. (3) the response to that first request
134as seen by the callee, a `++gift`. (4) the response to the first request
136as seen by the callee, a `++gift`. (4) the response to the first request
135as seen by the caller, a `++sign`.
137as seen by the caller, a `++sign`.
136
138
137−When a `++kiss` card is passed to a vane, arvo calls its `++call` gate,
139+When a `++kiss` card is passed to a vane, Arvo calls its `++call` gate,
138passing it both the card and its duct. This gate must be defined in
140passing it both the card and its duct. This gate must be defined in
139every vane. It produces two things in the following order: a list of
141every vane. It produces two things in the following order: a list of
140−moves and a possibly-modified copy of its context. The moves are used to
142+moves and a possibly modified copy of its context. The moves are used to
141interact with other vanes, while the new context allows the vane to save
143interact with other vanes, while the new context allows the vane to save
142−its state. The next time arvo activates the vane it will have this
144+its state. The next time Arvo activates the vane it will have this
143context as its subject.
145context as its subject.
144
146
145This overview has detailed how to pass a card to a particular vane. To
147This overview has detailed how to pass a card to a particular vane. To
docs/arvo/subscriptions.md+15−15
@@ -15,7 +15,7 @@ that it's built into arvo.
15
15
16Let's take a look at two apps, `:source` and `:sink`. First,
16Let's take a look at two apps, `:source` and `:sink`. First,
17`:source`:
17`:source`:
18−
18+
19 :: Sends subscription updates to sink.hoon
19 :: Sends subscription updates to sink.hoon
20 ::
20 ::
21 :::: /===/app/source/hoon
21 :::: /===/app/source/hoon
@@ -69,7 +69,7 @@ Let's take a look at two apps, `:source` and `:sink`. First,
69 --
69 --
70
70
71And secondly, `:sink`:
71And secondly, `:sink`:
72−
72+
73 :: Sets up a simple subscription to source.hoon
73 :: Sets up a simple subscription to source.hoon
74 ::
74 ::
75 :::: /===/app/sink/hoon
75 :::: /===/app/sink/hoon
@@ -232,8 +232,8 @@ added to it. This is why no wire is needed for the move -- we won't
232receive anything in response to it.
232receive anything in response to it.
233
233
234Anyways, there are four functions (arms) inside the `|_`. We already know when
234Anyways, there are four functions (arms) inside the `|_`. We already know when
235−`++poke-noun` is called. `++peer-example-path` is called when someone tries to
235+`++poke-noun` is called. `++peer-example-path` is called when someone tries to
236−subscribe to our app. Of course, you don't just subscribe to an app; you
236+subscribe to our app. Of course, you don't just subscribe to an app; you
237subscribe to a path on that app. This path comes in as the argument to `++peer`.
237subscribe to a path on that app. This path comes in as the argument to `++peer`.
238
238
239In our case, we don't care what path you subscribed on, and all we do is print
239In our case, we don't care what path you subscribed on, and all we do is print
@@ -254,8 +254,8 @@ languages call "map" -- it runs a function on every item in a list and collects
254the results in a list. The list is `(prey /example-path bow)` and the function
254the results in a list. The list is `(prey /example-path bow)` and the function
255is the `|=` line right after it.
255is the `|=` line right after it.
256
256
257−`++prey` is a standard library function defined in `zuse.hoon`. It takes a path
257+`++prey` is a standard library function defined in `zuse.hoon`. It takes a path
258−and a bowl and gives you a list of the subscribers who are subscribed on a path
258+and a bowl and gives you a list of the subscribers who are subscribed on a path
259that begins with the given path. "Prey" is short for "prefix".
259that begins with the given path. "Prey" is short for "prefix".
260
260
261Now we have the list of relevant subscribers. This a list of triples,
261Now we have the list of relevant subscribers. This a list of triples,
@@ -268,7 +268,7 @@ straightforward!
268
268
269### :sink
269### :sink
270
270
271−`:source` should now make sense. `:sink` is a little longer, but not much more
271+`:source` should now make sense. `:sink` is a little longer, but not much more
272complicated.
272complicated.
273
273
274In `:sink`, our definition of of `++move` is different. All moves start
274In `:sink`, our definition of of `++move` is different. All moves start
@@ -290,7 +290,7 @@ is the sign of type boolean (similar to `*`, `@`), which defaults to true (that
290is, `0`).
290is, `0`).
291
291
292In `++poke-noun` we check our input to see both if it's `%on` and we're
292In `++poke-noun` we check our input to see both if it's `%on` and we're
293−available (`val` is true). If so, we produce the move to subscribe to
293+available (`val` is true). If so, we produce the move to subscribe to
294`:source`:
294`:source`:
295
295
296 :~ :* ost.bow
296 :~ :* ost.bow
@@ -301,15 +301,15 @@ available (`val` is true). If so, we produce the move to subscribe to
301 ==
301 ==
302 ==
302 ==
303
303
304−Also, in the preceding lines, we set `val` to false (`|`) with `+>.$(val |)`.
304+Also, in the preceding lines, we set `val` to false (`|`) with `+>.$(val |)`.
305−Remember that the `:_` constructs an inverted cell, with the first child
305+Remember that the `:_` constructs an inverted cell, with the first child
306−(`+>.$(val |` in our case) as the tail and the second child as the head. Here,
306+(`+>.$(val |` in our case) as the tail and the second child as the head. Here,
307−the cell we produce when our subscription is `%on` and `val` is true has a
307+the cell we produce when our subscription is `%on` and `val` is true has a
308−head with our new state where `val` is set to false and a tail of our list of
308+head with our new state where `val` is set to false and a tail of our list of
309moves, which is shown in the code block above.
309moves, which is shown in the code block above.
310
310
311Otherwise, if our input is `%off` and we're already subscribed (i.e. `val`
311Otherwise, if our input is `%off` and we're already subscribed (i.e. `val`
312−is false), then we unsubscribe from `:source` and set `val` back to true (`&`),
312+is false), then we unsubscribe from `:source` and set `val` back to true (`&`),
313again using our handy inverted cell constructor mold `:_`:
313again using our handy inverted cell constructor mold `:_`:
314
314
315 :_ +>.$(val &)
315 :_ +>.$(val &)
@@ -319,7 +319,7 @@ It's important to send over the same bone and wire (`/subscribe`) as the
319one we originally subscribed on.
319one we originally subscribed on.
320
320
321If neither of these cases are true, then we print our current subscription
321If neither of these cases are true, then we print our current subscription
322−state, based on whether `val` is true or false, and return a cell containing
322+state, based on whether `val` is true or false, and return a cell containing
323a null list of moves and our unchanged app state:
323a null list of moves and our unchanged app state:
324
324
325 ~& ?: val
325 ~& ?: val
docs/arvo/umarkdown.umdnew file+350
@@ -0,0 +1,350 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 23
5+Title: Internals
6+---
7+
8+_thanks to ~rovnys-ricfer for writing this_
9+
10+# Urbit-Flavored Markdown
11+
12+## Overview
13+
14+Urbit-Flavored Markdown (UFM) is a minimal markup language for creating and rendering text documents,
15+with a [Markdown](https://en.wikipedia.org/wiki/Markdown)-inspired syntax. It's integrated with the Hoon programming
16+language, allowing it to be used as standalone prose in its own file or inside
17+a hoon source file, in which case it will be parsed into a tree of HTML nodes
18+using Hoon's `sail` datatype.
19+
20+UFM is stricter than Markdown and generally supports only one syntax for each
21+type of HTML node that it emits.
22+
23+### Headers
24+
25+Headers in UFM begin with one or more `#` characters, followed by a space. The
26+number of leading `#`s corresponds to the resulting HTML element: `#` yields an
27+`<h1>`; `##` yields the slightly smaller `<h2>`; and so on, through `<h6>`.
28+
29+Example:
30+```
31+### Header (h3)
32+
33+##### Header (h5)
34+```
35+produces:
36+
37+> ### Header (h3)
38+
39+ ##### Header (h5)
40+
41+### Lists
42+
43+A line beginning with a `-` or `+` followed by a space is interpreted as an
44+element of a list. `-` means unordered list (`<ul>`) and `+` means ordered list
45+(`<ol>`).
46+
47+Example:
48+
49+```
50+- unordered 1
51+ text on newline shows up on same line
52+- unordered 2\
53+ text on newline after `\` puts in <br> line break
54+
55+- unordered after 1 blank line
56+ - nested
57+ - double-nested
58+
59++ leading '+'
60++ leading '+'
61+- unordered '-'
62+ + nested ordered '+' item 1
63+ + nested ordered '+' item 2
64+
65++ ordered '+'
66+ + nested item 1
67+ + nested item 2
68+```
69+
70+produces:
71+
72+> - unordered 1
73+ text on newline shows up on same line
74+ - unordered 2\
75+ text on newline after `\` puts in <br> line break
76+
77+ - unordered after 1 blank line
78+ - nested
79+ - double-nested
80+
81+ + leading '+'
82+ + leading '+'
83+ - unordered '-'
84+ + nested ordered '+' item 1
85+ + nested ordered '+' item 2
86+
87+ + ordered '+'
88+ + nested item 1
89+ + nested item 2
90+
91+### Blockquotes
92+
93+A section of text beginning with `> ` and indented by two spaces yields a
94+`<blockquote>` element. This blockquote can itself turn contain more UFM,
95+including more blockquotes to render nested levels of quotation.
96+
97+Example:
98+
99+```
100+> As Gregor Samsa awoke one morning from uneasy dreams
101+ he found himself _transformed_ in his bed into a *monstrous* vermin.
102+```
103+
104+produces:
105+
106+> > As Gregor Samsa awoke one morning from uneasy dreams
107+ he found himself _transformed_ in his bed into a *monstrous* vermin.
108+
109+### Code blocks
110+
111+By enclosing a block of text in `\`\`\` on their own lines
112+before and after the block, the text will be treated as a code block.
113+
114+Example:
115+
116+```
117+> ```
118+ (def Y (fn [f]
119+ ((fn [x]
120+ (x x))
121+ (fn [x]
122+ (f (fn [y]
123+ ((x x) y)))))))
124+ ```
125+```
126+
127+produces:
128+
129+> ```
130+ (def Y (fn [f]
131+ ((fn [x]
132+ (x x))
133+ (fn [x]
134+ (f (fn [y]
135+ ((x x) y)))))))
136+ ```
137+
138+### Poems
139+
140+A poem is a section of text with meaningful newlines. Normally in UFM,
141+newlines are treated as spaces and do not create a new line of text. If you
142+want to embed text where newlines are retained, then indent the text by
143+question with eight spaces.
144+
145+Example:
146+```
147+ A shape with lion body and the head of a man,
148+ A gaze blank and pitiless as the sun,
149+ Is moving its slow thighs, while all about it
150+ Reel shadows of the indignant desert birds.
151+```
152+produces:
153+> A shape with lion body and the head of a man,
154+ A gaze blank and pitiless as the sun,
155+ Is moving its slow thighs, while all about it
156+ Reel shadows of the indignant desert birds.
157+
158+### Sail expressions
159+
160+It's possible to use Urbit-Flavored Markdown as an HTML-templating language akin to
161+PHP, ERB, JSP, or Handlebars templates. This facility derives
162+in part from the support for embedding Hoon code inside the markup.
163+There are two ways to do embed Hoon in UFM: inline expressions and `sail`.
164+[Sail](https://urbit.org/fora/posts/~2017.7.6..21.27.00..bebb~/)
165+is a DSL within Hoon for creating XML nodes, including HTML. It can
166+be used directly within UFM to provide scripting capability and also to
167+provide more fine-grained control over the resulting HTML.
168+
169+Example:
170+```
171+;=
172+ ;p
173+ ;strong: Don't panic!
174+ ;br;
175+ ;small: [reactive publishing intensifies]
176+ ==
177+==
178+```
179+
180+produces:
181+> ;=
182+ ;p
183+ ;strong: Don't panic!
184+ ;br;
185+ ;small: [reactive publishing intensifies]
186+ ==
187+ ==
188+
189+_Note:
190+[Urbit's web-publishing system](https://urbit.org/docs/arvo/web-apps/)
191+currently does not apply `<style>` elements or element attributes,
192+which are supported in `sail` syntax. Future versions of the publishing
193+system will rectify this._
194+
195+### Horizontal rules
196+
197+`---` on its own line produces an `<hr>` element, the 'horizontal rule'.
198+This is rendered as a horizontal line the width of its containing paragraph.
199+
200+Example:
201+```
202+Above the line
203+---
204+Below the line
205+```
206+> :: produces:\
207+ Above the line
208+ ---
209+ Below the line
210+
211+### Inline markup
212+
213+In addition to the above, UFM includes several options for marking up
214+inline text.
215+
216+##### Bold
217+
218+Enclose some text in asterisks to boldly render it inside a `<b>` element.
219+
220+Example:
221+```
222+The first rule of tautology club is
223+*the first rule of tautology club*.
224+```
225+produces:\
226+
227+> The first rule of tautology club is
228+ *the first rule of tautology club*.
229+
230+##### Italics
231+
232+Surrounding text with `_` on each side will cause it to appear
233+in italics, using an <i> element.
234+
235+Example:
236+```
237+Bueller? _Bueller?_
238+```
239+
240+produces:
241+
242+Bueller? _Bueller?_
243+
244+##### Double quote
245+
246+Text enclosed in double quotes (`"`) will be rendered with
247+opening and closing quotes.
248+
249+Example:
250+```
251+"Yes," he said. "That is the way with him."
252+```
253+produces:\
254+
255+"Yes," he said. "That is the way with him."
256+
257+##### Backslash escape
258+
259+A backslash directly before a word (with no spaces) will be interpreted
260+as an escape character, causing it to be rendered raw.
261+
262+Example:
263+```
264+Here is some *bold* text.
265+Here is some \*not bold\* text.
266+```
267+produces:
268+
269+Here is some *bold* text.
270+Here is some \*not bold\* text.
271+
272+##### Trailing backslash
273+
274+A backslash at the end of a line inserts a line break (`<br>`)
275+after that line. This contrasts with the normal UFM behavior of
276+converting newlines to spaces.
277+
278+Example:
279+```
280+I wonder how long each line
281+will be if I put backslashes\
282+at the ends of the lines.
283+```
284+produces:
285+
286+I wonder how long each line
287+will be if I put backslashes\
288+at the ends of the lines.
289+
290+##### Inline code literal
291+
292+Enclosing some text in ``` characters will cause it to be displayed as code,
293+inside a <code> element with monospace font and a different background color.
294+
295+Example:
296+```
297+`*[a 2 b c] -> *[*[a b] *[a c]]` is like lisp's `apply`.
298+```
299+produces:\
300+
301+`*[a 2 b c] -> *[*[a b] *[a c]]` is like lisp's `apply`.
302+
303+Also, using the `++` prefix before a word will cause the word
304+to be rendered as code, since that's the standard notation
305+for an `arm` in Hoon.
306+
307+Example:
308+```
309+The UFM parser is part of ++vast.
310+```
311+produces:\
312+
313+The UFM parser is part of ++vast.
314+
315+##### Hoon constants
316+
317+Hoon has several syntactic forms for literals (numbers, strings, dates, etc.)
318+that can be used in UFM as well. They will appear inside a <code> element like
319+inline code.
320+
321+Example:
322+
323+```
324+~2017.8.29 \
325+0xdead.beef \
326+%term
327+```
328+
329+produces:\
330+
331+~2017.8.29 \
332+0xdead.beef \
333+%term
334+
335+##### Url
336+
337+To insert a hyperlink, put the text content of the link in `[]` brackets
338+followed by the destination URL in `()` parentheses. Note that the text
339+of the displayed link can contain Markdown styling.
340+
341+Example:
342+
343+```
344+A [Hoon `core`](https://urbit.org/docs/hoon/concepts/#-core-object)
345+is similar to an object in a traditional programming language.
346+```
347+produces:\
348+
349+A [Hoon `core`](https://urbit.org/docs/hoon/concepts/#-core-object)
350+is similar to an object in a traditional programming language.