Skip to content

Commit 249bd29

Browse files
committed
5.0.0
1 parent 4b17dc9 commit 249bd29

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup GHC
1414
uses: actions/[email protected]
1515
with:
16-
ghc-version: "8.10.3"
16+
ghc-version: "8.10.4"
1717
enable-stack: true
1818

1919
- name: Clone project

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Changelog
22

3+
## 5.0.0 (2021-04-14)
4+
5+
This release brings `versions` in line with version `2.0.0` of the SemVer spec.
6+
The main addition to the spec is the allowance of hyphens in both the prerelease
7+
and metadata sections. As such, **certain versions like `1.2.3+1-1` which
8+
previously would not parse as SemVer now do.**
9+
10+
To accomodate this and other small spec updates, the `SemVer` and `Version`
11+
types have received breaking changes here.
12+
13+
#### Changed
14+
15+
- **Breaking:** The `_svMeta` field of `SemVer` is now parsed as a dumber `Maybe
16+
Text` instead of `[VChunk]`, due to metadata now being allowed to possess
17+
leading zeroes.
18+
- **Breaking:** Like the above, the `_vMeta` field of `Version` is now `Maybe Text`.
19+
- **Breaking: The `_vRel` and `_vMeta` fields of `Version` have had their order
20+
flipped.** Further, the prelease and meta sections are now expected in the
21+
same order as `SemVer` when parsing (prerel first, meta second). `Version` is
22+
thus now a quite similar to `SemVer`, except allowing letters in more
23+
permissive positions.
24+
- **Breaking:** The `meta` traversal has been altered to accomodate the metadata
25+
field changes.
26+
27+
#### Fixed
28+
29+
- Parsing certain legal SemVers specified in the spec.
30+
331
## 4.0.3 (2021-02-23)
432

533
#### Changed

Data/Versions.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
-- |
99
-- Module : Data.Versions
10-
-- Copyright : (c) Colin Woodbury, 2015 - 2020
10+
-- Copyright : (c) Colin Woodbury, 2015 - 2021
1111
-- License : BSD3
1212
-- Maintainer: Colin Woodbury <[email protected]>
1313
--
@@ -29,6 +29,8 @@
2929
-- currently using it. It provides consistency in version incrementing and has
3030
-- the best constraints on comparisons.
3131
--
32+
-- __This library implements version @2.0.0@ of the SemVer spec.__
33+
--
3234
-- == Using the Parsers
3335
-- In general, `versioning` is the function you want. It attempts to parse a
3436
-- given `Text` using the three individual parsers, `semver`, `version` and
@@ -250,16 +252,19 @@ _Mess :: Traversal' Text Mess
250252
_Mess f t = either (const (pure t)) (fmap prettyMess . f) $ mess t
251253
{-# INLINE _Mess #-}
252254

255+
-- | Possibly extract a `SemVer` from a `Versioning`.
253256
_Ideal :: Traversal' Versioning SemVer
254257
_Ideal f (Ideal s) = Ideal <$> f s
255258
_Ideal _ v = pure v
256259
{-# INLINE _Ideal #-}
257260

261+
-- | Possibly extract a `Version` from a `Versioning`.
258262
_General :: Traversal' Versioning Version
259263
_General f (General v) = General <$> f v
260264
_General _ v = pure v
261265
{-# INLINE _General #-}
262266

267+
-- | Possibly extract a `Mess` from a `Versioning`.
263268
_Complex :: Traversal' Versioning Mess
264269
_Complex f (Complex m) = Complex <$> f m
265270
_Complex _ v = pure v
@@ -422,11 +427,13 @@ digits = Digits
422427
str :: Text -> Maybe VUnit
423428
str t = bool Nothing (Just $ Str t) $ T.all isAlpha t
424429

430+
-- | Possibly traverse the inner digit value of a `VUnit`.
425431
_Digits :: Traversal' VUnit Word
426432
_Digits f (Digits i) = Digits <$> f i
427433
_Digits _ v = pure v
428434
{-# INLINE _Digits #-}
429435

436+
-- | Possibly traverse the inner text of a `VUnit`.
430437
_Str :: Traversal' VUnit Text
431438
_Str f (Str t) = Str . (\t' -> bool t t' (T.all isAlpha t')) <$> f t
432439
_Str _ v = pure v
@@ -611,6 +618,7 @@ instance Semantic Version where
611618
semantic _ v = pure v
612619
{-# INLINE semantic #-}
613620

621+
-- | A `Version`'s inner epoch `Word`.
614622
epoch :: Lens' Version (Maybe Word)
615623
epoch f v = fmap (\ve -> v { _vEpoch = ve }) (f $ _vEpoch v)
616624
{-# INLINE epoch #-}
@@ -738,7 +746,7 @@ data VSep = VColon | VHyphen | VPlus | VUnder
738746
--------------------------------------------------------------------------------
739747
-- Parsing
740748

741-
-- | A synonym for the more verbose `megaparsec` error type.
749+
-- | A synonym for the more verbose 'megaparsec' error type.
742750
type ParsingError = ParseErrorBundle Text Void
743751

744752
-- | Parse a piece of `Text` into either an (Ideal) `SemVer`, a (General)

versions.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: versions
3-
version: 4.0.3
3+
version: 5.0.0
44
synopsis: Types and parsers for software version numbers.
55
description:
66
A library for parsing and comparing software version numbers. We like to give
@@ -19,6 +19,8 @@ description:
1919
Please switch to <http://semver.org Semantic Versioning> if you aren't
2020
currently using it. It provides consistency in version incrementing and has
2121
the best constraints on comparisons.
22+
.
23+
This library implements version @2.0.0@ of the SemVer spec.
2224

2325
category: Data
2426
homepage: https://github.com/fosskers/versions

0 commit comments

Comments
 (0)