11# Looping & Branching
22
3- We’ve now seen how commands work with [ choice types] ( /types/choice.md ) (via selection),
4- and [ function types] ( /types/function.md ) (via sending). But those aren’t the only types that
3+ We’ve now seen how commands work with [ choice types] ( ../.. /types/choice.md) (via selection),
4+ and [ function types] ( ../.. /types/function.md) (via sending). But those aren’t the only types that
55come with their own command styles. Every type does.
66
77Let’s turn our attention to something more intricate: ** recursive types.**
@@ -15,8 +15,8 @@ type List<a> = recursive either {
1515}
1616```
1717
18- The ` List ` type is [ recursive] ( /types/recursive.md ) , and contains an
19- [ ` either ` ] ( / types/either.md) , and within that, a [ pair] ( /types/pair.md ) .
18+ The ` List ` type is [ recursive] ( ../.. /types/recursive.md) , and contains an
19+ [ ` either ` ] ( ../../ types/either.md) , and within that, a [ pair] ( ../.. /types/pair.md) .
2020
2121To work with such a structure in process syntax, we’ll need to combine three kinds of commands:
2222
@@ -69,15 +69,15 @@ not return something.
6969
7070There's another key difference: notice the ` .item ` branch has ` => ` right after the branch name!
7171There's no pattern. That's because in process syntax, binding the payload of an
72- [ either] ( /types/either.md ) is optional. Normally, ** the subject itself becomes the payload.**
72+ [ either] ( ../.. /types/either.md) is optional. Normally, ** the subject itself becomes the payload.**
7373However, it is possible to match the payload fully, if desired.
7474
7575So, inside the ` .item ` branch, ` strings ` now has the type ` (String) List<String> ` — it’s a pair, and
7676we want to peel off its first part, to add it to the string builder.
7777
7878There's ** one last important detail,** and that's concerning ** control flow.** If a ` .case `
7979branch process does not end (we'll learn about ending processes in the section about
80- [ ` chan ` expressions] ( /processes /chan_expression.md) ), then it proceeds to the next line after the closing
80+ [ ` chan ` expressions] ( .. /chan_expression.md) ), then it proceeds to the next line after the closing
8181parenthesis of the ` .case ` command. All local variables are kept.
8282
8383## Receiving
@@ -117,7 +117,7 @@ tagging along the control flow of `strings`.
117117## Patterns in ` .case ` branches
118118
119119The ` .item => ` branch can be made a little more pleasant. If the subject after .begin is a
120- [ pair] ( /types/pair.md ) , we’re allowed to use pattern matching directly in the ` .case ` branch.
120+ [ pair] ( ../.. /types/pair.md) , we’re allowed to use pattern matching directly in the ` .case ` branch.
121121
122122That means this:
123123
@@ -157,10 +157,10 @@ def TestConcat = Concat(*("A", "B", "C")) // = "ABC"
157157```
158158
159159This beautifully ties together all the commands we've covered so far:
160- - ** Selection** for [ choices] ( /types/choice.md ) .
161- - ** Sending** for [ functions] ( /types/function.md ) .
162- - ** Branching** for [ eithers] ( /types/either.md ) .
163- - ** Receiving** for [ pairs] ( /types/pair.md ) . Here, in the form of a pattern.
160+ - ** Selection** for [ choices] ( ../.. /types/choice.md) .
161+ - ** Sending** for [ functions] ( ../.. /types/function.md) .
162+ - ** Branching** for [ eithers] ( ../.. /types/either.md) .
163+ - ** Receiving** for [ pairs] ( ../.. /types/pair.md) . Here, in the form of a pattern.
164164
165165The _ receive commands_ is the least clearly useful here. Let's move to infinite sequences to see a
166166more compelling use-case.
0 commit comments