hydrogen-version 1.2 → 1.3
raw patch · 4 files changed
+116/−25 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Hydrogen.Version: fromDataVersion :: Version -> Version
+ Hydrogen.Version: toDataVersion :: Version -> Version
Files
- CHANGELOG.md +14/−1
- README.md +39/−0
- hydrogen-version.cabal +51/−24
- src/Hydrogen/Version.hs +12/−0
CHANGELOG.md view
@@ -1,2 +1,15 @@-v1.0.1+## v1.0++ Initial release++## v1.0.1 + Fixed `Read` instance++## v1.1++ Added instance for `Generic`++## v1.2++ Added instance for `Typeable`++## v1.3++ Added `fromDataVersion`++ Added `toDataVersion`
README.md view
@@ -0,0 +1,39 @@+hydrogen-version+================+ +A sane replacement for+[`Data.Version`](http://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Version.html)+from the [`base`](http://hackage.haskell.org/package/base) package.+ +*Note:* `Version` is also exported by+[`Hydrogen.Prelude`](https://github.com/scravy/hydrogen-prelude),+where it comes with some more instances (like+[`Serialize`](https://hackage.haskell.org/package/cereal)).+ + +Data.Version vs Hydrogen.Version+--------------------------------+ +### Sane `Ord` instance++`Data.Version` relies on `Ord` for lists, which will consider `1.0` to be less+than `1.0.0`. `Hydrogen.Version` considers these to be equal.++### Sane `Read` and `Show` instances++With `Hydrogen.Version` you can just do `read "1.0.0" :: Version`, whereas+the `Read` and `Show` instances for `Data.Version` do not give a concise representation+(`show dataVersion == "Version {versionBranch = [1,0], versionTags = []}"`).++### Stricter API++In `Hydrogen.Version` you can create a `Version` only via `mkVersion`,+whereas in `Data.Version` the constructor is exported, thus you could do+such nonsense as `Data.Version.Version [] []` (which is not a proper version+at all).+ +### No Tags++`Hydrogen.Version` does not support tags. This is intentional, since there is no+agreed upon definition for `Ord` in the presence of tags (consider `alpha` vs+`beta` vs `snapshot` vs `ga` vs ...).
hydrogen-version.cabal view
@@ -1,29 +1,56 @@-name: hydrogen-version-version: 1.2-homepage: https://scravy.de/hydrogen-version/-synopsis: Hydrogen Version Type-license: BSD3-license-file: LICENSE-extra-source-files: CHANGELOG.md, README.md-author: Julian Fleischer-maintainer: julian@scravy.de-category: Language-build-type: Simple-cabal-version: >=1.14+name: hydrogen-version+version: 1.3+homepage: https://scravy.de/hydrogen-version/+synopsis: Hydrogen Version Type+description: A sane replacement for "Data.Version" from the @base@ package.+ .+ "Hydrogen.Version" is also exported by "Hydrogen.Prelude" where+ it comes with a few more instances (e.g. for "Data.Serialize").+ .+ >>> Differences to Data.Version+ .+ [@Sane 'Ord' instance@] "Data.Version" relies on 'Ord' for lists,+ which will consider @1.0@ to be less than @1.0.0@. @Hydrogen.Version@+ considers these to be equal.+ .+ [@Sane 'Read' and 'Show' instances@] With @Hydrogen.Version@ you can+ just do @read "1.0.0" :: Version@, whereas the 'Read' and 'Show'+ instances for "Data.Version" do not give a concise representation:+ .+ > show hydrogenVersion == "1.0.0"+ > show dataVersion == "Version versionBranch = [1,0,0], versionTags = []"+ .+ [@Stricter API@] In @Hydrogen.Version@ you can create a 'Version'+ only via 'mkVersion', whereas in "Data.Version" the constructor is+ exported, thus you could so such nonsense as+ @Data.Version.Version [] []@ (which is not a proper version at all).+ .+ [@No Tags@] @Hydrogen.Version@ does not support tags. This is+ intentional, since there is no agreed upon definition for 'Ord' in+ the presence of tags (consider @alpha@ vs @beta@ vs @snapshot@ vs+ @ga@ vs ...).+license: MIT+license-file: LICENSE+extra-source-files: CHANGELOG.md, README.md+author: Julian Fleischer+maintainer: julian@scravy.de+category: Language+build-type: Simple+cabal-version: >=1.14 source-repository head- type: git- location: https://github.com/scravy/hydrogen-version+ type: git+ location: https://github.com/scravy/hydrogen-version library- exposed-modules: Hydrogen.Version- build-depends: base ==4.*- hs-source-dirs: src- ghc-options: -Wall- default-language: Haskell2010- default-extensions: CPP- , DeriveDataTypeable- , DeriveGeneric- , FlexibleContexts- , FlexibleInstances+ exposed-modules: Hydrogen.Version+ build-depends: base ==4.*+ hs-source-dirs: src+ ghc-options: -Wall+ default-language: Haskell2010+ default-extensions: CPP+ , DeriveDataTypeable+ , DeriveGeneric+ , FlexibleContexts+ , FlexibleInstances
src/Hydrogen/Version.hs view
@@ -6,6 +6,8 @@ , minorVersion , patchVersion , tailVersion+ , fromDataVersion+ , toDataVersion ) where import Prelude@@ -13,6 +15,7 @@ import Data.List (intersperse) import Data.Char (isDigit) import Data.Typeable+import qualified Data.Version as V import GHC.Generics @@ -65,4 +68,13 @@ refineVersion :: Version -> Integer -> Version refineVersion (Version v) i = Version (v ++ [i])++fromDataVersion :: V.Version -> Version+fromDataVersion = Version . map fromIntegral . V.versionBranch++toDataVersion :: Version -> V.Version+toDataVersion (Version v) = V.Version {+ V.versionBranch = map fromInteger v+ , V.versionTags = []+ }