Fix #15344: use fail when desugaring applicative-do

Applicative-do has a bug where it fails to use the monadic fail method
when desugaring patternmatches which can fail. See #15344.

This patch fixes that problem. It required more rewiring than I had expected.
Applicative-do happens mostly in the renamer; that's where decisions about
scheduling are made. This schedule is then carried through the typechecker and
into the desugarer which performs the actual translation. Fixing this bug
required sending information about the fail method from the renamer, through
the type checker and into the desugarer. Previously, the desugarer didn't
have enough information to actually desugar pattern matches correctly.

As a side effect, we also fix #16628, where GHC wouldn't catch missing
MonadFail instances with -XApplicativeDo.
22 jobs for master in 960 minutes and 43 seconds (queued for 8 seconds)
Status Job ID Name Coverage
  Lint
passed #187642
lint
lint-linters

00:00:19

passed #187645
lint
lint-submods-branch

00:00:15

passed #187643
lint
lint-testsuite

00:00:20

passed #187644
lint
typecheck-testsuite

00:00:13

 
  Quick Build
passed #187646
x86_64-linux
hadrian-ghc-in-ghci

00:11:23

 
  Build
passed #187649
x86_64-linux
release-x86_64-linux-deb9-dwarf

01:39:35

passed #187648
x86_64-linux
validate-x86_64-linux-deb9-debug

03:09:46

passed #187647
x86_64-linux
validate-x86_64-linux-deb9-hadrian

02:23:15

 
  Full Build
failed #187651
aarch64-linux allowed to fail
validate-aarch64-linux-deb9

02:29:15

failed #187652
armv7-linux allowed to fail
validate-armv7-linux-deb9

12:00:00

passed #187653
x86_64-linux
validate-i386-linux-deb9

01:20:01

passed #187650
x86_64-darwin
validate-x86_64-darwin

01:35:15

passed #187654
x86_64-linux
validate-x86_64-linux-deb9-integer-simple

01:22:35

passed #187655
x86_64-linux
validate-x86_64-linux-deb9-unreg

02:04:36

passed #187656
x86_64-linux
validate-x86_64-linux-fedora27

01:28:41

failed #187658
x86_64-windows allowed to fail
validate-x86_64-windows

00:09:01

failed #187657
x86_64-windows allowed to fail
validate-x86_64-windows-hadrian

00:46:42

 
  Cleanup
passed #187659
x86_64-darwin
cleanup-darwin

00:00:05

 
  Packaging
failed #187660
x86_64-linux allowed to fail
doc-tarball

00:01:39

 
  Testing
manual #187661
x86_64-linux allowed to fail manual
hackage
passed #187662
x86_64-linux
perf-nofib

00:35:50

 
  Deploy
failed #187663
x86_64-linux allowed to fail
pages

00:01:20

 
Name Stage Failure
failed
pages Deploy
$ git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true
warning: no common commits
From https://gitlab.haskell.org/ghc/ghc-performance-notes
* [new ref] refs/notes/perf -> refs/notes/perf
$ mkdir -p public/doc
$ tar -xf haddock.html.tar.xz -C public/doc
tar: haddock.html.tar.xz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
ERROR: Job failed: exit code 1
failed
doc-tarball Packaging
Submodule path 'utils/hsc2hs': checked out '4c65964de3ca1a002901cae95217ad10b95edeeb'
$ git checkout .gitmodules
$ git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true
warning: no common commits
From https://gitlab.haskell.org/ghc/ghc-performance-notes
* [new ref] refs/notes/perf -> refs/notes/perf
$ if [ ! -f "$LINUX_BINDIST" ]; then # collapsed multi-line command
Error: ghc-x86_64-mingw32.tar.xz does not exist. Did the 64-bit Windows job fail?
ERROR: Job failed: exit code 1
failed
validate-armv7-linux-deb9 Full Build The script exceeded the maximum execution time set for the job
[1 of 4] Compiling Enum             ( GEnum/Enum.hs, out_T5462Yes1/Enum.o )
[2 of 4] Compiling GEq1A ( GEq/GEq1A.hs, out_T5462Yes1/GEq1A.o )
[3 of 4] Compiling GFunctor ( GFunctor/GFunctor.hs, out_T5462Yes1/GFunctor.o )
[4 of 4] Compiling Main ( T5462Yes1.hs, out_T5462Yes1/Main.o )

*** unexpected failure for T5462Yes1(normal)
=====> T10604_bad_variable_occurrence(normal) 1536 of 7268 [0, 24, 0]
cd "generics/T10604/T10604_bad_variable_occurrence.run" && "/builds/ghc/ghc/inplace/bin/ghc-stage2" -c T10604_bad_variable_occurrence.hs -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output <
Pulling docker image gitlab/gitlab-runner-helper:arm-7137fd54 ...
ERROR: Job failed: execution took longer than 12h0m0s seconds
failed
validate-aarch64-linux-deb9 Full Build
Uploading artifacts...
WARNING: ghc-*.tar.xz: no matching files
WARNING: junit.xml: no matching files
WARNING: performance-metrics.tsv: no matching files
ERROR: No files to upload
Uploading artifacts...
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
failed
validate-x86_64-windows-hadrian Full Build
Runtime platform                                    arch=amd64 os=windows pid=6904 revision=1f513601 version=11.10.1
WARNING: ghc.tar.xz: no matching files
WARNING: junit.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=4740 revision=1f513601 version=11.10.1
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 1
failed
validate-x86_64-windows Full Build
Runtime platform                                    arch=amd64 os=windows pid=4260 revision=1f513601 version=11.10.1
WARNING: ghc-*.tar.xz: no matching files
WARNING: junit.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=5908 revision=1f513601 version=11.10.1
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 2