3 years agoRemove some varSetElems in dsCmdStmt
Bartosz Nitka [Wed, 11 May 2016 14:47:15 +0000 (07:47 -0700)] 
Remove some varSetElems in dsCmdStmt

varSetElems introduces unnecessary determinism and it's easy to
preserve determinism here.

Test Plan: ./validate

Reviewers: goldfire, simonmar, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agoHandle promotion failures when scavenging a WEAK (#11108)
Takano Akio [Wed, 11 May 2016 12:45:29 +0000 (14:45 +0200)] 
Handle promotion failures when scavenging a WEAK (#11108)

Previously, we ignored promotion failures when evacuating fields of
a WEAK object. When a failure happens, this resulted in an WEAK object
pointing to another object in a younger generation, causing crashes.

I used the test case from #11746 to check that the fix is working.
However I haven't managed to produce a test case that quickly reproduces
the issue.

Test Plan: ./validate

Reviewers: austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11108

3 years agorts: Fix C compiler warnings on Windows
Erik de Castro Lopo [Wed, 11 May 2016 06:17:08 +0000 (16:17 +1000)] 
rts: Fix C compiler warnings on Windows

Specifcally we want the MinGW compiler to use ISO print format

Test Plan: Validate on Linux, OS X and Windows

Reviewers: Phyx, austin, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: thomie

Differential Revision:

3 years agoRtsFlags: Make `mallocFailHook` const correct
Erik de Castro Lopo [Mon, 2 May 2016 11:20:28 +0000 (21:20 +1000)] 
RtsFlags: Make `mallocFailHook` const correct

Test Plan: Validate

Reviewers: hvr, austin, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: thomie

Differential Revision:

3 years agoDocument why closeOverKind is OK for determinism
Bartosz Nitka [Wed, 11 May 2016 10:39:25 +0000 (03:39 -0700)] 
Document why closeOverKind is OK for determinism

There's no point in converting the existing call sites to use
deterministic closeOverKinds if they never linearize the set.

Test Plan: it compiles, this is basically just documentation

Reviewers: simonpj, goldfire, simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agoKill foldUFM in classifyTyCon
Bartosz Nitka [Tue, 10 May 2016 15:29:39 +0000 (08:29 -0700)] 
Kill foldUFM in classifyTyCon

We can get away with anyUFM here.

3 years agomake accept for Make simplifyInstanceContexts deterministic
Bartosz Nitka [Tue, 10 May 2016 14:56:06 +0000 (07:56 -0700)] 
make accept for Make simplifyInstanceContexts deterministic

Making it deterministic changed some error messages and I
forgot to make accept. Relevant change: b58b0e18a568.

3 years agoFix typos
Bartosz Nitka [Tue, 10 May 2016 14:45:55 +0000 (07:45 -0700)] 
Fix typos

3 years agoGet rid of Traversable UniqFM and Foldable UniqFM
Bartosz Nitka [Tue, 10 May 2016 14:17:28 +0000 (07:17 -0700)] 
Get rid of Traversable UniqFM and Foldable UniqFM

Both Traversable and Foldable can introduce non-determinism
and because of typeclass overloading it's implicit and not
obvious at the call site. This removes the instances, so that
they can't accidentally be used.

Test Plan: ./validate

Reviewers: austin, goldfire, bgamari, simonmar, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agoTest Trac #11640
Simon Peyton Jones [Tue, 10 May 2016 14:14:11 +0000 (15:14 +0100)] 
Test Trac #11640

3 years agoRecord that EqualityConstraint now works
Simon Peyton Jones [Tue, 10 May 2016 13:37:36 +0000 (14:37 +0100)] 
Record that EqualityConstraint now works

Fixing Trac #9478

3 years agoUse partial-sig constraints as givens
Simon Peyton Jones [Tue, 10 May 2016 11:48:29 +0000 (12:48 +0100)] 
Use partial-sig constraints as givens

In TcSimplify.simplifyInfer, use the context of a partial type
signature as 'givens' when simplifying the inferred constraints of the
group.  This way we get maximum benefit from them.  See
Note [Add signature contexts as givens].

This (finally) fixes test EqualityConstraints in Trac #9478.

And it's a nice tidy-up.

3 years agoAdd Outputable ShowHowMuch
Simon Peyton Jones [Mon, 9 May 2016 08:46:27 +0000 (09:46 +0100)] 
Add Outputable ShowHowMuch

I needed this instance when debugging, so I thought I'd add
it permanently.

3 years agoComments only
Simon Peyton Jones [Fri, 6 May 2016 08:50:03 +0000 (09:50 +0100)] 
Comments only

3 years agoComments about static forms
Simon Peyton Jones [Fri, 6 May 2016 08:49:46 +0000 (09:49 +0100)] 
Comments about static forms

3 years agoMake simplifyInstanceContexts deterministic
Bartosz Nitka [Tue, 10 May 2016 12:32:28 +0000 (05:32 -0700)] 
Make simplifyInstanceContexts deterministic

simplifyInstanceContexts used cmpType which is nondeterministic
for canonicalising typeclass constraints in derived instances.
Following changes make it deterministic as explained by the
Note [Deterministic simplifyInstanceContexts].

Test Plan: ./validate

Reviewers: simonmar, goldfire, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agoKill unnecessary cmpType in lhs_cmp_type
Bartosz Nitka [Tue, 10 May 2016 12:26:06 +0000 (05:26 -0700)] 
Kill unnecessary cmpType in lhs_cmp_type

This is the only call site of `lhs_cmp_type` and we only
care about equality.
`cmpType` is nondeterministic (because `TyCon`s are compared
with Uniques in `cmpTc`), so if we don't have to use it, it's
better not to.

Test Plan: ./validate

Reviewers: simonmar, goldfire, bgamari, austin, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agoComments only
Erik de Castro Lopo [Tue, 10 May 2016 08:09:50 +0000 (18:09 +1000)] 
Comments only

[skip ci]

3 years agoFix a crash in requestSync()
Simon Marlow [Tue, 10 May 2016 10:22:57 +0000 (03:22 -0700)] 
Fix a crash in requestSync()

It was possible for a thread to read invalid memory after a conflict
when multiple threads were synchronising.

I haven't been successful in constructing a test case that triggers
this, but we have some internal code that ran into it.

3 years agoRdrHsSyn: Only suggest `type` qualification when appropriate
Ben Gamari [Tue, 10 May 2016 09:02:19 +0000 (11:02 +0200)] 
RdrHsSyn: Only suggest `type` qualification when appropriate

This suggestion only applies to operators.

3 years agoForbid variables to be parents in import lists.
Matthew Pickering [Tue, 10 May 2016 06:41:46 +0000 (08:41 +0200)] 
Forbid variables to be parents in import lists.

In the long discussion on #11432, it was decided that when a type
constructor is parsed as a variable ((--.->) is one example) then in
order to export the type constructor then the user should be required to
use the ExplicitNamespaces keyword.

This was implemented in quite an indirect manner in the renamer. It
is much more direct to enforce this in the parser at the expense of
slighty worse error messages. Further to this, the check in the
renamer was actually slightly wrong. If the variable was in scope
then no error was raised, this was causing panics, see #12026 for an

Reviewers: austin, bgamari

Subscribers: davean, skvadrik, thomie

Differential Revision:

GHC Trac Issues: #12026

3 years agostg/Types.h: Fix comment and #include
Ben Gamari [Tue, 10 May 2016 06:51:25 +0000 (08:51 +0200)] 
stg/Types.h: Fix comment and #include

3 years agoRe-do the invariant for TcDepVars
Simon Peyton Jones [Mon, 9 May 2016 22:12:31 +0000 (23:12 +0100)] 
Re-do the invariant for TcDepVars

Previously I had it so that dv_kvs and dv_tvs didn't
overlap.  Now they can, and quantifyZonkedTyVars
removes the former from the latter.  This is more
economical, and in fact there was a bug where the
invariant wasn't re-established.

It's much easier to allow dv_kvs and dv_kvs to overlap,
and to eliminate the overlap in TcMType.quantifyZonkedTyVars

3 years agoError message wibbles, re partial type sigs
Simon Peyton Jones [Mon, 9 May 2016 12:52:18 +0000 (13:52 +0100)] 
Error message wibbles, re partial type sigs

I committed three patches involving partial type sigs that
are collectively responsible for these error message changes.
The are all just changes to numbering in the pretty-printer.

I didn't bother to partition them between patches -- sorry!

3 years agoTidy up partial-sig quantification
Simon Peyton Jones [Mon, 9 May 2016 12:48:34 +0000 (13:48 +0100)] 
Tidy up partial-sig quantification

There's a messy bit of tcSimplifyInfer which concerns how
quantify when partial type signatures are involved. This
patch tidies it up a lot.

Notice that decideQuantification and quantify_tvs get
much simpler.  And previously the inferred type of a
function could be cluttered with phantom variables that
were relevant only to the error messgas.

See Note [Quantification and partial signatures].

3 years agoFix partial sigs and pattern bindings interaction
Simon Peyton Jones [Mon, 9 May 2016 12:08:02 +0000 (13:08 +0100)] 
Fix partial sigs and pattern bindings interaction

It turns out that GHC 8.0 would accept entirely bogus
programs like

   f2 :: (True, _) -> Char
   Just f2 = Just (\x->x)

(which is now partial-sigs/should_fail/PatBind3)

This also fixes Trac #9478, test `PatBind2`.

3 years agoComments only
Simon Peyton Jones [Mon, 9 May 2016 10:52:11 +0000 (11:52 +0100)] 
Comments only

3 years agoEmit wild-card constraints in the right place
Simon Peyton Jones [Mon, 9 May 2016 10:49:15 +0000 (11:49 +0100)] 
Emit wild-card constraints in the right place

We were failing to emit wild-card hole constraints altogether
in the case of pattern bindings.  Reason: it was done in
tcExtendTyVarEnvFromSig, which isn't called for pattern bindings.

This patch make it work right for both pattern and function
bindings.  Mainly, there is a call to emitWildCardHolds in
tcRhs for both PatBind and FunBind.

I also killed off TcExpr.typeSigCtxt.

3 years agoWhite space only
Simon Peyton Jones [Mon, 9 May 2016 10:45:49 +0000 (11:45 +0100)] 
White space only

3 years agoUse stdint types for Stg{Word,Int}{8,16,32,64}
Tomas Carnecky [Sun, 8 May 2016 12:44:07 +0000 (14:44 +0200)] 
Use stdint types for Stg{Word,Int}{8,16,32,64}

We can't define Stg{Int,Word} in terms of {,u}intptr_t because STG
depends on them being the exact same size as void*, and {,u}intptr_t
does not make that guarantee. Furthermore, we also need to define
StgHalf{Int,Word}, so the preprocessor if needs to stay. But we can at
least keep it in a single place instead of repeating it in various

Also define STG_{INT,WORD}{8,16,32,64}_{MIN,MAX} and use it in HsFFI.h,
further reducing the need for CPP in other files.

Reviewers: austin, bgamari, simonmar, hvr, erikd

Subscribers: thomie

Differential Revision:

3 years agoDocumentation for simplifyDeriv.
Edward Z. Yang [Fri, 6 May 2016 23:34:50 +0000 (16:34 -0700)] 
Documentation for simplifyDeriv.

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

Reviewers: simonpj, austin, goldfire, bgamari

Subscribers: thomie

Differential Revision:

3 years agorts/ProfHeap.c: Use `ssize_t` instead of `long`.
Erik de Castro Lopo [Thu, 5 May 2016 08:36:16 +0000 (18:36 +1000)] 
rts/ProfHeap.c: Use `ssize_t` instead of `long`.

On x64 Windows `sizeof long` is 4 which could easily overflow
resulting in incorrect heap profiling results. This change does not
affect either Linux or OS X where `sizeof long` == `sizeof ssize_t`
regardless of machine word size.

Test Plan: Validate on Linux and Windows

Reviewers: hsyl20, bgamari, simonmar, austin

Subscribers: thomie

Differential Revision:

3 years agoUpdate time submodule to release tag
Herbert Valerio Riedel [Sat, 7 May 2016 06:41:54 +0000 (08:41 +0200)] 
Update time submodule to release tag

3 years agoRemove trailing whitespace from 'testsuite/tests/module/all.T'
Matthew Pickering [Fri, 6 May 2016 16:16:55 +0000 (17:16 +0100)] 
Remove trailing whitespace from 'testsuite/tests/module/all.T'

[skip ci]

3 years agoFix pretty printing of IEThingWith
Matthew Pickering [Fri, 6 May 2016 16:15:54 +0000 (17:15 +0100)] 
Fix pretty printing of IEThingWith

[skip ci]

3 years agoUpdate Win32 submodule to v2.3.1.1 release tag
Herbert Valerio Riedel [Fri, 6 May 2016 08:45:36 +0000 (10:45 +0200)] 
Update Win32 submodule to v2.3.1.1 release tag

3 years agoUse tcExtendGlobalValEnv for default methods
Simon Peyton Jones [Fri, 6 May 2016 07:21:33 +0000 (08:21 +0100)] 
Use tcExtendGlobalValEnv for default methods

We add the default method Ids to the global type envt in
tcAddImplicits; and then again in tcInstDcls2 (for reasons
explained there).  But for some reason in the latter case
we added them to the /local/ type envt, via tcExtendLetEnv.

This patch just uses tcExtendGlobalValEnv consistently
for both.

(I found this when reviewing slightly-awkward code from Facundo's
static-form error-message patch; turned out that the awkwardness
came back to this inconsistency in the handling of default

3 years agoExplain linter optimization for StaticPtr checks.
Facundo Domínguez [Fri, 6 May 2016 00:32:49 +0000 (21:32 -0300)] 
Explain linter optimization for StaticPtr checks.

3 years agoComments only explaining export list parsing.
Matthew Pickering [Thu, 5 May 2016 09:25:12 +0000 (10:25 +0100)] 
Comments only explaining export list parsing.

3 years agorts: Replace `nat` with `uint32_t`
Erik de Castro Lopo [Sun, 1 May 2016 20:37:14 +0000 (06:37 +1000)] 
rts: Replace `nat` with `uint32_t`

The `nat` type was an alias for `unsigned int` with a comment saying
it was at least 32 bits. We keep the typedef in case client code is
using it but mark it as deprecated.

Test Plan: Validated on Linux, OS X and Windows

Reviewers: simonmar, austin, thomie, hvr, bgamari, hsyl20

Differential Revision:

3 years agoKill non-deterministic foldUFM in TrieMap and TcAppMap
Bartosz Nitka [Wed, 4 May 2016 16:22:37 +0000 (09:22 -0700)] 
Kill non-deterministic foldUFM in TrieMap and TcAppMap

foldUFM introduces unnecessary non-determinism that actually
leads to different generated code as explained in
Note [TrieMap determinism].

As we're switching from UniqFM to UniqDFM here you might be
concerned about performance. There's nothing that ./validate
detects. nofib reports no change in Compile Allocations, but
Compile Time got better on some tests and worse on some,
yielding this summary:

        -1 s.d.                -----            -3.8%
        +1 s.d.                -----            +5.4%
        Average                -----            +0.7%

This is not a fair comparison as the order of Uniques
changes what GHC is actually doing. One benefit from making
this deterministic is also that it will make the
performance results more stable.

Full nofib results: P108

Test Plan: ./validate, nofib

Reviewers: goldfire, simonpj, simonmar, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agobase: Export runRW# from GHC.Exts
Ben Gamari [Wed, 4 May 2016 16:30:51 +0000 (18:30 +0200)] 
base: Export runRW# from GHC.Exts

Seems like this should be available in GHC.Exts. Thanks for @carter
for pointing this out.

Test Plan: Validate

Reviewers: rwbarton, hvr, austin

Reviewed By: austin

Subscribers: thomie, carter

Differential Revision:

3 years agotestsuite: Add test for #11959
Ben Gamari [Tue, 3 May 2016 20:58:47 +0000 (22:58 +0200)] 
testsuite: Add test for #11959

Test Plan: Validate, expected to fail

Reviewers: goldfire, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11959

3 years agoBe more aggressive when checking constraints for custom type errors.
Iavor S. Diatchki [Tue, 3 May 2016 20:55:07 +0000 (22:55 +0200)] 
Be more aggressive when checking constraints for custom type errors.

This fixes #11990.

The current rule is simpler than before: if we encounter an unsolved
constraint that contains any mentions of properly applied `TypeError`,
then we report the type error.

If there are multiple `TypeErrors`, then we just report one of them.

Reviewers: simonpj, bgamari, austin

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11990

3 years agoMake 'make fast' work for the User Guide
Simon Marlow [Wed, 4 May 2016 11:47:12 +0000 (12:47 +0100)] 
Make 'make fast' work for the User Guide

If you already have mkUserGuidePart compiled.

3 years agoDon't STATIC_INLINE giveCapabilityToTask
Simon Marlow [Wed, 4 May 2016 11:29:06 +0000 (04:29 -0700)] 
Don't STATIC_INLINE giveCapabilityToTask

This causes errors with some versions of gcc (4.4.7 here).

3 years agoschedulePushWork: avoid unnecessary wakeups
Simon Marlow [Sun, 24 Apr 2016 20:31:55 +0000 (21:31 +0100)] 
schedulePushWork: avoid unnecessary wakeups

This function had some pathalogically bad behaviour: if we had 2 threads
on the current capability and 23 other idle capabilities, we would

* grab all 23 capabilities
* migrate one Haskell thread to one of them
* wake up a worker on *all* 23 other capabilities.

This lead to a lot of unnecessary wakeups when using large -N values.

Now, we

* Count how many capabilities we need to wake up
* Start from cap->no+1, so that we don't overload low-numbered capabilities
* Only wake up capabilities that we migrated a thread to (unless we have
  sparks to steal)

This results in a pretty dramatic improvement in our production system.

3 years agoAdd +RTS -AL<size>
Simon Marlow [Sun, 24 Apr 2016 20:31:55 +0000 (21:31 +0100)] 
Add +RTS -AL<size>

+RTS -AL<size> controls the total size of large objects that can be
allocated before a GC is triggered.  Previously this was always just the
value of -A, and the limit mainly existed to prevent runaway allocation
in pathalogical programs that allocate a lot of large objects.  However,
since the limit is shared between all cores, on a large multicore the
default becomes more restrictive, and can end up triggering GC well
before it would normally have been.

Arguably a better default would be A*N, but this is probably excessive.
Adding a flag lets you choose, and I've left the default as it was.

See docs for usage.

3 years agoAllow limiting the number of GC threads (+RTS -qn<n>)
Simon Marlow [Sat, 9 Apr 2016 19:45:50 +0000 (20:45 +0100)] 
Allow limiting the number of GC threads (+RTS -qn<n>)

This allows the GC to use fewer threads than the number of capabilities.
At each GC, we choose some of the capabilities to be "idle", which means
that the thread running on that capability (if any) will sleep for the
duration of the GC, and the other threads will do its work.  We choose
capabilities that are already idle (if any) to be the idle capabilities.

The idea is that this helps in the following situation:

* We want to use a large -N value so as to make use of hyperthreaded
* We use a large heap size, so GC is infrequent
* But we don't want to use all -N threads in the GC, because that
  thrashes the memory too much.

See docs for usage.

3 years agoAdjust testsuite output to bytestring-
Joachim Breitner [Wed, 4 May 2016 08:54:39 +0000 (10:54 +0200)] 
Adjust testsuite output to bytestring-

This is a band-aid; the test suite should not be sensitive to these

3 years agoExport oneShot from GHC.Exts
Joachim Breitner [Wed, 4 May 2016 07:54:40 +0000 (09:54 +0200)] 
Export oneShot from GHC.Exts

as suggested by carter in #12011.

3 years agoUpdate bytestring submodule to release tag
Herbert Valerio Riedel [Tue, 3 May 2016 22:45:43 +0000 (00:45 +0200)] 
Update bytestring submodule to release tag

3 years agoUpdate libraries/hpc submodule to v0.6.0.3 release tag
Herbert Valerio Riedel [Tue, 3 May 2016 20:11:59 +0000 (22:11 +0200)] 
Update libraries/hpc submodule to v0.6.0.3 release tag

3 years agoCleanups related to MAX_FREE_LIST
Simon Marlow [Mon, 2 May 2016 19:26:15 +0000 (20:26 +0100)] 
Cleanups related to MAX_FREE_LIST

- Rename to the (more correct) NUM_FREE_LISTS

- NUM_FREE_LISTS should be derived from the block and mblock sizes, not
  defined manually.  It was actually too large by one, which caused a
  little bit of (benign) extra work in the form of a redundant loop
  iteration in some cases.

- Add some ASSERTs for input preconditions to log_2() and log_2_ceil()

- Fix some comments

- Fix usage in allocLargeChunk, to account for the fact that
  log_2_ceil() can return NUM_FREE_LISTS.

3 years agoRevert "Revert "Use __builtin_clz() to implement log_1()""
U-THEFACEBOOK\smarlow [Sun, 1 May 2016 07:27:35 +0000 (08:27 +0100)] 
Revert "Revert "Use __builtin_clz() to implement log_1()""

This reverts commit 546f24e4f8a7c086b1e5afcdda624176610cbcf8.

And adds a fix for Windows: we need to use __builtin_clzll() rather than
__builtin_clzl(), because StgWord is unsigned long long on Windows.

3 years agoStaticPointers: Allow closed vars in the static form.
Facundo Domínguez [Thu, 7 Apr 2016 19:20:19 +0000 (16:20 -0300)] 
StaticPointers: Allow closed vars in the static form.

With this patch closed variables are allowed regardless of whether
they are bound at the top level or not.

The FloatOut pass is always performed. When optimizations are
disabled, only expressions that go to the top level are floated.
Thus, the applications of the StaticPtr data constructor are always

The CoreTidy pass makes sure the floated applications appear in the
symbol table of object files. It also collects the floated bindings
and inserts them in the static pointer table.

The renamer does not check anymore if free variables appearing in the
static form are top-level. Instead, the typechecker looks at the
tct_closed flag to decide if the free variables are closed.

The linter checks that applications of StaticPtr only occur at the
top of top-level bindings after the FloatOut pass.

The field spInfoName of StaticPtrInfo has been removed. It used to
contain the name of the top-level binding that contains the StaticPtr
application. However, this information is no longer available when the
StaticPtr is constructed, as the binding name is determined now by the
FloatOut pass.

Test Plan: ./validate

Reviewers: goldfire, simonpj, austin, hvr, bgamari

Reviewed By: simonpj

Subscribers: thomie, mpickering, mboes

Differential Revision:

GHC Trac Issues: #11656

3 years agoMake validDerivPred ignore non-visible arguments to a class type constructor
RyanGlScott [Mon, 2 May 2016 16:38:04 +0000 (12:38 -0400)] 
Make validDerivPred ignore non-visible arguments to a class type constructor

GHC choked when trying to derive the following:

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PolyKinds #-}
module Example where

class Category (cat :: k -> k -> *) where
  catId   :: cat a a
  catComp :: cat b c -> cat a b -> cat a c

newtype T (c :: * -> * -> *) a b = MkT (c a b) deriving Category

Unlike in #8865, where we were deriving `Category` for a concrete type like
`Either`, in the above example we are attempting to derive an instance of the

instance Category * c => Category (T * c) where ...

(using `-fprint-explicit-kinds` syntax). But `validDerivPred` is checking if
`sizePred (Category * c)` equals the number of free type variables in
`Category * c`. But note that `sizePred` counts both type variables //and//
type constructors, and `*` is a type constructor! So `validDerivPred`
erroneously rejects the above instance.

The fix is to make `validDerivPred` ignore non-visible arguments to the class
type constructor (e.g., ignore `*` is `Category * c`) by using

Fixes #11833.

Test Plan: ./validate

Reviewers: goldfire, hvr, simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11833

3 years agodocs/users_guide/glasgow_exts.rst: fix merge conflict
Sergei Trofimovich [Mon, 2 May 2016 10:24:23 +0000 (11:24 +0100)] 
docs/users_guide/glasgow_exts.rst: fix merge conflict

Signed-off-by: Sergei Trofimovich <>
3 years agoglasgow_exts.rst: fix quoting
Sergei Trofimovich [Thu, 21 Apr 2016 21:43:11 +0000 (22:43 +0100)] 
glasgow_exts.rst: fix quoting

glasgow_exts.rst:6525: WARNING: Inline literal start-string without end-string.

Signed-off-by: Sergei Trofimovich <>
3 years agoadded docstring for '-fhistory-size' flag
Sergei Trofimovich [Sun, 3 Jan 2016 11:55:38 +0000 (11:55 +0000)] 
added docstring for '-fhistory-size' flag

Signed-off-by: Sergei Trofimovich <>
3 years agoMake sure record pattern synonym selectors are in scope in GHCi.
Matthew Pickering [Sun, 1 May 2016 22:11:30 +0000 (00:11 +0200)] 
Make sure record pattern synonym selectors are in scope in GHCi.

Beforehand, when a record pattern synonym was defined in GHCi
the selectors would not be in scope. This is because of `is_sub_bndr`
in `HscTypes.icExtendGblRdrEnv` was throwing away the selectors.

This was broken by the fix to #10520 but it is easy to resolve.

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11985

3 years agoRemove unused equivClassesByUniq
Bartosz Nitka [Sun, 1 May 2016 22:09:22 +0000 (00:09 +0200)] 
Remove unused equivClassesByUniq

It uses `eltsUFM` so it can introduce nondeterminism, but it isn't used
so we can delete it.

Test Plan: it builds

Reviewers: simonpj, goldfire, simonmar, austin, bgamari

Reviewed By: austin, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agoExport constructors for IntPtr and WordPtr
RyanGlScott [Sun, 1 May 2016 22:07:14 +0000 (00:07 +0200)] 
Export constructors for IntPtr and WordPtr

This finishes what #5529 started by exporting the constructors for
`IntPtr` and `WordPtr` from `Foreign.Ptr`, allowing them to be used in
`foreign` declarations.

Fixes #11983.

Test Plan: `make TEST=T11983`

Reviewers: simonpj, hvr, bgamari, austin

Reviewed By: simonpj

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #11983

3 years agoderiveConstants: Fix nm advice one last time
Ben Gamari [Sun, 1 May 2016 16:05:28 +0000 (18:05 +0200)] 
deriveConstants: Fix nm advice one last time

Missing a close paren.

3 years agoAdd T11747 as a test
Ömer Sinan Ağacan [Sun, 1 May 2016 16:03:05 +0000 (18:03 +0200)] 
Add T11747 as a test

Reviewers: bgamari, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11747

3 years agoRemove unused getScopedTyVarBinds
Bartosz Nitka [Sun, 1 May 2016 15:56:39 +0000 (17:56 +0200)] 
Remove unused getScopedTyVarBinds

Test Plan: it compiles

Reviewers: simonpj, austin, goldfire, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie, simonmar

Differential Revision:

GHC Trac Issues: #4012

3 years agorts/itimer/pthread: Stop timer when ticker is stopped
Ben Gamari [Sun, 1 May 2016 15:41:05 +0000 (17:41 +0200)] 
rts/itimer/pthread: Stop timer when ticker is stopped

This reworks the pthread-based itimer implementation to disarm the timer
when events aren't needed. Thanks to hsyl20 for the nice design.

Test Plan: Validate

Reviewers: hsyl20, simonmar, austin

Reviewed By: simonmar

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #1623, #11965

3 years agoKill Itimer.h
Ben Gamari [Thu, 21 Apr 2016 10:01:12 +0000 (12:01 +0200)] 
Kill Itimer.h

It declared nothing.

3 years agoCatch errors from timerfd_settime
Ben Gamari [Thu, 21 Apr 2016 11:57:18 +0000 (13:57 +0200)] 
Catch errors from timerfd_settime

3 years agorts: Split up Itimer.c
Ben Gamari [Sun, 1 May 2016 11:39:23 +0000 (13:39 +0200)] 
rts: Split up Itimer.c

This shouldn't have any functional changes. It merely splits up what are
essentially three distinct codepaths which are melding together with

At the moment I merely #include the implementation to use with CPP
although this really feels very yucky.

Reviewers: erikd, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision:

3 years agorts: Close livelock window due to rapid ticker enable/disable
Ben Gamari [Sun, 1 May 2016 11:38:38 +0000 (13:38 +0200)] 
rts: Close livelock window due to rapid ticker enable/disable

This fixes #11830, where the RTS would livelock if run with `-I0` due
to a regression introduced by bbdc52f3a6e6a28e209fb8f65699121d4ef3a4e3.
The reason for this is that the new codepath introduced a subtle race

 1. one thread could request that the ticker stop and would block until
    the ticker in fact stopped
 2. meanwhile, another thread could sneak in and restart the ticker

this was implemented in such a way where thread (1) would end up
blocked forever. The solution here is to simply not block. The worst
that will happen is that timer fires again, but is ignored since the
ticker is stopped.

Test Plan:
Validate, try reproduction case in #11830. Need to find a nice

Reviewers: simonmar, erikd, hsyl20, austin

Reviewed By: erikd, hsyl20

Subscribers: erikd, thomie

Differential Revision:

GHC Trac Issues: #11830

3 years agoGreater customization of GHCi prompt
niksaz [Sun, 1 May 2016 11:34:45 +0000 (13:34 +0200)] 
Greater customization of GHCi prompt

This patch is trying to redesign the :set prompt option to take not a
String but a Haskell function, like [String] -> Int -> IO String, where
[String] is the list of the names of the currently loaded modules and
Int is the line number. Currently you may set prompt function with
**:set promt-function [String] -> Int -> IO String** option and old
version is also available - :set prompt String.

So, it looks like I've almost completed this patch:

1) Now we have a lot of escape sequences - 13 to be exact. Most of them
   are similar to bash prompt escape sequences. Thus they are quite handy.

2) We may use the special escape sequence to call shell functions, for
   example "%call(ls -l -a)".

3) We may use :set prompt-function to set PFunction to handle prompt.
   It is just [String] -> Int -> IO String.

Reviewers: erikd, austin, mpickering, bgamari

Reviewed By: mpickering, bgamari

Subscribers: mpickering, thomie

Differential Revision:

GHC Trac Issues: #5850

3 years agoBump haddock submodule
Ben Gamari [Sun, 1 May 2016 11:22:14 +0000 (13:22 +0200)] 
Bump haddock submodule

Fixes documentation installation.

3 years agousers-guide: Add index entry for "environment file"
Ben Gamari [Sun, 1 May 2016 11:21:55 +0000 (13:21 +0200)] 
users-guide: Add index entry for "environment file"

3 years agorts: Remove deprecated C type `lnat`
Erik de Castro Lopo [Sun, 1 May 2016 11:59:50 +0000 (21:59 +1000)] 
rts: Remove deprecated C type `lnat`

The `lnat` type was deprecated in 2012 in commit 41737f12f9 with
a note to use `StgWord` instead.

Test Plan: Validate on Linux and OS X

Reviewers: simonmar, austin, Phyx, hvr, bgamari

Reviewed By: simonmar, Phyx, bgamari

Subscribers: thomie

Differential Revision:

3 years agoFix aggressive cleanup of T1407
Tamar Christina [Sun, 1 May 2016 15:25:48 +0000 (17:25 +0200)] 
Fix aggressive cleanup of T1407

The aggressive cleanup routine of T1407 is removing files that don't belong to it.
Constrain the test to only removing files it should by putting all it's generated
binaries in it's own output folder.

Test Plan: make test -C testsuite/tests/ghci/linking/dyn

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

Differential Revision:

GHC Trac Issues: #1407

3 years agoTypos in DmdAnal
Ömer Sinan Ağacan [Sun, 1 May 2016 07:14:29 +0000 (03:14 -0400)] 
Typos in DmdAnal

3 years agoComment typo: unambigious -> unambiguous
Ryan Scott [Sat, 30 Apr 2016 18:34:25 +0000 (14:34 -0400)] 
Comment typo: unambigious -> unambiguous

[ci skip]

3 years agoComment typos: Mkae -> Make, Hsakell -> Haskell
RyanGlScott [Sat, 30 Apr 2016 18:10:30 +0000 (14:10 -0400)] 
Comment typos: Mkae -> Make, Hsakell -> Haskell

[ci skip]

3 years agoFix reference to Note in TcCanonical
RyanGlScott [Sat, 30 Apr 2016 18:06:31 +0000 (14:06 -0400)] 
Fix reference to Note in TcCanonical

Previously, it was referring to Note [Decomposing equalities],
but the name of it is actually  Note [Decomposing equality].

[ci skip]

3 years agoTestsuite: accept new output for 2 partial-sigs tests
Thomas Miedema [Thu, 28 Apr 2016 13:49:24 +0000 (15:49 +0200)] 
Testsuite: accept new output for 2 partial-sigs tests

Test Plan: make TEST='ExtraNumAMROn TidyClash2'

Differential Revision:

GHC Trac Issues: #9478

3 years agoTestsuite: make CLEANUP=1 the default (#9758)
Thomas Miedema [Tue, 26 Apr 2016 13:12:05 +0000 (15:12 +0200)] 
Testsuite: make CLEANUP=1 the default (#9758)

Also move the `cleanup` setting from `default_testopts` to `config`. The
`cleanup` setting is the same for all tests, hence it belongs in

Reviewed by: austin

Differential Revision:

3 years agoPPC NCG: Improve pointer de-tagging code
Peter Trommler [Fri, 29 Apr 2016 17:45:10 +0000 (17:45 +0000)] 
PPC NCG: Improve pointer de-tagging code

Generate a clrr[wd]i instruction to clear the tag bits in a pointer.
This saves one instruction and one temporary register.

Optimize signed comparison with zero after andi. operation This saves
one instruction when comparing a pointer tag with zero.

This reduces code size by 0.6 % in all nofib benchmarks.

Test Plan: validate on AIX and 32-bit Linux

Reviewed By: erikd, hvr

Differential Revision:

3 years agoFix typo: Superclases -> Superclasses
Bartosz Nitka [Fri, 29 Apr 2016 14:46:24 +0000 (07:46 -0700)] 
Fix typo: Superclases -> Superclasses

3 years agoTest #11484 in th/T11484
Richard Eisenberg [Tue, 26 Apr 2016 18:07:08 +0000 (14:07 -0400)] 
Test #11484 in th/T11484

3 years agoRemove the incredibly hairy splitTelescopeTvs.
Richard Eisenberg [Tue, 26 Apr 2016 14:50:33 +0000 (10:50 -0400)] 
Remove the incredibly hairy splitTelescopeTvs.

This patch removes splitTelescopeTvs by adding information about
scoped type variables to TcTyCon. Vast simplification!

This also fixes #11821 by bringing only unzonked vars into scope.

Test case: polykinds/T11821

3 years agoRTS: delete BlockedOnGA* + dead code
Thomas Miedema [Sat, 27 Feb 2016 21:02:22 +0000 (22:02 +0100)] 
RTS: delete BlockedOnGA* + dead code

Some old stuff related to the PAR way.

Reviewed by: austin, simonmar

Differential Revision:

3 years agotestsuite: fix up T11223's Makefile
Austin Seipp [Thu, 28 Apr 2016 23:42:55 +0000 (23:42 +0000)] 
testsuite: fix up T11223's Makefile

As reported by Simon on ghc-devs, this causes the build on Windows
to fail because it cannot find the `cc` command. The Makefile here
actually already sets `GCC=gcc`, but for some reason then uses both
`$(GCC)` and `$(CC)` to refer to C compilation.

Signed-off-by: Austin Seipp <>
Reviewed By: thomie

Differential Revision:

3 years agoFix path to the new build system, now called Hadrian.
Andrey Mokhov [Thu, 28 Apr 2016 22:32:14 +0000 (23:32 +0100)] 
Fix path to the new build system, now called Hadrian.

The new Shake-based build system has been given a name -- Hadrian,
and now lives in /hadrian directory.

This fixes the path to the configuration file to be populated by
the configure script.

Test Plan: Run Hadrian build.

Reviewers: thomie, bgamari, hvr, austin

Reviewed By: austin

Subscribers: erikd

Differential Revision:

3 years agoRemove unused foldNameEnv
Bartosz Nitka [Thu, 28 Apr 2016 22:27:17 +0000 (15:27 -0700)] 
Remove unused foldNameEnv

foldNameEnv is nondeterministic in the general case and it's
currently unused so we can remove it.

3 years agoRemove unused foldFsEnv
Bartosz Nitka [Thu, 28 Apr 2016 21:56:28 +0000 (14:56 -0700)] 
Remove unused foldFsEnv

foldFsEnv is nondeterministic in the general case and since it's
unused we can just remove it.

3 years agoLinker: Fix implicit function declaration warning on OS X
Erik de Castro Lopo [Tue, 26 Apr 2016 21:01:26 +0000 (07:01 +1000)] 
Linker: Fix implicit function declaration warning on OS X

Introduced in commit 177aec697b3.

Test Plan: Validate on OSX and Linux.

Reviewers: austin, bgamari, hvr

Subscribers: goldfire, thomie

Differential Revision:

3 years agorts/LdvProfile.c: Fix NULL dereference on shutdown
Erik de Castro Lopo [Thu, 28 Apr 2016 21:15:53 +0000 (07:15 +1000)] 
rts/LdvProfile.c: Fix NULL dereference on shutdown

Test Plan: validate

Reviewers: carter, austin, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11978

3 years agoTestsuite: delete T5054 and T5054_2 (#5054)
Thomas Miedema [Mon, 25 Apr 2016 15:22:55 +0000 (17:22 +0200)] 
Testsuite: delete T5054 and T5054_2 (#5054)

These tests no longer compile, because the hmatrix api has completely
changed. Even if we managed to fix the tests, I don't think they would
provided much value, since the ghc/llvm bug from #5054 was not
reproducible in the first place.

Reviewed by: bgamari

Differential Revision:

3 years agoTestsuite: delete -fesc tests
Thomas Miedema [Mon, 25 Apr 2016 18:28:23 +0000 (20:28 +0200)] 
Testsuite: delete -fesc tests

The -fesc flag does not exist, and has never existed.

Also delete now unused config.compiler_tags, and 'Project version' never
contains a '-'.

Reviewed by: bgamari

Differential Revision:

3 years agoKill mapUniqSet
Bartosz Nitka [Thu, 28 Apr 2016 20:35:14 +0000 (13:35 -0700)] 
Kill mapUniqSet

Note [Unsound mapUniqSet] explains why it got removed.

Test Plan: build ghc

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, simonmar

Differential Revision:

3 years agoAdd uniqSetAny and uniqSetAll and use them
Bartosz Nitka [Thu, 28 Apr 2016 20:32:39 +0000 (13:32 -0700)] 
Add uniqSetAny and uniqSetAll and use them

There are couple of places where we do `foldUniqSet` just to
compute `any` or `all`. `foldUniqSet` is non-deterministic in the
general case and `any` and `all` also read nicer.

Test Plan: ./validate

Reviewers: simonmar, goldfire, simonpj, bgamari, austin

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agoTestsuite: benign test fixes
Thomas Miedema [Thu, 28 Apr 2016 15:08:53 +0000 (17:08 +0200)] 
Testsuite: benign test fixes

3 years agoTestsuite: fix T11223_simple_(unused_)duplicate_lib
Thomas Miedema [Thu, 28 Apr 2016 09:55:40 +0000 (11:55 +0200)] 
Testsuite: fix T11223_simple_(unused_)duplicate_lib

These tests were failing on Travis when run independently from

3 years agoTestsuite: add -ignore-dot-ghci to some ghci tests [skip ci]
Thomas Miedema [Thu, 28 Apr 2016 09:49:02 +0000 (11:49 +0200)] 
Testsuite: add -ignore-dot-ghci to some ghci tests [skip ci]