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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With