Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7695683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:35:57+00:00 2026-05-31T21:35:57+00:00

What is the best/correct practice to specify version within your source code tree? What

  • 0

What is the best/correct practice to specify version within your source code tree?
What I want is, for instance, to put VERSION file in the top level of the source tree and get the “version” function to read it.

There is a version section in the cabal file. Is it possible to read it from my source by “help” or “version” functions?
What is the correct practice of specifying the version in one place and making it available globaly?

P.S. Are there any functions in the Cabal library that allow you to pull any section from the cabal file and present it in your source? Then I could simply pull the version section from the cabal file.

— UPDATE —

Thank you Thomas for an nice piece of knowledge about the Pathes_x module.
Just wanted to add that, apparently, I don’t need to put anything into my cabal file. Everything just works without it. All I needed was to import the Pathes_X as you sugested.
Also, I needed to import Data.Version to get the showVersion function to properly format/print the Version data type. So at the end I get something like this:

import Paths_kvman
import Data.Version

runVersion _ = putStrLn ("Version: " ++ (showVersion version))

Now, all I need is to change the version number in the cabal file to propagade it all over my source. Exactly what I needed. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:35:58+00:00Added an answer on May 31, 2026 at 9:35 pm

    Cabal automatically generates a module for each package named Paths_packagename. Just import this package and look at the version value it exports.

    Edit: For example:

    module Data.Blah where
    
    import Paths_t
    
    func :: IO ()
    func = print version
    

    And an example run:

    > func
    Version {versionBranch = [0,1], versionTags = []}
    

    Be sure to put Paths_packagename in your Other-Modules section of the cabal file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When defining a new class within a project what is the correct/best practice for
What is the correct/rails/best practice way to call media specific (i.e. print, screen, etc)
What is best practice to ensure only the correct users can see a webpart
I'm writing my first jquery plugin and wondered what the correct/best practice way of
Is there a pattern or best practice in Rails whereby we can specify, in
Possible Duplicate: Detect if PDF file is correct (header PDF) I want to validate
I've been doing a lot of research on how best to write correct network
I wondered about the best way to implement a correct, flexible and fast Equals
What is the best way to check if a user has correct rights to
Best to describe this in code... I have this public class A<T> { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.