Haskell: Correct practice to specify version in source?

后端 未结 2 1452
名媛妹妹
名媛妹妹 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:39

    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.

提交回复
热议问题