i have started using stack haskell, when specifying external dependencies project. place in .cabal file while other times place in .yaml file.
am right in thinking when put in cabal file looks in stackage repository packages. when place in .yaml file searches in hackage server, if cannot find in of snapshots?
all of dependencies project go .cabal
file. correct, though, list packages in stack.yaml
file, can understandably confusing. why that?
well, .cabal
file expresses dependencies upon packages, stack.yaml
file configures where packages come from. usually, when using stack
, packages come stackage based on resolver specify in stack.yaml
file. however, stackage not include packages in hackage, , not intended to—when need packages live outside of stackage, have specify them in stack.yaml
file.
why this? well, resolver automatically couples 2 important pieces of information together: package names and package versions. stackage resolvers provide (weak) guarantee of packages within single resolver work together, when package comes resolver, there no need manually pick version want. instead, stackage decide you.
when pulling packages hackage, not have luxury, need specify packages and versions using extra-deps
. example, might have this:
extra-deps: - crypto-pubkey-openssh-0.2.7 - data-bword-0.1 - data-dword-0.3
this entry determines versions of packages should pulled hackage rather stackage.
when building application, might seem little redundant—you can specify version constraints in .cabal
file, too, why duplicate them in stack.yaml
file? however, when building library, distinction little more significant: .cabal
file expresses actual version constraints of library (if any), stack.yaml
file specifies precisely versions install when developing locally.
in sense, stack.yaml
file serves purpose similar gemfile.lock
or npm-shrinkwrap.json
files of other package managers, though responsibilities not clear-cut stack
(in part due historical reasons around how haskell’s package system works , of problems it’s had in past).
Comments
Post a Comment