[GHC] #14391: Make the simplifier independent of the typechecker

GHC ghc-devs at haskell.org
Tue May 15 23:37:44 UTC 2018


#14391: Make the simplifier independent of the typechecker
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                Owner:  ulysses4ever
            Type:  task              |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.3
      Resolution:                    |             Keywords:  newcomer
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4503
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"bb3fa2d18686d0c08b57c66a90a9ea1b4e4482ee/ghc"
 bb3fa2d1/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="bb3fa2d18686d0c08b57c66a90a9ea1b4e4482ee"
 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
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14391#comment:26>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list