Rewrite `Coercible` solver

Summary:
This is a rewrite of the algorithm to solve for Coercible "instances".

A preliminary form of these ideas is at
https://ghc.haskell.org/trac/ghc/wiki/Design/NewCoercibleSolver

The basic idea here is that the `EqPred` constructor of `PredTree`
now is parameterised by a new type `EqRel` (where
`data EqRel = NomEq | ReprEq`). Thus, every equality constraint can
now talk about nominal equality (the usual case) or representational
equality (the `Coercible` case).

This is a change from the previous
behavior where `Coercible` was just considered a regular class with
a special case in `matchClassInst`.

Because of this change, representational equalities are now
canonicalized just like nominal ones, allowing more equalities
to be solved -- in particular, the case at the top of #9117.

A knock-on effect is that the flattener must be aware of the
choice of equality relation, because the inert set now stores
both representational inert equalities alongside the nominal
inert equalities. Of course, we can use representational equalities
to rewrite only within another representational equality --
thus the parameterization of the flattener.

A nice side effect of this change is that I've introduced a new
type `CtFlavour`, which tracks G vs. W vs. D, removing some ugliness
in the flattener.

This commit includes some refactoring as discussed on D546.
It also removes the ability of Deriveds to rewrite Deriveds.

This fixes bugs #9117 and #8984.

Reviewers: simonpj, austin, nomeata

Subscribers: carter, thomie

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

GHC Trac Issues: #9117, #8984
Flat constraint --> Simple constraint
reduceTyFamApp_maybe should *not* normalise arguments first.

Doing so made the solver gobble up tons of memory, now that matchFam
calls reduceTyFamApp_maybe. But, I don't know why, yet! Will
look more closely at this soon.
Parser: remove unused rule (copy/paste error)

Summary:
Found out when tracking down conflicts reported by happy.
It was accidentally introduced in large Api Annotations
patch: 803fc5db31f084b73713342cdceaed5a9c664267

Before:
  unused rules: 1
  shift/reduce conflicts:  60
  reduce/reduce conflicts: 16
After:
  shift/reduce conflicts:  60
  reduce/reduce conflicts: 12

Unused rule is seen in happy's --info= output as:
    rule 180 is unused
    ...
    decl_cls -> 'default' infixexp '::' sigtypedoc     (180)
    decl_cls -> 'default' infixexp '::' sigtypedoc     (181)

While at it removed 'q' typo in parser conflict log :)

Signed-off-by: Sergei Trofimovich <siarheit@google.com>

Reviewers: simonmar, austin, alanz

Reviewed By: alanz

Subscribers: carter, thomie

Differential Revision: https://phabricator.haskell.org/D569
Only use -fasm on platforms with an NCG (Closes: #9884).

Summary: Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>

Reviewers: austin, carter

Reviewed By: carter

Subscribers: carter, thomie

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

GHC Trac Issues: #9884
Update Haddock submodule to latest `master` tip

This also updates the perf-numbers for `haddock.base` and `haddock.Cabal`

NB: this switches from `ghc-head` to `master` branch temporarily
    until GHC 7.10 has been properly branched off.
Revert "Update Haddock submodule to latest `master` tip"

This reverts commit 7f634320a2c39f4f81f631deb844acbaebaced66 again for now as
it causes validate's bindist phase to fail with

  haddock: internal error: .../install   dir/lib/ghc-7.9.20141214/html:
     getDirectoryContents: does not exist (No such file or directory)
powerpc: fix and enable shared libraries by default on linux

Summary:
And fix things all the way down to it. Namely:
    - remove 'r30' from free registers, it's an .LCTOC1 register
      for gcc. generated .plt stubs expect it to be initialised.
    - fix PicBase computation, which originally forgot to use 'tmp'
      reg in 'initializePicBase_ppc.fetchPC'
    - mark 'ForeighTarget's as implicitly using 'PicBase' register
      (see comment for details)
    - add 64-bit MO_Sub and test on alloclimit3/4 regtests
    - fix dynamic label offsets to match with .LCTOC1 offset

Signed-off-by: Sergei Trofimovich <siarheit@google.com>

Test Plan: validate passes equal amount of vanilla/dyn tests

Reviewers: simonmar, erikd, austin

Reviewed By: erikd, austin

Subscribers: carter, thomie

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

GHC Trac Issues: #8024, #9831
Re-Update Haddock submodule to latest `master` tip

The previous attempt failed, but hopefully this one succeeds...

This also updates the perf-numbers for `haddock.base` and `haddock.Cabal`

NB: this switches from `ghc-head` to `master` branch temporarily
    until GHC 7.10 has been properly branched off.
Update `time` submodule to final 1.5.0.1 release
Update `filepath` submodule to current 1.3.1.0 RC
Update `binary` submodule to final 0.7.2.3 release

This also introduces a "bootstrap" `cabal_macros.h` header to provide
the `MIN_VERSION_base()` macro during Cabal bootstrapping which as it is
now used by `binary`.
Fixup bad haddock.base perf-num bump in 0c9c2d89
Update `bytestring` submodule to 0.10.6.0 RC

NB: this still carries the wrong version number 0.10.5.0 but will
be released as 0.10.6.0
Pattern-synonym matcher and builder Ids must be *LocalIds*

This easy-to-make mistake meant that pattern-synonym matcher and
builder Ids weren't being treated as locally defined by the simpplier.
That meant that we never looked up them up in the environment, got an
out-of-date unfolding, which made the Simplifier fall into an infinite
loop.  This was the cause of Trac #98587, but it was quite tricky to
find!

In a separate patch I'll make Lint check for locally-bound GlobalIds,
since they are always an error.
Make Core Lint check for locally-bound GlobalIds

There should be no bindings in this module for a GlobalId;
except after CoreTidy, when top-level bindings are globalised.

To check for this, I had to make the CoreToDo pass part of the
environment that Core Lint caries.  But CoreToDo is defined in
CoreMonad, which (before this patch) called CoreLint.

So I had to do quite a bit of refactoring, moving some
lint-invoking code into CoreLint itself.  Crucially, I also
more tcLookupImported_maybe, importDecl, and checkwiredInTyCon
from TcIface (which use CoreLint) to LoadIface (which doesn't).
This is probably better structure anyway.

So most of this patch is refactoring. The actual check for
GlobalIds is in CoreLint.lintAndScopeId
stm: update submodule for #9169 addition

Signed-off-by: Austin Seipp <austin@well-typed.com>
Changing prefetch primops to have a `seq`-like interface

Summary:
The current primops for prefetching do not properly work in pure code;
namely, the primops are not 'hoisted' into the correct call sites based
on when arguments are evaluated. Instead, they should use a `seq`-like
interface, which will cause it to be evaluated when the needed term is.

See #9353 for the full discussion.

Test Plan: updated tests for pure prefetch in T8256 to reflect the design changes in #9353

Reviewers: simonmar, hvr, ekmett, austin

Reviewed By: ekmett, austin

Subscribers: merijn, thomie, carter, simonmar

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

GHC Trac Issues: #9353
Write release notes for -XStaticPointers.

Test Plan: ./validate

Reviewers: goldfire, austin

Reviewed By: austin

Subscribers: mboes, carter, thomie

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

GHC Trac Issues: #7015
Fix panic on [t| _ |] (Trac #9879)

Summary:
Type brackets containing a wildcard, e.g. `[t| _ |]`, caused a panic.
Fix it by disallowing wildcards in type brackets.

Together with D572, this fixes #9879.

Test Plan: new test WildcardInTypeBrackets should pass

Reviewers: austin

Reviewed By: austin

Subscribers: carter, thomie, monoidal

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

GHC Trac Issues: #9879