Max Maier
Max Maier

Reputation: 1045

Could not find module 'Data.Set'

I have the following RPM packages installed on my Fedora 28 system:

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

According to hackage the set module should be included in the given RPMs. However trying to import Data.Set results in

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

Did I miss something to install? How can I check which modules are available?

Edit:

$ 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

How do I register a module?

Upvotes: 6

Views: 4515

Answers (3)

cdimitroulas
cdimitroulas

Reputation: 2539

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

Upvotes: 3

Albert Peschar
Albert Peschar

Reputation: 561

ghc-containers contains only the shared library (.so) for compiled programs that are linked to it. If you wish to use the library in development, install 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> 

Upvotes: 1

sshine
sshine

Reputation: 16105

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.

Upvotes: 4

Related Questions