Delete packages recursively

15 July 2012 | Tags: haskell, bash

Maintaining GHC’s package database in consistent state requires some effort. There are tools like cabal-dev which allows to use per-project package database, but it convenient to use global database when you write small throwaway programs.

In fact it’s not very difficult to avoid cabal hell if you don’t have too many dependencies. Recipe is to avoid having two different version of the same package at same time. So if new version of package is installed old version should be deleted or rather unregistered.

However ghc-pkg will refuse to unregister packages if other packages depend on it so they are have to removed too. In the end I wrote simple bash script which removes package and all packages which depends on it:

comments powered by Disqus