Skip to content

Don't replace type family applications with flattening variables

Richard Eisenberg requested to merge wip/cfuneqcan-refactor into master

This large patch simplifies the flattener used during constraint solving. Instead of creating flattening-metavariables (fmvs) and flattening-skolems (fsks), this just reduces type family applications directly. The biggest challenge is that, now, we need to be able to rewrite type family applications, not just variables. Still, this is a nice net win over the previous state of things.

Looking at the lines of this patch, the majority are just module shufflings. This was made necessary by moving the core flattener (distinct from the type-inference flattener) from FamInstEnv into Unify. The change is necessary because we now use the core flattener when looking up class instances, too (to detect that e.g. C [a] "unifies" with C [F b]). Sadly, moving the core flattener also required breaking up GHC.Core.Map into GHC.Core.Map and GHC.Core.Map.Type, avoiding module cycles with GHC.Core.

A good place to start is in GHC.Tc.Types.Constraint, where the new CEqCan canonical constraint is introduced, along with CanEqLHS, where the latter is a new datatype that represents either a variable or a type family application.

Edited by Richard Eisenberg

Merge request reports