4 years agomkUserGuidePart: Better flag cross-referencing
Ben Gamari [Sat, 23 Jan 2016 18:10:59 +0000 (19:10 +0100)] 
mkUserGuidePart: Better flag cross-referencing

4 years agoRemove -Wredundant-superclasses from standard warnings
Ben Gamari [Sat, 23 Jan 2016 17:40:33 +0000 (18:40 +0100)] 
Remove -Wredundant-superclasses from standard warnings

It is impossible to write warning-free code under the three-release
policy with this flag enabled by default. See #11370 for details.

4 years agoGive a more verbose error message when desugaring a HsTypeOut
Reid Barton [Sat, 23 Jan 2016 12:13:31 +0000 (13:13 +0100)] 
Give a more verbose error message when desugaring a HsTypeOut

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoSmall doc fix
Adam Sandberg Eriksson [Sat, 23 Jan 2016 12:13:07 +0000 (13:13 +0100)] 
Small doc fix

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoRemove unused IND_PERM
Joachim Breitner [Sat, 23 Jan 2016 12:12:10 +0000 (13:12 +0100)] 
Remove unused IND_PERM

it seems that this closure type has not been in use since 5d52d9, so all
this is dead and untested code. This removes it. Some of the code might
be useful for a counting indirection as described in #10613, so when
implementing that, have a look at what this commit removes.

Test Plan: validate on harbormaster

Reviewers: austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision:

4 years agoAdd test for Trac #11056
RyanGlScott [Sat, 23 Jan 2016 12:03:26 +0000 (13:03 +0100)] 
Add test for Trac #11056

Reviewers: thomie, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton

Differential Revision:

GHC Trac Issues: #11056

4 years agorts: Disable tick timer unless really needed
Ben Gamari [Fri, 22 Jan 2016 15:22:13 +0000 (16:22 +0100)] 
rts: Disable tick timer unless really needed

Trac #9105 notes significant CPU usage by an otherwise idle process when
compiled with profiling. The reason for this is that we keep the tick
timer active in the profiling RTS even if profiling wasn't requested at

If the user requests any sort of profiling then we need to keep the
timer active to ensure that samples are collected.

Test Plan: Validate, check CPU usage, ensure profiling still works

Reviewers: simonmar, austin

Reviewed By: simonmar, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #9105

4 years agoDo not count void arguments when considering a function for loopification.
Jonas Scholl [Fri, 22 Jan 2016 15:21:57 +0000 (16:21 +0100)] 
Do not count void arguments when considering a function for loopification.

This fixes #11372 by omitting arguments with a void-type when checking
whether a self-recursive tail call can be optimized to a local jump.
Previously, a function taking a real argument and a State# token
would report an arity of 1 in the SelfLoopInfo in getCallMethod,
but a self-recursive call would apply it to 2 arguments, one of them
being the State# token, thus no local jump would be generated.
As the State# token is not represented by anything at runtime, we can
ignore it and thus trigger the loopification optimization.

Test Plan: ./validate

Reviewers: austin, bgamari, simonmar

Reviewed By: bgamari

Subscribers: simonmar, thomie

Differential Revision:

GHC Trac Issues: #11372

4 years agoFix a formatting error in the user's guide
Eric Seidel [Fri, 22 Jan 2016 15:16:46 +0000 (16:16 +0100)] 
Fix a formatting error in the user's guide


seems to confuse ReST into producing an extended code-span


fixes it, but there may be a better solution

Test Plan: build the user's guide and inspect the last paragraph of
" Implicit CallStacks"

Reviewers: bgamari

Reviewed By: bgamari

Projects: #ghc

Differential Revision:

4 years agoMark some ghci tests as req_interp
Reid Barton [Fri, 22 Jan 2016 15:00:27 +0000 (10:00 -0500)] 
Mark some ghci tests as req_interp

Test Plan: validate

Reviewers: bgamari, austin

Reviewed By: bgamari, austin

Subscribers: thomie

Differential Revision:

4 years agoDon't print "Loaded GHCi configuration" message in ghc -e (#11478)
Reid Barton [Fri, 22 Jan 2016 14:59:20 +0000 (09:59 -0500)] 
Don't print "Loaded GHCi configuration" message in ghc -e (#11478)

Also don't print it if the user specifically requested
non-verbose output with -v0.

Since this means there is no longer any test that checks
for the message, add such a test.

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11478

4 years agoAdd tests for #11465 and the kind invariant
Ben Gamari [Fri, 22 Jan 2016 12:01:55 +0000 (13:01 +0100)] 
Add tests for #11465 and the kind invariant

4 years agoDefault non-canonical CallStack constraints
Eric Seidel [Fri, 22 Jan 2016 11:45:53 +0000 (12:45 +0100)] 
Default non-canonical CallStack constraints

Test Plan: `make test TEST=T11462`

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Projects: #ghc

Differential Revision:

GHC Trac Issues: #11462

4 years agoMake a constraint synonym for repeated BinaryStringRep and use it.
Edward Z. Yang [Thu, 21 Jan 2016 18:27:58 +0000 (19:27 +0100)] 
Make a constraint synonym for repeated BinaryStringRep and use it.

Test Plan: validate

Reviewers: austin, thomie, bgamari

Reviewed By: thomie, bgamari

Subscribers: thomie

Differential Revision:

4 years agoAdd expected stderr for #11466 test case
Joachim Breitner [Fri, 22 Jan 2016 09:51:46 +0000 (10:51 +0100)] 
Add expected stderr for #11466 test case

4 years agoAlways run test T9407
Reid Barton [Fri, 22 Jan 2016 02:09:21 +0000 (21:09 -0500)] 
Always run test T9407

We don't know what the cause of the bug was, or what commit fixed it.
or why it was Windows only. So it seems prudent to run it in all
configurations, in case the bug should crop up again.

4 years agoImprove comments in CmmSwitch
Joachim Breitner [Thu, 21 Jan 2016 16:55:48 +0000 (17:55 +0100)] 
Improve comments in CmmSwitch

addressing some valuable feedback by thomie at

Differential Revision:

4 years agosphinx-build: fix python stack overflow (Trac #10950)
Sergei Trofimovich [Thu, 21 Jan 2016 21:43:37 +0000 (21:43 +0000)] 
sphinx-build: fix python stack overflow (Trac #10950)

commit a034031a102bc08c76a6cdb104b72922ae22c96b did not
fix problem completely. Stack overflows still occasionally

Easy to test by the following Torture Test:

  while sphinx-build -T -N -E -a -b html \
        -d docs/users_guide/.doctrees-html \
        -D latex_paper_size=letter \
        docs/users_guide docs/users_guide/build-html/users_guide
    echo again

sphinx build large nested data structures when parses GHC manual
(docs/users_guide/glasgow_exts.rst is 455KB in size) which
can't be serialized useing default python call stack depth of 1000

The patch increases stack depth 10 times. Survived 2 hours of
Torture Test.

Signed-off-by: Sergei Trofimovich <>
Test Plan: ran Torture Test to make sure it is stable

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10950

4 years agoFix docstring GHC.IO.Handle.FD.openFileBLocking
Thomas Miedema [Thu, 21 Jan 2016 20:16:05 +0000 (21:16 +0100)] 
Fix docstring GHC.IO.Handle.FD.openFileBLocking

Fixes #4248.

4 years agoAdd -ignore-dot-ghci to tests that use --interactive
Reid Barton [Thu, 21 Jan 2016 18:50:00 +0000 (13:50 -0500)] 
Add -ignore-dot-ghci to tests that use --interactive

4 years agoAdd a missing .gitignore entry in annotations tests
Reid Barton [Thu, 21 Jan 2016 16:16:47 +0000 (11:16 -0500)] 
Add a missing .gitignore entry in annotations tests

4 years agoUpdate and improve documentation in Data.Foldable
Ben Gamari [Thu, 21 Jan 2016 13:51:01 +0000 (14:51 +0100)] 
Update and improve documentation in Data.Foldable

Previously there were a few obsolete references to `Data.List` and
the descriptions were lacking examples.

Fixes #11065.

Test Plan: Read it.

Reviewers: ekmett, goldfire, hvr, austin

Reviewed By: hvr

Subscribers: nomeata, thomie

Differential Revision:

GHC Trac Issues: #11065

4 years agorel-notes: Note the return of -Wmonomorphism-restriction
Ben Gamari [Thu, 21 Jan 2016 13:49:01 +0000 (14:49 +0100)] 
rel-notes: Note the return of -Wmonomorphism-restriction

4 years agouser-guide: Refer to MIN_VERSION_GLASGOW_HASKELL from intro
Ben Gamari [Thu, 21 Jan 2016 10:30:24 +0000 (11:30 +0100)] 
user-guide: Refer to MIN_VERSION_GLASGOW_HASKELL from intro

And fix markup.

4 years agouser-guide:: Improve -D description
Ben Gamari [Thu, 21 Jan 2016 10:36:00 +0000 (11:36 +0100)] 
user-guide:: Improve -D description

4 years agoTyCoRep: Restore compatibility with 7.10.1
Ben Gamari [Thu, 21 Jan 2016 10:19:23 +0000 (11:19 +0100)] 
TyCoRep: Restore compatibility with 7.10.1

Sadly CallStack wasn't present in 7.10.1, breaking the build when
bootstrapping from this version.

This patch essentially disables CallStack support for stage1 builds with
7.10.*. This doesn't seem so unreasonable though as stage2 will still

Test Plan: Validate with 7.10.1

Reviewers: gridaphobe, jstolarek, austin

Reviewed By: jstolarek

Subscribers: thomie, jstolarek

Differential Revision:

GHC Trac Issues: #11472

4 years agoAllow implicit parameters in constraint synonyms
Simon Peyton Jones [Thu, 21 Jan 2016 12:26:50 +0000 (12:26 +0000)] 
Allow implicit parameters in constraint synonyms

This fixes Trac #11466.

It went bad by accident in
 commit ffc21506894c7887d3620423aaf86bc6113a1071
 Refactor tuple constraints

4 years agoStrip casts in checkValidInstHead
Simon Peyton Jones [Wed, 20 Jan 2016 16:04:20 +0000 (16:04 +0000)] 
Strip casts in checkValidInstHead

This patch addresses Trac #11464.

The fix is a bit crude (traverse the type to remove CastTys),
but it's also simple.

See Note [Casts during validity checking] in TcValidity

4 years agoRemove the check_lifted check in TcValidity
Simon Peyton Jones [Wed, 20 Jan 2016 16:02:22 +0000 (16:02 +0000)] 
Remove the check_lifted check in TcValidity

This patch fixes Trac #11465.  The check_unlifted check really isn't
necessary, as discussed in Trac #11120 comment:19.

Removing it made just one test-suite change,
in indexed-types/should_fail/T9357, by allowing

   type family F (a :: k1) :: k2
   type instance F Int# = Int

to be accepted.  And indeed that seems entirely reasonable.

4 years agoImprove pretty-printing of UnivCo
Simon Peyton Jones [Wed, 20 Jan 2016 14:10:08 +0000 (14:10 +0000)] 
Improve pretty-printing of UnivCo

We really need to know the UnivCoProvenance to make sense
of UnivCos in debug output

4 years agoComments only
Simon Peyton Jones [Wed, 20 Jan 2016 14:09:35 +0000 (14:09 +0000)] 
Comments only

4 years agoRe-add missing kind generalisation
Simon Peyton Jones [Tue, 19 Jan 2016 13:18:39 +0000 (13:18 +0000)] 
Re-add missing kind generalisation

When splitting H98/GADT syntax in ConDecl we lost a key
kind-generalisation step.

I also renamed tcHsTyVarBndrs to tcExplicitTKBnders, by analogy
with tcImplicitTkBndrs.

This fixes Trac #11459.

Merge to 8.0.

4 years agoComments only
Simon Peyton Jones [Tue, 19 Jan 2016 13:11:58 +0000 (13:11 +0000)] 
Comments only

Re Trac #11051

4 years agoAdd comments about tyCoVarsOfType
Simon Peyton Jones [Wed, 20 Jan 2016 22:13:39 +0000 (22:13 +0000)] 
Add comments about tyCoVarsOfType

See Note [Free variables of types].

Richard to check.

4 years agoMkId: Update OpenKind reference
Ben Gamari [Thu, 21 Jan 2016 09:35:19 +0000 (10:35 +0100)] 
MkId: Update OpenKind reference

4 years agosubstTy to substTyUnchecked to fix Travis build
Bartosz Nitka [Wed, 20 Jan 2016 16:58:52 +0000 (08:58 -0800)] 
substTy to substTyUnchecked to fix Travis build

This fixes the immediate problem from

Test Plan: ./validate

Reviewers: bgamari, austin, thomie

Differential Revision:

GHC Trac Issues: #11371

4 years agoUpdate submodule stm + random
Thomas Miedema [Wed, 20 Jan 2016 16:41:53 +0000 (17:41 +0100)] 
Update submodule stm + random

Skip random tests when random is not built.
Skip stm tests when stm is not built.

4 years agoAdd test T9407 (Windows)
Rik Steenkamp [Wed, 20 Jan 2016 11:39:00 +0000 (12:39 +0100)] 
Add test T9407 (Windows)

Add test for #9407. The test is only run on Windows 64bit, as this is
where the problem occurred.

Reviewed by: thomie

Differential Revision:

4 years agoRework derivation of type representations for wired-in things
Ben Gamari [Wed, 20 Jan 2016 15:06:31 +0000 (16:06 +0100)] 
Rework derivation of type representations for wired-in things

Previously types defined by `GHC.Types` and `GHC.Prim` had their
`Typeable` representations manually defined in `GHC.Typeable.Internals`.
This was terrible, resulting in a great deal of boilerplate and a number
of bugs due to missing or inconsistent representations (see #11120).

Here we take a different tack, initially proposed by Richard Eisenberg:
We wire-in the `Module`, `TrName`, and `TyCon` types, allowing them to
be used in `GHC.Types`. We then allow the usual type representation
generation logic to handle this module.

`GHC.Prim`, on the other hand, is a bit tricky as it has no object code
of its own.  To handle this we instead place the type representations
for the types defined here in `GHC.Types`.

On the whole this eliminates several special-cases as well as a fair
amount of boilerplate from hand-written representations. Moreover, we
get full coverage of primitive types for free.

Test Plan: Validate

Reviewers: goldfire, simonpj, austin, hvr

Subscribers: goldfire, simonpj, thomie

Differential Revision:

GHC Trac Issues: #11120

4 years agoUse (&&) instead of `if` in Ix derivation
Ben Gamari [Tue, 19 Jan 2016 15:30:26 +0000 (16:30 +0100)] 
Use (&&) instead of `if` in Ix derivation

We were previously using `if` in the derivation of `Ix` instances. This
interacts badly with RebindableSyntax as the typechecker doesn't infer
the type of the argument we give to `tagToEnum#`.

Previously we produced, `if (ch >= ah) then (ch <= bh) else False`.

We now produce `(ch >= ah) && (ch <= bh)`

Fixes #11396.

Test Plan: Validate

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11396

4 years agoOops. Add missing close-comment
Simon Peyton Jones [Wed, 20 Jan 2016 09:27:31 +0000 (09:27 +0000)] 
Oops.  Add missing close-comment

This fixes 514bac2 for Trac #11172.  Sorry!

4 years agoFix combineIdenticalAlts
Simon Peyton Jones [Wed, 20 Jan 2016 08:07:43 +0000 (08:07 +0000)] 
Fix combineIdenticalAlts

This long-standing bug in CoreUtils.combineIdenticalAlts
was shown up by Trac #11172. The effect was that it returned
a correct set of alternatives, but a bogus set of "impossible
default constructors".  That meant that we subsequently
removed all the alternatives from a case, and hence ended
up with a bogusly empty case that should not have been empty.

See Note [Care with impossible-constructors when
combining alternatives] in CoreUtils.

4 years agoT11266: Improve the test by adding more of the other problematic modules
Ömer Sinan Ağacan [Tue, 19 Jan 2016 20:23:50 +0000 (15:23 -0500)] 
T11266: Improve the test by adding more of the other problematic modules

4 years agoFix IfaceType generation for TyCons without TyVars
Ömer Sinan Ağacan [Tue, 19 Jan 2016 19:56:59 +0000 (14:56 -0500)] 
Fix IfaceType generation for TyCons without TyVars

- This is only used for printing purposes (in :browse etc.).
- Fixes #11266.

Reviewers: goldfire, bgamari, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11266

4 years agoRe-export ghc-boot:GHC.Serialized as Serialized
Simon Marlow [Tue, 19 Jan 2016 16:20:06 +0000 (08:20 -0800)] 
Re-export ghc-boot:GHC.Serialized as Serialized

For backwards-compat with GHC 7.10.

4 years agoCheck InScopeSet in substTy and provide substTyUnchecked
Bartosz Nitka [Tue, 19 Jan 2016 11:25:39 +0000 (03:25 -0800)] 
Check InScopeSet in substTy and provide substTyUnchecked

This adds sanity checks to `substTy` that implement:

> when calling substTy subst ty it should be the case that the in-scope
> set in the substitution is a superset of
> * The free vars of the range of the substitution
> * The free vars of ty minus the domain of the substitution

and replaces violators with unchecked version. The violators were found
by running the GHC test suite.

This ensures that I can work on this incrementally and that what I fix won't
be undone by some other change.

It also includes a couple of fixes that I've already done.

Test Plan: ./validate

Reviewers: simonmar, goldfire, simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11371

4 years agoTypos in comments
Gabor Greif [Tue, 19 Jan 2016 11:10:13 +0000 (12:10 +0100)] 
Typos in comments

4 years agousers-guide: Begin documenting --frontend
Ben Gamari [Mon, 18 Jan 2016 23:07:47 +0000 (00:07 +0100)] 
users-guide: Begin documenting --frontend

Reviewers: austin

Subscribers: thomie, ezyang

Differential Revision:

GHC Trac Issues: #11448

4 years agouser-guide: Delete errant fragment
Ben Gamari [Mon, 18 Jan 2016 22:13:29 +0000 (23:13 +0100)] 
user-guide: Delete errant fragment

Reviewers: austin

Reviewed By: austin

Subscribers: thomie

Differential Revision:

4 years agoHide derived OccNames from user
Ben Gamari [Mon, 18 Jan 2016 22:12:51 +0000 (23:12 +0100)] 
Hide derived OccNames from user

This hides derived OccNames from the Names returned from
runDeclsWithLocation and clarifies the documentation. This is done to
ensure that these names (originating from, e.g., derived Generic
instances and type representation bindings) don't show up in ghci output
when run with `:set +t`. This fixes #11051.

Test Plan: Validate with included tests

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, hvr

Differential Revision:

GHC Trac Issues: #11051

4 years agoghci: Kill global macros list
Ben Gamari [Mon, 18 Jan 2016 22:12:34 +0000 (23:12 +0100)] 
ghci: Kill global macros list

Test Plan: Validate

Reviewers: simonmar, thomie, austin

Reviewed By: austin

Subscribers: alanz

Differential Revision:

4 years agoSwitch from -this-package-key to -this-unit-id.
Edward Z. Yang [Mon, 18 Jan 2016 16:32:27 +0000 (17:32 +0100)] 
Switch from -this-package-key to -this-unit-id.

A small cosmetic change, but we have to do a bit of work to
actually support it:

    - Cabal submodule update, so that Cabal passes us
      -this-unit-id when we ask for it.  This includes
      a Cabal renaming to be consistent with Unit ID, which
      makes ghc-pkg a bit more scrutable.

    - Build system is updated to use -this-unit-id rather than
      -this-package-key, to avoid deprecation warnings.  Needs
      a version test so I resurrected the old test we had
      (sorry rwbarton!)

    - I've *undeprecated* -package-name, so that we are in the same
      state as GHC 7.10, since the "correct" flag will have only
      entered circulation in GHC 8.0.

    - I removed -package-key.  Since we didn't deprecate -package-id
      I think this should not cause any problems for users; they
      can just change their code to use -package-id.

    - The package database is indexed by UNIT IDs, not component IDs.
      I updated the naming here.

    - I dropped the signatures field from ExposedModule; nothing
      was using it, and instantiatedWith from the package database

    - ghc-pkg was updated to use unit ID nomenclature, I removed
      the -package-key flags but I decided not to add any new flags
      for now.

Signed-off-by: Edward Z. Yang <>
Test Plan: validate

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: 23Skidoo, thomie, erikd

Differential Revision:

4 years agoReplace calls to `ptext . sLit` with `text`
Jan Stolarek [Fri, 15 Jan 2016 17:24:14 +0000 (18:24 +0100)] 
Replace calls to `ptext . sLit` with `text`

In the past the canonical way for constructing an SDoc string literal was the
composition `ptext . sLit`.  But for some time now we have function `text` that
does the same.  Plus it has some rules that optimize its runtime behaviour.
This patch takes all uses of `ptext . sLit` in the compiler and replaces them
with calls to `text`.  The main benefits of this patch are clener (shorter) code
and less dependencies between module, because many modules now do not need to
import `FastString`.  I don't expect any performance benefits - we mostly use
SDocs to report errors and it seems there is little to be gained here.

Test Plan: ./validate

Reviewers: bgamari, austin, goldfire, hvr, alanz

Subscribers: goldfire, thomie, mpickering

Differential Revision:

4 years agoFixes to "make clean" for the iserv dir
Simon Marlow [Mon, 18 Jan 2016 14:41:19 +0000 (06:41 -0800)] 
Fixes to "make clean" for the iserv dir

4 years agoTypo in comment
Simon Peyton Jones [Mon, 18 Jan 2016 11:55:20 +0000 (11:55 +0000)] 
Typo in comment

4 years agoTest Trac #11379
Simon Peyton Jones [Mon, 18 Jan 2016 11:53:05 +0000 (11:53 +0000)] 
Test Trac #11379

4 years agoImplement scoped type variables in pattern synonyms
Simon Peyton Jones [Fri, 15 Jan 2016 17:45:02 +0000 (17:45 +0000)] 
Implement scoped type variables in pattern synonyms

This fixes Trac #11351.   The implementation is pretty
simple, happily.

I took the opportunity to re-order the prov/req context
in builder-ids, which was confusingly backwards.

4 years agoAdd Trac #11427 to Note [Recursive superclasses]
Simon Peyton Jones [Fri, 15 Jan 2016 17:33:35 +0000 (17:33 +0000)] 
Add Trac #11427 to Note [Recursive superclasses]

4 years agoRefactoring on IdInfo and system derived names
Simon Peyton Jones [Fri, 15 Jan 2016 17:30:30 +0000 (17:30 +0000)] 
Refactoring on IdInfo and system derived names

Some modest refactoring, triggered in part by Trac #11051

* Kill off PatSynId, ReflectionId in IdDetails
  They were barely used, and only for pretty-printing

* Add helper function Id.mkExportedVanillaId, and use it

* Polish up OccName.isDerivedOccName, as a predicate for
  definitions generated internally by GHC, which we
  might not want to show to the user.

* Kill off unused OccName.mkDerivedTyConOcc

* Shorten the derived OccNames for newtype and data
  instance axioms

* A bit of related refactoring around newFamInstAxiomName

4 years agoImprove debug printing/warnings
Simon Peyton Jones [Mon, 11 Jan 2016 09:02:25 +0000 (09:02 +0000)] 
Improve debug printing/warnings

4 years agoWhite space only
Simon Peyton Jones [Mon, 11 Jan 2016 09:02:01 +0000 (09:02 +0000)] 
White space only

4 years agoFix typecheck of default associated type decls
Simon Peyton Jones [Mon, 18 Jan 2016 10:43:47 +0000 (10:43 +0000)] 
Fix typecheck of default associated type decls

This bug was thrown up by Trac #11361, but I found that the
problem was deeper: GHC was allowing

  class C a where
    type F (a :: k) :: *
    type F (x :: *) = x    -- Not right!

(Which is now indexed-types/should_compile/T11361a.)

Anyway the fix is relatively simple; use tcMatchTys in

Merge to 8.0 branch.

4 years agoLayout only
Simon Peyton Jones [Mon, 18 Jan 2016 10:37:09 +0000 (10:37 +0000)] 
Layout only

4 years agoSimplify API to tcMatchTys
Simon Peyton Jones [Mon, 18 Jan 2016 10:34:48 +0000 (10:34 +0000)] 
Simplify API to tcMatchTys

Previously tcMatchTys took a set of "template type variables" to
bind.  But all the calls are top-level, and we always want to
bind all variables in the template.  So I simplified the API
by omitting that argument.

There should be no change in behaviour.

Feel free to merge to 8.0 if it helps in merging other patches

4 years agoun-wire-in error, undefined, CallStack, and IP
Eric Seidel [Mon, 18 Jan 2016 08:45:23 +0000 (09:45 +0100)] 
un-wire-in error, undefined, CallStack, and IP

I missed a crucial step in the wiring-in process of `CallStack` in D861,
the bit where you actually wire-in the Name... This led to a nasty bug
where GHC thought `CallStack` was not wired-in and tried to fingerprint
it, which failed because the defining module was not loaded.

But we don't need `CallStack` to be wired-in anymore since `error` and
`undefined` no longer need to be wired-in. So we just remove them all.

Updates haddock submodule.

Test Plan: `./validate` and `make slowtest TEST=tc198`

Reviewers: simonpj, goldfire, austin, hvr, bgamari

Reviewed By: simonpj, bgamari

Subscribers: goldfire, thomie

Projects: #ghc

Differential Revision:

GHC Trac Issues: #11331

4 years agovalidate: Use gz compression during bindist check
Ben Gamari [Sun, 17 Jan 2016 23:16:35 +0000 (00:16 +0100)] 
validate: Use gz compression during bindist check

Test Plan: validate, check that gz is used

Reviewers: hvr, austin, thomie

Reviewed By: thomie

Differential Revision:

GHC Trac Issues: #11434

4 years agoAdd testcase for #11414
Ben Gamari [Sun, 17 Jan 2016 22:26:43 +0000 (23:26 +0100)] 
Add testcase for #11414

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11414

4 years agoShow TYPE 'Lifted/TYPE 'Unlifted as */# in Show TypeRep instance
RyanGlScott [Sun, 17 Jan 2016 18:28:10 +0000 (19:28 +0100)] 
Show TYPE 'Lifted/TYPE 'Unlifted as */# in Show TypeRep instance

Kind equalities changed how `*`/`#` are represented internally, which
means that showing a `TypeRep` that contains either of those kinds
produces a rather gross-looking result, e.g.,

> typeOf (Proxy :: Proxy 'Just)
Proxy (TYPE 'Lifted -> Maybe (TYPE 'Lifted)) 'Just

We can at least special-case the `Show` instance for `TypeRep` so that
it prints `*` to represent `TYPE 'Lifted` and `#` to represent `TYPE

Addresses one of the issues uncovered in #11334.

Test Plan: ./validate

Reviewers: simonpj, hvr, austin, goldfire, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11334

4 years agoComplete operators properly
Arthur Fayzrakhmanov (Артур Файзрахманов) [Sun, 17 Jan 2016 18:27:12 +0000 (19:27 +0100)] 
Complete operators properly

Fix operator completions: list of suitable completions only rather than
everything from imported modules.

Signed-off-by: Arthur Fayzrakhmanov (Артур Файзрахманов) <>
ghc: fix operator completions

Reviewers: austin, hvr, thomie, bgamari

Reviewed By: thomie, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10576

4 years agousers-guide: Clean manpage build artifacts and fix usage of clean-target
Ben Gamari [Sun, 17 Jan 2016 18:26:03 +0000 (19:26 +0100)] 
users-guide: Clean manpage build artifacts and fix usage of clean-target

Test Plan: Build then clean

Reviewers: austin, thomie

Reviewed By: thomie

Differential Revision:

GHC Trac Issues: #11433

4 years agorts/posix: Fail with HEAPOVERFLOW when out of memory during mmap
Ben Gamari [Sun, 17 Jan 2016 18:24:50 +0000 (19:24 +0100)] 
rts/posix: Fail with HEAPOVERFLOW when out of memory during mmap

Test Plan: Validate

Reviewers: simonmar, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11300

4 years agoAdd missing T11408.hs
Simon Peyton Jones [Sat, 16 Jan 2016 23:51:42 +0000 (23:51 +0000)] 
Add missing T11408.hs

4 years agoFix a number of subtle solver bugs
Simon Peyton Jones [Sat, 16 Jan 2016 00:37:15 +0000 (00:37 +0000)] 
Fix a number of subtle solver bugs

As a result of some other unrelated changes I found that
IndTypesPerf was failing, and opened Trac #11408.  There's
a test in indexed-types/should-compile/T11408.

The bug was that a type like
 forall t. (MT (UL t) (UR t) ~ t) => UL t -> UR t -> Int
is in fact unambiguous, but it's a bit subtle to prove
that it is unambiguous.

In investigating, Dimitrios and I found several subtle
bugs in the constraint solver, fixed by this patch

* canRewrite was missing a Derived/Derived case.  This was
  lost by accident in Richard's big kind-equality patch.

* Interact.interactTyVarEq would discard [D] a ~ ty if there
  was a [W] a ~ ty in the inert set.  But that is wrong because
  the former can rewrite things that the latter cannot.
  Fix: a new function eqCanDischarge

* In TcSMonad.addInertEq, the process was outright wrong for
  a Given/Wanted in the (GWModel) case.  We were adding a new
  Derived without kicking out things that it could rewrite.
  Now the code is simpler (no special GWModel case), and works

* The special case in kickOutRewritable for [W] fsk ~ ty,
  turns out not to be needed.  (We emit a [D] fsk ~ ty which
  will do the job.

I improved comments and documentation, esp in TcSMonad.

4 years agoWork SourceText in for all integer literals
Alan Zimmerman [Thu, 14 Jan 2016 22:03:58 +0000 (00:03 +0200)] 
Work SourceText in for all integer literals

Certain syntactic elements have integers in them, such as fixity
specifications, SPECIALISE pragmas and so on.

The lexer will accept mult-radix literals, with arbitrary leading zeros
in these.

Bring in a SourceText field to each affected AST element to capture the
original literal text for use with API Annotations.

Affected hsSyn elements are

     -- See note [Pragma source text]
     data Activation = NeverActive
                     | AlwaysActive
                     | ActiveBefore SourceText PhaseNum
                          -- Active only *strictly before* this phase
                     | ActiveAfter SourceText PhaseNum
                           -- Active in this phase and later
                     deriving( Eq, Data, Typeable )
                               -- Eq used in comparing rules in HsDecls

     data Fixity = Fixity SourceText Int FixityDirection
       -- Note [Pragma source text]
       deriving (Data, Typeable)


      | HsTickPragma         -- A pragma introduced tick
         SourceText           -- Note [Pragma source text] in BasicTypes
                                          -- external span for this tick
            -- Source text for the four integers used in the span.
            -- See note [Pragma source text] in BasicTypes
         (LHsExpr id)

Updates haddock submodule

Test Plan: ./validate

Reviewers: goldfire, bgamari, austin

Reviewed By: bgamari

Subscribers: thomie, mpickering

Differential Revision:

GHC Trac Issues: #11430

4 years agoFix some typos
Rik Steenkamp [Sat, 16 Jan 2016 12:18:53 +0000 (13:18 +0100)] 
Fix some typos

Differential Revision:

4 years agoFix #11405.
Richard Eisenberg [Thu, 14 Jan 2016 22:48:42 +0000 (17:48 -0500)] 
Fix #11405.

This adds a new variant of AbsBinds that is used solely for bindings
with a type signature. This allows for a simpler desugaring that
does not produce the bogus output that tripped up Core Lint in
ticket #11405. Should make other desugarings simpler, too.

4 years agoFix typo in error message (#11409)
Richard Eisenberg [Tue, 12 Jan 2016 02:29:23 +0000 (21:29 -0500)] 
Fix typo in error message (#11409)

4 years agoTiny refactoring in TcUnify
Richard Eisenberg [Tue, 12 Jan 2016 02:28:24 +0000 (21:28 -0500)] 
Tiny refactoring in TcUnify

4 years agoFix #11404
Richard Eisenberg [Mon, 11 Jan 2016 21:47:22 +0000 (16:47 -0500)] 
Fix #11404

We now check for unused variables one at a time, instead of
all at the top.

Test: dependent/should_compile/T11405

4 years agoConstrained types have kind * in validity check.
Richard Eisenberg [Mon, 11 Jan 2016 20:28:48 +0000 (15:28 -0500)] 
Constrained types have kind * in validity check.

This addresses #11405, but a deeper problem lurks.
Try test dependent/should_compile/T11405 and see comment:3
on the ticket.

4 years agoFix #11254.
Richard Eisenberg [Mon, 11 Jan 2016 19:47:49 +0000 (14:47 -0500)] 
Fix #11254.

This moves the call to tcSubType into the context of the
checkInstConstraints call, allowing the deferred type error
somewhere to hang its hat.

4 years agoClarify topological sorting of spec vars in manual
Richard Eisenberg [Mon, 11 Jan 2016 00:10:03 +0000 (19:10 -0500)] 
Clarify topological sorting of spec vars in manual

This is mentioned in #11376.

4 years agoFix #11311
Richard Eisenberg [Mon, 11 Jan 2016 22:03:47 +0000 (17:03 -0500)] 
Fix #11311

All things of kind *, including * itself, need to have a PtrRep.

Test: dependent/should_compile/T11311

4 years agoFix #10872.
Richard Eisenberg [Sat, 9 Jan 2016 21:59:05 +0000 (16:59 -0500)] 
Fix #10872.

This moves the duplicate-unique check from knownKeyNames (which omits
TH) to allKnownKeyNames (which includes TH).

4 years agoTest #11252 in ghci/scripts/T11252
Richard Eisenberg [Sat, 9 Jan 2016 16:26:14 +0000 (11:26 -0500)] 
Test #11252 in ghci/scripts/T11252

This one worked for me out of the box.

4 years agoFix #11355.
Richard Eisenberg [Sat, 9 Jan 2016 16:18:53 +0000 (11:18 -0500)] 
Fix #11355.

Previously, the check for impredicative type applications was
in the wrong spot.

Test case: typecheck/should_fail/T11355

4 years agoExpand type/kind synonyms in TyVars before deriving-related typechecking
RyanGlScott [Fri, 15 Jan 2016 16:42:02 +0000 (17:42 +0100)] 
Expand type/kind synonyms in TyVars before deriving-related typechecking

Before, it was possible to have a datatypes such as

type ConstantT a b = a
newtype T (f :: * -> *) (a :: ConstantT * f) = T (f a) deriving Functor

data family TFam (f :: * -> *) (a :: *)
newtype instance TFam f (ConstantT a f) = TFam (f a) deriving Functor

fail to eta-reduce because either (1) a TyVar had a kind synonym that
mentioned another TyVar, or (2) an instantiated type was itself a type
synonym that mentioned another TyVar. A little bit of tweaking to
`expandTypeSynonyms` and applying it before the eta-reduction check in
the `deriving` machinery is sufficient to fix this.

Fixes #11416.

Test Plan: ./validate

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11416

4 years agoAllow pattern synonyms which have several clauses.
Matthew Pickering [Fri, 15 Jan 2016 16:40:51 +0000 (17:40 +0100)] 
Allow pattern synonyms which have several clauses.

But still disallow empty pattern synonym builder declarations. Handling
this incorrectly was the cause of #11367.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11367

4 years Export MAKECMD to build system
Karel Gardas [Fri, 15 Jan 2016 16:38:41 +0000 (17:38 +0100)] Export MAKECMD to build system

Reviewers: austin, bgamari, thomie

Reviewed By: thomie

Subscribers: angerman, thomie, erikd

Differential Revision:

4 years agoRefactor lookupFixityRn-related code following D1744
RyanGlScott [Fri, 15 Jan 2016 15:37:18 +0000 (16:37 +0100)] 
Refactor lookupFixityRn-related code following D1744

Test Plan: ./validate

Reviewers: goldfire, austin, bgamari, simonpj

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #11345

4 years agoDon't output manpage in same directory as source
Ben Gamari [Fri, 15 Jan 2016 15:35:38 +0000 (16:35 +0100)] 
Don't output manpage in same directory as source

Test Plan: Validate

Reviewers: austin, thomie, nomeata

Differential Revision:

GHC Trac Issues: #11433

4 years agoUse XZ compression by default
Ben Gamari [Fri, 15 Jan 2016 14:19:10 +0000 (15:19 +0100)] 
Use XZ compression by default

Resolves #11434.

4 years agoLink command line libs to temp so
Peter Trommler [Fri, 15 Jan 2016 12:25:38 +0000 (13:25 +0100)] 
Link command line libs to temp so

Symbols in libraries specified on the GHCis command line are
not available to compiled modules because shared libraries
are loaded with local scope. So we link all libraries specified
on the command line into each temporary shared library.

Test Plan: validate

Reviewers: simonmar, hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10458

4 years agousers-guide: Fix cabal version number
Ben Gamari [Fri, 15 Jan 2016 12:16:51 +0000 (13:16 +0100)] 
users-guide: Fix cabal version number

4 years agouser-guide: Note Cabal version limitation
Ben Gamari [Thu, 14 Jan 2016 14:46:31 +0000 (15:46 +0100)] 
user-guide: Note Cabal version limitation

4 years agoANNOUNCE: Mention powerpc code generator
Ben Gamari [Thu, 14 Jan 2016 14:38:49 +0000 (15:38 +0100)] 
ANNOUNCE: Mention powerpc code generator

4 years agoFix #11015 with a nice note.
Edward Z. Yang [Thu, 14 Jan 2016 00:10:11 +0000 (16:10 -0800)] 
Fix #11015 with a nice note.

Signed-off-by: Edward Z. Yang <>
Test Plan: doc only

Reviewers: bgamari, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11015

4 years agoRemove lookup of sections by name instead use the index numbers as offsets
Tamar Christina [Tue, 12 Jan 2016 19:34:25 +0000 (20:34 +0100)] 
Remove lookup of sections by name instead use the index numbers as offsets

This patch comes from @awson

Playing with `-fsplit-sections` on Windows I've found a pile of ancient
(it was borrowed from Hugs interpreter code and I don't even know when
was it created), absolutely redundant and plain wrong code in RTS linker.

Technically it is a bug, but it doesn't break things when used with
current Windows binutils with no special linker scripts involved.

OTOH, it slows down runtime linker on Windows noticeably and thus can
be considered as a performance bug.

The nice side-effect for existing users is that GHCi now loads compiled
object code much faster on Windows.

More specifically, sections were being looked up by name by doing a loop
over all sections until the section with the given name is found.

The new approach uses the section index and finds the section in O(1) time
based on information gathered when we originally processed the section

Test Plan: ./validate (was run on GHC x86)

Reviewers: austin, awson, erikd, thomie, bgamari

Reviewed By: thomie, bgamari

Subscribers: awson, #ghc_windows_task_force

Differential Revision:

GHC Trac Issues: #11388

4 years agoT11300: Fix test on windows
Tamar Christina [Sun, 10 Jan 2016 06:20:57 +0000 (07:20 +0100)] 
T11300: Fix test on windows

Summary: Fix exit code for Windows to match expected for out-of-memory test

Test Plan: ./validate

Reviewers: simonmar, austin, thomie, bgamari

Reviewed By: thomie, bgamari

Differential Revision:

GHC Trac Issues: #11422

4 years agoAPI Annotations: use AnnValue for (~)
Alan Zimmerman [Thu, 14 Jan 2016 18:46:35 +0000 (20:46 +0200)] 
API Annotations: use AnnValue for (~)

Previously oqtycon used AnnTilde for the location of the RdrName when
parsing (~).

The recent increase in '~' characters in the AST confuses
ghc-exactprint, so this patch treats all RdrNames the same way now,
marking the location of the core name with AnnValue.