Haskell 栈版本依赖

Haskell stack version dependencies

Stack 新手。我开始构建 concurrent web scraper 和 运行 stack new my-project simple。在 my-project.cabal 中,我必须插入 hxt、url、http 和 maybet 的依赖项。

executable my-project
  hs-source-dirs:      src
  main-is:             Main.hs
  default-language:    Haskell2010
  build-depends:       base >= 4.7 && < 5,
                       time,
                       hxt,
                       http,
                       maybet

当我 运行 stack build 时,我得到这个:

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for my-project-0.1.0.0:
    http must match -any, but the stack configuration has no specified version
    maybet must match -any, but the stack configuration has no specified version
needed since my-project is a build target.

Some potential ways to resolve this:

  * Set 'allow-newer: true' to ignore all version constraints and build anyway.

  * You may also want to try using the 'stack solver' command.

在可执行指令下插入 allow-newer: true 似乎不起作用,添加版本后缀如 http == * 会出现解析错误,并根据 [=21] 给它 http == 4000.3.9, =] 给我 http must match ==4000.3.9, but the stack configuration has no specified version

有没有简单的方法告诉 cabal 文件我想要最新版本?

Hackage 中没有名为 http 的包。但是您有一个名为 HTTP.

的包

因此,修复包名称应该可以解决您的问题。

(而且博客文章似乎已经过时了,现在标准的 HTTP 请求方式是通过 conduit/wreq/req)。