Commit b74d7ded authored by Simon Marlow's avatar Simon Marlow
Browse files

Components of a package name should not begin with a digit

Avoids ambiguities with package identifiers like "foo-1" (the 1 is the
version number). 
parent 73996d68
......@@ -46,7 +46,7 @@ module Distribution.Package (
import Distribution.Version
import Distribution.Compat.ReadP as ReadP
import Data.Char ( isAlphaNum )
import Data.Char ( isAlpha, isAlphaNum )
import Data.List ( intersperse )
data PackageIdentifier
......@@ -62,8 +62,14 @@ showPackageId pkgid =
pkgName pkgid ++ '-': showVersion (pkgVersion pkgid)
parsePackageName :: ReadP r String
parsePackageName = do ns <- sepBy1 (munch1 isAlphaNum) (char '-')
parsePackageName = do ns <- sepBy1 component (char '-')
return (concat (intersperse "-" ns))
where component = do
c <- satisfy isAlpha
cs <- munch isAlphaNum
return (c:cs)
-- each component begins with an alphabetic character, to avoid
-- ambiguity in identifiers like foo-1 (the 1 is the version number).
parsePackageId :: ReadP r PackageIdentifier
parsePackageId = do
......
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