Skip to content
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

Make Tutorial menu choice auto-start first *unsolved* tutorial scenario #2314

Merged
merged 4 commits into from
Feb 8, 2025

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Feb 8, 2025

Choosing Tutorial from the main menu now automatically starts playing the first unsolved tutorial scenario, rather than always starting with the first. Closes #2308.

Copy link
Member

@xsebek xsebek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it, and it works well. 👍

I was worried about what it would do after you had solved all the scenarios:

# --autoplay, but counts as solution:
for s in data/scenarios/Tutorials/*.yaml; do cabal run swarm -- -i $s --run <(yq '.solution' $s); done

Once all are solved, only the first tutorial will open, like the current state.

@byorgey
Copy link
Member Author

byorgey commented Feb 8, 2025

Once all are solved, only the first tutorial will open, like the current state.

Yes, that was on purpose: that is accomplished by the code firstUnsolved = (tutorials >>= find unsolved) <|> (tutorials >>= listToMaybe), which tries to find an unsolved tutorial, but if there isn't one (i.e. if tutorials >>= find unsolved results in Nothing) it falls back to tutorials >>= listToMaybe which takes the first element of the tutorials list.

Note that could still be Nothing if the tutorials list is empty --- see #2309.

@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Feb 8, 2025
@mergify mergify bot merged commit 08afe6a into main Feb 8, 2025
12 checks passed
@mergify mergify bot deleted the feature/first-unsolved-tutorial branch February 8, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Choosing Tutorial from the main menu should take you to the first unsolved tutorial scenario
2 participants