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

Change MungedPackageName to not be opaque #5812

Merged
merged 3 commits into from
Jan 6, 2019
Merged

Change MungedPackageName to not be opaque #5812

merged 3 commits into from
Jan 6, 2019

Conversation

phadej
Copy link
Collaborator

@phadej phadej commented Dec 21, 2018

See commit messages.

cabal-install is not done. Asking for the review now already. I think cabal-install part should be quite straight-forward fixing of type errors

@phadej phadej requested review from ezyang, hvr, typedrat and fgaz December 21, 2018 12:50
@phadej
Copy link
Collaborator Author

phadej commented Dec 21, 2018

Travis is green. Review would be highly appreciated.

i.e. strict pair of PackageName and LibraryName
the legacy conversion is done via Pretty/Parsec instances.

Change of `Maybe UnqualComponentName` to `LibraryName` caused
a cascade of other changes, but they all seem to be good changes.
In the sense, they made many comments not-so-necessary.

Add Distribution.Types.PackageName.Magic for special package names.

Updates in cabal-install are mostly trivial type error driven changes.
I removed few (deprecated) `Text` instances: `MungedPackageId`,
`MungedPackageName` and `LibraryName`. Turns out only a `Pretty`
part was used, so it was easy to update. Note: `LibraryName`
doesn't have `Pretty` / `Parsec` instances as it's either parsed/printed
as a `ComponentName` or `UnqualComponentName`, never stand alone.
Copy link
Member

@fgaz fgaz left a comment

Choose a reason for hiding this comment

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

lgtm except some comments

When this is merged we can also mark https://github.com/haskell/cabal/wiki/Potential-Refactors#maybe-unqualcomponentname as done. Thanks for this!

@@ -370,6 +370,7 @@ library
Distribution.Types.LibraryName
Distribution.Types.MungedPackageName
Distribution.Types.PackageName
Distribution.Types.PackageName.Magic
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be a separate commit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not easily. Won't do.

@@ -1230,7 +1229,7 @@ selectDependency pkgid internalIndex installedIndex requiredDepsMap
-- even if there is a newer installed library "MyLibrary-0.2".
case Map.lookup dep_pkgname internalIndex of
Just cname -> if use_external_internal_deps
then do_external (Just cname) <$> Set.toList libs
then do_external (Just $ maybeToLibraryName cname) <$> Set.toList libs
Copy link
Member

Choose a reason for hiding this comment

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

I think the internalIndex should be Map PackageName LibraryName instead of Map PackageName (Maybe UnqualComponentName) (I checked where it originates and it seems to be doable)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Won't fix. Properly done current Map PackageName (Maybe UnqualComponentName) into a newtype over Map PackageName LibraryName

<$> optionalFieldDefAla "name" MQuoted basicName (mungedPackageName emptyInstalledPackageInfo)
<*> optionalFieldDefAla "version" MQuoted basicVersion nullVersion
<*> optionalField "package-name" basicPkgName
<*> optionalField "lib-name" basicLibName
where
mkBasic n v pn ln = Basic n v pn (maybe LMainLibName LSubLibName ln)
Copy link
Member

Choose a reason for hiding this comment

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

basicLibName should be of type LibraryName

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's not exported. wont'fix. (Also LibraryName doesn't have Parsec instance on purpose, so I'd need to introduce newtype etc.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe even using InstalledPackageIndex would make sense, even it's not "installed", but "package index" anyway.

@phadej phadej merged commit b96c601 into master Jan 6, 2019
@phadej phadej deleted the munged-rep branch January 6, 2019 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants