Make Data.List.Inits fast

Fixes #9345. Use a modified banker's queue to achieve amortized optimal
performance for inits. The previous implementation was extremely slow.

Reviewed By: nomeata, ekmett, austin

Differential Revision: https://phabricator.haskell.org/D329
Make tails a good producer (#9670)

Reviewed By: nomeata, austin
Differential Revision: https://phabricator.haskell.org/D325
Declare official GitHub home of libraries/deepseq

Effective immediately, `deepseq` is maintained officially by the
core-library-comittee.  Moreover, pushing to libraries/deepseq requires
pushing to ssh://git@github.com/haskell/deepseq.git from now on.

[skip ci]
Avoid printing uniques in specialization rules

Akio found an avoidable cause of non-determinisim: The names of RULES
generated by Specialise had uniques in them:
    "SPEC $cshowsPrec_a2QX @ [GHC.Types.Char]" [ALWAYS] forall ...
By using showSDocForUser instead of showSDocDump when building the rule
name, this is avoided:
    "SPEC $cshowsPrec @ [Char]" [ALWAYS] forall ...
See #4012, comments 61ff.
Update T6056 output

according to travis (and proably Harbormaster), although I just cannot
reproduce it here.
rts: fix unused parameter warning

Summary:
If `pthread_setname_np` is not available, then a regular
./validate will fail due to warnings; the `name` parameter to
`createOSThread` becomes unused.

Signed-off-by: Austin Seipp <austin@well-typed.com>

Test Plan: iiam

Reviewers: simonmar, nomeata, jstolarek, hvr

Reviewed By: nomeata, jstolarek, hvr

Subscribers: nomeata, thomie, carter, ezyang, simonmar

Differential Revision: https://phabricator.haskell.org/D344
Implement optimized NCG `MO_Ctz W64` op for i386 (#9340)

Summary:
This is an optimization to the CTZ primops introduced for #9340

Previously we called out to `hs_ctz64`, but we can actually generate
better hand-tuned code while avoiding the FFI ccall.

With this patch, the code

  {-# LANGUAGE MagicHash #-}
  module TestClz0 where
  import GHC.Prim
  ctz64 :: Word64# -> Word#
  ctz64 x = ctz64# x

results in the following assembler generated by NCG on i386:

  TestClz.ctz64_info:
      movl (%ebp),%eax
      movl 4(%ebp),%ecx
      movl %ecx,%edx
      orl %eax,%edx
      movl $64,%edx
      je _nAO

      bsf %ecx,%ecx
      addl $32,%ecx
      bsf %eax,%eax
      cmovne %eax,%ecx
      movl %ecx,%edx
  _nAO:
      movl %edx,%esi
      addl $8,%ebp
      jmp *(%ebp)

For comparision, here's what LLVM 3.4 currently generates:

  000000fc <TestClzz_ctzz64_info>:
    fc:   0f bc 45 04             bsf    0x4(%ebp),%eax
   100:   b9 20 00 00 00          mov    $0x20,%ecx
   105:   0f 45 c8                cmovne %eax,%ecx
   108:   83 c1 20                add    $0x20,%ecx
   10b:   8b 45 00                mov    0x0(%ebp),%eax
   10e:   8b 55 08                mov    0x8(%ebp),%edx
   111:   0f bc f0                bsf    %eax,%esi
   114:   85 c0                   test   %eax,%eax
   116:   0f 44 f1                cmove  %ecx,%esi
   119:   83 c5 08                add    $0x8,%ebp
   11c:   ff e2                   jmp    *%edx

Reviewed By: austin

Auditors: simonmar

Differential Revision: https://phabricator.haskell.org/D163
Remove obsolete Data.OldTypeable (#9639)

This finally removes the `Data.OldTypeable` module (which
has been deprecated in 7.8), from `base`, compiler and testsuite.

The deprecated `Typeable{1..7}` aliases in `Data.Typeable` are not
removed yet in order to give existing code a bit more time to adapt.

Reviewed By: hvr, dreixel

Differential Revision: https://phabricator.haskell.org/D311
Generalise `Control.Monad.{foldM,foldM_}` to `Foldable` (#9586)

With this change `Control.Monad.foldM` becomes an alias for
`Data.Foldable.foldlM`.

Reviewed By: austin, ekmett

Differential Revision: https://phabricator.haskell.org/D251
Remove redundant explicit `Prelude` imports

Since they're implied by the lack of `NoImplicitPrelude`
Python 3 support, second attempt (Trac #9184)

Summary:
This is a fixup of https://phabricator.haskell.org/D233

The only difference is in findTFiles (first commit), which
previously broke Windows runner; now I translated literally
instead attempting to improve it, and checked it works.

Test Plan:
I used validate under 2,3 on Linux and under 2 on msys2.
On Windows I've seen a large number of failures, but they don't
seem to be connected with the patch.

Reviewers: hvr, simonmar, thomie, austin

Reviewed By: austin

Subscribers: thomie, carter, ezyang, simonmar

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

GHC Trac Issues: #9184
Refactor module imports in base

This commit removes a couple of

  {-# OPTIONS_GHC -fno-warn-unused-imports #-}

by cleaning up the imports, as well as ensuring that all modules in the
GHC.* hierarchy avoid importing the `Prelude` module to clean-up the
import graph a bit.
Indentation and non-semantic changes only.

Summary:
Get these lines fitting in 80 columns, and replace ptext (sLit ...) with text

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

Test Plan: validate

Reviewers: simonmar, austin

Subscribers: thomie, carter, ezyang, simonmar

Differential Revision: https://phabricator.haskell.org/D342
Sync up `containers` submodule to latest `master`-tip

This updates `containers` to provide more specialised `Foldable`
instance methods, see also

  https://github.com/haskell/containers/issues/56

for more details.
Revert "Fix typo in section name: no leading period."

This reverts commit e8dac6dc60beea863c3a5daded68f5157ab546fb.
Revert "Check for staticclosures section in Windows linker."

This reverts commit 2fc0c6cf594731f343b4f8a5b3ecf9e72db4c3c0.
Revert "Rename _closure to _static_closure, apply naming consistently."

This reverts commit 35672072b4091d6f0031417bc160c568f22d0469.

Conflicts:
	compiler/main/DriverPipeline.hs
Revert "Properly generate info tables for static closures in C--."

This reverts commit 178eb9060f369b216f3f401196e28eab4af5624d.
Revert "BC-breaking changes to C-- CLOSURE syntax."

This reverts commit 3b5a840bba375c4c4c11ccfeb283f84c3a1ef22c.
Revert "Place static closures in their own section."

This reverts commit b23ba2a7d612c6b466521399b33fe9aacf5c4f75.

Conflicts:
	compiler/cmm/PprCmmDecl.hs
	compiler/nativeGen/PPC/Ppr.hs
	compiler/nativeGen/SPARC/Ppr.hs
	compiler/nativeGen/X86/Ppr.hs