Cannot find out module Data.Colour - haskell

I cannot import module Data.Colour, and the error as follow:
Could not find module `Data.Colour'
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
Am I missing anything?

A Hayoo! search reveals that this module lives in the colour package, which you presumably don't have installed. To install it, run cabal update followed by cabal install colour.

Related

Can not load a file that uses standard libraries in haskell

Hi I use GHCI and can normally load my files. Now I need to load a file that uses random. I get this error.
Chatterbot.hs:3:1: error:
Could not find module ‘System.Random’
Use -v to see a list of the files searched for.
|
3 | import System.Random
| ^^^^^^^^^^^^^^^^^^^^
This is very weird since it works for my friend who also have just installed GHCI and did nothing other than me. The main difference is that I am on windows. I really don t understand this and have tried googling a bit and many people speak about stack but it seems annoying and It obviously works for my friend without it.
Thanks in advance
EDIT problem solved. I needed to update cabal then I ran cabal install random and it worked well. Thanks everyone for the help!
If you are using a version of cabal-install >= 3.0 (check with cabal --version), then, instead of creating a cabal package, you can move to an empty folder and type:
cabal install --lib --package-env . random
This creates a .ghc.environment file in the folder. ghci sessions started inside that folder will pick it up, and they will be able to import System.Random.
If that works correctly, you might want to install "random" globally so that any invocation of ghci can use it:
cabal install --lib random
This creates/modifies the global environment file located at ~/.ghc/$ARCH-$OS-$GHCVER/environments/default.
The System.Random module is part of the random package, not of the base package. You thus should install it. If you for example use cabal, you can install it with cabal install random.
If you use Haskell stack for example, you can add it to your package-name.cabal file:
-- …
build-depends:
base >=4.7 && <5
, random >=1.0 && <2

Can not find module after installing it

I am trying to install "threepenny-gui", I simply do it by
cabal install threepenny-gui
It is a school project that I have to use it and you can find the start code here.
After I have installed it and run Calculator.hs without changing anything I get the error
ThreepennyPages.hs:13:18:
Could not find module ‘Data.Aeson’
Perhaps you meant Data.Version (from base-4.8.2.0)
Use -v to see a list of the files searched for.
ThreepennyPictures.hs:17:18:
Could not find module ‘Graphics.UI.Threepenny’
Use -v to see a list of the files searched for.
ThreepennyPictures.hs:18:8:
Could not find module ‘Graphics.UI.Threepenny.Core’
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
I read here in section 4.1 that
This happens when you install a package globally, and the previous packages were installed locally.
But does not give any real solution. How should I install it correctly? Have been having similar problems when installing other modules.

Issue using Hoe from cabal sandbox - System.Random not found

I'm trying to use the Hoe utility from a cabal sandbox and am presented with the following error:
lyndon#endpin ~/Haskell-Sandboxes/hoe-1.0.1 ./.cabal-sandbox/bin/hoe head
compile error: <no location info>:
Could not find module ‘System.Random’
Use -v to see a list of the files searched for.
I believe that this is due to Hoe using Hint to interpret expressions at runtime, and as part of this, expecting to be able to load globally installed modules. However, since I'm using a cabal-sandbox, modules are only installed locally.
I've attempted to look for any environment variables I can use to specify the location of the random module as ./.cabal-sandbox/lib/x86_64-osx-ghc-7.8.3/random-1.1, however nothing obvious has appeared.
22070308 suggested that HASKELL_PACKAGE_SANDBOX might help, but it doesn't seem to.
I actually just came across the solution
Setting GHC_PACKAGE_PATH to include the sandbox, and the default package location:
lyndon#endpin ~/Haskell-Sandboxes/hoe-1.0.1 find ~/ghc_versions/ghc-7.8.3/ | grep package.cache
/Users/lyndon/ghc_versions/ghc-7.8.3//lib/ghc-7.8.3/package.conf.d/package.cache
lyndon#endpin ~/Haskell-Sandboxes/hoe-1.0.1 GHC_PACKAGE_PATH=~/ghc_versions/ghc-7.8.3//lib/ghc-7.8.3/package.conf.d:./.cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d ./.cabal-sandbox/bin/hoe head
asdf
'a'

Installing Cabal has missing modules

My ghc install was out of date so I decided to reinstall ghc and cabal to hopefully fix some problems. I started out following the steps here. GHC is now version 7.8.3.
I then removed ~/.cabal and tried to install using the steps but it fails. So I removed .cabal again and tried the steps here but when I run sh bootstrap.sh it runs into missing modules:
Using local tarball for parsec-3.1.6.
[1 of 1] Compiling Main ( Setup.hs, Setup.o )
Linking Setup ...
Configuring parsec-3.1.6...
Building parsec-3.1.6...
Preprocessing library parsec-3.1.6...
Text/Parsec/Prim.hs:80:8:
Could not find module ‘Control.Monad.Trans’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:81:8:
Could not find module ‘Control.Monad.Identity’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:83:8:
Could not find module ‘Control.Monad.Reader.Class’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:84:8:
Could not find module ‘Control.Monad.State.Class’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:85:8:
Could not find module ‘Control.Monad.Cont.Class’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:86:8:
Could not find module ‘Control.Monad.Error.Class’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Text.hs:19:18:
Could not find module ‘Data.Text’
There are files missing in the ‘text-1.2.0.0’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Text/Lazy.hs:19:18:
Could not find module ‘Data.Text.Lazy’
There are files missing in the ‘text-1.2.0.0’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Error during cabal-install bootstrap:
Building the parsec package failed.
When I run ghc-pkg check I get a WHOLE lot of stuff like this:
cannot find any of ["libHSOpenGLRaw-1.5.0.0.a","libHSOpenGLRaw-1.5.0.0.p_a","libHSOpenGLRaw-1.5.0.0-ghc7.8.3.so","libHSOpenGLRaw-1.5.0.0-ghc7.8.3.dylib","HSOpenGLRaw-1.5.0.0-ghc7.8.3.dll"] on library path
Warning: haddock-interfaces: /usr/local/share/doc/x86_64-linux-ghc-7.8.3/Cabal-1.21.1.0/html/Cabal.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/local/share/doc/x86_64-linux-ghc-7.8.3/Cabal-1.21.1.0/html doesn't exist or isn't a directory
and then this:
The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
text-1.1.0.1
Cabal-1.20.0.2
zlib-0.5.4.1
contravariant-1.2
void-0.6.1
netwire-5.0.0
semigroups-0.15.3
unordered-containers-0.2.5.0
transformers-compat-0.3.3.4
exceptions-0.6.1
MonadRandom-0.3
mtl-2.2.1
transformers-0.4.1.0
cpphs-1.18.5
polyparse-1.9
nats-0.2
hashable-1.2.2.0
OpenGL-2.9.2.0
text-1.2.0.0
tagged-0.7.2
stb-image-0.2.1
split-0.2.2
reflection-1.5.1
random-1.0.1.1
primitive-0.5.3.0
prelude-extras-0.4
parallel-3.2.0.4
bitmap-0.0.2
bindings-DSL-1.0.21
GLURaw-1.4.0.1
OpenGLRaw-1.5.0.0
You can either use ghc-pkg unregister on each of the broken packages to clean them out properly, or possibly blow away the whole ~/.ghc folder and start again. You may need to use --force to avoid having to respect the dependency order of the packages.
Did you also remove ~/.ghc when you removed ~/.cabal? If not, I suggest you try that, since if I understand correctly, the first may contain references to packages installed in the second.

Haskell Could not find module `System'

I'm new with Haskell and have trouble with its package.
I want to import System.Random but
Could not find module `System.Random'
Then I tried to import System but
Could not find module `System'.
It is a member of the hidden package `haskell98-2.0.0.0'.
I tried to search this problem, but those solutions still don't work.
As this said, I tried to install cabal on my Mac OS X using MacPort, but
Error: The following dependencies were not installed: ghc
Error: Status 1 encountered during processing.
I have installed Haskell Platform and can use ghci in command-line.
GHCi, version 7.2.1
Then I tried to use ghc-pkg expose haskell98-2.0.0.0 as this one says.
But this time, I can't even run ghci.
Top level:
Ambiguous interface for `Prelude':
it was found in multiple packages: base haskell98-2.0.0.0
So, what can I do without using cabal?
The System.Random module belongs to the random package, which is no longer included with GHC as of version 7.2.1.
I'm not sure what to do about your Cabal problem, as I'm not familiar with Mac OS X, but I'd recommend getting that to work first. Installing random should then be trivial using Cabal.
As a possible workaround, you might want to consider using an older version of GHC.
the cabal incantation:
cabal install random
The answer here is a little bit dated and would lead to a global install and should be discouraged.
A better approach will be to add the random package as dependency in the .cabal file.
Something like this:
build-depends: base ^>=4.13.0.0 --base package
, random -- random package where System.Random can be found
cabal repl -b random # -b is short for --build-depends
This answer was based on another stackoverflow thread here. Basically it installs the package random as a dependency of your project rather than installing it globally. Packages are installed globally if you just write cabal install random - which we dont usally want.

Resources