4 years agoFix signature of atomic builtins
Andreas Schwab [Fri, 2 Oct 2015 21:03:12 +0000 (23:03 +0200)] 
Fix signature of atomic builtins

This patch is due to Andreas Schwab.

This fixes #10926, which reports (on AArch64) errors of the form,

/tmp/ghc1492_0/ghc_1.hc:2844:25: warning: passing argument 1 of
'hs_atomic_xor64' makes pointer from integer without a cast
     _c1Ho = hs_atomic_xor64((*Sp) + (((Sp[1]) << 0x3UL) + 0x10UL), Sp[2]);

In file included from
/home/abuild/rpmbuild/BUILD/ghc-7.10.2/includes/Stg.h:273:0: 0,
                 from /tmp/ghc1492_0/ghc_1.hc:3:

     note: expected 'volatile StgWord64 *
           {aka volatile long unsigned int *}'
           but argument is of type 'long unsigned int'
     StgWord64 hs_atomic_xor64(volatile StgWord64 *x, StgWord64 val);

Test Plan: Validate

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10926

4 years agoMove CallStack back to base
Ben Gamari [Fri, 2 Oct 2015 13:50:34 +0000 (15:50 +0200)] 
Move CallStack back to base

CallStack requires tuples, instances of which are defined in GHC.Tuple.
Unfortunately the change made in D757 to the `Typeable` deriving
mechanism means that `GHC.Tuple` must import `GHC.Types` for types
necessary to generate type representations.  This results in a cycle.

Test Plan: Validate

Reviewers: gridaphobe, austin, hvr

Subscribers: thomie

Differential Revision:

4 years agoLLVM: Factor out accumulation of LLVM statements and variables
Ben Gamari [Fri, 2 Oct 2015 13:49:24 +0000 (15:49 +0200)] 
LLVM: Factor out accumulation of LLVM statements and variables

The LLVM code generator currently has a rather large amount of
boilerplate devoted to piping around and building up various AST
elements. This is rather unfortunate for a language which prides itself
on ease of abstraction and detracts from readability.

Here I continue a refactoring that I originally suggested in D991, using
`WriterT` to factor out this pattern. `WriterT` is in general a bit
problematic from an evaluation perspective, but the expressions here are
small enough that it should be a problem in practice.

Test Plan: Validate

Reviewers: austin

Reviewed By: austin

Subscribers: thomie

Differential Revision:

4 years agoLLVM: Implement atomic operations in terms of LLVM primitives
Ben Gamari [Fri, 2 Oct 2015 13:48:55 +0000 (15:48 +0200)] 
LLVM: Implement atomic operations in terms of LLVM primitives

This fixes Trac #7883.

This adds proper support for,
  * `MO_AtomicRMW`
  * `MO_AtomicWrite`
  * `MO_CmpXChg`

Test Plan: Validate

Reviewers: rrnewton, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #7883

4 years agonativeGen PPC: fix > 16 bit offsets in stack handling
Peter Trommler [Fri, 2 Oct 2015 13:48:30 +0000 (15:48 +0200)] 
nativeGen PPC: fix > 16 bit offsets in stack handling

Implement access to spill slots at offsets larger than 16 bits.
Also allocation and deallocation of spill slots was restricted to
16 bit offsets. Now 32 bit offsets are supported on all PowerPC

The implementation of 32 bit offsets requires more than one instruction
but the native code generator wants one instruction. So we implement
pseudo-instructions that are pretty printed into multiple assembly

With pseudo-instructions for spill slot allocation and deallocation
we can also implement handling of the back chain pointer according
to the ELF ABIs.

Test Plan: validate (especially on powerpc (32 bit))

Reviewers: bgamari, austin, erikd

Reviewed By: erikd

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #7830

4 years agoDocument peculiarities of `traceM`.
Matthias Fischmann [Fri, 2 Oct 2015 13:48:08 +0000 (15:48 +0200)] 
Document peculiarities of `traceM`.

Reviewers: bgamari, hvr, austin

Reviewed By: bgamari, hvr, austin

Subscribers: thomie

Differential Revision:

4 years agoFix treatment of -0.0
Ben Gamari [Fri, 2 Oct 2015 13:40:43 +0000 (15:40 +0200)] 
Fix treatment of -0.0

Here we fix a few mis-optimizations that could occur in code with
floating point comparisons with -0.0. These issues arose from our
insistence on rewriting equalities into case analyses and the
simplifier's ignorance of floating-point semantics.

For instance, in Trac #10215 (and the similar issue Trac #9238) we
turned `ds == 0.0` into a case analysis,

case ds of
    __DEFAULT -> ...
    0.0 -> ...

Where the second alternative matches where `ds` is +0.0 and *also* -0.0.
However, the simplifier doesn't realize this and will introduce a local
inlining of `ds = -- +0.0` as it believes this is the only
value that matches this pattern.

Instead of teaching the simplifier about floating-point semantics
we simply prohibit case analysis on floating-point scrutinees and keep
this logic in the comparison primops, where it belongs.

We do several things here,

 - Add test cases from relevant tickets
 - Clean up a bit of documentation
 - Desugar literal matches against floats into applications of the
   appropriate equality primitive instead of case analysis
 - Add a CoreLint to ensure we don't pattern match on floats in Core

Test Plan: validate with included testcases

Reviewers: goldfire, simonpj, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10215, #9238

4 years agoUpdate nofib submodule again
Joachim Breitner [Fri, 2 Oct 2015 11:20:59 +0000 (13:20 +0200)] 
Update nofib submodule again

reverting my bogus commit there.

4 years agoUpdate nofib submodule
Joachim Breitner [Fri, 2 Oct 2015 09:09:31 +0000 (11:09 +0200)] 
Update nofib submodule

to contain these commits:
   commit 8bffe3cb01ce404ab493de2b4316f2c1c4a9bda9
   Author: Joachim Breitner <>
   Date:   Fri Oct 2 10:09:17 2015 +0200

       Expected output of mandel when run under valgrind

       probably due to rounding/floating point precision numbers. It looks
       broken, but so does the existing file spectral/mandel/mandel.stdout-mingw.

   commit f9a577973edf6976e4c0703bf2afac900d7b6fd8
   Author: Gabor Greif <>
   Date:   Fri Jul 31 00:43:38 2015 +0200

       Typos in comments

   commit 20ae9113ad31eca426883544f597a3cae9b60d94
   Author: Simon Peyton Jones <>
   Date:   Fri Apr 24 15:10:02 2015 +0100

       Add exact-real-arithmetic benchmark from David Lester

4 years agoAdd Data.Semigroup and Data.List.NonEmpty (re #10365)
Herbert Valerio Riedel [Sun, 27 Sep 2015 10:01:41 +0000 (12:01 +0200)] 
Add Data.Semigroup and Data.List.NonEmpty (re #10365)

This implements phase 1 of the semigroup-as-monoid-superclass
proposal (

The modules were migrated from the `semigroups-0.17` release mostly
as-is, except for dropping several trivial `{-# INLINE #-}`s,
removing CPP usage, and instances for types & classes provided
outside of `base` (e.g. `containers`, `deepseq`, `hashable`, `tagged`,
`bytestring`, `text`)

Differential Revision:

4 years agoTypos in comments
Joachim Breitner [Thu, 1 Oct 2015 19:55:57 +0000 (21:55 +0200)] 
Typos in comments

4 years ago.gitignore update for some test files.
Edward Z. Yang [Sat, 19 Sep 2015 05:30:12 +0000 (22:30 -0700)] 
.gitignore update for some test files.

Signed-off-by: Edward Z. Yang <>
4 years agoLexer: delete dead code for binary character literals
Thomas Miedema [Tue, 29 Sep 2015 15:54:32 +0000 (17:54 +0200)] 
Lexer: delete dead code for binary character literals

The Haskell 2010 report chapter 2.6 (Characters and String Literals)

  "Numeric escapes such as \137 are used to designate the character with
  decimal representation 137; octal (e.g. \o137) and hexadecimal (e.g.
  \x37) representations are also allowed."

Commit 1c0b5fdc9f2b6ea8166cc565383d4cd20432343c added syntax for writing
character literals using binary notation (e.g. '\b100100'). But this
code can never be reached, because '\b' already represents "backspace".

Turn on -fwarn-overlapping-patterns to catch such bugs in the future.

Reviewed by: hvr

Differential Revision:

4 years agoAllow enumDeltaIntegerFB to be inlined
Joachim Breitner [Mon, 28 Sep 2015 11:48:40 +0000 (13:48 +0200)] 
Allow enumDeltaIntegerFB to be inlined

The function is very small and the compiler should be at liberty to
inline it. But it is recursive, so it did not do it before. By applying
the usual transformation with a local recursive function, GHC can now
inline it, producing the loop that one would expect.

4 years agoreify associated types when reifying typeclasses(#10891)
Ömer Sinan Ağacan [Sat, 26 Sep 2015 19:07:51 +0000 (21:07 +0200)] 
reify associated types when reifying typeclasses(#10891)

As reported in Trac #10891, Template Haskell's `reify` was not
generating Decls for associated types. This patch fixes that.

Note that even though `reifyTyCon` function used in this patch returns
some type instances, I'm ignoring that.

Here's an example of how associated types are encoded with this patch:

(Simplified representation)

    class C a where
      type F a :: *


    OpenTypeFamilyD "F" ["a"]

With default type instances:

    class C a where
      type F a :: *
      type F a = a


    OpenTypeFamilyD "F" ["a"]
    TySynInstD "F" (TySynEqn [VarT "a"] "a")

Test Plan:
This patch was already reviewed and even merged. The patch is later
reverted because apparently it broke the build some time between the
validation of this patch and merge. Creating this new ticket to fix the

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10891

4 years agorts: Clean up whitespace in Trace.h
Ben Gamari [Sat, 26 Sep 2015 17:03:18 +0000 (19:03 +0200)] 
rts: Clean up whitespace in Trace.h

4 years agoDebug: Remove extraneous LANGUAGE CPP
Ben Gamari [Mon, 24 Aug 2015 09:42:24 +0000 (11:42 +0200)] 
Debug: Remove extraneous LANGUAGE CPP

4 years agoSkip a possible BOM in utf8 encoding
Joachim Breitner [Wed, 23 Sep 2015 08:10:03 +0000 (10:10 +0200)] 
Skip a possible BOM in utf8 encoding

and not the system locale, which might be something else. This fixes
bug #10907. A test is added, but less useful than it could be until
task #10909 is done.

Differential Revision: D1274

4 years agoDwarf: Ensure block length is encoded correctly
Ben Gamari [Fri, 25 Sep 2015 10:51:54 +0000 (12:51 +0200)] 
Dwarf: Ensure block length is encoded correctly

This is supposed to be encoded with ULEB128 which the previous
implementation would only guarranty with short lengths. This likely
holds in nearly all cases, but I'd really rather not take changes.

I fix this using the `.uleb128` directive. I'm not certain that this is
portable across assemblers but it makes this quite straightforward and
at the moment I value correctness over portability.

Test Plan: Compare implementation to DWARF spec

Reviewers: scpmw, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision:

4 years agoDwarf: Rename binding to avoid shadowing ppr
Ben Gamari [Fri, 25 Sep 2015 10:51:01 +0000 (12:51 +0200)] 
Dwarf: Rename binding to avoid shadowing ppr

Reviewers: austin

Reviewed By: austin

Subscribers: thomie

Differential Revision:

4 years agoWeak: Don't require wrapping/unwrapping of finalizers
Ben Gamari [Wed, 23 Sep 2015 12:36:40 +0000 (14:36 +0200)] 
Weak: Don't require wrapping/unwrapping of finalizers

To quote Simon Marlow,

    We don't expect users to ever write code that uses mkWeak# or
    finalizeWeak#, we have safe interfaces to these. Let's document the type
    unsafety and fix the problem with () without introducing any overhead.

Updates stm submodule.

4 years agoTestsuite: add test for #10767
Thomas Miedema [Thu, 24 Sep 2015 12:51:56 +0000 (14:51 +0200)] 
Testsuite: add test for #10767

4 years agoTestsuite: properly fix T8832.stdout-ws-32 (#8832)
Thomas Miedema [Thu, 24 Sep 2015 10:10:29 +0000 (12:10 +0200)] 
Testsuite: properly fix T8832.stdout-ws-32 (#8832)

4 years agoTestsuite: update expected output for T8832 on 32-bit systems (#8832)
Thomas Miedema [Thu, 24 Sep 2015 10:04:33 +0000 (12:04 +0200)] 
Testsuite: update expected output for T8832 on 32-bit systems (#8832)

4 years agoFix DeriveGeneric for types with same OccName (#10487)
Ömer Sinan Ağacan [Thu, 24 Sep 2015 07:51:19 +0000 (00:51 -0700)] 
Fix DeriveGeneric for types with same OccName (#10487)

DeriveGeneric generates some data types (for data type constructors and for
selectors of those constructors) and instances for those types. This patch
changes name generation for these new types to make it working with data types
with same names imported from different modules and with data types with same
names imported from same modules(using module imports).

Bonus content:

- Some refactoring in `TcGenGenerics.metaTyConsToDerivStuff` to remove some
  redundant partial function applications and to remove a duplicated function.
- Remove some unused names from `OccName`. (those were used for an old
  implementation of `DeriveGeneric`)

Reviewers: kosmikus, simonpj, dreixel, ezyang, bgamari, austin

Reviewed By: bgamari, austin

Subscribers: ezyang, thomie

Differential Revision:

GHC Trac Issues: #10487

4 years agoFix a bug with mallocForeignPtr and finalizers (#10904)
Simon Marlow [Wed, 23 Sep 2015 09:01:23 +0000 (10:01 +0100)] 
Fix a bug with mallocForeignPtr and finalizers (#10904)

Summary: See Note [MallocPtr finalizers]

Test Plan: validate; new test T10904

Reviewers: ezyang, bgamari, austin, hvr, rwbarton

Subscribers: thomie

Differential Revision:

4 years agoRevert "reify associated types when reifying typeclasses"
Austin Seipp [Wed, 23 Sep 2015 23:12:14 +0000 (18:12 -0500)] 
Revert "reify associated types when reifying typeclasses"

This caused the build to fail, due to some type checking errors. Whoops.

This reverts commit 5c115236fe795aa01f0c10106f1b1c959486a739.

4 years agoreify associated types when reifying typeclasses
Ömer Sinan Ağacan [Wed, 23 Sep 2015 18:19:58 +0000 (13:19 -0500)] 
reify associated types when reifying typeclasses

As reported in Trac #10891, Template Haskell's `reify` was not generating Decls
for associated types. This patch fixes that.

Note that even though `reifyTyCon` function used in this patch returns some
type instances, I'm ignoring that.

Here's an example of how associated types are encoded with this patch:

(Simplified representation)

    class C a where
      type F a :: *


    OpenTypeFamilyD "F" ["a"]

With default type instances:

    class C a where
      type F a :: *
      type F a = a


    OpenTypeFamilyD "F" ["a"]
    TySynInstD "F" (TySynEqn [VarT "a"] "a")

Reviewed By: goldfire

Differential Revision:

GHC Trac Issues: #10891

4 years agobase: export allocation counter/limit API from System.Mem
Simon Marlow [Wed, 23 Sep 2015 18:13:28 +0000 (13:13 -0500)] 
base: export allocation counter/limit API from System.Mem

Previously it was only available from GHC.Conc, but it makes sense for it to be
available from a more official place where people might find it.

While I was here, I improved the docs a little.

Reviewed By: austin

Differential Revision:

4 years agoUpdate Cabal to recognize DeriveLift
RyanGlScott [Wed, 23 Sep 2015 18:10:42 +0000 (13:10 -0500)] 
Update Cabal to recognize DeriveLift

This should (1) fix the ./validate build, which I accidentally broke in D1168,
and (2) update the Cabal submodule so that it recognizes `DeriveLift` as a GHC

Reviewed By: adamse, austin

Differential Revision:

GHC Trac Issues: #1830

4 years agoAdd constant-folding rule for Data.Bits.bit
Ben Gamari [Wed, 23 Sep 2015 18:10:13 +0000 (13:10 -0500)] 
Add constant-folding rule for Data.Bits.bit

This adds a constant-folding rule for `Integer`'s implementation of `bit` and
fixes the `T8832` testcase. Fixes #8832.

Reviewed By: simonpj, austin

Differential Revision:

GHC Trac Issues: #8832

4 years agoAnnotate CmmBranch with an optional likely target
Simon Marlow [Mon, 21 Sep 2015 08:14:33 +0000 (09:14 +0100)] 
Annotate CmmBranch with an optional likely target

This allows the code generator to give hints to later code generation
steps about which branch is most likely to be taken.  Right now it
is only taken into account in one place: a special case in
CmmContFlowOpt that swapped branches over to maximise the chance of
fallthrough, which is now disabled when there is a likelihood setting.

Test Plan: validate

Reviewers: austin, simonpj, bgamari, ezyang, tibbe

Subscribers: thomie

Differential Revision:

4 years agoDsBinds: Avoid using String when desugaring CallStack construction
Ben Gamari [Tue, 22 Sep 2015 22:56:03 +0000 (00:56 +0200)] 
DsBinds: Avoid using String when desugaring CallStack construction

Previously CallStacks would be built using String, which would pull in
GHC.Base while compiling GHC.Err. Use [Char] instead.

4 years agoRemove references to () from types of mkWeak# and friends
Ben Gamari [Fri, 18 Sep 2015 15:54:22 +0000 (17:54 +0200)] 
Remove references to () from types of mkWeak# and friends

Previously the types needlessly used (), which is defined ghc-prim,
leading to unfortunate import cycles. See #10867 for details.

Updates stm submodule.

4 years agotestsuite: attempt fixing fallout from 089b72f52
Austin Seipp [Wed, 23 Sep 2015 08:35:05 +0000 (03:35 -0500)] 
testsuite: attempt fixing fallout from 089b72f52

A few tests had the same name which is a big no-no, so I reorganized them a
little. The naming is somewhat haphazard, though...

Signed-off-by: Austin Seipp <>
4 years agoHscMain: Place CPP macro invocation on one line
Ben Gamari [Tue, 22 Sep 2015 12:14:32 +0000 (14:14 +0200)] 
HscMain: Place CPP macro invocation on one line

Clang's CPP implementation seems to barf otherwise

4 years agoDeriveLift extension (#1830)
RyanGlScott [Tue, 22 Sep 2015 02:50:55 +0000 (21:50 -0500)] 
DeriveLift extension (#1830)

This implements -XDeriveLift, which allows for automatic derivation
of the Lift class from template-haskell. The implementation is based
off of Ian Lynagh's th-lift library

Test Plan: ./validate

Reviewers: hvr, simonpj, bgamari, goldfire, austin

Reviewed By: goldfire, austin

Subscribers: osa1, thomie

Differential Revision:

GHC Trac Issues: #1830

4 years agoMake derived names deterministic
Bartosz Nitka [Tue, 22 Sep 2015 00:30:41 +0000 (19:30 -0500)] 
Make derived names deterministic

The names of auxiliary bindings end up in the interface file, and since uniques
are nondeterministic, we end up with nondeterministic interface files.

This uses the package and module name in the generated name, so I believe it
should avoid problems from #7947 and be deterministic as well.

The generated names look like this now:


and with `-ppr-debug`:


Reviewed By: simonmar, austin, ezyang

Differential Revision:

GHC Trac Issues: #4012

4 years agobase: use Show for ErrorCall in uncaughtExceptionHandler
Eric Seidel [Tue, 22 Sep 2015 00:18:56 +0000 (19:18 -0500)] 
base: use Show for ErrorCall in uncaughtExceptionHandler

The default top-level exception handler now uses the `Show` instance for
`ErrorCall` when printing exceptions, so it will actually print the out-of-band
data (e.g. `CallStack`s) in compiled binaries, instead of just printing the
error message.

This also updates the hpc submodule to fix the test output.

Reviewed By: austin, thomie

Differential Revision:

4 years agoRemove (now bogus) assert.
Edward Z. Yang [Mon, 21 Sep 2015 22:46:09 +0000 (15:46 -0700)] 
Remove (now bogus) assert.

Signed-off-by: Edward Z. Yang <>
4 years agoTcDeriv: Use a NameEnv instead of association list
Ben Gamari [Mon, 21 Sep 2015 21:52:23 +0000 (16:52 -0500)] 
TcDeriv: Use a NameEnv instead of association list

It's unlikely that these lists would have become very large but
nevertheless this is an easy and worthwhile change.

Reviewed By: austin

Differential Revision:

4 years agoRemove graphFromVerticesAndAdjacency
Bartosz Nitka [Mon, 21 Sep 2015 21:52:10 +0000 (16:52 -0500)] 
Remove graphFromVerticesAndAdjacency

It's not used anywhere.

Reviewed By: austin

Differential Revision:

4 years agoFix build failure, I think.
Edward Z. Yang [Mon, 21 Sep 2015 20:20:07 +0000 (13:20 -0700)] 
Fix build failure, I think.

Signed-off-by: Edward Z. Yang <>
4 years agoUnify hsig and hs-boot; add preliminary "hs-boot" merging.
Edward Z. Yang [Fri, 24 Jul 2015 22:13:49 +0000 (15:13 -0700)] 
Unify hsig and hs-boot; add preliminary "hs-boot" merging.

This patch drops the file level distinction between hs-boot and hsig;
we figure out which one we are compiling based on whether or not there
is a corresponding hs file lying around.

To make the "import A" syntax continue to work for bare hs-boot
files, we also introduce hs-boot merging, which takes an A.hi-boot
and converts it to an A.hi when there is no A.hs file in scope.
This will be generalized in Backpack to merge multiple A.hi files together;
which means we can jettison the "load multiple interface files" functionality.

This works automatically for --make, but for one-shot compilation
we need a new mode: ghc --merge-requirements A will generate an A.hi/A.o
from a local A.hi-boot file; Backpack will extend this mechanism further.

Has Haddock submodule update to deal with change in msHsFilePath behavior.

    - This commit drops support for the hsig extension. Can
      we support it?  It's annoying because the finder code is
      written with the assumption that where there's an hs-boot
      file, there's always an hs file too.  To support hsig, you'd
      have to probe two locations.  Easier to just not support it.

    - #10333 affects us, modifying an hs-boot still doesn't trigger

    - See compiler/main/Finder.hs: this diff is very skeevy, but
      it seems to work.

    - This code cunningly doesn't drop hs-boot files from the
      "drop hs-boot files" module graph, if they don't have a
      corresponding hs file.  I have no idea if this actually is useful.

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

Reviewers: simonpj, austin, bgamari, spinda

Subscribers: thomie

Differential Revision:

4 years agoRevert "Revert "Revert "Change loadSrcInterface to return a list of ModIface"""
Edward Z. Yang [Sat, 12 Sep 2015 00:15:52 +0000 (17:15 -0700)] 
Revert "Revert "Revert "Change loadSrcInterface to return a list of ModIface"""

This reverts commit 0c6c015d42c2bd0ee008f790c7c0cb4c5b78ca6b.

4 years agoRevert "Revert "Revert "Support for multiple signature files in scope."""
Edward Z. Yang [Sat, 12 Sep 2015 00:13:30 +0000 (17:13 -0700)] 
Revert "Revert "Revert "Support for multiple signature files in scope."""

This reverts commit 214596de224afa576a9c295bcf53c6941d6892e0.

4 years ago`_ <- mapM` --> `mapM_`
Richard Eisenberg [Mon, 21 Sep 2015 16:25:37 +0000 (12:25 -0400)] 
`_ <- mapM` --> `mapM_`

Thanks for the suggestion, Austin. Just missed that while making
a bunch of similar changes.

4 years agoRefactor BranchLists.
Richard Eisenberg [Sun, 20 Sep 2015 03:59:22 +0000 (23:59 -0400)] 
Refactor BranchLists.

Now we use Array to store branches. This makes sense because we often
have to do random access (once inference is done). This also vastly
simplifies the awkward BranchList type.

This fixes #10837 and updates submodule utils/haddock.

4 years agoRun simplifier only when the env is clean.
Richard Eisenberg [Sun, 20 Sep 2015 20:15:13 +0000 (16:15 -0400)] 
Run simplifier only when the env is clean.

This fixes #10896. In the indexed-types/should_fail/BadSock test,
there is a bad type definition. This gets type-checked, an error
gets reported, but then **GHC keeps going**. Later, when
running the simplifier to do an ambiguity check, the bad type
environment causes GHC to fall over. My solution: only run the
simplifier in a clean, error-free type environment.

A downside of this is that fewer error messages are reported.
This makes me a bit sad, but I'm not sure how to avoid the problem.
Suggestions welcome.

4 years agoPerform a validity check on assoc type defaults.
Richard Eisenberg [Sat, 19 Sep 2015 18:32:44 +0000 (14:32 -0400)] 
Perform a validity check on assoc type defaults.

This fixes #10817 and #10899. A knock-on effect is that we must
now remember locations of associated type defaults for error
messages during validity checking. This isn't too bad, but it
increases the size of the diff somewhat.

Test cases: indexed-types/should_fail/T108{17,99}

4 years agoSlightly better `Coercible` errors.
Richard Eisenberg [Sun, 20 Sep 2015 21:39:17 +0000 (17:39 -0400)] 
Slightly better `Coercible` errors.

This makes two real changes:
 - Equalities like (a ~R [a]) really *are* insoluble. Previously,
   GHC refused to give up when an occurs check bit on a representational
   equality. But for datatypes, it really should bail.

 - Now, GHC will sometimes report an occurs check error (in cases above)
   for representational equalities. Previously, it never did.

This "fixes" #10715, where by "fix", I mean clarifies the error message.
It's unclear how to do more to fix that ticket.

Test cases: typecheck/should_fail/T10715{,b}

4 years agoFix typo in test for #10347.
Richard Eisenberg [Mon, 21 Sep 2015 13:40:02 +0000 (09:40 -0400)] 
Fix typo in test for #10347.

Thanks to Gabor Greif for spotting the mistake.

4 years agoSmall improvement in pretty-printing constructors.
Richard Eisenberg [Sun, 20 Sep 2015 20:03:07 +0000 (16:03 -0400)] 
Small improvement in pretty-printing constructors.

This fixes #10810 by cleaning up pretty-printing of constructor
declarations. This change also removes a (in my opinion) deeply
bogus orphan instance OutputableBndr [Located name], making
HsDecls now a non-orphan module. Yay all around.

Test case: th/T10810

4 years agoRe-polish error messages around injective TFs.
Richard Eisenberg [Sun, 20 Sep 2015 19:28:55 +0000 (15:28 -0400)] 
Re-polish error messages around injective TFs.

The previous message was wrong, as pointed out by Jan Stolarek.

4 years agoClarify parsing infelicity.
Richard Eisenberg [Sat, 19 Sep 2015 20:44:29 +0000 (16:44 -0400)] 
Clarify parsing infelicity.

This fixes #10855.

4 years agoAllow TH quoting of assoc type defaults.
Richard Eisenberg [Sat, 19 Sep 2015 19:43:15 +0000 (15:43 -0400)] 
Allow TH quoting of assoc type defaults.

This fixes #10811.

4 years agoPrint associated types a bit better.
Richard Eisenberg [Sat, 19 Sep 2015 19:18:40 +0000 (15:18 -0400)] 
Print associated types a bit better.

This is part of #10811. It removes the "family" keyword from
associated type family declarations, and it adds the "type"
keyword to associated type family defaults.

4 years agoTest #10770
Richard Eisenberg [Sat, 19 Sep 2015 19:04:49 +0000 (15:04 -0400)] 
Test #10770

4 years agoUpdate user guide, fixing #10772
Richard Eisenberg [Sat, 19 Sep 2015 18:45:28 +0000 (14:45 -0400)] 
Update user guide, fixing #10772

4 years agoTest #10347
Richard Eisenberg [Sat, 19 Sep 2015 18:37:54 +0000 (14:37 -0400)] 
Test #10347

4 years agoDriver: --make -o without Main should be an error (#10895)
Thomas Miedema [Sat, 19 Sep 2015 14:14:47 +0000 (16:14 +0200)] 
Driver: --make -o without Main should be an error (#10895)

Reviewed by: austin

Differential Revision:

4 years agoPut stable pointer names in the name cache.
Edward Z. Yang [Sun, 20 Sep 2015 10:19:17 +0000 (12:19 +0200)] 
Put stable pointer names in the name cache.

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Reviewed By: austin, bgamari

Subscribers: thomie

Differential Revision:

4 years agoReplace [PostTc id Type] with PostTc id [Type]
Matthew Pickering [Sun, 20 Sep 2015 10:18:21 +0000 (12:18 +0200)] 
Replace [PostTc id Type] with PostTc id [Type]

This gives a clearer indication as to what gets filled in
when. It was suggested by Richard on D1152.

Test Plan: ./validate

Reviewers: austin, goldfire, bgamari

Reviewed By: goldfire, bgamari

Subscribers: thomie

Differential Revision:

4 years agoAlways run explicitly requested ways (extra_ways) for fast runs.
Edward Z. Yang [Sun, 20 Sep 2015 10:16:50 +0000 (12:16 +0200)] 
Always run explicitly requested ways (extra_ways) for fast runs.

To keep validates fast, we only one run one way.  But I think that
it's important for some tests to run them a few ways, just to
make sure functionality, e.g. the profiler, is working.  This commit
changes the logic so that any way specified in extra_ways is always
run for fast.  The big changes is now profiling tests are run on

I also made it so the G1 garbage collector tests only run on slow.

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

Reviewers: austin, thomie, bgamari

Reviewed By: austin, thomie, bgamari

Subscribers: thomie

Differential Revision:

4 years agoPolish some error messages.
Richard Eisenberg [Sat, 19 Sep 2015 13:56:03 +0000 (09:56 -0400)] 
Polish some error messages.

4 years agoFix #10815 by kind-checking type patterns against known kinds.
Richard Eisenberg [Mon, 31 Aug 2015 17:46:01 +0000 (10:46 -0700)] 
Fix #10815 by kind-checking type patterns against known kinds.

tcFamTyPats now must take information about the instantiation of any
class variables, when checking the instance of an associated type.

Getting this to work out required some unexpected refactoring in
TcDeriv. TcDeriv needs to look at class instances because of the
possibility of associated datatypes with `deriving` specs. TcDeriv
worked over the user-specified instances. But any data family instances
were already processed, and TcDeriv had no way of finding the rep
tycons. Indeed, TcDeriv *re-type-checked* any data family instances
in an attempt to rediscover what GHC already knew. So, this commit
introduces better tracking of compiled data families between TcInstDcls
and TcDeriv to streamline all of this.

4 years agoPass TEST_HC_OPTS in bug1465 and T5792.
Edward Z. Yang [Fri, 18 Sep 2015 02:52:01 +0000 (19:52 -0700)] 
Pass TEST_HC_OPTS in bug1465 and T5792.

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

Reviewers: austin, bgamari

Subscribers: thomie

Differential Revision:

4 years agoDocs: make sure all libs are included in index.html (#10879)
Thomas Miedema [Tue, 15 Sep 2015 19:37:38 +0000 (21:37 +0200)] 
Docs: make sure all libs are included in index.html (#10879)

During the build, when HADDOCK_DOCS=YES, the command 'cd libraries && sh
gen_contents_index --intree' is run, which calls haddock to generate the
haddock index at 'libraries/dist-haddock/index.html'.

What it did before was check the ./packages file for all libraries. The
problem is that 'base' and 'ghc-prim' were folded into the main repo
some time ago, hence don't have an entry in the ./packages file anymore.
As a result, 'base' and 'ghc-prim' were missing from the index.html

It now simply runs haddock on all the all the `.haddock` files in the
libraries directory.

The only risk is that this could include the extra libraries in the
index.html, if you ever built them in the past (with
BUILD_EXTRA_PKGS=YES), even though now you want to exclude them (with
BUILD_EXTRA_PKGS=NO). gen_contents_index doesn't have access to build
system variables though (PACKAGES_STAGE1+PACKAGES_STAGE2), so fixing
this would be a little bit fiddly.

Test Plan:
'make libraries/dist-haddock/index.html && grep -q base
libraries/dist-haddock/index.html && echo ok'

Reviewed by: austin

Differential Revision:

4 years agoAdd namePackage function to template-haskell
RyanGlScott [Thu, 17 Sep 2015 21:15:26 +0000 (23:15 +0200)] 
Add namePackage function to template-haskell

Currently there exists a nameBase function (for retrieving a Name's OccName)
and a nameModule function (for retrieving a Name's ModName), but there is no
counterpart for PkgNames.

This would be useful for implementing Template Haskell features which need
to have easy access to a Name's package (e.g., automatically derived Lift

Reviewed By: goldfire, austin, thomie

Differential Revision:

4 years agoApplicativeDo transformation
Simon Marlow [Fri, 13 Mar 2015 16:39:58 +0000 (16:39 +0000)] 
ApplicativeDo transformation

This is an implementation of the ApplicativeDo proposal.  See the Note
[ApplicativeDo] in RnExpr for details on the current implementation,
and the wiki page
for design notes.

Test Plan: validate

Reviewers: simonpj, goldfire, austin

Subscribers: thomie

Differential Revision:

4 years agoShow minimal complete definitions in ghci (#10847)
Moritz Kiefer [Thu, 17 Sep 2015 14:02:06 +0000 (16:02 +0200)] 
Show minimal complete definitions in ghci (#10847)

Show the minimal complete definition on :info in ghci. They
are shown like MINIMAL pragmas in code. If the minimal complete
definition is empty or only a specific method from a class is
requested, nothing is shown.

Reviewed By: simonpj, austin, thomie

Differential Revision:

4 years agoTestsuite: add test for #10781
Thomas Miedema [Thu, 17 Sep 2015 01:25:11 +0000 (03:25 +0200)] 
Testsuite: add test for #10781

4 years agoDynFlags: remove unused sPgm_sysman (#8689)
Thomas Miedema [Wed, 16 Sep 2015 09:01:37 +0000 (11:01 +0200)] 
DynFlags: remove unused sPgm_sysman (#8689)

Something about a long deleted 'system manager' for the 'parallel

Also remove confusing comment in SysTools, that supposedly referred to
sPgm_sysman. See commit 16d5d1c75c999677783c9c1bda519540fa9a6e58.

4 years agoFix `hp2ps -i-`
Thomas Miedema [Tue, 15 Sep 2015 21:20:10 +0000 (23:20 +0200)] 
Fix `hp2ps -i-`

From the help text:
  -i[+|-] sort by identifier string (-i+ gives greatest on top)

Found by David Binderman.

4 years agoPretty: fix unicode arrow operators.
Sebastian Reuße [Tue, 15 Sep 2015 12:20:01 +0000 (14:20 +0200)] 
Pretty: fix unicode arrow operators.

As per issue #10509, the documentation gave the wrong glyphs for Unicode
alternatives to the -< and >- arrow operators (the codepoints were
correct, but the glyphs were not). The incorrect glyphs have also
made it into the error output. This replaces those characters with the
correct versions.

GHC Trac Issues: #10883

4 years agoAccount for stack allocation in the thread's allocation counter
Simon Marlow [Mon, 14 Sep 2015 12:37:38 +0000 (13:37 +0100)] 
Account for stack allocation in the thread's allocation counter

Summary: (see comment for details)

Test Plan: validate

Reviewers: bgamari, ezyang, austin

Subscribers: thomie

Differential Revision:

4 years agoTestsuite: mark T6037 expect_fail on Windows (#6037)
Thomas Miedema [Sat, 12 Sep 2015 21:34:12 +0000 (23:34 +0200)] 
Testsuite: mark T6037 expect_fail on Windows (#6037)

4 years agohpc: use `takeDirectory` instead of `dropWhileEnd (/= '/')`
Thomas Miedema [Sat, 12 Sep 2015 20:41:35 +0000 (22:41 +0200)] 
hpc: use `takeDirectory` instead of `dropWhileEnd (/= '/')`

This fixes some hpc tests on Windows. Update submodule hpc.

4 years agoCodeGen: fix typo in error message
Thomas Miedema [Sat, 12 Sep 2015 18:37:20 +0000 (20:37 +0200)] 
CodeGen: fix typo in error message

4 years agoTestsuite: mark enum01-enum03 expect_broken(#9399) on Windows
Thomas Miedema [Sat, 12 Sep 2015 17:34:16 +0000 (19:34 +0200)] 
Testsuite: mark enum01-enum03 expect_broken(#9399) on Windows

4 years agoTestsuite: normalise slashes in callstack output
Thomas Miedema [Sat, 12 Sep 2015 13:23:12 +0000 (15:23 +0200)] 
Testsuite: normalise slashes in callstack output

This fixes some tests on Windows, for example T2120.

4 years agos/StgArrWords/StgArrBytes/
Siddhanathan Shanmugam [Fri, 11 Sep 2015 21:10:41 +0000 (16:10 -0500)] 

Rename StgArrWords to StgArrBytes (see Trac #8552)

Reviewed By: austin

Differential Revision:

GHC Trac Issues: #8552

4 years agoCode movement
Jan Stolarek [Fri, 11 Sep 2015 22:07:17 +0000 (00:07 +0200)] 
Code movement

4 years agoDead code removal, export cleanup
Jan Stolarek [Fri, 11 Sep 2015 21:55:52 +0000 (23:55 +0200)] 
Dead code removal, export cleanup

4 years agoRemove redundant language extensions
Jan Stolarek [Fri, 11 Sep 2015 21:44:42 +0000 (23:44 +0200)] 
Remove redundant language extensions

4 years agoAdd assertions
Jan Stolarek [Fri, 11 Sep 2015 20:29:02 +0000 (22:29 +0200)] 
Add assertions

4 years agoTestsuite cleanup
Jan Stolarek [Fri, 11 Sep 2015 20:02:35 +0000 (22:02 +0200)] 
Testsuite cleanup

As a result of fixing #10836 it is now possible to merge 11 different
tests for #6018 into one

4 years agoImprove documentation of comprehensions
Simon Peyton Jones [Fri, 11 Sep 2015 16:02:58 +0000 (17:02 +0100)] 
Improve documentation of comprehensions

Suggestion from Jeremy Gibbons

4 years agoFix broken links in documentation
Simon Peyton Jones [Fri, 11 Sep 2015 16:01:33 +0000 (17:01 +0100)] 
Fix broken links in documentation

4 years agoImprove documentation for transform list-comps
Simon Peyton Jones [Fri, 11 Sep 2015 15:23:35 +0000 (16:23 +0100)] 
Improve documentation for transform list-comps

Thanks to Jeremy Gibbons for spotting the infelictity

4 years agoA CFunEqCan can be Derived
Simon Peyton Jones [Fri, 11 Sep 2015 15:23:06 +0000 (16:23 +0100)] 
A CFunEqCan can be Derived

This fixes the ASSERTION failures in
when GHC is compiled with -DDEBUG

See Phab:D202 attached to Trac #6018

4 years agoAdd a test for Trac #10806
Simon Peyton Jones [Fri, 11 Sep 2015 14:55:29 +0000 (15:55 +0100)] 
Add a test for Trac #10806

4 years agoImprove rejigConRes (again)
Simon Peyton Jones [Fri, 11 Sep 2015 14:54:39 +0000 (15:54 +0100)] 
Improve rejigConRes (again)

I think this patch finally works around the delicacy in the strictness
of TcTyClsDecls.rejigConRes.   See the notes with that function and
Note [Checking GADT return types].

As a result, we fix Trac #10836, and improve Trac #7175

4 years agoComments on oneShot
Simon Peyton Jones [Thu, 27 Aug 2015 15:23:46 +0000 (16:23 +0100)] 
Comments on oneShot

4 years agoDon't check in autogenerated hs files for recomp013.
Edward Z. Yang [Thu, 10 Sep 2015 05:02:48 +0000 (22:02 -0700)] 
Don't check in autogenerated hs files for recomp013.

Signed-off-by: Edward Z. Yang <>
4 years agoTestsuite: comment out `setnumcapabilities001` (#10860)
Thomas Miedema [Wed, 9 Sep 2015 11:56:53 +0000 (13:56 +0200)] 
Testsuite: comment out `setnumcapabilities001` (#10860)

Don't mark it expect_broken, because it fails only sometimes.

4 years agoForbid annotations when Safe Haskell safe mode is enabled.
David Kraeutmann [Tue, 8 Sep 2015 16:35:33 +0000 (11:35 -0500)] 
Forbid annotations when Safe Haskell safe mode is enabled.

For now, this fails compliation immediately with an error. If desired, this
can be a warning that annotations in Safe Haskell are ignored.

Signed-off-by: David Kraeutmann <>
Reviewed By: goldfire, austin

Differential Revision:

GHC Trac Issues: #10826

4 years agoHeapStackCheck: Small refactoring
Ben Gamari [Tue, 8 Sep 2015 16:30:43 +0000 (11:30 -0500)] 
HeapStackCheck: Small refactoring

Use modern Cmm argument syntax in stg_block_blackhole definition.

Reviewed By: simonmar, austin

Differential Revision:

4 years agoBuild system: check for inconsistent settings (#10157)
Thomas Miedema [Tue, 8 Sep 2015 11:51:44 +0000 (13:51 +0200)] 
Build system: check for inconsistent settings (#10157)

`configure` currently detects when the docbook and hscolour tools aren't
available, and instead of failing outright (as it does for missing alex
and happy), sets some variables in mk/ to tell `make` not to
build the documentation.

Sometimes, however, you want to really make sure all documentation gets
built, fully colourized. For example when making a release. To do so,
you can override the mentioned variables from mk/ in
mk/ (e.g. set HSCOLOUR_SRCS=YES).

This patch adds some error checking to make sure that doing so will not
result in weird build failures when those tools are still missing.

Test Plan: ran `make` a couple of times, with different mk/ settings.

Reviewed by: austin

Differential Revision:

4 years agoMove GeneralCategory et al to GHC.Unicode
Ben Gamari [Tue, 8 Sep 2015 13:38:40 +0000 (08:38 -0500)] 
Move GeneralCategory et al to GHC.Unicode

This allows these to be used from Text.Read.Lex import cycles.

Reviewed By: thomie, austin

Differential Revision:

GHC Trac Issues: #10444