+\begin{code}
+isTyVar, isMutTyVar :: Var -> Bool
+isId, isLocalVar, isLocalId :: Var -> Bool
+isGlobalId, isExportedId, isSpecPragmaId :: Var -> Bool
+mustHaveLocalBinding :: Var -> Bool
+
+isTyVar var = case varDetails var of
+ TyVar -> True
+ MutTyVar _ _ -> True
+ other -> False
+
+isMutTyVar (Var {varDetails = MutTyVar _ _}) = True
+isMutTyVar other = False
+
+
+isId var = case varDetails var of
+ LocalId _ -> True
+ GlobalId _ -> True
+ other -> False
+
+isLocalId var = case varDetails var of
+ LocalId _ -> True
+ other -> False
+
+-- isLocalVar returns True for type variables as well as local Ids
+-- These are the variables that we need to pay attention to when finding free
+-- variables, or doing dependency analysis.
+isLocalVar var = case varDetails var of
+ LocalId _ -> True
+ TyVar -> True
+ MutTyVar _ _ -> True
+ other -> False
+
+-- mustHaveLocalBinding returns True of Ids and TyVars
+-- that must have a binding in this module. The converse
+-- is not quite right: there are some GlobalIds that must have
+-- bindings, such as record selectors. But that doesn't matter,
+-- because it's only used for assertions
+mustHaveLocalBinding var = isLocalVar var
+
+isGlobalId var = case varDetails var of
+ GlobalId _ -> True
+ other -> False
+
+-- isExportedId means "don't throw this away"
+isExportedId var = case varDetails var of
+ LocalId Exported -> True
+ LocalId SpecPragma -> True
+ GlobalId _ -> True
+ other -> False
+
+isSpecPragmaId var = case varDetails var of
+ LocalId SpecPragma -> True
+ other -> False