-
Notifications
You must be signed in to change notification settings - Fork 710
Make FlagAssignment
an opaque newtype
#4849
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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.
Looks great, seems quite straightforward. Few comments. 👍.
@@ -26,6 +26,9 @@ module Distribution.Client.BuildReports.Anonymous ( | |||
-- showList, | |||
) where | |||
|
|||
import Prelude (mapM) |
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.
why not traverse
?
@@ -15,6 +15,9 @@ module Distribution.Client.GenBounds ( | |||
genBounds | |||
) where | |||
|
|||
import Prelude (mapM_) |
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.
and traverse_
@@ -267,7 +265,7 @@ sortedFieldDescrs = sortBy (comparing fieldName) fieldDescrs | |||
|
|||
dispFlag :: (FlagName, Bool) -> Disp.Doc | |||
dispFlag (fname, True) = Disp.text (unFlagName fname) | |||
dispFlag (fname, False) = Disp.char '-' <> Disp.text (unFlagName fname) | |||
dispFlag (fname, False) = Disp.char '-' PP.<> Disp.text (unFlagName fname) |
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.
we have <<>>
, but I don't insist.
@@ -922,10 +922,10 @@ configureFinalizedPackage verbosity cfg enabled | |||
-- we do it here so that those get checked too | |||
let pkg_descr = addExtraIncludeLibDirs pkg_descr0' | |||
|
|||
when (not (null flags)) $ | |||
when (flags /= mempty) $ |
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.
should we have nullFlagAssignment
?
@@ -898,7 +898,7 @@ configuredPackageProblems :: Platform -> CompilerInfo | |||
-> SolverPackage UnresolvedPkgLoc -> [PackageProblem] | |||
configuredPackageProblems platform cinfo | |||
(SolverPackage pkg specifiedFlags stanzas specifiedDeps' _specifiedExeDeps') = | |||
[ DuplicateFlag flag | ((flag,_):_) <- duplicates specifiedFlags ] | |||
[ DuplicateFlag flag | ((flag,_):_) <- duplicates (PD.unFlagAssignment specifiedFlags) ] -- FIXME/TODO |
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.
could you comment a little more context to TODO
@@ -419,7 +418,7 @@ planPackages verbosity comp platform mSandboxPkgInfo solver | |||
(PackagePropertyFlags flags) | |||
in LabeledPackageConstraint pc ConstraintSourceConfigFlagOrTarget | |||
| let flags = configConfigurationsFlags configFlags | |||
, not (null flags) | |||
, flags /= mempty |
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.
nullFlagAssignment
fwiw, turning |
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.
LGTM, please merge.
This is a refactoring abstracting `FlagAssignment` while retaining its external appearance as much as possible (i.e. same Read/Show/Binary instances etc). Later we can attach new instances, enforce internal invariants (like e.g. uniqueness of flagnames), switch out the internal representation (maybe to `Data.Map`), etc more easily.
df78926
to
6cb6a51
Compare
This is a refactoring abstracting
FlagAssignment
while retaining itsexternal appearance as much as possible (i.e. same Read/Show/Binary
instances etc).
Later we can attach new instances, enforce internal invariants (like
e.g. uniqueness of flagnames), switch out the internal
representation (maybe to
Data.Map
), etc more easily.Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!