summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorArtem Pelenitsyn <a.pelenitsyn@gmail.com>2018-05-15 18:07:23 -0400
committerBen Gamari <ben@smart-cactus.org>2018-05-15 18:07:52 -0400
commitbb3fa2d18686d0c08b57c66a90a9ea1b4e4482ee (patch)
tree648d88b43e0c03bf78f77ecb81ff42fb441c20fc /testsuite
parentbb338f2eb706a3137bf6675e3ddbf96d4fe4f4aa (diff)
downloadhaskell-bb3fa2d18686d0c08b57c66a90a9ea1b4e4482ee.tar.gz
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
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/ghc-api/T4891/T4891.hs15
1 files changed, 6 insertions, 9 deletions
diff --git a/testsuite/tests/ghc-api/T4891/T4891.hs b/testsuite/tests/ghc-api/T4891/T4891.hs
index b2f8cc464d..4aa4842640 100644
--- a/testsuite/tests/ghc-api/T4891/T4891.hs
+++ b/testsuite/tests/ghc-api/T4891/T4891.hs
@@ -54,13 +54,10 @@ chaseConstructor !hv = do
case tipe closure of
Indirection _ -> chaseConstructor (ptrs closure ! 0)
Constr -> do
- withSession $ \hscEnv -> liftIO $ initTcForLookup hscEnv $ do
- eDcname <- dataConInfoPtrToName (infoPtr closure)
- case eDcname of
- Left _ -> return ()
- Right dcName -> do
- liftIO $ putStrLn $ "Name: " ++ showPpr dflags dcName
- liftIO $ putStrLn $ "OccString: " ++ "'" ++ getOccString dcName ++ "'"
- dc <- tcLookupDataCon dcName
- liftIO $ putStrLn $ "DataCon: " ++ showPpr dflags dc
+ withSession $ \hscEnv -> liftIO $ do
+ dcName <- dataConInfoPtrToName hscEnv (infoPtr closure)
+ putStrLn $ "Name: " ++ showPpr dflags dcName
+ putStrLn $ "OccString: " ++ "'" ++ getOccString dcName ++ "'"
+ dc <- ioLookupDataCon hscEnv dcName
+ putStrLn $ "DataCon: " ++ showPpr dflags dc
_ -> return ()