-
Notifications
You must be signed in to change notification settings - Fork 697
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
Refactor shared TargetProblem data types into their own module. #6774
Refactor shared TargetProblem data types into their own module. #6774
Conversation
-- | The various error conditions that can occur when matching a | ||
-- 'TargetSelector' against 'AvailableTarget's which can be extended | ||
-- with command specific target problems as described by 'e'. | ||
data ExtensibleTargetProblem e |
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.
Can TargetProblemCommon
and ExtensibleTargetProblem
be merged into one?
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 would be doable, would just require some more code shuffling. One question would be if we want to inline all of the cases of TargetProblemCommon
into the top level ExtensibleTargetProblem
or if we want to keep the hierarchy as is.
At the least we could move the TargetProblemCommon
definition into TargetProblem.hs
, I'd prefer to leave the change of flattening the hierarchy (if that's what we decide to do) to a follow-up PR to keep this one as simply extracting the repeated code into one location.
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.
Please shuffle code.
TargetProblemCommon
is a good nameExtensibleTargetProblem
is bad nameExtensibleTargetProblemNoTarget
is also bad. First we rename it fromTargetProblemNoTarget
to then rename back toTargetProblemNoTarget
again.
This commit is good start. But I won't merge it. Please at least try TargetProblemCommon
extraction as well in follow up commit, not PR.
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.
See most recent commit, to summarize:
- Rename
ExtensibleTargetProblem
->TargetProblem
(and change alias) - Shorten data constructor names in
TargetProblem
- Extracts
TargetProblemCommon
intoTargetProblem.hs
PTAL!
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.
Good but not enough. As commented.
This adds a new 'ExtensibleTargetProblem e' type which can be used uniformly across the commands, supporting the most common use case of errors being one of: 'common', 'none enabled', or 'no targets'. In cases where custom target errors are needed, the base set can be expanded with a custom problem type, and custom reporting/rendering is supported.
Also: - Rename ExtensibleTargetProblem -> TargetProblem - Rename TargetProblem alias -> TargetProblem' (following convention) - Shorted data constructor names it TargetProblem - Moved "problem rendering" to CmdErrorMessages module
7d9fe46
to
beefecc
Compare
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.
This looks good. I'll resolve problems after #6818 is merged, and do some minor tweaks.
Thanks!
|
||
-- | Target problems that occur during project orchestration. | ||
data TargetProblemCommon | ||
= TargetNotInProject PackageName |
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.
3 spaces, cabal is truly diverse!
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.
Haha! I really wish we could just run a formatter over the whole code base (I don't care which one!) so that I can stop worrying about indentation.
Want me to squash commits in the meantime or will you handle that when you make the tweaks and merge later? |
merged as #6821. Thanks! |
This adds a new 'ExtensibleTargetProblem e' type which can be used uniformly
across the commands, supporting the most common use case of errors being one of:
'common', 'none enabled', or 'no targets'. In cases where custom target errors
are needed, the base set can be expanded with a custom problem type, and custom
reporting/rendering is supported.
Please include the following checklist in your PR:
changelog.d
directory).Please also shortly describe how you tested your change. Bonus points for added tests!