【发布时间】:2018-12-08 14:06:44
【问题描述】:
我想要的只是使用正则表达式解析一个简单的字符串。
第一个问题:我应该使用 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 替换/增强了 Text.Regex。新的构建计划应该没问题。
-
是否使用与 Text.Regex 相同的界面?另外,您是如何发现它替换了 Text.Regex 的?
-
写在标题的正下方。 This is the interface
-
你可以访问 stackage.org,选择一个解析器(一个 LTS 版本,如果你想要稳定的东西)然后检查它附带的包。例如,选择
resolver: lts-12.21,我们会得到几个正则表达式库,我们可以将它们添加到我们的依赖项中——找到一个适合您的:stackage.org/lts-12.21
标签: haskell