Hello community, here is the log from the commit of package ghc-versions for openSUSE:Factory checked in at 2017-06-22 10:39:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-versions (Old) and /work/SRC/openSUSE:Factory/.ghc-versions.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-versions" Thu Jun 22 10:39:37 2017 rev:3 rq:504119 version:3.0.2.1 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-versions/ghc-versions.changes 2017-06-04 01:59:10.293773439 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-versions.new/ghc-versions.changes 2017-06-22 10:39:39.319862855 +0200 @@ -1,0 +2,10 @@ +Thu Jun 8 11:08:22 UTC 2017 - [email protected] + +- Update to version 3.0.2.1. + +------------------------------------------------------------------- +Wed May 31 14:01:14 UTC 2017 - [email protected] + +- Update to version 3.0.2. + +------------------------------------------------------------------- Old: ---- versions-3.0.1.1.tar.gz New: ---- versions-3.0.2.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-versions.spec ++++++ --- /var/tmp/diff_new_pack.kffmht/_old 2017-06-22 10:39:40.087754592 +0200 +++ /var/tmp/diff_new_pack.kffmht/_new 2017-06-22 10:39:40.091754029 +0200 @@ -19,7 +19,7 @@ %global pkg_name versions %bcond_with tests Name: ghc-%{pkg_name} -Version: 3.0.1.1 +Version: 3.0.2.1 Release: 0 Summary: Types and parsers for software version numbers License: BSD-3-Clause ++++++ versions-3.0.1.1.tar.gz -> versions-3.0.2.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/versions-3.0.1.1/CHANGELOG.md new/versions-3.0.2.1/CHANGELOG.md --- old/versions-3.0.1.1/CHANGELOG.md 2016-06-07 06:09:11.000000000 +0200 +++ new/versions-3.0.2.1/CHANGELOG.md 2017-05-26 03:38:35.000000000 +0200 @@ -1,6 +1,12 @@ Changelog ========= +3.0.2 +----- + +- Expose internal parsers so that they could be used in other parser programs + that parse version numbers in larger files. + 3.0.0 ----- - Updated for `megaparsec-5` and `ghc-8` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/versions-3.0.1.1/Data/Versions.hs new/versions-3.0.2.1/Data/Versions.hs --- old/versions-3.0.1.1/Data/Versions.hs 2017-05-20 01:30:51.000000000 +0200 +++ new/versions-3.0.2.1/Data/Versions.hs 2017-05-31 00:30:49.000000000 +0200 @@ -53,6 +53,10 @@ , semverP , versionP , messP + -- ** Megaparsec Parsers + , semver' + , version' + , mess' -- * Pretty Printing , prettyV , prettySemVer @@ -259,7 +263,48 @@ -- -- Examples of @Version@ that are not @SemVer@: 0.25-2, 8.u51-1, 20150826-1 data Version = Version { _vChunks :: [VChunk] - , _vRel :: [VChunk] } deriving (Eq,Ord,Show) + , _vRel :: [VChunk] } deriving (Eq,Show) + +-- | Customized. +instance Ord Version where + -- | The obvious base case. + compare (Version [] []) (Version [] []) = EQ + + -- | If the two Versions were otherwise equal and recursed down this far, + -- we need to compare them by their "release" values. + compare (Version [] rs) (Version [] rs') = compare (Version rs []) (Version rs' []) + + -- | If one side has run out of chunks to compare but the other hasn't, + -- the other must be newer. + compare (Version _ _) (Version [] _) = GT + compare (Version [] _) (Version _ _) = LT + + -- | The usual case. If first VChunks of each Version is equal, then we + -- keep recursing. Otherwise, we don't need to check further. Consider @1.2@ + -- compared to @1.1.3.4.5.6@. + compare (Version (a:as) rs) (Version (b:bs) rs') = case f a b of + EQ -> compare (Version as rs) (Version bs rs') + res -> res + where f [] [] = EQ + + -- | Opposite of the above. If we've recursed this far and one side has + -- fewer chunks, it must be the "greater" version. A Chunk break only occurs in + -- a switch from digits to letters and vice versa, so anything "extra" must be + -- an @rc@ marking or similar. Consider @1.1@ compared to @1.1rc1@. + f [] _ = GT + f _ [] = LT + + -- | The usual case. + f (Digits n:ns) (Digits m:ms) | n > m = GT + | n < m = LT + | otherwise = f ns ms + f (Str n:ns) (Str m:ms) | n > m = GT + | n < m = LT + | otherwise = f ns ms + + -- | An arbitrary decision to prioritize digits over letters. + f (Digits _ :_) (Str _ :_) = GT + f (Str _ :_ ) (Digits _ :_) = LT -- | > vChunks :: Lens' Version [VChunk] vChunks :: Functor f => ([VChunk] -> f [VChunk]) -> Version -> f Version @@ -329,11 +374,11 @@ -- | Parse a (Ideal) Semantic Version. semver :: Text -> Either ParsingError SemVer -semver = parse semanticVersion "Semantic Version" +semver = parse (semver' <* eof) "Semantic Version" -semanticVersion :: Parser SemVer -semanticVersion = p <* eof - where p = SemVer <$> major <*> minor <*> patch <*> preRel <*> metaData +-- | Internal megaparsec parser of 'semverP'. +semver' :: Parser SemVer +semver' = SemVer <$> major <*> minor <*> patch <*> preRel <*> metaData -- | Parse a group of digits, which can't be lead by a 0, unless it is 0. digits :: Parser Int @@ -355,8 +400,18 @@ metaData = (char '+' *> chunks) <|> pure [] chunks :: Parser [VChunk] -chunks = (oneZero <|> many (iunit <|> sunit)) `sepBy` char '.' +chunks = chunk `sepBy` char '.' + +-- | Handling @0@ is a bit tricky. We can't allow runs of zeros in a chunk, +-- since a version like @1.000.1@ would parse as @1.0.1@. +chunk :: Parser VChunk +chunk = try zeroWithLetters <|> oneZero <|> many (iunit <|> sunit) where oneZero = (:[]) . Digits . read <$> string "0" + zeroWithLetters = do + z <- Digits . read <$> string "0" + s <- some sunit + c <- chunk + pure $ (z : s) ++ c iunit :: Parser VUnit iunit = Digits . read <$> some digitChar @@ -370,10 +425,11 @@ -- | Parse a (General) `Version`, as defined above. version :: Text -> Either ParsingError Version -version = parse versionNum "Version" +version = parse (version' <* eof) "Version" -versionNum :: Parser Version -versionNum = Version <$> chunks <*> preRel <* eof +-- | Internal megaparsec parser of 'versionP'. +version' :: Parser Version +version' = Version <$> chunks <*> preRel -- | A wrapped `Mess` parser. Can be composed with other parsers. messP :: VParser @@ -381,16 +437,17 @@ -- | Parse a (Complex) `Mess`, as defined above. mess :: Text -> Either ParsingError Mess -mess = parse messNumber "Mess" +mess = parse (mess' <* eof) "Mess" -messNumber :: Parser Mess -messNumber = try node <|> leaf +-- | Internal megaparsec parser of 'messP'. +mess' :: Parser Mess +mess' = try node <|> leaf leaf :: Parser Mess -leaf = VLeaf <$> tchunks <* eof +leaf = VLeaf <$> tchunks node :: Parser Mess -node = VNode <$> tchunks <*> sep <*> messNumber +node = VNode <$> tchunks <*> sep <*> mess' tchunks :: Parser [Text] tchunks = (pack <$> some (letterChar <|> digitChar)) `sepBy` char '.' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/versions-3.0.1.1/test/Test.hs new/versions-3.0.2.1/test/Test.hs --- old/versions-3.0.1.1/test/Test.hs 2017-05-19 16:21:11.000000000 +0200 +++ new/versions-3.0.2.1/test/Test.hs 2017-05-31 00:30:49.000000000 +0200 @@ -13,7 +13,7 @@ -- | These don't need to parse as a SemVer. goodVers :: [Text] -goodVers = [ "1", "1.2", "1.58.0-3", "44.0.2403.157-1" +goodVers = [ "1", "1.2", "1.0rc0", "1.0rc1", "1.1rc1", "1.58.0-3", "44.0.2403.157-1" , "0.25-2", "8.u51-1", "21-2", "7.1p1-1", "20150826-1" ] @@ -73,6 +73,7 @@ map (\s -> testCase (unpack s) $ isomorphV s) goodVers , testGroup "Comparisons" $ testCase "1.2-5 < 1.2.3-1" (comp version "1.2-5" "1.2.3-1") : + testCase "1.0rc1 < 1.0" (comp version "1.0rc1" "1.0") : map (\(a,b) -> testCase (unpack $ a <> " < " <> b) $ comp version a b) (zip cabalOrd (tail cabalOrd) <> zip versionOrd (tail versionOrd)) ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/versions-3.0.1.1/versions.cabal new/versions-3.0.2.1/versions.cabal --- old/versions-3.0.1.1/versions.cabal 2017-05-20 01:41:07.000000000 +0200 +++ new/versions-3.0.2.1/versions.cabal 2017-05-31 00:31:10.000000000 +0200 @@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: versions -version: 3.0.1.1 +version: 3.0.2.1 synopsis: Types and parsers for software version numbers. description: A library for parsing and comparing software version numbers. We like to give version numbers to our software in a myriad of @@ -48,7 +48,7 @@ , text >=1.2 && <1.3 , megaparsec >=4 && <6 default-language: Haskell2010 - ghc-options: -fwarn-unused-imports -fwarn-unused-binds + ghc-options: -fwarn-unused-imports -fwarn-unused-binds -fwarn-name-shadowing -fwarn-unused-matches test-suite versions-test type: exitcode-stdio-1.0 @@ -63,4 +63,4 @@ test main-is: Test.hs default-language: Haskell2010 - ghc-options: -fwarn-unused-imports -fwarn-unused-binds -threaded + ghc-options: -fwarn-unused-imports -fwarn-unused-binds -fwarn-name-shadowing -fwarn-unused-matches -threaded
