Skip to content
  • sheaf's avatar
    Restructure the zonker · f62d8195
    sheaf authored and Marge Bot's avatar Marge Bot committed
    This commit 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`.
    
    Allocations slightly decrease on the whole due to using
    continuation-passing style instead of manual state passing of ZonkEnv
    in the final zonking to Type.
    
    -------------------------
    Metric Decrease:
        T4029
        T8095
        T14766
        T15304
        hard_hole_fits
        RecordUpdPerf
    Metric Increase:
        T10421
    -------------------------
    f62d8195