【问题标题】:cabal: how to automatically update the build-depends field in the .cabal file?cabal:如何自动更新 .cabal 文件中的 build-depends 字段?
【发布时间】:2015-05-14 23:05:07
【问题描述】:

有没有办法自动更新 .cabal-file 中的 build-depends 字段?例如,如果我们从以下.cabal 文件开始:

name:           HUnit
version:        1.1.1
synopsis:       A unit testing framework for Haskell
homepage:       http://hunit.sourceforge.net/
category:       Testing
author:         Dean Herington
license:        BSD3
license-file:   LICENSE
cabal-version:  >= 1.10
build-type:     Simple

library
  build-depends:      base >= 2 && < 4
  exposed-modules:    Test.HUnit.Base, Test.HUnit.Lang,
                      Test.HUnit.Terminal, Test.HUnit.Text, Test.HUnit
  default-extensions: CPP

然后,安装一个包:

cabal install warp

现在,我必须将warp &gt;=3.0 &amp;&amp; &lt;3.1 添加到build-depends 字段,使文件看起来像这样:

name:           HUnit
version:        1.1.1
synopsis:       A unit testing framework for Haskell
homepage:       http://hunit.sourceforge.net/
category:       Testing
author:         Dean Herington
license:        BSD3
license-file:   LICENSE
cabal-version:  >= 1.10
build-type:     Simple

library
  build-depends:      base >= 2 && < 4, warp >=3.0 && <3.1
  exposed-modules:    Test.HUnit.Base, Test.HUnit.Lang,
                      Test.HUnit.Terminal, Test.HUnit.Text, Test.HUnit
  default-extensions: CPP

我的问题是:我们如何自动更新这个文件?

【问题讨论】:

标签: haskell cabal


【解决方案1】:

现代cabal-install 中有两个工具用于帮助管理依赖关系的界限。首先是gen-bounds,它根据当前安装的版本规范为软件包建议适当的版本范围。第二个是outdated,它列出了cabal 文件中的依赖关系,在hackage 上存在较新版本。两者都记录在阴谋集团手册中:https://www.haskell.org/cabal/users-guide/developing-packages.html#generating-dependency-version-bounds

【讨论】:

    【解决方案2】:

    一种可能的替代方法是使用 hpack、yaml、海绵和 jq:

    您将需要 hpack package.yaml 文件。

    例如添加aeson作为依赖:

    cp package.yaml package.yaml.backup && (yaml2json package.yaml | jq '.dependencies += ["aeson"]' | json2yaml | sponge package.yaml ) && hpack
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多