on master help sign in
Merge pull request #2 from rmariani/test

Test

commit7f4243d0f7a6830829a0f7ca514d44fb5e28bb64 authorrmariani <robert@tlon.io> dateTue 17 Apr 2018, 16:36 (9 years ago) parent27d10106c0fc55
3 files changed+395−43
docs/arvo/internals.md+30−28 docs/arvo/subscriptions.md+15−15 docs/arvo/umarkdown.umd+350
docs/arvo/internals.md+30−28
@@ -1,6 +1,8 @@
11---
22navhome: /docs/
3+next: true
34sort: 22
5+Title: Internals
46---
57
68# Arvo internals
@@ -11,13 +13,13 @@ Arvo is composed of modules called vanes:
1113
1214<hr></hr>
1315
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
1517into something clean and structured for the programmer.
1618
1719`%arvo` is designed to avoid the usual state of complex event networks:
1820event spaghetti. We keep track of every event's cause so that we have a
1921clear 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
2123sync, or timer event. We push every step in the path the request takes
2224onto the chain until we get to the terminal cause of the computation.
2325Then 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
2931simply as a list of paths, where each path represents a step in the
3032causal chain. The first element in the path is the first letter of
3133whichever vane handled that step in the computation, or the empty span
32−for unix.
34+for Unix.
3335
3436Here's a duct that was recently observed in the wild:
3537
@@ -44,20 +46,20 @@ Here's a duct that was recently observed in the wild:
4446This is the duct the timer vane receives when "timer" sample app asks
4547the timer vane to set a timer. This is also the duct over which the
4648response is produced at the specified time. Unix sent a terminal
47−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,
49+keystroke event (enter), and Arvo routed it to `%dill` (our terminal),
50+which passed it on to the `%gall` app terminal, which sent it to shell,
4951its child, which created a new child (with process id 4), which on
5052startup asked the timer vane to set a timer.
5153
5254The 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
5456response on the same duct. This response is routed to the place we
5557popped off the top of the duct, i.e. the time app. This app produces the
5658text "ding", which falls down to the shell, which drops it through to
5759the 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
5961screen. 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
6163applies the effects.
6264
6365This is a call stack, with a crucial feature: the stack is a first-class
@@ -90,42 +92,42 @@ caller.
9092Vanes
9193-----
9294
93−As shown above, we use arvo proper to route and control the flow of
94−moves. However, arvo proper is rarely directly responsible for
95+As shown above, we use Arvo proper to route and control the flow of
96+moves. However, Arvo proper is rarely directly responsible for
9597processing the event data that directly causes the desired outcome of a
9698move. 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
98100its vanes, which each present an interface to clients for a particular
99101well-defined, stable, and general-purpose piece of functionality.
100102
101103As of this writing, we have seven vanes, which each provide the
102104following services:
103105
104−- `%ames` name of both our network and the vane that communicates over
105− it
106−- `%behn` a simple timer
107−- `%clay` version-controlled, referentially- transparent, and global
108− filesystem
109−- `%dill` terminal driver. Unix sends keyboard events to `%dill` from
106+- `%ames`: the name of both our network and the vane that communicates over
107+ it.
108+- `%behn`: a simple timer.
109+- `%clay`: our version-controlled, referentially- transparent, and global
110+ filesystem.
111+- `%dill`: a terminal driver. Unix sends keyboard events to `%dill` from
110112 either the console or telnet, and `%dill` produces terminal output.
111−- `%eyre` http server. Unix sends http messages to `%eyre`, and
112− `%eyre` produces http messages in response
113−- `%ford` handles resources and publishing
114−- `%gall` manages our userspace applications. `%gall` keeps state and
115− manages subscribers
113+- `%eyre`: an http server. Unix sends http messages to `%eyre`, and
114+ `%eyre` produces http messages in response.
115+- `%ford`: handles resources and publishing.
116+- `%gall`: manages our userspace applications. `%gall` keeps state and
117+ manages subscribers.
116118
117119Cards
118120-----
119121
120122Cards 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
122124types of cards: kisses, gifts, notes, and signs.
123125
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
125127`++call` gate with the card as its argument. To produce a result, the
126128vane `%give`s one of the cards defined in its `++gift`. If the vane
127129needs 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`
129131gate of the initial vane with one of the cards defined in its `++sign`.
130132
131133In 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
134136as seen by the callee, a `++gift`. (4) the response to the first request
135137as seen by the caller, a `++sign`.
136138
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,
138140passing it both the card and its duct. This gate must be defined in
139141every 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
141143interact 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
143145context as its subject.
144146
145147This 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.
1515
1616Let's take a look at two apps, `:source` and `:sink`. First,
1717`:source`:
18−
18+
1919 :: Sends subscription updates to sink.hoon
2020 ::
2121 :::: /===/app/source/hoon
@@ -69,7 +69,7 @@ Let's take a look at two apps, `:source` and `:sink`. First,
6969 --
7070
7171And secondly, `:sink`:
72−
72+
7373 :: Sets up a simple subscription to source.hoon
7474 ::
7575 :::: /===/app/sink/hoon
@@ -232,8 +232,8 @@ added to it. This is why no wire is needed for the move -- we won't
232232receive anything in response to it.
233233
234234Anyways, 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
236−subscribe to our app. Of course, you don't just subscribe to an app; you
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
237237subscribe to a path on that app. This path comes in as the argument to `++peer`.
238238
239239In 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
254254the results in a list. The list is `(prey /example-path bow)` and the function
255255is the `|=` line right after it.
256256
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
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
259259that begins with the given path. "Prey" is short for "prefix".
260260
261261Now we have the list of relevant subscribers. This a list of triples,
@@ -268,7 +268,7 @@ straightforward!
268268
269269### :sink
270270
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
272272complicated.
273273
274274In `: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
290290is, `0`).
291291
292292In `++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
294294`:source`:
295295
296296 :~ :* ost.bow
@@ -301,15 +301,15 @@ available (`val` is true). If so, we produce the move to subscribe to
301301 ==
302302 ==
303303
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
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
308−head with our new state where `val` is set to false and a tail of our list of
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
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
308+head with our new state where `val` is set to false and a tail of our list of
309309moves, which is shown in the code block above.
310310
311311Otherwise, 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 (`&`),
313313again using our handy inverted cell constructor mold `:_`:
314314
315315 :_ +>.$(val &)
@@ -319,7 +319,7 @@ It's important to send over the same bone and wire (`/subscribe`) as the
319319one we originally subscribed on.
320320
321321If 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
323323a null list of moves and our unchanged app state:
324324
325325 ~& ?: 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.