18 months agoWIP: DON'T PUSH, misc local changes wip/T13861
Gabor Greif [Wed, 3 Jan 2018 14:57:17 +0000 (15:57 +0100)] 
WIP: DON'T PUSH, misc local changes

18 months agoGet evaluated-ness right in the back end
Simon Peyton Jones [Wed, 3 Jan 2018 10:48:26 +0000 (10:48 +0000)] 
Get evaluated-ness right in the back end

See Trac #14626, comment:4.  We want to maintain evaluted-ness
info on Ids into the code generateor for two reasons
(see Note [Preserve evaluated-ness in CorePrep] in CorePrep)

- DataToTag magic
- Potentially using it in the codegen (this is Gabor's
  current work)

But it was all being done very inconsistently, and actually
outright wrong -- the DataToTag magic hasn't been working for

This patch tidies it all up, with Notes to match.


18 months agoRevert "WIP: clean up some cruft"
Gabor Greif [Wed, 3 Jan 2018 10:26:26 +0000 (11:26 +0100)] 
Revert "WIP: clean up some cruft"

This reverts commit a0fdeba207e457924a2b7204dd4f7db14d5e4364.

18 months agoWIP: an experiment
Gabor Greif [Wed, 3 Jan 2018 08:15:43 +0000 (09:15 +0100)] 
WIP: an experiment

18 months agoWIP: add an assert
Gabor Greif [Wed, 3 Jan 2018 06:21:36 +0000 (07:21 +0100)] 
WIP: add an assert

that we don't enter an Id that already *is* evald

18 months agoWIP: check isEvaldUnfolding
Gabor Greif [Tue, 2 Jan 2018 18:50:47 +0000 (19:50 +0100)] 
WIP: check isEvaldUnfolding

unfortunately it does not cover the "wild_*" variables :-(

18 months agoWIP: fix travis
Gabor Greif [Tue, 2 Jan 2018 04:21:32 +0000 (05:21 +0100)] 
WIP: fix travis

18 months agoWIP: cleanups
Gabor Greif [Mon, 1 Jan 2018 21:20:37 +0000 (22:20 +0100)] 
WIP: cleanups

18 months agoWIP: optimise literals
Gabor Greif [Mon, 1 Jan 2018 18:08:26 +0000 (19:08 +0100)] 
WIP: optimise literals

18 months agoWIP: fix thinko
Gabor Greif [Mon, 1 Jan 2018 12:08:45 +0000 (13:08 +0100)] 
WIP: fix thinko

18 months agoWIP: clean up some cruft
Gabor Greif [Sat, 30 Dec 2017 22:06:36 +0000 (23:06 +0100)] 
WIP: clean up some cruft

18 months agoWIP: appease travis
Gabor Greif [Sat, 30 Dec 2017 13:29:32 +0000 (14:29 +0100)] 
WIP: appease travis

18 months agoWIP: another test
Gabor Greif [Sat, 30 Dec 2017 13:14:36 +0000 (14:14 +0100)] 
WIP: another test

18 months agoWIP: cleanups
Gabor Greif [Sat, 30 Dec 2017 00:30:13 +0000 (01:30 +0100)] 
WIP: cleanups

of warnings, thinkos

18 months agoWIP: implement lumping of same results for may constructors
Gabor Greif [Sat, 30 Dec 2017 00:02:09 +0000 (01:02 +0100)] 
WIP: implement lumping of same results for may constructors

18 months agoWIP: add some noise
Gabor Greif [Fri, 29 Dec 2017 12:27:04 +0000 (13:27 +0100)] 
WIP: add some noise

18 months agoAnother identity test
Gabor Greif [Fri, 29 Dec 2017 12:25:42 +0000 (13:25 +0100)] 
Another identity test

18 months agoWIP: less noise, and add TODO
Gabor Greif [Fri, 29 Dec 2017 12:23:50 +0000 (13:23 +0100)] 
WIP: less noise, and add TODO

18 months agoWIP: lump with DEFAULT
Gabor Greif [Fri, 29 Dec 2017 11:47:59 +0000 (12:47 +0100)] 
WIP: lump with DEFAULT

18 months agoWIP: implement DEFAULT lumping
Gabor Greif [Fri, 29 Dec 2017 11:25:52 +0000 (12:25 +0100)] 
WIP: implement DEFAULT lumping

and fix note, as we have no guards in STG

18 months agocheck other lump identity
Gabor Greif [Fri, 29 Dec 2017 11:24:41 +0000 (12:24 +0100)] 
check other lump identity

18 months agoWIP: add note
Gabor Greif [Fri, 29 Dec 2017 11:16:19 +0000 (12:16 +0100)] 
WIP: add note

18 months agoWIP: create DEFAULT when more than two alts give binder
Gabor Greif [Fri, 29 Dec 2017 10:46:20 +0000 (11:46 +0100)] 
WIP: create DEFAULT when more than two alts give binder

18 months agoWIP: detect lumping opportunities
Gabor Greif [Fri, 29 Dec 2017 10:26:31 +0000 (11:26 +0100)] 
WIP: detect lumping opportunities

18 months agotest whether two STG equiv alts get joined
Gabor Greif [Fri, 29 Dec 2017 08:37:03 +0000 (09:37 +0100)] 
test whether two STG equiv alts get joined

18 months agomake 'quux'' test 3 to 2
Gabor Greif [Fri, 29 Dec 2017 07:30:59 +0000 (08:30 +0100)] 
make 'quux'' test 3 to 2

18 months agocheck that 'quux' is the identity
Gabor Greif [Fri, 29 Dec 2017 06:52:57 +0000 (07:52 +0100)] 
check that 'quux' is the identity

18 months agoTypos in comments [ci skip]
Gabor Greif [Wed, 27 Dec 2017 22:31:21 +0000 (23:31 +0100)] 
Typos in comments [ci skip]

18 months agoWIP: add another test [ci skip]
Gabor Greif [Wed, 27 Dec 2017 20:15:17 +0000 (21:15 +0100)] 
WIP: add another test [ci skip]

18 months agothis is not needed any more
Gabor Greif [Wed, 27 Dec 2017 19:56:51 +0000 (20:56 +0100)] 
this is not needed any more

should fix Travis

18 months agoWIP: don't reenter WHNF thing for re-tagging
Gabor Greif [Wed, 27 Dec 2017 18:47:50 +0000 (19:47 +0100)] 
WIP: don't reenter WHNF thing for re-tagging

this is a very crude test. How to make it more robust?

18 months agodon't inline 'same', this way one of the mysteries is resolved
Gabor Greif [Fri, 22 Dec 2017 21:16:11 +0000 (22:16 +0100)] 
don't inline 'same', this way one of the mysteries is resolved

18 months agoWIP: status quo
Gabor Greif [Fri, 22 Dec 2017 13:26:35 +0000 (14:26 +0100)] 
WIP: status quo

two responses not totally understood yet

18 months agotrace less
Gabor Greif [Fri, 22 Dec 2017 11:26:38 +0000 (12:26 +0100)] 
trace less

18 months agotake out the doorstops
Gabor Greif [Fri, 22 Dec 2017 11:23:07 +0000 (12:23 +0100)] 
take out the doorstops

consider everything for CSE

18 months agotravis compilation
Gabor Greif [Fri, 22 Dec 2017 00:50:44 +0000 (01:50 +0100)] 
travis compilation

18 months agoMerge branch 'wip/cross-constr-cse' into wip/T13861
Gabor Greif [Thu, 21 Dec 2017 23:58:52 +0000 (00:58 +0100)] 
Merge branch 'wip/cross-constr-cse' into wip/T13861


18 months agoAdd note about mechanics of double switching wip/T14373
Gabor Greif [Thu, 21 Dec 2017 17:19:33 +0000 (18:19 +0100)] 
Add note about mechanics of double switching

for big families

19 months agotest that no nested switches generated
Gabor Greif [Wed, 20 Dec 2017 12:21:07 +0000 (13:21 +0100)] 
test that no nested switches generated

19 months agocleanup
Gabor Greif [Mon, 18 Dec 2017 17:34:00 +0000 (18:34 +0100)] 

19 months agoHandle the case when ptr tag is telling no story
Gabor Greif [Sat, 16 Dec 2017 13:47:59 +0000 (14:47 +0100)] 
Handle the case when ptr tag is telling no story

e.g. when we only `\case Fifteenth -> ...`, and
add a corresponding test.

19 months agoExtra argument for emitting pre-join label code
Gabor Greif [Fri, 15 Dec 2017 10:54:49 +0000 (11:54 +0100)] 
Extra argument for emitting pre-join label code

in 'emitSwitch'. The former functionality can be
recovered by passing `(pure ())`.

Now we can eliminate the forming a the weird branch island
around the switch on info-pointer tag (`cgAlts` in StgCmmExpr.hs).

19 months agonote tweaks
Gabor Greif [Fri, 15 Dec 2017 10:36:28 +0000 (11:36 +0100)] 
note tweaks

19 months agofirst round of review feedback
Gabor Greif [Thu, 14 Dec 2017 22:00:13 +0000 (23:00 +0100)] 
first round of review feedback

19 months agojoin *after* the second switch
Gabor Greif [Wed, 13 Dec 2017 14:50:17 +0000 (15:50 +0100)] 
join *after* the second switch

19 months agoImplement pointer tagging for 'big' families #14373
Gabor Greif [Fri, 20 Oct 2017 13:45:37 +0000 (15:45 +0200)] 
Implement pointer tagging for 'big' families #14373

Formerly we punted on these and evaluated constructors always
got a tag of 1.

We now cascade switches because we have to check the tag first
and when it is MAX_PTR_TAG then get the precise tag from the info
table and switch on that. The only technically tricky part is that the
default case needs (logical) duplication. To do this we emit an extra
label for it and branch to that from the second switch. This avoids
duplicated codegen.

19 months agoTypofix in comment
Gabor Greif [Wed, 13 Dec 2017 21:59:03 +0000 (22:59 +0100)] 
Typofix in comment

19 months agoFurther improvements to well-kinded types
Simon Peyton Jones [Wed, 13 Dec 2017 12:53:26 +0000 (12:53 +0000)] 
Further improvements to well-kinded types

The typechecker has the invariant that every type should be well-kinded
as it stands, without zonking.  See Note [The well-kinded type invariant]
in TcType.

That invariant was not being upheld, which led to Trac #14174.  I fixed
part of it, but T14174a showed that there was more.  This patch finishes
the job.

* See Note [The tcType invariant] in TcHsType, which articulates an
  invariant that was very nearly, but not quite, true.  One place that
  falisified it was the HsWildCardTy case of tc_hs_type, so I fixed that.

* mkNakedCastTy now makes no attempt to eliminate casts; indeed it cannot
  lest it break Note [The well-kinded type invariant].  The prior comment
  suggested that it was crucial for performance but happily it seems not
  to be. The extra Refls are eliminated by the zonker.

* I found I could tidy up TcHsType.instantiateTyN and instantiateTyUntilN
  by eliminating one of its parameters.  That led to a cascade of minor
  improvements in TcTyClsDecls. Hooray.

19 months agoRe-centre perf for T5321Fun
Simon Peyton Jones [Wed, 13 Dec 2017 16:00:14 +0000 (16:00 +0000)] 
Re-centre perf for T5321Fun

Bytes allocated has fallen by around 5%. I think this due
to some of my recent refactoring of the typechecker, but
I'm not certain about exactly which change did it.

Good though!

19 months agoAdd missing stderr for Trac #14561
Simon Peyton Jones [Wed, 13 Dec 2017 15:56:41 +0000 (15:56 +0000)] 
Add missing stderr for Trac #14561

19 months agoTidy up of wired-in names
Simon Peyton Jones [Wed, 13 Dec 2017 10:49:31 +0000 (10:49 +0000)] 
Tidy up of wired-in names

Two things here:

* While debugging Trac #14561 I found it hard to understand
  ghcPrimIds and magicIds in MkId.  This patch adds more
  structure and comments.

* I also discovered that ($) no longer needs to be a wiredInId
  because we now have levity polymorphism.  So I took dollarId
  out of MkId; and gave it a levity-polymorphic type in GHC.Base

19 months agoDetect levity-polymorphic uses of unsafeCoerce#
Simon Peyton Jones [Wed, 13 Dec 2017 10:46:26 +0000 (10:46 +0000)] 
Detect levity-polymorphic uses of unsafeCoerce#

This bug was shown up by Trac #14561. The deguarer carefully
detects unsaturated and levity-polymorphic uses of primops,
but not of things like unsafeCoerce#.

The fix is simple: see Note [Levity-polymorphic Ids] in Id.

19 months agoMinor refactor of TcExpr.tcApp
Simon Peyton Jones [Wed, 13 Dec 2017 10:37:57 +0000 (10:37 +0000)] 
Minor refactor of TcExpr.tcApp

This refactoring has no change in behaviour but makes the
structure clearer

19 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.

19 months agobase: fdReady(): Return only after sycall returns after `msecs` have passed
Niklas Hambüchen [Mon, 11 Dec 2017 18:07:38 +0000 (13:07 -0500)] 
base: fdReady(): Return only after sycall returns after `msecs` have passed

Reviewers: bgamari, austin, hvr, dfeuer

Reviewed By: dfeuer

Subscribers: syd, dfeuer, rwbarton, thomie

Differential Revision:

19 months agofdReady: Use C99 bools / CBool in signature
Niklas Hambüchen [Mon, 11 Dec 2017 18:06:33 +0000 (13:06 -0500)] 
fdReady: Use C99 bools / CBool in signature

Reviewers: bgamari, Phyx, austin, hvr, simonmar

Reviewed By: bgamari

Subscribers: syd, rwbarton, thomie

Differential Revision:

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:

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:

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:

19 months agoAdd NOINLINE pragma to hPutStr'
Matthew Pickering [Mon, 11 Dec 2017 17:54:18 +0000 (12:54 -0500)] 
Add NOINLINE pragma to hPutStr'

There appears to be no benefit in inlining this function.
If you turn up the unfolding threshold a lot then it eventually
inlines which produces a bit unoptimisable program.

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agoAdd information about irrefutable pattern Syntax to XStrict. [Mon, 11 Dec 2017 17:53:54 +0000 (12:53 -0500)] 
Add information about irrefutable pattern Syntax to XStrict.

This information was present in the ghc wiki but not the user guide.
[skip ci]

Test Plan: None

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie, carter

Differential Revision:

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:

19 months agoFixed misprint 'aqcuired'
Kirill Zaborsky [Mon, 11 Dec 2017 15:04:55 +0000 (18:04 +0300)] 
Fixed misprint 'aqcuired'

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.

19 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]

19 months agoBuild only well-kinded types in type checker
Simon Peyton Jones [Mon, 11 Dec 2017 11:52:44 +0000 (11:52 +0000)] 
Build only well-kinded types in type checker

During type inference, we maintain the invariant that every type is
well-kinded /without/ zonking; and in particular that typeKind does
not fail (as it can for ill-kinded types).

But TcHsType.tcInferApps was not guaranteeing this invariant,
resulting in Trac #14174 and #14520.

This patch fixes it, making things better -- but it does /not/
fix the program in Trac #14174 comment:5, which still crashes.
So more work to be done.

See Note [Ensure well-kinded types] in TcHsType

19 months agoImproved panic message for zonkTcTyVarToTyVar
Simon Peyton Jones [Fri, 8 Dec 2017 17:32:16 +0000 (17:32 +0000)] 
Improved panic message for zonkTcTyVarToTyVar

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 agoOccurrrence analysis improvements for NOINLINE functions
Simon Peyton Jones [Fri, 8 Dec 2017 15:39:05 +0000 (15:39 +0000)] 
Occurrrence analysis improvements for NOINLINE functions

This patch fixes #14567.  The idea is simple: if a function
is marked NOINLINE then it makes a great candidate for a loop

Implementation is easy too, but it needs a little extra plubming,
notably the occ_unf_act field in OccEnv

19 months agoImprove LiberateCase
Simon Peyton Jones [Fri, 8 Dec 2017 15:31:36 +0000 (15:31 +0000)] 
Improve LiberateCase

This patch, which fixes Trac #14566, makes LiberateCase a little
more conservative.  In particular:

* In libCaseBind, treat a recursive group as a whole, rather than
  binding-by-binding, allowing the group to be duplicated only if
    - the bindings /considered together/ are smaller than the
      liberate-case threshold (which is large by default)
    - none of them are thunks
    - none of them are guaranteed-diverging

  The latter condidtion is new, and happens to apply in the
  case of Data/Typeable/Internal.mkTrApp

19 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

19 months agoRevert accidental hsc2hs submodule downgrade
Herbert Valerio Riedel [Thu, 7 Dec 2017 19:05:56 +0000 (20:05 +0100)] 
Revert accidental hsc2hs submodule downgrade

This submodule update was committed unintentionally in

19 months agoRefactor ConDecl: Trac #14529
Simon Peyton Jones [Tue, 28 Nov 2017 11:33:37 +0000 (11:33 +0000)] 
Refactor ConDecl: Trac #14529

This patch refactors HsDecls.ConDecl.  Specifically

* ConDeclGADT was horrible, with all the information hidden
  inside con_res_ty.  Now it's kept separate, as it should be.

* ConDeclH98: use [LHsTyVarBndr] instead of LHsQTyVars for the
  existentials. There is no implicit binding here.

* Add a field con_forall to both ConDeclGADT and ConDeclH98
  which says if there is an explicit user-written forall.

* Field renamings in ConDecl
     con_cxt     to con_mb_cxt
     con_details to con_args

There is an accompanying submodule update to Haddock.

Also the following change turned out to remove a lot of clutter:

* add a smart constructor for HsAppsTy, namely mkHsAppsTy,
  and use it consistently. This avoids a lot of painful pattern
  matching for the common singleton case.

Two api-annotation tests (T10278, and T10399) are broken, hence marking
them as expect_broken(14529).  Alan is going to fix them, probably by
changing the con_forall field to
   con_forall :: Maybe SrcSpan
instead of Bool

19 months agoForward-port changes from GHC 8.2 branch
Herbert Valerio Riedel [Thu, 7 Dec 2017 08:58:00 +0000 (09:58 +0100)] 
Forward-port changes from GHC 8.2 branch

(cherry picked from commit 3fa061a647d2fdc182eff9296eea02d6a7d516cd)

19 months agoutils/hsc2hs: update submodule
Sergei Trofimovich [Tue, 5 Dec 2017 07:51:16 +0000 (07:51 +0000)] 
utils/hsc2hs: update submodule

This pulls single change to fix building of cross-compilers:
* Use the same conditional install logic from unlit

Signed-off-by: Sergei Trofimovich <>
Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agorts: fix filename case for mingw32 target
Sergei Trofimovich [Tue, 5 Dec 2017 07:49:24 +0000 (07:49 +0000)] 
rts: fix filename case for mingw32 target

The failure is visible when we build a cross-compiler
from linux to mingw32 as:

    $ ./configure --host=x86_64-pc-linux-gnu \
    $ make
    rts/linker/PEi386.c:159:10: error:
         fatal error: Psapi.h: No such file or directory
         #include <Psapi.h>
    159 | #include <Psapi.h>
        |          ^

The problem here is case-sensitive linux filesystem. On windows
it does not matter what case is used for includes and libraries.

mingw32 provides all libraries and headers lowercase. This change
fixes case for <dbghelp.h>, <psapi.h>, -ldbghelp, -lpsapi.

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

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

19 months agoBump version to 8.5 ghc-8.5-start
Ben Gamari [Wed, 29 Nov 2017 14:54:14 +0000 (09:54 -0500)] 
Bump version to 8.5

The ghc-8.4 branch has now been cut. Updates the haddock submodule.

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