-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete the build-depends internal reform in Cabal
- Loading branch information
1 parent
b9896bb
commit 67f932e
Showing
9 changed files
with
123 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DeriveDataTypeable #-} | ||
module Distribution.Types.LibDependency ( | ||
LibDependency(..), | ||
libDependencyToDependency, | ||
libDependencyToMixin, | ||
simplifyLibDependency, | ||
) where | ||
|
||
import Prelude () | ||
import Distribution.Compat.Prelude | ||
|
||
import Distribution.Package | ||
import Distribution.Types.UnqualComponentName | ||
import Distribution.Types.Mixin | ||
import Distribution.Types.Dependency | ||
import Distribution.Types.IncludeRenaming | ||
import Distribution.Version | ||
|
||
import Distribution.Compat.ReadP | ||
import Distribution.Text | ||
import Text.PrettyPrint as PP ((<+>), text, empty) | ||
|
||
-- | Like 'Dependency', but this corresponds exactly to the syntax we support in | ||
-- a Cabal file. | ||
data LibDependency = LibDependency { | ||
libDepPackageName :: PackageName, | ||
libDepLibraryName :: Maybe UnqualComponentName, | ||
libDepVersionRange :: VersionRange | ||
} | ||
deriving (Generic, Read, Show, Eq, Typeable, Data) | ||
|
||
instance Binary LibDependency | ||
instance NFData LibDependency where rnf = genericRnf | ||
|
||
instance Text LibDependency where | ||
disp (LibDependency name mCname ver) = | ||
(disp name <<>> dispMaybeCname) <+> disp ver | ||
where | ||
dispMaybeCname = case mCname of | ||
Nothing -> PP.empty | ||
Just cname -> text ":" <<>> disp cname | ||
|
||
parse = do name <- parse | ||
mb_cname <- option Nothing $ do | ||
_ <- char ':' | ||
fmap Just parse | ||
skipSpaces | ||
ver <- parse <++ return anyVersion | ||
return (LibDependency name mb_cname ver) | ||
|
||
libDependencyToDependency :: LibDependency -> Dependency | ||
libDependencyToDependency (LibDependency pn _ vr) = Dependency pn vr | ||
|
||
libDependencyToMixin :: LibDependency -> Mixin | ||
libDependencyToMixin (LibDependency pn cn _) = Mixin pn cn defaultIncludeRenaming | ||
-- | Simplify the 'VersionRange' expression in a 'Dependency'. | ||
-- See 'simplifyVersionRange'. | ||
-- | ||
simplifyLibDependency :: LibDependency -> LibDependency | ||
simplifyLibDependency (LibDependency name mb_cname range) = | ||
LibDependency name mb_cname (simplifyVersionRange range) |