Fix LLVM code generated for word2Float# and word2Double#.
Make validating with GhcProfiled=YES Just Work

It now takes care of adding p to the GhcLibWays, rather than just
complaining that it's missing.
Set DBLATEX_OPTS to -P 'filename.as.url=0' (fixes #7486)

Apparently this fixes the build with dblatex 0.3.4.
Make CaseElim a bit less aggressive

See Note [Case elimination: lifted case]:

We used to do case elimination if
        (c) the scrutinee is a variable and 'x' is used strictly
But that changes
    case x of { _ -> error "bad" }
    --> error "bad"
which is very puzzling if 'x' is later bound to (error "good").
Where the order of evaluation is specified (via seq or case)
we should respect it.

c.f. Note [Empty case alternatives] in CoreSyn, which is how
I came across this.
Allow empty case expressions (and lambda-case) with -XEmptyCase

The main changes are:
  * Parser accepts empty case alternatives
  * Renamer checks that -XEmptyCase is on in that case
  * (Typechecker is pretty much unchanged.)
  * Desugarer desugars empty case alternatives, esp:
      - Match.matchWrapper and Match.match now accept empty eqns
      - New function matchEmpty deals with the empty case
      - See Note [Empty case alternatives] in Match

This patch contains most of the work, but it's a bit mixed up
with a refactoring of MatchGroup that I did at the same time
(next commit).
Refactor HsExpr.MatchGroup

 * Make MatchGroup into a record, and use the record fields

 * Split the type field into two: mg_arg_tys and mg_res_ty
   This makes life much easier for the desugarer when the
   case alterantives are empty

A little bit of this change unavoidably ended up in the preceding
commit about empty case alternatives
Add an ASSERT
Switch on -XEmptyCase when renaming derived declarations

Compiler-generated code can have empty cases
Merge branch 'master' of darcs.haskell.org:/home/darcs/ghc
Changed deriving of Functor, Foldable, Traversable to fix #7436. Added foldMap to derived Foldable instance.

The derived instances will no longer eta-expand the function. I.e. instead of
    fmap f (Foo a) = Foo (fmap (\x -> f x) a)
we now derive
    fmap f (Foo a) = Foo (fmap f a)

Some superflous lambdas are generated as a result. For example
    data X a = X (a,a)
    fmap f (X x) = (\y -> case y of (a,b) -> (f a, f b)) x
The optimizer should be able to simplify this code, as it is just beta reduction.

The derived Foldable instance now includes foldMap in addition to foldr.
Added note explaining the lambdas generated by functor deriving code, and how it compares to the old deriving code which used eta expansion.
Add a -rpath entry for the RTS library, so that it can find libffi

This fixes dynamic library resolution when --enable-new-dtags is used
(#7062).

When --enable-new-dtags is used when linking an executable, a RUNPATH as
well as RPATH is set. The linker then ignores RPATH, and RUNPATH is only
used for directly (not transitively) needed libraries. As the program
doesn't directly need libffi, it isn't found.
Refactor invariants for FamInsts.

This commit mirrors work done in the commit for ClsInsts, 5efe9b...

Specifically:
- All FamInsts have *fresh* type variables. So, no more freshness work
in addLocalFamInst

Also:
- Some pretty-printing code around FamInsts was cleaned up a bit
This caused location information to be added to CoAxioms and index
information to be added to FamInstBranches.
Merge branch 'master' of darcs.haskell.org:/home/darcs/ghc
make "./sync-all -r <path> remote set-url origin" work
Fix bugs in allocMoreStack (#7498, #7510)

There were four bugs here.  Clearly I didn't test this enough to
expose the bugs - it appeared to work on x86/Linux, but completely by
accident it seems.

1. the delta was wrong by a factor of the slot size (as noted on #7498)

2. we weren't correctly aligning the stack pointer (sp needs to be
16-byte aligned on x86/x86_64)

3. we were doing the adjustment multiple times in the case of a block
that was both a return point and a local branch target.  To fix this I
had to add new shim blocks to adjust the stack pointer, and retarget
the original branches.  See comment for details.

4. we were doing the adjustment for CALL instructions, which is
unnecessary and wrong; only JMPs should be preceded by a stack
adjustment.

(Someone with a PPC box will need to update the PPC version of
allocMoreStack to fix the above bugs, using the x86 version as a
guide.)
Rearrange the computation of unused imports; fixes Trac #7454
Remove two unused imports, detected by the fix to Trac #7454
Re-engineer the ambiguity test for user type signatures

Two main changes. First, re-engineer the ambiguity test.  Previously
TcMType.checkAmbiguity used a rather syntactic test to detect some
types that are certainly ambiguous.  But a much easier test is available,
and it is used for inferred types in TcBinds. Namely
    <type> is ambiguous
iff
   <type> `TcUnify.isSubType` <type>
fails to hold, where "isSubType" means "is provably more polymorphic than".
Example:
      C a => Int
is ambiguous, because isSubType instantiates the (C a => Int)
to (C alpha => Int) and then tries to deduce (C alpha) from (C a). This is
Martin Sulzmann's definition of ambiguity.  (Defn 10 of "Understanding
functional dependencies via constraint handling rules", JFP.)

This change is neat, reduces code, and correctly rejects more programs.
However is *is* just possible to have a useful program that would be
rejected. For example
          class C a b
          f :: C Int b => Int -> Int
Here 'f' would be rejected as having an ambiguous type. But it is
just possible that, at a *call* site there might be an instance
declaration  instance C Int b, which does not constrain 'b' at all.
This is pretty strange -- why is 'b' overloaded at all? -- but it's
possible, so I also added a flag -XAllowAmbiguousTypes that simply
removes the ambiguity check.  Let's see if anyone cares.  Meanwhile
the earlier error report will be useful for everyone else.

A handful of regression tests had to be adjusted as a result, because
they used ambiguous types, somewhat accidentally.

Second, split TcMType (already too large) into two

  * TcMType: a low-level module dealing with monadic operations like
    zonking, creating new evidence variables, etc

  * TcValidity: a brand-new higher-level module dealing with
    validity checking for types: checkValidType, checkValidInstance,
    checkFamInstPats etc

Apart from the fact that TcMType was too big, this allows TcValidity
to import TcUnify(tcSubType) without causing a loop.
Merge remote branch 'origin/master'