ghc-6.12.3: The GHC APISource codeContentsIndex
VarEnv
Contents
Var, Id and TyVar environments (maps)
Manipulating these environments
The InScopeSet type
Operations on InScopeSets
The RnEnv2 type
Operations on RnEnv2s
TidyEnv and its operation
Synopsis
type VarEnv elt = UniqFM elt
type IdEnv elt = VarEnv elt
type TyVarEnv elt = VarEnv elt
emptyVarEnv :: VarEnv a
unitVarEnv :: Var -> a -> VarEnv a
mkVarEnv :: [(Var, a)] -> VarEnv a
elemVarEnv :: Var -> VarEnv a -> Bool
varEnvElts :: VarEnv a -> [a]
varEnvKeys :: VarEnv a -> [Unique]
extendVarEnv :: VarEnv a -> Var -> a -> VarEnv a
extendVarEnv_C :: (a -> a -> a) -> VarEnv a -> Var -> a -> VarEnv a
extendVarEnvList :: VarEnv a -> [(Var, a)] -> VarEnv a
plusVarEnv :: VarEnv a -> VarEnv a -> VarEnv a
plusVarEnv_C :: (a -> a -> a) -> VarEnv a -> VarEnv a -> VarEnv a
delVarEnvList :: VarEnv a -> [Var] -> VarEnv a
delVarEnv :: VarEnv a -> Var -> VarEnv a
lookupVarEnv :: VarEnv a -> Var -> Maybe a
lookupVarEnv_NF :: VarEnv a -> Var -> a
lookupWithDefaultVarEnv :: VarEnv a -> a -> Var -> a
mapVarEnv :: (a -> b) -> VarEnv a -> VarEnv b
zipVarEnv :: [Var] -> [a] -> VarEnv a
modifyVarEnv :: (a -> a) -> VarEnv a -> Var -> VarEnv a
modifyVarEnv_Directly :: (a -> a) -> UniqFM a -> Unique -> UniqFM a
isEmptyVarEnv :: VarEnv a -> Bool
foldVarEnv :: (a -> b -> b) -> b -> VarEnv a -> b
elemVarEnvByKey :: Unique -> VarEnv a -> Bool
lookupVarEnv_Directly :: VarEnv a -> Unique -> Maybe a
filterVarEnv_Directly :: (Unique -> a -> Bool) -> VarEnv a -> VarEnv a
restrictVarEnv :: VarEnv a -> VarSet -> VarEnv a
data InScopeSet
emptyInScopeSet :: InScopeSet
mkInScopeSet :: VarEnv Var -> InScopeSet
delInScopeSet :: InScopeSet -> Var -> InScopeSet
extendInScopeSet :: InScopeSet -> Var -> InScopeSet
extendInScopeSetList :: InScopeSet -> [Var] -> InScopeSet
extendInScopeSetSet :: InScopeSet -> VarEnv Var -> InScopeSet
getInScopeVars :: InScopeSet -> VarEnv Var
lookupInScope :: InScopeSet -> Var -> Maybe Var
elemInScopeSet :: Var -> InScopeSet -> Bool
uniqAway :: InScopeSet -> Var -> Var
data RnEnv2
mkRnEnv2 :: InScopeSet -> RnEnv2
rnBndr2 :: RnEnv2 -> Var -> Var -> RnEnv2
rnBndrs2 :: RnEnv2 -> [Var] -> [Var] -> RnEnv2
rnOccL :: RnEnv2 -> Var -> Var
rnOccR :: RnEnv2 -> Var -> Var
inRnEnvL :: RnEnv2 -> Var -> Bool
inRnEnvR :: RnEnv2 -> Var -> Bool
rnBndrL :: RnEnv2 -> Var -> (RnEnv2, Var)
rnBndrR :: RnEnv2 -> Var -> (RnEnv2, Var)
nukeRnEnvL :: RnEnv2 -> RnEnv2
nukeRnEnvR :: RnEnv2 -> RnEnv2
extendRnInScopeList :: RnEnv2 -> [Var] -> RnEnv2
rnInScope :: Var -> RnEnv2 -> Bool
rnInScopeSet :: RnEnv2 -> InScopeSet
lookupRnInScope :: RnEnv2 -> Var -> Var
type TidyEnv = (TidyOccEnv, VarEnv Var)
emptyTidyEnv :: TidyEnv
Var, Id and TyVar environments (maps)
type VarEnv elt = UniqFM eltSource
type IdEnv elt = VarEnv eltSource
type TyVarEnv elt = VarEnv eltSource
Manipulating these environments
emptyVarEnv :: VarEnv aSource
unitVarEnv :: Var -> a -> VarEnv aSource
mkVarEnv :: [(Var, a)] -> VarEnv aSource
elemVarEnv :: Var -> VarEnv a -> BoolSource
varEnvElts :: VarEnv a -> [a]Source
varEnvKeys :: VarEnv a -> [Unique]Source
extendVarEnv :: VarEnv a -> Var -> a -> VarEnv aSource
extendVarEnv_C :: (a -> a -> a) -> VarEnv a -> Var -> a -> VarEnv aSource
extendVarEnvList :: VarEnv a -> [(Var, a)] -> VarEnv aSource
plusVarEnv :: VarEnv a -> VarEnv a -> VarEnv aSource
plusVarEnv_C :: (a -> a -> a) -> VarEnv a -> VarEnv a -> VarEnv aSource
delVarEnvList :: VarEnv a -> [Var] -> VarEnv aSource
delVarEnv :: VarEnv a -> Var -> VarEnv aSource
lookupVarEnv :: VarEnv a -> Var -> Maybe aSource
lookupVarEnv_NF :: VarEnv a -> Var -> aSource
lookupWithDefaultVarEnv :: VarEnv a -> a -> Var -> aSource
mapVarEnv :: (a -> b) -> VarEnv a -> VarEnv bSource
zipVarEnv :: [Var] -> [a] -> VarEnv aSource
modifyVarEnv :: (a -> a) -> VarEnv a -> Var -> VarEnv aSource
modifyVarEnv_Directly :: (a -> a) -> UniqFM a -> Unique -> UniqFM aSource
isEmptyVarEnv :: VarEnv a -> BoolSource
foldVarEnv :: (a -> b -> b) -> b -> VarEnv a -> bSource
elemVarEnvByKey :: Unique -> VarEnv a -> BoolSource
lookupVarEnv_Directly :: VarEnv a -> Unique -> Maybe aSource
filterVarEnv_Directly :: (Unique -> a -> Bool) -> VarEnv a -> VarEnv aSource
restrictVarEnv :: VarEnv a -> VarSet -> VarEnv aSource
The InScopeSet type
data InScopeSet Source
A set of variables that are in scope at some point
show/hide Instances
Operations on InScopeSets
emptyInScopeSet :: InScopeSetSource
mkInScopeSet :: VarEnv Var -> InScopeSetSource
delInScopeSet :: InScopeSet -> Var -> InScopeSetSource
extendInScopeSet :: InScopeSet -> Var -> InScopeSetSource
extendInScopeSetList :: InScopeSet -> [Var] -> InScopeSetSource
extendInScopeSetSet :: InScopeSet -> VarEnv Var -> InScopeSetSource
getInScopeVars :: InScopeSet -> VarEnv VarSource
lookupInScope :: InScopeSet -> Var -> Maybe VarSource
Look up a variable the InScopeSet. This lets you map from the variable's identity (unique) to its full value.
elemInScopeSet :: Var -> InScopeSet -> BoolSource
uniqAway :: InScopeSet -> Var -> VarSource
uniqAway in_scope v finds a unique that is not used in the in-scope set, and gives that to v.
The RnEnv2 type
data RnEnv2 Source

When we are comparing (or matching) types or terms, we are faced with "going under" corresponding binders. E.g. when comparing:

 \x. e1	~   \y. e2

Basically we want to rename [x -> y] or [y -> x], but there are lots of things we must be careful of. In particular, x might be free in e2, or y in e1. So the idea is that we come up with a fresh binder that is free in neither, and rename x and y respectively. That means we must maintain:

1. A renaming for the left-hand expression

2. A renaming for the right-hand expressions

3. An in-scope set

Furthermore, when matching, we want to be able to have an 'occurs check', to prevent:

 \x. f   ~   \y. y

matching with [f -> y]. So for each expression we want to know that set of locally-bound variables. That is precisely the domain of the mappings 1. and 2., but we must ensure that we always extend the mappings as we go in.

All of this information is bundled up in the RnEnv2

Operations on RnEnv2s
mkRnEnv2 :: InScopeSet -> RnEnv2Source
rnBndr2 :: RnEnv2 -> Var -> Var -> RnEnv2Source
rnBndr2 env bL bR goes under a binder bL in the Left term, and binder bR in the Right term. It finds a new binder, new_b, and returns an environment mapping bL -> new_b and bR -> new_b
rnBndrs2 :: RnEnv2 -> [Var] -> [Var] -> RnEnv2Source
Applies rnBndr2 to several variables: the two variable lists must be of equal length
rnOccL :: RnEnv2 -> Var -> VarSource
Look up the renaming of an occurrence in the left or right term
rnOccR :: RnEnv2 -> Var -> VarSource
inRnEnvL :: RnEnv2 -> Var -> BoolSource
Tells whether a variable is locally bound
inRnEnvR :: RnEnv2 -> Var -> BoolSource
rnBndrL :: RnEnv2 -> Var -> (RnEnv2, Var)Source
Similar to rnBndr2 but used when there's a binder on the left side only. Useful when eta-expanding
rnBndrR :: RnEnv2 -> Var -> (RnEnv2, Var)Source
Similar to rnBndr2 but used when there's a binder on the right side only. Useful when eta-expanding
nukeRnEnvL :: RnEnv2 -> RnEnv2Source
Wipe the left or right side renaming
nukeRnEnvR :: RnEnv2 -> RnEnv2Source
extendRnInScopeList :: RnEnv2 -> [Var] -> RnEnv2Source
rnInScope :: Var -> RnEnv2 -> BoolSource
rnInScopeSet :: RnEnv2 -> InScopeSetSource
lookupRnInScope :: RnEnv2 -> Var -> VarSource
TidyEnv and its operation
type TidyEnv = (TidyOccEnv, VarEnv Var)Source
When tidying up print names, we keep a mapping of in-scope occ-names (the TidyOccEnv) and a Var-to-Var of the current renamings
emptyTidyEnv :: TidyEnvSource
Produced by Haddock version 2.6.1