Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate cabal file with dependencies on foreign libs

Tags:

haskell

cabal

Is it possible to automatically generate cabal file for a given haskell project, that will create appropriate Build-depends dependencies for all the libs that the project uses?

like image 841
Andriy Drozdyuk Avatar asked Mar 25 '12 03:03

Andriy Drozdyuk


People also ask

Are all dependencies other Cabal packages?

Not all dependencies are other Cabal packages. Foreign libraries are clearly another kind of dependency. It’s also possible to think of language extensions as dependencies: the package depends on a Haskell implementation that supports all those extensions. Where compiler-specific options are needed however, there is an “escape hatch” available.

How do I turn a project into a cabal package?

This simple example has all the project files in one directory, but most packages will use one or more subdirectories. To turn this into a Cabal package we need two extra files in the project’s root directory: proglet.cabal: containing package metadata and build information.

How do I open a cabal file?

Load up the .cabal file in a text editor. The first part of the .cabal file has the package metadata and towards the end of the file you will find the executable or library section. You will see that the fields that have yet to be filled in are commented out.

How do you Resolve dependencies with Cabal?

This means tools like cabal can resolve dependencies and install a package plus all of its dependencies automatically. Alternatively, it is possible to mechanically (or mostly mechanically) translate Cabal packages into system packages and let the system package manager install dependencies automatically.


1 Answers

Yes! In fact, the 'cabal init' command does this in the HEAD version of cabal-install. It's true that it's not possible to get it exactly right in all cases, but it just makes the best guesses it can and then lets you fix the generated build-depends list as necessary.

like image 129
Brent Yorgey Avatar answered Oct 19 '22 10:10

Brent Yorgey