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

Use forM_/mapM_ #2273

Merged
merged 1 commit into from
Jan 6, 2025
Merged

Use forM_/mapM_ #2273

merged 1 commit into from
Jan 6, 2025

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented Jan 6, 2025

Searched for instances of return () and pure (), especially Nothing -> return (), which uncovered several opportunities to use when/unless and mapM_/forM_.

@kostmo kostmo force-pushed the refactor/forM-replacement branch from bb8122b to fa4d9b5 Compare January 6, 2025 17:38
@kostmo kostmo changed the base branch from refactor/ui-gameplay-optional-part1 to main January 6, 2025 17:38
@kostmo kostmo added the Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality. label Jan 6, 2025
@kostmo kostmo requested a review from byorgey January 6, 2025 17:38
@kostmo kostmo marked this pull request as ready for review January 6, 2025 17:38
case capProviders of
Nothing -> throwError $ Incapable FixByEquip (R.singletonCap cap) (TConst c)
Just rawCosts -> payExerciseCost c rawCosts
gets @Robot (constCapsFor c) >>= mapM_ go
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, does it work to write gets @Robot (constCapsFor c) >>= mapM_ \cap -> do ... ? Either is fine though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that works, and I've changed it. However, I was unable to make the same change here (perhaps due to the $ operator).

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, that's odd. Oh well.

Comment on lines +97 to +99
getNormalizedCurrentScenarioPath >>= mapM_ go
where
go p = do
Copy link
Member Author

Choose a reason for hiding this comment

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

cannot inline the lambda here

@kostmo kostmo force-pushed the refactor/forM-replacement branch from fa4d9b5 to d58d237 Compare January 6, 2025 22:35
@kostmo kostmo added the merge me Trigger the merge process of the Pull request. label Jan 6, 2025
@mergify mergify bot merged commit e7b4d65 into main Jan 6, 2025
12 checks passed
@mergify mergify bot deleted the refactor/forM-replacement branch January 6, 2025 22:50
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. Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants