• Artem Pelenitsyn's avatar
    Less Tc inside simplCore (Phase 1 for #14391) · bb3fa2d1
    Artem Pelenitsyn authored
    Simplifier depends on typechecker in two points: `thNameToGhcName`
    (`lookupThName_maybe`, in particular)  and `lookupGlobal`. We want to
    cut the ties in two steps.
    1. (Presented in this commit), reimplement both functions in a way that
    doesn't use typechecker.
    2. (Should follow), do code moving: a) `lookupGlobal` should go in some
    typechecker-free place; b) `thNameToGhcName` should leave simplifier,
    because it is not used there at all (probably, it should be placed
    somewhere where `GhcPlugins` can see it -- this is suggested by Joachim
    on Trac).
    We redesigned lookup interface a bit so that it exposes some
    `IO`-equivalents of `Tc`-features in use.
    First, `CoreMonad.hs` still calls `lookupGlobal` which is no longer
    bound to the typechecker monad, but still resides in `TcEnv.hs` — it
    should be moved out of Tc-land at some point (“Phase 2”) in the
    future in order to achieve its part of the #14391's goal.
    Second, `lookupThName_maybe` is eliminated from `CoreMonad.hs`
    completely; this already achieves its part of the goal of #14391. Its
    client, though, `thNameToGhcName`, is better to be moved in the future
    also, for it is not used in the `CoreMonad.hs` (or anywhere else)
    anyway. Joachim suggested “any module reexported by GhcPlugins (or
    maybe even that module itself)”.
    As a side goal, we removed `initTcForLookup` which was instrumental for
    the past version of `lookupGlobal`. This, in turn, called for pushing
    some more parts of the lookup interface from the `Tc`-monad to `IO`,
    most notably, adding `IO`-version of `lookupOrig` and pushing
    `dataConInfoPtrToName` to `IO`. The `lookupOrig` part, in turn,
    triggered a slight redesign of name cache updating interface: we now
    have both, `updNameCacheIO` and `updNameCacheTc`, both accepting `mod`
    and `occ` to force them inside, instead of more error-prone outside
    before. But all these hardly have to do anything with #14391, mere
    Reviewers: simonpj, nomeata, bgamari, hvr
    Reviewed By: simonpj, bgamari
    Subscribers: rwbarton, thomie, carter
    GHC Trac Issues: #14391
    Differential Revision: https://phabricator.haskell.org/D4503
DebuggerUtils.hs 5.02 KB