Skip to content
Snippets Groups Projects
Commit c6dab7a7 authored by Oleg Grenrus's avatar Oleg Grenrus
Browse files

Disallow spaces around colon in Parsec Dependency

parent b744cde7
No related branches found
No related tags found
No related merge requests found
......@@ -57,9 +57,9 @@ instance NFData Dependency where rnf = genericRnf
instance Pretty Dependency where
pretty (Dependency name ver sublibs) = pretty name
<+> optionalMonoid
(sublibs /= Set.singleton LMainLibName)
(PP.colon <+> PP.braces prettySublibs)
<<>> optionalMonoid
(sublibs /= Set.singleton LMainLibName)
(PP.colon <<>> PP.braces prettySublibs)
<+> pretty ver
where
optionalMonoid True x = x
......@@ -81,12 +81,40 @@ versionGuardMultilibs expr = do
else
expr
-- |
--
-- >>> simpleParsec "mylib:sub" :: Maybe Dependency
-- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LSubLibName (UnqualComponentName "sub")]))
--
-- >>> simpleParsec "mylib:{sub1,sub2}" :: Maybe Dependency
-- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]))
--
-- >>> simpleParsec "mylib:{ sub1 , sub2 }" :: Maybe Dependency
-- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]))
--
-- >>> simpleParsec "mylib:{ sub1 , sub2 } ^>= 42" :: Maybe Dependency
-- Just (Dependency (PackageName "mylib") (MajorBoundVersion (mkVersion [42])) (fromList [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]))
--
-- Spaces around colon are not allowed:
--
-- >>> simpleParsec "mylib: sub" :: Maybe Dependency
-- Nothing
--
-- >>> simpleParsec "mylib :sub" :: Maybe Dependency
-- Nothing
--
-- >>> simpleParsec "mylib: {sub1,sub2}" :: Maybe Dependency
-- Nothing
--
-- >>> simpleParsec "mylib :{sub1,sub2}" :: Maybe Dependency
-- Nothing
--
instance Parsec Dependency where
parsec = do
name <- lexemeParsec
name <- parsec
libs <- option [LMainLibName]
$ (char ':' *> spaces *>)
$ (char ':' *>)
$ versionGuardMultilibs
$ pure <$> parseLib name <|> parseMultipleLibs name
......
......@@ -5,7 +5,7 @@ version: 5846
library
default-language: Haskell2010
build-depends:
lib1 : {a, b} -any,
lib2 : {c} -any,
lib3 : {d} >=1,
lib4 : {a, b} >=1
lib1:{a, b} -any,
lib2:{c} -any,
lib3:{d} >=1,
lib4:{a, b} >=1
......@@ -9,4 +9,4 @@ Preprocessing library 'privatelib' for d-0.1.0.0..
Building library 'privatelib' for d-0.1.0.0..
Configuring library for p-0.1.0.0..
cabal: Encountered missing or private dependencies:
d : {privatelib} ==0.1.0.0
d:{privatelib} ==0.1.0.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment