Commit 8101623c authored by Oleg Grenrus's avatar Oleg Grenrus
Browse files

Add emptySourceRepo, classifyRepoType and classifyRepoKind

parent cc529f9a
......@@ -95,6 +95,7 @@ module Distribution.PackageDescription (
RepoKind(..),
RepoType(..),
knownRepoTypes,
emptySourceRepo,
-- * Custom setup build information
SetupBuildInfo(..),
......
......@@ -997,15 +997,7 @@ parsePackageDescription file = do
repo <- lift $ parseFields
sourceRepoFieldDescrs
warnUnrec
SourceRepo {
repoKind = kind,
repoType = Nothing,
repoLocation = Nothing,
repoModule = Nothing,
repoBranch = Nothing,
repoTag = Nothing,
repoSubdir = Nothing
}
(emptySourceRepo kind)
sec_fields
skipField
(repos, flags, csetup, mlib, sub_libs, exes, tests, bms) <- getBody pkg
......
......@@ -6,6 +6,9 @@ module Distribution.Types.SourceRepo (
RepoKind(..),
RepoType(..),
knownRepoTypes,
emptySourceRepo,
classifyRepoType,
classifyRepoKind,
) where
import Prelude ()
......@@ -77,6 +80,17 @@ data SourceRepo = SourceRepo {
}
deriving (Eq, Generic, Read, Show, Typeable, Data)
emptySourceRepo :: RepoKind -> SourceRepo
emptySourceRepo kind = SourceRepo
{ repoKind = kind
, repoType = Nothing
, repoLocation = Nothing
, repoModule = Nothing
, repoBranch = Nothing
, repoTag = Nothing
, repoSubdir = Nothing
}
instance Binary SourceRepo
-- | What this repo info is for, what it represents.
......@@ -123,12 +137,13 @@ instance Text RepoKind where
disp RepoThis = Disp.text "this"
disp (RepoKindUnknown other) = Disp.text other
parse = do
name <- ident
return $ case lowercase name of
"head" -> RepoHead
"this" -> RepoThis
_ -> RepoKindUnknown name
parse = fmap classifyRepoKind ident
classifyRepoKind :: String -> RepoKind
classifyRepoKind name = case lowercase name of
"head" -> RepoHead
"this" -> RepoThis
_ -> RepoKindUnknown name
instance Text RepoType where
disp (OtherRepoType other) = Disp.text other
......
......@@ -488,7 +488,7 @@ instance Arbitrary SourceRepo where
<*> (fmap getShortToken <$> arbitrary)
<*> (fmap getShortToken <$> arbitrary)
<*> (fmap getShortToken <$> arbitrary))
`suchThat` (/= emptySourceRepo)
`suchThat` (/= emptySourceRepo RepoThis)
shrink (SourceRepo _ x1 x2 x3 x4 x5 x6) =
[ repo
......@@ -505,14 +505,9 @@ instance Arbitrary SourceRepo where
(fmap getShortToken x4')
(fmap getShortToken x5')
(fmap getShortToken x6')
, repo /= emptySourceRepo
, repo /= emptySourceRepo RepoThis
]
emptySourceRepo :: SourceRepo
emptySourceRepo = SourceRepo RepoThis Nothing Nothing Nothing
Nothing Nothing Nothing
instance Arbitrary RepoType where
arbitrary = elements knownRepoTypes
......
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