Revert "Fix obscure problem with using the system linker (#8935)"

This reverts commit 72bd832eb87975c504654a65f9c88daaa478f677.

Signed-off-by: Austin Seipp <austin@well-typed.com>
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)
Revert "Test Trac #9023"

This reverts commit f6e494231b2ad00fa073fc6623a876ffe40e900e.

Signed-off-by: Austin Seipp <austin@well-typed.com>
Revert "Fix egregious instantiation bug in matchOneConLike (fixing Trac #9023)"

This reverts commit d1c2a2784ffc120bdd8f1fccc9cc61933c0cc5d0.

Signed-off-by: Austin Seipp <austin@well-typed.com>
Revert "Store IfExtNames for PatSyn matchers and wrappers in interface file."

This reverts commit e40bd13b5b509b76d61ae66247ded145d4af93ea.

Signed-off-by: Austin Seipp <austin@well-typed.com>
Make splitStrProdDmd (and similarly Use) more robust

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

(cherry picked from commit b60df0fa017eac8800a3848650dbad09acb6f1b8)
Line up kind and type variables correctly when desugaring TH brackets

This bug was causing Trac #9199

(cherry picked from commit 571f0adccda687098d59f63524357f4ac98e72fb)

Conflicts:
	testsuite/tests/th/all.T
Fix Trac #9071, an egregious bug in TcDeriv.inferConstraints

The constraints for Functor don't line up 1-1 with the arguments
(they are fetched out from sub-terms of the type), but the surrounding
code was mistakenly assuming they were in 1-1 association.

(cherry picked from commit 13a330e87cf459311a7f164e1e57baf877741da6)

Conflicts:
	compiler/typecheck/TcDeriv.lhs
Adding missing test files for #9071

(cherry picked from commit 59b4e6d0ba504b33cc7064d489b8ec485a7703f4)
Fix elemLocalRdrEnv (Trac #9160)

This was pretty obscure.  elemLocalRdrEnv was utterly wrong (replied
False when it should reply True) when given an Exact Name. That
doesn't happen often, but it does happen in the result of a TH splice.
The result was that an associated type didn't get a type variable that
lined up with its parent class (elemLocalRdrEnv is used in
RnTypes.bindHsTyVars), and that messed up the singletons package.

I've made a completely different test case to show up the bug:
indexed_types/should_fail/T9160

I also refactored RdrName.LocalRdrEnv to be a record with named
fields, which makes the code more robust and easy to understand.

(cherry picked from commit b637585dcbfc1ba53aa49bcb9b730cd08fea4b59)

Conflicts:
	testsuite/tests/indexed-types/should_fail/all.T