versions 2.0.0 → 3.0.0
raw patch · 5 files changed
+32/−20 lines, 5 filesdep ~basedep ~megaparsec
Dependency ranges changed: base, megaparsec
Files
- CHANGELOG.md +4/−0
- Data/Versions.hs +11/−6
- README.md +8/−5
- test/Test.hs +4/−4
- versions.cabal +5/−5
CHANGELOG.md view
@@ -1,6 +1,10 @@ Changelog ========= +3.0.0+-----+- Updated for `megaparsec-5` and `ghc-8`+ 2.0.0 ----- - Switched to `megaparsec` to perform all parsing as `Text`
Data/Versions.hs view
@@ -43,6 +43,7 @@ , VChunk , VSep(..) , VParser(..)+ , ParsingError -- * Parsers , semver , version@@ -57,6 +58,7 @@ , prettySemVer , prettyVer , prettyMess+ , parseErrorPretty -- * Lenses -- ** Traversing Text , _Versioning@@ -296,10 +298,13 @@ -- * An underscore (_). Stop using this if you are. data VSep = VColon | VHyphen | VPlus | VUnder deriving (Eq,Show) +-- | A synonym for the more verbose `megaparsec` error type.+type ParsingError = ParseError (Token Text) Dec+ -- | A wrapper for a parser function. Can be composed via their -- Semigroup instance, such that a different parser can be tried -- if a previous one fails.-newtype VParser = VParser { runVP :: Text -> Either ParseError Versioning }+newtype VParser = VParser { runVP :: Text -> Either ParsingError Versioning } instance Semigroup VParser where (VParser f) <> (VParser g) = VParser h@@ -307,7 +312,7 @@ -- | Parse a piece of @Text@ into either an (Ideal) SemVer, a (General) -- Version, or a (Complex) Mess.-parseV :: Text -> Either ParseError Versioning+parseV :: Text -> Either ParsingError Versioning parseV = runVP $ semverP <> versionP <> messP -- | A wrapped `SemVer` parser. Can be composed with other parsers.@@ -315,7 +320,7 @@ semverP = VParser $ fmap Ideal . semver -- | Parse a (Ideal) Semantic Version.-semver :: Text -> Either ParseError SemVer+semver :: Text -> Either ParsingError SemVer semver = parse semanticVersion "Semantic Version" semanticVersion :: Parser SemVer@@ -356,7 +361,7 @@ versionP = VParser $ fmap General . version -- | Parse a (General) `Version`, as defined above.-version :: Text -> Either ParseError Version+version :: Text -> Either ParsingError Version version = parse versionNum "Version" versionNum :: Parser Version@@ -366,8 +371,8 @@ messP :: VParser messP = VParser $ fmap Complex . mess --- | Parse a (Complex) `Mess`, as defined above. -mess :: Text -> Either ParseError Mess+-- | Parse a (Complex) `Mess`, as defined above.+mess :: Text -> Either ParsingError Mess mess = parse messNumber "Mess" messNumber :: Parser Mess
README.md view
@@ -3,16 +3,19 @@ [](https://travis-ci.org/aurapm/haskell-versions) [](https://coveralls.io/github/aurapm/haskell-versions?branch=master)+[](https://hackage.haskell.org/package/versions)+[](http://stackage.org/nightly/package/versions)+[](http://stackage.org/lts/package/versions) A Haskell library for parsing and comparing software version numbers. About ------We like to give version numbers to our software in a myriad of different-ways. Some ways follow strict guidelines for incrementing and comparison.-Some follow conventional wisdom and are generally self-consistent. Some are-just plain asinine. This library provides a means of parsing and comparing-*any* style of versioning, be it a nice Semantic Version like this:+We like to give version numbers to our software in a myriad of ways. Some+ways follow strict guidelines for incrementing and comparison. Some follow+conventional wisdom and are generally self-consistent. Some are just plain+asinine. This library provides a means of parsing and comparing *any* style+of versioning, be it a nice Semantic Version like this: > 1.2.3-r1+git123
test/Test.hs view
@@ -84,13 +84,13 @@ map (\(a,b) -> testCase (unpack $ a <> " < " <> b) $ comp mess a b) $ zip messComps (tail messComps) ]- , testGroup "Mixed Versioning" $- [ testGroup "Identification" $+ , testGroup "Mixed Versioning"+ [ testGroup "Identification" [ testCase "1.2.3 is SemVer" $ check $ isSemVer <$> parseV "1.2.3" , testCase "1.2.3-1 is SemVer" $ check $ isSemVer <$> parseV "1.2.3-1" , testCase "1.2.3-1+1 is SemVer" $ check $ isSemVer <$> parseV "1.2.3-1+1" , testCase "1.2.3r1 is Version" $ check $ isVersion <$> parseV "1.2.3r1"- , testCase "0.25-2 is Version" $ check $ isVersion <$> parseV "0.25-2" + , testCase "0.25-2 is Version" $ check $ isVersion <$> parseV "0.25-2" , testCase "1.2.3+1-1 is Mess" $ check $ isMess <$> parseV "1.2.3+1-1" , testCase "1:1.2.3-1 is Mess" $ check $ isMess <$> parseV "1:1.2.3-1" , testCase "000.007-1 is Mess" $ check $ isMess <$> parseV "000.007-1"@@ -98,7 +98,7 @@ ] , testGroup "Isomorphisms" $ map (\s -> testCase (unpack s) $ isomorph s) $ goodSemVs ++ goodVers ++ messes- , testGroup "Comparisons" $+ , testGroup "Comparisons" [ testCase "1.2.2r1-1 < 1.2.3-1" $ comp parseV "1.2.2r1-1" "1.2.3-1" , testCase "1.2.3-1 < 1.2.4r1-1" $ comp parseV "1.2.3-1" "1.2.4r1-1" , testCase "1.2.3-1 < 2+0007-1" $ comp parseV "1.2.3-1" "2+0007-1"
versions.cabal view
@@ -1,9 +1,9 @@ name: versions-version: 2.0.0+version: 3.0.0 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 different+ We like to give version numbers to our software in a myriad of ways. Some ways follow strict guidelines for incrementing and comparison. Some follow conventional wisdom and are generally self-consistent. Some are just plain asinine. This library provides a means of parsing@@ -40,8 +40,8 @@ other-extensions: OverloadedStrings - build-depends: base >=4.8 && <4.9- , megaparsec >= 4 && < 5+ build-depends: base >=4.8 && <4.10+ , megaparsec >= 5 && < 6 , semigroups >= 0.16.2.2 , text >=1.2 && <1.3 @@ -51,7 +51,7 @@ type: exitcode-stdio-1.0 other-extensions: OverloadedStrings - build-depends: base >=4.8 && <4.9+ build-depends: base >=4.8 && <4.10 , either >= 4.4.1 , microlens >= 0.4 && < 0.5 , tasty >= 0.10.1.2