Skip to content

Described Mixin #6800

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 1 commit into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Cabal/Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import Distribution.SPDX
import Distribution.System
import Distribution.Types.Dependency
import Distribution.Types.Flag (FlagAssignment, FlagName, mkFlagAssignment, mkFlagName, unFlagAssignment)
import Distribution.Types.IncludeRenaming
import Distribution.Types.LibraryName
import Distribution.Types.Mixin
import Distribution.Types.ModuleRenaming
import Distribution.Types.PackageId
import Distribution.Types.PackageName
import Distribution.Types.PackageVersionConstraint
Expand Down Expand Up @@ -156,6 +159,22 @@ instance Arbitrary VersionIntervals where
instance Arbitrary Bound where
arbitrary = elements [ExclusiveBound, InclusiveBound]

-------------------------------------------------------------------------------
-- Backpack
-------------------------------------------------------------------------------

instance Arbitrary Mixin where
arbitrary = genericArbitrary
shrink = genericShrink

instance Arbitrary IncludeRenaming where
arbitrary = genericArbitrary
shrink = genericShrink

instance Arbitrary ModuleRenaming where
arbitrary = genericArbitrary
shrink = genericShrink

-------------------------------------------------------------------------------
-- ModuleName
-------------------------------------------------------------------------------
Expand Down
22 changes: 21 additions & 1 deletion Cabal/Cabal-described/src/Distribution/Described.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ import Distribution.Types.Flag (FlagAssignment, FlagName)
import Distribution.Types.ForeignLib (LibVersionInfo)
import Distribution.Types.ForeignLibOption (ForeignLibOption)
import Distribution.Types.ForeignLibType (ForeignLibType)
import Distribution.Types.IncludeRenaming (IncludeRenaming)
import Distribution.Types.LegacyExeDependency (LegacyExeDependency)
import Distribution.Types.LibraryVisibility (LibraryVisibility)
import Distribution.Types.Mixin (Mixin)
import Distribution.Types.ModuleReexport (ModuleReexport)
import Distribution.Types.ModuleRenaming (ModuleRenaming)
import Distribution.Types.MungedPackageName (MungedPackageName)
import Distribution.Types.PackageId (PackageIdentifier)
import Distribution.Types.PackageName (PackageName)
Expand Down Expand Up @@ -410,6 +412,11 @@ instance Described ForeignLibOption where
instance Described ForeignLibType where
describe _ = REUnion ["native-shared","native-static"]

instance Described IncludeRenaming where
describe _ = mr <> REOpt (RESpaces <> "requires" <> RESpaces1 <> mr)
where
mr = describe (Proxy :: Proxy ModuleRenaming)

instance Described Language where
describe _ = REUnion ["Haskell98", "Haskell2010"]

Expand All @@ -424,7 +431,8 @@ instance Described LibVersionInfo where
reDigits = reChars ['0'..'9']

instance Described Mixin where
describe _ = RETodo
describe _ = RENamed "package-name" (describe (Proxy :: Proxy PackageName)) <>
REOpt (RESpaces1 <> describe (Proxy :: Proxy IncludeRenaming))

instance Described ModuleName where
describe _ = REMunch1 (reChar '.') component where
Expand All @@ -433,6 +441,18 @@ instance Described ModuleName where
instance Described ModuleReexport where
describe _ = RETodo

instance Described ModuleRenaming where
describe _ = REUnion
[ reEps
, "hiding" <> RESpaces <> bp (REMunch reSpacedComma mn)
, bp (REMunch reSpacedComma entry)
]
where
bp r = "(" <> RESpaces <> r <> RESpaces <> ")"
mn = RENamed "module-name" $ describe (Proxy :: Proxy ModuleName)

entry = mn <> REOpt (RESpaces1 <> "as" <> RESpaces1 <> mn)

instance Described MungedPackageName where
describe _ = RETodo

Expand Down
2 changes: 1 addition & 1 deletion Cabal/Distribution/Types/IncludeRenaming.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ instance Parsec IncludeRenaming where
parsec = do
prov_rn <- parsec
req_rn <- P.option defaultRenaming $ P.try $ do
P.spaces
P.spaces -- no need to be space
_ <- P.string "requires"
P.spaces
parsec
Expand Down
2 changes: 1 addition & 1 deletion Cabal/doc/buildinfo-fields-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ mixins
* Documentation of :pkg-field:`mixins`

.. math::
\mathrm{commalist}\mathsf{\color{red}{TODO}}
\mathrm{commalist}\left(\mathop{\mathit{package\text{-}name}}{\left(\bullet\left\{ \mid\mathop{\mathord{``}\mathtt{hiding}\mathord{"}}\circ\mathop{\mathord{``}\mathtt{\text{(}}\mathord{"}}\circ{\mathop{\mathit{module\text{-}name}}}^\ast_{\left(\circ\mathop{\mathord{``}\mathtt{\text{,}}\mathord{"}}\circ\right)}\circ\mathop{\mathord{``}\mathtt{\text{)}}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{\text{(}}\mathord{"}}\circ{\left(\mathop{\mathit{module\text{-}name}}{\left(\bullet\mathop{\mathord{``}\mathtt{as}\mathord{"}}\bullet\mathop{\mathit{module\text{-}name}}\right)}^?\right)}^\ast_{\left(\circ\mathop{\mathord{``}\mathtt{\text{,}}\mathord{"}}\circ\right)}\circ\mathop{\mathord{``}\mathtt{\text{)}}\mathord{"}} \right\}{\left(\circ\mathop{\mathord{``}\mathtt{requires}\mathord{"}}\bullet\left\{ \mid\mathop{\mathord{``}\mathtt{hiding}\mathord{"}}\circ\mathop{\mathord{``}\mathtt{\text{(}}\mathord{"}}\circ{\mathop{\mathit{module\text{-}name}}}^\ast_{\left(\circ\mathop{\mathord{``}\mathtt{\text{,}}\mathord{"}}\circ\right)}\circ\mathop{\mathord{``}\mathtt{\text{)}}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{\text{(}}\mathord{"}}\circ{\left(\mathop{\mathit{module\text{-}name}}{\left(\bullet\mathop{\mathord{``}\mathtt{as}\mathord{"}}\bullet\mathop{\mathit{module\text{-}name}}\right)}^?\right)}^\ast_{\left(\circ\mathop{\mathord{``}\mathtt{\text{,}}\mathord{"}}\circ\right)}\circ\mathop{\mathord{``}\mathtt{\text{)}}\mathord{"}} \right\}\right)}^?\right)}^?\right)

other-extensions
* Monoidal field
Expand Down
6 changes: 6 additions & 0 deletions Cabal/tests/UnitTests/Distribution/Described.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import Distribution.ModuleName (ModuleName)
import Distribution.System (Arch, OS)
import Distribution.Types.Dependency (Dependency)
import Distribution.Types.Flag (FlagAssignment, FlagName)
import Distribution.Types.IncludeRenaming (IncludeRenaming)
import Distribution.Types.Mixin (Mixin)
import Distribution.Types.ModuleRenaming (ModuleRenaming)
import Distribution.Types.PackageId (PackageIdentifier)
import Distribution.Types.PackageName (PackageName)
import Distribution.Types.PackageVersionConstraint (PackageVersionConstraint)
Expand All @@ -38,4 +41,7 @@ tests = testGroup "Described"
, testDescribed (Proxy :: Proxy Arch)
, testDescribed (Proxy :: Proxy CompilerFlavor)
, testDescribed (Proxy :: Proxy CompilerId)
, testDescribed (Proxy :: Proxy ModuleRenaming)
, testDescribed (Proxy :: Proxy IncludeRenaming)
, testDescribed (Proxy :: Proxy Mixin)
]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ weeder :
# tags
.PHONY : tags
tags :
hasktags -c Cabal/Distribution Cabal/Language cabal-install/Distribution
hasktags -b Cabal/Distribution Cabal/Cabal-described/src Cabal/Language cabal-install/Distribution