Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which versions of packages can my Haskell package depend upon?

Tags:

haskell

cabal

I'm nearly ready to upload my first package to Hackage!

I have this in my hstest.cabal:

Executable hstest
        Main-Is:        hstest.hs
        Build-Depends:  base, mtl, directory, ghc, ghc-paths, random, QuickCheck

I understand that it's bad form to simply list which packages my package depends upon; instead I should state which versions of these packages are needed.

The versions I have installed are

  • base = 4.1.0.0
  • mtl = 1.1.0.2
  • directory = 1.0.0.3
  • ghc = 6.10.3
  • ghc-paths = 0.1.0.5
  • random = 1.0.0.1
  • QuickCheck = 1.2.0.0

Is there an easy way of finding out what the earliest acceptable versions of each of these packages my package actually needs? (i.e. without installing lots of obsolete versions and testing them one by one?)

Which future versions of these packages can I assume my package can depend on?

like image 706
dave4420 Avatar asked May 15 '10 22:05

dave4420


People also ask

What is a Haskell package?

A package is a library of Haskell modules known to the compiler. GHC comes with several packages: see the accompanying library documentation. More packages to install can be obtained from HackageDB.

Where are Haskell packages stored?

By default stack installs packages to ~/. cabal and ~/. ghc in your home directory.

How do I import packages into Haskell?

The syntax for importing modules in a Haskell script is import <module name>. This must be done before defining any functions, so imports are usually done at the top of the file. One script can, of course, import several modules. Just put each import statement into a separate line.


1 Answers

Is there an easy way of finding out what the earliest acceptable versions of each of these packages my package actually needs

No, there's no tool for that.

Which future versions of these packages can I assume my package can depend on?

The safest way is to follow the package versioning policy, which says to only rely on API-extending versions of packages. That is versions of the form: A.B.*. As the policy states:

To minimize breakage when new package versions are released, you can use dependencies that are insensitive to minor version changes (e.g. foo >= 1.2.1 && < 1.3).

So you would do something like:

 QuickCheck >= 1.2 && < 1.3

Now, testing may reveal lower or higher bounds on what features you actually use.

like image 115
Don Stewart Avatar answered Oct 06 '22 14:10

Don Stewart