+rttiEnvironment :: HscEnv -> IO HscEnv
+rttiEnvironment hsc_env@HscEnv{hsc_IC=ic} = do
+ let InteractiveContext{ic_tmp_ids=tmp_ids} = ic
+ incompletelyTypedIds =
+ [id | id <- tmp_ids
+ , not $ null [v | v <- varSetElems$ tyVarsOfType (idType id)
+ , isSkolemTyVar v]
+ , (occNameFS.nameOccName.idName) id /= result_fs]
+ tys <- reconstructType hsc_env 10 `mapM` incompletelyTypedIds
+ -- map termType `fmap` (obtainTerm hsc_env False `mapM` incompletelyTypedIds)
+
+ improvs <- sequence [improveRTTIType hsc_env ty ty'
+ | (ty, Just ty') <- zip (map idType incompletelyTypedIds) tys]
+ let ic' = foldr (\mb_subst ic' ->
+ maybe (WARN(True, text ("RTTI failed to calculate the "
+ ++ "improvement for a type")) ic')
+ (substInteractiveContext ic' . skolemiseSubst)
+ mb_subst)
+ ic
+ improvs
+ return hsc_env{hsc_IC=ic'}
+
+skolemiseSubst :: TvSubst -> TvSubst
+skolemiseSubst subst = subst `setTvSubstEnv`
+ mapVarEnv (fst.skolemiseTy) (getTvSubstEnv subst)
+