-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scenarioRef should be a non-optional member of UIGameplay #2265
Comments
This makes a lot of sense. Currently, every time we start a scenario we manually reset all of the swarm/src/swarm-tui/Swarm/TUI/Model/StateUpdate.hs Lines 266 to 283 in f5c0700
initUIState . The one exception to this (that I have noticed; there could be others) is the REPL history: we want to be careful to preserve that across scenarios.
Note we could also get rid of the |
Towards #2265. This will be a multi-part refactoring, since `uiGamestate` is accessed in hundreds of places. The more repetition that can be eliminated, the easier it will be to eventually modify the type of the record fields. In this PR, a few no-op refactorings: * use a narrower type in many places (e.g. pass `UIGameplay` rather than `AppState` as function parameter * define local aliases for long lens chains * Use `zoom` for blocks of operations on deeply nested state
scenarioRef
should be a non-optional member ofUIGameplay
, anduiGameplay
should be an optional member ofUIState
.This would encode the invariant that
UIGameplay
pertains to an actively-running scenario. That is, theuiGameplay
member should beNothing
when not playing a particular scenario (i.e. in the toplevel menu), and aJust UIGameplay
while playing. With that, we should be able to guarantee that theUIGameplay
record always has a non-null reference to aScenario
.This would simplify #2264.
The text was updated successfully, but these errors were encountered: