Fix #8631.

This patch allows turning on ImpredicativeTypes while type-checking
the code generated by GeneralizedNewtypeDeriving. It does this
by adding a field ib_extensions to InstBindings, informing the
type-checker what extensions should be enabled while type-checking
the instance.
Issue an error for pattern synonyms defined in a local scope (#8757)

This also fixes the internal crash when using pattern synonyms
in GHCi (#8749)
Add test suite for #8757
double-negate test for Stage1Only to fix `make clean`

This was causing `utils/ghctags/dist-install` to not get removed
on `make clean` as `Stage1Only` was unset. So testing for `!= YES` is
less fragile than testing for `== NO` in this case.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Let `make distclean` remove `/{ch01,ch02,index}.html`

These files are created during `./configure` and therefore
by convention are expected to be removed by `make distclean`.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Move test case for #8631 to the correct directory.
Fix #8758 by assuming RankNTypes when checking GND code.
Test #6147, which was fixed with the roles commit.
Test #7481, which had already been fixed.
Fix #8759 by not panicking with TH and patsyns.

We should still have pattern synonyms in TH, though.
Apply changes relative to TH.Pred becoming a TH.Type's synonym (issue #7021)

Signed-off-by: Richard Eisenberg <eir@cis.upenn.edu>
Fix tests due to issue #7021

Signed-off-by: Richard Eisenberg <eir@cis.upenn.edu>
Make Pred a type synonym of Type (issue #7021)

In order to make any type as a Predicate in Template Haskell, as allowed by ConstraintKinds

Signed-off-by: Richard Eisenberg <eir@cis.upenn.edu>
Change type of equalityT to be more parallel with others.
Add documentation to why Pred has become a type synonym.
Refactor previous commit on fixing #7021.
Implement CallArity analysis

This analysis finds out if a let-bound expression with lower manifest
arity than type arity is always called with more arguments, as in that
case eta-expansion is allowed and often viable. The analysis is very
much tailored towards the code generated when foldl is implemented via
foldr; without this analysis doing so would be a very bad idea!

There are other ways to improve foldr/builder-fusion to cope with foldl,
if any of these are implemented then this step can probably be moved to
-O2 to save some compilation times. The current impact of adding this
phase is just below +2% (measured running GHC's "make").
Implement foldl with foldr

together with the call arity analysis and the following patch (about inlining
maximum), we get nice benefits from fusing foldl and foldl' with good
producers:

                Min          -0.1%    -74.5%     -6.8%     -8.3%    -50.0%
                Max          +0.2%      0.0%    +38.5%    +38.5%      0.0%
     Geometric Mean          -0.0%     -4.1%     +7.7%     +7.7%     -0.8%

Because this depends on a compiler optimisation, we have to watch out for cases
where this is not an improvements, and whether they occur in the wild.
Inline maximum/minium a bit more aggresively

in order to allow fusion of the foldr in the foldl in the foldl' therein.
Add a unit test for CallArity

This also sets precedence for testing internals of GHC directly, i.e.
without trying to come up with Haskell code and observable effects.
Let's see how that goes.

I put all the tests (including those where the analysis could do better)
in one file because starting the GHC API is quite slow.