includes/Stg.h: define _DEFAULT_SOURCE for glibc-2.20

_BSD_SOURCE we are using for 'gamma()' and friends
was deprecated in glibc-2.20 in favour of '_DEFAULT_SOURCE'.

gcc says:

    In file included from /usr/include/math.h:26:0:
        0,
                         from includes/Stg.h:69,
                         from /tmp/ghc19488_0/ghc19488_2.hc:3:

    /usr/include/features.h:148:3:
         warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
         # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
           ^

Patch fixes testsuite failures on UNREG
(stderr are not cluttered by warnings anymore).

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Remove a stray Trustworthy flag in ghc.
Add in `-fwarn-trustworthy-safe` flag.

This warns when a module marked as `-XTrustworthy` could have been
inferred as safe instead.
Add `--fwarn-trustworthy-safe` to `-Wall`

Update submodule haskell2010, haskell98, hoop, hpc and stm to fix new
warnings.
Update userguide for new `-fwarn-trustworthy-safe` flag.
base: Fix map/coerce comment

Make the comment on the map/coerce rule refer to the right section in
the paper; give the full name of the papers, and name its authors.

[skip ci]

Differential Revision: https://phabricator.haskell.org/D472
Make unwords and words fuse somewhat

Make `words` a good producer and `unwords` a good consumer for list
fusion. Thus `unwords . words` will avoid producing an intermediate list
of words, although it will produce each individual word.

Make `unwords` slightly lazier, so that
`unwords (s : undefined) = s ++ undefined` instead of `= undefined`.

Reviewed By: austin

Differential Revision: https://phabricator.haskell.org/D375
base: define `sequence = mapM id`

This avoids duplication in `GHC.Base`; originally, we had

  mapM f = sequence . map f

This led to excessive allocation in `cryptarithm2`. Defining

  sequence = mapM id

does not appear to cause any `nofib` problems.

Reviewed By: hvr

Differential Revision: https://phabricator.haskell.org/D470
Improve `Foldable` instance for `Array`

Previously, `Array`s were simply converted to lists, and the list
methods used. That works acceptably well for `foldr` and `foldr1`, but
not so sensibly for most other things. Left folds ended up "twisted" the
way they are for lists, leading to surprising performance
characteristics.

Moreover, this implements `length` and `null` so they check the array
size directly.

Finally, a test is added to the testsuite ensuring the overridden
`Foldable` methods agree with their expected default semantics.

Addresses #9763

Reviewed By: hvr, austin

Differential Revision: https://phabricator.haskell.org/D459
Fix `integer-gmp2` compilation with GMP 4.x (#9281)

GMP 4.x didn't provide the `mp_bitcnt_t` typedef yet, so we locally
define one if GMP 4.x is detected.
Fix typo in panic message
Binding things matched by an unboxed pattern synonym should require a bang
If pattern synonym is bidirectional and its type is some unboxed type T#,
generate a worker function of type Void# -> T#, and redirect the wrapper
(via a compulsory unfolding) to the worker. Fixes #9732.
Apply compulsory unfoldings during desugaring, except for `seq` which is special.
See Note [Unfolding while desugaring] for the rationale.
nlHsTyApps: for applying a function both on type- and term-level arguments
When calling the success continuation of a matcher, pass existential tyvars
as type arguments, not value arguments
Implement amap/coerce for Array (re #9796)

Implement an `amap`/`coerce` rule in `GHC.Arr` to match the
`map`/`coerce` rule in GHC.Base.

In order to do so, delay inlining `amap` until phase 1.

To prevent the inlining delay from causing major inefficiencies due to
missed list fusion, rewrite `amap` to avoid relying on list fusion. This
has the extra benefit of reducing the size of the compiled amap code by
skipping the impossible case of an array with a negative size.

Reviewed By: nomeata

Differential Revision: https://phabricator.haskell.org/D471
Update .mailmap

[skip ci]
Partially revert 475dd93efa

This introduces ./validate failures for Windows right now, so in the
mean time let's just back this flag out as a default -Wall flag.

Signed-off-by: Austin Seipp <austin@well-typed.com>
Generalize exposed-modules field in installed package database

Summary:
Instead of recording exposed-modules and reexported-modules as seperate
fields in the installed package database, this commit merges them into
a single field (exposed-modules).  The motivation for this change is
in preparation for the inclusion of *signatures* into the installed
package database, which may also be reexported.  Merging the representation
means that we can treat reexports uniformly, no matter if they're a normal
module or a signature.

This commit adds a stub for signatures, but that code isn't wired up to
anything yet.

Contains Cabal submodule update to accommodate these changes.

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

Test Plan: validate

Reviewers: simonpj, duncan, austin

Subscribers: thomie, carter, simonmar

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