Phil
Phil

Reputation: 50486

Are all Haskell packages compatible with each other?

I see a lot of Haskell packages listed here:

http://hackage.haskell.org/packages/archive/pkg-list.html#cat:database

Are all these packages compatible with each other? If I bring in say 10 packages in order to make a program, are they all going to be OK. What if I brought in all packages listed on the page?

Imagine if you are in Java, in Java if you bring in say 10 jar's from around the web, there maybe dependancies between the JAR's that mean that one JAR requires a version other another JAR that is not a good version for a different JAR. For example, one JAR may need Hibernate version 3.0.0 and another needs Hibernate 2.0.0. So I cannot use these two jars because they don't use a common equal Hibernate version.

Upvotes: 3

Views: 197

Answers (2)

ertes
ertes

Reputation: 76

You have the same problem in Haskell, although as pointed out Cabal is exceptionally smart at resolving dependencies the best way.

Cabal will happily install multiple versions of a package, but that can lead to a subtle error when creating your own: Your package might indirectly depend on multiple versions (Cabal warns you about that when doing configure), which holds a subtle surprise: When you refer indirectly (e.g. through type inference) to a type, say State, it might be resolved to mtl 1.x at one place and mtl 2.x in another, and the two can't be unified. This becomes a problem when you use two packages and want to combine them in your code. It's seldomly a problem, but it is noteworthy.

Note also that Haskell packages usually depend on a version range instead of a single version. This means that Cabal builds the intersection of accepted versions and uses the newest in it.

Upvotes: 6

Philip JF
Philip JF

Reputation: 28539

No, but

  1. Packages all declare dependencies including version ranges
  2. If you use cabal-install it will try its hardest to keep everything consistent. It does a pretty good job most of the time. I have been unable to get software to build because of dependencies to old versions, but I have never seen a situation where cabal got fooled. If cabal installs the packages for you, it is going to work; and cabal will probably install the packages for you

Upvotes: 6

Related Questions