-- Then, we extract a substitution,
-- mapping the old tyvars to the reconstructed types.
let Just reconstructed_type = termType term
- subst = computeRTTIsubst (idType id) (reconstructed_type)
+ subst = unifyRTTI (idType id) (reconstructed_type)
return (term',subst)
tidyTermTyVars :: Session -> Term -> IO Term
termTyVars,
-- unsafeDeepSeq,
cvReconstructType,
- computeRTTIsubst,
+ unifyRTTI,
sigmaType,
Closure(..),
getClosureData,
isFullyEvaluatedTerm _ = False
instance Outputable (Term) where
- ppr = head . cPprTerm cPprTermBase
+ ppr t | Just doc <- cPprTerm cPprTermBase t = doc
+ | otherwise = panic "Outputable Term instance"
-------------------------------------------------------------------------
-- Runtime Closure Datatype and functions for retrieving closure related stuff
type TermPrinter = Precedence -> Term -> SDoc
type TermPrinterM m = Precedence -> Term -> m SDoc
-app_prec,cons_prec ::Int
-app_prec = 10
+app_prec,cons_prec, max_prec ::Int
+max_prec = 10
+app_prec = max_prec
cons_prec = 5 -- TODO Extract this info from GHC itself
pprTerm :: TermPrinter -> TermPrinter
| Just (tc,_) <- splitNewTyConApp_maybe ty
, ASSERT(isNewTyCon tc) True
, Just new_dc <- maybeTyConSingleCon tc = do
- real_term <- y 10 t
+ real_term <- y max_prec t
return$ cparen (p >= app_prec) (ppr new_dc <+> real_term)
pprNewtypeWrap _ _ _ = panic "pprNewtypeWrap"
coerceShow f _p = return . text . show . f . unsafeCoerce# . val
- --NOTE pprinting of list terms is not lazy
+ --Note pprinting of list terms is not lazy
doList p h t = do
let elems = h : getListTerms t
isConsLast = termType(last elems) /= termType h
-- is that the former are _not_ polymorphic, thus polymorphism must
-- be stripped. Syntactically, forall's must be stripped.
-- We also remove predicates.
-computeRTTIsubst :: Type -> Type -> TvSubst
-computeRTTIsubst ty rtti_ty =
+unifyRTTI :: Type -> Type -> TvSubst
+unifyRTTI ty rtti_ty =
case mb_subst of
Just subst -> subst
Nothing -> pprPanic "Failed to compute a RTTI substitution"
tys <- reconstructType hsc_env 10 `mapM` incompletelyTypedIds
-- map termType `fmap` (obtainTerm hsc_env False `mapM` incompletelyTypedIds)
- let substs = [computeRTTIsubst ty ty'
+ let substs = [unifyRTTI ty ty'
| (ty, Just ty') <- zip (map idType incompletelyTypedIds) tys]
ic' = foldr (flip substInteractiveContext) ic
(map skolemiseSubst substs)