19 months agoRemove incorrect comment
Simon Jakobi [Sat, 26 May 2018 23:03:58 +0000 (01:03 +0200)] 
Remove incorrect comment

Moving fingerprintByteString to GHC.Fingerprint would require
adding a dependency on bytestring to base.

19 months agoImprove the documentation of lexically scoped type variables
AntC [Sat, 19 May 2018 07:23:39 +0000 (19:23 +1200)] 
Improve the documentation of lexically scoped type variables

Section 10.16 in the Users Guide. Also reviewed mentions/links from
other sections: none need revision.

Fixes #15146.

19 months agoUpdate repository sub-dir for ghc-heap in
Alp Mestanogullari [Sun, 27 May 2018 15:13:37 +0000 (11:13 -0400)] 
Update repository sub-dir for ghc-heap in

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agoFix validate for GHCi without TABLES_NEXT_TO_CODE
Peter Trommler [Sun, 27 May 2018 15:11:37 +0000 (11:11 -0400)] 
Fix validate for GHCi without TABLES_NEXT_TO_CODE

Suppress warning about unused match.

Fixes #15187

Reviewers: bgamari, simonmar, erikd, hvr

Reviewed By: bgamari, simonmar

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agollvm-targets: Add versioned ARM targets
Guillaume GARDET [Fri, 18 May 2018 06:56:28 +0000 (08:56 +0200)] 
llvm-targets: Add versioned ARM targets

Namely armv6l-unknown-linux-gnueabihf and

19 months agoMove printMutableList to Printer.c next to other printers
Ömer Sinan Ağacan [Wed, 30 May 2018 10:02:53 +0000 (13:02 +0300)] 
Move printMutableList to Printer.c next to other printers

19 months agoHandle TREC_CHUNK in printClosure
Ömer Sinan Ağacan [Wed, 30 May 2018 08:55:02 +0000 (11:55 +0300)] 
Handle TREC_CHUNK in printClosure

19 months agotestsuite: Use /usr/bin/env instead of /bin/bash
Ben Gamari [Tue, 29 May 2018 21:37:01 +0000 (17:37 -0400)] 
testsuite: Use /usr/bin/env instead of /bin/bash

Namely in T13719 and T13701.

19 months agotestsuite: Fix incorrectly capitalized True in
Ben Gamari [Tue, 29 May 2018 21:36:13 +0000 (17:36 -0400)] 
testsuite: Fix incorrectly capitalized True in

19 months agoUnmask readMVar in readChan
David Feuer [Tue, 29 May 2018 20:51:16 +0000 (16:51 -0400)] 
Unmask readMVar in readChan

When `readMVar` was implemented using `takeMVar` and `putMVar`,
we needed to use `modifyMVarMasked` in `readChan` just in case
the `readMVar` was interrupted between taking and putting. Now
that `readMVar` uses an atomic primop, this is impossible, so we can
safely unmask `readMVar`.

Reviewers: hvr, bgamari, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agobase: Improve zip documentation
Taylor Fausak [Tue, 22 May 2018 13:29:43 +0000 (09:29 -0400)] 
base: Improve zip documentation

19 months agoUse a less confusing type variable in a few types
Simon Jakobi [Mon, 21 May 2018 18:04:07 +0000 (20:04 +0200)] 
Use a less confusing type variable in a few types

19 months agoMinor refactoring
Gabor Greif [Tue, 29 May 2018 10:16:23 +0000 (12:16 +0200)] 
Minor refactoring

19 months agoTypofix in manual [ci skip]
Gabor Greif [Tue, 29 May 2018 10:15:18 +0000 (12:15 +0200)] 
Typofix in manual [ci skip]

19 months agoremove dead maybeIsLFCon
Gabor Greif [Mon, 28 May 2018 12:14:59 +0000 (14:14 +0200)] 
remove dead maybeIsLFCon

19 months agoTypofixes [ci skip]
Gabor Greif [Fri, 25 May 2018 13:33:21 +0000 (15:33 +0200)] 
Typofixes [ci skip]

19 months agoFactor stack chunk printing out of printTSO
Ömer Sinan Ağacan [Tue, 29 May 2018 07:36:16 +0000 (10:36 +0300)] 
Factor stack chunk printing out of printTSO

Makes it possible to print STACK (StgStack) objects easily in gdb

19 months agoClean up Windows testsuite failures
Tamar Christina [Mon, 28 May 2018 18:34:11 +0000 (19:34 +0100)] 
Clean up Windows testsuite failures

Another round and attempt at getting these down to 0.

We really should re-enable the CI and not wait for those cloud based ones.

I've disabled the backpack tests on windows as they are too broad, they test
as much the shell as they do the compiler.

The perf tests have been too long to track down. but the numbers are horrible
but I don't see them getting fixed so just have to accept them.

T9293 has new windows specific output because a Dyn way only flag was added.
This will of course not work on non-Dyn way builds.

Test Plan: ./validate

Reviewers: bgamari, hvr, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15107

Differential Revision:

19 months agoFix 32 bit windows build
Tamar Christina [Mon, 28 May 2018 18:19:18 +0000 (19:19 +0100)] 
Fix 32 bit windows build

Fix a number of issues that have broken the 32 bit build.
This makes it build again.

Test Plan: ./validate

Reviewers: hvr, goldfire, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agoUpdate GHC.Stats docs
Ömer Sinan Ağacan [Mon, 28 May 2018 06:59:55 +0000 (09:59 +0300)] 
Update GHC.Stats docs

Make it clear that max_live_bytes is updated after a major GC whereas
live_bytes is updated after all GCs (including minor collections) and
considers data in uncollected generations as live.

Reviewers: bgamari, simonmar, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agobase: Introduce Data.Monoid.Ap
chessai [Wed, 11 Apr 2018 22:28:41 +0000 (18:28 -0400)] 
base: Introduce Data.Monoid.Ap

This data type witnesses the lifting of a monoid into an applicative

20 months agoMark #12447's test case as expected to pass
Ryan Scott [Sat, 26 May 2018 16:38:08 +0000 (12:38 -0400)] 
Mark #12447's test case as expected to pass

This appears to have been fixed at some point between GHC 8.0 and

20 months agoAdd regression test for #14246
Ryan Scott [Sat, 26 May 2018 15:58:03 +0000 (11:58 -0400)] 
Add regression test for #14246

20 months agoAdd regression test for #14172
Ryan Scott [Sat, 26 May 2018 15:39:26 +0000 (11:39 -0400)] 
Add regression test for #14172

Commit 433b80dec1cfef787fc1327a9eada1791b11c12e fixed #14172. Let's
add a regression test to ensure that it stays fixed.

20 months agoAdd regression test for #11766
Ryan Scott [Sat, 26 May 2018 14:29:22 +0000 (10:29 -0400)] 
Add regression test for #11766

20 months agotestsuite: Don't rely on find command in T15038
Ben Gamari [Sat, 26 May 2018 08:04:18 +0000 (11:04 +0300)] 
testsuite: Don't rely on find command in T15038

Test Plan: Validate

Reviewers: int-index, osa1

Reviewed By: osa1

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15038

Differential Revision:

20 months agoComments about the substition invariant
Simon Peyton Jones [Fri, 25 May 2018 11:23:43 +0000 (12:23 +0100)] 
Comments about the substition invariant

20 months agoisDllName: use Opt_ExternalDynamicRefs, not WayDyn
Simon Marlow [Thu, 24 May 2018 10:18:48 +0000 (11:18 +0100)] 
isDllName: use Opt_ExternalDynamicRefs, not WayDyn

This should have been part of D4477, but got missed.

20 months agoAdd -fghci-leak-check to check for space leaks
Simon Marlow [Wed, 2 May 2018 10:01:13 +0000 (11:01 +0100)] 
Add -fghci-leak-check to check for space leaks

(re-applying this patch now that D4659 is committed)

Space leaks in GHCi emerge from time to time and tend to come back again
after they get fixed. This is an attempt to limit regressions by

* adding a reliable detection for some classes of space leaks in GHCi
* turning on leak checking for all GHCi tests in the test suite, so that
  we'll notice if the leak appears again.

The idea for detecting space leaks is quite simple:

* find some data that we expect to be GC'd later, make a weak pointer to it
* when we expect the data to be dead, do a `performGC` and then check
  the status of the weak pointer.

It would be nice to apply this trick to lots of things in GHC,
e.g. ensuring that HsSyn is not retained after the desugarer, or
ensuring that CoreSyn from the previous simplifier pass is not retained.

Test Plan: validate

Reviewers: bgamari, simonpj, erikd, niteria

Subscribers: thomie, carter

GHC Trac Issues: #15111

20 months agoMinor typos
Ryan Scott [Thu, 24 May 2018 14:37:35 +0000 (10:37 -0400)] 
Minor typos

20 months agoClean up the conflicting data family instances error message
Ryan Scott [Thu, 24 May 2018 14:33:51 +0000 (10:33 -0400)] 
Clean up the conflicting data family instances error message

The way we were pretty-printing conflicting data family
instances in an error message was far from ideal:

1. If a data type had no constructors, it would print an equals sign
   with nothing to the right of it.
2. It would try to print GADTs using Haskell98 syntax.
3. It eta-reduced away some type variables from the LHS.

This patch addresses these three issues:

1. We no longer print constructors at all in this error message.
   There's really no reason to do so in the first place, since
   duplicate data family instances always conflict, regardless of
   their constructors.
2. Since we no longer print constructors, we no longer have to
   worry about whether we're using GADT or Haskell98 syntax.
3. I've put in a fix to ensure that type variables are no longer
   eta-reduced away from the LHS.

Test Plan: make test TEST=T14179

Reviewers: goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14179

Differential Revision:

20 months agoCheck for mismatched class methods during typechecking
Ryan Scott [Thu, 24 May 2018 14:31:28 +0000 (10:31 -0400)] 
Check for mismatched class methods during typechecking

Template Haskell provides a wormhole through which you can
sneak methods that don't belong to a class into an instance for that
class, bypassing the renamer's validity checks. The solution adopted
here is to mirror the treatment for associated type family instances,
which have an additional check in the typechecker which catch
mismatched associated type families that were snuck through using
Template Haskell. I've put a similar check for class methods into

Test Plan: make test TEST=T12387

Reviewers: bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #12387

Differential Revision:

20 months agotestsuite: Bump OS X performance numbers
Ben Gamari [Thu, 24 May 2018 13:59:43 +0000 (09:59 -0400)] 
testsuite: Bump OS X performance numbers

Sadly I can't easily determine the cause of T13701's regression since the tree
was broken.

20 months agoDisable the SRT offset optimisation on MachO platforms
Ben Gamari [Tue, 22 May 2018 13:36:35 +0000 (09:36 -0400)] 
Disable the SRT offset optimisation on MachO platforms

Unfortunately, this optimisation is infeasible on MachO platforms (e.g.
Darwin) due to an object format limitation. Specifically, linking fails
with errors of the form:

     error: unsupported relocation with subtraction expression, symbol
     '_integerzmgmp_GHCziIntegerziType_quotInteger_closure' can not be
     undefined in a subtraction expression

Apparently MachO does not permit relocations' subtraction expressions to
refer to undefined symbols. As far as I can tell this means that it is
essentially impossible to express an offset between symbols living in
different compilation units. This means that we lively can't use this
optimisation on MachO platforms.

Test Plan: Validate on Darwin

Reviewers: simonmar, erikd

Subscribers: rwbarton, thomie, carter, angerman

GHC Trac Issues: #15169

Differential Revision:

20 months agoFix a bug in SRT generation
Simon Marlow [Tue, 22 May 2018 14:19:55 +0000 (15:19 +0100)] 
Fix a bug in SRT generation

I had good intentions, but they were not being followed. In particular,
this comment:

---  - we never resolve a reference to a CAF to the contents of its SRT, since
---    the point of SRTs is to keep CAFs alive.

was not true, because we updated the srtMap after generating the SRT
for a CAF. Therefore it was possible for another CAF to refer to an
earlier CAF, and the reference to the earlier CAF would be shortcutted
to refer to its SRT instead of pointing to the CAF itself.

The fix is just to not update the srtMap when generating the SRT for a
CAF, but I also refactored the code and comments around this to be a bit
better organised.

Test Plan: Harbourmaster

Reviewers: bgamari, michalt, simonpj, erikd

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15173, #15168

Differential Revision:

20 months agoUse dischargeFunEq consistently
Simon Peyton Jones [Wed, 23 May 2018 12:06:53 +0000 (13:06 +0100)] 
Use dischargeFunEq consistently

Trac #15122 turned out to be interesting.

* Were calling dischargeFmv in three places.

* In all three cases we dealt with the Given case

* In two of the three cases the Given code was right,
  (albeit duplicated).

* In the third case (in TcCanonical.canCFunEqCan), we had
     ; case flav of
         Given -> return () -- nothing more to do.
  which was utterly wrong.

The solution is easy: move the Given-case handling into
dischargeFmv (now reenamed dischargeFunEq), and delete it
from the call sites.

Result: less code, easier to understand (dischargeFunEq handles
all three cases, not just two out of three), and Trac #15122 is fixed.

20 months agoDon't expose strictness when sm_inline is False
Simon Peyton Jones [Wed, 23 May 2018 12:30:21 +0000 (13:30 +0100)] 
Don't expose strictness when sm_inline is False

This is very much a corner case, but Trac #15163 showed
that if you have a RULE like
    forall x. f (g x) = ..x..

and g = undefined, then the simplifier is likely to discard
that 'x' argument. It is usually right to do so; but not here
because then x is used on the right but not bound on the left.

The fix is a narrow one, aimed at this rather pathalogical case.
See Note [Do not expose strictness if sm_inline=False] in

20 months agoAdd missing check to isReflCoVar_maybe
Simon Peyton Jones [Wed, 23 May 2018 12:19:33 +0000 (13:19 +0100)] 
Add missing check to isReflCoVar_maybe

isReflCoVar_maybe is called, by CoreLint, on all sorts of
Vars (tyvars, term vars, coercion vars).  But it was silently
assuming that it was always called on a CoVar, and as a result
could crash fatally.  This is the immediate cause of the panic
in Trac #15163.

It's easy to fix.

NB: this does not completely fix Trac #15163; more to come

20 months agoRemove special case from TcTyVar level check
Simon Peyton Jones [Wed, 23 May 2018 12:14:50 +0000 (13:14 +0100)] 
Remove special case from TcTyVar level check

In TcMType.writeMetaTyVarRef we have an assertion
check, level_check_ok, that the type being written
to a unification variable is not deeper than the level
of the unification varaible itself.

This check used to have a special case for fmv/fsk
flatten vars, but this commit changed fmv/fsks to have
an ordinary level number:

    commit 2bbdd00c6d70bdc31ff78e2a42b26159c8717856
    Author: Simon Peyton Jones <>
    Date:   Fri May 18 08:43:11 2018 +0100

    Orient TyVar/TyVar equalities with deepest on the left

So we can delete the isFlattenTyVar special case from
the level_check_ok assertion.  Simpler, less ad hoc.

20 months agoTypo in comments
Gabor Greif [Wed, 7 Feb 2018 15:54:38 +0000 (16:54 +0100)] 
Typo in comments

20 months agoImprove performance of CallArity
Joachim Breitner [Mon, 21 May 2018 15:24:05 +0000 (11:24 -0400)] 
Improve performance of CallArity

the hot path contained a call to

    v `elemUnVarSet` (neighbors g v)

and creating the set of neighbors just to check if `v` is inside
accounted for half the allocations of the test case of #15164.

By introducing a non-allocating function `hasLoopAt` for this we shave
off half the allocations. This brings the total cost of Call Arity down
to 20% of time and 23% of allocations, according to a profiled run. Not
amazing, but still much better.

Differential Revision:

20 months agoRevert "ghc-pkg: recompute `abi-depends` for updated packages"
Ben Gamari [Mon, 21 May 2018 20:37:31 +0000 (16:37 -0400)] 
Revert "ghc-pkg: recompute `abi-depends` for updated packages"

This reverts commit 1cdc14f9c014f1a520638f7c0a01799ac6d104e6.

This is causing non-deterministic testsuite output.

20 months agoCheck for type families in an instance context
Simon Peyton Jones [Mon, 21 May 2018 12:38:12 +0000 (13:38 +0100)] 
Check for type families in an instance context

This patch adds a check for type families to the instance-decl
termination check.  See Note [Type families in instance contexts]
and Trac #15172.

20 months agoMake dischargeFmv handle Deriveds
Simon Peyton Jones [Mon, 21 May 2018 09:38:03 +0000 (10:38 +0100)] 
Make dischargeFmv handle Deriveds

A Derived CFunEqCan does not "own" its FlatMetaTv (fmv), and should not
update it.  But one caller (canCFunEqCan) was failing to satisfy the
precondition to dischargeFmv, which led to a crash (Trac #15170).

I fixed this by making dischargeFmv handle Deriveds (to avoid forcing
each caller to do so separately).

NB: this does not completely fix the original #15170 bug, but I'll
explain that on the ticket.  The test case for this patch is actually
the program in comment:1.

20 months agoRemove TcType.toTcType
Simon Peyton Jones [Mon, 21 May 2018 08:00:32 +0000 (09:00 +0100)] 
Remove TcType.toTcType

In the olden days we insisted that only TcTyVars could appear
in a TcType.  But now we are more accommodating; see TcType
  Note [TcTyVars and TyVars in the typechecker]

This patch removes a function that converted a Type to a TcType.
It didn't do anything useful except statisfy an invariant that
we no longer have.  Now it's gone.

20 months agoFix perf numbers for #15164
Simon Peyton Jones [Mon, 21 May 2018 10:02:57 +0000 (11:02 +0100)] 
Fix perf numbers for #15164

20 months agoDo better sharing in the short-cut solver
Simon Peyton Jones [Sun, 20 May 2018 20:43:45 +0000 (21:43 +0100)] 
Do better sharing in the short-cut solver

Trac #15164 showed that it sometimes really matters to share
sub-proofs when solving constraints.  Without it, we can get
exponentialy bad behaviour.

Fortunately, it's easily solved.
Note [Shortcut try_solve_from_instance] explains.

I did some minor assocaited refactoring.

20 months agoghc-pkg: recompute `abi-depends` for updated packages
Austin Seipp [Sun, 20 May 2018 17:25:09 +0000 (13:25 -0400)] 
ghc-pkg: recompute `abi-depends` for updated packages

See `Note [Recompute abi-depends]` for more information.

Signed-off-by: Austin Seipp <>
Test Plan: `./validate`

Reviewers: bgamari, ezyang

Reviewed By: bgamari

Subscribers: tdammers, juhp, carter, alexbiehl, shlevy, cocreature,
rwbarton, thomie

GHC Trac Issues: #14381

Differential Revision:

20 months agoghc-prim: Bump version
Ben Gamari [Sun, 20 May 2018 23:47:43 +0000 (19:47 -0400)] 
ghc-prim: Bump version

unpackClosure#'s behavior and type has changed. This caused a CPP guard
in the new ghc-heap package to fail when bootstrapping with GHC 8.4.

Test Plan: Validate bootstrapping with GHC 8.4

Reviewers: RyanGlScott

Subscribers: rwbarton, thomie, carter

Differential Revision:

20 months agoAdd HeapView functionality
Patrick Dougherty [Wed, 16 May 2018 20:50:13 +0000 (16:50 -0400)] 
Add HeapView functionality

This pulls parts of Joachim Breitner's ghc-heap-view library inside GHC.
The bits added are the C hooks into the RTS and a basic Haskell wrapper
to these C hooks. The main reason for these to be added to GHC proper
is that the code needs to be kept in sync with the closure types
defined by the RTS. It is expected that the version of HeapView shipped
with GHC will always work with that version of GHC and that extra
functionality can be layered on top with a library like ghc-heap-view
distributed via Hackage.

Test Plan: validate

Reviewers: simonmar, hvr, nomeata, austin, Phyx, bgamari, erikd

Reviewed By: bgamari

Subscribers: carter, patrickdoc, tmcgilchrist, rwbarton, thomie

Differential Revision:

20 months agorts: Fix compaction of SmallMutArrPtrs
Ben Gamari [Sat, 19 May 2018 18:00:59 +0000 (14:00 -0400)] 
rts: Fix compaction of SmallMutArrPtrs

This was blatantly wrong due to copy-paste blindness:

 * labels were shadowed, which GHC doesn't warn about(!), resulting in
   plainly wrong behavior
 * the sharing check was omitted
 * the wrong closure layout was being used

Moreover, the test wasn't being run due to its primitive dependency, so
I didn't even notice. Sillyness.

Test Plan: install `primitive`, `make test TEST=compact_small_array`

Reviewers: simonmar, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13857.

Differential Revision:

20 months agoAnother batch of './validation --slow' tweaks
Alp Mestanogullari [Sat, 19 May 2018 18:00:21 +0000 (14:00 -0400)] 
Another batch of './validation --slow' tweaks

This finally gets us to a green ./validate --slow on linux for a ghc
checkout from the beginning of this week, see

This is hopefully the final (or second to final) patch to
address #14890.

Test Plan: ./validate --slow

Reviewers: bgamari, hvr, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14890

Differential Revision:

20 months agobase: Fix typo
Ben Gamari [Thu, 17 May 2018 03:44:34 +0000 (23:44 -0400)] 
base: Fix typo

20 months agobase: Add Foldable and Traversable instances for Alt
Jack Henahan [Wed, 16 May 2018 20:39:15 +0000 (16:39 -0400)] 
base: Add Foldable and Traversable instances for Alt

Add Foldable and Traversable instances for Data.Monoid.Alt

Signed-off-by: Jack Henahan <>
Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: mpickering, rwbarton, thomie, carter

GHC Trac Issues: #15099

Differential Revision:

20 months agoFix retainer profiling after SRT overhaul
Simon Marlow [Sat, 19 May 2018 05:43:52 +0000 (08:43 +0300)] 
Fix retainer profiling after SRT overhaul

Recent changes to SRTs (D4632, D4637) also required changes to
RetainerProfile.c. This should hopefully get things working again.

Test Plan: validate with profiling turned on

Reviewers: bgamari, osa1, tdammers, erikd

Subscribers: rwbarton, thomie, carter

Differential Revision:

20 months agoDo not unify representational equalities
Simon Peyton Jones [Fri, 18 May 2018 12:58:25 +0000 (13:58 +0100)] 
Do not unify representational equalities

This patch is an easy fix to Trac #15144, which was caused
by accidentally unifying a representational equality in the
unflattener.  (The main code in TcInteract was always careful
not to do so, but I'd missed the test in the unflattener.)

See Note [Do not unify representational equalities]
in TcInteract

20 months agoDebug tracing only
Simon Peyton Jones [Fri, 18 May 2018 07:47:26 +0000 (08:47 +0100)] 
Debug tracing only

20 months agoOrient TyVar/TyVar equalities with deepest on the left
Simon Peyton Jones [Fri, 18 May 2018 07:43:11 +0000 (08:43 +0100)] 
Orient TyVar/TyVar equalities with deepest on the left

Trac #15009 showed that, for Given TyVar/TyVar equalities, we really
want to orient them with the deepest-bound skolem on the left. As it
happens, we also want to do the same for Wanteds, but for a different
reason (more likely to be touchable).  Either way, deepest wins:
see TcUnify Note [Deeper level on the left].

This observation led me to some significant changes:

* A SkolemTv already had a TcLevel, but the level wasn't really being
  used.   Now it is!

* I updated added invariant (SkolInf) to TcType
  Note [TcLevel and untouchable type variables], documenting that
  the level number of all the ic_skols should be the same as the
  ic_tclvl of the implication

* FlatSkolTvs and FlatMetaTvs previously had a dummy level-number of
  zero, which messed the scheme up.   Now they get a level number the
  same way as all other TcTyVars, instead of being a special case.

* To make sure that FlatSkolTvs and FlatMetaTvs are untouchable (which
  was previously done via their magic zero level) isTouchableMetaTyVar
  just tests for those two cases.

* TcUnify.swapOverTyVars is the crucial orientation function; see the
  new Note [TyVar/TyVar orientation].  I completely rewrote this function,
  and it's now much much easier to understand.

I ended up doing some related refactoring, of course

* I noticed that tcImplicitTKBndrsX and tcExplicitTKBndrsX were doing
  a lot of useless work in the case where there are no skolems; I
  added a fast-patch

* Elminate the un-used tcExplicitTKBndrsSig; and thereby get rid of
  the higher-order parameter to tcExpliciTKBndrsX.

* Replace TcHsType.emitTvImplication with TcUnify.checkTvConstraints,
  by analogy with TcUnify.checkConstraints.

* Inline TcUnify.buildImplication into its only call-site in

* TcS.buildImplication becomes TcS.CheckConstraintsTcS, with a
  simpler API

* Now that we have NoEvBindsVar we have no need of termEvidenceAllowed;
  nuke the latter, adding Note [No evidence bindings] to TcEvidence.

20 months agoTiny refactor
Simon Peyton Jones [Thu, 10 May 2018 16:30:43 +0000 (17:30 +0100)] 
Tiny refactor

20 months agoComments only
Simon Peyton Jones [Thu, 10 May 2018 16:30:09 +0000 (17:30 +0100)] 
Comments only

20 months agoAdd regression tests for #11515 and #12563
Ryan Scott [Fri, 18 May 2018 15:50:07 +0000 (11:50 -0400)] 
Add regression tests for #11515 and #12563

Happily, both of these issues appear to have been fixed in GHC 8.2.
Let's add regression tests for them to ensure that they stay fixed.

20 months agoFix unwinding of C -> Haskell FFI calls with -threaded (2nd try)
Bartosz Nitka [Thu, 17 May 2018 15:06:33 +0000 (08:06 -0700)] 
Fix unwinding of C -> Haskell FFI calls with -threaded (2nd try)

See the new note.
This should fix cb5c2fe875965b7aedbc189012803fc62e48fb3f enough
to unbreak Windows and OS X builds.

Test Plan: manual testing with patched gdb

Reviewers: bgamari, simonmar, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

20 months agoFix GHCi space leaks (#15111)
Simon Marlow [Tue, 1 May 2018 15:52:05 +0000 (16:52 +0100)] 
Fix GHCi space leaks (#15111)

There were a number of leaks causing previously loaded modules to be
retained after a new `:load`.  This fixes enough leaks to get the
tests to pass from D4658.

Test Plan: See new tests in D4658

Reviewers: niteria, bgamari, simonpj, erikd

Subscribers: thomie, carter

GHC Trac Issues: #15111

Differential Revision:

20 months agoAdd /* fallthrough */ to fix -Wimplicit-fallthrough warning
Simon Marlow [Thu, 17 May 2018 08:04:05 +0000 (09:04 +0100)] 
Add /* fallthrough */ to fix -Wimplicit-fallthrough warning

20 months agoUpdate Cabal submodule
Simon Marlow [Thu, 17 May 2018 07:48:40 +0000 (08:48 +0100)] 
Update Cabal submodule

20 months agoComments and refactoring only
Simon Marlow [Wed, 16 May 2018 13:03:55 +0000 (14:03 +0100)] 
Comments and refactoring only

Addressing review comments on D4637

20 months agoFix #15073 by suggesting UnboxedTuples in an error message
Ryan Scott [Wed, 16 May 2018 16:59:45 +0000 (12:59 -0400)] 
Fix #15073 by suggesting UnboxedTuples in an error message

Under certain circumstances, `GeneralizedNewtypeDeriving`
can emit code which uses unboxed tuple types, but if `UnboxedTuples`
wasn't enabled, the error message that GHC gave didn't make it very
clear that it could be worked around by explicitly enabling the
extension. Easily fixed.

Test Plan: make test TEST=T15073

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: simonpj, thomie, carter

GHC Trac Issues: #15073

Differential Revision:

20 months agoImprove numeric stability of numericEnumFrom for floating numbers
HE, Tao [Wed, 16 May 2018 16:13:16 +0000 (12:13 -0400)] 
Improve numeric stability of numericEnumFrom for floating numbers

Fixes #15081.

Test Plan: cd libraries/base && make test TEST="enumNumeric"

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: dfeuer, simonpj, thomie, carter

GHC Trac Issues: #15081

Differential Revision:

20 months agoFix #15039 by pretty-printing equalities more systematically
Ryan Scott [Wed, 16 May 2018 16:11:37 +0000 (12:11 -0400)] 
Fix #15039 by pretty-printing equalities more systematically

GHC previously had a handful of special cases for
pretty-printing equalities in a more user-friendly manner, but they
were far from comprehensive (see #15039 for an example of where this
fell apart).

This patch makes the pretty-printing of equalities much more
systematic. I've adopted the approach laid out in, and updated
`Note [Equality predicates in IfaceType]` accordingly. We are now
more careful to respect the properties of the
`-fprint-explicit-kinds` and `-fprint-equality-relations` flags,
which led to some improvements in error message outputs.

Along the way, I also tweaked the error-reporting machinery not to
print out the type of a typed hole when the type is an unlifted
equality, since it's kind (`TYPE ('TupleRep '[])`) was more
confusing than anything.

Test Plan: make test TEST="T15039a T15039b T15039c T15039d"

Reviewers: simonpj, goldfire, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15039

Differential Revision:

20 months agoAdd pprTraceM to Outputable as analog to traceM. [Wed, 16 May 2018 16:11:27 +0000 (12:11 -0400)] 
Add pprTraceM to Outputable as analog to traceM.

Test Plan: ci, using it in monadic code.

Reviewers: bgamari, mpickering

Reviewed By: mpickering

Subscribers: rwbarton, thomie, carter

Differential Revision:

20 months agoInfoTables: Fix #if uses introduced by D4634
Ben Gamari [Wed, 16 May 2018 16:15:32 +0000 (12:15 -0400)] 
InfoTables: Fix #if uses introduced by D4634

20 months agoMake finalizers more reliable.
Tamar Christina [Wed, 16 May 2018 01:20:45 +0000 (21:20 -0400)] 
Make finalizers more reliable.

Ignore any errors thrown by finalizers when running them.

This prevents a faulty finalizer from stopping the rest being called.

Test Plan: ./validate, new test T13167

Reviewers: hvr, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13167

Differential Revision:

20 months agoMerge FUN_STATIC closure with its SRT
Simon Marlow [Sun, 22 Apr 2018 18:34:32 +0000 (19:34 +0100)] 
Merge FUN_STATIC closure with its SRT

The idea here is to save a little code size and some work in the GC,
by collapsing FUN_STATIC closures and their SRTs.

This is (4) in a series; see D4632 for more details.

There's a tradeoff here: more complexity in the compiler in exchange
for a modest code size reduction (probably around 0.5%).

* GHC binary itself (statically linked) is 1% smaller
* -0.2% binary sizes in nofib (-0.5% module sizes)

Full nofib results comparing D4634 with this: P177 (ignore runtimes,
these aren't stable on my laptop)

Test Plan: validate, nofib

Reviewers: bgamari, niteria, simonpj, erikd

Subscribers: thomie, carter

Differential Revision:

20 months agoSave a word in the info table on x86_64
Simon Marlow [Sun, 22 Apr 2018 13:28:47 +0000 (14:28 +0100)] 
Save a word in the info table on x86_64

An info table with an SRT normally looks like this:

    StgWord64 srt_offset
    StgClosureInfo layout
    StgWord32 layout
    StgWord32 has_srt

But we only need 32 bits for srt_offset on x86_64, because the small
memory model requires that code segments are at most 2GB. So we can
optimise this to

    StgClosureInfo layout
    StgWord32 layout
    StgWord32 srt_offset

saving a word.  We can tell whether the info table has an SRT or not,
because zero is not a valid srt_offset, so zero still indicates that
there's no SRT.

Test Plan:
* validate
* For results, see D4632.

Reviewers: bgamari, niteria, osa1, erikd

Subscribers: thomie, carter

Differential Revision:

20 months agoAllow CmmLabelDiffOff with different widths
Simon Marlow [Sun, 22 Apr 2018 11:48:11 +0000 (12:48 +0100)] 
Allow CmmLabelDiffOff with different widths

This change makes it possible to generate a static 32-bit relative label
offset on x86_64. Currently we can only generate word-sized label

This will be used in D4634 to shrink info tables.  See D4632 for more

Test Plan: See D4632

Reviewers: bgamari, niteria, michalt, erikd, jrtc27, osa1

Subscribers: thomie, carter

Differential Revision:

20 months agoAn overhaul of the SRT representation
Simon Marlow [Mon, 26 Sep 2016 11:07:05 +0000 (12:07 +0100)] 
An overhaul of the SRT representation

- Previously we would hvae a single big table of pointers per module,
  with a set of bitmaps to reference entries within it. The new
  representation is identical to a static constructor, which is much
  simpler for the GC to traverse, and we get to remove the complicated
  bitmap-traversal code from the GC.

- Rewrite all the code to generate SRTs in CmmBuildInfoTables, and
  document it much better (see Note [SRTs]). This has been something
  I've wanted to do since we moved to the new code generator, I
  finally had the opportunity to finish it while on a transatlantic
  flight recently :)

There are a series of 4 diffs:

1. D4632 (this one), which does the bulk of the changes

2. D4633 which adds support for smaller `CmmLabelDiffOff` constants

3. D4634 which takes advantage of D4632 and D4633 to save a word in
   info tables that have an SRT on x86_64. This is where most of the
   binary size improvement comes from.

4. D4637 which makes a further optimisation to merge some SRTs with
   static FUN closures.  This adds some complexity and the benefits
   are fairly modest, so it's not clear yet whether we should do this.

Results (after (3), on x86_64)

- GHC itself (staticaly linked) is 5.2% smaller

- -1.7% binary sizes in nofib, -2.9% module sizes. Full nofib results: P176

- I measured the overhead of traversing all the static objects in a
  major GC in GHC itself by doing `replicateM_ 1000 performGC` as the
  first thing in `Main.main`.  The new version was 5-10% faster, but
  the results did vary quite a bit.

- I'm not sure if there's a compile-time difference, the results are
  too unreliable.

Test Plan: validate

Reviewers: bgamari, michalt, niteria, simonpj, erikd, osa1

Subscribers: thomie, carter

Differential Revision:

20 months agoForce findPtr to be included in the binary
Simon Marlow [Wed, 9 May 2018 12:37:30 +0000 (13:37 +0100)] 
Force findPtr to be included in the binary

Summary: A better alternative to D4657.

Test Plan:
cd testsuite/tests/codeGen/should_run
../../../../inplace/bin/ghc-stage2 -debug cgrun001
nm cgrun001 | grep findPtr

Reviewers: bgamari, Phyx, erikd

Subscribers: rwbarton, thomie, carter

Differential Revision:

20 months agoLess Tc inside simplCore (Phase 1 for #14391)
Artem Pelenitsyn [Tue, 15 May 2018 22:07:23 +0000 (18:07 -0400)] 
Less Tc inside simplCore (Phase 1 for #14391)

Simplifier depends on typechecker in two points: `thNameToGhcName`
(`lookupThName_maybe`, in particular)  and `lookupGlobal`. We want to
cut the ties in two steps.

1. (Presented in this commit), reimplement both functions in a way that
doesn't use typechecker.

2. (Should follow), do code moving: a) `lookupGlobal` should go in some
typechecker-free place; b) `thNameToGhcName` should leave simplifier,
because it is not used there at all (probably, it should be placed
somewhere where `GhcPlugins` can see it -- this is suggested by Joachim
on Trac).


We redesigned lookup interface a bit so that it exposes some
`IO`-equivalents of `Tc`-features in use.

First, `CoreMonad.hs` still calls `lookupGlobal` which is no longer
bound to the typechecker monad, but still resides in `TcEnv.hs` — it
should be moved out of Tc-land at some point (“Phase 2”) in the
future in order to achieve its part of the #14391's goal.

Second, `lookupThName_maybe` is eliminated from `CoreMonad.hs`
completely; this already achieves its part of the goal of #14391. Its
client, though, `thNameToGhcName`, is better to be moved in the future
also, for it is not used in the `CoreMonad.hs` (or anywhere else)
anyway. Joachim suggested “any module reexported by GhcPlugins (or
maybe even that module itself)”.

As a side goal, we removed `initTcForLookup` which was instrumental for
the past version of `lookupGlobal`. This, in turn, called for pushing
some more parts of the lookup interface from the `Tc`-monad to `IO`,
most notably, adding `IO`-version of `lookupOrig` and pushing
`dataConInfoPtrToName` to `IO`. The `lookupOrig` part, in turn,
triggered a slight redesign of name cache updating interface: we now
have both, `updNameCacheIO` and `updNameCacheTc`, both accepting `mod`
and `occ` to force them inside, instead of more error-prone outside
before. But all these hardly have to do anything with #14391, mere

Reviewers: simonpj, nomeata, bgamari, hvr

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14391

Differential Revision:

20 months agoAlgebraically simplify add/sub with carry/overflow
Sebastian Graf [Tue, 15 May 2018 17:12:56 +0000 (13:12 -0400)] 
Algebraically simplify add/sub with carry/overflow

Previously, the `{add,sub}{Int,Word}C#` PrimOps weren't handled
in PrelRules (constant folding and algebraic simplification) at all.
This implements the necessary logic, so that using these primitives
isn't too punishing compared to their well-optimised, overflow-unaware

This is so that using these primitives in `enumFromThenTo @Int` can
be optimized by constant folding, reducing closure sizes.

Reviewers: bgamari, simonpj, hsyl20

Reviewed By: bgamari, simonpj

Subscribers: AndreasK, thomie, carter

GHC Trac Issues: #8763

Differential Revision:

20 months agoCalling GetLastError() on Windows for socket IO (trac issue #12012)
ARJANEN Loïc Jean David [Mon, 14 May 2018 20:38:21 +0000 (16:38 -0400)] 
Calling GetLastError() on Windows for socket IO (trac issue #12012)

For the threaded RTS, putting a private copy of the throwErrno
series in GHC.IO.FD which gets if the operation was on a socket,
so that we can call c_maperrno if need be.
For the non-threaded RTS, if memory serves we call GetLastError()
in case of an error on socket IO. However, we don't do the translation
ErrCode ↔ Errno currently (and besides, it's a primop) so we do it if
needed through c_maperrno_func in the asynchronous read/write

Signed-off-by: ARJANEN Loïc Jean David <>
Reviewers: ekmett, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #12012

Differential Revision:

20 months agotestsuite: Disable T14697 on Windows
Ben Gamari [Mon, 14 May 2018 20:36:52 +0000 (16:36 -0400)] 
testsuite: Disable T14697 on Windows

Test Plan: Validate on Windows

Subscribers: thomie, carter

GHC Trac Issues: #14697, #15072

Differential Revision:

20 months agoMore explicit comment on switch in registerDelay
Kirill Zaborsky [Thu, 10 May 2018 14:57:59 +0000 (17:57 +0300)] 
More explicit comment on switch in registerDelay

20 months agoEnsure that RTS cabal file reflects dependency on libnuma
Ben Gamari [Mon, 14 May 2018 14:17:51 +0000 (10:17 -0400)] 
Ensure that RTS cabal file reflects dependency on libnuma

Test Plan: Validate with Hadrian and `libnuma` support

Reviewers: snowleopard, hvr, erikd, simonmar

Subscribers: izgzhen, alpmestan, thomie, carter

Differential Revision:

20 months agoRevert "Simplify callSiteInline a little"
Ben Gamari [Mon, 14 May 2018 13:25:32 +0000 (09:25 -0400)] 
Revert "Simplify callSiteInline a little"

This lead to some rather significant performance regressions.

    bytes allocated value is too high:
        Expected    T5631(normal) bytes allocated: 1106015512 +/-5%
        Lower bound T5631(normal) bytes allocated: 1050714736
        Upper bound T5631(normal) bytes allocated: 1161316288
        Actual      T5631(normal) bytes allocated: 1164953208
        Deviation   T5631(normal) bytes allocated:        5.3 %
    *** unexpected stat test failure for T5631(normal)
    max_bytes_used value is too high:
        Expected    T9630(normal) max_bytes_used: 35324712 +/-15%
        Lower bound T9630(normal) max_bytes_used: 30026005
        Upper bound T9630(normal) max_bytes_used: 40623419
        Actual      T9630(normal) max_bytes_used: 43490984
        Deviation   T9630(normal) max_bytes_used:     23.1 %
    *** unexpected stat test failure for T9630(normal)

This reverts commit 7271db46c332f15c302b9a55f4ed005cdd0fb898.
This reverts commit b750dcc5d9e1df8505788a41d0cf0d92acd17f0d.
This reverts commit 33de71fa06d03e6da396a7c0a314fea3b492ab91.

20 months agotestsuite: Fix expected allocations of T9020 and T12425
Ben Gamari [Mon, 14 May 2018 21:19:07 +0000 (17:19 -0400)] 
testsuite: Fix expected allocations of T9020 and T12425

These were both improved by d92c7556501a4cdeb7d269c4624992c94d9b3b8b but the
changes were lost due to merge silliness.

20 months agoTidy up error suppression
Simon Peyton Jones [Tue, 15 May 2018 10:36:28 +0000 (11:36 +0100)] 
Tidy up error suppression

Trac #15152 showed that when a flag turned an error into a warning, we
were still (alas) suppressing subequent errors; includign their
essential addTcEvBind.  That led (rightly) to a Lint error.

This patch fixes it, and incidentally tidies up an ad-hoc special
case of out-of-scope variables (see the old binding for
'out_of_scope_killer' in 'tryReporters').

No test, because the problem was only shown up when turning
inaccessible code into a warning.

20 months agorts: export new absentSumFieldError from base
Sergei Trofimovich [Mon, 14 May 2018 20:51:48 +0000 (21:51 +0100)] 
rts: export new absentSumFieldError from base

commit b2ff5dde399cd012218578945ada1d9ff68daa35 "Fix #15038"
added new stable closure 'absentSumFieldError_closure' to
base package. This closure is used in rts package.

Unfortunately the symbol was not explicitly exported and build
failed on windows as:

"inplace/bin/ghc-stage1" -o ...hsc2hs.exe ...
rts/dist/build/libHSrts.a(RtsStartup.o): In function `hs_init_ghc':

rts/RtsStartup.c:272:0: error:
     undefined reference to `base_ControlziExceptionziBase_absentSumFieldError_closure'
272 |     getStablePtr((StgPtr)absentSumFieldError_closure);
    | ^


This change adds 'absentSumFieldError_closure' to explicit export
into libHSbase.def.

Signed-off-by: Sergei Trofimovich <>
20 months agoFix performance regressions from #14737
Tobias Dammers [Mon, 14 May 2018 12:50:29 +0000 (08:50 -0400)] 
Fix performance regressions from #14737

See #15019. When removing an unnecessary type equality check in #14737,
several regression tests failed. The cause was that some coercions that
are actually Refl coercions weren't passed in as such, which made the
equality check needlessly complex (Refl coercions can be discarded in
this particular check immediately, without inspecting the types at all).

We fix that, and get additional performance improvements for free.

Reviewers: goldfire, bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, thomie, carter

Differential Revision:

20 months agoRevert "rts: Compile with gcc -Og"
Ben Gamari [Mon, 14 May 2018 12:48:42 +0000 (08:48 -0400)] 
Revert "rts: Compile with gcc -Og"

This reverts commit d4abd031f6e8c2fa01f8949f60d8a02cca513804.

20 months agoFix #14973
Denis M [Mon, 14 May 2018 04:08:36 +0000 (00:08 -0400)] 
Fix #14973

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

Differential Revision:

20 months agoutils/fs: use <sys/stat.h>, not <sys\stat.h>
Sergei Trofimovich [Mon, 14 May 2018 08:09:58 +0000 (09:09 +0100)] 
utils/fs: use <sys/stat.h>, not <sys\stat.h>

Fix cross-compilation failure from linux to windows:
  CC utils/unlit/dist-install/build/fs.o
utils/unlit/fs.c:24:10: fatal error: sys\stat.h: No such file or directory
 #include <sys\stat.h>

Signed-off-by: Sergei Trofimovich <>
20 months agoImprove some Foldable methods for NonEmpty
David Feuer [Mon, 14 May 2018 03:26:08 +0000 (23:26 -0400)] 
Improve some Foldable methods for NonEmpty

* `length` is improved by using the default definition,
  while `foldr1` is improved by using a custom one.

* Several methods had useless lazy pattern matches
  (i.e., the functions were actually strict in those arguments).
  Remove `~`s to clarify.

Reviewers: hvr, bgamari, mpickering, nomeata

Reviewed By: bgamari

Subscribers: ygale, rwbarton, thomie, carter

GHC Trac Issues: #15131

Differential Revision:

20 months agoFix another batch of `./validate --slow` failures
Alp Mestanogullari [Sun, 13 May 2018 22:38:18 +0000 (18:38 -0400)] 
Fix another batch of `./validate --slow` failures

A rather detailed summary can be found at:

This doesn't fix all expectation mismatches yet, but we're down to about
20 mismatches with my previous patch and this one, as opposed to ~150
when I got started.

Test Plan: ./validate --slow

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: thomie, carter

GHC Trac Issues: #14890

Differential Revision:

20 months agoAdd support for opting out of package environments
Herbert Valerio Riedel [Sun, 13 May 2018 22:37:18 +0000 (18:37 -0400)] 
Add support for opting out of package environments

This implements the first part proposed in #13753:

Define a special magic "null" environment, which instructs GHC to ignore
any package environment files. To this end, I propose to use the name
`-` (i.e. a single dash), as that is more portable than using the empty
string for environment variables. In other words, a

- `-package-env -` CLI flag, or a
- `GHC_ENVIRONMENT=-` env var (unless a `-package-env` flag is present)

would inhibit GHC from looking up and interpreting any package
environment files from the filesystem; this is the equivalent of
`-ignore-dot-ghci` for package environment files.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13753

Differential Revision:

20 months agoghc-pkg: Configure handle encodings
Ben Gamari [Sun, 13 May 2018 22:36:59 +0000 (18:36 -0400)] 
ghc-pkg: Configure handle encodings

This fixes #15021 using a the same approach as was used to fix the issue
in ghc (#10762).

Test Plan: Validate on Windows as user whose username contains
non-ASCII characters

Reviewers: simonmar

Reviewed By: simonmar

Subscribers: lehins, thomie, carter

GHC Trac Issues: #15021

Differential Revision:

20 months agoFix #14875 by introducing PprPrec, and using it
Ryan Scott [Sun, 13 May 2018 22:36:23 +0000 (18:36 -0400)] 
Fix #14875 by introducing PprPrec, and using it

Trying to determine when to insert parentheses during TH
conversion is a bit of a mess. There is an assortment of functions
that try to detect this, such as:

* `hsExprNeedsParens`
* `isCompoundHsType`
* `hsPatNeedsParens`
* `isCompoundPat`
* etc.

To make things worse, each of them have slightly different semantics.
Plus, they don't work well in the presence of explicit type
signatures, as #14875 demonstrates.

All of these problems can be alleviated with the use of an explicit
precedence argument (much like what `showsPrec` currently does). To
accomplish this, I introduce a new `PprPrec` data type, and define
standard predences for things like function application, infix
operators, function arrows, and explicit type signatures (that last
one is new). I then added `PprPrec` arguments to the various
`-NeedsParens` functions, and use them to make smarter decisions
about when things need to be parenthesized.

A nice side effect is that functions like `isCompoundHsType` are
now completely unneeded, since they're simply aliases for
`hsTypeNeedsParens appPrec`. As a result, I did a bit of refactoring
to remove these sorts of functions. I also did a pass over various
utility functions in GHC for constructing AST forms and used more
appropriate precedences where convenient.

Along the way, I also ripped out the existing `TyPrec`
data type (which was tailor-made for pretty-printing `Type`s) and
replaced it with `PprPrec` for consistency.

Test Plan: make test TEST=T14875

Reviewers: alanz, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14875

Differential Revision:

20 months agoAdd note documenting refineDefaultAlt
Matthew Pickering [Sun, 13 May 2018 22:36:10 +0000 (18:36 -0400)] 
Add note documenting refineDefaultAlt

Reviewers: sjakobi, bgamari

Reviewed By: sjakobi

Subscribers: rwbarton, thomie, carter

Differential Revision:

20 months agoClarify what the FFI spec says
David Feuer [Sun, 13 May 2018 22:35:34 +0000 (18:35 -0400)] 
Clarify what the FFI spec says

Section 10.1.1 claimed that

> The FFI addendum stipulates that an implementation is free to
implement an unsafe call by performing a safe call ...

Reading through the FFI addendum (and the Haskell 2010 Report, which
integrates it), I see no such stipulation. I think this explains the
situation a bit better.

[ci skip]

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

Differential Revision:

20 months agoGHCi: Include a note in the hint to expose a hidden package
Chaitanya Koparkar [Sun, 13 May 2018 22:35:18 +0000 (18:35 -0400)] 
GHCi: Include a note in the hint to expose a hidden package

Test Plan: validate

Reviewers: bgamari, RyanGlScott, osa1

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15055

Differential Revision:

20 months agorts: Compile with gcc -Og
Ben Gamari [Sun, 13 May 2018 22:34:48 +0000 (18:34 -0400)] 
rts: Compile with gcc -Og

This optimisation level is specifically designed to provide the benefits
of optimisation without the obfuscation that sometimes results.

Test Plan: Validate

Reviewers: simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

Differential Revision: