ghc.git
2 years agotestsuite: Allow join007 to pass on 32-bit machines
Ben Gamari [Fri, 24 Mar 2017 16:27:35 +0000 (12:27 -0400)] 
testsuite: Allow join007 to pass on 32-bit machines

The output of the test overflows. Given that the result is stable
regardless of whether it overflows, I just made the expected output
word-size dependent.

2 years agorts: Fix stat output on 32-bit platforms
Ben Gamari [Fri, 24 Mar 2017 18:59:14 +0000 (14:59 -0400)] 
rts: Fix stat output on 32-bit platforms

The formatting strings fell out of sync with the arguments.

2 years agoEliminate word-size dependence in HsDumpAst output
Ben Gamari [Fri, 24 Mar 2017 16:05:23 +0000 (12:05 -0400)] 
Eliminate word-size dependence in HsDumpAst output

Fixes DumpTypecheckedAst output on 32-bit platforms.

2 years agotestsuite: Make T10245 pass on 32-bit platforms
Ben Gamari [Fri, 24 Mar 2017 15:36:31 +0000 (11:36 -0400)] 
testsuite: Make T10245 pass on 32-bit platforms

2 years agolinker: fix OpenBSD build failure, EM_PPC64 is not defined there
Sergei Trofimovich [Sun, 26 Mar 2017 14:40:40 +0000 (15:40 +0100)] 
linker: fix OpenBSD build failure, EM_PPC64 is not defined there

Adam Steen reported build failure on OpenBSD:
  rts/linker/Elf.c:402:0: error:
    error: 'EM_PPC64' undeclared (first use in this function)
      case EM_PPC64: IF_DEBUG(linker,debugBelch( "powerpc64" ));

OpenBSD-6.0 does not define EM_PPC64:
  /usr/include/sys/exec_elf.h:#define EM_PPC 20 /* PowerPC */

Reported-by: Adam Steen <adam@adamsteen.com.au>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agotestsuite: Add testcase for #13429
Ben Gamari [Fri, 24 Mar 2017 03:03:54 +0000 (23:03 -0400)] 
testsuite: Add testcase for #13429

2 years agotestsuite: Add failing testcase for #13233
Ben Gamari [Fri, 24 Mar 2017 02:53:29 +0000 (22:53 -0400)] 
testsuite: Add failing testcase for #13233

Thanks to Ryan Scott for the example.

2 years agoDocument hithertoo undocumented HPCTIXFILE option.
Edward Z. Yang [Fri, 24 Mar 2017 01:03:40 +0000 (21:03 -0400)] 
Document hithertoo undocumented HPCTIXFILE option.

Test Plan: none

Reviewers: bgamari, austin, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: dfeuer, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3357

2 years agox86 nativeGen: Fix test with mask in range [128,255] (#13425)
Reid Barton [Fri, 24 Mar 2017 01:02:29 +0000 (21:02 -0400)] 
x86 nativeGen: Fix test with mask in range [128,255] (#13425)

My commit bdb0c43c7 optimized the encoding of instructions to test
tag bits, but it did not always set exactly the same condition codes
since the testb instruction does a single-byte comparison, rather
than a full-word comparison.

It would be correct to optimize the expression `x .&. 128 > 0` to
the sequence

    testb $128, %al
    seta %al         ; note: 'a' for unsigned comparison,
                     ; not 'g' for signed comparison

but the pretty-printer is not the right place to make this kind of
context-sensitive optimization.

Test Plan: harbormaster

Reviewers: trofi, austin, bgamari, dfeuer

Reviewed By: trofi, dfeuer

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3359

2 years agoCmm: remove a few unused type aliases
Michal Terepeta [Fri, 24 Mar 2017 01:00:24 +0000 (21:00 -0400)] 
Cmm: remove a few unused type aliases

Test Plan: ./validate

Reviewers: austin, bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3372

2 years agoImprove tracing in OccurAnal
Matthew Pickering [Fri, 24 Mar 2017 01:00:08 +0000 (21:00 -0400)] 
Improve tracing in OccurAnal

One commented out tracing function didn't type check and also show the
scores of loop breaker nodes.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3371

2 years agoTypos in comments (notes too) [ci skip]
Gabor Greif [Fri, 24 Mar 2017 10:21:52 +0000 (11:21 +0100)] 
Typos in comments (notes too) [ci skip]

2 years agoghci/Linker.hs: Fix a typo in error message
Ömer Sinan Ağacan [Fri, 24 Mar 2017 06:10:00 +0000 (09:10 +0300)] 
ghci/Linker.hs: Fix a typo in error message

2 years agoconfig.mk.in: Add bzip, gzip, and xz executable names to be overridden
Ben Gamari [Fri, 24 Mar 2017 00:59:21 +0000 (20:59 -0400)] 
config.mk.in: Add bzip, gzip, and xz executable names to be overridden

Reviewers: austin, hvr, erikd

Reviewed By: erikd

Subscribers: rwbarton, thomie, erikd, snowleopard

Differential Revision: https://phabricator.haskell.org/D3367

2 years agoAllow colors to be customized
Phil Ruffwind [Fri, 24 Mar 2017 00:59:01 +0000 (20:59 -0400)] 
Allow colors to be customized

Allow customization of diagnostic colors through the GHC_COLORS
environment variable.  Some color-related code have been refactored to
PprColour to reduce the circular dependence between DynFlags,
Outputable, ErrUtils.  Some color functions that were part of Outputable
but were never used have been deleted.

Test Plan: validate

Reviewers: austin, hvr, bgamari, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: dfeuer, rwbarton, thomie, snowleopard

Differential Revision: https://phabricator.haskell.org/D3364

2 years agoBump haddock submodule
Ben Gamari [Fri, 24 Mar 2017 00:41:34 +0000 (20:41 -0400)] 
Bump haddock submodule

2 years agoMake unsafeInterleaveST less unsafe
David Feuer [Wed, 22 Mar 2017 21:25:03 +0000 (17:25 -0400)] 
Make unsafeInterleaveST less unsafe

* Make `unsafeInterleaveST` use `noDuplicate#` like
`unsafeInterleaveIO` does to prevent the suspended action from
being run in two threads.

* In order to accomplish this without `unsafeCoerce#`, generalize
the type of `noDuplicate#`.

* Add `unsafeDupableInterleaveST` to get the old behavior.

* Document unsafe `ST` functions and clean up some related
documentation.

Fixes #13457

Reviewers: austin, hvr, bgamari, ekmett

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3370

2 years agoHaddock submodule update.
Edward Z. Yang [Wed, 22 Mar 2017 21:14:45 +0000 (14:14 -0700)] 
Haddock submodule update.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agotestsuite: Bump performance test allocations
Ben Gamari [Wed, 22 Mar 2017 00:21:13 +0000 (20:21 -0400)] 
testsuite: Bump performance test allocations

It's unclear what bumped these, but Simon had noticed that they are marginal.
Happily, all are improvements.

2 years agoBump unix submodule
Ben Gamari [Tue, 21 Mar 2017 14:07:44 +0000 (10:07 -0400)] 
Bump unix submodule

2 years agoLet GHC know MutVar# ops can't fail
David Feuer [Tue, 21 Mar 2017 04:12:07 +0000 (00:12 -0400)] 
Let GHC know MutVar# ops can't fail

The only way `readMutVar#` or `writeMutVar#` can fail is if its
argument is not a valid pointer. I believe we ensure this by
construction, and never test for pointer validity. So I think it
should be safe to say that it can't fail.

Fixes #13424

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3340

2 years agoCorrectly account for -package-db ordering when picking packages.
Edward Z. Yang [Sun, 19 Mar 2017 23:07:49 +0000 (16:07 -0700)] 
Correctly account for -package-db ordering when picking packages.

Summary:
When I originally implemented ABI-based shadowing as per
ee4e1654c31b9c6f6ad9b19ece25f040bbbcbd72, I switched our strategy
from pasting together lists to creating a map of all units first,
and then selecting packages from this.  However, what I did
not realize when doing this was that we actually depended
on the *ordering* of these lists later, when we selected
a preferred package to use.

The crux is if I have -package-db db1 -package-db db2 -package p-0.1,
and p-0.1 is provided by both db1 and db2, which one does the
-package flag select?  Previously, this was undetermined; now
we always select the instance from the LATEST package database.
(If p-0.1 shows up multiple times in the same database, once again
the chosen package is undefined.)

The reason why cabal08 intermittently failed was that, in practice,
we were sorting on the UnitId, so when we bumped version numbers,
that often wibbled the UnitIds so that they compared oppositely.
I've extended the test so that we check that the relation is
antisymmetric.

Fixes #13313

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3369

2 years agoDocument the perplexing reversed nature of extraPkgConfs and friends.
Edward Z. Yang [Sun, 19 Mar 2017 23:06:55 +0000 (16:06 -0700)] 
Document the perplexing reversed nature of extraPkgConfs and friends.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoUniqMap implementation.
Edward Z. Yang [Sun, 19 Mar 2017 22:24:01 +0000 (15:24 -0700)] 
UniqMap implementation.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoFix Windows x86 build
Tamar Christina [Sat, 18 Mar 2017 15:19:01 +0000 (15:19 +0000)] 
Fix Windows x86 build

Summary:
Fix some `-Werror` failures and work around a
bug in the `x86` version of `mingw-w64-crt`'s libraries.

The bump in the `win32` submodule is required for this.

Test Plan: ./validate

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3362

2 years agomkUserGuidePart: Remove duplicate -XDeriveGeneric entry
Ömer Sinan Ağacan [Mon, 20 Mar 2017 05:49:36 +0000 (08:49 +0300)] 
mkUserGuidePart: Remove duplicate -XDeriveGeneric entry

2 years agousers-guide: Document TemplateHaskell availability
Ben Gamari [Sun, 19 Mar 2017 15:26:08 +0000 (11:26 -0400)] 
users-guide: Document TemplateHaskell availability

2 years agogenSym: Fix DEBUG build
Ben Gamari [Sat, 18 Mar 2017 18:45:35 +0000 (14:45 -0400)] 
genSym: Fix DEBUG build

It looks like this was likely a cut-and-paste error.

2 years agoUpdate link to paper about demand analyser in user guide
Matthew Pickering [Fri, 17 Mar 2017 00:28:26 +0000 (20:28 -0400)] 
Update link to paper about demand analyser in user guide

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3354

2 years agoOccurAnal.hs: Add an assert for an invariant
Ömer Sinan Ağacan [Sun, 19 Mar 2017 05:28:37 +0000 (08:28 +0300)] 
OccurAnal.hs: Add an assert for an invariant

Reviewers: austin, bgamari, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3360

2 years agoOccurAnal.hs: Fix "Adjusting for lambdas" note name
Ömer Sinan Ağacan [Sat, 18 Mar 2017 06:56:37 +0000 (09:56 +0300)] 
OccurAnal.hs: Fix "Adjusting for lambdas" note name

2 years agoRevert "GHC_STAGE1 isn't defined, use other form."
Edward Z. Yang [Sat, 18 Mar 2017 02:33:53 +0000 (19:33 -0700)] 
Revert "GHC_STAGE1 isn't defined, use other form."

This reverts commit 138434fbef32ec86733747bdbc57f6da73cad500.

2 years agoNo join-point from an INLINE function with wrong arity
Simon Peyton Jones [Fri, 17 Mar 2017 16:25:41 +0000 (16:25 +0000)] 
No join-point from an INLINE function with wrong arity

The main payload of this patch is NOT to make a join-point
from a function with an INLINE pragma and the wrong arity;
see Note [Join points and INLINE pragmas] in CoreOpt.
This is what caused Trac #13413.

But we must do the exact same thing in simpleOptExpr,
which drove me to the following refactoring:

* Move simpleOptExpr and simpleOptPgm from CoreSubst to a new
  module CoreOpt along with a few others (exprIsConApp_maybe,
  pushCoArg, etc)

  This eliminates a module loop altogether (delete
  CoreArity.hs-boot), and stops CoreSubst getting too huge.

* Rename Simplify.matchOrConvertToJoinPoint
     to joinPointBinding_maybe
  Move it to the new CoreOpt
  Use it in simpleOptExpr as well as in Simplify

* Define CoreArity.joinRhsArity and use it

2 years agoImprove Lint a little
Simon Peyton Jones [Fri, 17 Mar 2017 08:54:39 +0000 (08:54 +0000)] 
Improve Lint a little

Better location info if the error is in an unfolding

2 years agoTest #13435 in typecheck/should_run/T13435
Richard Eisenberg [Fri, 17 Mar 2017 15:22:19 +0000 (11:22 -0400)] 
Test #13435 in typecheck/should_run/T13435

2 years agoRemove solveSomeEqualities
Richard Eisenberg [Thu, 16 Mar 2017 19:56:37 +0000 (15:56 -0400)] 
Remove solveSomeEqualities

I had thought that it was necessary to solve kind-level equalities
before validity-checking a type, but I was wrong. This patch simply
deletes code. Hooray!

2 years agoFix #13343 by not defaulting SigTvs
Richard Eisenberg [Thu, 16 Mar 2017 15:59:45 +0000 (11:59 -0400)] 
Fix #13343 by not defaulting SigTvs

test case: typecheck/should_compile/T13343

2 years agoFix #13202 by failing more eagerly in tcRnStmt
Richard Eisenberg [Thu, 16 Mar 2017 15:38:05 +0000 (11:38 -0400)] 
Fix #13202 by failing more eagerly in tcRnStmt

test cases: ghci/scripts/T13202{,a}

2 years agoFix #12709 by not building bad applications
Richard Eisenberg [Thu, 16 Mar 2017 14:34:29 +0000 (10:34 -0400)] 
Fix #12709 by not building bad applications

In an effort to report multiple levity polymorphism errors all at
once, the desugarer does not fail when encountering bad levity
polymorphism. But we must be careful not to build the bad applications,
lest they try to satisfy the let/app invariant and call
isUnliftedType on a levity polymorphic type. This protects calls
to mkCoreAppDs appropriately.

test case: typecheck/should_fail/T12709

2 years agoComment coercion flattening [skip ci]
Richard Eisenberg [Fri, 3 Mar 2017 19:23:24 +0000 (14:23 -0500)] 
Comment coercion flattening [skip ci]

2 years agoTypos in manual and comments [ci skip]
Gabor Greif [Fri, 17 Mar 2017 09:20:42 +0000 (10:20 +0100)] 
Typos in manual and comments [ci skip]

2 years agoGHC_STAGE1 isn't defined, use other form.
Edward Z. Yang [Fri, 10 Mar 2017 22:33:39 +0000 (14:33 -0800)] 
GHC_STAGE1 isn't defined, use other form.

Summary:
I don't really know why this stopped working for me, but it
did on a recent clean.  I don't know if this is right but
it solved the problem for me.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3318

2 years agoSave renamed syntax when signature merging.
Edward Z. Yang [Mon, 13 Mar 2017 09:22:06 +0000 (02:22 -0700)] 
Save renamed syntax when signature merging.

Summary:
This is required to make Haddock work correctly.

Comes with a Haddock submodule update for better rendering.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3335

2 years agoGHC.Word: Move Read instances to GHC.Read
Erik de Castro Lopo [Fri, 17 Mar 2017 06:47:33 +0000 (17:47 +1100)] 
GHC.Word: Move Read instances to GHC.Read

Test Plan: Validate

Reviewers: hvr, austin, bgamari

Reviewed By: hvr

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3353

2 years agoBump unix submodule
Ben Gamari [Thu, 16 Mar 2017 00:38:36 +0000 (20:38 -0400)] 
Bump unix submodule

2 years agoBump hsc2hs submodule
Ben Gamari [Wed, 15 Mar 2017 21:52:47 +0000 (17:52 -0400)] 
Bump hsc2hs submodule

2 years agoBump nofib submodule
Ben Gamari [Wed, 15 Mar 2017 21:48:50 +0000 (17:48 -0400)] 
Bump nofib submodule

2 years agoDecrease locked region size on Windows to fix ERROR_LOCK_INVALID_RANGE
Andrzej Rybczak [Wed, 15 Mar 2017 18:30:48 +0000 (14:30 -0400)] 
Decrease locked region size on Windows to fix ERROR_LOCK_INVALID_RANGE

Reviewers: austin, hvr, bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3345

2 years agoBump hsc2hs submodule
Ben Gamari [Wed, 15 Mar 2017 15:55:09 +0000 (11:55 -0400)] 
Bump hsc2hs submodule

Fixes #13388. Also updates the expected output for T12504, which
previously contained a redundant LINE pragma.

2 years agoIntroduce putLogMsg
Ben Gamari [Wed, 15 Mar 2017 13:29:24 +0000 (09:29 -0400)] 
Introduce putLogMsg

This factors out the repetition of (log_action dflags dflags) and will
hopefully allow us to someday better abstract log output.

Test Plan: Validate

Reviewers: austin, hvr, goldfire

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3334

2 years agoIntroduce and use EnumSet in DynFlags
Ben Gamari [Wed, 15 Mar 2017 18:30:33 +0000 (14:30 -0400)] 
Introduce and use EnumSet in DynFlags

This factors out a repeated pattern found in DynFlags, where we use an
IntSet and Enum to represent sets of flags.

Requires bump of haddock submodule.

Test Plan: validate

Reviewers: austin, goldfire

Subscribers: rwbarton, thomie, snowleopard

Differential Revision: https://phabricator.haskell.org/D3331

2 years agoAlways build GHCi libs
Simon Marlow [Wed, 15 Mar 2017 13:28:10 +0000 (09:28 -0400)] 
Always build GHCi libs

Since the introduction of -split-sections, using GHCi with the RTS
linker is really slow:

```
$ time (echo :quit | ./inplace/bin/ghc-stage2 --interactive -fexternal-interpreter)
GHCi, version 8.1.20170304: http://www.haskell.org/ghc/  :? for help
Prelude> Leaving GHCi.

real        0m3.793s
```

(when we use `-fexternal-interpreter` it uses the RTS linker by default,
you can make it use the system linker by adding `-dynamic`)

Building the GHCi libs doesn't take much time or space in the GHC build,
but makes things much quicker for people using the RTS linker:

```
$ time (echo :quit | ./inplace/bin/ghc-stage2 --interactive -fexternal-interpreter)
GHCi, version 8.1.20170304: http://www.haskell.org/ghc/  :? for help
Prelude> Leaving GHCi.

real        0m0.285s
```

So I propose that we build and ship them unconditionally.

Test Plan: validate, perf tests above

Reviewers: bgamari, austin, niteria, erikd, Phyx

Reviewed By: bgamari

Subscribers: rwbarton, thomie, snowleopard

Differential Revision: https://phabricator.haskell.org/D3298

2 years agotestsuite: Bump margin of T4029 to 15%
Ben Gamari [Wed, 15 Mar 2017 17:34:48 +0000 (13:34 -0400)] 
testsuite: Bump margin of T4029 to 15%

This test has been fluctuating wildly recently. Moreover, it's not even clear to
me that this is a particularly useful thing to be testing.

2 years agoReimplement minusList using Set
David Feuer [Tue, 14 Mar 2017 23:53:39 +0000 (19:53 -0400)] 
Reimplement minusList using Set

`minusList ms ns` was `O(m*n)`. Now it's `O((m + n) log n)`, which
should be a bit better.

Reviewers: austin, bgamari, mpickering

Reviewed By: mpickering

Subscribers: mpickering, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3341

2 years agoShortcut a test in exprIsOk
David Feuer [Tue, 14 Mar 2017 20:43:37 +0000 (16:43 -0400)] 
Shortcut a test in exprIsOk

`exprIsOk` didn't shortcut properly when checking `case` (it used
`foldl` inappropriately). Fix that.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3343

2 years agoFix #13337.
Richard Eisenberg [Tue, 14 Mar 2017 17:32:00 +0000 (13:32 -0400)] 
Fix #13337.

The big change is the introduction of solveSomeEqualities. This
is just like solveEqualities, but it doesn't fail if there are unsolved
equalities when it's all done. Anything unsolved is re-emitted. This
is appropriate if we are not kind-generalizing, so this new form
is used when decideKindGeneralizationPlan says not to.

We initially thought that any use of solveEqualities would be tied
to kind generalization, but this isn't true. For example, we need
to solveEqualities a bunch in the "tc" pass in TcTyClsDecls (which
is really desugaring). These equalities are all surely going to be
soluble (if they weren't the "kc" pass would fail), but we still
need to solve them again. Perhaps if the "kc" pass produced type-
checked output that is then desugared, solveEqualities really would
be tied only to kind generalization.

Updates haddock submodule.

Test Plan: ./validate, typecheck/should_compile/T13337

Reviewers: simonpj, bgamari, austin

Reviewed By: simonpj

Subscribers: RyanGlScott, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3315

2 years agoFix Windows GCC driver
Tamar Christina [Tue, 14 Mar 2017 17:31:36 +0000 (13:31 -0400)] 
Fix Windows GCC driver

In Windows 10 Insiders build 15019+ which will probably be released
mainstream somewhere this year Microsoft seems to have started being
stricter with API calls.

The call to `FreeConsole` just after `CreateProcess` is making Windows
treat the process
as an interactive process. In which case it tries to use the `Desktop
session` but fails resulting
in the cryptic error reported.

I don't understand why the call to `FreeConsole` was there and it
doesn't seem to be needed,
so removed.

This fixes #13411

Test Plan: ./validate, alternative just do anything with ghc which
requires compilation.

Reviewers: austin, bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, #ghc_windows_task_force

Differential Revision: https://phabricator.haskell.org/D3319

2 years agoAllow associated types to pattern-match in non-class-bound variables
Ryan Scott [Tue, 14 Mar 2017 14:58:58 +0000 (10:58 -0400)] 
Allow associated types to pattern-match in non-class-bound variables

Summary:
After 8136a5cbfcd24647f897a2fae9fcbda0b1624035 (#11450), if you have
a class with an associated type:

```
class C a where
  type T a b
```

And you try to create an instance of `C` like this:

```
instance C Int where
  type T Int Char = Bool
```

Then it is rejected, since you're trying to instantiate the variable ``b`` with
something other than a type variable. But this restriction proves quite
onerous in practice, as it prevents you from doing things like this:

```
class C a where
  type T a (b :: Identity c) :: c

instance C Int where
  type T Int ('Identity x) = x
```

You have to resort to an auxiliary type family in order to define this now,
which becomes extremely tiring. This lifts this restriction and fixes #13398,
in which it was discovered that adding this restriction broke code in the wild.

Test Plan: ./validate

Reviewers: simonpj, bgamari, austin

Reviewed By: simonpj

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3302

2 years agoFurther document :type +v's role in analyzing -XTypeApplications in GHCi
Ryan Scott [Tue, 14 Mar 2017 14:58:41 +0000 (10:58 -0400)] 
Further document :type +v's role in analyzing -XTypeApplications in GHCi

Summary:
The section on `-XTypeApplications` in the users' guide isn't terribly
clear on how to view the visibility of a function type signature's type
variables in GHCi properly (i.e., using the `:type +v` GHCi command). This
adds some more exposition that demonstrates how to use `:type +v` (and why you
don't want to use `:type`).

Fixes #13401.

Test Plan: Eyeball it

Reviewers: bgamari, austin, goldfire, crockeea

Reviewed By: goldfire, crockeea

Subscribers: rwbarton, thomie, crockeea

Differential Revision: https://phabricator.haskell.org/D3310

2 years agotestsuite: Bump allocations for T4029
Ben Gamari [Tue, 14 Mar 2017 14:04:40 +0000 (10:04 -0400)] 
testsuite: Bump allocations for T4029

Both the OS X build machine and my local builds have been failing.
Unfortunately, our x86_64 Linux machine has been succeeding.

2 years agoIntroduce and use mkLetRec, mkLetNonRec
Ben Gamari [Mon, 13 Mar 2017 23:46:38 +0000 (19:46 -0400)] 
Introduce and use mkLetRec, mkLetNonRec

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3303

2 years agoFix CaseIdentity optimisation AGAIN
Simon Peyton Jones [Tue, 14 Mar 2017 13:52:48 +0000 (13:52 +0000)] 
Fix CaseIdentity optimisation AGAIN

In this commit
    commit 02ac2974ce8e537372bff8d9e0a6efb461ed2c59
    Author: Simon Peyton Jones <simonpj@microsoft.com>
    Date:   Wed Nov 16 10:37:47 2011 +0000

    Fix CaseIdentity optimisaion

    In fixing one bug I'd introduced another;
       case x of { T -> T; F -> F }
    wasn't getting optmised!  Trivial to fix.

I introduced yet another!  This line of code in SimplUtils.mkCase1

    check_eq (Var v)    (DataAlt con) []   = v == dataConWorkId con
                                             -- Optimisation only

is patently false when arg_tys is non-empty.  Astonishing that it
has not shown up before now.

Easily fixed though.  This was all shown up by Trac #13417, which is
now fixed.

Merge to 8.0, 8.2.

2 years agoTypos in manual and comments
Gabor Greif [Tue, 14 Mar 2017 11:38:50 +0000 (12:38 +0100)] 
Typos in manual and comments

2 years agoFix #13382: Put join ceiling underneath lambdas
Luke Maurer [Mon, 13 Mar 2017 22:49:25 +0000 (18:49 -0400)] 
Fix #13382: Put join ceiling underneath lambdas

Test Plan: No new test (bug is latent)

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3285

2 years agoBump nofib submodule
Ben Gamari [Mon, 13 Mar 2017 22:41:26 +0000 (18:41 -0400)] 
Bump nofib submodule

2 years agotestsuite: Fix peak_megabytes_allocated for T4029
Ben Gamari [Mon, 13 Mar 2017 21:03:42 +0000 (17:03 -0400)] 
testsuite: Fix peak_megabytes_allocated for T4029

It seems I must have dropped the update of the expected value during a conflict
resolution.

2 years agotestsuite: Fix use of wc in T13340
Ben Gamari [Mon, 13 Mar 2017 21:00:01 +0000 (17:00 -0400)] 
testsuite: Fix use of wc in T13340

As previously documented (88f5add0280788d424c9df5f751a73e73a1a4284) wc's output
is inconsistent between Linux and BSDs. Use grep -c instead.

2 years agoTypeable: Fix remaining typeRepX referencds
Ben Gamari [Mon, 13 Mar 2017 19:20:40 +0000 (15:20 -0400)] 
Typeable: Fix remaining typeRepX referencds

What was previously known as TypeRepX is now known as SomeTypeRep.

2 years agoMake exports from Data.Typeable and Type.Reflection consistent
Ryan Scott [Mon, 13 Mar 2017 19:19:03 +0000 (15:19 -0400)] 
Make exports from Data.Typeable and Type.Reflection consistent

This fixes some idiosyncracies I noticed between `Data.Typeable` and
`Type.Reflection`:

* `showsTypeRep` (from `Data.Typeable`) had the type `SomeTypeRep ->
  ShowS`, despite the fact that `SomeTypeRep` isn't exported from
  `Data.Typeable`. I changed it to be `Data.Typeable.TypeRep -> ShowS`.

* Similarly, `typeRepFingerprint` (reexported from `Data.Typeable`) had
  the type `SomeTypeRep -> Fingerprint`. I changed it to `Data.Typeable.TypeRep
  -> Fingerprint`.

* `Type.Reflection` wasn't exporting `typeRepX` or `typeRepXFingerprint`,
  despite the fact that their counterparts were exported from `Data.Typeable`.
  `Type.Reflection` now exports them as well.

* `withTypeable :: TypeRep (a :: k) -> (Typeable a => r) -> r` was being
   reexported from `Data.Typeable`. This is in spite of the fact that you
   can't actually use the type-indexed `TypeRep a` by importing
   `Data.Typeable` alone. I decided to remove this export from `Data.Typeable`.

Reviewers: bgamari, austin, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3309

2 years agoBroaden demand analysis IO hack notes
David Feuer [Mon, 13 Mar 2017 19:18:49 +0000 (15:18 -0400)] 
Broaden demand analysis IO hack notes

The I/O hack for demand analysis has broader and arguably more
important implications than the note expressed. Broaden it.

[skip ci]

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: carter, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3307

2 years agoMaybe Monoid doc: "is no semigroup" -> "used to be no semigroup"
Chris Martin [Mon, 13 Mar 2017 19:18:33 +0000 (15:18 -0400)] 
Maybe Monoid doc: "is no semigroup" -> "used to be no semigroup"

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3312

2 years agoAdd COLUMN pragma
Phil Ruffwind [Mon, 13 Mar 2017 19:18:22 +0000 (15:18 -0400)] 
Add COLUMN pragma

Test Plan: validate

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3313

2 years agoAdd `-fmax-errors` flag
Charles Cooper [Mon, 13 Mar 2017 19:17:58 +0000 (15:17 -0400)] 
Add `-fmax-errors` flag

This commit adds a command line option to limit the number of errors
displayed. It also moves the documentation for `reverse-errors` into the
`Warnings` section.

https://ghc.haskell.org/trac/ghc/ticket/13326

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3323

2 years agounlit: replace the SHEBANG with an empty line
Phil Ruffwind [Mon, 13 Mar 2017 19:17:47 +0000 (15:17 -0400)] 
unlit: replace the SHEBANG with an empty line

This corrects the line numbers for literate code after a shebang.
Fixes #13414.

Test Plan: validate

Reviewers: austin, bgamari, trofi

Reviewed By: bgamari, trofi

Subscribers: trofi, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3333

2 years agoElaborate further on ZipList Applicative docs
Chris Martin [Sun, 12 Mar 2017 19:15:29 +0000 (15:15 -0400)] 
Elaborate further on ZipList Applicative docs

I was initially confused when I read "zipWithn" in the haddock for
ZipList, went looking for a function named "zipWithn", and found that
it didn't exist. This expands the docs to clarify that we're referring
to the family of functions [zipWith, zipWith3, zipWith4, ...],
capitalizes the letter "n" in "zipWithN" in attempt to make that more
readable, and gives an example.

I also moved this documentation from ZipList itself to the Applicative
instance, so that it will show up in both the Ziplist documentation and
in the list of Applicative instances.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3324

2 years agoDon't reference elSupremum in haddock for Lifetime Monoid
Chris Martin [Sun, 12 Mar 2017 19:15:17 +0000 (15:15 -0400)] 
Don't reference elSupremum in haddock for Lifetime Monoid

Reviewers: austin, hvr, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3325

2 years agoReplace debugging trace with a proper WARN
Matthew Pickering [Sun, 12 Mar 2017 19:15:05 +0000 (15:15 -0400)] 
Replace debugging trace with a proper WARN

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3326

2 years agoKQueue: Eliminate redundant import
Ben Gamari [Sun, 12 Mar 2017 22:06:34 +0000 (18:06 -0400)] 
KQueue: Eliminate redundant import

At long last fixes OS X build.

2 years agoRemove `runs` function which already exists in base
Ömer Sinan Ağacan [Sun, 12 Mar 2017 18:56:31 +0000 (21:56 +0300)] 
Remove `runs` function which already exists in base

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3320

2 years agoObserve #13267 in release notes
Ryan Scott [Sat, 11 Mar 2017 20:46:20 +0000 (15:46 -0500)] 
Observe #13267 in release notes

I noticed some code in the wild that broke due to the validity checking
introduced in #13267, so we should be proactive and warn about it in the 8.2
release notes.

2 years agoEmit Core lint warnings on stderr, fix #13342
Ben Fiedler [Tue, 7 Mar 2017 00:48:24 +0000 (01:48 +0100)] 
Emit Core lint warnings on stderr, fix #13342

2 years agodsGRHSs: Remove unused pattern variables argument
Ömer Sinan Ağacan [Sat, 11 Mar 2017 13:33:54 +0000 (16:33 +0300)] 
dsGRHSs: Remove unused pattern variables argument

2 years agoFix bkpcabal03 test.
Edward Z. Yang [Fri, 10 Mar 2017 22:32:25 +0000 (14:32 -0800)] 
Fix bkpcabal03 test.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoBump time submodule
Ben Gamari [Fri, 10 Mar 2017 22:03:21 +0000 (17:03 -0500)] 
Bump time submodule

Fixes 32-bit validation

2 years agotestsuite: Bump T10359 allocations
Ben Gamari [Fri, 10 Mar 2017 22:03:08 +0000 (17:03 -0500)] 
testsuite: Bump T10359 allocations

2 years agoComments only
Simon Peyton Jones [Fri, 10 Mar 2017 14:40:25 +0000 (14:40 +0000)] 
Comments only

2 years agoDrop redundant import
Simon Peyton Jones [Fri, 10 Mar 2017 12:50:59 +0000 (12:50 +0000)] 
Drop redundant import

2 years agoDefine TcSimplify.simplifyTopImplic and use it
Simon Peyton Jones [Fri, 10 Mar 2017 12:50:05 +0000 (12:50 +0000)] 
Define TcSimplify.simplifyTopImplic and use it

A very small refactoring

2 years agoFix constraint simplification in rules
Simon Peyton Jones [Fri, 10 Mar 2017 12:09:52 +0000 (12:09 +0000)] 
Fix constraint simplification in rules

Trac #13381 showed that we were losing track of a wanted constraint
when simplifying the LHS constraints for a RULE.

This patch fixes it, makes the code a bit simpler, and better
documented.

2 years agoImprove error messages for skolems
Simon Peyton Jones [Fri, 10 Mar 2017 11:46:50 +0000 (11:46 +0000)] 
Improve error messages for skolems

In error messages like this
    • Couldn't match type ‘c’ with ‘f0 (a -> b)’
      ‘c’ is a rigid type variable bound by
        the type signature for:
          f :: ((a -> b) -> b) -> forall c. c -> a

we need to take case both to actually show that 'forall c',
and to make sure that its name lines with the 'c' in the
error message.

This has been shaky for some time, and this commit puts it on solid
ground.  See TcRnTypes: Note [SigSkol SkolemInfo]

The main changes are

* SigSkol gets an extra field that records the way in which the
  type signature was skolemised.

* The type in SigSkol is now the /un/-skolemised version

* pprSkolemInfo uses the info to make the tidy type line up
  nicely

Lots of error message wibbles!

2 years agoFix TcSimplify.decideQuantification for kind variables
Simon Peyton Jones [Fri, 10 Mar 2017 11:20:00 +0000 (11:20 +0000)] 
Fix TcSimplify.decideQuantification for kind variables

TcSimplify.decideQuantification was doing the Wrong Thing when
"growing" the type variables to quantify over. We were trying to do
this on a tyvar set where we'd split off the dependent type varaibles;
and we just got it wrong.  A kind variable wasn't being generalised
properly, with confusing knock on consequences.

All this led to Trac #13371 and Trac #13393.

This commit tidies it all up:

* The type TcDepVars is renamed as CandidateQTvs;
  and splitDepVarsOfType to candidateQTyVarsOfType

* The code in TcSimplify.decideQuantification is simpler.
  It no longer does the tricky "grow" stuff over TcDepVars.
  Instead it use ordinary VarSets (thereby eliminating the
  nasty growThetaTyVarsDSet) and uses that to filter the
  result of candidateQTyVarsOfType.

* I documented that candidateQTyVarsOfType returns the type
  variables in a good order in which to quantify, and rewrote
  it to use an accumulator pattern, so that we would predicatably
  get left-to-right ordering.

In doing all this I also made UniqDFM behave a little more nicely:

* When inserting an element that is there already, keep the old tag,
  while still overwriting with the new value.

* This means that when doing udfmToList we get back elements in the
  order they were originally inserted, rather than in reverse order.

It's not a big deal, but in a subsequent commit I use it to improve
the order of type variables in inferred types.

All this led to a lot of error message wibbles:
 - changing the order of quantified variables
 - changing the order in which instances are listed in GHCi
 - changing the tidying of variables in typechecker erors

There's a submodule update for 'array' because one of its tests
has an error-message change.

I may not have associated all of them with the correct commit.

2 years agoDeal with JoinIds before void types
Simon Peyton Jones [Fri, 10 Mar 2017 11:12:12 +0000 (11:12 +0000)] 
Deal with JoinIds before void types

Trac #13394, comment:4 showed up another place where we were testing
for the representation of of a type; and it turned out to be a JoinId
which can be rep-polymorphic.

Just putting the test in the right places solves this easily.

2 years agoDo not generate a data-con wrapper for !Int#
Simon Peyton Jones [Thu, 9 Mar 2017 15:58:32 +0000 (15:58 +0000)] 
Do not generate a data-con wrapper for !Int#

See Note [Data con wrappers and unlifted types] in MkId.
We were being totally stupid!

See Trac #1600 comment:66

2 years agoimplement missing Fabs{32,64} on i386 NCG and UNREG
Sergei Trofimovich [Fri, 10 Mar 2017 09:30:10 +0000 (09:30 +0000)] 
implement missing Fabs{32,64} on i386 NCG and UNREG

Noticed breakage as build failure on i386 freebsd build bot:
  http://haskell.inf.elte.hu/builders/freebsd-i386-head/1267/10.html

  ghc-stage1: panic! (the 'impossible' happened)
    (GHC version 8.1.20170310 for i386-portbld-freebsd):
      outOfLineCmmOp: MO_F64_Fabs not supported here

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoconfigure.ac: Bump version to 8.3 ghc-8.3-start
Ben Gamari [Thu, 9 Mar 2017 18:01:03 +0000 (13:01 -0500)] 
configure.ac: Bump version to 8.3

Bumps haddock submodule

2 years agoFix typo in base changelog
Ryan Scott [Thu, 9 Mar 2017 23:10:56 +0000 (18:10 -0500)] 
Fix typo in base changelog

Replace `Data.Reflection` with `Type.Reflection`.

2 years agoData.Typeable: Export splitTyConApp, typeRepArgs, and typeRepTyCon
Ben Gamari [Thu, 9 Mar 2017 21:20:38 +0000 (16:20 -0500)] 
Data.Typeable: Export splitTyConApp, typeRepArgs, and typeRepTyCon

Test Plan: Validate

Reviewers: austin, hvr, RyanGlScott

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3294

2 years agoconfigure.ac: Ensure that we handle case of non-present --target
Ben Gamari [Thu, 9 Mar 2017 21:19:56 +0000 (16:19 -0500)] 
configure.ac: Ensure that we handle case of non-present --target

@rwbarton pointed out that this could be an issue during review, but I
assumed from my point sample of three test builds that this wouldn't be
necessary.  Sadly, none of these builds were on Windows, which indeed
does fail.

Strangely, only Simon and Harbormaster have been able to replicate the
issue (which apparently manifests as libffi thinking it's building for
unix).  I've been completely unable to replicate the failure in my own
builds, neither locally nor on the Harbormaster machine.

Test Plan: Validate on Windows

Reviewers: austin, Phyx, hvr

Reviewed By: Phyx

Subscribers: thomie, rwbarton, erikd

Differential Revision: https://phabricator.haskell.org/D3304

2 years agoFix test results for T13380
David Feuer [Thu, 9 Mar 2017 21:01:50 +0000 (16:01 -0500)] 
Fix test results for T13380

They were `expect_broken` without any output. Add the actual
output and remove the `expect_broken`.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3306

2 years agoRevert "configure.ac: Bump version to 8.3"
Ben Gamari [Thu, 9 Mar 2017 17:59:16 +0000 (12:59 -0500)] 
Revert "configure.ac: Bump version to 8.3"

This reverts commit 5dce2160a1b361eba7d0109d314246c8ec97878b as it
didn't build.