Skip to content
Snippets Groups Projects
Commit bb3fa2d1 authored by Artem Pelenitsyn's avatar Artem Pelenitsyn Committed by Ben Gamari
Browse files

Less Tc inside simplCore (Phase 1 for #14391)

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).

Details
=======

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
refactoring.

Reviewers: simonpj, nomeata, bgamari, hvr

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14391

Differential Revision: https://phabricator.haskell.org/D4503
parent bb338f2e
No related branches found
No related tags found
No related merge requests found
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