我想尝试在GHCi中做正则表达式.我试着加载模块
:mod +Text.Regex.Posix
Run Code Online (Sandbox Code Playgroud)
但是得到了这个错误
<no location info>:
Could not find module ‘Text.Regex.Posix’
It is not a module in the current program, or in any known package.
Run Code Online (Sandbox Code Playgroud)
但是我应该安装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
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我对此没有任何问题:
import Text.Read
Run Code Online (Sandbox Code Playgroud)
为什么?
bhe*_*ilr 18
问题是你根本没有regex-posix安装包.这是导出Text.Regex.Posix模块的包. Text.Read由base每个Haskell发行版附带的包导出.
你可以通过运行看到这一点ghc-pkg find-module Text.Read.要regex-posix全局安装程序包,请运行该命令cabal install regex-posix.如果您不想全局安装它或者在安装它时遇到问题,最好cabal sandbox init在您选择的目录中运行之后尝试使用相同的命令在沙箱中安装它.