为什么我不能在Stack项目中使用Text.Regex?

时间:2018-12-08 14:06:45

标签: haskell

我只想使用regex解析一个简单的字符串。

第一个问题:我应该使用Text.Regex还是其他?堆栈列出至少11个正则表达式软件包。我不在乎是PCRE还是Posix。此时,我会接受任何东西。

第二个问题:如何在我的项目中包含Text.Regex?到目前为止,这是我的经验:

package.yaml具有

dependencies:
- base >= 4.7 && < 5
- regex

stacky.yaml尝试1

extra-deps:
- regex-1.0.1.3

响应堆栈构建

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

In the dependencies for regex-1.0.1.3:
    base-compat-0.10.5 from stack configuration does not match >=0.6 && <0.10  (latest matching version is 0.9.3)
    template-haskell-2.13.0.0 from stack configuration does not match >=2.7 && <2.12  (latest matching version is 2.11.1.0)
needed due to CCompiler-0.1.0.0 -> regex-1.0.1.3

Some different approaches to resolving this:

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

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
    errors, but results may be unpredictable.

  * Recommended action: try adding the following to your extra-deps in /Users/adamfrank/Dev/Haskell/CCompiler/stack.yaml:

- base-compat-0.9.3
- template-haskell-2.11.1.0

Plan construction failed.

stack.yaml尝试2 超深度 -regex-1.0.1.3 -基本兼容-0.9.3 -template-haskell-2.11.1.0

响应堆栈构建:

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

In the dependencies for regex-1.0.1.3:
    template-haskell-2.13.0.0 from stack configuration does not match >=2.7 && <2.12  (latest matching version is 2.11.1.0)
needed due to CCompiler-0.1.0.0 -> regex-1.0.1.3

Some different approaches to resolving this:

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

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
    errors, but results may be unpredictable.

  * Recommended action: try adding the following to your extra-deps in /Users/adamfrank/Dev/Haskell/CCompiler/stack.yaml:

- template-haskell-2.11.1.0

Plan construction failed.

???

它说我需要添加已经添加的行。

我需要其他版本的正则表达式吗?如果是这样,哪一个,我该如何解决?

1 个答案:

答案 0 :(得分:0)

注释中有关于使用什么的一些建议:regex-base,但是最好理解为什么不进行编译。

Stackage在每个LTS中提供了兼容软件包的列表。您可以更改某些版本号,只要它们遵守其他依赖项的版本约束即可。并非所有这些依赖关系限制都在来自Hackage的软件包中得到了很好的定义,这是使用Stackage的原因之一。

通常,每个主要的LTS堆栈发行版都与特定版本的GHC相关联,该版本也具有特定版本的base。当您选择LTS的主要版本时,您也在选择GHC和base的版本。如果要更改GHC和/或base版本,则更容易更改LTS版本。 Stackage LTS页上的LTS版本之后的第一件事是GHC版本号。

在您的情况下,regex要求版本template-haskellbase-compat违反其他依赖项的约束。