找不到模块'Text.Regex.Posix'

时间:2015-04-10 13:42:19

标签: haskell

我想尝试在GHCi中使用正则表达式。我尝试加载模块

 :mod +Text.Regex.Posix

但是却得到了这个错误

<no location info>:
    Could not find module ‘Text.Regex.Posix’
    It is not a module in the current program, or in any known package.

但我应该安装Text

ghc-pkg find-module Text.Regex.Posix会给我

/usr/local/Cellar/ghc/7.8.4/lib/ghc-7.8.4/package.conf.d
/Users/a/.ghc/x86_64-darwin-7.8.4/package.conf.d

我该怎么办?

我对此没有任何问题:

import Text.Read

为什么?

1 个答案:

答案 0 :(得分:18)

问题是您根本没有安装regex-posix软件包。这是导出Text.Regex.Posix模块的包。 Text.Read由每个Haskell发行版附带的base包导出。

您可以通过运行ghc-pkg find-module Text.Read来查看此内容。要全局安装regex-posix包,请运行命令cabal install regex-posix。如果您不想全局安装它或者在安装它时遇到问题,最好在您选择的目录中运行cabal sandbox init后尝试在沙箱中使用相同的命令安装它。

相关问题