Repository navigation
Distinguish between true package names, and munged package names - #4382
Conversation
|
@Ericson2314, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ezyang, @23Skidoo and @dcoutts to be potential reviewers. |
| Just n -> n | ||
| Nothing -> pkgName $ Installed.sourcePackageId ipi, | ||
| Nothing -> mkPackageName $ unMungedName | ||
| $ mungedName $ Installed.sourceMungedId ipi, |
There was a problem hiding this comment.
This deserves a comment, since it is doing something dodgy.
There was a problem hiding this comment.
Well hmm, I moved the functionality to Distribution.InstalledPackageInfo, and give a it a quick comment, but perhaps the fact that ghc-pkg can strip this metadata so care must be taken should also be mentioned.
| instance Package (ConfiguredPackage loc) where | ||
| packageId cpkg = packageId (confPkgSource cpkg) | ||
|
|
||
| instance HasMungedId (ConfiguredPackage loc) where |
There was a problem hiding this comment.
Should I everywhere rename MungedId to MungedPackageId? I don't think this is any more or less clear than the type itself.
| -- 'sourcePackageId' actually stores a *munged* version of the | ||
| -- package identifier that also incorporates the component name. | ||
| -- The /real/ package name is stored in 'sourcePackageName'. | ||
| sourcePackageId :: PackageId, |
There was a problem hiding this comment.
At the very least, we need a compatibility definition of sourcePackageId from this module. You can DEPRECATE it if you like.
There was a problem hiding this comment.
Ah, that would solve most problems. Should it recover original name or just be straight synonym?
There was a problem hiding this comment.
Well, it depends on whether or not sourcePackageId returns a PackageId or a MungedId ;)
| "/* DO NOT EDIT: This file is automatically generated by Cabal */\n\n" ++ | ||
| generatePackageVersionMacros | ||
| (package pkg_descr : map snd (componentPackageDeps clbi)) ++ | ||
| (computeCompatPackageId (package pkg_descr) CLibName |
There was a problem hiding this comment.
This is a no-op right, because CLibName always is the real package name.
There was a problem hiding this comment.
Yeah, it's a no-op. I like to convert in this way this as a warning sign that the code might not be very component-aware.
| data PackageIdentifier = PackageIdentifier { | ||
| pkgName :: String, | ||
| pkgVersion :: Version | ||
| data MungedId = MungedId { |
There was a problem hiding this comment.
This isn't right. The reason why PackageIdentifier is redefined here is because the conversion function needs the Read instance (see below) to be compatible with the output of a Show instance from an old version of Cabal. If you change the data structure as you've done here, you break the Read instance!
There was a problem hiding this comment.
Can we change the type name as long as the constructor stays the same? I'm trying that.
There was a problem hiding this comment.
Not only does the constructor have to be, but each record selector has to be the same.
ezyang@sabre:~$ runghc T.hs
MkT {f = 2}
ezyang@sabre:~$ cat T.hs
data T = MkT {f :: Int }
deriving (Show)
main = print (MkT 2)
| {-# LANGUAGE DeriveDataTypeable #-} | ||
| {-# LANGUAGE DeriveGeneric #-} | ||
| module Distribution.Types.MungedId | ||
| ( MungedId(..) |
There was a problem hiding this comment.
Let's make this abstract please.
There was a problem hiding this comment.
Oh oops that was never intended.
|
There are also general BC considerations which I've mentioned to @Ericson2314 on IRC. |
|
Ok fixed everything but the opacity. Whatever is done there I think is best to do in a second commit (though in this PR is fine.) To put some things into context, I just thought of an example why we hypothetically might want to change I guess this would be an argument for opacity if we can default new fields in a back-compat way (for construction). Perhaps they both should be opaque? The consistency would make me feel better about it, I think. |
There should be little-to-no functional changes with this commit
It depends on how you setup the smart constructor. One reasonably forwards compatible scheme is to have the constructor take package name, library name, and version number. Then you can switch representation between (MungedName, Version) versus (PackageName, LibraryName, Version).
The difference is making PackageId opaque is a (gasp) BC-breaking change ;) |
This reverts commit 4774fb6.
This reverts commit 4774fb6.
This reverts commit 4774fb6.
Distinguish between true package names, and munged package names
There should be little-to-no functional changes with this commit