Commit cdfe9b08 authored by mnislaih's avatar mnislaih

Dont tidy up tyvars after :print type reconstruction

I introduced a bug yesterday when I changed the way tidying up was performed.
As a result of tidying,  cvObtainTerm could be returning types 
with regular tyvars inside, which never should.

But actually, it's better if we do not do the tidying up, in order to 
keep the tyvar names from the environment.
New names will be introduced only when an existential is found, which
is not so common. In this case the user will see a funny name. 
Is that really an issue?
parent f1915bd7
......@@ -472,31 +472,7 @@ instScheme ty | (tvs, rho) <- tcSplitForAllTys ty = liftTcM$ do
return (ty', zipTopTvSubst tvs' (mkTyVarTys tvs))
cvObtainTerm :: HscEnv -> Bool -> Maybe Type -> HValue -> IO Term
cvObtainTerm hsc_env force mb_ty a = do
-- Obtain the term and tidy the type before returning it
term <- cvObtainTerm1 hsc_env force mb_ty a
let term' = tidyTypes term
return term'
where allvars = nub . foldTerm TermFold {
fTerm = \ty _ _ tt ->
varEnvElts(tyVarsOfType ty) ++ concat tt,
fSuspension = \_ mb_ty _ _ ->
maybe [] (varEnvElts . tyVarsOfType) mb_ty,
fPrim = \ _ _ -> [] }
tidyTypes term = let
go = foldTerm idTermFold {
fTerm = \ty dc hval tt ->
Term (tidy ty) dc hval tt,
fSuspension = \ct mb_ty hval n ->
Suspension ct (fmap tidy mb_ty) hval n }
tidy ty = tidyType (emptyTidyOccEnv, tidyVarEnv) ty
tidyVarEnv = mkVarEnv$
[ (v, alpha_tv `setTyVarUnique` varUnique v)
| (alpha_tv,v) <- zip alphaTyVars (allvars term)]
in go term
cvObtainTerm1 :: HscEnv -> Bool -> Maybe Type -> HValue -> IO Term
cvObtainTerm1 hsc_env force mb_ty hval = runTR hsc_env $ do
cvObtainTerm hsc_env force mb_ty hval = runTR hsc_env $ do
tv <- liftM mkTyVarTy (newVar argTypeKind)
case mb_ty of
Nothing -> go tv tv hval
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment