Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Cabal Sandbox

I want to build an environment for tutorial programs for Haskell, as I want to try and learn the language. So I read about Cabal and already have it on my machine, because I updated pandoc sometimes. I followed some tutorials, which state that you should run:

$ cabal sandbox init
$ cabal install --only-dependencies
$ cabal build

To have the environment set up. However, if I try so, I receive the following message:

$ cabal sandbox init
Writing a default package environment file to
/home/xiaolong/development/Haskell/cabal.sandbox.config
Using an existing sandbox located at
/home/xiaolong/development/Haskell/.cabal-sandbox

(Output of ls command)

$ ls
cabal.sandbox.config

And then:

$ cabal install --only-dependencies
cabal: Error reading local package.
Couldn't find .cabal file in: .

Huh? Suddenly there needs to be a .cabal file? This is puzzling to me. What steps do I need to take to get an environment, in which I can simply install packages and then use that environment to run code of any tutorials I choose?

This is another tutorial suggesting the described workflow. Something is there I am missing.

(I am under the impression, that cabal sandboxes are comparable to python virtualenvs, being useful in the way, that one doesn't need to install packages system-wide, but can instead install them in a directory and then use that environment to run programs.)

like image 417
Zelphir Kaltstahl Avatar asked Jan 24 '16 00:01

Zelphir Kaltstahl


1 Answers

You need to have a cabal file inside it which describes your project's name, package dependencies, license etc. A cabal file can be generated using cabal init which is followed by a series of question you have to answer.

Once the initial cabal configuration file is created, you can go inside the package directory and create sandbox inside it using the commands you have described above.

You may be also interested in Stack which is another alternate (better, if you would ask me :)) tool for developing Haskell projects.

like image 65
Sibi Avatar answered Oct 11 '22 16:10

Sibi