summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfosskers <>2016-06-07 04:11:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2016-06-07 04:11:00 (GMT)
commit52d131fdb8a2b7b1a7018c6124e1944a99eafad5 (patch)
tree1cc48e56f5a4f4efb664e0a875d115dd8aec56d4
parentf82506a857c524e41e1edd0075706043fc9fd4c9 (diff)
version 3.0.03.0.0
-rw-r--r--CHANGELOG.md4
-rw-r--r--Data/Versions.hs17
-rw-r--r--README.md13
-rw-r--r--test/Test.hs8
-rw-r--r--versions.cabal10
5 files changed, 32 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7bdab3f..d96ce12 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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`
diff --git a/Data/Versions.hs b/Data/Versions.hs
index 1759a6c..787cbcc 100644
--- a/Data/Versions.hs
+++ b/Data/Versions.hs
@@ -43,6 +43,7 @@ module Data.Versions
, VChunk
, VSep(..)
, VParser(..)
+ , ParsingError
-- * Parsers
, semver
, version
@@ -57,6 +58,7 @@ module Data.Versions
, prettySemVer
, prettyVer
, prettyMess
+ , parseErrorPretty
-- * Lenses
-- ** Traversing Text
, _Versioning
@@ -296,10 +298,13 @@ instance Ord Mess where
-- * 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 @@ instance Semigroup VParser where
-- | 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
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
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 @@ versionNum = Version <$> chunks <*> preRel <* eof
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
diff --git a/README.md b/README.md
index 6991c9f..b60a62c 100644
--- a/README.md
+++ b/README.md
@@ -3,16 +3,19 @@ versions
[![Build Status](https://travis-ci.org/aurapm/haskell-versions.svg?branch=master)](https://travis-ci.org/aurapm/haskell-versions)
[![Coverage Status](https://coveralls.io/repos/github/aurapm/haskell-versions/badge.svg?branch=master)](https://coveralls.io/github/aurapm/haskell-versions?branch=master)
+[![Hackage](https://img.shields.io/hackage/v/versions.svg?style=flat)](https://hackage.haskell.org/package/versions)
+[![Stackage Nightly](http://stackage.org/package/versions/badge/nightly)](http://stackage.org/nightly/package/versions)
+[![Stackage LTS](http://stackage.org/package/versions/badge/lts)](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
diff --git a/test/Test.hs b/test/Test.hs
index 06763d6..24ea383 100644
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -84,13 +84,13 @@ suite = testGroup "Unit Tests"
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 @@ suite = testGroup "Unit Tests"
]
, 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"
diff --git a/versions.cabal b/versions.cabal
index f0270e3..bafcfdb 100644
--- a/versions.cabal
+++ b/versions.cabal
@@ -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 @@ library
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 @@ test-suite versions-test
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