Showing posts with label Hackage. Show all posts
Showing posts with label Hackage. Show all posts

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 'hackage.haskell.org' 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!

Saturday, 8 August 2015

Haskell - updating GHC and leaving the Haskell platform

This was my first GHC update and since it made me spend a couple of minutes scratching my head and deciding on how to approach this, let me share my experience in the form of a Q&A for the sake of brevity.

Q: When to update my GHC?
A: Whenever you think you need a newer version. A good example would be: new hackage packages stop working (give installation errors) and require new versions of core packages like base.

Q: I am using Haskell Platform, how do I update GHC?
A: Simply download the latest GHC and make sure your PATH points at the updated version (and not at Haskell Platform). Fear not. Stepping away from, otherwise very useful, Haskel Platform will give you much more freedom and control over the packages you're using.

Q: I have the latest version of GHC installed. How do I update my PATH?
A: If you've been using the Haskell Platform until now, your PATH should point at two things located in the Haskell Platform:
  • GHC
    C:\Program Files (x86)\Haskell Platform\2013.2.0.0\bin
  • mingw
    C:\Program Files (x86)\Haskell Platform\2013.2.0.0\mingw\bin
To leave the Haskell Platform's GHC and start using the new one, simply update the PATH accordingly (depending on where you installed the latest GHC):
  • GHC
    C:\Users\Piotr\Documents\Haskell\ghc-7.10.2\bin
  • mingw
    C:\Users\Piotr\Documents\Haskell\ghc-7.10.2\mingw\bin

This should get you access to the latest Haskell packages. Please share if your experience was different or if you follow a simpler process.

Happy hacking!