Do I need to manually edit the *.cabal file's build-depends
section to add package as a project dependency?
Or perhaps there is a more convenient way that is not as error prone as manually mangling with build files is.
Thinking about functionality that pretty much any package manager I used has, namely
apt install
npm i
nuget install
Install Package
and so on. Does such functionality exist in Cabal?
apt install
etc. aren't really comparable. It used to be possible tocabal install
a package to the “global project” and then it would be available in any Haskell file without an associated cabal project... but eventually people agreed that this was unreliable, and that explicitly adding dependencies to the.cabal
file is actually the better way. That said, I agree that it would be nice to have a command-line utility for the actual editing of the file, including lookup of a suitable version range. – Dreecabal-install
itself. There's a helper executable calledcabal-edit
that seems to do what you want. hackage.haskell.org/package/cabal-edit You can install it with the commandcabal install cabal-edit --overwrite-policy=always --install-method=copy --installdir=some_destination_folder
. – Mozzettaapt install whatever-fancy-program
andapt
tells you it's also going to installgtk
, how do you suppose it knows thatgtk
is a dependency? Answer: somebody manually mangled a file to record that information. (And if this is not the functionality that you refer to when you say "such functionality", then can you be more specific about what you want? You may think it's obvious, but to me it's not -- I'm making a lot of guesses here.) – Montesnpm i
See, what I am looking for is just a way to use package manager to add build dependencies in the cabal file. Just that. Currently I need to do that manually which is surprising and I guess more experienced Haskell programmers do have a better way to manage build dependencies other that typing them manually. At least I hope this is the case. – Psychrometer