据我所知,Text.ParserCombinators.Parsec
被Text.Parsec
取代
在这里,这是我的环境
4.9.73-1-MANJARO
The Glorious Glasgow Haskell Compilation System, version 8.2.2
cabal-install version 2.0.0.1
compiled using version 2.0.1.0 of the Cabal library
以下源代码是我main.hs
module Main where
import System.Environment
import Text.Parsec
main :: IO ()
main = do
args <- getArgs
putStrLn (readExpr (args !! 0))
然后我编译它
$ ghc -package parsec -o main main.hs
出现以下错误消息
[1 of 1] Compiling Main ( main.hs, main.o )
main.hs:3:1: error:
Could not find module ‘Text.Parsec’
There are files missing in the ‘parsec-3.1.11’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
|
3 | import Text.Parsec
| ^^^^^^^^^^^^^^^^^^
rm: cannot remove '*.hi': No such file or directory
./run.sh: line 11: ./TestProj: No such file or directory
我确保我已经安装了parsec
.所以我想问我犯了什么错误?
$ cabal install parsec
Resolving dependencies...
All the requested packages are already installed:
parsec-3.1.11
Use --reinstall if you want to reinstall anyway.
Manjaro可能继承了Arch与Haskell的问题。
这是怎么回事
Arch 安装动态库,但默认情况下静态ghc
链接。这也是错误消息"有文件丢失在...包",表示包存在,但不包含ghc
要查找的内容。
如果我尝试在打开 -v
详细标志的情况下进行编译,错误消息将扩展为:
ghc -v main.hs
(...)
Locations searched:
Text/Parsec.hs
Text/Parsec.lhs
Text/Parsec.hsig
Text/Parsec.lhsig
/usr/lib/ghc-8.2.2/site-local/parsec-3.1.11/Text/Parsec.hi
(...)
特别是,查看上次报告的位置,该位置在您的系统上可能有所不同; 如果我的猜测是正确的,ghc
正在寻找一个静态接口文件,.hi
消息所示,但只有一个动态的.dyn_hi
。
修复
使用 -dynamic
标志进行编译。
ghc -dynamic main.hs
如果有效,请阅读以下内容以修复设置:
https://wiki.archlinux.org/index.php/Haskell
您必须在静态和动态链接之间进行选择;我实际上不明白这里的权衡。