使用regex-compat

时间:2016-08-19 20:37:57

标签: windows haskell ghc

在Windows上使用GHC时,以下代码崩溃。它在Linux上完美运行。

这有什么意义还是有错误?

module Main where

import qualified Text.Regex as Re -- from regex-compat
import Debug.Trace

main :: IO ()
main = do
  putStr $ cleanWord "jan"
  putStr $ cleanWord "dec"
  putStr $ cleanWord "jun" -- crashes here

cleanWord :: String -> String
cleanWord word_ =
  let word = trace (show word_) word_ in
  let re = Re.mkRegexWithOpts "(jun|jul|aug|sep|oct|nov|dec)" True False in
  Re.subRegex re word ""

一些其他细节

  1. 我正在使用stack
  2. 构建
  3. 它在GHCi中崩溃并运行已编译的可执行文件
  4. 我尝试启用分析,但似乎无法弄清楚如何使其正常工作。

1 个答案:

答案 0 :(得分:0)

围绕正则表达式进行洗牌避免了这种情况下的错误。

这对我现在很好用

let re = Re.mkRegexWithOpts "(jul|aug|sep|oct|jun|nov|dec)" True False in 

即。将jun移到正则表达式的末尾。不是特别令人满意,但它有效,这意味着我可以继续。

@ Zeta的评论表明这是底层库的错误

  

这是一个错误,可能在regex-posix中,因为它的差异   从1994年开始包含底层BSD正则表达式库。在sslow中,a   

将访问无效的内存地址(-1(%rdx),rdx = 0)
相关问题