Skip to content

Make more dependency types #4067

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

Merged
merged 3 commits into from
Nov 2, 2016
Merged

Conversation

Ericson2314
Copy link
Collaborator

This is a follow-up to #4057, so until that is dealt with this diff will also be humongous and unreviewable.

This PR makes separate types for different types of dependencies:

  • Dependency is now just for regular (usually library) dependencies on haskell packages
  • LegacyExeDependecy for legacy build-tools dependencies
  • PkgconfigDependecy for pkg-config dependencies

Additionally, there is a newtype PkgconfigName for pkg-config library names. For Cabal's uses alone this wouldn't be worth it, but cabal-install already distinguishes these libraries widely with PackageName. Continuing to use PackageName seemed inconsistent with the newly-rigorous use of Dependecy, while going back to String seemed like a step backwards.

Plain String is used for legacy built tool names, as those can mean quite different things, and very little code was using PackageName and not String for them.

Note I had to make some orphan instances (module-wise, not package-wise) in order to avoid a Distribution.ParserUtils <-> Distribution.Package cyclic dep. This can go away once the old parser is removed.

@mention-bot
Copy link

@Ericson2314, thanks for your PR! By analyzing the history of the files in this pull request, we identified @dcoutts, @phadej and @ezyang to be potential reviewers.

@ezyang
Copy link
Contributor

ezyang commented Oct 31, 2016

CI failures are real. If you try compiling with -Werror that should help you catch the warnings (CI will fail unless you are warnings-free.)

@ezyang
Copy link
Contributor

ezyang commented Oct 31, 2016

CC @phadej especially on b729cff ; @Ericson2314 spotted an inconsistency with the Parsec parser and the old parser: whether or not quoted strings in build-tools are allowed.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Marvelous! All we need to do is kill the CI failures :)

@@ -19,6 +19,7 @@
-- This module is meant to be local-only to Distribution...

{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE Rank2Types #-}
Copy link
Contributor

Choose a reason for hiding this comment

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

OK, excellent use of rank 2 types :)

@@ -138,6 +141,39 @@ unPackageName = unUnqualComponentName . packageNameToUnqualComponentName
mkPackageName :: String -> PackageName
mkPackageName = PackageName . mkUnqualComponentName

-- | A pkgconfig library name
Copy link
Contributor

Choose a reason for hiding this comment

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

But what is a pkgconfig library name?! Answer: "a valid argument to the pkg-config utility".

@@ -317,19 +353,24 @@ mkLegacyUnitId = newSimpleUnitId . mkComponentId . display
data Dependency = Dependency PackageName VersionRange
deriving (Generic, Read, Show, Eq, Typeable, Data)

instance Binary Dependency
-- | Describes a legacy `build-tools`-style dependency on an executable
Copy link
Contributor

Choose a reason for hiding this comment

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

It is "legacy" because we do not know if the build-tool referred to, refers to a pkg-config executable, or an internal executable (thus it is stringly typed.)

-- | Describes a legacy `build-tools`-style dependency on an executable
--
data LegacyExeDependency = LegacyExeDependency
String -- ^ name of one of the hardcoded understood tools
Copy link
Contributor

Choose a reason for hiding this comment

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

Not always a hardcoded tool, right?

@@ -0,0 +1,56 @@
-- | *Dependency Text instances moved from Distribution.Package
{-# OPTIONS_GHC -fno-warn-orphans #-}
Copy link
Contributor

Choose a reason for hiding this comment

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

OK for now. Let's refactor it away later.

@Ericson2314
Copy link
Collaborator Author

Ah to be I opened up a separate PR for the parser commit so @phadej can ignore this.

@Ericson2314 Ericson2314 force-pushed the dep-types branch 4 times, most recently from 59b9d20 to 4cad7b0 Compare November 1, 2016 14:18
@Ericson2314
Copy link
Collaborator Author

Distribution/Package.hs:407:28: parse error on input ‘VersionRange’

There's a haddock error but not sure what's wrong. Would -- ^ be required for every field?

@ezyang
Copy link
Contributor

ezyang commented Nov 1, 2016

I guess so. Add it and see?

@Ericson2314
Copy link
Collaborator Author

Ericson2314 commented Nov 1, 2016

Ah, need a record for per-field documentation. https://www.haskell.org/haddock/doc/html/ch03s02.html

    Plain `Dependency` should strictly refer to a Haskell Package, usually the
    library component of that package.
@Ericson2314
Copy link
Collaborator Author

No point documenting per-variant if there's only one, so I removed the -- ^.

@Ericson2314
Copy link
Collaborator Author

@ezyang also despite the not-invalidated diffs aboved I think I fixed everything you mentioned if you want to toggle your review :).

@Ericson2314 Ericson2314 changed the title [WIP] Make more dependency types Make more dependency types Nov 2, 2016
@Ericson2314 Ericson2314 merged commit 8bccb4d into haskell:master Nov 2, 2016
@Ericson2314 Ericson2314 deleted the dep-types branch November 2, 2016 04:20
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