Various patches for GHC 7.8 compatibility