Add comments & notes explaining the typing of pattern synonym definitions

(cherry picked from commit d2c4f9758ca735f294033401efef225699c292f8)
Split off pattern synonym definition checking from pattern inversion

(cherry picked from commit c269b7e85524f4a8be3cd0f00e107207ab9197af)
Remove unused variable binding to fix validate

(cherry picked from commit b7f51d60093ea13d0854bd7e1d4ecf58d12628a1)
Add source file for new test that checks that as-patterns are rejected
in pattern synonym definitions

(cherry picked from commit dd3a6d270f827a59f7a33f32facc506cb35af1fa)
Expected output of as-pattern test

(cherry picked from commit 7233638ba6e82179cc4bd1b981eff5292b18e118)
Instead of tracking Origin in LHsBindsLR, track it in MatchGroup

(cherry picked from commit eeaea2df3fa585db503034f419c6e4331a4d8a84)
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

(cherry picked from commit ac2796e6ddbd54c5762c53e2fcf29f20ea162fd5)

Conflicts:
	utils/haddock
Improve tracing slightly

(cherry picked from commit cbe59d89f2f1cc41147fabb4a4c58126152bef7f)
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.

(cherry picked from commit 0a55a3cada2fea37586b1a270c1511ed9957dbd4)
Print for-alls more often (Trac #9018)

We now display the foralls of a type if any of the type variables
is polykinded.  This put kind polymorphism "in your face" a bit more
often, but eliminates a lot of head scratching.

The user manual reflects the new behaviour.

(cherry picked from commit 2f3ea95285d0cccc2a999e7572d8fb78dc2ea441)

Conflicts:
	testsuite/tests/ghci/scripts/ghci059.stdout
	testsuite/tests/polykinds/T7438.stderr
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.

(cherry picked from commit 7ac600d5fcd74db1f991555de6e415030970d5f3)

Conflicts:
	utils/haddock
Test Trac #9023

(cherry picked from commit 616f54bdc28ad699f903248a5fb18dc0e5b52a52)
Add fake entries into the global kind environment for pattern synonyms.

This is needed to give meaningful error messages (instead of internal
panics) when a program tries to lift a pattern synonym into a kind.
(fixes T9161)

(cherry picked from commit aa3166f42361cb605e046f4a063be3f9e1f48015)
Add Note [Placeholder PatSyn kinds] in TcBinds

This is just documentation for the fix to Trac #9161

(cherry picked from commit 0757831eaca96c8ebfd99fc51427560d3568cffa)
Fix T7438 output

Signed-off-by: Austin Seipp <austin@well-typed.com>