Haskell: Correct practice to specify version in source?

后端 未结 2 1544
名媛妹妹
名媛妹妹 2021-01-07 22:16

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

2条回答
  •  臣服心动
    2021-01-07 22:43

    Best practice is to put the version number in your cabal file, as you have already noted.

    I am not aware of any good practices by which you can maintain a single point of truth about the version, yet make the number available both to cabal and to your application.

    I would recommend a single file Version.hs in the sources with these contents:

     module Version 
     where
     version :: String
     version = "3.14159"
    

    You could then, if you wished, use some kind of script to update the cabal file with this number, but I don't know how to do this from within cabal itself.

    This strategy will work only for application packages; if you are building a library, you'll need to give some thought to where in the namespace of hierarchical modules your Version.hs will go.

    On the whole, I suspect the game is not worth the candle.


    P.S. The version number should be immutable, so you want a value, not a function.

提交回复
热议问题