Fix #9047

Signed-off-by: Austin Seipp <austin@well-typed.com>
(cherry picked from commit b84748121e777d098198f2583d11a9424c1b1650)
Fix up b84748121e777d

I forgot to amend this to my last commit.

Signed-off-by: Austin Seipp <austin@well-typed.com>
(cherry picked from commit 95f95ed6281adf9616d87b97470d68fb54c0b7f3)
Fix over-zealous unused-import warning

See Note [Un-warnable import decls] in RnNames.

Fixes Trac #9061.

(cherry picked from commit 9f3e39d5f8686e511ffca406a6e056dec4095e53)
Second go at fixing #9061

My first attempt introduce a bug in -fprint-minimal-imports, but
fortunately a regression test caught it.

(cherry picked from commit 5b73dc5fda1941d51827ea72614782c10a355a3d)
Fix a serious, but rare, strictness analyser bug (Trac #9128)

In a special case for trivial RHSs (see DmdAnal.unpackTrivial),
I'd forgotten to include a demand for the RHS itself.
See Note [Remember to demand the function itself].

Thanks to David Terei for guiding me to the bug,
at PLDI in Edinburgh.

(cherry picked from commit 7d9feb264a4fc3c15d1e5f88f2e7a04202ed9743)
In splitHsFunType, take account of prefix (->)

This fixes Trac #9096

(cherry picked from commit 770e16fceee60db0c2f79e3b77f6fc619bc1d864)
Make the unifier a fixpoint even for the free kind vars of a tyvar

The (pure) unifier tcUnifyTys returns an idempotent substitution.
But previously the kinds of type variables free in the range of
the subst could have un-substituted kind variables.

This patch fixes that, fixing Trac #9106.

See Note [Finding the substitution fixpoint] in Unify

(cherry picked from commit d8d97113c24e7216be36c9cdfc58e91f26528f06)
Store IfExtNames for PatSyn matchers and wrappers in interface file.
This way, the Ids for the matchers/wrappers are reused by importing
modules, and thus unfoldings are kept.

Also updates haddock submodule to accomodate tweaks in PatSyn representation

Conflicts:
	compiler/typecheck/TcPatSyn.lhs
	utils/haddock

(cherry picked from commit e0fbf1e3bc062b7ce3f1c515a135fd9f3d49e2ee)
Fix egregious instantiation bug in matchOneConLike (fixing Trac #9023)

We simply weren't giving anything like the right instantiating types
to patSynInstArgTys in matchOneConLike.

To get these instantiating types would have involved matching the
result type of the pattern synonym with the pattern type, which is
tiresome.  So instead I changed ConPatOut so that instead of recording
the type of the *whole* pattern (in old field pat_ty), it not records
the *instantiating* types (in new field pat_arg_tys).  Then we canuse
TcHsSyn.conLikeResTy to get the pattern type when needed.

There are lots of knock-on incidental effects, but they mostly made
the code simpler, so I'm happy.

Conflicts:
	compiler/typecheck/TcPat.lhs

(cherry picked from commit 1fc4f6b973a4fb14b2b15143b2774ec597b4da0f)
Test Trac #9023

(cherry picked from commit 1b45c6b4959762209dbcabf3290feb8673a60b23)
Make the matcher and wrapper Ids in PatSyn into LocalIds, not GlobalIds

This was a serious bug, exposed by Trac #9175.  The matcher and wrapper
must be LocalIds, like record selectors and dictionary functions, for
the reasons now documented in Note [Exported LocalIds] in Id.lhs

In fixing this I found
 - PatSyn should have an Id inside it (apart from the wrapper and matcher)
   It should be a Name.  Hence psId --> psName, with knock-on consequences

 - Tidying of PatSyns in TidyPgm was wrong

 - The keep-alive set in Desugar.deSugar (now) doesn't need pattern synonyms
   in it

I also cleaned up the interface to PatSyn a little, so there's a tiny knock-on
effect in Haddock; hence the haddock submodule update.

It's very hard to make a test for this bug, so I haven't.

Conflicts:
	compiler/typecheck/TcRnTypes.lhs
	utils/haddock