Skip to content

Distinguish between true package names, and munged package names - #4382

Merged
ezyang merged 1 commit into
haskell:masterfrom
Ericson2314:munge
Mar 10, 2017
Merged

ezyang merged 1 commit into
haskell:masterfrom
Ericson2314:munge

Conversation

@Ericson2314

Copy link
Copy Markdown
Collaborator

There should be little-to-no functional changes with this commit

@mention-bot

Copy link
Copy Markdown

@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.

ezyang
ezyang previously requested changes Mar 8, 2017
Just n -> n
Nothing -> pkgName $ Installed.sourcePackageId ipi,
Nothing -> mkPackageName $ unMungedName
$ mungedName $ Installed.sourceMungedId ipi,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This deserves a comment, since it is doing something dodgy.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Heh sure

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Has munged id... of what?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should I everywhere rename MungedId to MungedPackageId? I don't think this is any more or less clear than the type itself.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At your discretion!

-- '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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At the very least, we need a compatibility definition of sourcePackageId from this module. You can DEPRECATE it if you like.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah, that would solve most problems. Should it recover original name or just be straight synonym?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a no-op right, because CLibName always is the real package name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Can we change the type name as long as the constructor stays the same? I'm trying that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

Comment thread Cabal/Distribution/Types/MungedId.hs Outdated
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.MungedId
( MungedId(..)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's make this abstract please.

@Ericson2314 Ericson2314 Mar 8, 2017 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh oops that was never intended.

@ezyang

ezyang commented Mar 8, 2017

Copy link
Copy Markdown
Contributor

There are also general BC considerations which I've mentioned to @Ericson2314 on IRC.

@Ericson2314

Copy link
Copy Markdown
Collaborator Author

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 PackageId and MungedId in practice: to disambiguate between packages' origin in the context of new-build projects using local and git overrides. It's unclear how these other package sources interact with qualified goals---perhaps packages with the same name and version from different origins can exist in the same plan.

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
@ezyang

ezyang commented Mar 9, 2017

Copy link
Copy Markdown
Contributor

I guess this would be an argument for opacity if we can default new fields in a back-compat way (for construction).

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).

Perhaps they both should be opaque? The consistency would make me feel better about it, I think.

The difference is making PackageId opaque is a (gasp) BC-breaking change ;)

@ezyang
ezyang dismissed their stale review March 9, 2017 05:59

new patchset

@ezyang
ezyang merged commit 332d809 into haskell:master Mar 10, 2017
@Ericson2314
Ericson2314 deleted the munge branch March 10, 2017 16:51
ezyang added a commit to ezyang/cabal that referenced this pull request Mar 14, 2017
This reverts commit 332d809, reversing
changes made to 0c72bc8.
@ezyang ezyang mentioned this pull request Mar 14, 2017
ezyang added a commit to ezyang/cabal that referenced this pull request Mar 14, 2017
ezyang added a commit to ezyang/cabal that referenced this pull request Mar 14, 2017
ezyang added a commit to ezyang/cabal that referenced this pull request Mar 17, 2017
This reverts commit 332d809, reversing
changes made to 0c72bc8.
ezyang added a commit to ezyang/cabal that referenced this pull request Mar 17, 2017
ezyang added a commit to ezyang/cabal that referenced this pull request Mar 21, 2017
Distinguish between true package names, and munged package names
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