package-version: A package for retrieving a package's version number.

[ bsd3, development, library ] [ Propose Tags ] [ Report a vulnerability ]

package-version reads the package version number from a cabal file. This version number can be retrieved at compile-time via TemplateHaskell or runtime via ordinary functions.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2, 0.3, 0.4
Change log CHANGELOG.md
Dependencies base (>=4.14.1.0 && <4.21), bytestring (>=0.10.10.0 && <0.13), deepseq (>=1.4.4.0 && <1.6), template-haskell (>=2.16.0.0 && <2.23), text (>=1.2.3.2 && <2.2) [details]
Tested with ghc ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.5 || ==9.8.2 || ==9.10.1
License BSD-3-Clause
Copyright 2021-2024 Thomas Bidne
Author Thomas Bidne
Maintainer tbidne@protonmail.com
Category Development
Home page https://github.com/tbidne/package-version/
Bug tracker https://github.com/tbidne/package-version/issues
Source repo head: git clone https://github.com/tbidne/package-version
Uploaded by tbidne at 2024-08-12T23:48:54Z
Distributions NixOS:0.4
Downloads 612 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for package-version-0.4

[back to package description]

Package Version

Hackage ci BSD-3-Clause

Package Description

This package defines a PackageVersion type that represents PVP version numbers. We provide functionality for reading these numbers from cabal files at both runtime and compile-time, the latter being useful when implementing --version options in executables. See the haddocks on hackage for more information.

Alternatives

Reading the cabal version can also be achieved by utilizing the generated Paths_<pkg-name> module. For instance, for a package named foo, we first add the generated module to our list of modules in foo.cabal:

cabal-version:      2.4
name:               foo
version:            0.1

...

library
  other-modules:   Paths_foo
  autogen-modules: Paths_foo

Then we can reference this in our code:

import Data.List (intercalate)
import Data.Version (Version(versionBranch))
import Paths_foo qualified as Paths

vsn :: String
vsn = intercalate "." $ fmap show $ versionBranch Paths.version

See the documentation for more details.