2 years agoMake GHCi work when RebindableSyntax is enabled
Ryan Scott [Fri, 2 Jun 2017 15:49:47 +0000 (11:49 -0400)] 
Make GHCi work when RebindableSyntax is enabled

Previously, we were running some blocks of code at the start of every
GHCi sessions which use do-notation, something which doesn't work well
if you start GHCi with the `-XRebindableSyntax` flag on. This tweaks the
code to avoid the use of do-notation so that `-XRebindableSyntax` won't
reject it.

Test Plan: make test TEST=T13385

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13385

Differential Revision:

2 years agoRemove references to static flags in flag reference
Ryan Scott [Fri, 2 Jun 2017 15:48:57 +0000 (11:48 -0400)] 
Remove references to static flags in flag reference

A follow-up to #8440 (Ditch static flags). There are still some
lingering references to static flags in the flag reference, so let's
modify those references accordingly.

Test Plan: Build the documentation

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoAdd a flag reference entry for -XTypeInType
Ryan Scott [Fri, 2 Jun 2017 15:48:44 +0000 (11:48 -0400)] 
Add a flag reference entry for -XTypeInType

Test Plan: Read it

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13762

Differential Revision:

2 years agoBetter import library support for Windows
Tamar Christina [Fri, 2 Jun 2017 15:47:57 +0000 (11:47 -0400)] 
Better import library support for Windows

The import library support added for 7.10.3 was only a partial one.
This support was predicated on using file extensions to determine
whether or not a library was an import library. It also couldn't handle
libraries with multiple dll pointers.

This is a rewrite of that patch and fully integrating it into the normal
archive parsing and loading routines. This solves a host of issues,
among others allowing us to finally use `-lgcc_s`.

This also fixes a problem with our previous implementation, where we
just loaded the DLL and moved on. Doing this had the potential of using
the wrong symbol at resolve time. Say a DLL already loaded (A.dll) has
symbol a exported (dependency of another dll perhaps).

We find an import library `B.lib` explicitly defining an export of `a`.
we load `B.dll` but this gets put after `A.dll`, at resolve time we
would use the value from `A` instead of `B` which is what we wanted.

Test Plan: ./valide and make test TEST=13606

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, RyanGlScott, thomie, #ghc_windows_task_force

GHC Trac Issues: #13606, #12499, #12498

Differential Revision:

2 years agoaclocal: Fix regression in linker detection
Ben Gamari [Fri, 2 Jun 2017 13:36:01 +0000 (09:36 -0400)] 
aclocal: Fix regression in linker detection

5ddb307edf15c4d86e5c35c4063ec967424e19f2 regressed autoconf's ability to
find the linker due to a silly variable interpolation issue, causing
segmentation faults on AArch64.

2 years ago[iserv] move forkIO
Moritz Angermann [Sat, 27 May 2017 14:26:44 +0000 (10:26 -0400)] 
[iserv] move forkIO

This moves the forkIO into the `startSlave` function from the
`startSlave'` function, such that this allows consumers to call
`forkSlave'` if they want the blocking behaviour.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: Ericson2314, ryantrinkle, rwbarton, thomie

Differential Revision:

2 years agoA few typos [ci skip]
Gabor Greif [Fri, 2 Jun 2017 09:02:13 +0000 (11:02 +0200)] 
A few typos [ci skip]

2 years agoaclocal.m4: add support for versioned darwin triplets
Sergei Trofimovich [Thu, 1 Jun 2017 21:30:05 +0000 (22:30 +0100)] 
aclocal.m4: add support for versioned darwin triplets

The change adds support for 'darwin*' OS:
    $ ./configure --target=aarch64-apple-darwin14

Reported-by: jp_rider
Signed-off-by: Sergei Trofimovich <>
2 years agoFaster checkFamInstConsistency
Bartosz Nitka [Fri, 19 May 2017 15:08:01 +0000 (08:08 -0700)] 
Faster checkFamInstConsistency

This implements the idea from

It's explained in Note [Checking family instance optimization]
in more detail.

This improves the test case T13719 tenfold and
cuts down the compile time on `:load` in `ghci` on our
internal code base by half.

Test Plan: ./validate

Reviewers: simonpj, simonmar, rwbarton, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie

GHC Trac Issues: #13719

Differential Revision:

2 years agoEfficient checks for stable modules
Bartosz Nitka [Tue, 30 May 2017 11:48:57 +0000 (04:48 -0700)] 
Efficient checks for stable modules

With a large number of modules in a home package
(in my case 5000) the costs of linear lookups becomes significant.
This changes them to efficient IntMap lookups.

It reduces the cost of `:reload` on unchanged source
from 5.77s to 1.62s on my test case.

I could go further and make `Linker.unload` also take a set,
but I prefer to concentrate on one thing at a time.

Test Plan: harbormaster

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoModern type signature style in UniqSet
Bartosz Nitka [Mon, 29 May 2017 22:30:06 +0000 (15:30 -0700)] 
Modern type signature style in UniqSet

2 years agoRemove HsContext from ppr_mono_ty, and remove ppParendHsType
Alan Zimmerman [Fri, 26 May 2017 15:06:11 +0000 (17:06 +0200)] 
Remove HsContext from ppr_mono_ty, and remove ppParendHsType

This is a cleanup after Trac #13238, as the context was no longer being used.

2 years agoFix test output after 'Some tidying up of type pretty-printing'
Bartosz Nitka [Sat, 27 May 2017 14:42:26 +0000 (07:42 -0700)] 
Fix test output after 'Some tidying up of type pretty-printing'

Most are cosmetic. There's an interesting change in T7861,
but the error is still accurate.

2 years agoFix build after 'Shrink a couple of hs-boot files'
Bartosz Nitka [Sat, 27 May 2017 13:06:16 +0000 (06:06 -0700)] 
Fix build after 'Shrink a couple of hs-boot files'

2 years agotemplate-haskell: Properly escape StrTyLit doc
Eric Mertens [Thu, 25 May 2017 23:44:18 +0000 (16:44 -0700)] 
template-haskell: Properly escape StrTyLit doc

2 years agouser-guide: Add since annotation for -Wcpp-undef
Erik de Castro Lopo [Sat, 27 May 2017 04:54:42 +0000 (14:54 +1000)] 
user-guide: Add since annotation for -Wcpp-undef

Reviewers: hvr, bgamari, austin

Reviewed By: hvr

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoAdd regression test for #12648
Ryan Scott [Sat, 27 May 2017 01:28:28 +0000 (21:28 -0400)] 
Add regression test for #12648

Commit ce97b7298d54bdfccd9dcf366a69c5617b4eb43f (the fix for #12175) also
fixed #12648. Let's add a regression test so that it stays fixed.

2 years agoAdd regression test for #13758
Ryan Scott [Fri, 26 May 2017 22:47:28 +0000 (18:47 -0400)] 
Add regression test for #13758

2 years agoRevert "Rewrite boot in Python"
Ben Gamari [Fri, 26 May 2017 22:27:37 +0000 (18:27 -0400)] 
Revert "Rewrite boot in Python"

This reverts commit 0440af6abe592c2366d302d603664fe763ad0828.
Unfortunately this breaks on Windows for tiresome reasons. I'll need to
reevaluate this.

2 years agoTypos in comments [ci skip]
Gabor Greif [Fri, 26 May 2017 09:08:54 +0000 (11:08 +0200)] 
Typos in comments [ci skip]

2 years agoSome tidying up of type pretty-printing
Simon Peyton Jones [Thu, 25 May 2017 15:18:06 +0000 (16:18 +0100)] 
Some tidying up of type pretty-printing

Triggered by the changes in #13677, I ended up doing a bit of
refactoring in type pretty-printing.

* We were using TyOpPrec and FunPrec rather inconsitently, so
  I made it consisent.

* That exposed the fact that we were a bit undecided about whether
  to print
     a + b -> c + d   vs   (a+b) -> (c+d)
  and similarly
     a ~ [b] => blah  vs   (a ~ [b]) => blah

  I decided to make TyOpPrec and FunPrec compare equal
  (in BasicTypes), so (->) is treated as equal precedence with
  other type operators, so you get the unambiguous forms above,
  even though they have more parens.

  We could readily reverse this decision.
  See Note [Type operator precedence] in BasicTypes

* I fixed a bug in pretty-printing of HsType where some
  parens were omitted by mistake.

2 years agoShrink a couple of hs-boot files
Simon Peyton Jones [Thu, 25 May 2017 15:07:09 +0000 (16:07 +0100)] 
Shrink a couple of hs-boot files

IfaceType.hs-boot and ToIface.hs-boot were bigger than they
needed to be, so I'm shrinking them.

2 years agoRe-engineer Given flatten-skolems
Simon Peyton Jones [Fri, 26 May 2017 08:31:38 +0000 (09:31 +0100)] 
Re-engineer Given flatten-skolems

The big change here is to fix an outright bug in flattening of Givens,
albeit one that is very hard to exhibit.  Suppose we have the constraint
    forall a. (a ~ F b) => ..., (forall c. ....(F b)...) ...

 - we'll flatten the (F) b to a fsk, say  (F b ~ fsk1)
 - we'll rewrite the (F b) inside the inner implication to 'fsk1'
 - when we leave the outer constraint we are suppose to unflatten;
   but that fsk1 will still be there
 - if we re-simplify the entire outer implication, we'll re-flatten
   the Given (F b) to, say, (F b ~ fsk2)
Now we have two fsks standing for the same thing, and that is very

Solution: make fsks behave more like fmvs:
 - A flatten-skolem is now a MetaTyVar, whose MetaInfo is FlatSkolTv
 - We "fill in" that meta-tyvar when leaving the implication
 - The old FlatSkol form of TcTyVarDetails is gone completely
 - We track the flatten-skolems for the current implication in
   a new field of InertSet, inert_fsks.

See Note [The flattening story] in TcFlatten.

In doing this I found various other things to fix:

* I removed the zonkSimples from TcFlatten.unflattenWanteds; it wasn't
  needed.   But I added one in TcSimplify.floatEqualities, which does
  the zonk precisely when it is needed.

* Trac #13674 showed up a case where we had
     - an insoluble Given,   e.g.  a ~ [a]
     - the same insoluble Wanted   a ~ [a]
  We don't use the Given to rewwrite the Wanted (obviously), but
  we therefore ended up reporting
      Can't deduce (a ~ [a]) from (a ~ [a])
  which is silly.

  Conclusion: when reporting errors, make the occurs check "win"
  See Note [Occurs check wins] in TcErrors

2 years agoMake isInsolubleOccursCheck more aggressive
Simon Peyton Jones [Fri, 26 May 2017 08:27:08 +0000 (09:27 +0100)] 
Make isInsolubleOccursCheck more aggressive

  type family F a :: * -> *

Then (a ~ F Int a) is an insoluble occurs check, and can be reported
as such.  Previous to this patch, TcType.isInsolubleOccursCheck was
treating any type-family application (including an over-saturated one)
as unconditionally not-insoluble.

This really only affects error messages, and then only slightly. I
tripped over this when investigating  Trac #13674.

2 years agoA bit more tc-tracing
Simon Peyton Jones [Fri, 26 May 2017 08:24:14 +0000 (09:24 +0100)] 
A bit more tc-tracing

2 years agorules: add per-library EXTRA_HC_OPTS
Sergei Trofimovich [Thu, 25 May 2017 21:44:37 +0000 (22:44 +0100)] 
rules: add per-library EXTRA_HC_OPTS

Sometimes it's handy to change a compiler flag
for a library in stage{0,1,2}.

Usage example:

    libraries/binary_EXTRA_HC_OPTS += -O1
    libraries/containers_EXTRA_HC_OPTS += -O1
    libraries/bytestring_EXTRA_HC_OPTS += -O1

Here override default -O2 defined in .cabal files
for these libraries to speed build up.

Signed-off-by: Sergei Trofimovich <>
2 years agoPattern synonyms and higher rank types
Simon Peyton Jones [Thu, 25 May 2017 08:59:29 +0000 (09:59 +0100)] 
Pattern synonyms and higher rank types

This patch fixes two separate bugs which contributed to making
Trac #13752 go wrong

1.  We need to use tcSubType, not tcUnify,
    in tcCheckPatSynDecl.tc_arg.

    Reason: Note [Pattern synonyms and higher rank types]

2.  TcUnify.tc_sub_type had a special case designed to improve error
    messages; see Note [Don't skolemise unnecessarily].  But the
    special case was too liberal, and ended up using unification
    (which led to rejecting the program) when it should instead taken
    the normal path (which accepts the program).

    I fixed this by making the test more conservative.

2 years agoComments only
Simon Peyton Jones [Thu, 25 May 2017 08:59:09 +0000 (09:59 +0100)] 
Comments only

2 years agoTypos in comments and manual [ci skip]
Gabor Greif [Tue, 23 May 2017 10:08:25 +0000 (12:08 +0200)] 
Typos in comments and manual [ci skip]

2 years agorts: Make compact debugging output depend upon compact debug flag
Ben Gamari [Tue, 23 May 2017 14:33:58 +0000 (10:33 -0400)] 
rts: Make compact debugging output depend upon compact debug flag

2 years agobase: Fix a few TODOs in Typeable.Internal
Ben Gamari [Tue, 23 May 2017 13:42:12 +0000 (09:42 -0400)] 
base: Fix a few TODOs in Typeable.Internal

Test Plan: Validate

Reviewers: austin, hvr, dfeuer

Reviewed By: dfeuer

Subscribers: rwbarton, thomie

GHC Trac Issues: #13746

Differential Revision:

2 years rename installed ghc-stage1 on non-windows
Sergei Trofimovich [Tue, 23 May 2017 08:45:50 +0000 (09:45 +0100)] rename installed ghc-stage1 on non-windows

When user installs _native_ build ghc executable is renamed
from '$(libexec)/bin/ghc-stage<N>' to '$(libexec)/bin/ghc'.
But not on windows!

In case of _cross-compiler_ rename should happen only
for '$(libexec)/bin/ghc-stage<N>' runnable on non-windows

Before the change '$(libexec)/bin/ghc-stage<N>' rename happened
for any compiler not targeting windows.

After the patch rename also happens for '$(libexec)/bin/ghc-stage1'
cross-compiler built for linux targeting windows (Stage1Only=YES case).

Or on a concrete example:

   # host is x86_64-pc-linux-gnu
   $ ./configure --target=i686-w64-mingw32
   $ make install Stage1Only=YES

Before the change the layout was:
   - '$(libexec)/bin/ghc-stage1' was installed
   - bin/ghc contained 'exec $(libexec)/bin/ghc' # missing file!
After the change:
   - '$(libexec)/bin/ghc' was installed
   - bin/ghc contained 'exec $(libexec)/bin/ghc' # present file

Signed-off-by: Sergei Trofimovich <>
2 years agomk/ lower -O2 optimization down to -O1 on UNREG
Sergei Trofimovich [Tue, 23 May 2017 08:36:50 +0000 (09:36 +0100)] 
mk/ lower -O2 optimization down to -O1 on UNREG

It's not a new behaviour. First it was introduced by
("lower -O2 optimization down to -O1 on UNREG") to fix build
failure on unregisterised powerpc64.

This time I've noticed build failures on unregisterised ia64.

The change was accidentally reverted by commit
("Build system: Add stage specific SRC_HC_(WARNING_)OPTS)

The revert happened due to the following code rearrangement:

    ifeq "$(GhcUnregisterised)" "YES"


As a result 'ifeq' part has no effect.

The change moves 'ifeq' down to the very end of file
and adds a note it depends on the 'GhcUnregisterised' variable.

Signed-off-by: Sergei Trofimovich <>
2 years agoaclocal.m4: allow override of dllwrap and windres when cross-compiling
Sergei Trofimovich [Tue, 23 May 2017 08:13:43 +0000 (09:13 +0100)] 
aclocal.m4: allow override of dllwrap and windres when cross-compiling

Commit 66108864540601837ad77847f4062a670362361f reverted ability
to override 'dllwrap' and 'windres' paths when cross-compiling.

After this change (and a few libraries/Win32 patches) I was able
to build cross-compiler to windows:

    $ ./configure --target=i686-w64-mingw32 \
        DllWrap=i686-w64-mingw32-dllwrap \

Later both 'dllwrap' and 'windres' should be derived from --target=
as we do now for 'CC', 'AR', 'NM' and others.

Signed-off-by: Sergei Trofimovich <>
2 years agoExtend ModuleSet with useful functions
Bartosz Nitka [Mon, 22 May 2017 17:16:26 +0000 (10:16 -0700)] 
Extend ModuleSet with useful functions

2 years agoTestcase for type family consistency checks
Bartosz Nitka [Mon, 22 May 2017 16:01:05 +0000 (12:01 -0400)] 
Testcase for type family consistency checks

Based on my quick search, we don't have a test
that verifies that we check the type family instances of
currently compiled module against direct or indirect

This adds two tests: for a direct dependency and
for an indirect dependency.

I also added a comment to make it clear what the 'Over'
test tests.

Other than completeness, it makes sense to have these
tests because if you look at
Note [The type family instance consistency story] in FamInsts
these cases are checked through different mechanisms.

Test Plan: new tests

Reviewers: simonmar, rwbarton, simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: thomie

GHC Trac Issues: #13719

Differential Revision:

2 years agoTestcase for #13719
Bartosz Nitka [Mon, 22 May 2017 16:00:52 +0000 (12:00 -0400)] 
Testcase for #13719

I expect to improve this, a testcase will ensure
it doesn't regress.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13719

Differential Revision:

2 years agoAdd "header" to GHC_COLORS
Phil Ruffwind [Mon, 22 May 2017 16:00:34 +0000 (12:00 -0400)] 
Add "header" to GHC_COLORS

Add "header" to GHC_COLORS and allow colors to be inherited from the

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13718

Differential Revision:

2 years agoHandle file targets in missing home modules warning
Herbert Valerio Riedel [Mon, 22 May 2017 15:59:56 +0000 (11:59 -0400)] 
Handle file targets in missing home modules warning

When main module is listed on command line as a file, we should not
issue a warning about it. See Trac #13727

Reviewers: austin, bgamari, Yuras

Reviewed By: bgamari, Yuras

Subscribers: 23Skidoo, rwbarton, thomie

GHC Trac Issues: #13727

Differential Revision:

2 years agofix a memory leak in osNumaMask
Kubo Kovac [Mon, 22 May 2017 15:51:55 +0000 (11:51 -0400)] 
fix a memory leak in osNumaMask

got an error when using asan:
==1866689==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x10640568 in malloc ??:?
    #1 0x154d867e in numa_bitmask_alloc .../numactl-2.0.8/libnuma_nosymve r.c:204
    #2 0x154d867e in numa_allocate_nodemask .../numactl-2.0.8/libnuma_nosymve r.c:724
    #3 0x154d867e in numa_get_mems_allowed .../numactl-2.0.8/libnuma_nosymve r.c:1141
    #4 0x10b54a45 in osNumaMask ...ghc-8.0.2/rts/posix/OSMem.c:59 8

Test Plan: compile, validate

Reviewers: simonmar, niteria, austin, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoRewrite boot in Python
Ben Gamari [Mon, 22 May 2017 15:50:55 +0000 (11:50 -0400)] 
Rewrite boot in Python

Test Plan: Validate

Reviewers: hvr, austin

Subscribers: rwbarton, thomie, erikd

Differential Revision:

2 years agoEnsure package.cache is newer than registration files after make install
Ben Gamari [Sun, 21 May 2017 15:11:30 +0000 (11:11 -0400)] 
Ensure package.cache is newer than registration files after make install

Rebuild package.cache to ensure that it's newer than the package
database registration files, avoiding out-of-date cache warnings from
ghc-pkg. See #13375.

Test Plan: `make install`, run `ghc-pkg list`, look for out-of-date
cache warning

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13375

Differential Revision:

2 years agoAdd missing "do" to example in arrow docs.
null-a [Mon, 22 May 2017 09:13:14 +0000 (10:13 +0100)] 
Add missing "do" to example in arrow docs.

2 years agoFix levity polymorphism docs
Alexey Vagarenko [Sun, 21 May 2017 10:08:41 +0000 (15:08 +0500)] 
Fix levity polymorphism docs

2 years agoBump to LLVM 4.0
Moritz Angermann [Sat, 20 May 2017 16:57:15 +0000 (12:57 -0400)] 
Bump to LLVM 4.0

The llvm textual ir seems to have stayed sufficiently similar from llvm
3.9 to llvm 4.0, such that a simple bump is possible.

Reviewers: austin, hvr, bgamari, erikd

Reviewed By: bgamari, erikd

Subscribers: rwbarton, thomie, erikd

Differential Revision:

2 years agoPretty-print strict record fields from ifaces correctly
Ryan Scott [Sat, 20 May 2017 16:56:50 +0000 (12:56 -0400)] 
Pretty-print strict record fields from ifaces correctly

We need to use parentheses more when pretty-printing types with bang
patterns within constructors that use record syntax. Fixes #13699.

Test Plan: make test TEST=T13699

Reviewers: austin, bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, rwbarton, thomie

GHC Trac Issues: #13699

Differential Revision:

2 years agoA few documentation fixes
David Feuer [Sat, 20 May 2017 16:56:20 +0000 (12:56 -0400)] 
A few documentation fixes

`MIN_VERSION_pkg` was documented backwards. An important caveat
about initializing the Haskell runtime was buried in a footnote.
The documentation of `-dynamic` was (even more) confusing.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoCorrectly expand lines with multiple tabs
Phil Ruffwind [Sat, 20 May 2017 16:48:26 +0000 (12:48 -0400)] 
Correctly expand lines with multiple tabs

rwbarton pointed out that tab expansions can affect the column numbers
of subsequent characters, so a unstateful map + zip won't do.  This
commit hopefully fixes that.  It also adds a test for this particular

Test Plan: validate

Reviewers: bgamari, rwbarton, austin

Reviewed By: bgamari

Subscribers: dfeuer, thomie

Differential Revision:

2 years agobase: Explicitly mark Data.Either.{left,right} as INLINABLE
Ben Gamari [Sat, 20 May 2017 16:48:03 +0000 (12:48 -0400)] 
base: Explicitly mark Data.Either.{left,right} as INLINABLE

Test Plan: read it

Reviewers: dfeuer, austin, hvr, nomeata

Reviewed By: dfeuer, nomeata

Subscribers: nomeata, rwbarton, thomie

GHC Trac Issues: #13689

Differential Revision:

2 years agoCompile modules that are needed by template haskell, even with -fno-code.
Douglas Wilson [Sat, 20 May 2017 16:47:41 +0000 (12:47 -0400)] 
Compile modules that are needed by template haskell, even with -fno-code.

This patch relates to Trac #8025

The goal here is to enable typechecking of packages that contain some
template haskell. Prior to this patch, compilation of a package with
-fno-code would fail if any functions in the package were called from
within a splice.

downsweep is changed to do an additional pass over the modules,
targetting any ModSummaries transitively depended on by a module that
has LangExt.TemplateHaskell enabled. Those targeted modules have
hscTarget changed from HscNothing to the default target of the platform.

There is a small change to the prevailing_target logic to enable this.

A simple test is added.

I have benchmarked with and without a patched haddock
lation).  Running cabal haddock on the wreq package results in a 25%
speedup on my machine:

time output from patched cabal haddock:

real    0m5.780s
user    0m5.304s
sys     0m0.496s
time output from unpatched cabal haddock:

real    0m7.712s
user    0m6.888s
sys     0m0.736s

Reviewers: austin, bgamari, ezyang

Reviewed By: bgamari

Subscribers: bgamari, DanielG, rwbarton, thomie

GHC Trac Issues: #8025

Differential Revision:

2 years agoCNF: Silence pointer fix-up message unless gc debugging is enabled
Ben Gamari [Wed, 17 May 2017 14:22:55 +0000 (10:22 -0400)] 
CNF: Silence pointer fix-up message unless gc debugging is enabled

2 years agoFailing test case for #13734
Joachim Breitner [Sat, 20 May 2017 18:09:21 +0000 (14:09 -0400)] 
Failing test case for #13734

2 years agoImprove error msg for simplifier tick exhaustion
David Feuer [Fri, 19 May 2017 22:09:43 +0000 (18:09 -0400)] 
Improve error msg for simplifier tick exhaustion

Simplifier tick exhaustion is not necessarily "impossible", and
isn't even always a GHC bug, per se. Improve the error message.
Furthermore, the simplifier code has access to `IO`, so we can
throw a proper `IO` exception instead of panicking.

Reviewers: austin, bgamari, angerman

Reviewed By: angerman

Subscribers: angerman, rwbarton, thomie

Differential Revision:

2 years agoModern type signature style in Module
Bartosz Nitka [Fri, 19 May 2017 14:54:06 +0000 (07:54 -0700)] 
Modern type signature style in Module

2 years agoFix scoping of data cons during kind checking
Simon Peyton Jones [Fri, 19 May 2017 13:57:59 +0000 (14:57 +0100)] 
Fix scoping of data cons during kind checking

Trac #13625 pointed out that in

   data X :: Y where Y :: X

we need 'Y' to be in scope (as APromotionErr) when dealing with
X's kind signature.  Previously we got a crash.

This patch simplifies the code as well as making it work.

2 years agoAccount for IfUnpackCo in freeNamesIfDecl
Simon Peyton Jones [Fri, 19 May 2017 11:00:26 +0000 (12:00 +0100)] 
Account for IfUnpackCo in freeNamesIfDecl

We were simply failing to recognise all the free variables of an
IfaceDecl, notably the ones in the coercion of an IfUnpackCo.
Result: the dependency analysis got messed up, so that fingerprint
calculation went wrong.  Trac #13695 showed it up.

A test case is tricky but the fix is a solid one.

2 years agoRefactor freeNamesIfDecl
Simon Peyton Jones [Fri, 19 May 2017 10:57:21 +0000 (11:57 +0100)] 
Refactor freeNamesIfDecl

This just switches to using pattern matching rather than field
selectors, which I generally prefer.  No change in behaviour.

2 years agoComments and white space only
Simon Peyton Jones [Fri, 19 May 2017 10:55:38 +0000 (11:55 +0100)] 
Comments and white space only

2 years agoFix Haddock markup
Alexey Vagarenko [Thu, 18 May 2017 21:49:18 +0000 (02:49 +0500)] 
Fix Haddock markup

2 years agoEnsure that insolubles are fully rewritten
Simon Peyton Jones [Fri, 19 May 2017 09:50:35 +0000 (10:50 +0100)] 
Ensure that insolubles are fully rewritten

I was alerted to this by Trac #12468 and #11325.  We were treating
insolubles (and "hole" constraints are treated as insoluble)
inconsistently.  In some places we were carefully rewriting them
e.g. Note [Make sure that insolubles are fully rewritten] in
TcCanonical.  But in TcSimplify we weren't feeding them into
the solver.

As a result, "hole" constraints were not being rewritten, which
some users found confusing, and I think rightly so.

This patch also fixes a bug in TcSMonad.emitInsoluble, in which two
different "hole" constriants could be treated (bogusly) as duplicates,
thereby losing one.

2 years agoInsert missing newline
Frederik Hanghøj Iversen [Thu, 18 May 2017 12:26:10 +0000 (14:26 +0200)] 
Insert missing newline

2 years agoHandle type-lets better
Simon Peyton Jones [Wed, 17 May 2017 08:44:46 +0000 (09:44 +0100)] 
Handle type-lets better

Core allows non-recursive type-lets, thus

   let a = TYPE ty in ...

They are substituted away very quickly, but it's convenient for
some passes to produce them (rather than to have to substitute

Trac #13708 tried the effect of not running the simplifer at all
(a rather bizarre thing to do, but still).  That showed that some
passes crashed because they always treated a let-bounder binder
as an Id.  This patch adds some easy fixes.

2 years agoFix #13703 by correctly using munged names in ghc-pkg.
Edward Z. Yang [Tue, 16 May 2017 04:17:45 +0000 (21:17 -0700)] 
Fix #13703 by correctly using munged names in ghc-pkg.

Cabal internal libraries are implemented using a trick, where the 'name'
field in ghc-pkg registration file is munged into a new form to keep
each internal library looking like a distinct package to ghc-pkg and
other tools; e.g. the internal library q from package p is named

Later, Cabal library got refactored so that we made a closer distinction
between these "munged" package names and the true package name of a
package.  Unfortunately, this is an example of a refactor for clarity in
the source code which ends up causing problems downstream, because the
point of "munging" the package name was to make it so that ghc-pkg and
similar tools transparently used MungedPackageName whereever they
previously used PackageName (in preparation for them learning proper
syntax for package name + component name).  Failing to do this meant
that internal libraries from the same package (but with different
names) clobber each other.

This commit search-replaces most occurrences of PackageName in
ghc-pkg and turns them into MungedPackageName. Otherwise there
shouldn't be any functional differenes.

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

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13703

Differential Revision:

2 years agoFix the pure unifier
Simon Peyton Jones [Tue, 16 May 2017 14:43:55 +0000 (15:43 +0100)] 
Fix the pure unifier

This patch fixes Trac #13705, by fixing a long-standing outright bug
in the pure unifier.  I'm surprised this hasn't caused more trouble
before now!

2 years agoTiny refactor
Simon Peyton Jones [Tue, 16 May 2017 14:42:34 +0000 (15:42 +0100)] 
Tiny refactor

2 years agoKill off unused IfaceType.eqIfaceType
Simon Peyton Jones [Tue, 16 May 2017 10:56:23 +0000 (11:56 +0100)] 
Kill off unused IfaceType.eqIfaceType

Edward implemented these functions, but they aren't
used any more.  Trac #13679

2 years agotestsuite: Add testcase for T13658
Ben Gamari [Tue, 16 May 2017 00:15:11 +0000 (20:15 -0400)] 
testsuite: Add testcase for T13658

2 years agoPrint warnings on parser failures (#12610).
Dave Laing [Mon, 15 May 2017 20:09:11 +0000 (16:09 -0400)] 
Print warnings on parser failures (#12610).

Test Plan: validate

Reviewers: austin, bgamari, simonmar, mpickering

Reviewed By: mpickering

Subscribers: mpickering, rwbarton, thomie

GHC Trac Issues: #12610

Differential Revision:

2 years agousers-guide: Document -g flag
Ben Gamari [Mon, 15 May 2017 18:21:38 +0000 (14:21 -0400)] 
users-guide: Document -g flag

2 years agoRevert "Use a deterministic map for imp_dep_mods"
Bartosz Nitka [Mon, 15 May 2017 11:44:35 +0000 (04:44 -0700)] 
Revert "Use a deterministic map for imp_dep_mods"

This reverts commit 7fea7121ce195e562a5443c0a8ef3861504ef1b3.
It turns out that on a newly added MultiLayerModules test
case it gets very expensive to union the transitive module
sets while preserving determinism.

Fortunately, we can just sort to restore determinism
when converting imp_dep_mods to a list.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoStress test for nested module hierarchies
Bartosz Nitka [Fri, 12 May 2017 13:38:18 +0000 (06:38 -0700)] 
Stress test for nested module hierarchies

I'm optimizing a case that is well approximated by
multiple layers of modules where every module in a layer
imports all the modules in the layer below.

It turns out I regressed performance on such cases in 7fea7121.
I'm adding a test case to track improvements and prevent
future regressions.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoRevert "Stress test for nested module hierarchies"
Bartosz Nitka [Mon, 15 May 2017 11:21:52 +0000 (04:21 -0700)] 
Revert "Stress test for nested module hierarchies"

This reverts commit e527fc2e90958280a36645b6bd0223861cc50a55.

I merged more than I intended in e527fc2e, I will merge
D3575 and D3577 separately.

2 years agoStress test for nested module hierarchies
Bartosz Nitka [Mon, 15 May 2017 11:14:01 +0000 (04:14 -0700)] 
Stress test for nested module hierarchies

I'm optimizing a case that is well approximated by
multiple layers of modules where every module in a layer
imports all the modules in the layer below.

It turns out I regressed performance on such cases in 7fea7121.
I'm adding a test case to track improvements and prevent
future regressions.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision:

2 years agorts/linker/ElfTypes.h: restore powerps (and others) support
Sergei Trofimovich [Sun, 14 May 2017 19:33:16 +0000 (20:33 +0100)] 
rts/linker/ElfTypes.h: restore powerps (and others) support

GHC build fails for powerpc-unknown-linux-gnu
and hppa-unknown-linux-gnu targets as:
  rts_dist_HC rts/dist/build/RtsStartup.o
    rts/linker/ElfTypes.h:23:4: error:
         error: #error "Unsupported arch!"

Before the change code tried to whitelist architectures
and classify them into ELF32/ELF64. It does not work
for UNREG arches like 'hppa', 'sparc64', 'm68k', 'mips'.

It is nuanced for things like mips64 and x86_64:
    'mips64-unknown-linux-gnu-gcc -mabi=64' is ELFCLASS64
    'mips64-unknown-linux-gnu-gcc'          is ELFCLASS32
    'x86_64-pc-linux-gnu-gcc'               is ELFCLASS64
    'x86_64-pc-linux-gnu-gcc -mx32'         is ELFCLASS32
Here it's not enough to know HOST_ARCH. We really need to
know ABI.

The change uses '__LP64__' as a proxy for ELFCLASS64.

Signed-off-by: Sergei Trofimovich <>
Reviewers: angerman, simonmar, austin, bgamari, erikd

Reviewed By: angerman, bgamari, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #13696

Differential Revision:

2 years agorts: annotate switch/case with '/* fallthrough */'
Sergei Trofimovich [Sun, 14 May 2017 19:22:37 +0000 (20:22 +0100)] 
rts: annotate switch/case with '/* fallthrough */'

Fixes gcc-7.1.0 warnings of form:

  rts/sm/Scav.c:559:9: error:
     error: this statement may fall through [-Werror=implicit-fallthrough=]

Many of places are indeed unobvious and some are
already annotated by comments.

Signed-off-by: Sergei Trofimovich <>
2 years agoProfilerReportJson.c: fix out-of-bounds access
Sergei Trofimovich [Sun, 14 May 2017 19:21:50 +0000 (20:21 +0100)] 
ProfilerReportJson.c: fix out-of-bounds access

Found by gcc-7.1 which reported build error as:

rts/ProfilerReportJson.c:23:16: error:
     error: comparison between pointer and zero
       character constant [-Werror=pointer-compare]
         for (; str != '\0' && len > 0; str++) {
23 |     for (; str != '\0' && len > 0; str++) {
   |                ^

Unfixed code in context:

  static void escapeString(char const* str, char *out, int len)
     len--; // reserve character in output for terminating NUL
     for (; str != '\0' && len > 0; str++) {
         char c = *str;

The intent here is to process 'len' (if positive) or '\0'-terminator
in 'str' but dereference was missing.

Signed-off-by: Sergei Trofimovich <>
2 years agoUpdate unix submodule
Ben Gamari [Sun, 14 May 2017 01:19:45 +0000 (21:19 -0400)] 
Update unix submodule

2 years agoincludes/Stg.h: '#if sparch_HOST_ARCH' -> '#if defined(sparch_HOST_ARCH)'
Sergei Trofimovich [Sun, 14 May 2017 08:17:37 +0000 (09:17 +0100)] 
includes/Stg.h: '#if sparch_HOST_ARCH' -> '#if defined(sparch_HOST_ARCH)'

Signed-off-by: Sergei Trofimovich <>
2 years agoAdd a test for #12600
David Feuer [Sat, 13 May 2017 23:26:59 +0000 (19:26 -0400)] 
Add a test for #12600

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12600

Differential Revision:

2 years agoAdd a test for #11272
David Feuer [Sat, 13 May 2017 20:09:31 +0000 (16:09 -0400)] 
Add a test for #11272

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #11272

Differential Revision:

2 years agoRevert "Treat banged bindings as FunBinds"
Ben Gamari [Fri, 12 May 2017 20:59:33 +0000 (16:59 -0400)] 
Revert "Treat banged bindings as FunBinds"

This partially reverts commit 372995364c52eef15066132d7d1ea8b6760034e6 as it
doesn't actually fix #13594. Namely it does not revert the mkPrefixFunRhs
refactoring since this is rather independent from the functional changes.

Going to try again with a whole working patch

2 years agoBump haddock submodule
Ben Gamari [Fri, 12 May 2017 18:48:03 +0000 (14:48 -0400)] 
Bump haddock submodule

Fixes lazy IO bug

2 years agoRender \t as 8 spaces in caret diagnostics
Phil Ruffwind [Thu, 11 May 2017 19:41:08 +0000 (15:41 -0400)] 
Render \t as 8 spaces in caret diagnostics

Test Plan: validate

Reviewers: austin, bgamari, rwbarton

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13664

Differential Revision:

2 years agoFix crash in isModuleInterpreted for HsBoot (fixes #13591)
Lennart Spitzner [Wed, 10 May 2017 14:47:19 +0000 (16:47 +0200)] 
Fix crash in isModuleInterpreted for HsBoot (fixes #13591)

Rename isModuleInterpreted to moduleIsBootOrNotObjectLinkable
because a) there already is a moduleIsInterpreted function in
the same module b) I have no idea if the (new) semantic of
the bool returned matches some understanding of
"is interpreted".

2 years agoAutomatically add SCCs to INLINABLE bindings
David Feuer [Fri, 12 May 2017 18:37:36 +0000 (14:37 -0400)] 
Automatically add SCCs to INLINABLE bindings

Instead of excluding `isAnyInlinePragma`, just exclude
`isInlinePragma`. This makes GHC behave as documented;
the user's guide only indicates that GHC does not automatically
add SCCs to `INLINE` bindings.

Fixes #12962.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: DemiMarie, osa1, Mikolaj, simonpj, rwbarton, thomie

GHC Trac Issues: #12962

Differential Revision:

2 years agoAdd regression test for #11964
Ryan Scott [Fri, 12 May 2017 13:06:24 +0000 (09:06 -0400)] 
Add regression test for #11964

This issue was only ever present in the GHC 8.0.1 release candidates, but
let's add a regression test for it just to be safe.

2 years agoAdd regression test for #11966
Ryan Scott [Fri, 12 May 2017 12:57:26 +0000 (08:57 -0400)] 
Add regression test for #11966

Commit a7ee2d4c4229b27af324ebac93081f692835365d fixed #11966. Here's a
regression test for it.

2 years agoAdd regression tests for #12083
Ryan Scott [Fri, 12 May 2017 12:54:30 +0000 (08:54 -0400)] 
Add regression tests for #12083

Commit 0c9d9dec0a924a4f34f4cff26d004143c028861a (the fix for #13271) fixed the
programs in #12083. This adds regression tests for them.

Test Plan: make test TEST="T12083a T12083b"

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12083

Differential Revision:

2 years agoTypos [ci skip]
Gabor Greif [Thu, 11 May 2017 13:13:02 +0000 (15:13 +0200)] 
Typos [ci skip]

2 years agoUpdate autoconf scripts from correct source
Ben Gamari [Fri, 12 May 2017 01:33:58 +0000 (21:33 -0400)] 
Update autoconf scripts from correct source

2 years agoRnEnv refactoring
Matthew Pickering [Thu, 11 May 2017 21:21:43 +0000 (22:21 +0100)] 
RnEnv refactoring

Summary: Lots of refactoring in RnEnv to reduce code duplication.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13545

Differential Revision:

2 years agotestsuite: Fix location of T13594 test
Ben Gamari [Thu, 11 May 2017 22:20:33 +0000 (18:20 -0400)] 
testsuite: Fix location of T13594 test

2 years agoFix up tests for #13594
Ben Gamari [Thu, 11 May 2017 21:30:31 +0000 (17:30 -0400)] 
Fix up tests for #13594

This adds the GHCi variant of the failing program in #13594. Also, I
inadvertently changed the T13594 test previously introduced in a way that made
it no longer faithfully test the ticket as written. Fix this.

2 years agoUpdate autoconf scripts
Ben Gamari [Thu, 11 May 2017 21:25:40 +0000 (17:25 -0400)] 
Update autoconf scripts

2 years agousers-guide: Document requirement of at least one -dep-suffix
Ben Gamari [Thu, 11 May 2017 20:49:54 +0000 (16:49 -0400)] 
users-guide: Document requirement of at least one -dep-suffix

This requirement was introduced around 7.8 but was never documented.

Resolves #9287.

2 years agoAllow spliced patterns in pattern synonyms
Ben Gamari [Thu, 11 May 2017 19:46:37 +0000 (15:46 -0400)] 
Allow spliced patterns in pattern synonyms

This ended up being quite simple.

Reviewers: austin, goldfire, mpickering

Subscribers: rwbarton, shlevy, thomie

GHC Trac Issues: #13688

Differential Revision:

2 years agoFix collect_lpat's treatment of HsSplicedPats
Ryan Scott [Thu, 11 May 2017 19:46:02 +0000 (15:46 -0400)] 
Fix collect_lpat's treatment of HsSplicedPats

`collect_lpat` was missing a case for `HsSplicedPat`, which caused
incorrect renaming of TH-spliced pattern variables.

Fixes #13473.

Test Plan: make test TEST=T13473

Reviewers: facundominguez, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13473

Differential Revision:

2 years agoParenthesize pretty-printed equalities when necessary
Ryan Scott [Thu, 11 May 2017 19:42:55 +0000 (15:42 -0400)] 
Parenthesize pretty-printed equalities when necessary

Fixes #13677 by parenthesizing equalities in a sufficiently high
pretty-printing context.

Test Plan: make test TEST=T13677

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13677

Differential Revision:

2 years agoUse Proxy rather than undefined in MatchLit
Matthew Pickering [Thu, 11 May 2017 19:42:23 +0000 (15:42 -0400)] 
Use Proxy rather than undefined in MatchLit

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoAdd Outputable instance for Node
Matthew Pickering [Thu, 11 May 2017 19:42:02 +0000 (15:42 -0400)] 
Add Outputable instance for Node

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: