ghc.git
2 years agoAdd support for producing position-independent executables
Ben Gamari [Tue, 22 Aug 2017 15:41:47 +0000 (11:41 -0400)] 
Add support for producing position-independent executables

Previously due to #12759 we disabled PIE support entirely. However, this
breaks the user's ability to produce PIEs. Add an explicit flag, -fPIE,
allowing the user to build PIEs.

Test Plan: Validate

Reviewers: rwbarton, austin, simonmar

Subscribers: trommler, simonmar, trofi, jrtc27, thomie

GHC Trac Issues: #12759, #13702

Differential Revision: https://phabricator.haskell.org/D3589

2 years agoDynFlags: Add inverse of -dno-debug-output
Ben Gamari [Tue, 22 Aug 2017 15:40:51 +0000 (11:40 -0400)] 
DynFlags: Add inverse of -dno-debug-output

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #14142

Differential Revision: https://phabricator.haskell.org/D3876

2 years agoFixed a typo in template-haskell documentation
Benjamin Hodgson [Tue, 22 Aug 2017 12:11:43 +0000 (13:11 +0100)] 
Fixed a typo in template-haskell documentation

The documentation for `Type`'s `ForallT` constructor had a typo (pun not
intended). `ctxt` is separated from `type` in the surface syntax by a fat
arrow (`=>`), not a thin arrow (`->`).

2 years agofix typo (expreesions -> expressions)
Chris Martin [Sat, 19 Aug 2017 22:33:11 +0000 (18:33 -0400)] 
fix typo (expreesions -> expressions)

2 years agoBump haddock submodule
Ben Gamari [Tue, 22 Aug 2017 12:47:33 +0000 (08:47 -0400)] 
Bump haddock submodule

2 years agoMake law for Foldable.length explicit
Alain O'Dea [Tue, 22 Aug 2017 12:47:07 +0000 (08:47 -0400)] 
Make law for Foldable.length explicit

Test Plan: Documentation only. Not necessary.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3878

2 years agoStgLint: Allow join point bindings of unlifted type
Ben Gamari [Tue, 22 Aug 2017 12:44:47 +0000 (08:44 -0400)] 
StgLint: Allow join point bindings of unlifted type

As described in `Note [CoreSyn let/app invariant]` this is allowed.

Fixes #14117.

Test Plan: Build GHC with BuildFlavour=devel2 with -dstg-lint

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: #14117

Differential Revision: https://phabricator.haskell.org/D3857

2 years agoFix incorrect retypecheck loop in -j (#14075)
Edward Z. Yang [Tue, 22 Aug 2017 12:44:25 +0000 (08:44 -0400)] 
Fix incorrect retypecheck loop in -j (#14075)

The parallel codepath was incorrectly retypechecking the
hs-boot ModIface prior to typechecking the hs file,
which was inconsistent with the non-parallel case.  The
non-parallel case gets it right: you don't want to retypecheck
the hs-boot file itself (forwarding its declarations to hs)
because you need it to be consistently knot-tied with itself
when you compare the interfaces.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, simonpj, austin

Reviewed By: bgamari

Subscribers: duog, rwbarton, thomie

GHC Trac Issues: #14075

Differential Revision: https://phabricator.haskell.org/D3815

2 years agoMove validate cleaning from distclean to clean
Douglas Wilson [Tue, 22 Aug 2017 12:44:00 +0000 (08:44 -0400)] 
Move validate cleaning from distclean to clean

This bit me today: I was in validate mode without realising it and "make
clean" didn't help. I don't see a reason for this to be in distclean, as
it isn't generated by ./configure, which is the rule described in
https://ghc.haskell.org/trac/ghc/wiki/Building/Using

Test Plan: Is there a reason for this to be in distclean?

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3814

2 years agoMake the Read instance for Proxy (and friends) ignore precedence
Ryan Scott [Tue, 22 Aug 2017 13:29:07 +0000 (09:29 -0400)] 
Make the Read instance for Proxy (and friends) ignore precedence

Summary:
The `Read` instance for `Proxy`, as well as a handful of other data
types in `base` which only have a single constructor, are doing something
skeevy: they're requiring that they be surrounded by parentheses if the parsing
precedence is sufficiently high. This means that `"Thing (Proxy)"` would parse,
but not `"Thing Proxy"`. But the latter really ought to parse, since there's no
need to surround a single constructor with parentheses. Indeed, that's the
output of `show (Thing Proxy)`, so the current `Read` instance for `Proxy`
violates `read . show = id`.

The simple solution is to change `readParen (d > 10)` to `readParen False` in
the `Read` instance for `Proxy`. But given that a derived `Read` instance would
essentially accomplish the same thing, but with even fewer characters, I've
opted to just replace the hand-rolled `Read` instance with a derived one.

Test Plan: make test TEST=T12874

Reviewers: ekmett, austin, hvr, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12874

Differential Revision: https://phabricator.haskell.org/D3871

2 years agoRevise function arity mismatch errors involving TypeApplications
Ryan Scott [Tue, 22 Aug 2017 13:29:01 +0000 (09:29 -0400)] 
Revise function arity mismatch errors involving TypeApplications

Summary:
Currently, whenever you apply a function to too many arguments and
some of those arguments happen to be visible type applications, the error
message that GHC gives is rather confusing. Consider the message you receive
when typechecking `id @Int 1 2`:

```
The function `id` is applied to three arguments,
but its type `Int -> Int` has only one
```

This is baffling, since the two lines treat the visible type argument `@Int`
differently. The top line ("applied to three arguments") includes `@Int`,
whereas the bottom line ("has only one") excludes `@Int` from consideration.

There are multiple ways one could fix this, which I explain in an addendum to
`Note [Herald for matchExpectedFunTys]`. The approach adopted here is to change
the herald of this error message to include visible type arguments, and to
avoid counting them in the "applied to n arguments" part of the error. The end
result is that the new error message for `id @Int 1 2` is now:

```
The expression `id @Int` is applied to two arguments,
but its type `Int -> Int` has only one
```

Test Plan: make test TEST=T13902

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie

GHC Trac Issues: #13902

Differential Revision: https://phabricator.haskell.org/D3868

2 years agoFix #13885 by freshening reified GADT constructors' universal tyvars
Ryan Scott [Tue, 22 Aug 2017 13:28:56 +0000 (09:28 -0400)] 
Fix #13885 by freshening reified GADT constructors' universal tyvars

Summary:
When reifying GADTs with Template Haskell, the universally quantified
type variables were being reused across both the data type head and the
constructors' type signatures. This had the annoying effect of causing sets
of differently scoped variables to have the same uniques. To avoid this, we
now freshen the universal tyvars before reifying the constructors so as to
ensure they have distinct uniques.

Test Plan: make test TEST=T13885

Reviewers: goldfire, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: #13885

Differential Revision: https://phabricator.haskell.org/D3867

2 years agoFix #14114 by checking for duplicate vars on pattern synonym RHSes
Ryan Scott [Tue, 22 Aug 2017 13:28:49 +0000 (09:28 -0400)] 
Fix #14114 by checking for duplicate vars on pattern synonym RHSes

Summary:
Because we weren't checking for duplicate variables on the right-hand
sides of pattern synonyms, bogus definitions like this one passed the renamer:

```lang=haskell
pattern Foo a <- (a,a)
```

Luckily, the fix is simple.

Test Plan: make test TEST=T14114

Reviewers: mpickering, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #14114

Differential Revision: https://phabricator.haskell.org/D3866

2 years agoFix #14125 by normalizing data family instances more aggressively
Ryan Scott [Tue, 22 Aug 2017 13:28:43 +0000 (09:28 -0400)] 
Fix #14125 by normalizing data family instances more aggressively

Summary:
Commit 3540d1e1a23926ce0a8a6ae83a36f5f6b2497ccf inadvertently broke
the ability for newtype instances to be used as marshallable types in FFI
declarations. The reason is a bit silly: an extra check was added for type
synonyms with no type families on the RHS in `normalise_tc_app`, but this check
would only skip over type families, not //data// families, since the predicate
being used was `not . isTypeFamilyCon`.

The fix is simple: just use `not . isFamilyCon` instead so that data families
are also skipped by this check.

Test Plan: make test TEST=T14125

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: #14125

Differential Revision: https://phabricator.haskell.org/D3865

2 years agoFix loading of dlls on 32bit windows
Sergey Vinokurov [Sun, 20 Aug 2017 21:40:08 +0000 (00:40 +0300)] 
Fix loading of dlls on 32bit windows

The point of fix is to handle case when loaded dll loads no
other dlls, i.e. it's import table is empty.

GHC Trac Issues: #14081

2 years agoRevert "Add strict variant of iterate"
Ben Gamari [Sat, 19 Aug 2017 11:44:13 +0000 (07:44 -0400)] 
Revert "Add strict variant of iterate"

This was not ready to commit.
This reverts commit 8e5b6ec6566da57d15b0810a07902d9eac85cb79.

2 years agoCorrect incorrect free in PE linker
Tamar Christina [Sat, 19 Aug 2017 07:31:34 +0000 (08:31 +0100)] 
Correct incorrect free in PE linker

Summary:
The big-obj support (D3523) had introduced an early free on
the info structure. Because the pointer is not NULL'd
and the default of all the utility functions was to the
standard object format, it all kept working.

The one big-obj test that exists was subjected to a timing issue.
usually the test ran quickly enough that the allocator hasn't
had time to reclaim the memory yet, so it still passed.

This corrects it. Also as it so happens, static LLVM libraries
from mingw-w64 are compiled using big-obj.

Test Plan: ./validate

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13815, #13093

Differential Revision: https://phabricator.haskell.org/D3862

2 years agoAdd strict variant of iterate
Ben Gamari [Fri, 18 Aug 2017 14:24:58 +0000 (10:24 -0400)] 
Add strict variant of iterate

This closes the nearly-eight-year-old #3474.

2 years agousers_guide: Convert mkUserGuidePart generation to a Sphinx extension
Patrick Dougherty [Fri, 18 Aug 2017 13:20:07 +0000 (09:20 -0400)] 
users_guide: Convert mkUserGuidePart generation to a Sphinx extension

This removes all dependencies the users guide had on `mkUserGuidePart`.
The generation of the flag reference table and the various pieces of the
man page is now entirely contained within the Spinx extension
`flags.py`. You can see the man page generation on the orphan page
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghc.html

The extension works by collecting all of the meta-data attached to the
`ghc-flag` directives and then formatting and displaying it at
`flag-print` directives. There is a single printing directive that can
be customized with two options, what format to display (table, list, or
block of flags) and an optional category to limit the output to
(verbosity, warnings, codegen, etc.).

New display formats can be added by creating a function
`generate_flag_xxx` (where `xxx` is a description of the format) which
takes a list of flags and a category and returns a new `xxx`. Then just
add a reference in the dispatch table `handlers`. That display can now
be run by passing `:type: xxx` to the `flag-print` directive.

`flags.py` contains two maps of settings that can be adjusted. The first
is a canonical list of flag categories, and the second sets default
categories for files.

The only functionality that Sphinx could not replace was the
`what_glasgow_exts_does.gen.rst` file. `mkUserGuidePart` actually just
reads the list of flags from `compiler/main/DynFlags.hs` which Sphinx
cannot do. As the flag is deprecated, I added the list as a static file
which can be updated manually.

Additionally, this patch updates every single documented flag with the
data from `mkUserGuidePart` to generate the reference table.

Fixes #11654 and, incidentally, #12155.

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #11654, #12155

Differential Revision: https://phabricator.haskell.org/D3839

2 years agoEnable -Wcpp-undef for GHC and runtime system
Ben Gamari [Fri, 18 Aug 2017 12:37:14 +0000 (08:37 -0400)] 
Enable -Wcpp-undef for GHC and runtime system

This gets us much of the benefit of enabling it globally, which avoiding
(at least for now) the pain of making the core libraries build as well.
See #13636.

Test Plan: Validate

Reviewers: erikd, austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13636

Differential Revision: https://phabricator.haskell.org/D3517

2 years agoDoctests for Data.Tuple
David Luposchainsky [Fri, 11 Aug 2017 08:37:55 +0000 (10:37 +0200)] 
Doctests for Data.Tuple

2 years agoTest Trac #14110
Simon Peyton Jones [Fri, 18 Aug 2017 13:50:57 +0000 (14:50 +0100)] 
Test Trac #14110

2 years agoComments only
Simon Peyton Jones [Fri, 18 Aug 2017 08:02:13 +0000 (09:02 +0100)] 
Comments only

2 years agoTracing in OccAnal (commented out)
Simon Peyton Jones [Wed, 2 Aug 2017 14:56:32 +0000 (15:56 +0100)] 
Tracing in OccAnal (commented out)

2 years agoRestrict Lint's complaints about recursive INLINEs somewhat
Simon Peyton Jones [Wed, 2 Aug 2017 08:48:58 +0000 (09:48 +0100)] 
Restrict Lint's complaints about recursive INLINEs somewhat

This patch makes the Lint warning about recursive functions with an
INLINE only apply if there is a stable unfolding.  If not (e.g. some
other pass took it out) we don't need to worry.  Not a big deal.

2 years agoComments about GlobalRdrEnv shadowing
Simon Peyton Jones [Tue, 1 Aug 2017 11:07:34 +0000 (12:07 +0100)] 
Comments about GlobalRdrEnv shadowing

Provoked by Trac #14052

2 years agoCSE.cseOneExpr: Set InScopeSet correctly
Joachim Breitner [Fri, 18 Aug 2017 12:14:19 +0000 (14:14 +0200)] 
CSE.cseOneExpr: Set InScopeSet correctly

because this is a convenience function for API users, calculate the
in-scope set from `exprFreeVars`.

2 years agotestsuite: Add test for #13916
Ben Gamari [Thu, 17 Aug 2017 14:32:58 +0000 (10:32 -0400)] 
testsuite: Add test for #13916

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3764

2 years agoMake function intToSBigNat# preserve sign (fixes #14085)
Olivier Chéron [Thu, 17 Aug 2017 14:32:28 +0000 (10:32 -0400)] 
Make function intToSBigNat# preserve sign (fixes #14085)

Impacts only functions gcdExtInteger, powModInteger and
recipModInteger which gave invalid results on negative S# inputs.

Also fixes gcdExtInteger assertion when first argument is negative.

Test Plan: Updated test case integerGmpInternals

Reviewers: austin, hvr, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14085

Differential Revision: https://phabricator.haskell.org/D3826

2 years agoRemove unneeded reqlibs for mtl and parsec in the GHC testsuite
Ryan Scott [Thu, 17 Aug 2017 14:31:26 +0000 (10:31 -0400)] 
Remove unneeded reqlibs for mtl and parsec in the GHC testsuite

Now that `mtl` and `parsec` are boot libraries, there's no need to
qualify various tests in the testsuite with `reqlib('mtl')` or
`reqlib('parsec')`.

Test Plan: make test TEST="T4809 tcfail126 T4355 tc232 tc223 tc220
tc217 tc183 T5303 DoParamM qq005 qq006 galois_raytrace T1074 mod133
T3787 T4316 prog011 drvfail006 drvfail008"

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3855

2 years agoFix #13399 by documenting higher-rank kinds.
Richard Eisenberg [Thu, 17 Aug 2017 14:29:57 +0000 (10:29 -0400)] 
Fix #13399 by documenting higher-rank kinds.

Test Plan: Read it.

Reviewers: simonpj, RyanGlScott, austin, bgamari

Reviewed By: RyanGlScott

Subscribers: rwbarton, thomie

GHC Trac Issues: #13399

Differential Revision: https://phabricator.haskell.org/D3860

2 years agouser-guide: add `:type +d` and `:type +v` in release highlight
Takenobu Tani [Thu, 17 Aug 2017 14:29:43 +0000 (10:29 -0400)] 
user-guide: add `:type +d` and `:type +v` in release highlight

Add new ghci command to release highlight and fix link anchor.

This commit is for ghc-8.2 branch.

Test Plan: build

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #11975

Differential Revision: https://phabricator.haskell.org/D3850

2 years agorts: Enable USDT probes object on Linux
Ben Gamari [Thu, 17 Aug 2017 14:28:39 +0000 (10:28 -0400)] 
rts: Enable USDT probes object on Linux

Summary: The dtrace utility shipped with Debian expects this.

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3829

2 years agouser-guide: fix examples of ghci commands
Takenobu Tani [Thu, 17 Aug 2017 14:28:01 +0000 (10:28 -0400)] 
user-guide: fix examples of ghci commands

Fix examples of ghci commands:
  * correct typos
  * add top-level binding without let statement
  * modify Time.getClockTime to Data.Time.getZonedTime
  * modify Directory.setCurrentDirectory
  * modify ghc version number

Test Plan: build

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3852

2 years agoFix index entries in "separate compilation" section
Chris Martin [Tue, 15 Aug 2017 01:15:22 +0000 (21:15 -0400)] 
Fix index entries in "separate compilation" section

This appears to have been a mistake from the translation of the manual into RST
format by 4fd6207ec6.

2 years agoAdd missing initial version for extension doc.
superfunc [Mon, 14 Aug 2017 00:20:47 +0000 (20:20 -0400)] 
Add missing initial version for extension doc.

2 years agoLoads of doc(test)s
David Luposchainsky [Fri, 11 Aug 2017 12:25:57 +0000 (14:25 +0200)] 
Loads of doc(test)s

2 years agoConvert documentation examples to doctests for ReadP module
David Luposchainsky [Fri, 11 Aug 2017 11:46:13 +0000 (13:46 +0200)] 
Convert documentation examples to doctests for ReadP module

2 years agoMention the category laws explicitly
David Luposchainsky [Fri, 11 Aug 2017 10:56:32 +0000 (12:56 +0200)] 
Mention the category laws explicitly

2 years agoAdd some Monoid doctests
David Luposchainsky [Fri, 11 Aug 2017 10:50:13 +0000 (12:50 +0200)] 
Add some Monoid doctests

2 years agoInsert missing blank line to fix Applicative doc
David Luposchainsky [Fri, 11 Aug 2017 10:31:23 +0000 (12:31 +0200)] 
Insert missing blank line to fix Applicative doc

2 years agoSections with undefined operators have non-standard behavior
David Luposchainsky [Fri, 11 Aug 2017 09:26:52 +0000 (11:26 +0200)] 
Sections with undefined operators have non-standard behavior

2 years agoDoctest for Void.absurd
David Luposchainsky [Fri, 11 Aug 2017 08:38:24 +0000 (10:38 +0200)] 
Doctest for Void.absurd

2 years agoHandle ListPat in isStrictPattern
Alexander Biehl [Fri, 11 Aug 2017 06:29:23 +0000 (08:29 +0200)] 
Handle ListPat in isStrictPattern

This fixes #14105.

2 years agoRemove extra ` from "kind-indexed GADTs" doc
Chris Martin [Thu, 10 Aug 2017 23:37:02 +0000 (19:37 -0400)] 
Remove extra ` from "kind-indexed GADTs" doc

2 years agoFix #11785 by making reifyKind = reifyType
Ryan Scott [Thu, 17 Aug 2017 14:07:32 +0000 (10:07 -0400)] 
Fix #11785 by making reifyKind = reifyType

Summary:
This ties up the last loose end in Template Haskell's separate
code paths for types and kinds. By making `reifyKind = reifyType` in
`TcSplice`, types and kinds are now treated on equal terms in TH.

This is itself a small patch, but most of the heavy lifting to make this
possible was done in ad7b945257ea262e3f6f46daa4ff3e451aeeae0b.

Test Plan: ./validate

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie

GHC Trac Issues: #11785

Differential Revision: https://phabricator.haskell.org/D3854

2 years agoSuggest how to fix illegally nested foralls in GADT constructor type signatures
Ryan Scott [Thu, 17 Aug 2017 14:07:03 +0000 (10:07 -0400)] 
Suggest how to fix illegally nested foralls in GADT constructor type signatures

Summary:
Although the code from #12087 isn't accepted by GHC, we can at least
do a better job of letting users know what the problem is, and how to fix it.

Test Plan: make test TEST=T12087

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie

GHC Trac Issues: #12087

Differential Revision: https://phabricator.haskell.org/D3851

2 years agoFix #13972 by producing tidier errors
Ryan Scott [Thu, 17 Aug 2017 14:06:32 +0000 (10:06 -0400)] 
Fix #13972 by producing tidier errors

Summary:
Previously, one could experience an error message like this:

```
Expected: T (a -> Either a b)
  Actual: T (a -> Either a b)
```

This makes the error message an iota clearer by tidying it first, which will
instead produce:

```
Expected: T (a1 -> Either a1 b1)
  Actual: T (a -> Either a b)
```

Which steers users towards the understanding that the two sets of tyvars are
actually different.

Test Plan: make test TEST=T13972

Reviewers: simonpj, austin, bgamari, goldfire

Reviewed By: goldfire

Subscribers: goldfire, rwbarton, thomie

GHC Trac Issues: #13972

Differential Revision: https://phabricator.haskell.org/D3820

2 years agoAllow TcDerivInfer to compile with GHC 8.0.1
Ben Gamari [Wed, 16 Aug 2017 23:01:59 +0000 (19:01 -0400)] 
Allow TcDerivInfer to compile with GHC 8.0.1

As of ed7a830de6a2ea74dd6bb81f8ec55b9fe0b52f28 this module uses
MultiWayIf, the parsing behavior of which changed in 8.0.2 due
to #10807. Reformat the code so that it compiles under both 8.0.1 and
8.0.2/8.2.1.

Test Plan: Validate bootstrapping with 8.0.1

Reviewers: austin

Subscribers: rwbarton, thomie, RyanGlScott

GHC Trac Issues: #14130

Differential Revision: https://phabricator.haskell.org/D3863

2 years agoSpeed up compilation of profiling stubs
Ben Gamari [Wed, 16 Aug 2017 23:01:05 +0000 (19:01 -0400)] 
Speed up compilation of profiling stubs

Here we encode the cost centre list as static data. This means that the
initialization stubs are small functions which should be easy for GCC to
compile, even with optimization.

Fixes #7960.

Test Plan: Test profiling

Reviewers: austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #7960

Differential Revision: https://phabricator.haskell.org/D3853

2 years agoBump mtl, parsec, text submodules (again)
Ryan Scott [Wed, 16 Aug 2017 15:50:41 +0000 (11:50 -0400)] 
Bump mtl, parsec, text submodules (again)

We failed to add dist-install and dist-boot to .gitignore in the commits
brought in via commit e054c5f06451def4437d9d770ae156f034796c59. This round of
submodule commits should do the trick.

2 years agoBump mtl, parsec, text submodules
Ben Gamari [Tue, 15 Aug 2017 12:28:50 +0000 (08:28 -0400)] 
Bump mtl, parsec, text submodules

a520adcce27908c799b64214618cf9b33572dc37 updated the upstream repository
locations but failed to update the commits themselves.

2 years agoBump nofib submodule
Ben Gamari [Tue, 15 Aug 2017 00:52:57 +0000 (20:52 -0400)] 
Bump nofib submodule

2 years agoAdd Semigroup/Monoid instances to ST monad
Ben Gamari [Tue, 15 Aug 2017 00:58:16 +0000 (20:58 -0400)] 
Add Semigroup/Monoid instances to ST monad

Fixes #14107.

Signed-off-by: Philipp Middendorf <middendorf@plapadoo.de>
Reviewers: austin, hvr, bgamari, RyanGlScott

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie

GHC Trac Issues: #14107

Differential Revision: https://phabricator.haskell.org/D3845

2 years agoBump mtl, parsec, text submodules
Ryan Scott [Tue, 15 Aug 2017 00:57:11 +0000 (20:57 -0400)] 
Bump mtl, parsec, text submodules

These three submodules have commits which add certain files to their
respective .gitignores which GHC's build system produces. Also update
the packages file accordingly.

Test Plan: If it builds, ship it

Reviewers: hvr, austin, bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3842

2 years agoRecognize FreeBSD compiler as Clang.
Gleb Popov [Tue, 15 Aug 2017 00:56:44 +0000 (20:56 -0400)] 
Recognize FreeBSD compiler as Clang.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3840

2 years agoUse a ReaderT in TcDeriv to avoid some tedious plumbing
Ryan Scott [Tue, 15 Aug 2017 00:56:04 +0000 (20:56 -0400)] 
Use a ReaderT in TcDeriv to avoid some tedious plumbing

Addresses point (2) of https://phabricator.haskell.org/D3337#107865.

Before, several functions in `TcDeriv` and `TcDerivInfer` which compute
an `EarlyDerivSpec` were manually threading through about 10 different
arguments, which contribute to quite a lot of clutter whenever they need
to be updated. To minimize this plumbing, and to make it clearer which
of these 10 values are being used where, I refactored the code in
`TcDeriv` and `TcDerivInfer` to use a new `DerivM` type:

```lang=haskell
type DerivM = ReaderT DerivEnv TcRn
```

where `DerivEnv` contains the 10 aforementioned values. In addition to
cleaning up the code, this should make some subsequent changes planned
for later less noisy.

Test Plan: ./validate

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3846

2 years agoDon't drop GHCi-defined functions with -fobject-code enabled
Ryan Scott [Tue, 15 Aug 2017 00:55:39 +0000 (20:55 -0400)] 
Don't drop GHCi-defined functions with -fobject-code enabled

The desugarer was using `targetRetainsAllBindings` as a litmus test for
determining if a function was defined in interactive mode (and thus
should be exported). However, there is a corner case where one can be in
interactive mode and have `targetRetainsAllBindings` return `False`: if
`-fobject-code` is enabled (since the target will no longer be
`HscInteractive`). In such a scenario, we should fall back on a
different test for determining if we are in a GHCi session. I chose to
use `isInteractiveModule`, which appears to do the trick.

Test Plan: make test TEST=T12091

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12091

Differential Revision: https://phabricator.haskell.org/D3849

2 years agoProperly handle dlerror() message on FreeBSD when linking linker scripts
Gleb Popov [Tue, 15 Aug 2017 00:54:36 +0000 (20:54 -0400)] 
Properly handle dlerror() message on FreeBSD when linking linker scripts

Test Plan: `GHCi.loadDll "/usr/lib/libc++.so` now works on FreeBSD.

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3841

2 years agoFix #14060 by more conservatively annotating TH-reified types
Ryan Scott [Tue, 15 Aug 2017 00:53:57 +0000 (20:53 -0400)] 
Fix #14060 by more conservatively annotating TH-reified types

Before, TH was quite generous in applying kind annotations to reified
type constructors whose result kind happened to mention type variables.
This could result in agonizingly large reified types, so this patch aims
to quell this a bit by adopting a more nuanced algorithm for determining
when a tycon application deserves a kind annotation.

This implements the algorithm laid out in
https://ghc.haskell.org/trac/ghc/ticket/14060#comment:1. I've updated
`Note [Kind annotations on TyConApps]` to reflect the new wisdom.
Essentially, instead of only checking if the result kind contains free
variables, we also check if any of those variables do not appear free in
injective positions in the argument kinds—only then do we put on a kind
annotation.

Bumps `haddock` submodule.

Test Plan: make test TEST=T14060

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie

GHC Trac Issues: #14060

Differential Revision: https://phabricator.haskell.org/D3807

2 years agoPoint to FunDeps documentation on Haskell wiki
Ben Gamari [Tue, 8 Aug 2017 03:40:51 +0000 (23:40 -0400)] 
Point to FunDeps documentation on Haskell wiki

2 years agoAdd test for #14101
Ryan Scott [Sat, 12 Aug 2017 20:24:19 +0000 (16:24 -0400)] 
Add test for #14101

I forgot to do this in
0bb1e84034a12d7f700b48fca6710c01bd08f397.

2 years agoExpand type synonyms during role inference
Ryan Scott [Sat, 12 Aug 2017 19:52:08 +0000 (15:52 -0400)] 
Expand type synonyms during role inference

Summary:
During role inference, we need to expand type synonyms, since
oversaturated applications of type synonym tycons would otherwise have overly
conservative roles inferred for its arguments.

Fixes #14101.

Test Plan: ./validate

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie

GHC Trac Issues: #14101

Differential Revision: https://phabricator.haskell.org/D3838

2 years agoChange isClosedAlgType to be TYPE-aware, and rename it to pmIsClosedType
Ryan Scott [Sat, 12 Aug 2017 19:51:37 +0000 (15:51 -0400)] 
Change isClosedAlgType to be TYPE-aware, and rename it to pmIsClosedType

Summary:
In a267580e4ab37115dcc33f3b8a9af67b9364da12, I somewhat awkwardly
inserted a special case for `TYPE` in the `EmptyCase` coverage checker.
Instead of placing it there, @mpickering noted that `isClosedAlgType` would
be a better fit for it. I do just that in this patch.

I also renamed `isClosedAlgType` to `pmIsClosedType`, reflecting the fact that
`TYPE` technically isn't an algebraic type (it's a primitive one), and that its
behavior is pattern-match coverage checking-oriented. I also moved it to
`Check`, which is a better home for this function than `Type`. Luckily,
the only call sites for `isClosedAlgType` were in the pattern-match coverage
checker anyways, so this change is simple enough.

Test Plan: ./validate

Reviewers: mpickering, austin, goldfire, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie, mpickering

GHC Trac Issues: #14086

Differential Revision: https://phabricator.haskell.org/D3830

2 years agoUse NonEmpty lists to represent lists of duplicate elements
Ryan Scott [Sat, 12 Aug 2017 19:47:27 +0000 (15:47 -0400)] 
Use NonEmpty lists to represent lists of duplicate elements

Summary:
Three functions in `ListSetOps` which compute duplicate elements
represent lists of duplicates of `[a]`. This is a really bad way to go about
things, because these lists are guaranteed to always have at least one element
(the "representative" of the duplicates), and several places in the GHC API
call `head` (a partial function) on these lists of duplicates to retrieve the
representative.

This changes the representation of duplicates to `NonEmpty` lists instead,
which allow for many partial uses of `head` to be made total.

Fixes #13823.

Test Plan: ./validate

Reviewers: bgamari, austin, goldfire

Reviewed By: bgamari

Subscribers: goldfire, rwbarton, thomie

GHC Trac Issues: #13823

Differential Revision: https://phabricator.haskell.org/D3823

2 years agoDon't suppress unimplemented type family warnings with DeriveAnyClass
Ryan Scott [Sat, 12 Aug 2017 19:46:44 +0000 (15:46 -0400)] 
Don't suppress unimplemented type family warnings with DeriveAnyClass

Summary:
For some asinine reason, we were suppressing warnings when
deriving associated type family instances with `DeriveAnyClass`. That seems
like a bad idea. Let's not do that.

Along the way, I noticed that the error contexts associated with these
newly emitted warnings were less than ideal, so I did some minor refactoring
to improve the story there.

Fixes #14094

Test Plan: ./validate

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #14094

Differential Revision: https://phabricator.haskell.org/D3828

2 years agoSplit out inferConstraintsDataConArgs from inferConstraints
Ryan Scott [Sat, 12 Aug 2017 19:46:22 +0000 (15:46 -0400)] 
Split out inferConstraintsDataConArgs from inferConstraints

Summary:
Addresses point (1) of https://phabricator.haskell.org/D3337#107865.

Before, `inferConstraints` awkwardly combined all of the logic needed to handle
stock, newtype, and anyclass deriving. Really, though, the stock/newtype logic
is quite different from the anyclass logic, so this splits off
`inferConstraintsDataConArgs` (so named because it infers constraints by
inspecting the types of the arguments to data constructors) from
`inferConstraints` to handle the stock/newtype-specific bits.

Aside from making the code somewhat clearer, this allows us to factor out
superclass constraint inference, which is done regardless of deriving strategy.

Test Plan: If it builds, ship it

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3827

2 years agoFix EmptyCase documentation
Cyd Parser [Mon, 7 Aug 2017 05:23:23 +0000 (22:23 -0700)] 
Fix EmptyCase documentation

2 years agoConvert examples to doctests, and add a handful of new ones
David Luposchainsky [Sun, 6 Aug 2017 11:32:52 +0000 (13:32 +0200)] 
Convert examples to doctests, and add a handful of new ones

2 years agoFix string escaping in JSON
Dmitry Malikov [Sat, 5 Aug 2017 14:28:40 +0000 (16:28 +0200)] 
Fix string escaping in JSON

It seems to that double quotes is not escaped well at the moment.

We'd noticed this with @alexbiehl during the work on https://github.com/haskell/haddock/pull/645

2 years agoAdd forgotten > in Control.Applicative
Oleg Grenrus [Fri, 4 Aug 2017 15:07:14 +0000 (18:07 +0300)] 
Add forgotten > in Control.Applicative

As reported by tabaqui on `#hackage`

2 years agoDon't warn when empty casing on Type
Ryan Scott [Sat, 5 Aug 2017 16:02:54 +0000 (12:02 -0400)] 
Don't warn when empty casing on Type

Summary:
`Type` (a.k.a. `TYPE LiftedRep`) can be used at the type level thanks
to `TypeInType`. However, expressions like

```lang=haskell
f :: Type -> Int
f x = case x of {}
```

were falsely claiming that the empty case on the value of type `Type` was
non-exhaustive. The reason is a bit silly: `TYPE` is technically not an empty
datatype in GHC's eyes, since it's a builtin, primitive type. To convince the
pattern coverage checker otherwise, this adds a special case for `TYPE`.

Test Plan: make test TEST=T14086

Reviewers: gkaracha, austin, bgamari, goldfire

Reviewed By: goldfire

Subscribers: goldfire, rwbarton, thomie

GHC Trac Issues: #14086

Differential Revision: https://phabricator.haskell.org/D3819

2 years agoRemove the deprecated Typeable{1..7} type synonyms
Ryan Scott [Sat, 5 Aug 2017 16:02:41 +0000 (12:02 -0400)] 
Remove the deprecated Typeable{1..7} type synonyms

Summary:
`Typeable{1..7}` (type synonyms for the poly-kinded `Typeable`) have
been deprecated since GHC 7.8. They're now causing problems for users who try
to still work with them in legacy code, since they can no longer be used in
instances. To avoid this sort of confusion, let's just remove `Typeable{1..7}`
altogether. Resolves #14047.

Reviewers: bgamari, austin, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14047

Differential Revision: https://phabricator.haskell.org/D3817

2 years agoAdd MonadIO Q - by requiring MonadIO => Quasi
Oleg Grenrus [Sat, 5 Aug 2017 16:02:16 +0000 (12:02 -0400)] 
Add MonadIO Q - by requiring MonadIO => Quasi

Summary: This is follow-up to https://ghc.haskell.org/trac/ghc/ticket/10773

Reviewers: austin, goldfire, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3816

2 years agoAdd the bootstrapping/ dir to .gitignore
Ryan Scott [Wed, 2 Aug 2017 20:12:03 +0000 (16:12 -0400)] 
Add the bootstrapping/ dir to .gitignore

Summary: This is generated when building `ghc-cabal`.

Reviewers: hvr, bgamari, austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3813

2 years agoRemove unneeded uses of ImplicitParams
Ryan Scott [Wed, 2 Aug 2017 20:10:34 +0000 (16:10 -0400)] 
Remove unneeded uses of ImplicitParams

Summary:
Finish the work started in
7d1909ad110f05c8cb2fb0689ee75857ceb945f6.

Test Plan: If it builds, ship it

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3812

2 years agoGet the roles right for newtype instances
Simon Peyton Jones [Wed, 2 Aug 2017 16:59:56 +0000 (12:59 -0400)] 
Get the roles right for newtype instances

This was a simple slip, that gave rise to the bug reported in
comment:13 of Trac #14045.  We were supplying roles to mkAlgTyCon
that didn't match the tyvars.

2 years agoAdd .gitmodules entries for text, parsec, mtl submodules
Ben Gamari [Tue, 1 Aug 2017 20:51:41 +0000 (16:51 -0400)] 
Add .gitmodules entries for text, parsec, mtl submodules

2 years agoBump unix submodule
Ben Gamari [Tue, 1 Aug 2017 15:10:46 +0000 (11:10 -0400)] 
Bump unix submodule

2 years agoEnable building Cabal with parsec
Herbert Valerio Riedel [Tue, 1 Aug 2017 15:05:18 +0000 (11:05 -0400)] 
Enable building Cabal with parsec

Cabal's parser has been rewritten in terms of Parsec (which is not
enabled yet in Cabal-2.0 by default, but can be enabled by a cabal
flag). The plan for Cabal is to drop support for the non-parsec parser,
so we need to prepare GHC to cope with new situation.

However, this means that lib:Cabal requires three new library
dependency submodules,

 - parsec
 - text
 - mtl

What complicates matters is that we need to build `ghc-cabal` early on
during the bootstrap phase which currently needs to invoke `ghc --make`
directly. So these additional dependencies need to be integrated into
the monolithic `ghc --make` invocation which produces the `ghc-cabal`
executable.

Test Plan: `./validate --fast` passed

Reviewers: austin, bgamari

Subscribers: erikd, phadej, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3757

2 years agoDrop GHC 7.10 compatibility
Ryan Scott [Tue, 1 Aug 2017 13:48:52 +0000 (09:48 -0400)] 
Drop GHC 7.10 compatibility

GHC 8.2.1 is out, so now GHC's support window only extends back to GHC
8.0. This means we can delete gobs of code that was only used for GHC
7.10 support. Hooray!

Test Plan: ./validate

Reviewers: hvr, bgamari, austin, goldfire, simonmar

Reviewed By: bgamari

Subscribers: Phyx, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3781

2 years agoSimplify OccurAnal.tagRecBinders
Joachim Breitner [Tue, 1 Aug 2017 02:56:51 +0000 (22:56 -0400)] 
Simplify OccurAnal.tagRecBinders

No need to mark the binders with markNonTailCalled, as they already have been
marked as such in rhs_udss' via adjust.

Differential Revision: https://phabricator.haskell.org/D3810

2 years agorts: Fix "variable set but not used" warning
Ben Gamari [Tue, 1 Aug 2017 02:33:51 +0000 (22:33 -0400)] 
rts: Fix "variable set but not used" warning

gcc complains about this while building with Hadrian,
```
rts/RetainerProfile.c: In function ‘computeRetainerSet’:

rts/RetainerProfile.c:1758:18: error:
     error: variable ‘rtl’ set but not used
[-Werror=unused-but-set-variable]
         RetainerSet *rtl;
                      ^~~
     |
1758 |     RetainerSet *rtl;
     |                  ^
```

Reviewers: austin, erikd, simonmar, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3801

2 years agoAllow bundling pattern synonyms with exported data families
Ryan Scott [Tue, 1 Aug 2017 02:33:40 +0000 (22:33 -0400)] 
Allow bundling pattern synonyms with exported data families

Test Plan: make test TEST=T14058

Reviewers: mpickering, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #14058

Differential Revision: https://phabricator.haskell.org/D3808

2 years agoKnownUniques: Handle DataCon wrapper names
Ben Gamari [Tue, 1 Aug 2017 02:33:24 +0000 (22:33 -0400)] 
KnownUniques: Handle DataCon wrapper names

For some reason these weren't handled. I seem to remember thinking I had
a reason for omitting them when writing the original patch, but I don't
recall what that reason was at this point and clearly workers do show up
in interface files.

Test Plan: Validate against T14051

Reviewers: austin

Subscribers: rwbarton, thomie, RyanGlScott

GHC Trac Issues: #14051

Differential Revision: https://phabricator.haskell.org/D3805

2 years agoTypofixes [ci skip]
Gabor Greif [Tue, 1 Aug 2017 12:14:31 +0000 (14:14 +0200)] 
Typofixes [ci skip]

2 years agoA bunch of typofixes
Gabor Greif [Mon, 31 Jul 2017 15:34:43 +0000 (17:34 +0200)] 
A bunch of typofixes

2 years agoUse field names for all uses of datacon Match
Simon Peyton Jones [Mon, 31 Jul 2017 12:27:54 +0000 (13:27 +0100)] 
Use field names for all uses of datacon Match

This is refactoring only... elimiante all positional uses
of the data constructor Match in favour of field names.

No change in behaviour.

2 years agoRemove redundant goop
Simon Peyton Jones [Mon, 31 Jul 2017 12:25:17 +0000 (13:25 +0100)] 
Remove redundant goop

See comment:22 in Trac #13594

2 years agoReject top-level banged bindings
Simon Peyton Jones [Mon, 31 Jul 2017 12:22:38 +0000 (13:22 +0100)] 
Reject top-level banged bindings

Bizarrely, we were not rejecting
  !x = e

Fix:

* In the test in DsBinds.dsTopLHsBinds, use isBangedHsBind, not
  isBangedPatBind.  (Indeed the latter dies altogther.)

* Implement isBangedHsBind in HsUtils;
  be sure to handle AbsBinds

All this was shown up by Trac #13594

2 years agoDo a bit more CSE
Simon Peyton Jones [Mon, 31 Jul 2017 10:00:33 +0000 (11:00 +0100)] 
Do a bit more CSE

I discovered that in

   let x = MkT y in ....(MKT y |> co)....

we weren't CSE'ing the (MkT y).  The fix is easy.

2 years agoImprove the desugaring of -XStrict
Simon Peyton Jones [Mon, 31 Jul 2017 09:49:16 +0000 (10:49 +0100)] 
Improve the desugaring of -XStrict

Trac #14035 showed that -XStrict was generating some TERRIBLE
desugarings, espcially for bindings with INLINE pragmas. Reason: with
-XStrict, all AbsBinds (even for non-recursive functions) went via the
general-case deguaring for AbsBinds, namely "generate a tuple and
select from it", even though in this case there was only one variable
in the tuple.  And that in turn interacts terribly badly with INLINE
pragmas.

This patch cleans things up:

* I killed off AbsBindsSig completely, in favour of a boolean flag
  abs_sig in AbsBinds.  See Note [The abs_sig field of AbsBinds]

  This allowed me to delete lots of code; and instance-method
  declarations can enjoy the benefits too.  (They could have
  before, but no one had changed them to use AbsBindsSig.)

* I refactored all the AbsBinds handling in DsBinds into a new
  function DsBinds.dsAbsBinds.  This allowed me to handle the
  strict case uniformly

2 years agoRefactoring around FunRhs
Simon Peyton Jones [Mon, 31 Jul 2017 09:48:00 +0000 (10:48 +0100)] 
Refactoring around FunRhs

* Clarify the comments around the mc_strictness field of FunRhs
* Use record field names consistently for FunRhs

2 years agoClarify comment about data family arities
Richard Eisenberg [Mon, 31 Jul 2017 12:29:48 +0000 (08:29 -0400)] 
Clarify comment about data family arities

as requested in #14045.

[skip ci] comments only

2 years agoAllow Windows to set blank environment variables
Habib Alamin [Mon, 31 Jul 2017 04:48:43 +0000 (05:48 +0100)] 
Allow Windows to set blank environment variables

Test Plan: ./validate on harbormaster

Reviewers: austin, hvr, bgamari, erikd, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie

GHC Trac Issues: #12494

Differential Revision: https://phabricator.haskell.org/D3726

2 years agoAdd haddock markup
Gabor Greif [Fri, 28 Jul 2017 19:09:03 +0000 (21:09 +0200)] 
Add haddock markup

2 years agoTypofixes [ci skip]
Gabor Greif [Fri, 28 Jul 2017 18:36:59 +0000 (20:36 +0200)] 
Typofixes [ci skip]

2 years agoFollow-up to #13887, for promoted infix constructors
Ryan Scott [Sat, 29 Jul 2017 23:36:42 +0000 (19:36 -0400)] 
Follow-up to #13887, for promoted infix constructors

Summary:
Correct a couple more spots in the TH pretty-printer by applying the
appropriate parenthesization for infix names. Fixes #13887 (again).

Test Plan: make test TEST=T13887

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13887

Differential Revision: https://phabricator.haskell.org/D3802

2 years agoAdd regression test for #14055
Ryan Scott [Sat, 29 Jul 2017 23:35:52 +0000 (19:35 -0400)] 
Add regression test for #14055

2 years agoFix #14045 by omitting an unnecessary check
Richard Eisenberg [Sat, 29 Jul 2017 01:43:38 +0000 (21:43 -0400)] 
Fix #14045 by omitting an unnecessary check

Previously, we checked the number of patterns in a data instances
for all data families whose kind did not end in a kind variable.
But, of course, undersaturating instances can happen even without
the kind ending in a kind variable. So I've omitted the arity check.
Data families aren't as particular about their arity as type families
are (because data families can be undersaturated). Still, this change
degrades error messages when instances don't have the right arity;
now, instead of reporting a simple mismatch in the number of patterns,
GHC reports kind errors. The new errors are fully accurate, but perhaps
not as easy to work with. Still, with the new flexibility of allowing
data family instances with varying numbers of patterns, I don't see
a better way.

This commit also improves source fidelity in some error messages,
requiring more changes than really are necessary. But without these
changes, error messages around mismatched associated instance heads
were poor.

test cases: indexed-types/should_compile/T14045,
            indexed-types/should_fail/T14045a