on master help sign in
Egg timer, card -> move
e350b23Fang
tutorials/hoon/egg-timer.md+6−6
@@ -21,7 +21,7 @@ The Arvo operating system is divided up into modules called vanes. Gall is the v
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 card) +>.$]
24+ ^+ [*(list move) +>.$]
25 ~& "Timer went off!"
25 ~& "Timer went off!"
26 [~ +>.$]
26 [~ +>.$]
27--
27--
@@ -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 card) +>.$]
62+ ^+ [*(list move) +>.$]
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 `card`, 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 `move`, 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
@@ -96,12 +96,12 @@ The final part of this `move` 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 `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`.
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 a `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 card) +>.$]
104+ ^+ [*(list move) +>.$]
105 ~& "Timer went off!"
105 ~& "Timer went off!"
106 [~ +>.$]
106 [~ +>.$]
107```
107```
@@ -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 `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.
119+Finally, we need to produce our `move`. 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.