Sunday, 27 September 2015

Hackage - releasing packages

You are ready to share your first Haskell package with the whole world. How to do it? It is not difficult at all and should take you no longer than 15 minutes. I took some notes whilte releasing my package: roller to help fellow Haskellers share their work with the community. Let’s dive right into it.

To begin with, run the following command in your package directory:

cabal sdist

This will try to prepare a hackage-acceptable package of your code. Depending on your package, first time you run it, cabal will complain a lot producing the something like this result:

Warning: Cannot run preprocessors. Run 'configure' command first.
Building source dist for roller-0.1.4...
Source tarball created: dist\roller-0.1.4.tar.gz

Cabal configure needed, let’s run it:

cabal configure

This will produce following results:

Warning: The package list for '' is 44.3 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Configuring roller-0.1.4...
cabal: At least the following dependencies are missing:
optparse-applicative >=0.11.0,
random >=1.0.1,
regex-applicative >=0.3

Cabal complains about dependencies being not up to date, let’s update cabal first:

cabal update

(this will take a while)

An now, let’s update those problematic packages beginning with:

cabal sandbox init

and followed by:

cabal install optparse-applicative
cabal install random
cabal install regex-applicative

Now, cabal configure should not complain anymore, let’s find out:

cabal configure

This should produce:

Resolving dependencies...
Configuring roller-0.1.4...

Looks well! We are now ready to prepare the package:

cabal sdist

Now cabal should produce this output:

Building source dist for roller-0.1.4...
Preprocessing library roller-0.1.4...
Preprocessing executable 'roller' for roller-0.1.4...
Source tarball created: dist\roller-0.1.4.tar.gz

At this stage your package is ready and can be uploaded to hackage, so please use this link when you're ready for that final step.

Good luck with your packages and happy hacking!