Allow recursive (undecidable) superclasses
authorSimon Peyton Jones <simonpj@microsoft.com>
Tue, 15 Dec 2015 14:26:13 +0000 (14:26 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Tue, 15 Dec 2015 14:33:32 +0000 (14:33 +0000)
commit6eabb6ddb7c53784792ee26b1e0657bde7eee7fb
treeaf17a00ab5a30d1ab9a9a11a4786f0f239fe82b4
parentb8ca64592e331005def4f734e026d5418950e6e1
Allow recursive (undecidable) superclasses

This patch fulfils the request in Trac #11067, #10318, and #10592,
by lifting the conservative restrictions on superclass constraints.

These restrictions are there (and have been since Haskell was born) to
ensure that the transitive superclasses of a class constraint is a finite
set.  However (a) this restriction is conservative, and can be annoying
when there really is no recursion, and (b) sometimes genuinely recursive
superclasses are useful (see the tickets).

Dimitrios and I worked out that there is actually a relatively simple way
to do the job. It’s described in some detail in

   Note [The superclass story] in TcCanonical
   Note [Expanding superclasses] in TcType

In brief, the idea is to expand superclasses only finitely, but to
iterate (using a loop that already existed) if there are more
superclasses to explore.

Other small things

- I improved grouping of error messages a bit in TcErrors

- I re-centred the haddock.compiler test, which was at 9.8%
  above the norm, and which this patch pushed slightly over
57 files changed:
compiler/main/DynFlags.hs
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSMonad.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcTyDecls.hs
compiler/typecheck/TcType.hs
compiler/utils/Bag.hs
docs/users_guide/glasgow_exts.rst
libraries/ghc-prim/GHC/Classes.hs
testsuite/tests/ado/ado004.stderr
testsuite/tests/driver/T4437.hs
testsuite/tests/ghci/scripts/ghci013.stdout
testsuite/tests/indexed-types/should_compile/T10318.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/T11067.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/T3017.stderr
testsuite/tests/indexed-types/should_compile/T3208b.stderr
testsuite/tests/indexed-types/should_compile/T8889.stderr
testsuite/tests/indexed-types/should_compile/all.T
testsuite/tests/indexed-types/should_fail/T1897b.stderr
testsuite/tests/indexed-types/should_fail/T3330a.stderr
testsuite/tests/indexed-types/should_fail/T4174.stderr
testsuite/tests/indexed-types/should_fail/T8227.stderr
testsuite/tests/indexed-types/should_fail/T9662.stderr
testsuite/tests/module/mod40.stderr
testsuite/tests/partial-sigs/should_compile/ExtraConstraints1.stderr
testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr
testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr
testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr
testsuite/tests/partial-sigs/should_fail/T10999.stderr
testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr
testsuite/tests/perf/haddock/all.T
testsuite/tests/pmcheck/should_compile/T3927b.hs
testsuite/tests/polykinds/T7332.hs
testsuite/tests/polykinds/T7594.hs
testsuite/tests/polykinds/T7594.stderr
testsuite/tests/polykinds/T9017.stderr
testsuite/tests/simplCore/should_compile/T4398.stderr
testsuite/tests/typecheck/should_compile/T10100.hs
testsuite/tests/typecheck/should_compile/T10109.hs
testsuite/tests/typecheck/should_compile/T10564.hs
testsuite/tests/typecheck/should_compile/T9834.stderr
testsuite/tests/typecheck/should_compile/tc256.hs
testsuite/tests/typecheck/should_fail/T2714.stderr
testsuite/tests/typecheck/should_fail/T5853.stderr
testsuite/tests/typecheck/should_fail/T7869.stderr
testsuite/tests/typecheck/should_fail/T8883.stderr
testsuite/tests/typecheck/should_fail/T9415.stderr
testsuite/tests/typecheck/should_fail/T9739.stderr
testsuite/tests/typecheck/should_fail/tcfail027.stderr
testsuite/tests/typecheck/should_fail/tcfail216.hs
testsuite/tests/typecheck/should_fail/tcfail216.stderr
testsuite/tests/typecheck/should_fail/tcfail217.hs
testsuite/tests/typecheck/should_fail/tcfail217.stderr