Clean up block allocator, fixes #8609

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Update Note [Coercible instances]
Handle parens in predicates when converting to TH

This fixes Trac #8625
In ':show imports' take account of -XNoImplicitPrelude

Fixes Trac #8640
Use the GlobalRdrEnv when renaming the axuiliary bindings in 'deriving'

I'm not sure why were were using bindLocalNames before, but it triggers
an assert failure that checks that local names are Internal.  This
change makes things more uniform and straightforward.
Add alterOccEnv
Improve error message when using qualified names in GHCi

When you say
  ghci> :i Foo.x
GHCi tries to find module Foo and get 'x' from it.  But
if Foo doesn't exist we don't want to say:
  Attempting to use module ‛Foo’ which is not loaded

This is a bit confusing. Rather we just want to say that
Foo.x is not in scope.
Refactor the way shadowing in handled in GHCi

If you say
  ghci> import Foo( T )
  ghci> data T = MkT
  ghci> data T = XXX
then the second 'data T' should shadow the first.  But the qualified
Foo.T should still be available.  We really weren't handling this
correctly at all, resulting in Trac #8639 and #8628 among others

This patch:

* Add RdrName.extendGlobalRdrEnv, which does shadowing properly

* Change HscTypes.icExtendGblRdrEnv (was badly-named icPlusGblRdrEnv)
  to use the new function

* Change RnNames.extendGobalRdrEnvRn to use the new function

* Move gresFrom Avails into RdrName
* Better pprGlobalRdrEnv function in RdrName
Improve the equality-floating story (again), to fix Trac #8644

We float equalities out of implications whose 'givens' include equalities.
But it's a bit tricky knowing whether some givens do or do not include
equalities, as #8644 shows.  There the given has type 'c' (which might
have equalities), but we discover that 'c ~ ()', which definitely doesn't.

In short, we must look at the givens *after* normalisation, not before.
Moreover, something similar happens in approximateWC, where we need
to ask whether an implication has given equalities.

This patch does the job:

* Add a Boolean field inert_no_eqs to InertCans, which records
  whether we've added a non-constant equality

* Add a field ic_no_eqs to Implication, which records whether the
  ic_given binders include any equalities

* Get rid of Inst.hasEqualities altogether

On the way I did some un-forced refactoring

* Introduce the auxiliary function TcCanonical.flattenNestedFamApp

* Kill off FamHeadMap and PredMap in favour of
  the new FunEqMap and DictMap respectively
Fix #5209: Reset GHCi prompt in multiline mode

GHCi didn't reset the multiline prompt when an exception (in particular,
the UserInterrupt exception) occured. This commit uses `finally` to
reset the prompt in all cases.