haskell - 为什么我无法在 Stack 项目中使用 Text.Regex?

标签 haskell

我想要的只是使用正则表达式解析一个简单的字符串。

第一个问题:我应该使用 Text.Regex 还是其他东西? Stackage 列出了至少 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 额外部门: - 正则表达式-1.0.1.3 - 基础兼容-0.9.3 - 模板-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.

???

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

我需要不同版本的正则表达式吗?如果是的话,是哪一个,我该如何解决?

最佳答案

评论中有一些关于使用什么的建议:regex-base ,但了解它为什么不编译也很好。

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

通常,每个 stackage 主要 LTS 版本都与特定版本的 GHC 相关联,该版本还具有特定版本的base。当您选择 LTS 的主要版本时,您还选择了 GHC 和 base 的版本。如果您想更改 GHC 和/或 base 版本,更改 LTS 版本会更容易。 LTS 版本之后的第一件事是 Stackage LTS page 是 GHC 版本号。

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

关于haskell - 为什么我无法在 Stack 项目中使用 Text.Regex?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53683316/

相关文章:

haskell - 如何让 GHC 相信递归类型的类型相等性

haskell - 带状态参数的 IterateUntil

haskell - 处理具有相同内部表示和最小样板的多种类型?

haskell - 在我自己的 Queue 类型中包装 Data.Sequence 有什么问题吗?

haskell - 如何在同一个函数中订阅多个 Redis channel ?

haskell - 'Chaining operations' 是 Monad 类解决的 "only"吗?

haskell - Applicative 中纯定义的问题

haskell - 做MapReduce的最佳功能语言?

haskell - 为什么在这个 SBV/Z3 代码中 Int32 排序比整数排序慢得多?

haskell - 如何指定子表达式的多态类型?