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

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

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]

Properties

Versions 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]
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-05-22T00:14:30Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


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.