[Hackage] #823: Accessing the package version from within the package

#823: Accessing the package version from within the package ----------------------------+----------------------------------------------- Reporter: basvandijk | Owner: Type: enhancement | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.8.0.6 Severity: normal | Keywords: Difficulty: unknown | Ghcversion: Platform: | ----------------------------+----------------------------------------------- Just like you can [http://haskell.org/cabal/release/cabal-latest/doc /users-guide/authors.html#paths-module access data files from a package], it would be useful to retrieve the current version of your package from within your program. This is useful when you want to print the current version of your program when the user issues a `--version` flag for example. More specifically I would like the following module to be generated automatically: {{{ module Version_pkgname where import Distribution.Version (Version) version :: Version version = <the current package version> }}} where [http://haskell.org/cabal/release/cabal-latest/doc/API/Cabal /Distribution-Version.html#t%3AVersion Version] is from the `Cabal` library. Having just a `String` for the version type is also OK and maybe even preferable because otherwise a dependency on the `Cabal` library is required. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/823 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#823: Accessing the package version from within the package ----------------------------+----------------------------------------------- Reporter: basvandijk | Owner: Type: enhancement | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.8.0.6 Severity: normal | Keywords: Difficulty: unknown | Ghcversion: Platform: | ----------------------------+----------------------------------------------- Comment(by AntoineLatter): Maybe I'm miss-understanding, but this feature already exists exactly as you've described. Paths_$pkgname.version :: Version is exported by default. I'm not sure in which version it was introduced, and the user guide makes no mention of the feature. Here's the code in 1.10: http://www.haskell.org/ghc/docs/7.0.2/html/libraries/Cabal-1.10.1.0/src /Distribution-Simple-Build-PathsModule.html -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/823#comment:1 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#823: Accessing the package version from within the package ----------------------------+----------------------------------------------- Reporter: basvandijk | Owner: Type: enhancement | Status: closed Priority: normal | Milestone: Component: Cabal library | Version: 1.8.0.6 Severity: normal | Resolution: worksforme Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Changes (by basvandijk): * status: new => closed * resolution: => worksforme Comment: Replying to [comment:1 AntoineLatter]:
Maybe I'm miss-understanding, but this feature already exists exactly as you've described.
Indeed. I just discovered this myself when browsing through the `autogen` directory of one of my packages and reading the `Paths_package` module. I'm closing the ticket as `worksforme`. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/823#comment:2 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#823: Accessing the package version from within the package ----------------------------+----------------------------------------------- Reporter: basvandijk | Owner: Type: enhancement | Status: closed Priority: normal | Milestone: Component: Cabal library | Version: 1.8.0.6 Severity: normal | Resolution: worksforme Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Comment(by basvandijk): I [ticket:825 wrote] some documentation. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/823#comment:3 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects
participants (1)
-
Hackage