Comment typo only
Simplify the binder-swap transformation

The occurrence analyser implements the "binder-swap" transformation,
described in Note [Binder swap] in OccAnal. For some reason I had
implemeted an extremely complicated version, I believe intended to get
as much as possible done in single simplifier pass.  But it turned
out (Trac #7258) that the 'getProxies' bit of this complicated code
scaled rather non-linearly, and all by itself could consume half of
the entire compile time.

The patch dramatically simplifies the transformation, so that
we simply swizzle
     case x of y { I# v -> e }
to
     case x of y { I# v -> let x = y in e }

I can't see any reason not to do this

  * Compiler allocation for #7258 with 200 fields goes down by 25%
    and compile time by 20%

  * The nofib figures do not budge

  * Quite a bit of complicated code goes away
Add traceSmpl for simplifier tracing, now that the simplifier has the IO monad
Make combine-identical-alternatives work again (Trac #7360)

Move the "combine indentical alternatives" transformation *before*
simplifying the alternatives.  For example
     case x of y
        [] -> length y
        (_:_) -> length y }

If we look *post* simplification, since 'y' is used in the
alterantives, the case binders *might* be (see the keep_occ_info test
in Simplify.simplAlt); and hence the combination of the two
alteranatives does not happen.  But if we do it *pre* simplification
there is no problem.

This fixes Trac #7360.
Make the treatment of addAltUnfoldings handle casts

This minor refactoring re-attaches Note [Add unfolding for scrutinee].
It had become detached, which led me on a bit of a wild goose
chase.

While I was at it, I made the code work right for the case where
the scrutinee is of form (x |> co); I don't think this is an important
improvement.

I also make simplAlt unconditionally zap occurrence information on
case-alternative binders (see Note [Case alternative occ info]);
it was almost always being zapped and the additional complexity seems
not worth it.
Define ListSetOps.getNth, and use it

I was tracking down an error looking like
  Prelude.(!!): index too large
which is very unhelpful.  This patch replaces at least some uses
of (!!) in GHC with getNth, which has a more helpful error
message (with DEBUG anyway)
Refactoring; no change in behaviour
Crucial bug fix: use scrut' rather than scrut!
Add an extra error check in DEBUG mode for ill-typed unfoldings
Merge branch 'master' of darcs.haskell.org:/home/darcs/ghc