Skip to content
  • Richard Eisenberg's avatar
    Remove decideKindGeneralisationPlan · c955a514
    Richard Eisenberg authored
    TypeInType came with a new function: decideKindGeneralisationPlan.
    This type-level counterpart to the term-level decideGeneralisationPlan
    chose whether or not a kind should be generalized. The thinking was
    that if `let` should not be generalized, then kinds shouldn't either
    (under the same circumstances around -XMonoLocalBinds).
    
    However, this is too conservative -- the situation described in the
    motivation for "let should be be generalized" does not occur in types.
    
    This commit thus removes decideKindGeneralisationPlan, always
    generalizing.
    
    One consequence is that tc_hs_sig_type_and_gen no longer calls
    solveEqualities, which reports all unsolved constraints, instead
    relying on the solveLocalEqualities in tcImplicitTKBndrs. An effect
    of this is that reporing kind errors gets delayed more frequently.
    This seems to be a net benefit in error reporting; often, alongside
    a kind error, the type error is now reported (and users might find
    type errors easier to understand).
    
    Some of these errors ended up at the top level, where it was
    discovered that the GlobalRdrEnv containing the definitions in the
    local module was not in the TcGblEnv, and thus errors were reported
    with qualified names unnecessarily. This commit rejiggers some of
    the logic around captureTopConstraints accordingly.
    
    One error message (typecheck/should_fail/T1633)
    is a regression, mentioning the name of a default method. However,
    that problem is already reported as #10087, its solution is far from
    clear, and so I'm not addressing it here.
    
    This commit fixes #15141. As it's an internal refactor, there is
    no concrete test case for it.
    
    Along the way, we no longer need the hsib_closed field of
    HsImplicitBndrs (it was used only in decideKindGeneralisationPlan)
    and so it's been removed, simplifying the datatype structure.
    
    Along the way, I removed code in the validity checker that looks
    at coercions. This isn't related to this patch, really (though
    it was, at one point), but it's an improvement, so I kept it.
    
    This updates the haddock submodule.
    c955a514