Make mkQualPackage more robust when package key is bad.

Authored by ezyang.

Description

Make mkQualPackage more robust when package key is bad.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: bgamari, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1060

GHC Trac Issues: Trac #10624