versions 3.1.1 → 3.2.0
raw patch · 3 files changed
+34/−29 lines, 3 filesdep ~basedep ~megaparsec
Dependency ranges changed: base, megaparsec
Files
- CHANGELOG.md +4/−0
- Data/Versions.hs +25/−24
- versions.cabal +5/−5
CHANGELOG.md view
@@ -1,6 +1,10 @@ Changelog ========= +3.2.0+-----+- Updated for `megaparsec-6` and GHC 8.2.+ 3.1.1 ----- - Added instances for common typeclasses: `Generic`, `NFData`, and
Data/Versions.hs view
@@ -91,10 +91,11 @@ import Data.Hashable import Data.List (intersperse) import Data.Monoid-import Data.Text (Text,pack,snoc)+import Data.Text (Text,pack,unpack,snoc)+import Data.Void import GHC.Generics import Text.Megaparsec-import Text.Megaparsec.Text+import Text.Megaparsec.Char --- @@ -378,7 +379,7 @@ data VSep = VColon | VHyphen | VPlus | VUnder deriving (Eq,Show,Generic,NFData,Hashable) -- | A synonym for the more verbose `megaparsec` error type.-type ParsingError = ParseError (Token Text) Dec+type ParsingError = ParseError (Token Text) Void -- | A wrapper for a parser function. Can be composed via their -- Monoid instance, such that a different parser can be tried@@ -407,46 +408,46 @@ semver = parse (semver' <* eof) "Semantic Version" -- | Internal megaparsec parser of 'semverP'.-semver' :: Parser SemVer+semver' :: Parsec Void Text 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-digits = read <$> (string "0" <|> some digitChar)+digits :: Parsec Void Text Int+digits = read <$> ((unpack <$> string "0") <|> some digitChar) -major :: Parser Int+major :: Parsec Void Text Int major = digits <* char '.' -minor :: Parser Int+minor :: Parsec Void Text Int minor = major -patch :: Parser Int+patch :: Parsec Void Text Int patch = digits -preRel :: Parser [VChunk]+preRel :: Parsec Void Text [VChunk] preRel = (char '-' *> chunks) <|> pure [] -metaData :: Parser [VChunk]+metaData :: Parsec Void Text [VChunk] metaData = (char '+' *> chunks) <|> pure [] -chunks :: Parser [VChunk]+chunks :: Parsec Void Text [VChunk] 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 :: Parsec Void Text VChunk chunk = try zeroWithLetters <|> oneZero <|> many (iunit <|> sunit)- where oneZero = (:[]) . Digits . read <$> string "0"+ where oneZero = (:[]) . Digits . read . unpack <$> string "0" zeroWithLetters = do- z <- Digits . read <$> string "0"+ z <- Digits . read . unpack <$> string "0" s <- some sunit c <- chunk pure $ (z : s) ++ c -iunit :: Parser VUnit+iunit :: Parsec Void Text VUnit iunit = Digits . read <$> some digitChar -sunit :: Parser VUnit+sunit :: Parsec Void Text VUnit sunit = Str . pack <$> some letterChar -- | A wrapped `Version` parser. Can be composed with other parsers.@@ -458,10 +459,10 @@ version = parse (version' <* eof) "Version" -- | Internal megaparsec parser of 'versionP'.-version' :: Parser Version+version' :: Parsec Void Text Version version' = Version <$> optional (try epoch) <*> chunks <*> preRel -epoch :: Parser Int+epoch :: Parsec Void Text Int epoch = read <$> (some digitChar <* char ':') -- | A wrapped `Mess` parser. Can be composed with other parsers.@@ -473,19 +474,19 @@ mess = parse (mess' <* eof) "Mess" -- | Internal megaparsec parser of 'messP'.-mess' :: Parser Mess+mess' :: Parsec Void Text Mess mess' = try node <|> leaf -leaf :: Parser Mess+leaf :: Parsec Void Text Mess leaf = VLeaf <$> tchunks -node :: Parser Mess+node :: Parsec Void Text Mess node = VNode <$> tchunks <*> sep <*> mess' -tchunks :: Parser [Text]+tchunks :: Parsec Void Text [Text] tchunks = (pack <$> some (letterChar <|> digitChar)) `sepBy` char '.' -sep :: Parser VSep+sep :: Parsec Void Text VSep sep = choice [ VColon <$ char ':' , VHyphen <$ char '-' , VPlus <$ char '+'
versions.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.17.1.+-- This file has been generated from package.yaml by hpack version 0.17.0. -- -- see: https://github.com/sol/hpack name: versions-version: 3.1.1+version: 3.2.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@@ -42,9 +42,9 @@ exposed-modules: Data.Versions build-depends:- base >=4.8 && <4.10+ base >=4.8 && <4.11 , text >=1.2 && <1.3- , megaparsec >=4 && <6+ , megaparsec >=6 && <7 , deepseq >= 1.4 && < 1.5 , hashable >= 1.2 && < 1.3 default-language: Haskell2010@@ -53,7 +53,7 @@ test-suite versions-test type: exitcode-stdio-1.0 build-depends:- base >=4.8 && <4.10+ base >=4.8 && <4.11 , text >=1.2 && <1.3 , microlens >=0.4 && <0.5 , tasty >=0.10.1.2