1

I've been using ghc 8.0.2 and I recently installed ghc 8.2.2. I tried compiling my project and got the following error message:

Could not find module ‘Data.Vector’
Perhaps you meant Data.Functor (from base-4.10.1.0)
Use -v to see a list of the files searched for.
   |
17 | import qualified Data.Vector as V

I checked the docs for Data.Vector and it doesn't say anything about the whole library becoming unavailable. Why did this happen and how can I fix it?

Eben Kadile
  • 759
  • 4
  • 21
  • 3
    Add `vector` as a dependency in your `.cabal` file. – Alexis King Feb 13 '18 at 07:34
  • 1
    Is the package installed? Maybe you need to install it using `cabal`? A package installed for one version of GHC is not automatically available for other versions. – chi Feb 13 '18 at 08:27
  • I wonder if this is in any way related to this (unresolved) problem of mine... https://stackoverflow.com/q/48083426/126014 – Mark Seemann Feb 13 '18 at 13:21
  • 1
    Probably irrelevant, but: on my Arch the recently installed ghc 8.2.2 whined about exactly the same kind of "Could not find module"-errors and required `ghc -dynamic` option to be passed. – Andrey Tyukin Feb 13 '18 at 13:35
  • 1
    @AndreyTyukin Good reminder. From what I've heard about such issues, it is probably best to avoid the distro packages when installing the Haskell toolchain on Arch, which is unfortunate. – duplode Feb 13 '18 at 14:05
  • 1
    As you can probably tell from the other comments, the `vector` package is still available with GHC 8.2.2, but it's hard to tell what's going on without more information: (1) How did you install GHC (`stack`, your Linux distribution's packages, etc.)? (2) What command are you using to build your project? (3) Does it have a `.cabal` file, and if so what are the contents? – K. A. Buhr Feb 13 '18 at 14:42

1 Answers1

0

I was unaware that certain packages weren't automatically available to all versions of ghc, but it does makes sense.

Thanks to chi's comment, I ran cabal install vector as well as cabal install parallel and the project is compiling once again.

Eben Kadile
  • 759
  • 4
  • 21
  • 3
    I'd go further and say _most_ packages are not "automatically available" (bundled) with the compiler. GHC ships with around a dozen packages and there are thousands out there. – Thomas M. DuBuisson Feb 13 '18 at 17:24
  • 1
    Why a down vote? The answer needed a clarifiction, not a downvote. – Evgeny Nov 10 '18 at 19:54
  • @EPo Lmao I was actually being really stupid when I asked and answered this. I can't believe it was less than a year ago. – Eben Kadile Nov 10 '18 at 20:24
  • 1
    2013 actually. I thing both the question and answer are useful, the haskell beginners like myself always stumble on whta is installed and what not in haskell. One departing from python expects basic things to be in a 'standard library' or already installed in a bundle like Anaconda, but they are not in ghci above-mentioned mentioned dozen. – Evgeny Nov 10 '18 at 23:02