%
+% (c) The University of Glasgow 2006
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section{@Vars@: Variables}
setVarName, setVarUnique,
-- TyVars
- TyVar, mkTyVar, mkTcTyVar, mkWildTyVar,
+ TyVar, mkTyVar, mkTcTyVar, mkWildCoVar,
tyVarName, tyVarKind,
setTyVarName, setTyVarUnique, setTyVarKind,
tcTyVarDetails,
Id, DictId,
idName, idType, idUnique, idInfo, modifyIdInfo, maybeModifyIdInfo,
setIdName, setIdUnique, setIdType, setIdInfo, lazySetIdInfo,
- setIdExported, setIdNotExported,
+ setIdExported, setIdNotExported,
globalIdDetails, globaliseId,
#include "HsVersions.h"
-import {-# SOURCE #-} TypeRep( Type, Kind, isCoSuperKind )
+import {-# SOURCE #-} TypeRep( Type, Kind )
import {-# SOURCE #-} TcType( TcTyVarDetails, pprTcTyVarDetails )
-import {-# SOURCE #-} IdInfo( GlobalIdDetails, notGlobalId, IdInfo, seqIdInfo )
-
-import Name ( Name, NamedThing(..),
- setNameUnique, nameUnique, mkSysTvName
- )
-import Unique ( Unique, Uniquable(..), mkUniqueGrimily, getKey#,
- mkBuiltinUnique )
+import {-# SOURCE #-} IdInfo( GlobalIdDetails, notGlobalId,
+ IdInfo, seqIdInfo )
+import Name hiding (varName)
+import Unique
import FastTypes
-import Outputable
+import FastString
+import Outputable
\end{code}
realUnique :: FastInt, -- Key for fast comparison
-- Identical to the Unique in the name,
-- cached here for speed
- tyVarKind :: Kind }
+ tyVarKind :: Kind,
+ isCoercionVar :: Bool
+ }
| TcTyVar { -- Used only during type inference
-- Used for kind variables during
mkTyVar name kind = TyVar { varName = name
, realUnique = getKey# (nameUnique name)
, tyVarKind = kind
+ , isCoercionVar = False
}
mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar
tcTyVarDetails = details
}
-mkWildTyVar :: Kind -> TyVar
-mkWildTyVar kind
+mkWildCoVar :: Kind -> TyVar
+-- A type variable that is never referred to,
+-- so its unique doesn't matter
+mkWildCoVar kind
= TyVar { varName = mkSysTvName wild_uniq FSLIT("co_wild"),
realUnique = _ILIT(1),
- tyVarKind = kind }
+ tyVarKind = kind,
+ isCoercionVar = True }
where
- wild_uniq = (mkBuiltinUnique 1)
+ wild_uniq = mkBuiltinUnique 1
\end{code}
%************************************************************************
setCoVarName = setVarName
mkCoVar :: Name -> Kind -> CoVar
-mkCoVar name kind = mkTyVar name kind
+mkCoVar name kind = TyVar { varName = name
+ , realUnique = getKey# (nameUnique name)
+ , tyVarKind = kind
+ , isCoercionVar = True
+ }
-isCoVar :: TyVar -> Bool
-isCoVar ty = isCoSuperKind (tyVarKind ty)
\end{code}
%************************************************************************
isLocalId (LocalId {}) = True
isLocalId other = False
+isCoVar (v@(TyVar {})) = isCoercionVar v
+isCoVar 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.