6

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?

Max Maier
  • 985
  • 6
  • 16
  • 1
    Try `ghc-pkg list` to check if everything's alrite. – arrowd Sep 02 '18 at 08:01
  • Perhaps you installed the "software", but did not register it in the package manager. – Willem Van Onsem Sep 02 '18 at 08:10
  • 2
    I suspect Fedora's `ghc-containers-0.5.10.2-66` package actually targets a different compiler from the one you're trying to use it with. Haskell packages are always built against one specific compiler and can't be used with another. Most people do not rely on OS-distro packages for this at all but install all needed packages with Cabal-install or Stack. I.e., https://www.haskell.org/platform/ or https://docs.haskellstack.org/en/stable/README/. – leftaroundabout Sep 02 '18 at 09:14
  • 5
    I don't know why its not working; perhaps a bug in the Fedora RPM. However you are probably better off without the Fedora version of GHC. It exists primarily as the compiler for other Haskell software that is packaged for Fedora. I suggest removing it and installing stack instead. – Paul Johnson Sep 02 '18 at 12:28

3 Answers3

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.
sshine
  • 15,635
  • 1
  • 41
  • 66
3

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
cdimitroulas
  • 2,380
  • 1
  • 15
  • 22
1

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> 
Albert Peschar
  • 521
  • 3
  • 4