%
+% (c) The University of Glasgow 2006
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section{@Vars@: Variables}
setVarName, setVarUnique,
-- TyVars
- TyVar, mkTyVar, mkTcTyVar,
+ 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
- )
-import Unique ( Unique, Uniquable(..), mkUniqueGrimily, getKey# )
+import {-# SOURCE #-} IdInfo( GlobalIdDetails, notGlobalId,
+ IdInfo, seqIdInfo )
+#ifdef DEBUG
+import {-# SOURCE #-} TypeRep( isCoercionKind )
+#endif
+
+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
\begin{code}
mkTyVar :: Name -> Kind -> TyVar
-mkTyVar name kind = TyVar { varName = name
+mkTyVar name kind = ASSERT( not (isCoercionKind kind ) )
+ TyVar { varName = name
, realUnique = getKey# (nameUnique name)
, tyVarKind = kind
+ , isCoercionVar = False
}
mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar
mkTcTyVar name kind details
- = TcTyVar { varName = name,
+ = ASSERT( not (isCoercionKind kind) )
+ TcTyVar { varName = name,
realUnique = getKey# (nameUnique name),
tyVarKind = kind,
tcTyVarDetails = details
setCoVarName = setVarName
mkCoVar :: Name -> Kind -> CoVar
-mkCoVar name kind = mkTyVar name kind
+mkCoVar name kind = ASSERT( isCoercionKind kind )
+ TyVar { varName = name
+ , realUnique = getKey# (nameUnique name)
+ , tyVarKind = kind
+ , isCoercionVar = True
+ }
-isCoVar :: TyVar -> Bool
-isCoVar ty = isCoSuperKind (tyVarKind ty)
+mkWildCoVar :: Kind -> TyVar
+-- A type variable that is never referred to,
+-- so its unique doesn't matter
+mkWildCoVar kind
+ = ASSERT( isCoercionKind kind )
+ TyVar { varName = mkSysTvName wild_uniq FSLIT("co_wild"),
+ realUnique = _ILIT(1),
+ tyVarKind = kind,
+ isCoercionVar = True }
+ where
+ wild_uniq = mkBuiltinUnique 1
\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.