Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
goless
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
6 ms
·
1.
▲
by
goless
7mo ago
In the world of distributed systems, we often find ourselves caught in a dilemma: a protocol requires the collaboration of multiple roles, yet the behavioral logic of each role must be implemented separately. As a result, the exact same con
2.
▲
by
goless
8mo ago
Troupe is a distributed protocol construction library built on Zig's type system. Its core philosophy is using type determinism to counter communication uncertainty: protocols are modeled as fully deterministic state machines, correctn
3.
▲
Troupe:multi-role finite state machine
(ziggit.dev)
2 points
by
goless
11mo ago
|
1 comments
4.
▲
by
goless
11mo ago
Multi-role finite state machine, used for multithreaded programs or distributed programs. The behaviors of multiple characters are orchestrated into a state machine. Imagine a theater with many characters performing a play. The behaviors of
5.
▲
by
goless
1y ago
How to Properly Use Polystate? The correct way to use polystate is: reason about program behavior through symbols, then transform these symbols into code. https://github.com/sdzx-1/ray-game/blob/master/Ho
6.
▲
by
goless
1y ago
I changed the file name, here is the new article!
7.
▲
by
goless
1y ago
https://github.com/sdzx-1/ray-game/blob/master/How-to-proper...
8.
▲
How to Properly Use Polystate?
(github.com)
1 points
by
goless
1y ago
|
3 comments
9.
▲
by
goless
1y ago
The correct way to use polystate is: reason about program behavior through symbols, then transform these symbols into code. This might sound bewildering, but don't worry - I'll explain this process through concrete examples.
10.
▲
by
goless
1y ago
Due to my submission yesterday, this diagram can no longer fully accurately express the current state machine, but it can probably be used as an approximate reference.
11.
▲
by
goless
1y ago
https://github.com/sdzx-1/polystate/raw/master/data/graph.pn... This is the state diagram combining two selects!
12.
▲
by
goless
1y ago
Haha, thanks for your reply, I will improve my documentation to make the descriptions more accurate, and you may raise some issues to help this library better. As for why semantic composition is used, the following example may be instructiv
13.
▲
by
goless
1y ago
Here I must mention the great advantage of the Zig language: it has the expressiveness of a dynamic language and the type safety of a static language.
14.
▲
by
goless
1y ago
I'm not sure if this is a new form of state machine. If you look at the code here you'll see that the select state uses some functions from the parameter state. https://github.com/sdzx-1/ray-game/blob
15.
▲
by
goless
1y ago
Try modifying it yourself, you will fall in love with this way of programming.
16.
▲
by
goless
1y ago
In fact, relying on this monad, we can achieve full type safety for multi-role communication. https://github.com/sdzx-1/typed-session
17.
▲
by
goless
1y ago
I once wrote a library typed-fsm https://github.com/sdzx-1/typed-fsm It has a completely type-safe finite state machine, and it does not require additional programming conventions. It relies on a special monad: Mcbrid
18.
▲
by
goless
1y ago
In fact, I have introduced this in detail here. It is a kind of finite state machine programming, and everything that FSM can solve is suitable for it.
19.
▲
by
goless
1y ago
Haha, this is just a demo, written casually, you can change this to exit, and then as you expected, the program will exit directly.
20.
▲
by
goless
1y ago
From this perspective, do you think my previous description is accurate?
21.
▲
by
goless
1y ago
Is there a way to combine: Higher order finite state machines that require other states as parameters to work. https://github.com/sdzx-1/ray-game/blob/master/src/select.zi... The select, inside, and
22.
▲
by
goless
1y ago
Yes the expression may not be precise enough, but the example should be accurate enough. 1, https://github.com/sdzx-1/polystate?tab=readme-ov-file#2-imp... This shows what composition means, and even complex nested sel
23.
▲
by
goless
1y ago
Sorry, I am not familiar with Rust. Although I try hard to understand this library, I cannot say that I understand it. I have two questions here: 1. How to express uncertain state in type. In my example, it is implemented by union (enum) +
24.
▲
by
goless
1y ago
I need some time to get to this library.
25.
▲
by
goless
1y ago
I don't know much about XState but it looks more like a dynamically interpreted execution state machine.
26.
▲
by
goless
1y ago
Yes, but their expressiveness may vary. An important role of polystate is code reuse. It can express more complex states and still be type-safe.
27.
▲
by
goless
1y ago
Yes, FSMs are underestimated in imperative programming. Of course this is probably because before type-safe state machines were available, manual coding was very error-prone.
28.
▲
by
goless
1y ago
Yes, all my examples have state diagrams, they are automatically generated and are an effective way for me to understand the structure of the program.
29.
▲
by
goless
1y ago
Fixed, thanks for your reminder!!
30.
▲
by
goless
1y ago
Thanks for your reply, I will try to understand your code carefully, which may take some time. I have a raw haskell prototype of polystate here, maybe it will help you. https://github.com/sdzx-1/typed-gui/blob/
More ›