-
Notifications
You must be signed in to change notification settings - Fork 501
Improve error handling, safety, readability; replace unsafe patterns. #7446
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
base: master
Are you sure you want to change the base?
Improve error handling, safety, readability; replace unsafe patterns. #7446
Conversation
… modernize sorting ✅ Pull Request: Improve Error Handling, Safety & Readability Summary This pull request improves the stability, safety, and readability of the PIR tool without changing its core functionality. Changes Made Replaced unsafe pattern matches on Program with safe bindings. Replaced raw error calls with friendly error messages + exitFailure. Improved readability in retention analysis and name table generation. Updated sorting using Down for cleaner intent. Added simple CLI messages for better user feedback. Added comments explaining intentional orphan instances. Removed minor redundancies and improved formatting. Why This Matters These changes: Prevent sudden crashes caused by pattern-match failures Make CLI errors easier to understand Improve maintainability Do not change logic or output format No Functional Behavior Changed This PR is safe, review-friendly, and strictly improves code quality.
|
This PR improves the PIR tool by:
All CI checks are expected to pass; feedback is welcome. |
| Left e -> error $ show e | ||
| Right t -> writeProgram outp (pirFormatToFormat ofmt) mode | ||
| (Program () PLC.latestVersion(void t)) | ||
| prog <- readProgram (pirFormatToFormat ifmt) inp |
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.
Honestly this is superb, Dev
This .hs file is easy to comprehend.
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 this quite literally made it worse. But feel free to elaborate how it is superb.
zliu41
left a comment
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.
You removed most if not all comments from this module. Why do you think they should be removed?
Replacing unsafe patterns with safer alternatives
Which specific patterns were unsafe? Please elaborate
Enhancing error handling and readability
How is error handling improved? Please elaborate
Minor optimizations for analysis and CSV output
What optimizations? How do they work? Please elaborate
| Left e -> error $ show e | ||
| Right t -> writeProgram outp (pirFormatToFormat ofmt) mode | ||
| (Program () PLC.latestVersion(void t)) | ||
| prog <- readProgram (pirFormatToFormat ifmt) inp |
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 this quite literally made it worse. But feel free to elaborate how it is superb.
… modernize sorting
✅ Pull Request: Improve Error Handling, Safety & Readability Summary
This pull request improves the stability, safety, and readability of the PIR tool without changing its core functionality.
Changes Made
Replaced unsafe pattern matches on Program with safe bindings.
Replaced raw error calls with friendly error messages + exitFailure.
Improved readability in retention analysis and name table generation.
Updated sorting using Down for cleaner intent.
Added simple CLI messages for better user feedback.
Added comments explaining intentional orphan instances.
Removed minor redundancies and improved formatting.
Why This Matters
These changes:
Prevent sudden crashes caused by pattern-match failures
Make CLI errors easier to understand
Improve maintainability
Do not change logic or output format
No Functional Behavior Changed
This PR is safe, review-friendly, and strictly improves code quality.
Pre-submit checklist: