import Control.Monad.Par not working - haskell

Here are my version info:
cabal-install version 1.24.0.2
compiled using version 1.24.2.0 of the Cabal library
On Ubuntu 18.04
$ ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Prelude> import Control.Monad.Par
<no location info>: error:
Could not find module ‘Control.Monad.Par’
Perhaps you meant
Control.Monad.Fail (from base-4.9.1.0)
Control.Monad.Fix (from base-4.9.1.0)
Control.Monad.RWS (needs flag -package-key mtl-2.2.1#mtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6)
Would appreciate any help on how to get Control.Monad.Par to work.

In general, Could not find module ‘...’ means you don't have the package installed1. You can search the module name on hayoo to get the package name, and then do:
cabal install [package name]
Or if you're using Stack for your project (recommended), you can add the package name to the build-depends section in your *.cabal file.
1It could also mean you misspelled the module name, the package was installed incorrectly, GHC isn't looking for the package in the place it was installed, or some other weird thing is going on, but I won't go into that.

Related

how do I install `Test.QuickCheck` GHCi can't find it, import fails

I'm on macOS running stack/GHCi version 8.4.3:
import Test.QuickCheck fails at both the GHCi prompt and in my .hs files. Either way I'm told it's not found.
GHCi Prelude>
<no location info>: error:
Could not find module ‘Test.QuickCheck’
It is not a module in the current program, or in any known package.
in .hs file >
"Could not find module ‘Test.QuickCheck’ '
The source code is on this page but I'm not sure how to install a new package into stack manually. From my brief reading when I googled "install Haskell package" it suggests installing a cabal package universally is a bad idea. Not sure this is a cabal package, and in any case it would be good to be able to import it for any project I think in my case.
The modern way to do this for a quick ghci session is to use cabal repl and add a dependency on QuickCheck:
% cabal repl --build-depends QuickCheck
> import Test.QuickCheck
Test.QuickCheck> -- ^_^
For longer-term programming (i.e. not just quick tests of stuff in ghci), the modern way is to create a cabal package and add QuickCheck to the build-depends section in the *.cabal produced:
% mkdir fancy-package
% cd fancy-package
% cabal init
<follow prompts>
% $EDITOR fancy-package.cabal
<find build-depends: and add, for example, QuickCheck ^>= 2.14 to the list>
% cabal repl
*Main> import Test.QuickCheck
*Main Test.QuickCheck> -- ^_^

How to resolve Haskell error in loading module?

I am getting the following error.
(base) Pauls-MBP-2:~ reiners$ ghci
GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help
Prelude> import Euterpea
<no location info>: error:
Could not find module ‘Euterpea’
It is not a module in the current program, or in any known package.
Prelude>
I had previously installed Euterpea with the command
cabal install Euterpea
In fact, the import actually worked. However, for other reasons, I closed that command prompt, and now it's not working.
I also tried running it from the cabal repl and got the same result:
(base) Pauls-MBP-2:~ reiners$ cabal repl
Resolving dependencies...
Build profile: -w ghc-8.8.4 -O1
In order, the following will be built (use -v for more details):
- fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Preprocessing library for fake-package-0..
Warning: No exposed modules
GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /var/folders/8k/74p15mf15zsg82l4r7xz28t00000gn/T/cabal-repl.-19576/setcwd.ghci
Prelude> import Euterpia
<no location info>: error:
Could not find module ‘Euterpia’
It is not a module in the current program, or in any known package.
Prelude>
I'm using macOS Catalina (10.15.7).

SDL.Cairo.Canvas not found even if the newest version of SDL(0.6.6.0) has been installed

Right after I installed the newest version of haskell binding version of SDL(0.6.6.0), though I can import SDL.Cairo, I still can not import SDL.Cairo.Canvas:
Prelude> install SDL.Cairo.Canvas
<interactive>:1:9: error:
Not in scope: data constructor ‘SDL.Cairo.Canvas’
No module named ‘SDL.Cairo’ is imported.
Prelude> import SDL.Cairo.Canvas as Canvas
<no location info>: error:
Could not find module ‘SDL.Cairo.Canvas’
It is not a module in the current program, or in any known package.
So, is SDL.Cairo.Canvas only available in the older versions? Or is it caused by incorrect installation?
SDL.Cairo.Canvas is not in the sdl2 package. It is in older versions of the sdl2-cairo package (before 0.2). You can install that with cabal or stack or whatever else you use to install packages.
Alternatively one can find the equivalent module in cairo-canvas as Graphics.Rendering.Cairo.Canvas.

PostgreSQL "Could not find module"

I'm trying to use Posgres and a cabal sandbox for a new project. I've got postgresql-simple installed, as evidenced by installation outputs:
$ cabal install postgresql-simple
Resolving dependencies...
All the requested packages are already installed:
postgresql-simple-0.4.10.0
Use --reinstall if you want to reinstall anyway.
Notice: installing into a sandbox located at
/Users/inaimathi/projects/hs-test/.cabal-sandbox
but when I try to import the library in ghci, I get the error
ghci
GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help
Prelude> import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple
<no location info>:
Could not find module ‘Database.PostgreSQL.Simple’
It is not a module in the current program, or in any known package.
Prelude>
Can anyone point out what I'm doing wrong?
You need to start GHCi with a -package-db=... flag pointing to /Users/inaimathi/projects/hs-test/.cabal-sandbox
so
ghci -package-db=/Users/inaimathi/projects/hs-test/.cabal-sandbox
or thereabouts...

Unable to import lens library

I installed haskell lens library. In ghci I try to run
λ> import Control.Lens
and it says -
<no location info>:
Could not find module ‘Control.Lens’
Perhaps you meant Control.Seq (from parallel-3.2.0.4)
I ran ghc-pkg list to list the installed packages and it does show -
lens-4.6.0.1
I am using GHC 7.8.3 on Ubuntu 13.04.

Resources