GHC 8.4.2 无法导入 System.Random

GHC 8.4.2 cannot import System.Random

我正在使用 Ubuntu 18.04 "Bionic Beaver",我有一个名为 BurgerKing.hs 的文件,它在 random 包中导入 System.Random

GHC 8.0.2,在Ubuntu的'universe'仓库下,可以编译:

ndos@ndos-desktop:~/Haskell$ ghc BurgerKing.hs -O2
[1 of 1] Compiling Main             ( BurgerKing.hs, BurgerKing.o )

BurgerKing.hs:14:1: warning: [-Wtabs]
    Tab character found here, and in 171 further locations.
    Please use spaces instead.
Linking BurgerKing ...

但是 GHC 8.4.2,它在 Herbert V. Riedel 的 PPA 下并且是通过符号 link 编辑的 link,无法编译它:

ndos@ndos-desktop:~/Haskell$ ./bin/ghc BurgerKing.hs -O2
[1 of 1] Compiling Main             ( BurgerKing.hs, BurgerKing.o )

BurgerKing.hs:10:1: error:
    Could not find module ‘System.Random’
    Use -v to see a list of the files searched for.
   |
10 | import System.Random
   | ^^^^^^^^^^^^^^^^^^^^

为什么?

编辑: 我尝试重新安装 PPA,ghc-8.4.2cabal-install-2.2,但问题仍然存在。

编辑 2: 我尝试清除旧版本的 ghccabal,然后重新安装 ghc-8.4.2cabal-install-2.2通过 sudo apt-get install --reinstall,但问题仍然存在。

我用有点难看的方式解决了这个问题。在清除 ghccabal 的旧版本后,我做了这些:

ndos@ndos-desktop:/usr/bin$ sudo ln -s /opt/ghc/bin/ghc
ndos@ndos-desktop:/usr/bin$ sudo ln -s /opt/ghc/bin/ghci

所以cabal会找到ghcrandom包可以下载成功:

ndos@ndos-desktop:~/Haskell$ ./bin/cabal install random
Resolving dependencies...
Configuring random-1.1...
Building random-1.1...
Installed random-1.1

并且BurgerKing.hs编译良好:

ndos@ndos-desktop:~/Haskell$ ghc BurgerKing.hs -O2
[1 of 1] Compiling Main             ( BurgerKing.hs, BurgerKing.o )

BurgerKing.hs:14:1: warning: [-Wtabs]
    Tab character found here, and in 171 further locations.
    Please use spaces instead.
   |
14 |         | Menu {price :: Int, name :: String, category :: MenuCategory}
   | ^^^^^^^^
Linking BurgerKing ...