【问题标题】:What is this error? - FAILED DURING THE BUILDING PHASE这是什么错误? - 在构建阶段失败
【发布时间】:2015-06-16 08:29:54
【问题描述】:

我在构建时遇到了这个错误:

dist/package.conf.inplace:
inappropriate type

FAILED DURING THE BUILDING PHASE. The **exception** was: ExitFailure 1

我如何使用subRegex 在包中 Text.Regex?

我写过:

import Text.Regex.Posix

但是我收到了这个错误:

_.hs:13:5: Not in scope: ‘subRegex’

_.hs:13:15:
    Not in scope: ‘mkRegex’
    Perhaps you meant ‘makeRegex’ (imported from Text.Regex.Posix)

所以,我去了Text.Regex的[page][1],上面写着:

Text.Regex.Posix中使用POSIX正则表达式接口。

那么为什么这些函数不在范围内呢?

【问题讨论】:

  • 注意Text.Regex 不是一个包。它是 regex-compat 包中的一个模块。

标签: regex haskell scope ghc


【解决方案1】:

您可以执行以下步骤使其正常工作。

  1. http://hackage.haskell.org/package/regex-compat-0.92下载,解压到\2014.2.0.0\lib\
  2. 运行 Haskell。
  3. 输入:mod +Text.Regex 加载包。
  4. 类型,例如subRegex (mkRegex "[0-9]+") "foobar567" "123"
  5. 结果是"foobar123"(加载所有包后)。

这里是subRegex description

:: Regex Search pattern
-> String Input string
-> String Replacement text
-> String Output string

用替换替换给定正则表达式的每次出现 字符串。

在替换字符串中,“\1”指的是第一个子字符串; "\2" 到 第二个等;和 "\0" 到整个匹配。 "\\" 将插入一个 文字反斜杠。

如果正则表达式匹配一个空字符串,这不会前进。这 misfeature 是为了匹配原作的行为 Text.Regex API。

一些很酷的链接可以帮助您深入研究:
http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/
https://wiki.haskell.org/Cookbook/Pattern_matching

我在 Windows 中使用它,这是我的屏幕:

【讨论】:

  • 我在构建时收到此错误:在构建阶段失败。例外是:ExitFailure 1
  • 在我的日志中它说:dist/package.conf.inplace:不合适的类型
  • 首先让我提一下,通过记录另一张票 (stackoverflow.com/questions/29837198/…),您承认这已经是一个单独的问题。现在,dev.stephendiehl.com/hask 有很好的 cabal 安装信息。然后,在ircbrowse.net/browse/haskell?events_page=4&q=Dist,您可以检查几种可能的解决方案:1)使用rm -rf dist 删除/dist 文件夹,然后使用cabal install,2)从haskell.org/ghc 获取最新版本(GHC 7.10.1 与 cabal-安装版本 1.22+)。
  • 我看到你在问题中包含了对你有用的代码。基本上,它与我的代码相同,因为您使用的是来自Text.Regex 模块的subRegex
【解决方案2】:

你不应该导入Text.Regex.Posix,而应该只导入Text.Regex,因为你想要的两个函数都在那里。

看看the Hackage page - 你快到了,但函数实际上在那个文件中。

【讨论】:

  • 我正在使用 ghci 但我仍然遇到错误。帮助!我尝试这样做并编译它也遇到了errorrrr
  • @Help-Ineedsomebody'shelp 如果您不告诉我们错误,我们将无法帮助您。
  • @Eric GOT THIS EROORORORO:在构建阶段失败。例外是:ExitFailure 1
  • 在我的日志中说 dist/package.conf.inplace: inappropriate type
猜你喜欢
  • 1970-01-01
  • 2012-12-01
  • 1970-01-01
  • 2021-10-29
  • 1970-01-01
  • 1970-01-01
  • 2019-03-26
  • 2019-08-08
  • 1970-01-01
相关资源
最近更新 更多