#! /bin/bash

case "$1" in
   "" | "-h" | "--help")

      echo "Script for 'clean' removal of globally-installed GHC packages"
      echo "usage: $(basename $0) GHC-PACKAGE"
      echo
      echo "Find packages to remove by looking at output of \`ghc-pkg list\`"
      echo "or looking in /usr/local/lib, /usr/local/share and /usr/local/share/doc"
      echo
      echo "Also, be aware that some packages may have installed binaries in"
      echo "/usr/local/bin that will need to be hand-removed by you."
      echo
      echo "This script is intended be run as root"

      exit 1
      ;;
esac

ghc-pkg unregister $1 || exit 1
rm -rfv /usr/local/lib/$1
rm -rfv /usr/local/share/$1
rm -rfv /usr/local/share/doc/$1
