-
Notifications
You must be signed in to change notification settings - Fork 3
/
Status.howl
55 lines (37 loc) · 1.67 KB
/
Status.howl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
⊐̥ System.Math; ⊐ ArgEx = System.ArgumentException;
⊓ Activ.Rx{
‒⌷ᴾ ⊟ status{
⌷ ᆞ ω;
‒̥ ⌷ status done = ⌢ status(+1),
fail = ⌢ status(-1),
cont = ⌢ status( 0);
‒ ㅇ failing → ω ☰ -1;
‒ ㅇ running → ω ☰ 0;
‒ ㅇ complete → ω ☰ +1;
‒ status(ᆞ ω) → ⦿.ω = ω ≥ -1 ∨ ω ≤ +1 ? ω
: throw ⌢ ArgEx($"Init value out of bounds {ω}");
// Sequence/Selector
‒̥ status ⨕ & (status x, status y) → y;
‒̥ status ⨕ | (status x, status y) → y;
‒̥ ㅇ ⨕ true (status s) → s.ω != -1;
‒̥ ㅇ ⨕ false (status s) → s.ω != +1;
// Other operators
‒̥ status ⨕ + (status x, status y) → ⌢ status(Max(x.ω, y.ω));
‒̥ status ⨕ * (status x, status y) → ⌢ status(Min(x.ω, y.ω));
‒̥ status ⨕ % (status x, status y) → ⌢ status(x.ω);
‒̥ status ⨕ ! (status s) → ⌢ status(-s.ω);
‒̥ status ⨕ ~ (status s) → ⌢ status(s.ω * s.ω);
‒̥ status ⨕ + (status s) → ⌢ status(s.ω ☰ +1 ? +1 : s.ω + 1);
‒̥ status ⨕ - (status s) → ⌢ status(s.ω ☰ -1 ? -1 : s.ω - 1);
‒̥ status ⨕ ++ (status s) → +s;
‒̥ status ⨕ -- (status s) → -s;
// Type conversions
⒤ status(ㅇ ⧕) → ⌢ status(⧕ ? +1 : -1);
// Equality and hashing
‒⁺ ㅇ Equals(⊡ x) → x is status ? Equals((status)x) : ✗;
‒ ㅇ Equals(status x) → ⦿ ☰ x;
‒̥ ㅇ ⨕ ☰ (status x, status y) → x.ω ☰ y.ω;
‒̥ ㅇ ⨕ ≠ (status x, status y) → !(x ☰ y);
‒⁺ ᆞ GetHashCode ⎚ ω;
‒⁺ ㄹ ToString ⎚ ω.ToString();
}}