2 years agoMark previously failing backpack tests as passing, with correct output.
Edward Z. Yang [Fri, 14 Oct 2016 07:13:44 +0000 (00:13 -0700)] 
Mark previously failing backpack tests as passing, with correct output.

Signed-off-by: Edward Z. Yang <>
2 years agoOnly delete instances when merging when there is an exact match.
Edward Z. Yang [Fri, 14 Oct 2016 07:11:10 +0000 (00:11 -0700)] 
Only delete instances when merging when there is an exact match.

Previously, we deleted if the heads matched, which meant that
we effectively were picking an arbitrary instance if there
were incompatible instances.  The new behavior makes more sense,
although without incoherent instances you are unlikely to
be able to do anything useful with the instances.

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

Reviewers: austin, bgamari

Subscribers: thomie

Differential Revision:

2 years agoSupport constraint synonym implementations of abstract classes.
Edward Z. Yang [Fri, 14 Oct 2016 04:34:17 +0000 (21:34 -0700)] 
Support constraint synonym implementations of abstract classes.


Test Plan: validate

Reviewers: goldfire, simonpj, austin, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12679

2 years agoNew story for abstract data types in hsig files.
Edward Z. Yang [Thu, 13 Oct 2016 06:55:41 +0000 (23:55 -0700)] 
New story for abstract data types in hsig files.

In the old implementation of hsig files, we directly
reused the implementation of abstract data types from
hs-boot files.  However, this was WRONG.  Consider the
following program (an abridged version of bkpfail24):

    {-# LANGUAGE GADTs #-}
    unit p where
        signature H1 where
            data T
        signature H2 where
            data T
        module M where
            import qualified H1
            import qualified H2

            f :: H1.T ~ H2.T => a -> b
            f x = x

Prior to this patch, M was accepted, because the type
inference engine concluded that H1.T ~ H2.T does not
hold (indeed, *presently*, it does not).  However, if
we subsequently instantiate p with the same module for
H1 and H2, H1.T ~ H2.T does hold!  Unsound.

The key is that abstract types from signatures need to
be treated like *skolem variables*, since you can interpret
a Backpack unit as a record which is universally quantified
over all of its abstract types, as such (with some fake
syntax for structural records):

    p :: forall t1 t2. { f :: t1 ~ t2 => a -> b }
    p = { f = \x -> x } -- ill-typed

Clearly t1 ~ t2 is not solvable inside p, and also clearly
it could be true at some point in the future, so we better
not treat the lambda expression after f as inaccessible.

The fix seems to be simple: do NOT eagerly fail when trying
to simplify the given constraints.  Instead, treat H1.T ~ H2.T
as an irreducible constraint (rather than an insoluble
one); this causes GHC to treat f as accessible--now we will
typecheck the rest of the function (and correctly fail).
Per the OutsideIn(X) paper, it's always sound to fail less
when simplifying givens.

We do NOT apply this fix to hs-boot files, where abstract
data is also guaranteed to be nominally distinct (since
it can't be implemented via a reexport or a type synonym.)
This is a somewhat unnatural state of affairs (there's
no way to really interpret this in Haskell land) but
no reason to change behavior.

I deleted "representationally distinct abstract data",
which is never used anywhere in GHC.

In the process of constructing this fix, I also realized
our implementation of type synonym matching against abstract
data was not sufficiently restrictive.  In order for
a type synonym T to be well-formed type, it must be a
nullary synonym (i.e., type T :: * -> *, not type T a = ...).
Furthermore, since we use abstract data when defining
instances, they must not have any type family applications.

More details in #12680.  This probably deserves some sort
of short paper report.

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

Reviewers: goldfire, simonpj, austin, bgamari

Subscribers: thomie

Differential Revision:

2 years Report Unregisterised setting
Erik de Castro Lopo [Wed, 19 Oct 2016 18:21:25 +0000 (05:21 +1100)] Report Unregisterised setting

Showing the value of this configure option in the configure output
can help debugging issues in build bots etc.

Test Plan: N/A

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agoStgCmmPrim: Add missing write barrier.
Peter Trommler [Wed, 19 Oct 2016 13:02:54 +0000 (09:02 -0400)] 
StgCmmPrim: Add missing write barrier.

On architectures with weak memory consistency a write barrier
is needed before the write to the pointer array.

Fixes #12469

Test Plan: rebuilt Stackage nightly twice on powerpc64le

Reviewers: hvr, rrnewton, erikd, austin, simonmar, bgamari

Reviewed By: erikd, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12469

2 years agoTest for newtype with unboxed argument
Simon Peyton Jones [Wed, 19 Oct 2016 11:22:11 +0000 (12:22 +0100)] 
Test for newtype with unboxed argument

Newtypes cannot (currently) have an unboxed argument type.
But Trac #12729 showed that this was only being checked for
newtypes in H98 syntax; in GADT snytax they were let through.

This patch moves the test to checkValidDataCon, where it properly

2 years agocmm/Hoopl/Dataflow: remove unused code
Michal Terepeta [Wed, 19 Oct 2016 02:17:49 +0000 (22:17 -0400)] 
cmm/Hoopl/Dataflow: remove unused code

We had *a lot* of code copied from Hoopl that is for rewriting. But GHC
doesn't use it (it only uses some forked Hoopl code for analysis).

So we can safely kill all this code and make it much easier to refactor
and improve the parts that we do use.

Signed-off-by: Michal Terepeta <>
Test Plan: ./validate

Reviewers: austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agoCompute export hash based on ALL transitive orphan modules.
Edward Z. Yang [Wed, 19 Oct 2016 02:17:10 +0000 (22:17 -0400)] 
Compute export hash based on ALL transitive orphan modules.

Previously we pruned out orphan modules from external packages but this
was wrong.  Fixes #12733 (which has more discussion.)

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

Reviewers: simonpj, bgamari, austin

Reviewed By: simonpj

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #12733

2 years agoAdd some missing RTS symbols
Simon Marlow [Wed, 19 Oct 2016 02:13:55 +0000 (22:13 -0400)] 
Add some missing RTS symbols

Test Plan: validate

Reviewers: austin, bgamari, erikd

Reviewed By: bgamari, erikd

Subscribers: thomie

Differential Revision:

2 years agofix build failure on Solaris caused by usage of --export-dynamic
Karel Gardas [Tue, 18 Oct 2016 19:47:35 +0000 (21:47 +0200)] 
fix build failure on Solaris caused by usage of --export-dynamic

This patch fixes build failure on Solaris which is caused
by usage --export-dynamic linker parameter. This parameter is not
supported by Solaris linker. The param itself was added by D2590

Reviewers: bgamari, simonmar, austin

Subscribers: thomie

Differential Revision:

2 years agoghc/Main.hs: Add import list to DynamicLoading
Ömer Sinan Ağacan [Tue, 18 Oct 2016 19:24:23 +0000 (15:24 -0400)] 
ghc/Main.hs: Add import list to DynamicLoading

2 years agoDynamicLoading: Replace map + zip with zipWith
Ömer Sinan Ağacan [Tue, 18 Oct 2016 19:05:16 +0000 (15:05 -0400)] 
DynamicLoading: Replace map + zip with zipWith

2 years agofixup! Add option to not retain CAFs to the linker API
Simon Marlow [Tue, 18 Oct 2016 14:18:28 +0000 (15:18 +0100)] 
fixup! Add option to not retain CAFs to the linker API

2 years agoremove unnecessary ifdef
Simon Marlow [Tue, 18 Oct 2016 10:35:12 +0000 (11:35 +0100)] 
remove unnecessary ifdef

2 years agoAdd option to not retain CAFs to the linker API
Simon Marlow [Thu, 13 Oct 2016 11:51:33 +0000 (12:51 +0100)] 
Add option to not retain CAFs to the linker API

2 years agoTrack dep_finsts in exports hash, as it affects downstream deps.
Edward Z. Yang [Mon, 17 Oct 2016 21:06:18 +0000 (14:06 -0700)] 
Track dep_finsts in exports hash, as it affects downstream deps.

I also added some more comments about the orphan and family instance
hashing business.

Fixes #12723.

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

Reviewers: bgamari, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12723

2 years agoBump parallel submodule
Ben Gamari [Mon, 17 Oct 2016 18:34:25 +0000 (14:34 -0400)] 
Bump parallel submodule

Includes testsuite fix for Python 3.

2 years agotestsuite: Mark T7037 as broken on Windows
Ben Gamari [Mon, 17 Oct 2016 12:57:12 +0000 (08:57 -0400)] 
testsuite: Mark T7037 as broken on Windows

Due to #12725.

2 years agotestsuite/driver: Allow threading on Windows
Ben Gamari [Mon, 17 Oct 2016 00:49:57 +0000 (20:49 -0400)] 
testsuite/driver: Allow threading on Windows

It seems that threading now works fine. The only caveat here is that it
makes some race conditions more likely (e.g. #12554), although these
also appear to affect single-threaded runs.

Test Plan: Validate on Windows

Reviewers: austin, Phyx

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10510

2 years agotestsuite: Eliminate unnecessary compile_timeout_multiplier
Ben Gamari [Mon, 17 Oct 2016 00:49:46 +0000 (20:49 -0400)] 
testsuite: Eliminate unnecessary compile_timeout_multiplier

tc266 was failing intermittently on Windows due to a very small
compile_timeout_multiplier. This test was added in
e907e1f12f4dedc0ec13c7a501c8810bcfc03583 which doesn't appear to have
any timng dependence, so I see no reason to retain the multiplier at

Test Plan: Validate

Reviewers: ezyang, austin

Subscribers: thomie

Differential Revision:

2 years agotestsuite/driver: More Unicode awareness
Ben Gamari [Mon, 17 Oct 2016 00:49:36 +0000 (20:49 -0400)] 
testsuite/driver: More Unicode awareness

Explicitly specify utf8 encoding in a few spots which were failing on
Windows with Python 3.

Test Plan: Validate

Reviewers: austin, thomie

Differential Revision:

GHC Trac Issues: #9184

2 years agovalidate: Allow user to override Python interpreter
Ben Gamari [Mon, 17 Oct 2016 00:49:26 +0000 (20:49 -0400)] 
validate: Allow user to override Python interpreter

Due to #12554 and #12661 we must be quite picky about our choice of
Python interpreter on Windows. Allow the user to override it.

Test Plan: `PYTHON=/usr/bin/python2 ./validate` on Windows

Reviewers: austin, Phyx

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12554, #12661

2 years agotestsuite/timeout: Ensure that processes are cleaned up on Windows
Ben Gamari [Mon, 17 Oct 2016 00:49:15 +0000 (20:49 -0400)] 
testsuite/timeout: Ensure that processes are cleaned up on Windows

Previously if the test is interrupted (e.g. with Ctrl-C) any processes
which it spawned may not be properly terminated. Here we catch any
exception and ensure that we job is terminated.

Test Plan: Validate on Windows

Reviewers: Phyx, austin

Subscribers: thomie

Differential Revision:

2 years agotestsuite/driver: Never symlink on Windows
Ben Gamari [Mon, 17 Oct 2016 00:49:00 +0000 (20:49 -0400)] 
testsuite/driver: Never symlink on Windows

While msys' mingw Python 3 does indeed export `os.symlink`, it is
unusable since creating symbolic links on Windows requires permissions
that essentially no one has.

Test Plan: Validate on Windows

Reviewers: austin, Phyx, thomie

Differential Revision:

2 years agotestsuite: Mark T9405 as broken on Windows
Ben Gamari [Sun, 16 Oct 2016 02:53:06 +0000 (02:53 +0000)] 
testsuite: Mark T9405 as broken on Windows

There seems to be a runtime system bug here, as described in #12714.

2 years agotestsuite: Mark T10858 as broken on Windows
Ben Gamari [Sun, 16 Oct 2016 02:25:50 +0000 (02:25 +0000)] 
testsuite: Mark T10858 as broken on Windows

Strangely the allocation numbers on Windows differ significantly from
those on Linux. Usually I would just update the number, but I would
really like to understand why this is the case. This is a rather large
deviation in the compilation of a program which really shouldn't have
any appreciable platform dependence.

2 years agotestsuite: Mark break011 as broken
Ben Gamari [Sun, 16 Oct 2016 02:05:50 +0000 (02:05 +0000)] 
testsuite: Mark break011 as broken

See #12712.

2 years agotestsuite: Work around #12554
Ben Gamari [Sat, 15 Oct 2016 18:18:14 +0000 (18:18 +0000)] 
testsuite: Work around #12554

It seems that Python 2.7.11 and "recent" msys2 releases are broken,
holding open file locks unexpected. This causes rmtree to intermittently
fail. Even worse, it would fail silently (since we pass
ignore_errors=True), causing makedirs to fail later.

We now explicitly check for the existence of the test directory before
attempting to delete it and disable ignore_errors. Moreover, on Windows
we now try multiple times to rmtree the testdir, working around the
apparently msys bug.

This is all just terrible, but Phyx and I spent several hours trying to
track down the issue to no available. The workaround is better than

2 years agoRe-add accidentally-deleted line
Simon Peyton Jones [Mon, 17 Oct 2016 08:23:50 +0000 (09:23 +0100)] 
Re-add accidentally-deleted line

This adds a line I deleted by mistake in

  commit db71d971379c74dd1d2b958c11dc6c9e718a3e61
  Author: Simon Peyton Jones <>
  Date:   Fri Oct 14 17:40:51 2016 +0100

      Reduce trace output slightly

Sorry about that!

2 years agoTypos in comments
Gabor Greif [Mon, 17 Oct 2016 08:05:45 +0000 (10:05 +0200)] 
Typos in comments

2 years agoComments only
Simon Peyton Jones [Fri, 14 Oct 2016 16:50:28 +0000 (17:50 +0100)] 
Comments only

2 years agoAdd more variants of T3064 (in comments)
Simon Peyton Jones [Fri, 14 Oct 2016 16:42:00 +0000 (17:42 +0100)] 
Add more variants of T3064 (in comments)

2 years agoReduce trace output slightly
Simon Peyton Jones [Fri, 14 Oct 2016 16:40:51 +0000 (17:40 +0100)] 
Reduce trace output slightly

2 years agoTest Trac #12681
Simon Peyton Jones [Mon, 17 Oct 2016 07:40:16 +0000 (08:40 +0100)] 
Test Trac #12681

2 years agoFix wrapping order in matchExpectedConTy
Simon Peyton Jones [Fri, 14 Oct 2016 16:13:43 +0000 (17:13 +0100)] 
Fix wrapping order in matchExpectedConTy

The wrappers in matchExpectedConTy were being composed back
to front, resulting in a Core Lint error.  Yikes!  This has
been here a long time.

Fixes Trac #12676.

2 years agoCorrect order of existentials in pattern synonyms
Simon Peyton Jones [Fri, 14 Oct 2016 14:54:14 +0000 (15:54 +0100)] 
Correct order of existentials in pattern synonyms

Trac #12698 exposed a nasty bug in the typechecking for
pattern synonmys: the existential type variables weren't
being put in properly-scoped order.

For some reason TcPatSyn.tcCollectEx was colleting them as a
set, not as a list!  Easily fixed.

2 years agoTypo in comment
Simon Peyton Jones [Fri, 14 Oct 2016 14:52:15 +0000 (15:52 +0100)] 
Typo in comment

2 years agoFix shadowing in mkWwBodies
Simon Peyton Jones [Fri, 14 Oct 2016 11:05:46 +0000 (12:05 +0100)] 
Fix shadowing in mkWwBodies

This bug, exposed by Trac #12562 was very obscure, and has been
lurking for a long time.  What happened was that, in the
worker/wrapper split

  a tyvar binder for a worker function
  accidentally shadowed an in-scope term variable
  that was mentioned in the body of the function

It's jolly hard to provoke, so I have not even attempted to make
a test case.  There's a Note [Freshen WW arguments] to explain.

Interestingly, fixing the bug (which meant fresher type variables)
revealed a second lurking bug: I'd failed to apply the substitution to
the coercion in the second last case of mkWWArgs, which introduces a

2 years agoFix comment typo
Simon Peyton Jones [Fri, 14 Oct 2016 09:41:45 +0000 (10:41 +0100)] 
Fix comment typo

2 years agoComments about -Wredundant-constraints
Simon Peyton Jones [Fri, 14 Oct 2016 09:41:14 +0000 (10:41 +0100)] 
Comments about -Wredundant-constraints

2 years agoCorrect name of makeStableName in haddock
Reid Barton [Sun, 16 Oct 2016 17:40:11 +0000 (13:40 -0400)] 
Correct name of makeStableName in haddock

2 years agoAdd a forward reference for a Note
Ryan Scott [Sat, 15 Oct 2016 22:33:06 +0000 (18:33 -0400)] 
Add a forward reference for a Note

And fix a typo within said Note.

[ci skip]

2 years agoFix Show derivation in the presence of RebindableSyntax/OverloadedStrings
Ryan Scott [Sat, 15 Oct 2016 15:11:20 +0000 (11:11 -0400)] 
Fix Show derivation in the presence of RebindableSyntax/OverloadedStrings

To fix this issue, we simply disable `RebindableSyntax` whenever we rename
the code generated from a deriving clause.

Fixes #12688.

Test Plan: make test TEST=T12688

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12688

2 years agoFix Windows build following D2588
Ryan Scott [Sat, 15 Oct 2016 02:28:29 +0000 (22:28 -0400)] 
Fix Windows build following D2588

Commit 8c6a3d68c0301bb985aa2a462936bbcf7584ae9c inadvertently broke the build
on Windows. This restores Windows compatibility.

2 years agoDisable T-signals-child test on single-threaded runtime
Michael Snoyman [Fri, 14 Oct 2016 14:53:40 +0000 (10:53 -0400)] 
Disable T-signals-child test on single-threaded runtime

As identified by Joachim, this test broke the Travis build. It appears
that this is due to the usage of the single-threaded runtime there. I've
confirmed that this fix causes the Travis build to pass:

Test Plan: Confirm tests now pass

Reviewers: austin, nomeata, bgamari

Reviewed By: nomeata, bgamari

Subscribers: thomie

Differential Revision:

2 years agoCheck for empty entity string in "prim" foreign imports
Sylvain HENRY [Fri, 14 Oct 2016 14:43:30 +0000 (10:43 -0400)] 
Check for empty entity string in "prim" foreign imports

Foreign imports with "prim" convention require a valid symbol identifier
(see linked issue). We check this.

Fix line too long

Test Plan: Validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12355

2 years agoBuild ghc-iserv with --export-dynamic
Simon Marlow [Fri, 14 Oct 2016 14:43:10 +0000 (10:43 -0400)] 
Build ghc-iserv with --export-dynamic

This enables loading dynamic libraries that refer to the RTS.  I just
came across somewhere I needed to do that, and without
`--export-dynamic` it's impossible.

For now we'll only support that when using `-fexternal-interpreter`,
because the dynamic symbol table for GHC itself is much bigger.

Test Plan: validate

Reviewers: niteria, austin, erikd, bgamari

Reviewed By: bgamari

Subscribers: Phyx, thomie

Differential Revision:

2 years agoMake error when deriving an instance for a typeclass less misleading
Ryan Scott [Fri, 14 Oct 2016 14:40:56 +0000 (10:40 -0400)] 
Make error when deriving an instance for a typeclass less misleading

Before, when you attempted to derive an instance for a typeclass,

class C1 (a :: Constraint) where
class C2 where

deriving instance C1 C2

GHC would complain that `C2`'s data constructors aren't in scope. But
makes no sense, since typeclasses don't have constructors! By refining
checks that GHC performs when deriving, we can make the error message a
little more sensible.

This also cleans up a related `DeriveAnyClass` infelicity. Before, you
wouldn't have been able to compile code like this:

import System.IO (Handle)
class C a
deriving instance C Handle

Since GHC was requiring that all data constructors of `Handle` be in
scope. But `DeriveAnyClass` doesn't even generate code that mentions
any data constructors, so this requirement is silly!

Fixes #11509.

Test Plan: make test TEST=T11509

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: thomie, simonpj

Differential Revision:

GHC Trac Issues: #11509

2 years agoAdd missing Semigroup instances for Monoidal datatypes in base
Ryan Scott [Fri, 14 Oct 2016 14:30:54 +0000 (10:30 -0400)] 
Add missing Semigroup instances for Monoidal datatypes in base

There are currently three datatypes that are exposed in `base` that have
`Monoid` instances, but no `Semigroup` instances:

* `IO`
* `Event` (from `GHC.Event`)
* `Lifetime` (from `GHC.Event`)

(There is also `EventLifetime` in `GHC.Event.Internal`, but it is not exported
directly, so I didn't bother with it.)

Adding the `Semigroup` instances for these types directly in the modules in
which they're defined resulted in some horrific import cycles, so I opted to
take the easy approach of defining all of these instances in `Data.Semigroup`.
(When `Semigroup` becomes a superclass of `Monoid`, these instances will have
to be moved somehow.)

Fixes #12464.

Test Plan: It compiles

Reviewers: hvr, ekmett, austin, bgamari

Reviewed By: ekmett

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12464

2 years agoPrelInfo: Fix style
Ben Gamari [Fri, 14 Oct 2016 00:42:59 +0000 (20:42 -0400)] 
PrelInfo: Fix style

2 years agoImprove find_lbl panic message
Ben Gamari [Thu, 13 Oct 2016 23:42:21 +0000 (19:42 -0400)] 
Improve find_lbl panic message

2 years agoMkIface: Turn a foldr into a foldl'
Ben Gamari [Tue, 23 Aug 2016 03:18:02 +0000 (23:18 -0400)] 
MkIface: Turn a foldr into a foldl'

There is no reason why this should be a foldr considering we are
building a map.

2 years agoClean up handling of known-key Names in interface files
Ben Gamari [Fri, 14 Oct 2016 01:53:13 +0000 (21:53 -0400)] 
Clean up handling of known-key Names in interface files

Previously BinIface had some dedicated logic for handling tuple names in
the symbol table. As it turns out, this logic was essentially dead code
as it was superceded by the special handling of known-key things. Here
we cull the tuple code-path and use the known-key codepath for all
tuple-ish things.

This had a surprising number of knock-on effects,

 * constraint tuple datacons had to be made known-key (previously they
   were not)

 * IfaceTopBndr was changed from being a synonym of OccName to a
   synonym of Name (since we now need to be able to deserialize Names
   directly from interface files)

 * the change to IfaceTopBndr complicated fingerprinting, since we need
   to ensure that we don't go looking for the fingerprint of the thing
   we are currently fingerprinting in the fingerprint environment (see
   notes in MkIface). Handling this required distinguishing between
   binding and non-binding Name occurrences in the Binary serializers.

 * the original name cache logic which previously lived in IfaceEnv has
   been moved to a new NameCache module

 * I ripped tuples and sums out of knownKeyNames since they introduce a
   very large number of entries. During interface file deserialization
   we use static functions (defined in the new KnownUniques module) to
   map from a Unique to a known-key Name (the Unique better correspond
   to a known-key name!) When we need to do an original name cache
   lookup we rely on the parser implemented in isBuiltInOcc_maybe.

 * HscMain.allKnownKeyNames was folded into PrelInfo.knownKeyNames.

 * Lots of comments were sprinkled about describing the new scheme.

Updates haddock submodule.

Test Plan: Validate

Reviewers: niteria, simonpj, austin, hvr

Reviewed By: simonpj

Subscribers: simonmar, niteria, thomie

Differential Revision:

GHC Trac Issues: #12532, #12415

2 years agoUnique: Simplify encoding of sum uniques
Ben Gamari [Fri, 14 Oct 2016 01:52:57 +0000 (21:52 -0400)] 
Unique: Simplify encoding of sum uniques

The previous encoding was entropically a bit better, but harder to
encode and decode. Now we just split up the integer part of the unique
into a bitfield.

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision:

2 years agoCabal submodule update.
Edward Z. Yang [Thu, 13 Oct 2016 07:52:20 +0000 (00:52 -0700)] 
Cabal submodule update.

Signed-off-by: Edward Z. Yang <>
2 years agoFurther improve error handling in TcRn monad
Simon Peyton Jones [Thu, 13 Oct 2016 11:24:53 +0000 (12:24 +0100)] 
Further improve error handling in TcRn monad

This patch builds on the one for Trac #12124, by dealing properly
with out-of-scope "hole" errors.

This fixes Trac #12529. The hard error coming from visible type application
is still there, but the out-of-scope error is no longer suppressed.

(Arguably the VTA message should be suppressed somehow, but that's a
battle for another day.)

2 years agoAdd missing @since annotations
Ryan Scott [Thu, 13 Oct 2016 02:22:43 +0000 (22:22 -0400)] 
Add missing @since annotations

2 years agoAdd test for #12456
Ryan Scott [Thu, 13 Oct 2016 01:06:48 +0000 (21:06 -0400)] 
Add test for #12456

Commit f352e5cd7bb629fe0ca3b913bfbe7bee43d62f3a fixed #12456. Let's add a test
to make sure it stays fixed.

2 years agoAdd test for #12589
Ryan Scott [Wed, 12 Oct 2016 23:16:46 +0000 (19:16 -0400)] 
Add test for #12589

Commit af21e38855f7d517774542b360178b05045ecb08 fixed #12598. Let's add a test
to make sure it stays fixed.

2 years agoAdd test for #12411
Ryan Scott [Wed, 12 Oct 2016 18:57:32 +0000 (14:57 -0400)] 
Add test for #12411

The fix for #12584 also fixed the problem in #12411. Let's add a test to ensure
that it stays fixed.

2 years agotestsuite: Bump T1969 allocations
Ben Gamari [Wed, 12 Oct 2016 15:49:55 +0000 (11:49 -0400)] 
testsuite: Bump T1969 allocations

2 years agoRnExpr: Actually fail if patterns found in expression
Ben Gamari [Tue, 11 Oct 2016 13:26:46 +0000 (09:26 -0400)] 
RnExpr: Actually fail if patterns found in expression

This fixes #12584, where wildcard patterns were snuck into an
expression, which then crashed the typechecker in TcExpr since EWildPats
aren't supposed to appear in the AST after renaming.

The problem was that `rnTopSpliceDecl` failed to check for errors from
`rnSplice` (as done by other callers to `rnSplice`).

Thanks to Shayan for reporting this!

Reviewers: simonpj, austin

Reviewed By: simonpj

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #12584

2 years agoComments and equation ordering only
Simon Peyton Jones [Wed, 12 Oct 2016 14:26:24 +0000 (15:26 +0100)] 
Comments and equation ordering only

2 years agoAdd derived shadows only for Wanted constraints
Simon Peyton Jones [Wed, 12 Oct 2016 11:02:04 +0000 (12:02 +0100)] 
Add derived shadows only for Wanted constraints

This patch implements choice (3) of comment:14 on Trac #12660.
It cures an infinite loop (caused by the creation of an infinite
type) in in compiling the 'singletons' package.

See Note [Add derived shadows only for Wanteds] in TcSMonad.

2 years agoAdd a broken test case for #12689
Joachim Breitner [Tue, 11 Oct 2016 20:50:25 +0000 (16:50 -0400)] 
Add a broken test case for #12689

A rule with a phase specification trying to match on a constructor with
a wrapper will fail to match, as the wrapper will be inlined by then.
The fact that it works in the other case is also mostly by accident.
(Split into two test cases so that regressions with regard what works so
far are caught.)

2 years agoAdd test case for #12689
Joachim Breitner [Tue, 11 Oct 2016 20:25:05 +0000 (16:25 -0400)] 
Add test case for #12689

which test a few variants of rules involving constructors, including
nullary constructors, constructors with wrappers, and unsaturated of

At the moment, all the rules work as expected, despite GHC’s compile
time warnings when called with -Wall.

2 years agoMore tests for Trac #12522
Simon Peyton Jones [Mon, 10 Oct 2016 12:57:01 +0000 (13:57 +0100)] 
More tests for Trac #12522

These ones test the variations in coment:15 of the ticket

2 years agoImproved stats for Trac #1969
Simon Peyton Jones [Mon, 10 Oct 2016 12:45:42 +0000 (13:45 +0100)] 
Improved stats for Trac #1969

With my latest commits

  76a5477 Move zonking out of tcFamTyPats
  b255ae7 Orient improvement constraints better

perf has improved slightly for T1969:

allocs:    733M -> 26M
residency: 43M  -> 41M

I don't know exactly why, but hey, it's good

2 years agoMove zonking out of tcFamTyPats
Simon Peyton Jones [Fri, 7 Oct 2016 23:03:53 +0000 (00:03 +0100)] 
Move zonking out of tcFamTyPats

In tcFamTyPats we were zonking from the TcType world to the
Type world, ready to build the results into a CoAxiom (which
should have no TcType stuff.  But the 'thing_inside' for
tcFamTyPats also must be zonked, and that zonking must have
the ZonkEnv from the binders zonked tcFamTyPats.

Ugh.  This caused an assertion failure (with DEBUG on) in
RaeBlobPost and TypeLevelVec, both in tests/dependent, as
shown in Trac #12682.  Why it hasn't shown up before now
is obscure to me.

So I moved the zonking stuff out of tcFamTyPats to its
three call sites, where we can do it all together. Very
slightly longer, but much more robust.

2 years agoDelete orphan where clause
Simon Peyton Jones [Fri, 7 Oct 2016 22:57:29 +0000 (23:57 +0100)] 
Delete orphan where clause

2 years agoRename a parameter; trivial refactor
Simon Peyton Jones [Fri, 7 Oct 2016 22:55:54 +0000 (23:55 +0100)] 
Rename a parameter; trivial refactor

2 years agoOrient improvement constraints better
Simon Peyton Jones [Fri, 7 Oct 2016 22:51:44 +0000 (23:51 +0100)] 
Orient improvement constraints better

This patch fixes an infinite loop in the constraint solver,
shown up by Trac #12522.

The solution is /very/ simple: just reverse the orientation of the
derived constraints arising from improvement using type-family
injectivity.  I'm not very proud of the fix --- it seems fragile
--- but it has the very great merit of simplicity, and it works

See Note [Improvement orientation] in TcInteract, and some
discussion on the Trac ticket.

2 years agoEscape lambda.
Vaibhav Sagar [Sun, 9 Oct 2016 22:21:58 +0000 (18:21 -0400)] 
Escape lambda.

Test Plan: View updated documentation?

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12672

2 years agoTurn on -n4m with -A16m or greater
Simon Marlow [Sun, 9 Oct 2016 22:21:35 +0000 (18:21 -0400)] 
Turn on -n4m with -A16m or greater

Nursery chunks help reduce the cost of GC when capabilities are unevenly
loaded, by ensuring that we use more of the available nursery.

The rationale for enabling this at -A16m is that any negative effects
due to loss of cache locality are less likely to be an issue at -A16m
and above.  It's a conservative guess.  If we had a lot of benchmark
data we could probably do better.

Results for nofib/parallel at -N4 -A32m with and without -n4m:

        Program           Size    Allocs   Runtime   Elapsed  TotalMem
   blackscholes           0.0%     -9.5%     -9.0%    -15.0%     -2.2%
          coins           0.0%     -4.7%     -3.6%     -0.6%    -13.6%
         mandel           0.0%     -0.3%     +7.7%    +13.1%     +0.1%
        matmult           0.0%     +1.5%    +10.0%     +7.7%     +0.1%
          nbody           0.0%     -4.1%     -2.9%     0.085      0.0%
         parfib           0.0%     -1.4%     +1.0%     +1.5%     +0.2%
        partree           0.0%     -0.3%     +0.8%     +2.9%     -0.8%
           prsa           0.0%     -0.5%     -2.1%     -7.6%      0.0%
         queens           0.0%     -3.2%     -1.4%     +2.2%     +1.3%
            ray           0.0%     -5.6%    -14.5%     -7.6%     +0.8%
       sumeuler           0.0%     -0.4%     +2.4%     +1.1%      0.0%
            Min           0.0%     -9.5%    -14.5%    -15.0%    -13.6%
            Max           0.0%     +1.5%    +10.0%    +13.1%     +1.3%
 Geometric Mean          +0.0%     -2.6%     -1.3%     -0.5%     -1.4%

Not conclusive, but slightly better.  This matters a lot more when you
have more cores.

Test Plan: validate, nofib/paralel

Reviewers: niteria, ezyang, nh2, trofi, austin, erikd, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #9221

2 years agoDefault +RTS -qn to the number of cores
Simon Marlow [Sun, 9 Oct 2016 22:20:53 +0000 (18:20 -0400)] 
Default +RTS -qn to the number of cores

Setting a -N value that is too large has a dramatic negative effect on
performance, but the new -qn flag can mitigate the worst of the effects
by limiting the number of GC threads.

So now, if you don't explcitly set +RTS -qn, and you set -N larger than
the number of cores (or use setNumCapabilities to do the same), we'll
default -qn to the number of cores.

These are the results from nofib/parallel on my 4-core (2 cores x 2
threads) i7 laptop, comparing -N8 before and after this change.

        Program           Size    Allocs   Runtime   Elapsed  TotalMem
   blackscholes          +0.0%     +0.0%    -72.5%    -72.0%     +9.5%
          coins          +0.0%     -0.0%    -73.7%    -72.2%     -0.8%
         mandel          +0.0%     +0.0%    -76.4%    -75.4%     +3.3%
        matmult          +0.0%    +15.5%    -26.8%    -33.4%     +1.0%
          nbody          +0.0%     +2.4%     +0.7%     0.076      0.0%
         parfib          +0.0%     -8.5%    -33.2%    -31.5%     +2.0%
        partree          +0.0%     -0.0%    -60.4%    -56.8%     +5.7%
           prsa          +0.0%     -0.0%    -65.4%    -60.4%      0.0%
         queens          +0.0%     +0.2%    -58.8%    -58.8%     -1.5%
            ray          +0.0%     -1.5%    -88.7%    -85.6%     -3.6%
       sumeuler          +0.0%     -0.0%    -47.8%    -46.9%      0.0%
            Min          +0.0%     -8.5%    -88.7%    -85.6%     -3.6%
            Max          +0.0%    +15.5%     +0.7%    -31.5%     +9.5%
 Geometric Mean          +0.0%     +0.6%    -61.4%    -63.1%     +1.4%

Test Plan: validate, nofib/parallel benchmarks

Reviewers: niteria, ezyang, nh2, austin, erikd, trofi, bgamari

Reviewed By: trofi, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #9221

2 years agoCleanup PosixSource.h
Moritz Angermann [Sun, 9 Oct 2016 22:19:26 +0000 (18:19 -0400)] 
Cleanup PosixSource.h

When trying to build arm64-apple-iso, the build fell over `strdup`, as
the arm64-apple-ios build did not fall into `darwin_HOST_OS`, and would
need `ios_HOST_OS`.

This diff tries to clean up PosixSource.h, instead of layering another
define on top.

As we use `strnlen` in sources that include PosixSource.h, and `strnlen`
is defined in POSIX.1-2008, the `_POSIX_C_SOURCE` and `_XOPEN_SOURCE`
are increased accordingly.

Furthermore the `_DARWIN_C_SOURCE` (required for `u_char`, etc. used in
sysctl.h) define is moved into `OSThreads.h` alongside a similar ifdef
for freebsd.

Test Plan: Build on all supported platforms.

Reviewers: austin, simonmar, erikd, kgardas, bgamari

Reviewed By: simonmar, erikd, kgardas, bgamari

Subscribers: Phyx, hvr, thomie

Differential Revision:

GHC Trac Issues: #12624

2 years agoDo not segfault if no common root can be found
Moritz Angermann [Sun, 9 Oct 2016 22:17:46 +0000 (18:17 -0400)] 
Do not segfault if no common root can be found

When trying to profile a plugin, ghc mysteriously segfaulted.  Upon
closer examination the segfault happend due to a `->prevStack` lookup
on a NULL pointer.

A new CostCentre: Unknown is introduced that is set, if ccsapp and
ccsfn are of equal depth (e.g. 0), and do not have a common CostCentre
in their stacks.

Reviewers: bgamari, simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: Phyx, thomie

Differential Revision:

2 years agoGenerate a unique symbol for signature object stub files, fixes #12673
Edward Z. Yang [Sun, 9 Oct 2016 22:17:32 +0000 (18:17 -0400)] 
Generate a unique symbol for signature object stub files, fixes #12673

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12673

2 years agoFix build
Csongor Kiss [Sat, 8 Oct 2016 10:28:22 +0000 (11:28 +0100)] 
Fix build

- interaction between backpack and export list refactoring
  introduced a few syntax errors, and constructor arity mismatches
- CPP macro used in backpack was not accepted by clang because of
  extraneous whitespace

Signed-off-by: Csongor Kiss <>
Reviewers: austin, bgamari, mpickering

Reviewed By: mpickering

Subscribers: thomie

Differential Revision:

2 years agoAdd trailing comma to fix the build.
Matthew Pickering [Sat, 8 Oct 2016 09:28:47 +0000 (10:28 +0100)] 
Add trailing comma to fix the build.

2 years agoRework renaming of children in export lists.
Matthew Pickering [Sat, 8 Oct 2016 09:06:01 +0000 (10:06 +0100)] 
Rework renaming of children in export lists.

The target of this patch is exports such as:

module Foo ( T(A, B, C) ) where

Essentially this patch makes sure that we use the correct lookup functions in order
to lookup the names in parent-children export lists. This change
highlighted the complexity of this small part of GHC which accounts for
the scale.

This change was motivated by wanting to
remove the `PatternSynonym` constructor from `Parent`. As with all these
things, it quickly spiraled out of control into a much larger refactor.

Reviewers: simonpj, goldfire, bgamari, austin

Subscribers: adamgundry, thomie

Differential Revision:

GHC Trac Issues: #11970

2 years agoCabal submodule update.
Edward Z. Yang [Fri, 7 Oct 2016 06:20:38 +0000 (23:20 -0700)] 
Cabal submodule update.

Signed-off-by: Edward Z. Yang <>
2 years agoReport that we support Backpack in --info.
Edward Z. Yang [Fri, 7 Oct 2016 06:20:19 +0000 (23:20 -0700)] 
Report that we support Backpack in --info.

Signed-off-by: Edward Z. Yang <>
2 years agoUpdate haddock.Cabal perf for Cabal update.
Edward Z. Yang [Fri, 7 Oct 2016 01:19:22 +0000 (18:19 -0700)] 
Update haddock.Cabal perf for Cabal update.

Signed-off-by: Edward Z. Yang <>
2 years agoMake InstalledUnitId be ONLY a FastString.
Edward Z. Yang [Thu, 6 Oct 2016 20:40:10 +0000 (13:40 -0700)] 
Make InstalledUnitId be ONLY a FastString.

It turns out that we don't really need to be able to
extract a ComponentId from UnitId, except in one case.
So compress UnitId into a single FastString.

The one case where we do need the ComponentId is when
we are compiling an instantiated version of a package;
we need the ComponentId to look up the indefinite
version of this package from the database.  So now we
just pass it in as an argument -this-component-id.

Also: ghc-pkg now no longer will unregister a package if
you register one with the same package name, if the
instantiations don't match.

Cabal submodule update which tracks the same data type

Signed-off-by: Edward Z. Yang <>
2 years agoDistinguish between UnitId and InstalledUnitId.
Edward Z. Yang [Thu, 6 Oct 2016 07:17:15 +0000 (00:17 -0700)] 
Distinguish between UnitId and InstalledUnitId.

Signed-off-by: Edward Z. Yang <>
2 years agoThe Backpack patch.
Edward Z. Yang [Sat, 10 Oct 2015 19:01:14 +0000 (12:01 -0700)] 
The Backpack patch.

This patch implements Backpack for GHC.  It's a big patch but I've tried quite
hard to keep things, by-in-large, self-contained.

The user facing specification for Backpack can be found at:

A guide to the implementation can be found at:

Has a submodule update for Cabal, as well as a submodule update
for filepath to handle more strict checking of cabal-version.

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

Reviewers: simonpj, austin, simonmar, bgamari, goldfire

Subscribers: thomie, mpickering

Differential Revision:

2 years agoExclude Cabal PackageTests from gen_contents_index.
Edward Z. Yang [Thu, 6 Oct 2016 23:20:24 +0000 (16:20 -0700)] 
Exclude Cabal PackageTests from gen_contents_index.

Signed-off-by: Edward Z. Yang <>
2 years agoRemove reexports from ghc-boot, help bootstrap with GHC 8.
Edward Z. Yang [Sun, 2 Oct 2016 19:59:44 +0000 (12:59 -0700)] 
Remove reexports from ghc-boot, help bootstrap with GHC 8.

Signed-off-by: Edward Z. Yang <>
2 years agoNote about external interface changes.
Edward Z. Yang [Tue, 30 Aug 2016 04:20:58 +0000 (21:20 -0700)] 
Note about external interface changes.

Signed-off-by: Edward Z. Yang <>
2 years agoTc267, tests what happens if you forgot to knot-tie.
Edward Z. Yang [Thu, 25 Aug 2016 05:11:07 +0000 (22:11 -0700)] 
Tc267, tests what happens if you forgot to knot-tie.

Signed-off-by: Edward Z. Yang <>
2 years agoSimplify implementation of wWarningFlags
Matthew Pickering [Fri, 7 Oct 2016 14:19:56 +0000 (15:19 +0100)] 
Simplify implementation of wWarningFlags

2 years agoDon't suggest deprecated flags in error messages
Martin Ceresa [Fri, 7 Oct 2016 12:54:10 +0000 (13:54 +0100)] 
Don't suggest deprecated flags in error messages

When looking up flags, we make sure to lookup the non-deprecated flags first
by ordering the list of flags.

Reviewers: bgamari, austin, mpickering

Reviewed By: mpickering

Subscribers: mpickering, thomie

Differential Revision:

GHC Trac Issues: #12574

2 years agoFix memory leak from #12664
Bartosz Nitka [Thu, 6 Oct 2016 12:40:24 +0000 (05:40 -0700)] 
Fix memory leak from #12664

This fixes the leak with `setProgArgv`. The problem was
that `setProgArgv` would not free the objects pointed
to by `prog_argc`, `prog_argv` when the globals were
changed resulting in a leak.

The only strictly necessary change is in `rts/RtsFlags.c`, but
the code in `System.Environment` was a bit confusing and not
exception safe, so I refactored it.

Test Plan: ./validate

Reviewers: simonmar, ezyang, austin, hvr, bgamari, erikd

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12664

2 years agoAdd compact to packages so it gets cleaned on make clean.
Edward Z. Yang [Thu, 6 Oct 2016 23:48:56 +0000 (16:48 -0700)] 
Add compact to packages so it gets cleaned on make clean.

Signed-off-by: Edward Z. Yang <>
2 years agoRemove dead code “mkHsConApp”
Joachim Breitner [Wed, 5 Oct 2016 20:14:59 +0000 (16:14 -0400)] 
Remove dead code “mkHsConApp”

Differential Revision:

2 years agoRegAlloc: Make some pattern matched complete
Joachim Breitner [Thu, 6 Oct 2016 03:37:03 +0000 (23:37 -0400)] 
RegAlloc: Make some pattern matched complete

these actually are complete, but due to the use of pattern guards, the
compiler does not see that. Refactor the code that it does.

Differential Revision:

2 years agoRefactor TcDeriv and TcGenDeriv
Ryan Scott [Thu, 6 Oct 2016 13:14:49 +0000 (09:14 -0400)] 
Refactor TcDeriv and TcGenDeriv

Keeping a promise I made to Simon to clean up these modules.

This change splits up the massive `TcDeriv` and `TcGenDeriv` modules into
somewhat more manageable pieces. The new modules are:

* `TcGenFunctor`: This contains the deriving machinery for `Functor`,
  `Foldable`, and `Traversable` (which all use the same underlying algorithm).
* `TcDerivInfer`: This is the new home for `inferConstraints`,
  `simplifyInstanceContexts`, and related functions, whose role is to come up
  with the derived instance context and subsequently simplify it.
* `TcDerivUtils`: This is a grab-bag module that contains several
  error-checking utilities originally in `TcDeriv`, as well as some functions
  that `TcDeriv` and `TcDerivInfer` both need.

The end result is that `TcDeriv` is now less than 1,600 SLOC (originally 2,686
SLOC), and `TcGenDeriv` is now about 2,000 SLOC (originally 2,964).

In addition, this also implements a couple of tiny refactorings:

* I transformed `type Condition = (DynFlags, TyCon) -> Validity` into
  `type Condition = DynFlags -> TyCon -> Validity`
* I killed the `DerivSpecGeneric` constructor for `DerivSpecMechanism`, and
  merged its functionality into `DerivSpecStock`. In addition,
  `hasStockDeriving` now contains key-value pairs for `Generic` and `Generic1`,
  so they're no longer treated as an awkward special case in `TcDeriv`.

Test Plan: ./validate

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie, mpickering

Differential Revision:

2 years agoRemove unused T12124.srderr
Ryan Scott [Thu, 6 Oct 2016 13:12:05 +0000 (09:12 -0400)] 
Remove unused T12124.srderr

This was (accidentally?) introduced in 465c6c5d15f8fb54afb78408f3a79e75e74d2cd4