Synchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862)

Issue #15862 demonstrated examples of type constructors on which
`TcTypeable.tyConIsTypeable` would return `False`, but the `Typeable`
constraint solver in `ClsInst` (in particular, `doTyConApp`) would
try to generate `Typeable` evidence for anyway, resulting in
disaster. This incongruity was caused by the fact that `doTyConApp`
was using a weaker validity check than `tyConIsTypeable` to determine
if a type constructor warrants `Typeable` evidence or not. The
solution, perhaps unsurprisingly, is to use `tyConIsTypeable` in
`doTyConApp` instead.

To avoid import cycles between `ClsInst` and `TcTypeable`, I factored
out `tyConIsTypeable` into its own module, `TcTypeableValidity`.

Fixes #15862.
18 jobs for !1199 with wip/T15862 in 403 minutes and 41 seconds (queued for 1 second)
latest detached
Status Job ID Name Coverage
  Lint
passed #103268
lint
ghc-linters

00:00:14

passed #103269
lint
lint-submods-mr

00:00:16

 
  Build
passed #103285
x86_64-linux
hadrian-ghc-in-ghci

00:18:15

failed #103273
x86_64-linux allowed to fail
release-x86_64-linux-deb9-dwarf

01:25:26

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

01:44:57

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

02:18:19

failed #103271
x86_64-linux
hadrian-ghc-in-ghci

00:11:01

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

04:21:21

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

01:27:38

passed #103274
x86_64-darwin
validate-x86_64-darwin

01:00:32

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

01:49:15

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

03:33:03

passed #103279
x86_64-linux
validate-x86_64-linux-fedora27

01:47:02

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

02:20:36

passed #103280
x86_64-windows
validate-x86_64-windows-hadrian

01:22:35

 
  Cleanup
passed #103282
x86_64-darwin
cleanup-darwin

00:00:05

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

00:03:37

 
  Hackage
manual #103284
x86_64-linux allowed to fail manual
hackage
 
Name Stage Failure
failed
doc-tarball Packaging
+ for i in haddock libraries users_guide
+ tar -Jcf ../../../../../libraries.html.tar.xz libraries
+ for i in haddock libraries users_guide
+ tar -Jcf ../../../../../users_guide.html.tar.xz users_guide
+ mv index.html ../../../../..
+ cd ..
+ mv '*.pdf' ../../../..
mv: cannot stat '*.pdf': No such file or directory
ERROR: Job failed: exit code 1
failed
release-x86_64-linux-deb9-dwarf Build
$ cp -Rf $HOME/.cabal cabal-cache
Uploading artifacts...
ghc-*.tar.xz: found 1 matching files
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=103273 responseStatus=201 Created token=H6Vi4YYa
Uploading artifacts...
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=103273 responseStatus=201 Created token=H6Vi4YYa
ERROR: Job failed: exit code 1
failed
validate-x86_64-windows Full Build
junit.xml: found 1 matching files                  
WARNING: Failed to load system CertPool:crypto/x509: system root pool is not available on Windows
Uploading artifacts to coordinator... ok
id=103281 responseStatus=201 Created token=hE5exvCA
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=4084 revision=1f513601 version=11.10.1
junit.xml: found 1 matching files

WARNING: Failed to load system CertPool:crypto/x509: system root pool is not available on Windows
Uploading artifacts to coordinator... ok
id=103281 responseStatus=201 Created token=hE5exvCA
ERROR: Job failed: exit status 2
failed
validate-aarch64-linux-deb9 Full Build
$ cp -Rf $HOME/.cabal cabal-cache
Uploading artifacts...
ghc-*.tar.xz: found 1 matching files
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=103275 responseStatus=201 Created token=4LEdzWtb
Uploading artifacts...
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=103275 responseStatus=201 Created token=4LEdzWtb
ERROR: Job failed: exit code 1