on master help sign in
gall fixes
e9fdef3joshuareagan
docs/tutorials/gall/generators.umd+34−29
@@ -31,10 +31,11 @@ Another generator is `+hood/merge`. Try running `+hood/merge` with the
31normal arguments for `|merge`:
31normal arguments for `|merge`:
32
32
33```
33```
34−~fintud-macrep:dojo> +hood/merge %home our %they
34+> +hood/merge %home our %they
35−[syd=%home her=~fintud-macrep sud=%they gem=%auto]
35+[syd=%home her=~zod sud=%they cas=[%da p=~2018.10.4..21.11.49..901c] gem=%auto]
36+
36−~fintud-macrep:dojo> +hood/merge %home our %they, =gem %this
37+> +hood/merge %home our %they, =gem %this
37−[syd=%home her=~fintud-macrep sud=%they gem=%auto]
38+[syd=%home her=~zod sud=%they cas=[%da p=~2018.10.4..21.12.11..ee32] gem=%this]
38```
39```
39
40
40This didn't run any merge, it just constructed the command that, if sent
41This didn't run any merge, it just constructed the command that, if sent
@@ -56,47 +57,47 @@ pattern is so common, this can be abbreviated to
56generators for the `:hood` app, `:hood|generator <args>` can be
57generators for the `:hood` app, `:hood|generator <args>` can be
57shortened to `|generator <args>`.
58shortened to `|generator <args>`.
58
59
59−Let's write a generator for a modified version of `:examples-pong` from
60+Let's write a generator for a modified version of `:pong` from
60the chapter on [Network Messages](/docs/arvo/system/network). Recall
61the chapter on [Network Messages](/docs/arvo/system/network). Recall
61−that `:examples-pong` takes an urbit address, which is of mark `urbit`,
62+that `:pong` takes an urbit address, which is of mark `urbit`,
62and sends that urbit the message `'howdy'`. First--without a
63and sends that urbit the message `'howdy'`. First--without a
63−generator--let's make `:examples-ping` that does the same, except that
64+generator--let's make `:ping` that does the same, except that
64it lets the user optionally specify the message as well.
65it lets the user optionally specify the message as well.
65
66
66We'll need a new mark for our arguments. Let's call it
67We'll need a new mark for our arguments. Let's call it
67−`examples-ping-message`.
68+`ping-message`.
68
69
69−> For app-specific marks, it's good style to prefix the name of the mark with the name of the app. Since many apps have several such marks, subdirectories in `/mar` are rendered as `-`, so that `ping-message` is written in (/mar/examples/ping/message.hoon).
70+> For app-specific marks, it's good style to prefix the name of the mark with the name of the app. Since many apps have several such marks, subdirectories in `/mar` are rendered as `-`, so that `ping-message` is written in (/mar/ping/message.hoon).
70
71
71```
72```
72::
73::
73−:::: /hoon/message/ping/examples/app
74+:::: /mar/ping/message/hoon
74 ::
75 ::
75/? 314
76/? 314
76|_ [to=@p message=@t]
77|_ [to=@p message=@t]
77++ grab
78++ grab
78 |%
79 |%
79− ++ noun [@p @t]
80+ +$ noun [@p @t]
80 --
81 --
81--
82--
82```
83```
83
84
84−The app can easily be modified to use this (`/app/examples/ping.hoon`):
85+The app can easily be modified to use this (`/app/ping.hoon`):
85
86
86```
87```
87:: Allows one ship to ping another with a string of text
88:: Allows one ship to ping another with a string of text
88::
89::
89−:::: /hoon/ping/examples/app
90+:::: /app/ping/hoon
90 ::
91 ::
91/? 314
92/? 314
92|%
93|%
93− ++ move [bone term wire *]
94+ +$ move [bone term wire *]
94--
95--
95!:
96!:
96−|_ [bowl:gall state=$~]
97+|_ [bowl:gall state=%~]
97::
98::
98−++ poke-examples-ping-message
99+++ poke-ping-message
99− |= [to=@p message/@t}
100+ |= [to=@p message=@t]
100 ~& 'sent'
101 ~& 'sent'
101 ^- [(list move) _+>.$]
102 ^- [(list move) _+>.$]
102 :- ^- (list move)
103 :- ^- (list move)
@@ -119,27 +120,28 @@ The app can easily be modified to use this (`/app/examples/ping.hoon`):
119Now we can run this with:
120Now we can run this with:
120
121
121```
122```
122−~fintud-macrep:dojo> |start %examples-ping
123+~fintud-macrep:dojo> |start %ping
123>=
124>=
125+
124−~fintud-macrep:dojo> :examples-ping &examples-ping-message [~sampel-sipnym 'heyya']
126+~fintud-macrep:dojo> :ping &ping-message [~sampel-sipnym 'heyya']
125>=
127>=
126```
128```
127
129
128−And on `~sampel-sipnym`, assuming it's running `:examples-ping` as well,
130+And on `~sampel-sipnym`, assuming it's running `:ping` as well,
129we see `[%receiving 'heyya']`.
131we see `[%receiving 'heyya']`.
130
132
131This is an annoying way to invoke the app, though. The `[]` are
133This is an annoying way to invoke the app, though. The `[]` are
132mandatory, and optional arguments are hard. Let's make a generator,
134mandatory, and optional arguments are hard. Let's make a generator,
133−`+examples-send` to make everything nicer. Since it's specific to
135+`+send` to make everything nicer. Since it's specific to
134−`:examples-ping`, let's put it in `/gen/examples/ping/send.hoon`:
136+`:ping`, let's put it in `/gen/ping/send.hoon`:
135
137
136```
138```
137:- %say
139:- %say
138−|= [^ [to=@p message=?($~ [text=@t $~])] $~]
140+|= [^ [to=@p message=?(%~ [text=@t %~])] %~]
139−[%examples-ping-message to ?~(message 'howdy' text.message)]
141+[%ping-message to ?~(message 'howdy' text.message)]
140```
142```
141
143
142−A couple of new things here. Firstly, `message=?($~ [text=@t $~])`
144+A couple of new things here. Firstly, `message=?(%~ [text=@t %~])] %~]`
143should be read as "the message is either null or a pair of text and
145should be read as "the message is either null or a pair of text and
144null". Generator argument lists are always null-terminated, which makes
146null". Generator argument lists are always null-terminated, which makes
145it convenient to accept lists in tail position (which are particularly
147it convenient to accept lists in tail position (which are particularly
@@ -151,17 +153,20 @@ anything that's in either `a` or `b`. Thus, in our case,
151This is run as follows:
153This is run as follows:
152
154
153```
155```
154−~fintud-macrep:dojo> :examples-ping|send ~sampel-sipnym
156+~fintud-macrep:dojo> :ping|send ~sampel-sipnym
155>=
157>=
158+
156−~fintud-macrep:dojo> :examples-ping|send ~sampel-sipnym 'how do you do'
159+~fintud-macrep:dojo> :ping|send ~sampel-sipnym 'how do you do'
157>=
160>=
158```
161```
159
162
160Which causes `~sampel-sipnym` to print `[%receiving 'howdy']` and
163Which causes `~sampel-sipnym` to print `[%receiving 'howdy']` and
161`[%receiving 'how do you do']`.
164`[%receiving 'how do you do']`.
162
165
166+(Note: `:ping|send ~sampel-sipnym` is short for `:ping +ping/send ~sampel-sipnym`.)
167+
163*Exercises*:
168*Exercises*:
164
169
165−- Create a generator for `:examples-sum` from [State](../../state) so that you can run `:examples-sum|add 5` to add numbers to it.
170+- Create a generator for `:sum` from [State](../../state) so that you can run `:sum|add 5` to add numbers to it.
166
171
167−- Create a generator for `:examples-click` from [Web Apps](../../web-apps) so that you can run `:examples-click|poke` to poke it.
172+- Create a generator for `:click` from [Web Apps](../../web-apps) so that you can run `:click|poke` to poke it.
docs/tutorials/gall/http.umd+7−12
@@ -13,12 +13,12 @@ Let's figure out how to make HTTP requests and set timers.
13
13
14Let's build an uptime-monitoring system. It'll ping a web
14Let's build an uptime-monitoring system. It'll ping a web
15service periodically and print out an error when the response
15service periodically and print out an error when the response
16−code isn't 2xx. Here's `app/up.hoon`:
16+code isn't 2xx. Save the following as `app/up.hoon`:
17
17
18```
18```
19:: Up-ness monitor. Accepts atom url, 'on', or 'off'
19:: Up-ness monitor. Accepts atom url, 'on', or 'off'
20::
20::
21−:::: /hoon/up/examples/app
21+:::: /hoon/up/app
22 ::
22 ::
23/? 314
23/? 314
24|%
24|%
@@ -33,7 +33,7 @@ code isn't 2xx. Here's `app/up.hoon`:
33 [%target p=cord] :: set poll target('http://...')
33 [%target p=cord] :: set poll target('http://...')
34 ==
34 ==
35--
35--
36−|_ [hid=bowl:gall on=_| in-progress=_| target=@t}
36+|_ [hid=bowl:gall on=_| in-progress=_| target=@t]
37++ poke-atom
37++ poke-atom
38 |= url-or-command=@t ^- (quip move +>)
38 |= url-or-command=@t ^- (quip move +>)
39 =+ ^- act/action
39 =+ ^- act/action
@@ -140,12 +140,7 @@ Here's the move that sends the HTTP request:
140[ost.hid %hiss /request ~ %httr %purl (need (epur target))]
140[ost.hid %hiss /request ~ %httr %purl (need (epur target))]
141```
141```
142
142
143−> Remember, we are expected to produce a *list* of moves. Note the `~`
143+> Remember, we are expected to produce a *list* of moves. Note the `~` after the move in the full example. This is a convenient shortcut for creating a list of a single element. It's part of a small family of such shortcuts. `~[a b c]` is `[a b c ~]`, `[a b c]~` is `[[a b c] ~]` and `\`[a b c]` is `[~ a b c]`. These may be mixed and matched to create various convoluted structures and emojis.
144−> after the move in the full example. This is a convenient shortcut for
145−> creating a list of a single element. It's part of a small family of
146−> such shortcuts. `~[a b c]` is `[a b c ~]`, `[a b c]~` is `[[a b c]
147−> ~]` and `\`[a b c]` is `[~ a b c]`. These may be mixed and matched to
148−> create various convoluted structures and emojis.
149
144
150The correspondence between this move and `[bone card]` can be hard to
145The correspondence between this move and `[bone card]` can be hard to
151visualize on one line. Here it is more pedantically:
146visualize on one line. Here it is more pedantically:
@@ -182,14 +177,14 @@ Let's try it out:
182```
177```
183~fintud-macrep:dojo> |start %up
178~fintud-macrep:dojo> |start %up
184>=
179>=
185−~fintud-macrep:dojo> :examples-up &atom 'http://www.google.com'
180+~fintud-macrep:dojo> :up &atom 'http://www.google.com'
186>=
181>=
187[%all-is-well 200]
182[%all-is-well 200]
188[%all-is-well 200]
183[%all-is-well 200]
189−~fintud-macrep:dojo> :examples-up &atom 'http://example.com'
184+~fintud-macrep:dojo> :up &atom 'http://example.com'
190>=
185>=
191[%all-is-well 200]
186[%all-is-well 200]
192−~fintud-macrep:dojo> :examples-up &atom 'http://google.com'
187+~fintud-macrep:dojo> :up &atom 'http://google.com'
193>=
188>=
194[%we-have-a-problem 301]
189[%we-have-a-problem 301]
195[ %headers
190[ %headers
docs/tutorials/gall/marks.umd+18−24
@@ -13,9 +13,9 @@ our own marks. Let's write a sample mark of our own, then chain
13it together with some preexisting ones to have fun with type
13it together with some preexisting ones to have fun with type
14conversions.
14conversions.
15
15
16−Let's make a small "examples-cord" mark. "Cord" is a name we use for `@t`
16+Let's make a small "cord" mark. "Cord" is a name we use for `@t`
17text, but there's no predefined mark for it. Let's put the following code in:
17text, but there's no predefined mark for it. Let's put the following code in:
18−`/mar/examples/cord.hoon`:
18+`/mar/cord.hoon`:
19
19
20```
20```
21/? 314
21/? 314
@@ -63,10 +63,10 @@ marked atom and convert it to our new mark.
63~fintud-macrep:dojo> &atom 9
63~fintud-macrep:dojo> &atom 9
649
649
65
65
66−~fintud-macrep:dojo> &examples-cord &atom 9
66+~fintud-macrep:dojo> &cord &atom 9
67'9'
67'9'
68
68
69−~fintud-macrep:dojo> &examples-cord &atom &examples-cord &atom 9
69+~fintud-macrep:dojo> &cord &atom &cord &atom 9
70 '57'
70 '57'
71```
71```
72
72
@@ -78,16 +78,13 @@ same concept. They're not isomorphisms.
78Let's play around a little more:
78Let's play around a little more:
79
79
80```
80```
81−~fintud-macrep:dojo> &md &examples-cord &atom 17
81+~fintud-macrep:dojo> &md &cord &atom 17
82'17'
82'17'
83+
83−~fintud-macrep:dojo> &hymn &md &examples-cord &atom 17
84+~fintud-macrep:dojo> &hymn &md &cord &atom 17
84[ [%html ~]
85[ [%html ~]
85− [[%head ~] [[%title ~] [[%~. [%~. "Untitled"] ~] ~] ~] ~]
86+ [[%head ~] ~]
86− [ [%body ~]
87− [ i=[g=[n=%meta a=~[[n=%value v="{}"] [n=%name v="frontmatter"] [n=[%urb %front] v=""]]] c=~]
88− t=[i=[g=[n=%p a=~] c=~[[g=[n=%$ a=~[[n=%$ v="17"]]] c=~]]] t=~]
87+ [[%body ~] [g=[n=%pre a=~] c=~[[g=[n=%$ a=~[[n=%$ v="17"]]] c=~]]] ~]
89− ]
90− ]
91 ~
88 ~
92]
89]
93```
90```
@@ -100,35 +97,32 @@ the time this gets to the web page, it's plain html. Let's do
100the final step in the conversion.
97the final step in the conversion.
101
98
102```
99```
103−~fintud-macrep:dojo> &mime &hymn &md &examples-cord &atom 17
100+~fintud-macrep:dojo> &mime &hymn &md &cord &atom 17
104−[ [%text %html ~]
105− p=121
106− q='<html><head><title>Untitled</title></head><body><meta value="{}" name="frontmatter" urb:front="" /><p>17</p></body></html>'
101+[[%text %html ~] p=52 q='<html><head></head><body><pre>17</pre></body></html>']
107−]
108```
102```
109
103
110This is a mime-typed octet stream with type `/text/html`, length
104This is a mime-typed octet stream with type `/text/html`, length
111121 bytes, and our lowly number `17` rendered to a web page.
105121 bytes, and our lowly number `17` rendered to a web page.
112−`examples-cord` was just one step in the chain.
106+`cord` was just one step in the chain.
113
107
114Of course, arvo can infer some parts of this chain:
108Of course, arvo can infer some parts of this chain:
115
109
116```
110```
117−~fintud-macrep:dojo> &examples-cord 17
111+~fintud-macrep:dojo> &cord 17
118'17'
112'17'
119```
113```
120
114
121−Likewise, `md` is the only way to get from `examples-cord` to `hymn`, so
115+Likewise, `md` is the only way to get from `cord` to `hymn`, so
122that can be omitted. If we omit the `hymn`, though, we get:
116that can be omitted. If we omit the `hymn`, though, we get:
123
117
124```
118```
125−~fintud-macrep:dojo> &mime &examples-cord 17
119+~fintud-macrep:dojo> &mime &cord 17
126−[[%text %x-markdown ~] p=1 q='7']
120+[[%text %x-markdown ~] p=2 q='17']
127```
121```
128
122
129−Here, we converted straight from `examples-cord` to `md` to `mime`. Arvo
123+Here, we converted straight from `cord` to `md` to `mime`. Arvo
130decided that was the most straightforward conversion, but it
124decided that was the most straightforward conversion, but it
131gives a different result than passing it through the `hymn`
125gives a different result than passing it through the `hymn`
132mark.
126mark.
133
127
134−The minimal correct input, then, is `&mime &hymn &examples-cord &atom 17`.
128+The minimal correct input, then, is `&mime &hymn &cord &atom 17`.
docs/tutorials/gall/network.umd+5−2
@@ -33,6 +33,8 @@ Let's get our planets to talk to each other. To listen for and receive messages
33-- :: end of poke-noun arm definition
33-- :: end of poke-noun arm definition
34```
34```
35
35
36+Save this as `echo.hoon` in the `/app` directory of your urbit's pier.
37+
36This is a very simple app that does only one thing. If you poke it with
38This is a very simple app that does only one thing. If you poke it with
37a value, it prints that value out. To try this out, you have to start
39a value, it prints that value out. To try this out, you have to start
38the app, then you can poke it from the command line with the following
40the app, then you can poke it from the command line with the following
@@ -85,8 +87,7 @@ particular address in our subject where our formal app state is stored.
85It'll become clear why this is later on, but for now pretend that `+>.$`
87It'll become clear why this is later on, but for now pretend that `+>.$`
86is a magic invocation that means "app state".
88is a magic invocation that means "app state".
87
89
88−Let's look at another example (edit your code in
90+Let's look at another example. Say we want to
89−`/app/examples/echo/hoon` to reflect the code below). Say we want to
90only accept a number, and then print out the square of that number.
91only accept a number, and then print out the square of that number.
91
92
92```
93```
@@ -110,6 +111,8 @@ only accept a number, and then print out the square of that number.
110--
111--
111```
112```
112
113
114+Save this as `square.hoon` in the `/app` directory of your urbit's pier.
115+
113A few things have changed. Firstly, we no longer accept arbitrary nouns because
116A few things have changed. Firstly, we no longer accept arbitrary nouns because
114we can only square atoms (integers, in this case an unsigned one). Thus, our
117we can only square atoms (integers, in this case an unsigned one). Thus, our
115argument is now `tom=@`. Secondly, it's `++poke-atom` rather than `++poke-noun`.
118argument is now `tom=@`. Secondly, it's `++poke-atom` rather than `++poke-noun`.
docs/tutorials/gall/state.umd+1−1
@@ -86,7 +86,7 @@ you like. But let's clarify a couple other things before we continue.
86
86
87First, `bowl` is a set of general global states. This set is managed by the
87First, `bowl` is a set of general global states. This set is managed by the
88system. It includes things like `now` (the current time), `our` (our urbit
88system. It includes things like `now` (the current time), `our` (our urbit
89−identity), and `eny` (256 bits of guaranteed-fresh entropy). For the full list
89+identity), and `eny` (512 bits of guaranteed-fresh entropy). For the full list
90of things in `++bowl`, search for `++ bowl` (note: two spaces) in
90of things in `++bowl`, search for `++ bowl` (note: two spaces) in
91`/arvo/zuse.hoon`.
91`/arvo/zuse.hoon`.
92
92
docs/tutorials/gall/subscriptions.umd+7−3
@@ -39,17 +39,17 @@ Let's take a look at two apps, `:source` and `:sink`. First,
39 ^- [(list move) _+>.$]
39 ^- [(list move) _+>.$]
40 :_ +>.$
40 :_ +>.$
41 %+ turn (prey /example-path bow)
41 %+ turn (prey /example-path bow)
42− |=({o=bone *} [o %diff %noun non])
42+ |=([o=bone *] [o %diff %noun non])
43::
43::
44++ peer-example-path
44++ peer-example-path
45− |= pax/path
45+ |= pax=path
46 ^- [(list move) _+>.$]
46 ^- [(list move) _+>.$]
47 ~& source+peer-notify+'Someone subscribed to you!'
47 ~& source+peer-notify+'Someone subscribed to you!'
48 ~& source+[ship+src.bow path+pax]
48 ~& source+[ship+src.bow path+pax]
49 [~ +>.$]
49 [~ +>.$]
50::
50::
51++ coup
51++ coup
52− |= {wir=wire err=(unit tang)}
52+ |= [wir=wire err=(unit tang)]
53 ^- [(list move) _+>.$]
53 ^- [(list move) _+>.$]
54 ?~ err
54 ?~ err
55 ~& source+success+'Poke succeeded!'
55 ~& source+success+'Poke succeeded!'
@@ -71,6 +71,8 @@ Let's take a look at two apps, `:source` and `:sink`. First,
71--
71--
72```
72```
73
73
74+Save this as `source.hoon` in the `/app` directory of your urbit's pier.
75+
74And secondly, `:sink`:
76And secondly, `:sink`:
75
77
76```
78```
@@ -138,6 +140,8 @@ And secondly, `:sink`:
138--
140--
139```
141```
140
142
143+Save this as `sink.hoon` in the `/app` directory of your urbit's pier.
144+
141Two notes:
145Two notes:
142
146
143- `bowl` is the type of the system state within our app. For example, it includes things like `our`, the name of the host urbit, and `now`, the current time.
147- `bowl` is the type of the system state within our app. For example, it includes things like `our`, the name of the host urbit, and `now`, the current time.
docs/tutorials/gall/web-apps.umd+43−45
@@ -20,7 +20,7 @@ poke it. There'll be a button to poke the app, and line of text
20below it saying how many times the app has been poked. We can
20below it saying how many times the app has been poked. We can
21update this by subscribing our page to the relevant path on its app.
21update this by subscribing our page to the relevant path on its app.
22
22
23−Let's first checkout the app `/app/examples/click.hoon`:
23+Save the following as `click.hoon` in the `/app` directory of your urbit's pier.
24
24
25```
25```
26/? 314
26/? 314
@@ -30,26 +30,26 @@ Let's first checkout the app `/app/examples/click.hoon`:
30--
30--
31!:
31!:
32|_ [hid=bowl:gall clicks=@]
32|_ [hid=bowl:gall clicks=@]
33−++ poke-examples-click-click
33+++ poke-click
34− |= click/$click
34+ |= click=%click
35 ~& [%poked +(clicks)]
35 ~& [%poked +(clicks)]
36 :_ +>.$(clicks +(clicks))
36 :_ +>.$(clicks +(clicks))
37− %+ turn (prey /the-path hid)
37+ %+ turn (prey:pubsub:userlib /the-path hid)
38− |=({o=bone *} [o %diff %examples-click-clicks +(clicks)])
38+ |=([o=bone *] [o %diff %clicks +(clicks)])
39++ peer-the-path
39++ peer-the-path
40− |= pax/path
40+ |= pax=path
41− [[[ost.hid %diff %examples-click-clicks clicks] ~] +>.$]
41+ [[[ost.hid %diff %clicks clicks] ~] +>.$]
42--
42--
43```
43```
44
44
45There's nothing really new here, except that we use a couple of
45There's nothing really new here, except that we use a couple of
46new marks, `click` and `clicks`. When we get poked with a
46new marks, `click` and `clicks`. When we get poked with a
47`click`, we increment the variable `clicks` in our state and tell
47`click`, we increment the variable `clicks` in our state and tell
48−all our subcribers the new value. When someone subscribes to us
48+all our subscribers the new value. When someone subscribes to us
49on the path `/the-path`, we immediately give them the current
49on the path `/the-path`, we immediately give them the current
50number of clicks.
50number of clicks.
51
51
52−Let's take a look at the new marks. Here's `/mar/examples/click/click.hoon`:
52+Let's take a look at the new marks. Save this as `/mar/click.hoon`:
53
53
54```
54```
55|_ click=%click
55|_ click=%click
@@ -58,68 +58,66 @@ Let's take a look at the new marks. Here's `/mar/examples/click/click.hoon`:
58 ++ noun |=(* %click)
58 ++ noun |=(* %click)
59 ++ json
59 ++ json
60 |= jon=^json
60 |= jon=^json
61− ?> =('click' (need (so:jo jon)))
61+ ?> =('click' (need (so:dejs-soft:format jon)))
62 %click
62 %click
63 --
63 --
64--
64--
65```
65```
66
66
67−The mark `examples-click-click` has type `%click`, which means the only
67+The mark `click` has type `%click`, which means the only
68valid value is `%click`. We can convert from `noun` by just
68valid value is `%click`. We can convert from `noun` by just
69producing `%click`.
69producing `%click`.
70
70
71−We also convert from json by parsing a json string with `so:jo`,
71+We also convert from json by parsing a json string with `so:dejs-soft:format`,
72asserting the parsing succeeded with `need`, and asserting the
72asserting the parsing succeeded with `need`, and asserting the
73result was 'click' with `?>`, which asserts that its first child
73result was 'click' with `?>`, which asserts that its first child
74is true.
74is true.
75
75
76−> Note the argument to `++json`is `jon=^json`. Why `^json`?
77−> `++json` shadows the type definition, so if we want to refer to
78−> the type, we have to prepend a `^`. This extends to multiple
79−> levels: `^^^foo` means the fourth most innermost instance of `foo`.
76+> Note the argument to `++json`is `jon=^json`. Why `^json`? `++json` shadows the type definition, so if we want to refer to the type, we have to prepend a `^`. This extends to multiple levels: `^^^foo` means the fourth most innermost instance of `foo`.
80
77
81−> `++jo` in `zuse` is a useful library for parsing complex json
78+> `dejs-soft:format` in `zuse` is a useful library for parsing complex json into hoon structures. In this case, the `:` between `dejs-soft` and `format` means 'inside of', because `dejs-soft` is an arm contained within the core `format`. Our case is actually simple enough that the `?>` line could have been `?> =([%s 'click'] jon)`.
82−> into hoon structures. In this case, the `:` between `so` and
83−> `jo` means 'inside of', because `so` is an arm contained within
84−> the core `jo`. Our case is actually simple enough that the
85−> `?>` line could have been `?> =([%s 'click'] jon)`.
86
79
87−We can test this mark from the command line (don't forget to start your app with `|start %examples-click`)
80+We can test this mark from the command line (don't forget to start your app with `|start %click`)
88
81
89```
82```
90−~fintud-macrep:dojo> &examples-click-click %click
83+~fintud-macrep:dojo> &click %click
91%click
84%click
85+
92−~fintud-macrep:dojo> &examples-click-click &json [%s 'click']
86+~fintud-macrep:dojo> &click &json [%s 'click']
93%click
87%click
88+
94−~fintud-macrep:dojo> &examples-click-click &json &mime [/text/json (taco '"click"')]
89+~fintud-macrep:dojo> &click &json &mime [/text/json (as-octs:mimes:html '"click"')]
95%click
90%click
91+
96−~fintud-macrep:dojo> &examples-click-click &json &mime [/text/json (taco '"clickety"')]
92+~fintud-macrep:dojo> &click &json &mime [/text/json (as-octs:mimes:html '"clickety"')]
97/~fintud-macrep/home/0/mar/click:<[7 5].[8 11]>
93/~fintud-macrep/home/0/mar/click:<[7 5].[8 11]>
98ford: casting %json to %click
94ford: casting %json to %click
99ford: cast %click
95ford: cast %click
100```
96```
101
97
102−And `/mar/examples/click/clicks.hoon`:
98+And save the following as `/mar/clicks.hoon`:
103
99
104```
100```
105|_ clicks=@
101|_ clicks=@
102+++ grab
103+ |%
104+ ++ noun @
105+ --
106++ grow
106++ grow
107 |%
107 |%
108 ++ json
108 ++ json
109− (joba %clicks (jone clicks))
109+ (frond:enjs:format %clicks (numb:enjs:format clicks))
110 --
110 --
111--
111--
112```
112```
113
113
114−`examples-clicks-clicks` is just an atom. We convert to json by creating an
114+`clicks` is just an atom. We convert to json by creating an
115object with a single field "clicks" with our value.
115object with a single field "clicks" with our value.
116
116
117−> Be sure to checkout section 3bD, JSON and XML, in zuse.hoon
118−> `++joba` is just a function that takes a key-value pair and
117+> Be sure to check out section 3bD, JSON and XML, in zuse.hoon `frond:enjs:format` is just a function that takes a key-value pair and produces a JSON object with one element.
119−> produces a JSON object with one element.
120
118
121```
119```
122−~fintud-macrep:dojo> &json &examples-click-clicks 6
120+~fintud-macrep:dojo> &json &clicks 6
123[%o p={[p='clicks' q=[%n p=~.6]]}]
121[%o p={[p='clicks' q=[%n p=~.6]]}]
124```
122```
125
123
@@ -128,26 +126,26 @@ above. Everything should be pretty straightforward. Let's poke
128the app from the command line.
126the app from the command line.
129
127
130```
128```
131−~fintud-macrep:dojo> |start %examples-click
129+~fintud-macrep:dojo> |start %click
132>=
130>=
133−~fintud-macrep:dojo> :examples-click &examples-click-click %click
131+~fintud-macrep:dojo> :click &click %click
134[%poked 1]
132[%poked 1]
135>=
133>=
136−~fintud-macrep:dojo> :examples-click &examples-click-click %click
134+~fintud-macrep:dojo> :click &click %click
137[%poked 2]
135[%poked 2]
138>=
136>=
139```
137```
140
138
141−Please pardon the awkwardness of the name 'examples-click-click', but we used it to stay true to our examples naming convention.
142−
143*Exercise*:
139*Exercise*:
144
140
145−- Modify `:sink` from the subcriptions chapter to listen to `:click` and print out the subscription updates on the command line.
141+- Modify `:sink` from the subscriptions chapter to listen to `:click` and print out the subscription updates on the command line.
146
142
147# Frontend
143# Frontend
148
144
145+> Note: the instructions below are outdated and do not work in the current version of Urbit. Feel free to experiment though.
146+
149That's all that's needed for the back end. The front end is just
147That's all that's needed for the back end. The front end is just
150−some "sail" html (Hoon markup for XML) and javascript. Here's `/web/pages/examples/click.hoon`:
148+some "sail" html (Hoon markup for XML) and javascript. Here's `/web/pages/click.hoon`:
151
149
152```
150```
153;html
151;html
@@ -162,7 +160,7 @@ some "sail" html (Hoon markup for XML) and javascript. Here's `/web/pages/examp
162 ;div#err(class "disabled");
160 ;div#err(class "disabled");
163 ;div#clicks;
161 ;div#clicks;
164 ==
162 ==
165− ;script(type "text/javascript", src "/pages/examples/click/click.js");
163+ ;script(type "text/javascript", src "/pages/click/click.js");
166 ==
164 ==
167==
165==
168```
166```
@@ -171,12 +169,12 @@ You should recognize the sail syntax from an earlier chapter.
171Aside from jquery, we also include `urb.js`, which is a framework
169Aside from jquery, we also include `urb.js`, which is a framework
172for interacting with urbit.
170for interacting with urbit.
173
171
174−To view the frontend, point your browser at `ship-name.urbit.org/~~/pages/examples/click` if you're on the live network. If you're running a fake galaxy, navigate to whatever port it's running on, which is usually: `https://localhost:8443/~~/pages/examples/click`.
172+To view the frontend, point your browser at `ship-name.urbit.org/~~/pages/click` if you're on the live network. If you're running a fake galaxy, navigate to whatever port it's running on, which is usually: `https://localhost:8443/~~/pages/click`.
175
173
176We have a button labeled "Poke!" and a div with id `clicks` where
174We have a button labeled "Poke!" and a div with id `clicks` where
177we'll put the number of clicks. We also include a small
175we'll put the number of clicks. We also include a small
178javascript file where the client-side application logic can be
176javascript file where the client-side application logic can be
179−found. It's in `/web/pages/examples/click/click.js`:
177+found. It's in `/web/pages/click.js`:
180
178
181```
179```
182$(function() {
180$(function() {
@@ -189,7 +187,7 @@ $(function() {
189 $go.on("click",
187 $go.on("click",
190 function() {
188 function() {
191 window.urb.send(
189 window.urb.send(
192− "click", {mark: "examples-click-click"}
190+ "click", {mark: "click-click"}
193 ,function(err,res) {
191 ,function(err,res) {
194 if(err)
192 if(err)
195 return $err.text("There was an error. Sorry!")
193 return $err.text("There was an error. Sorry!")
@@ -202,7 +200,7 @@ $(function() {
202 })
200 })
203 })
201 })
204
202
205− window.urb.appl = "examples-click"
203+ window.urb.appl = "click"
206 window.urb.bind('/the-path',
204 window.urb.bind('/the-path',
207 function(err,dat) {
205 function(err,dat) {
208 clicks = dat.data.clicks
206 clicks = dat.data.clicks