Best practices for distributing and updating the Haskell application

TL; DR

About a week ago, I released the 0.1.0.0 package for my first non-trivial Haskell project. I want the executable to be easy to install and upgrade, even for non-Haskellers. In README, I suggested installing with cabal install . This is mistake?

Context

I heard about "Cabal hell", but did not understand how difficult it would be for users to update a globally installed copy of the package, even if I conservatively did not change any version dependencies in the .cabal file. In the end, I went down a deep rabbit hole, trying to upgrade from 0.1.0.0 to 0.2.0.0. He warned me about dependency breaking, I tried various spells to force update or reset my local state, and braked the system so hard that I had to reinstall the ghc and cabal-install Brew packages (this is on macOS) to return everything to state in which I could install and run again.

Alternative:

  • stack install : I already used Stack to manage the local development environment, but it seems to work just fine for self-installation if you have Stack installed. (You just need to configure your $PATH accordingly.)
  • Distributing the finished binary: it would be nice and easy for end users, but at least on OS X, I would have to worry about signing the code and I didn't even have an ID for that anymore.

So, in my README right now, I mention both stack install and cabal install . But what is the best practice of 2016?

+6
source share
1 answer

Looking at the .cabal file , I see that you have no restrictions on your dependencies. You really should have at least lower bounds and preferably both lower and upper bounds.

As @Emanuel Borsboom mentioned, you can have a stack fill in version restrictions for you when you load a package in Hackage with:

 stack upload --pvp-bounds=both 

In fact, for applications, I suggest including the cabal.config file generated by cabal freeze in the package:

 cabal freeze mv cabal.config cabal.config-sample 

When I ran into the problem of creating legacy applications from Hackage, I often wanted authors to include this information. You can get the cabal.config file for a specific snapshot:

 https://www.stackage.org/{RESOLVER}/cabal.config 

And in your stack.yaml file stack.yaml I would use the standard version of LTS, not nightly- . Presumably, they will never be deleted. On the other hand, you will help your users by reducing the number of snapshots of the directories they need to support.

+3
source

All Articles