Did I install cabal correctly? - haskell

Hi I've just updated cabal to the latest version by the command
cabal update
and
cabal install cabal-install
Then it returns
Installed cabal-install-1.22.2.0
Updating documentation index /MyPath
I want to use alex and happy. Sorry I'm very new to it.. When I tried to issue alex in ghci by the line
alex wordcount.x
It returns
Not in scope: ‘alex’
Perhaps you meant ‘lex’ (imported from Prelude)
I searched online for this and I found a webpage saying that I should first check the version of them by
cabal configure -v | grep -e alex -e happy
But I got this line
cabal: No cabal file found.
Please create a package description file <pkgname>.cabal
Could anyone help me with this problem?

Once you install cabal you can install other packages.
So, to install the Alex package, you'll do cabal install alex. Then I see that you tried to invoke Alex in GHCi, but that's not correct, since alex is a program. You have to invoke it from the terminal.

Related

Cabal install command Gives error

I can't understand why it just dosen't work. My question is what might have gone wrong i have created the ~/.bash_profile and tried to add the PATH given by the haskell webpage.
When i preform cabal install i get this output:
Marcuss-MacBook-Pro:~ marcuslagerstedt$ cabal install
cabal: Error reading local package.
Couldn't find .cabal file in: .
Marcuss-MacBook-Pro:~ marcuslagerstedt$
I hope i did a correct question.
But i really need help aswell.
You seem to be wanting to install a particular package, namely agda. The command cabal install takes either the name of a package or assumes you are installing some package in the local directory. You are hitting this second case.
To install agda try:
cabal update
cabal install agda

Problems with Cabal when installing Agda

Im trying to get Agda working following this turtorial. However when I type cabal install agda I get an error saying I have the wrong version of alex installed, I then use cabal install alex and after alex is installed I checks so that alex -v gives me the correct version which it does. I then try to run cabal install agda again but still it is complaining about wrong version of alex. I then put the exact path to alex on my path which is:
/Users/me/Library/Haskell/ghc-7.6.3/lib/alex-3.1.4/bin
This works and fixes the problem for alex but now cabal install agda need the correct version of cpph.
So my questions is why do i need to put ever package directly on my systems path for cabal to find the latest version? Why can it not use the following path which has all the correct symlinks and is also on my systems path:
~/Library/Haskell/bin:
The path ~/Library/Haskell/bin should be the first one in the list of your paths.

ubuntu haskell ghci 7.4.1 could not find module "System.Random"

When I tried to load a .hs in ghci, it failed on the line:
import System.Random
Message:
Could not find module `System.Random'
Use -v to see a list of the files searched for.
I remember it worked yesterday and all of a sudden today it does not work.
This problem only occurs on Ubuntu 12.04 LTS, GHCi 7.4.1 , when i tried this on windows haskell platform and other linux machines i worked.
I tried to use
sudo apt-get remove ghc
sudo apt-get install ghc
to remove and re install ghc, but however the problem persists.
Could someone help me? Thanks
You must install the random package. You can probably get it from your package manager (as something like libghc-random-dev or similar), or you may cabal install random.
Edit in 2021 These days, cabal install is not the way. Instead, use cabal init to create a package and list random in your build-depends field. Compilation can be performed with cabal build (just build) or cabal run (to execute the result); interactive use is available via cabal repl.

installing reactive-banana-wx

when you try to install the library reactie-banana-wx, get the error:
src\CRUD.hs:10:18: Could not find module `Data.Map': It is a member of the hidden package `containers-0.4.0.0'. Perhaps you need to add `containers' to the build-depends in your .cabal file.
installed the command:
cabal install reactive-banana-wx
Please help correct the problem.
The advice it offers is sound, if a bit confusing: cabal install hides the step where it produces the .cabal file! Here's how you can do that part explicitly:
cabal unpack reactive-banana-wx
cd reactive-banana-wx-*
gvim *.cabal # or whatever editor you prefer
# follow the instructions given in the error
cabal install

cabal install yesod fails?

Haskell package dependencies continue to be a problem but I don't know how to get around this one. My environment:
Ubuntu 10.10, new install
apt-get install ghc6 cabal-install
cabal update && cabal install cabal-install
Then:
cabal install yesod
And I get this:
$ cabal install yesod
cabal: Error: some packages failed to install:
persistent-0.3.1.2 failed during the building phase. The exception was:
ExitFailure 1
yesod-0.6.6 depends on persistent-0.3.1.2 which failed to install.
$ cabal install persistent-0.3.1.2
Resolving dependencies...
cabal: cannot configure blaze-builder-0.2.0.2. It requires text ==0.10.*
For the dependency on text ==0.10.* there are these packages: text-0.10.0.0,
text-0.10.0.1 and text-0.10.0.2. However none of them are available.
text-0.10.0.0 was excluded because enumerator-0.4.3.1 requires text ==0.11.*
text-0.10.0.1 was excluded because enumerator-0.4.3.1 requires text ==0.11.*
text-0.10.0.2 was excluded because enumerator-0.4.3.1 requires text ==0.11.*
How do I get yesod installed?
To see more details, add -v (or even -v2 or -v3) and perhaps --dry-run. Also it's useful to see what's currently installed, with ghc-pkg list.
When you upgrade persistent, cabal decides it should also rebuild your existing yesod which depends on it. This triggers a blaze-builder upgrade. blaze-builder requires an older text than enumerator which is also being installed.
http://hackage.haskell.org/package/enumerator claims to support older text versions as well as 0.11. But cabal has been outwitted somehow. The verbose output may tell more, or see if you can help it along with a --constraint or two. Or by first uninstalling some related packages, like yesod. And of course be sure you have done cabal update.
yesod is under heavy development. email michael snoyman (contact info can be found here), he is very responsive to requests
There is a dependency-break. Report this as an error to the author of the package. Consider downloading and installing an older version of enumerator manually, too.
I found some information about a better install process here:
https://github.com/yesodweb/yesod
Look for the section about cabal-src.
I'm in the process of trying it out.
I'll report back, and let people know if it works.

Resources