The latest typed-fsm-zig simplifies the state and allows state transition functions based on state transition messages, which is a victory for abstraction.
is there a way to have the GUI loop managed externally from the state machine logic?
From what I understand, your FSM can’t retain static typing unless genMsg runs the gui loop to retrieve the user input.
But, there are situations where the GUI can’t be run directly from genMsg(), for example if it’s managed by a host application.
I’ve looked into it, and I can’t find a solution: no matter what, if genMsg doesn’t own the loop, then you have to resort to using a dispatcher function, which nullifies the strong typing…
IMO, it has some pretty interesting ideas that go a long way toward making illegal states materialize as type errors. It uses Singletons to do much of that. I wonder is that plausible or possible in Zig?
Another cool feature is being able to generate a diagram of all possible states and transitions solely using the code.