5

我的 Fedora 28 系统上安装了以下 RPM 软件包:

ghc-ghc-8.2.2-66
ghc-containers-0.5.10.2-66

根据hackage,set 模块应该包含在给定的 RPM 中。然而试图import Data.Set导致

<no location info>: error:
    Could not find module ‘Data.Set’
    Perhaps you meant Data.Int (from base-4.10.1.0)

我错过了要安装的东西吗?如何检查哪些模块可用?

编辑:

$ ghc-pkg list
/usr/lib64/ghc-8.2.2/package.conf.d
    base-4.10.1.0
    ghc-prim-0.5.1.1
    integer-gmp-1.0.1.0
    rts-1.0

如何注册模块?

4

3 回答 3

4

I would skip the operating system packages and go with stack:

$ wget -o get-stack.sh https://get.haskellstack.org/
$ chmod +x get-stack.sh
$ ./get-stack.sh -d ~/.local/bin
$ echo 'export PATH="~/.local/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc
$ stack --version
Version 1.7.1, Git revision ...

Then use stack ghc to run GHC; the first time it will install this:

$ stack ghc
Writing implicit global project config file to: ...
Note: You can change the snapshot via the resolver field there.
Using latest snapshot resolver: lts-12.9
Downloaded lts-12.9 build plan.    
Preparing to install GHC to an isolated location.
于 2018-09-03T10:35:12.973 回答
2

For anyone new like me who finds this, you need to add containers to your package.yaml dependencies in order to import Data.Set. My package.yaml dependencies looked like this to get a Data.Set import to work:

dependencies:
  - base >= 4.7 && < 5
  - containers > 0.6

Then you can import Data.Set in your file like

import Data.Set (Set)
import qualified Data.Set as Set
于 2019-12-22T11:25:35.860 回答
1

ghc-containers仅包含链接到它的已编译程序的共享库 (.so)。如果您希望在开发中使用该库,请安装ghc-containers-devel

$ dnf install -y ghc-containers-devel
$ ghci
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
Prelude> import Data.Set
Prelude Data.Set> 
于 2019-03-22T09:13:14.123 回答