Tidy up treatment of FlexibleContexts
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 30 Apr 2015 08:18:49 +0000 (09:18 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Thu, 30 Apr 2015 08:22:20 +0000 (09:22 +0100)
commitb83160d07e626bee685f329a9a73e90a4a6074ae
treeaba7948b3d73a3b05db887da48905fec73c62e69
parent54cefbd753b516fe8645c1470750ad7f65352844
Tidy up treatment of FlexibleContexts

Previously (Trac #10351) we could get

    Non type-variable argument in the constraint: C [t]
    (Use FlexibleContexts to permit this)
    When checking that `f' has the inferred type
      f :: forall t. C [t] => t -> ()

which is a bit stupid: we have *inferred* a type that we
immediately *reject*.  This patch arranges that that the
generalisation mechanism (TcSimplify.decideQuantification)
doesn't pick a predicate that will be rejected by the
subsequent validity check.

This forced some minor refactoring, as usual.
compiler/main/DynFlags.hs
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcValidity.hs
testsuite/tests/typecheck/should_fail/T10351.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T10351.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T6022.stderr
testsuite/tests/typecheck/should_fail/T8883.stderr
testsuite/tests/typecheck/should_fail/all.T
testsuite/tests/typecheck/should_fail/tcfail108.stderr