Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 992
Max Maier Avatar asked Sep 02 '18 07:09

Max Maier


2 Answers

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.
like image 90
sshine Avatar answered Oct 02 '22 21:10

sshine


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
like image 27
cdimitroulas Avatar answered Oct 02 '22 20:10

cdimitroulas