|
|
|
|
|
|
Synopsis |
|
|
|
|
Var, Id and TyVar environments (maps)
|
|
|
|
|
|
|
|
Manipulating these environments
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The InScopeSet type
|
|
|
A set of variables that are in scope at some point
| Instances | |
|
|
Operations on InScopeSets
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Look up a variable the InScopeSet. This lets you map from
the variable's identity (unique) to its full value.
|
|
|
|
|
uniqAway in_scope v finds a unique that is not used in the
in-scope set, and gives that to v.
|
|
The RnEnv2 type
|
|
|
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
|
|
|
|
|
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
|
|
|
Applies rnBndr2 to several variables: the two variable lists must be of equal length
|
|
|
Look up the renaming of an occurrence in the left or right term
|
|
|
|
|
Tells whether a variable is locally bound
|
|
|
|
|
Similar to rnBndr2 but used when there's a binder on the left
side only. Useful when eta-expanding
|
|
|
Similar to rnBndr2 but used when there's a binder on the right
side only. Useful when eta-expanding
|
|
|
Wipe the left or right side renaming
|
|
|
|
|
|
|
|
|
|
|
|
TidyEnv and its operation
|
|
|
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
|
|
|
|
Produced by Haddock version 2.6.1 |