@@ -24,7 +24,7 @@ Table of Contents
2424 * [ Block #2 : defining stateful functions] ( #block-2-defining-stateful-functions )
2525 * [ Block #3 : signing statements] ( #block-3-signing-statements )
2626 * [ Block #4 : registering namespaces] ( #block-4-registering-namespaces )
27- * [ Block #4 : playing a multiplayer game] ( #block-5-playing-a-multiplayer-game )
27+ * [ Block #5 : playing a multiplayer game] ( #block-5-playing-a-multiplayer-game )
2828* [ Technical Overview] ( #technical-overview )
2929 * [ Blocks] ( #blocks )
3030 * [ Statements] ( #statements )
@@ -147,11 +147,21 @@ You can run it offline by installing Kindelia and entering the command below:
147147kindelia run block_1.kdl
148148```
149149
150- When a Kindelia node runs that block, the global function ` Sum ` will be defined
151- forever inside the network. Note how it follows a functional style, closely
152- resembling Haskell's equational notation. Kindelia functions aren't compiled to
153- fit stack machines: they run natively as is, because beta reduction and pattern
154- matching are primitive, O(1) opcodes on the HVM.
150+ This will output the following execution log:
151+
152+ ``` c
153+ [ctr] Leaf
154+ [ctr] Branch
155+ [fun] Sum
156+ [run] #10 [26 mana | 0 size]
157+ ```
158+
159+ When a Kindelia node runs that block, the constructors ` Leaf ` and ` Branch ` , as
160+ well as the global function ` Sum ` , will be defined forever inside the network.
161+ Note how it follows a functional style, closely resembling Haskell's equational
162+ notation. Kindelia functions aren't compiled to fit stack machines: they run
163+ natively as is, because beta reduction and pattern matching are primitive, O(1)
164+ opcodes on the HVM.
155165
156166Other than defining constructors and functions, blocks can also evaluate
157167side-effective actions inside ` run {} ` statements. These operate like Haskell's
@@ -219,6 +229,16 @@ run {
219229}
220230```
221231
232+ It outputs:
233+
234+ ```
235+ [ctr] Inc
236+ [ctr] Get
237+ [fun] Counter
238+ [run] #0 [54 mana | 0 size]
239+ [run] #3 [30 mana | 0 size]
240+ ```
241+
222242Note that ` load ` and ` save ` aren't side-effective functions. Instead, they
223243* describe* effects using a pure datatype, exactly like Haskell's IO. These
224244effects can be passed as first-class expressions, and are evaluated when placed
@@ -255,11 +275,20 @@ run {
255275}
256276```
257277
258- That hexadecimal string represents the secp256k1 signature of the serialization
259- of the ` run{} ` statement above. This will set the * subject* of the execution as
260- the signer, changing the behavior of the ` IO.subj ` and ` IO.from ` primitives,
261- which return the subject's name, and the caller's name, respectively. To sign a
262- statement, just place it at the end of a ` .kdl ` file, and enter the command:
278+ It outputs:
279+
280+ ``` c
281+ [run] #656161725219724531611238334681629285 [2 mana | 0 size]
282+ ```
283+
284+ That hexadecimal string inside ` sign{} ` represents the secp256k1 signature of
285+ the serialization of the ` run{} ` statement above. The result shown is the
286+ decimal for ` 7e5f4552091a69125d5dfcb7b8c265 ` , which is the first 15 bytes of the
287+ signer's address. Signing a statement has the effect of changing the * subject*
288+ of the execution to be the signer's identity, affecting the behavior of the
289+ ` IO.subj ` and ` IO.from ` primitives, which return the subject's name, and the
290+ caller's name, respectively. To sign a statement, just place it at the end of a
291+ ` .kdl ` file, and enter the command:
263292
264293```
265294kindelia sign block_file.kdl key_file
@@ -329,6 +358,15 @@ run {
329358}
330359```
331360
361+ It outputs:
362+
363+ ```c
364+ [reg] #x2b5ad5c4795c026514f8317c7a215e Foo
365+ [reg] #x6813eb9362372eef6200f3b1dbc3f8 Foo.Bar
366+ [fun] Foo.Bar.cats
367+ [run] #42 [2 mana | 0 size]
368+ ```
369+
332370Block #5 : playing a multiplayer game
333371------------------------------------
334372
@@ -353,7 +391,7 @@ Statements
353391
354392Kindelia statements alter the network's state. They can be one of 4 variants:
355393
356- ### [ CTR] : defines a new constructor
394+ ### ` CTR ` : defines a new constructor
357395
358396#### Syntax:
359397
@@ -377,7 +415,9 @@ ctr {
377415
378416- Output the defined constructor.
379417
380- ### [ FUN] : defines a new function
418+ ### ` FUN ` : defines a new function
419+
420+ #### Syntax:
381421
382422``` c
383423fun (Name arg_0 arg_1 ...) {
@@ -408,7 +448,7 @@ fun (Name arg_0 arg_1 ...) {
408448
409449- Output the defined function.
410450
411- ### [ RUN] : runs an IO expression
451+ ### ` RUN` : runs an IO expression
412452
413453#### Syntax:
414454
@@ -438,7 +478,9 @@ run {
438478
439479- Output the normalized result.
440480
441- ### [ REG] : registers a namespace
481+ ### ` REG ` : registers a namespace
482+
483+ #### Syntax:
442484
443485``` c
444486reg Name {
0 commit comments