Commit 7898f527 authored by Oleg Grenrus's avatar Oleg Grenrus

Described Mixin

parent 8d9e8afe
......@@ -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
......@@ -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
-------------------------------------------------------------------------------
......
......@@ -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)
......@@ -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"]
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......@@ -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)
]
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment