17 months agoFix #14681 and #14682 with precision-aimed parentheses ghc-8.4.1-alpha2
Ryan Scott [Thu, 18 Jan 2018 16:06:42 +0000 (11:06 -0500)] 
Fix #14681 and #14682 with precision-aimed parentheses

It turns out that `Convert` was recklessly leaving off
parentheses in two places:

* Negative numeric literals
* Patterns in lambda position

This patch fixes it by adding three new functions, `isCompoundHsLit`,
`isCompoundHsOverLit`, and `isCompoundPat`, and using them in the
right places in `Convert`. While I was in town, I also sprinkled
`isCompoundPat` among some `Pat`-constructing functions in `HsUtils`
to help avoid the likelihood of this problem happening in other
places. One of these places is in `TcGenDeriv`, and sprinkling
`isCompountPat` there fixes #14682

Test Plan: make test TEST="T14681 T14682"

Reviewers: alanz, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14681, #14682

Differential Revision:

(cherry picked from commit 575c009d9e4b25384ef984c09b2c54f909693e93)

17 months agoRemove executable filename check on windows [Mon, 15 Jan 2018 18:52:15 +0000 (13:52 -0500)] 
Remove executable filename check on windows

On Windows GHC enforces currently that the real executable is named

I don't see a good reason why this is neccessary.
This patch removes this restriction and fixes #14652

Test Plan: ci

Reviewers: bgamari, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie, carter

GHC Trac Issues: #14652

Differential Revision:

(cherry picked from commit 1bf70b2041dc2b7c89565fcb46cad8f151f96790)

17 months agoFix hash in haddock of ghc-prim.
HE, Tao [Mon, 15 Jan 2018 18:51:15 +0000 (13:51 -0500)] 
Fix hash in haddock of ghc-prim.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14653

Differential Revision:

(cherry picked from commit 2feed118413944cae8a4eed17365f40521f470db)

17 months agoInform hole substitutions of typeclass constraints (fixes #14273).
Matthías Páll Gissurarson [Thu, 18 Jan 2018 05:49:38 +0000 (00:49 -0500)] 
Inform hole substitutions of typeclass constraints (fixes  #14273).

This implements SPJ's suggestion on the ticket (#14273). We find the
relevant constraints (ones that whose free unification variables are all
mentioned in the type of the hole), and then clone the free unification
variables of the hole and the relevant constraints. We then add a
subsumption constraints and run the simplifier, and then check whether
all the constraints were solved.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie, carter

GHC Trac Issues: #14273

Differential Revision:

(cherry picked from commit 1e14fd3ecfd468c3beddb2e5f992c358e1a798de)

17 months agoImprove treatment of sectioned holes
Ryan Scott [Thu, 21 Dec 2017 00:25:53 +0000 (19:25 -0500)] 
Improve treatment of sectioned holes

Previously, GHC was pretty-printing left-section holes
incorrectly and not parsing right-sectioned holes at all. This patch
fixes both problems.

Test Plan: make test TEST=T14590

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, mpickering, carter

GHC Trac Issues: #14590

Differential Revision:

(cherry picked from commit 4d41e9212d1fdf109f2d0174d204644446f5874c)

17 months agoBlackholes can be large objects (#14497)
Simon Marlow [Mon, 18 Dec 2017 16:23:16 +0000 (11:23 -0500)] 
Blackholes can be large objects (#14497)

Test Plan: validate

Reviewers: bgamari, niteria, erikd, dfeuer

Reviewed By: dfeuer

Subscribers: Yuras, dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #14497

Differential Revision:

(cherry picked from commit fb1f0a46983a887057de647eaaae9e83b5ebebd1)

17 months agoconfigure: Various cleanups
John Ericson [Mon, 15 Jan 2018 18:53:08 +0000 (13:53 -0500)] 
configure: Various cleanups

Substitute RanlibCmd for consistency, and other configure cleanups that
should have no effect

The other commands are so substituted. Maybe we don't need ranlib at
all, and the configure snippet can be removed all together, but that
can always be done later.

Reviewers: bgamari, hvr, angerman

Reviewed By: bgamari, angerman

Subscribers: rwbarton, thomie, erikd, carter

Differential Revision:

(cherry picked from commit 8de8930520dce26ffa4fa1e67a977213de667e16)

17 months agoParenthesize forall-type args in cvtTypeKind
Ryan Scott [Mon, 15 Jan 2018 18:51:55 +0000 (13:51 -0500)] 
Parenthesize forall-type args in cvtTypeKind

Trac #14646 happened because we forgot to parenthesize `forall` types to
the left of an arrow. This simple patch fixes that.

Test Plan: make test TEST=T14646

Reviewers: alanz, goldfire, bgamari

Reviewed By: alanz

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14646

Differential Revision:

(cherry picked from commit f380115cd834ffbe51aca60f5476a51b94cdd413)

17 months agoFix join-point decision
Simon Peyton Jones [Tue, 9 Jan 2018 13:53:09 +0000 (13:53 +0000)] 
Fix join-point decision

This patch moves the "ok_unfolding" test
   from  CoreOpt.joinPointBinding_maybe
   to    OccurAnal.decideJoinPointHood

Previously the occurrence analyser was deciding to make
something a join point, but the simplifier was reversing
that decision, which made the decision about /other/ bindings

Fixes Trac #14650.

(cherry picked from commit 66ff794fedf6e81e727dc8f651e63afe6f2a874b)

18 months agoSimplify HsPatSynDetails
Simon Peyton Jones [Wed, 20 Dec 2017 15:36:49 +0000 (15:36 +0000)] 
Simplify HsPatSynDetails

This is a pure refactoring.  Use HsConDetails to implement
HsPatSynDetails, instead of defining a whole new data type.
Less code, fewer types, all good.

(cherry picked from commit 584cbd4a19887497776ce1f61c15df652b8b2ea4)

18 months agoFix previous patch
Simon Peyton Jones [Wed, 10 Jan 2018 16:46:55 +0000 (16:46 +0000)] 
Fix previous patch

This recent patch
    commit 1577908f2a9db0fcf6f749d40dd75481015f5497
    Author: Simon Peyton Jones <>
    Date:   Tue Jan 9 16:20:46 2018 +0000

        Fix two more bugs in partial signatures

        These were shown up by Trac #14643

failed validation for typecheck/should_run/T10846
(Reported in Trac #14658.)

The fix is simple.

(cherry picked from commit f3f90a079179e085295ee7edd2dda6505799370c)

18 months agoFix two more bugs in partial signatures
Simon Peyton Jones [Tue, 9 Jan 2018 16:20:46 +0000 (16:20 +0000)] 
Fix two more bugs in partial signatures

These were shown up by Trac #14643

Bug 1: if we had a single partial signature for
two functions
   f, g :: forall a. _ -> a
then we made two different SigTvs but with the sane Name.
This was jolly confusing and ultimately led to deeply bogus
results with Any's appearing in the resulting program. Yikes.
Fix: clone the quantified variables in TcSigs.tcInstSig (as
indeed its name suggests).

Bug 2: we were not eliminating duplicate/superclass constraints
in the partial signatures of a mutually recursive group.

Easy to fix: we are already doing dup/superclass elim in
TcSimplify.decideQuantification.  So we move the partial-sig
constraints there too.

(cherry picked from commit 1577908f2a9db0fcf6f749d40dd75481015f5497)

18 months agoAdd regression test for #14040
Ryan Scott [Tue, 12 Dec 2017 15:16:39 +0000 (10:16 -0500)] 
Add regression test for #14040

This adds a regression test for the original program in #14040.

This does not fix #14040 entirely, though, as the program in still
panics, so there is more work to be done there.

(cherry picked from commit be1ca0e439e9d26107c7d82fe6e78b64ee6320a9)

18 months agoDrop dead Given bindings in setImplicationStatus
Simon Peyton Jones [Thu, 4 Jan 2018 12:32:13 +0000 (12:32 +0000)] 
Drop dead Given bindings in setImplicationStatus

Trac #13032 pointed out that we sometimes generate unused
bindings for Givens, and (worse still) we can't always discard
them later (we don't drop a case binding unless we can prove
that the scrutinee is non-bottom.

It looks as if this may be a major reason for the performace
problems in #14338 (see comment:29).

This patch fixes the problem at source, by pruning away all the
dead Givens.  See Note [Delete dead Given evidence bindings]

Remarkably, compiler allocation falls by 23% in

I have not confirmed whether this change actualy helps with

(cherry picked from commit 954cbc7c106a20639960f55ebb85c5c972652d41)

18 months agoFix floating of equalities
Simon Peyton Jones [Thu, 21 Dec 2017 14:13:54 +0000 (14:13 +0000)] 
Fix floating of equalities

This rather subtle patch fixes Trac #14584.  The problem was
that we'd allowed a coercion, bound in a nested scope, to escape
into an outer scope.

The main changes are

* TcSimplify.floatEqualities takes more care when floating
  equalities to make sure we don't float one out that mentions
  a locally-bound coercion.
  See Note [What prevents a constraint from floating]

* TcSimplify.emitResidualConstraints (which emits the residual
  constraints in simplifyInfer) now avoids burying the constraints
  for escaping CoVars inside the implication constraint.

* Since I had do to this stuff with CoVars, I moved the
  fancy footwork about not quantifying over CoVars from
  TcMType.quantifyTyVars to its caller
  TcSimplify.decideQuantifiedTyVars.  I think its other
  callers don't need to worry about all this CoVar stuff.

This turned out to be surprisigly tricky, and took me a solid
day to get right.  I think the result is reasonably neat, though,
and well documented with Notes.

(cherry picked from commit f5cf9d1a1b198edc929e1fa96c6d841d182fe766)

18 months agoRefactor coercion holes
Simon Peyton Jones [Thu, 21 Dec 2017 13:31:13 +0000 (13:31 +0000)] 
Refactor coercion holes

In fixing Trac #14584 I found that it would be /much/ more
convenient if a "hole" in a coercion (much like a unification
variable in a type) acutally had a CoVar associated with it
rather than just a Unique.  Then I can ask what the free variables
of a coercion is, and get a set of CoVars including those
as-yet-un-filled in holes.

Once that is done, it makes no sense to stuff coercion holes
inside UnivCo.  They were there before so we could know the
kind and role of a "hole" coercion, but once there is a CoVar
we can get that info from the CoVar.  So I removed HoleProv
from UnivCoProvenance and added HoleCo to Coercion.

In summary:

* Add HoleCo to Coercion and remove HoleProv from UnivCoProvanance

* Similarly in IfaceCoercion

* Make CoercionHole have a CoVar in it, not a Unique

* Make tyCoVarsOfCo return the free coercion-hole variables
  as well as the ordinary free CoVars.  Similarly, remember
  to zonk the CoVar in a CoercionHole

We could go further, and remove CoercionHole as a distinct type
altogther, just collapsing it into HoleCo.  But I have not done
that yet.

(cherry picked from commit a492af06d3264530d134584f22ffb726a16c78ec)

18 months agoCheck for bogus quantified tyvars in partial type sigs
Simon Peyton Jones [Wed, 20 Dec 2017 15:41:02 +0000 (15:41 +0000)] 
Check for bogus quantified tyvars in partial type sigs

This fixes Trac #14479.  Not difficult.

See Note [Quantification and partial signatures] Wrinkle 4,
in TcSimplify.

(cherry picked from commit 72938f5890dac81afad52bf58175c1e29ffbc6dd)

18 months agoFix SigTvs at the kind level
Simon Peyton Jones [Mon, 11 Dec 2017 15:53:32 +0000 (15:53 +0000)] 
Fix SigTvs at the kind level

This patch fixes two bugs in the treatment of SigTvs at the
kind level:

- We should always generalise them, never default them
  (Trac #14555, #14563)

- We should check if they get unified with each other
  (Trac #11203)

Both are described in TcHsType
   Note [Kind generalisation and SigTvs]

(cherry picked from commit 8361b2c5a9f7a00f0024f44a43b851998ae41e33)

18 months agoRefactor kcHsTyVarBndrs
Simon Peyton Jones [Thu, 7 Dec 2017 14:31:53 +0000 (14:31 +0000)] 
Refactor kcHsTyVarBndrs

This refactoring

* Renames kcHsTyVarBndrs to kcLHsQTyVars,
  which is more truthful. It is only used in getInitialKind.

* Pulls out bind_telescope from that function, and calls it
  kcLHsTyVarBndrs, again to reflect its argument

* Uses the new kcLHsTyVarBndrs in kcConDecl, where the old
  function was wild overkill.

There should not be any change in behaviour

(cherry picked from commit de2044098ae96245aa741fe1b47a06a996a1c725)

18 months agoKQueue: Fix write notification requests being ignored...
Matthias Treydte [Mon, 8 Jan 2018 15:33:37 +0000 (10:33 -0500)] 
KQueue: Fix write notification requests being ignored...

when read notifications are requested, too (#13903)

Signed-off-by: Matthias Treydte <>
KQueue: Drop Bits/FiniteBits instances for Filter as they are really
constants whose bits should not be fiddled with

Signed-off-by: Matthias Treydte <>
Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: gridaphobe, kazu_yamamoto, rwbarton, thomie

GHC Trac Issues: #13903

Differential Revision:

(cherry picked from commit 6c3eafb35eb7c664963d08a5904faf8c6471218e)

18 months agoMake typeToLHsType produce kind signatures for tycon applications
Ryan Scott [Thu, 4 Jan 2018 01:11:31 +0000 (20:11 -0500)] 
Make typeToLHsType produce kind signatures for tycon applications

`GeneralizedNewtypeDeriving` generates calls to `coerce`
which take visible type arguments. These types must be produced by
way of `typeToLHsType`, which converts a `Type` to an `LHsType`.
However, `typeToLHsType` was leaving off important kind information
when a `Type` contained a poly-kinded tycon application, leading to
incorrectly generated code in #14579.

This fixes the issue by tweaking `typeToLHsType` to generate
explicit kind signatures for tycon applications. This makes the
generated code noisier, but at least the program from #14579 now
works correctly.

Test Plan: make test TEST=T14579

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14579

Differential Revision:

(cherry picked from commit 649e777211fe08432900093002547d7358f92d82)

18 months agoFix #14578 by checking isCompoundHsType in more places
Ryan Scott [Thu, 21 Dec 2017 00:25:18 +0000 (19:25 -0500)] 
Fix #14578 by checking isCompoundHsType in more places

The `HsType` pretty-printer does not automatically insert
parentheses where necessary for type applications, so a function
`isCompoundHsType` was created in D4056 towards this purpose.
However, it was not used in as many places as it ought to be,
resulting in #14578.

Test Plan: make test TEST=T14578

Reviewers: alanz, bgamari, simonpj

Reviewed By: alanz, simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #14578

Differential Revision:

(cherry picked from commit 1bd91a7ac60eba3b0c019e2228f4b2b07f8cd5ad)

18 months agoExport typeNat{Div;Mod;Log}TyCon from TcTypeNats
Christiaan Baaij [Mon, 8 Jan 2018 17:26:54 +0000 (12:26 -0500)] 
Export typeNat{Div;Mod;Log}TyCon from TcTypeNats

Summary: To be in line with the other typeNatTyCons

Reviewers: bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, rwbarton, thomie, carter

GHC Trac Issues: #14632

Differential Revision:

(cherry picked from commit fb78b0d22635b1d7ae68385c648b8c407f5562c2)

18 months agoMake the Div and Mod type families `infixl 7`
Ryan Scott [Sun, 7 Jan 2018 18:05:13 +0000 (13:05 -0500)] 
Make the Div and Mod type families `infixl 7`

Commit fa8035e3ee83aff5a20fc5e7e2697bac1686d6a6 added `Div`
and `Mod` type families to `GHC.TypeNats`. However, they did not add
the corresponding fixities! Currently, we have that both `div` and
`mod` (at the value level) are `infixl 7`, so we should adopt the
same fixities for the type-level `Div` and `Mod` as well.

Test Plan: It compiles

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14640

Differential Revision:

(cherry picked from commit 303106d55d75a9c796e58867cb541ad136bb217f)

18 months agoFix #14608 by restoring an unboxed tuple check
Ryan Scott [Tue, 2 Jan 2018 21:03:08 +0000 (16:03 -0500)] 
Fix #14608 by restoring an unboxed tuple check

Commit 714bebff44076061d0a719c4eda2cfd213b7ac3d removed
a check in the bytecode compiler that caught illegal uses of unboxed
tuples (and now sums) in case alternatives, which causes the program
in #14608 to panic. This restores the check (using modern,
levity-polymorphic vocabulary).

Test Plan: make test TEST=T14608

Reviewers: hvr, bgamari, dfeuer, simonpj

Reviewed By: dfeuer, simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #14608

Differential Revision:

(cherry picked from commit ecff651fc2f6d9833131e3e7fbc9a37b5b2f84ee)

18 months agoMake System.IO.openTempFile thread-safe on Windows
Tamar Christina [Tue, 2 Jan 2018 21:02:49 +0000 (16:02 -0500)] 
Make System.IO.openTempFile thread-safe on Windows

This calls out to the Win32 API `GetTempFileName` to generate
a temporary file. Using `uUnique = 0` guarantees that the file
we get back is unique and the file is "reserved" by creating it.

Test Plan:

I can't think of any sensible tests that shouldn't run for a while
to verify. So the example in #10731 was ran for a while and no
collisions in new code

Reviewers: hvr, bgamari, erikd

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie, carter

GHC Trac Issues: #10731

Differential Revision:

(cherry picked from commit 46287af0911f7cb446c62850630f85af567ac512)

18 months agoFix #14618 by applying a subst in deeplyInstantiate
Richard Eisenberg [Tue, 26 Dec 2017 19:23:40 +0000 (14:23 -0500)] 
Fix #14618 by applying a subst in deeplyInstantiate

Previously, we were inexplicably not applying an instantiating
substitution to arguments in non-prenex types. It's amazing this
has been around for so long! I guess there aren't a lot of non-prenex
types around.

test case: typecheck/should_fail/T14618

(cherry picked from commit 722a6584bb338bc77ad978d14113b3b8e6a45cab)

18 months agoBump Cabal submodule
Ben Gamari [Thu, 21 Dec 2017 20:04:05 +0000 (15:04 -0500)] 
Bump Cabal submodule

(cherry picked from commit e237e1f132d0c0e1d9bf24d21cf688110305fb28)

18 months agorelnotes: Remove note about -split-sections on Windows
Ben Gamari [Thu, 21 Dec 2017 20:02:28 +0000 (15:02 -0500)] 
relnotes: Remove note about -split-sections on Windows

Split-sections unfortunately isn't yet working.

18 months agorelnotes: Note GCC compatibility constraint
Ben Gamari [Wed, 20 Dec 2017 19:06:10 +0000 (14:06 -0500)] 
relnotes: Note GCC compatibility constraint

18 months agoMkIface: Ensure syntactic compatibility with ghc 8.0.1
Ben Gamari [Mon, 18 Dec 2017 22:16:22 +0000 (17:16 -0500)] 
MkIface: Ensure syntactic compatibility with ghc 8.0.1

Prior to 8.0.2 MultiWayIf syntax required that the -> token be indented relative
to the guard. See #10807.

18 months agoSync `ghc-prim` changelog from GHC 8.2, again
Herbert Valerio Riedel [Thu, 21 Dec 2017 23:04:19 +0000 (00:04 +0100)] 
Sync `ghc-prim` changelog from GHC 8.2, again

[skip ci]

(cherry picked from commit 4d99a665986f66f403ad49f7d91a1fc069870274)

18 months agoSync up ghc-prim changelog from GHC 8.2 branch
Herbert Valerio Riedel [Wed, 20 Dec 2017 07:10:59 +0000 (08:10 +0100)] 
Sync up ghc-prim changelog from GHC 8.2 branch

[skip ci]

(cherry picked from commit 005656776be8a447785627d549ee393dad468ff6)

19 months agousers-guide: Remove release notes for 8.2 ghc-8.4.1-alpha1
Ben Gamari [Thu, 14 Dec 2017 22:04:19 +0000 (17:04 -0500)] 
users-guide: Remove release notes for 8.2

19 months agousers-guide: Fix various bits of markup
Ben Gamari [Thu, 14 Dec 2017 21:52:59 +0000 (16:52 -0500)] 
users-guide: Fix various bits of markup

19 months agousers-guide: Consistently document LLVM version requirement
Ben Gamari [Thu, 14 Dec 2017 18:44:52 +0000 (13:44 -0500)] 
users-guide: Consistently document LLVM version requirement

19 months agoFix #14135 by validity checking matches
Carlos Tomé [Mon, 11 Dec 2017 20:38:03 +0000 (15:38 -0500)] 
Fix #14135 by validity checking matches

We filter the complete patterns given in a COMPLETE set to only those that
subsume the type we are matching. Otherwise we end up introducing an ill-typed
equation into the overlap checking, provoking a crash. This was the cause of
Trac #14135.

Reviewers: austin, bgamari, mpickering, gkaracha, simonpj, RyanGlScott,

Reviewed By: bgamari

Subscribers: carter, dfeuer, RyanGlScott, goldfire, rwbarton, thomie

GHC Trac Issues: #14135

Differential Revision:

(cherry picked from commit 16c7d9dc9ea7505256e0792c958cab8ae7c8a5c4)

19 months agoImprove Control.Monad.guard and Control.Monad.MonadPlus docs
Nathan Collins [Mon, 11 Dec 2017 17:52:55 +0000 (12:52 -0500)] 
Improve Control.Monad.guard and Control.Monad.MonadPlus docs

This fixes Issue #12372: documentation for Control.Monad.guard not
useful after AMP.

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit 6847c6bf5777eaf507f1cef28c1fc75a2c68bdef)

19 months agoOnly look for locales of the form LL.VV
Gabor Greif [Thu, 30 Nov 2017 19:49:03 +0000 (20:49 +0100)] 
Only look for locales of the form LL.VV

Because in recent RHEL7 suddenly locales like `bokmål` pop up, which
screw up reading-in of ASCII strings a line later. This additional
criterion reliably eliminates those unicode characters.

(cherry picked from commit abd5db6072218ada2b4a21177f5200ea0d3273a0)

19 months agoAllow users to ignore optimization changes
David Feuer [Mon, 11 Dec 2017 18:03:52 +0000 (13:03 -0500)] 
Allow users to ignore optimization changes

* Add a new flag, `-fignore-optim-changes`, allowing them to avoid
  recompilation if the only changes are to the `-O` level or to
  flags controlling optimizations.

* When `-fignore-optim-changes` is *off*, recompile when optimization
  flags (e.g., `-fno-full-laziness`) change. Previously, we ignored
  these unconditionally when deciding whether to recompile a module.

Reviewers: austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: duog, carter, simonmar, rwbarton, thomie

GHC Trac Issues: #13604

Differential Revision:

(cherry picked from commit 708ed9ca4dbf372817fe84a2fe486940123bddfb)

19 months agorts: Don't default to single capability when profiled
Ben Gamari [Mon, 11 Dec 2017 17:55:31 +0000 (12:55 -0500)] 
rts: Don't default to single capability when profiled

This was presumably a vestige of the days when the profiled RTS couldn't
run threaded. Fixes #14545.

Test Plan: simonmar

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14545

Differential Revision:

(cherry picked from commit 4bfff7a507b5807736e9c6ce9814a9cfa60faeff)

19 months agoAlways use the safe open() call
Simon Marlow [Mon, 11 Dec 2017 17:56:09 +0000 (12:56 -0500)] 
Always use the safe open() call

open() can sometimes take a long time, for example on NFS or FUSE
filesystems.  We recently had a case where open() was taking multiple
seconds to return for a (presumably overloaded) FUSE filesystem, which
blocked GC and caused severe issues.

Test Plan: validate

Reviewers: niteria, bgamari, nh2, hvr, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13296

Differential Revision:

(cherry picked from commit cafe98345cb5d4b11f2059d60d2f20e976ef4f2a)

19 months agoAdd hadrian as a submodule
Ben Gamari [Fri, 8 Dec 2017 18:02:06 +0000 (13:02 -0500)] 
Add hadrian as a submodule

It will remain a submodule until we are ready to merge Hadrian into the

19 months agoRip out hadrian subtree
Ben Gamari [Fri, 8 Dec 2017 17:42:35 +0000 (12:42 -0500)] 
Rip out hadrian subtree

Sadly subtrees haven't worked quite as well as we would have liked for
developers. See Hadrian #440.

19 months agoBump version to 8.4
Ben Gamari [Mon, 4 Dec 2017 22:01:15 +0000 (17:01 -0500)] 
Bump version to 8.4

Updates haddock dsubmodule

19 months agoFix ghc_packages
Ben Gamari [Mon, 4 Dec 2017 21:15:52 +0000 (16:15 -0500)] 
Fix ghc_packages

The LaTeX produced by this previously failed to compile. Changing the first cell
of the row from an inline to a paragraph fixes this. Then I noticed that the
table overflowed the page. This is fixed by applying the longtable class.

19 months agotemplate-haskell: Rip out FamFlavour
Ben Gamari [Mon, 4 Dec 2017 18:50:36 +0000 (13:50 -0500)] 
template-haskell: Rip out FamFlavour

This was scheduled to happen for 8.2, it looks like it will actually
happen in 8.4.

19 months agoMake the Con and Con' patterns produce evidence
David Feuer [Mon, 4 Dec 2017 13:27:18 +0000 (08:27 -0500)] 
Make the Con and Con' patterns produce evidence

Matching with the `Con` and `Con'` patterns can reveal evidence
that the type in question is *not* an application. This can help
the pattern checker.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: carter, rwbarton, thomie

Differential Revision:

19 months agoCache TypeRep kinds aggressively
David Feuer [Fri, 1 Dec 2017 22:00:24 +0000 (17:00 -0500)] 
Cache TypeRep kinds aggressively

Cache `TypeRep k` in each `TrApp` or `TrTyCon` constructor of
`TypeRep (a :: k)`. This makes `typeRepKind` cheap.

With this change, we won't need any special effort to deserialize
typereps efficiently. The downside, of course, is that we make
`TypeRep`s slightly larger.

Reviewers: austin, hvr, bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: carter, simonpj, rwbarton, thomie

GHC Trac Issues: #14254

Differential Revision:

19 months agoAdd trace injection
David Feuer [Fri, 1 Dec 2017 20:59:24 +0000 (15:59 -0500)] 
Add trace injection

Add support for injecting runtime calls to `trace` in `DsM`. This
allows the desugarer to add compile-time information to a runtime

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: carter, thomie, rwbarton

Differential Revision:

19 months agoHandle CPP properly in Backpack
Edward Z. Yang [Sat, 25 Nov 2017 02:12:05 +0000 (10:12 +0800)] 
Handle CPP properly in Backpack

Previously, we attempted to lookup 'hole' packages for
include directories; this obviously is not going to work.

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

Reviewers: ekmett, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14525

Differential Revision:

19 months agoMake use of boot TyThings during typechecking.
Edward Z. Yang [Mon, 30 Oct 2017 00:15:07 +0000 (20:15 -0400)] 
Make use of boot TyThings during typechecking.

Suppose that you are typechecking A.hs, which transitively imports,
via B.hs, A.hs-boot.  When we poke on B.hs and discover that it
has a reference to a type from A, what TyThing should we wire
it up with?  Clearly, if we have already typechecked A, we
should use the most up-to-date TyThing: the one we freshly
generated when we typechecked A.  But what if we haven't typechecked
it yet?

For the longest time, GHC adopted the policy that this was
*an error condition*; that you MUST NEVER poke on B.hs's reference
to a thing defined in A.hs until A.hs has gotten around to checking
this.  However, actually ensuring this is the case has proven
to be a bug farm.  The problem was especially poignant with
type family consistency checks, which eagerly happen before
any typechecking takes place.

This patch takes a different strategy: if we ever try to access
an entity from A which doesn't exist, we just fall back on the
definition of A from the hs-boot file.  This means that you may
end up with a mix of A.hs and A.hs-boot TyThings during the
course of typechecking.

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

Reviewers: simonpj, bgamari, austin, goldfire

Subscribers: thomie, rwbarton

GHC Trac Issues: #14396

Differential Revision:

19 months agoDarwin: Use gmp from homebrew
Ben Gamari [Wed, 29 Nov 2017 22:02:17 +0000 (17:02 -0500)] 
Darwin: Use gmp from homebrew

As discussed on ghc-devs, OS X appears to ship an old or otherwise broken gmp.

19 months agoDarwin: Set deployment target
Ben Gamari [Wed, 29 Nov 2017 22:01:07 +0000 (17:01 -0500)] 
Darwin: Set deployment target

19 months agoBump unix submodule
Ben Gamari [Wed, 29 Nov 2017 20:23:41 +0000 (15:23 -0500)] 
Bump unix submodule

Fixes FreeBSD build.

19 months agoComments only: Trac #14511
Simon Peyton Jones [Tue, 28 Nov 2017 16:02:18 +0000 (16:02 +0000)] 
Comments only: Trac #14511

19 months agoMinor tweaks to codegens.rst
Steven Shaw [Wed, 29 Nov 2017 07:16:14 +0000 (17:16 +1000)] 
Minor tweaks to codegens.rst

A couple of nits involving the letter 'C'.

19 months agoCircleCI: Freeze all packages at fixed index state
Ben Gamari [Wed, 29 Nov 2017 15:22:50 +0000 (10:22 -0500)] 
CircleCI: Freeze all packages at fixed index state

We will periodically bump this as necessary.

19 months agoCircleCI: Disallow hscolour 1.24.3
Ben Gamari [Wed, 29 Nov 2017 14:58:42 +0000 (09:58 -0500)] 
CircleCI: Disallow hscolour 1.24.3

This release does not build.

19 months agoCLabel: A bit of documentation
Ben Gamari [Tue, 28 Nov 2017 20:35:32 +0000 (15:35 -0500)] 
CLabel: A bit of documentation

19 months agoCmm: Add missing cases for BlockInfoTable
Ben Gamari [Tue, 28 Nov 2017 19:32:34 +0000 (14:32 -0500)] 
Cmm: Add missing cases for BlockInfoTable

Silly rabbit, BlockInfoTables are data. This fixes the unregisterised build,
finally fixing #14454.

19 months agoCLabel: More specific debug output from CLabel
Ben Gamari [Tue, 28 Nov 2017 19:23:02 +0000 (14:23 -0500)] 
CLabel: More specific debug output from CLabel

19 months agonativeGen: Use foldl' instead of foldl
Ben Gamari [Tue, 28 Nov 2017 01:02:55 +0000 (20:02 -0500)] 
nativeGen: Use foldl' instead of foldl

19 months agonativeGen: Use plusUFMList instead of foldr
Ben Gamari [Tue, 28 Nov 2017 01:02:25 +0000 (20:02 -0500)] 
nativeGen: Use plusUFMList instead of foldr

19 months agoCLabel: Refactor pprDynamicLinkerAsmLabel
Ben Gamari [Tue, 14 Nov 2017 19:58:40 +0000 (14:58 -0500)] 
CLabel: Refactor pprDynamicLinkerAsmLabel

19 months agocmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocks
Ben Gamari [Mon, 13 Nov 2017 17:34:54 +0000 (12:34 -0500)] 
cmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocks

blockLbl was originally changed in 8b007abbeb3045900a11529d907a835080129176 to
use mkTempAsmLabel to fix an inconsistency resulting in #14221. However, this
breaks the C code generator, which doesn't support AsmTempLabels (#14454).

Instead let's try going the other direction: use a new CLabel variety,
LocalBlockLabel. Then we can teach the C code generator to deal with
these as well.

19 months agoCLabel.labelType: Make catch-all case explicit
Ben Gamari [Tue, 14 Nov 2017 22:34:36 +0000 (17:34 -0500)] 
CLabel.labelType: Make catch-all case explicit

19 months agobase: Rip out old RTS statistics interface
Ben Gamari [Mon, 27 Nov 2017 19:02:56 +0000 (14:02 -0500)] 
base: Rip out old RTS statistics interface

Test Plan: Validate

Reviewers: simonmar, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #14516

Differential Revision:

19 months agorelnotes: Rework treatment of included package list
Ben Gamari [Mon, 27 Nov 2017 19:01:02 +0000 (14:01 -0500)] 
relnotes: Rework treatment of included package list

Previously the included package lists took a disproportionate amount of
space in the resulting document and were difficult to maintain. Turn it
into a table.

Subscribers: rwbarton, thomie

Differential Revision:

19 months agoDon't call alex for Cabal lib during GHC build
Tobias Dammers [Mon, 27 Nov 2017 19:00:50 +0000 (14:00 -0500)] 
Don't call alex for Cabal lib during GHC build

The Cabal library now commits `Lexer.hs` directly to the source tree,
so the build step where we'd call alex ourselves to generate that file
is no longer necessary, nor will it work.

See also:

Reviewers: bgamari, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14459

Differential Revision:

19 months agotypecheck: Consistently use pretty quotes in error messages
Ben Gamari [Mon, 27 Nov 2017 19:00:06 +0000 (14:00 -0500)] 
typecheck: Consistently use pretty quotes in error messages

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agoCheck quantification for partial type signatues
Simon Peyton Jones [Tue, 14 Nov 2017 15:26:19 +0000 (15:26 +0000)] 
Check quantification for partial type signatues

Trac #14449 showed that we were failing to check that the
quantified type variables of a partial type signature remained

See Note [Quantified variables in partial type signatures]
in TcBinds.

A little refactoring along the way.

19 months agoboot: Eliminate superfluous output
Ben Gamari [Mon, 27 Nov 2017 15:20:59 +0000 (10:20 -0500)] 
boot: Eliminate superfluous output

19 months agoRtsFlags: allow +RTS -K0
Ben Gamari [Mon, 27 Nov 2017 14:46:55 +0000 (09:46 -0500)] 
RtsFlags: allow +RTS -K0

Reviewers: erikd, simonmar, hvr

Reviewed By: hvr

Subscribers: hvr, rwbarton, thomie

Differential Revision:

19 months agoAdd obvious Outputable Integer instance. [Mon, 27 Nov 2017 14:46:32 +0000 (09:46 -0500)] 
Add obvious Outputable Integer instance.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

19 months agoFollow symlinks in the Win32 code for System.Environment.getExecutablePath
Alp Mestanogullari [Mon, 27 Nov 2017 14:45:52 +0000 (09:45 -0500)] 
Follow symlinks in the Win32 code for System.Environment.getExecutablePath

This partially addresses #14483 by fixing the Windows implementation of
System.Environment.getExecutablePath. This is achieved by using
GetFinalPathNameByHandleW to resolve potential symlinks, while making
sure we do not get back a UNC path (see #14460).

Test Plan: Validate

Reviewers: Phyx, bgamari, angerman, hvr, goldfire

Reviewed By: Phyx, bgamari

GHC Trac Issues: #14483

Differential Revision:

19 months agoDon't complain about UNPACK in -fno-code.
Edward Z. Yang [Mon, 27 Nov 2017 14:45:23 +0000 (09:45 -0500)] 
Don't complain about UNPACK in -fno-code.

Test Plan: validate

Reviewers: ekmett, austin, bgamari

Reviewed By: bgamari

Subscribers: duog, goldfire, rwbarton, thomie

Differential Revision:

19 months agoCircleCI: Reenable artifact collection on Darwin
Ben Gamari [Thu, 23 Nov 2017 20:03:18 +0000 (15:03 -0500)] 
CircleCI: Reenable artifact collection on Darwin

Supposedly the original issue has been fixed.

19 months agobase: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262.
Niklas Hambüchen [Thu, 23 Nov 2017 18:17:24 +0000 (13:17 -0500)] 
base: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262.

On 64-bit UNIX and Windows, Haskell `Int` has 64 bits
but C `int msecs` has 32 bits, resulting in an overflow.

This commit fixes it by switching fdReady() to take int64_t,
into which a Haskell `Int` will always fit.

(Note we could not switch to `long long` because that is
32 bit on 64-bit Windows machines.)

Further, to be able to actually wait longer than ~49 days,
we put loops around the waiting syscalls (they all accept only
32-bit integers).

Note the timer signal would typically interrupt the syscalls
before the ~49 days are over, but you can run Haskell programs
without the timer signal, an we want it to be correct in all

Reviewers: bgamari, austin, hvr, NicolasT, Phyx

Reviewed By: bgamari, Phyx

Subscribers: syd, Phyx, rwbarton, thomie

GHC Trac Issues: #14262

Differential Revision:

19 months agousers-guide: Fix :default: placement
Ben Gamari [Thu, 23 Nov 2017 18:14:33 +0000 (13:14 -0500)] 
users-guide: Fix :default: placement

19 months agoDynFlags: Expand $topdir in --info output
Ben Gamari [Thu, 23 Nov 2017 18:05:30 +0000 (13:05 -0500)] 
DynFlags: Expand $topdir in --info output

Test Plan: Try running nofib on Windows

Reviewers: Phyx

Subscribers: rwbarton, thomie

Differential Revision:

19 months agoSysTools: Split up TopDir logic into new module
Ben Gamari [Thu, 23 Nov 2017 18:05:05 +0000 (13:05 -0500)] 
SysTools: Split up TopDir logic into new module

Test Plan: Validate on Linux and Windows

Reviewers: erikd

Subscribers: rwbarton, thomie

Differential Revision:

19 months agoSysTools: Expand occurrences of $topdir anywhere in a Settings path
Ben Gamari [Thu, 23 Nov 2017 18:04:55 +0000 (13:04 -0500)] 
SysTools: Expand occurrences of $topdir anywhere in a Settings path

Subscribers: rwbarton, thomie, Phyx

Differential Revision:

19 months agorts/Printer: add closure name entries for small arrays (Fixes #14513)
Takano Akio [Thu, 23 Nov 2017 17:17:24 +0000 (12:17 -0500)] 
rts/Printer: add closure name entries for small arrays (Fixes #14513)

Test Plan: ./validate

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14513

Differential Revision:

19 months agoCircleCI: Install lbzip2 and patch
Ben Gamari [Wed, 22 Nov 2017 17:07:29 +0000 (12:07 -0500)] 
CircleCI: Install lbzip2 and patch

tar needs lbzip2 to extract the GMP tarball. Patch is needed to, well, patch.

19 months agocircleci: Build with Hadrian
Ben Gamari [Sat, 18 Nov 2017 19:50:24 +0000 (14:50 -0500)] 
circleci: Build with Hadrian

19 months agoCircleCI: Try validating LLVM as well
Ben Gamari [Sun, 12 Nov 2017 00:04:42 +0000 (19:04 -0500)] 
CircleCI: Try validating LLVM as well

19 months agoCircleCI: Perform nightly validation of unregisterised build
Ben Gamari [Sat, 11 Nov 2017 23:53:56 +0000 (18:53 -0500)] 
CircleCI: Perform nightly validation of unregisterised build

19 months agoFix README
Ben Gamari [Thu, 23 Nov 2017 14:53:30 +0000 (09:53 -0500)] 

This was unfortunately overwritten by the Hadrian README in a previous
Hadrian merge.

19 months agoRevert "Add new mbmi and mbmi2 compiler flags"
Ben Gamari [Wed, 22 Nov 2017 19:27:55 +0000 (14:27 -0500)] 
Revert "Add new mbmi and mbmi2 compiler flags"

This broke the 32-bit build.

This reverts commit f5dc8ccc29429d0a1d011f62b6b430f6ae50290c.

19 months agoUpdate Hadrian
Ben Gamari [Wed, 22 Nov 2017 13:50:45 +0000 (08:50 -0500)] 
Update Hadrian

19 months agoSquashed 'hadrian/' changes from fa3771fe6b..4499b294e4
Ben Gamari [Wed, 22 Nov 2017 13:47:55 +0000 (08:47 -0500)] 
Squashed 'hadrian/' changes from fa3771fe6b..4499b294e4

4499b294e4 Follow GHC changes
8fd68186b2 Add ways to build hadrian using nix
e5c7a29c23 Do not depend on the in-tree filepath library
9dd7ad2acc Fix dependencies
497184390e Bring mtl dependency back
6c5f5c9bd9 Minor clean up of Hadrian dependencies
9aff81d424 Fix Windows build
fa95caa8df Unbreak `cabal new-build`

git-subtree-dir: hadrian
git-subtree-split: 4499b294e4a53f71f8808d6eb55a7dd0b341cfb8

19 months agoErrUtils: Ensure timing dumps are always output on one line
Ben Gamari [Wed, 22 Nov 2017 03:59:28 +0000 (22:59 -0500)] 
ErrUtils: Ensure timing dumps are always output on one line

This output is supposed to be machine-readable; having random line-breaks
defeats this.

19 months agoErrUtils: Refactor dump file logic
Ben Gamari [Wed, 22 Nov 2017 03:57:27 +0000 (22:57 -0500)] 
ErrUtils: Refactor dump file logic

This refactors the dump file setup path, separating concerns a bit. It also
fixes an exception-unsafe usage of openFile.

19 months agoBump stm submodule
Ben Gamari [Wed, 22 Nov 2017 04:00:13 +0000 (23:00 -0500)] 
Bump stm submodule

19 months agobase: Remove redundant subtraction in (^) and stimes
Ben Gamari [Wed, 22 Nov 2017 02:15:29 +0000 (21:15 -0500)] 
base: Remove redundant subtraction in (^) and stimes

Subtraction `y - 1` is redundant. The value of y is guaranteed to be
positive and odd, so
(y - 1) `quot` 2` = `y `quot` 2

Test Plan: validate

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14439

Differential Revision:

19 months agocmm: Optimise remainders by powers of two
Ben Gamari [Wed, 22 Nov 2017 02:14:31 +0000 (21:14 -0500)] 
cmm: Optimise remainders by powers of two

Test Plan: validate

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14437

Differential Revision:

19 months agotestsuite: Add test for #14257
Ben Gamari [Tue, 21 Nov 2017 23:30:17 +0000 (18:30 -0500)] 
testsuite: Add test for #14257

Subscribers: rwbarton, thomie, duog

GHC Trac Issues: #14257

Differential Revision:

19 months agoTest Trac #14488
Vladislav Zavialov [Tue, 21 Nov 2017 23:28:21 +0000 (18:28 -0500)] 
Test Trac #14488

The refactoring in 3f5673f34a2f761423027bf46f64f7499708725f also fixed a
previously unreported issue in the typechecker that prevented defining a
lens to a record field with a constraint. This patch adds a regression

Test Plan: make test TEST=14488

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: int-e, rwbarton, thomie

GHC Trac Issues: #14488

Differential Revision:

19 months agoRemove hadrian sub-dir from .gitignore
Matthew Pickering [Tue, 21 Nov 2017 23:26:16 +0000 (18:26 -0500)] 
Remove hadrian sub-dir from .gitignore

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: