on master help sign in
replaced effect and syscall with move and card
8b37d39David Kerschner
tutorials/hoon/egg-timer.md+17−17
@@ -10,18 +10,18 @@ The Arvo operating system is divided up into modules called vanes. Gall is the v
10
10
11```hoon
11```hoon
12|%
12|%
13−+$ effect (pair bone syscall)
13++$ move (pair bone card)
14−+$ syscall [%wait path @da]
14++$ card [%wait path @da]
15--
15--
16|_ [bowl:gall ~]
16|_ [bowl:gall ~]
17++ poke-noun
17++ poke-noun
18 |= t=@dr
18 |= t=@dr
19− ^+ [*(list effect) +>.$]
19+ ^+ [*(list move) +>.$]
20 :_ +>.$ :_ ~
20 :_ +>.$ :_ ~
21 [ost %wait /egg-timer (add now t)]
21 [ost %wait /egg-timer (add now t)]
22++ wake
22++ wake
23 |= [=wire error=(unit tang)]
23 |= [=wire error=(unit tang)]
24− ^+ [*(list effect) +>.$]
24+ ^+ [*(list card) +>.$]
25 ~& "Timer went off!"
25 ~& "Timer went off!"
26 [~ +>.$]
26 [~ +>.$]
27--
27--
@@ -31,14 +31,14 @@ The first thing to notice is that we are creating a `core` (`|%`) and a `door` (
31
31
32```hoon
32```hoon
33|%
33|%
34−+$ effect (pair bone syscall)
34++$ card (pair bone move)
35−+$ syscall [%wait path @da]
35++$ move [%wait path @da]
36--
36--
37```
37```
38
38
39−The `core` here defines two types: `effect` and `syscall`. An `effect` is a `pair` of `bone` and `syscall`. A `bone` is a Gall-only type that identifies app event chains by mapping atoms to them. We define `syscall` to be a request to Arvo to do something for us. In this case, the only valid `syscall` will be `%wait` which we'll discuss in a bit.
39+The `core` here defines two types: `card` and `move`. An `card` is a `pair` of `bone` and `move`. A `bone` is a Gall-only type that identifies app event chains by mapping atoms to them. We define `move` to be a request to Arvo to do something for us. In this case, the only valid `move` will be `%wait` which we'll discuss in a bit.
40
40
41−It's important to note that the names `effect` and `syscall` are arbitrary; you can call them whatever you'd like. Commonly you will see them called `move` and `card`, respectively, but we've changed the names here to try to introduce some clarity that that older convention lacks.
41+It's important to note that the names `card` and `move` are arbitrary; you can call them whatever you'd like. Commonly you will see them called `move` and `card`.
42
42
43The sample of the `door` is:
43The sample of the `door` is:
44
44
@@ -59,7 +59,7 @@ The `door` we've made has two arms `poke-noun` and `wake`. Gall is capable of di
59```hoon
59```hoon
60++ poke-noun
60++ poke-noun
61 |= t=@dr
61 |= t=@dr
62− ^+ [*(list effect) +>.$]
62+ ^+ [*(list card) +>.$]
63 :_ +>.$ :_ ~
63 :_ +>.$ :_ ~
64 [ost %wait /egg-timer (add now t)]
64 [ost %wait /egg-timer (add now t)]
65```
65```
@@ -70,7 +70,7 @@ In the above code, we create a gate that takes a single `@dr` argument. `@dr` is
70- `~m20` 20 minutes
70- `~m20` 20 minutes
71- `~d42` 42 days
71- `~d42` 42 days
72
72
73−As a matter of good type hygiene, we explicitly cast the output of this gate with `^+` to ensure we are producing the correct thing for Gall to handle. `^+` is the rune for casting by example. Our example is a cell: `list` of `effect`, which we `bunt` with `*`, is the head; `+>.$`, the enclosing core which is our `door`, is the tail.
73+As a matter of good type hygiene, we explicitly cast the output of this gate with `^+` to ensure we are producing the correct thing for Gall to handle. `^+` is the rune for casting by example. Our example is a cell: `list` of `card`, which we `bunt` with `*`, is the head; `+>.$`, the enclosing core which is our `door`, is the tail.
74
74
75Next we're going to use the `:_` rune which is just the inverted form a `:-` the cell construction rune. We use it twice so the actual data will end up looking something like:
75Next we're going to use the `:_` rune which is just the inverted form a `:-` the cell construction rune. We use it twice so the actual data will end up looking something like:
76
76
@@ -78,9 +78,9 @@ Next we're going to use the `:_` rune which is just the inverted form a `:-` the
78[[[ost %wait /egg-timer (add now t)] ~] +>.$]
78[[[ost %wait /egg-timer (add now t)] ~] +>.$]
79```
79```
80
80
81−`ost` is the `bone`, the opaque reference to a chain of events, that comes from `bowl`, so we're going to continue to use it here. `%wait` is the name of the `syscall`, in this case a request to the Behn vain to start a timer for us.
81+`ost` is the `bone`, the opaque reference to a chain of events, that comes from `bowl`, so we're going to continue to use it here. `%wait` is the name of the `move`, in this case a request to the Behn vain to start a timer for us.
82
82
83−After `%wait`, we have the `path`, a `list` of `cords` that serves as the unique identifier for this `syscall`:
83+After `%wait`, we have the `path`, a `list` of `cords` that serves as the unique identifier for this `move`:
84
84
85```
85```
86/egg-timer
86/egg-timer
@@ -88,7 +88,7 @@ After `%wait`, we have the `path`, a `list` of `cords` that serves as the unique
88
88
89The `/` here is an irregular syntax to make a `path`.
89The `/` here is an irregular syntax to make a `path`.
90
90
91−The final part of this `syscall` is:
91+The final part of this `move` is:
92
92
93```
93```
94(add now t)
94(add now t)
@@ -96,17 +96,17 @@ The final part of this `syscall` is:
96
96
97`now` is the current time of type `@da`, and `t` was declared as `@dr`. Because they are both atoms, we can add `now` and `t` these two to get an atom that is `t` units of time into the future from `now`. That produced atom can be interpreted as a `@da`.
97`now` is the current time of type `@da`, and `t` was declared as `@dr`. Because they are both atoms, we can add `now` and `t` these two to get an atom that is `t` units of time into the future from `now`. That produced atom can be interpreted as a `@da`.
98
98
99−That's all for our `poke-noun` arm. But what about when the timer goes off? Behn will create a `gift`, a similar construct to how we created an `effect`, only this time it will end up being dispatched back to us via Gall in the `++wake` arm. Any app that wants to use a timer trigger needs to have an arm called `++wake`.
99+That's all for our `poke-noun` arm. But what about when the timer goes off? Behn will create a `gift`, a similar construct to how we created an `card`, only this time it will end up being dispatched back to us via Gall in the `++wake` arm. Any app that wants to use a timer trigger needs to have an arm called `++wake`.
100
100
101```hoon
101```hoon
102++ wake
102++ wake
103 |= [=wire error=(unit tang)]
103 |= [=wire error=(unit tang)]
104− ^+ [*(list effect) +>.$]
104+ ^+ [*(list card) +>.$]
105 ~& "Timer went off!"
105 ~& "Timer went off!"
106 [~ +>.$]
106 [~ +>.$]
107```
107```
108
108
109−`wake` is a `gate` that has two arguments: a `wire`, and a `(unit tang)` with the face `error`. The syntax of `=wire` is a shortcut for `wire=wire`; it's a common pattern to shadow the name of a type when you only have one instance of the type and are not going to refer to the type itself. A `wire` is just an alias for `path`. Our `wire` will be the `path` that we gave original `syscall`. If we needed to do something based on which request caused this gate to be called, we could use the wire to do so. In this case, we don't do perform such a dispatch.
109+`wake` is a `gate` that has two arguments: a `wire`, and a `(unit tang)` with the face `error`. The syntax of `=wire` is a shortcut for `wire=wire`; it's a common pattern to shadow the name of a type when you only have one instance of the type and are not going to refer to the type itself. A `wire` is just an alias for `path`. Our `wire` will be the `path` that we gave original `move`. If we needed to do something based on which request caused this gate to be called, we could use the wire to do so. In this case, we don't do perform such a dispatch.
110
110
111Next we have the same cast we used in `++poke-noun` to make sure we are producing the correct thing for Gall. These casts are not strictly necessary, as the type system can infer what the type will be, but they can be very useful both for debugging our own code and for someone else trying to determine what our code should be producing.
111Next we have the same cast we used in `++poke-noun` to make sure we are producing the correct thing for Gall. These casts are not strictly necessary, as the type system can infer what the type will be, but they can be very useful both for debugging our own code and for someone else trying to determine what our code should be producing.
112
112
@@ -116,4 +116,4 @@ Next we have the same cast we used in `++poke-noun` to make sure we are producin
116
116
117`~&` is the debugging printf rune. Here we're using it to output a message. We could, however, modify this line of code to do any other computation we would want to happen when `++wait` gets called.
117`~&` is the debugging printf rune. Here we're using it to output a message. We could, however, modify this line of code to do any other computation we would want to happen when `++wait` gets called.
118
118
119−Finally, we need to produce our `effect`. Here the effect is simply `[~ +>.$]`, since we have no `syscall` to make and we are not changing the state of our app. We just use the `door` without changing its sample.
119+Finally, we need to produce our `card`. Here the effect is simply `[~ +>.$]`, since we have no `move` to make and we are not changing the state of our app. We just use the `door` without changing its sample.