Improve Applicative definitions

Generally clean up things relating to Applicative and Monad in `GHC.Base`
and `Control.Applicative` to make `Applicative` feel like a bit more of a
first-class citizen rather than just playing second fiddle to `Monad`. Use
`coerce` and GND to improve performance and clarity.

Change the default definition of `(*>)` to use `(<$)`, in case the
`Functor` instance optimizes that.

Moreover, some manually written instances are made into compiler-derived
instances.

Finally, this also adds a few AMP-related laws to the `Applicative` docstring.

NOTE: These changes result in a 13% decrease in allocation for T9020

Reviewed By: ekmett, hvr

Differential Revision: https://phabricator.haskell.org/D432
Make getTag use a bang pattern instead of seq

It's prettier that way, and there's less risk of anything
going sideways.

Reviewed By: hvr, simonpj

Differential Revision: https://phabricator.haskell.org/D450
Update .gitignore to properly ignore emacs temp files

Signed-off-by: Austin Seipp <austin@well-typed.com>
*Really*, really fix RTS crash due to bad coercion.

Summary:
My previous attempt to fix the new coercion bug introduced by my fix actually
just reverted back to the *old* bug. This time it should properly handle all
three size scenarios.

Signed-off-by: Merijn Verstraaten <merijn@inconsistent.nl>

Test Plan: validate

Reviewers: dfeuer, austin, hvr

Reviewed By: austin, hvr

Subscribers: thomie, carter, simonmar

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

GHC Trac Issues: #8089
small parser/lexer cleanup

Summary:
The last three '#define ...' macros were removed from Parser.y.pp and this file was renamed to Parser.y.
This basically got rid of a CPP step in the build.

Also converted two modules in compiler/parser/ from .lhs to .hs.

Test Plan: Does it build? Yes, I performed a full build here and things are looking good.

Reviewers: austin

Reviewed By: austin

Subscribers: adamse, thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D411
[Docs] Fixed several broken urls in user's guide

Summary: Some of the links in user's guide were broken, I've found the files they used to link and updated urls.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D418
Use bracket in `withCurrentDirectory`

Summary: There was a comment about that. Seems like a better behaviour.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D419
Have validate take into account stat test failures too.

This should have gone in with the update in testlib.py to split
off stat test failures into a separate category in the summary.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter

Differential Revision: https://phabricator.haskell.org/D451
base: Manually unlit .lhs into .hs modules

This commit mostly converts literate comments into ordinary
Haskell comments or sometimes even Haddock comments, while also
removing literate comments in a few cases where they don't make
much sense anymore.

Moreover, in a few cases trailing whitespaces were removed as well.

Reviewed By: austin

Differential Revision: https://phabricator.haskell.org/D456
Preserve argument order to (==)/eq in nub and nubBy

This makes nub and nubBy behave as specified in the Haskell 98 Report.

This reverts 0ad9def53842e86fb292eccb810190711c42d7c5, and
fixes #3280, #7913 and #2528 (properly).

Before this change, the output of `T2528` was (4x wrong):
```
[A,B]
[1,2]
False
False
```

Reviewed By: dfeuer, ekmett, austin, hvr

Differential Revision: https://phabricator.haskell.org/D238
Typofix.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Miscellaneous documentation for the Finder.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Top-level comment for keepPackageImports.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
In pattern synonym matchers, support unboxed continuation results (fixes #9783).

This requires ensuring the continuations have arguments by adding a dummy
Void# argument when needed. This is so that matching on a pattern synonym
is lazy even when the result is unboxed, e.g.

    pattern P = ()
    f P = 0#

In this case, without dummy arguments, the generated matcher's type would be

   $mP :: forall (r :: ?). () -> r -> r -> r

which is called in `f` at type `() -> Int# -> Int# -> Int#`,
so it would be strict, in particular, in the failure continuation
of `patError`.

We work around this by making sure both continuations have arguments:

  $mP :: forall (r :: ?). () -> (Void# -> r) -> (Void# -> r) -> r

Of course, if `P` (and thus, the success continuation) has any arguments,
we are only adding the extra dummy argument to the failure continuation.
Group PatSyn req/prov arguments together so that they're not all over the place
Unlit overlooked GHC/Conc/Sync.lhs

This is a follow-up commit to df3b1d43cc862fe03f0724a9c0ac9e7cecdf4605
Use (.) and id from Base in Control.Applicative

Control.Applicative previously imported `(.)` and `id` from `Control.Arrow`,
but then only applied them to functions.

Reviewed By: ekmett, hvr

Differential Revision: https://phabricator.haskell.org/D462
Move Data.Functor.Identity from transformers to base

This also updates the `transformers` submodule to the just
released `transformers-0.4.2.0` package version.

See #9664 for more details

Reviewed By: austin, ekmett

Differential Revision: https://phabricator.haskell.org/D313
Typo fix; Trac #9787

Also, reword :print description.

Signed-off-by: Austin Seipp <austin@well-typed.com>
Define list monad operations using comprehensions

Define list monad operations using list comprehensions. Code using monad
operations with lists did not fuse fully. Writing list code with `do`
notation or `(>>=)` and `(>>)` operations could allocate more than
equivalent code using list comprehensions.

Define `mapM` directly, instead of using `sequence` and `map`. This
leads to substantially less allocation in `cryptarithm2`.

Addresses #9781

Reviewed By: ekmett, nomeata

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