import Maybes ( maybeToBool )
import PrimRep ( PrimRep(..), isFollowableRep )
import Unique -- quite a few *Keys
-import Util ( thenCmp, mapAccumL )
+import Util ( thenCmp, mapAccumL, seqList, ($!) )
import Outputable
\end{code}
A type is
*unboxed* iff its representation is other than a pointer
- Unboxed types cannot instantiate a type variable
+ Unboxed types cannot instantiate a type variable.
Unboxed types are always unlifted.
*lifted* A type is lifted iff it has bottom as an element.
subst_ty tenv tset ty
= go ty
where
- go (TyConApp tc tys) = TyConApp tc (map go tys)
- go (NoteTy (SynNote ty1) ty2) = NoteTy (SynNote (go ty1)) (go ty2)
+ go (TyConApp tc tys) = let args = map go tys
+ in args `seqList` TyConApp tc args
+ go (NoteTy (SynNote ty1) ty2) = NoteTy (SynNote $! (go ty1)) $! (go ty2)
go (NoteTy (FTVNote _) ty2) = go ty2 -- Discard the free tyvar note
- go (FunTy arg res) = FunTy (go arg) (go res)
- go (AppTy fun arg) = mkAppTy (go fun) (go arg)
+ go (FunTy arg res) = (FunTy $! (go arg)) $! (go res)
+ go (AppTy fun arg) = mkAppTy (go fun) $! (go arg)
go ty@(TyVarTy tv) = case (lookupVarEnv tenv tv) of
Nothing -> ty
Just ty' -> ty'
go (ForAllTy tv ty) = case substTyVar tenv tset tv of
- (tenv', tset', tv') -> ForAllTy tv' (subst_ty tenv' tset' ty)
+ (tenv', tset', tv') -> ForAllTy tv' $! (subst_ty tenv' tset' ty)
substTyVar :: TyVarSubst -> TyVarSet -> TyVar
-> (TyVarSubst, TyVarSet, TyVar)
go (TyVarTy tv) = case lookupVarEnv subst tv of
Nothing -> TyVarTy tv
Just tv' -> TyVarTy tv'
- go (TyConApp tycon tys) = TyConApp tycon (map go tys)
- go (NoteTy note ty) = NoteTy (go_note note) (go ty)
- go (AppTy fun arg) = AppTy (go fun) (go arg)
- go (FunTy fun arg) = FunTy (go fun) (go arg)
- go (ForAllTy tv ty) = ForAllTy tv' (tidyType env' ty)
+ go (TyConApp tycon tys) = let args = map go tys
+ in args `seqList` TyConApp tycon args
+ go (NoteTy note ty) = (NoteTy $! (go_note note)) $! (go ty)
+ go (AppTy fun arg) = (AppTy $! (go fun)) $! (go arg)
+ go (FunTy fun arg) = (FunTy $! (go fun)) $! (go arg)
+ go (ForAllTy tv ty) = ForAllTy tv' $! (tidyType env' ty)
where
(env', tv') = tidyTyVar env tv
- go_note (SynNote ty) = SynNote (go ty)
+ go_note (SynNote ty) = SynNote $! (go ty)
go_note note@(FTVNote ftvs) = note -- No need to tidy the free tyvars
tidyTypes env tys = map (tidyType env) tys