Skip to content
Snippets Groups Projects
Commit 5d65393e authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Marge Bot
Browse files

Remove the Core flattener

This big MR entirely removes the "flattener" that took a type and
replaced each type-family application with a fresh type variable.
The flattener had its origin in the paper
     Injective type families for Haskell

But (a) #25657 showed that flattening doesn't really work.
    (b) since we wrote the paper we have introduced the so-called
        "fine-grained" unifier GHC.Core.Unify, which can return
                 * SurelyApart
                 * Unifiable subst
                 * MaybeApart subst
        where the MaybeApart says that the two types are not unifiable by a
        substitution, but could (perhaps) be unified "later" after some type
        family reductions.  This turns out to subsume flattening.

This MR does a major refactor of GHC.Core.Unify to make it capable of
subsuming flattening.   The main payload is described in
       Note [Apartness and type families]
and its many wrinkles.

The key (non-refactoring) implementation change is to add `um_fam_env`
to the `UMState` in the unification monad.

Careful review with Richard revealed various bugs in the treament of
`kco`, the kind coercion carried around by the unifier, so that is
substantially fixed too: see Note [Kind coercions in Unify].

Compile-time performance is improved by 0.1% with a few improvements over
1% and one worsening by 1.3% namely T9872a.  (I have not investigated the
latter.)

Metric Decrease:
    T9872b
    T9872c
    TcPlugin_RewritePerf
Metric Increase:
    T9872a
parent 25d46547
No related branches found
No related tags found
Loading
Showing
with 1457 additions and 1267 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment