Skip to content

Restructure the zonker

sheaf requested to merge sheaf/ghc:T23351 into master

This MR refactors and splits up the zonker into a few separate components, described in Note [The structure of the zonker] in GHC.Tc.Zonk.Type.

  1. GHC.Tc.Zonk.Monad introduces a pared-down TcM monad, ZonkM, which has enough information for zonking types.
    This allows us to refactor ErrCtxt to use ZonkM instead of TcM, which guarantees we don't throw an error while reporting an error.

  2. GHC.Tc.Zonk.Env is the new home of ZonkEnv, and also defines two zonking monad transformers, ZonkT and ZonkBndrT.
    ZonkT is a reader monad transformer over ZonkEnv.
    ZonkBndrT m is the codensity monad over ZonkT m.

    ZonkBndrT is used for computations that accumulate binders in the ZonkEnv.

  3. GHC.Tc.Zonk.TcType contains the code for zonking types, for use in the typechecker. It uses the ZonkM monad.

  4. GHC.Tc.Zonk.Type contains the code for final zonking to Type, which has been refactored to use ZonkTcM = ZonkT TcM and ZonkBndrTcM = ZonkBndrT TcM.

Edited by sheaf

Merge request reports