+mapTermType f = foldTerm idTermFold {
+ fTerm = \ty dc hval tt -> Term (f ty) dc hval tt,
+ fSuspension = \ct mb_ty hval n ->
+ Suspension ct (fmap f mb_ty) hval n }
+
+termTyVars = foldTerm TermFold {
+ fTerm = \ty _ _ tt ->
+ tyVarsOfType ty `plusVarEnv` concatVarEnv tt,
+ fSuspension = \_ mb_ty _ _ ->
+ maybe emptyVarEnv tyVarsOfType mb_ty,
+ fPrim = \ _ _ -> emptyVarEnv }
+ where concatVarEnv = foldr plusVarEnv emptyVarEnv