@hackage / package-version

A package for retrieving a package's version number.

Latest0.4.1

About

Metadata

  • Last updated , by tbidne
  • License BSD-3-Clause
  • Categories Development
  • Maintained by: tbidne@protonmail.com

  • Lottery factor: 1

Links

Installation

Tested Compilers

  1. 9.12.1
  2. 9.10.1
  3. 9.8.4
  4. 9.6.6
  5. 9.4.8
  6. 9.2.8
  7. 9.0.2
  8. 8.10.7

Readme

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.