-
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
Add CLI option to start the game paused #2080
Conversation
app/game/Main.hs
Outdated
appOpts :: Parser AppOpts | ||
appOpts = do | ||
userSeed <- seed | ||
userScenario <- scenario | ||
scriptToRun <- run | ||
pausedAtStart <- paused | ||
autoPlay <- autoplay | ||
speed <- speedFactor | ||
cheatMode <- cheat | ||
colorMode <- color | ||
userWebPort <- webPort | ||
let repoGitInfo = gitInfo | ||
return AppOpts {..} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, it seems GHC 9.2 and 9.4 did not understand the ApplicativeDo
I wanted to use here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe they don't deal properly with ApplicativeDo
+ record wildcards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is unfortunate. Perhaps just put it back the way it was, but add a comment (+ an issue?) to update the code once we drop support for GHC 9.4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Try using pure
instead of return
, perhaps? The error message says No instance for (Monad Parser) arising from a use of ‘return’
This page seems to indicate this style has been possible for a while: https://chshersh.com/recordwildcards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message is wrong - the problem is in the line above containing let
. As GHC docs note:
In particular, slight variations such as
return . Just $ x
orlet x = e in return x
would not be recognised.
Later versions of GHC seem to have gotten better at this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a bit strange to me that if you use the -p
option without --scenario
, it starts the menu but then auto-pauses whatever is the first scenario you choose from the menu. I guess it makes sense though.
app/game/Main.hs
Outdated
appOpts :: Parser AppOpts | ||
appOpts = do | ||
userSeed <- seed | ||
userScenario <- scenario | ||
scriptToRun <- run | ||
pausedAtStart <- paused | ||
autoPlay <- autoplay | ||
speed <- speedFactor | ||
cheatMode <- cheat | ||
colorMode <- color | ||
userWebPort <- webPort | ||
let repoGitInfo = gitInfo | ||
return AppOpts {..} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is unfortunate. Perhaps just put it back the way it was, but add a comment (+ an issue?) to update the code once we drop support for GHC 9.4?
@byorgey, it's not just the first scenario you open; it changes the default for all scenarios to start paused. 🙂 I hope it is an understandable and useful behavior. Could you please also have a look at the added |
I think it should be in the UI state in preparation for asynchronous UI (pr/issue soon). |
Ah, that makes sense.
On the contrary, I think it does belong in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the extra Bool
parameters make sense.
Thanks, @byorgey for thinking that through - that explanation could well be a note in Temporal Game State. 👍 |
You can test it with:
After one step (Ctrl+O) the Goal dialog will show up along with the rest of the UI.