class documentation
class Substitutions: (source)
A domain of instantiated type variables.
>>> d = Substitutions() >>> assert len(list(d.variables())) == 0 >>> t1 = TypeVariable() >>> t2 = TypeVariable() >>> v1 = Type('int') >>> v2 = Type('float') >>> d.bind(t1, v1) >>> dd = d.copy() >>> d.bind(t2, v2) >>> d <Substitutions: @TypeVar... -> int @TypeVar... -> float <UnionFind: elts=['@TypeVar...', 'int', '@TypeVar...', 'float'], siz=[1, 1, 1, 1], par=[0, 1, 2, 3], nb_rm=[0, 0, 0, 0], removed=[], free=[], n_elts=4,n_comps=4> > >>> d.bind(t1, t2) >>> d <Substitutions: @TypeVar... -> float @TypeVar... -> float <UnionFind: elts=['@TypeVar...', 'int', '@TypeVar...', 'float'], siz=[2, 2, 1, 1], par=[0, 1, 0, 1], nb_rm=[0, 0, 0, 0], removed=[], free=[], n_elts=4,n_comps=2> > >>> dd.bind(t1, t2) >>> dd <Substitutions: @TypeVar... -> int @TypeVar... -> int <UnionFind: elts=['@TypeVar...', 'int', '@TypeVar...'], siz=[2, 1, 1], par=[0, 1, 0], nb_rm=[0, 0, 0], removed=[], free=[], n_elts=3,n_comps=2> >
| Method | __init__ |
Undocumented |
| Method | __repr__ |
Undocumented |
| Method | bind |
Add a new binding for a variable. |
| Method | copy |
Copy the substitutions into a new instance. |
| Method | mark |
Create a mark of this substitutions, to be applied with restore. |
| Method | rep |
Get the representant of this type. |
| Method | restore |
Restore a mark previously created with mark. |
| Method | type |
This will return the complex type associated with a given type variable. |
| Method | variables |
Iterate over all type variables in the domain. |
| Method | _merge |
Undocumented |
| Instance Variable | _graph |
Undocumented |
| Instance Variable | _uf |
Dans la structure de données Union-find, les classes d'équivalence ne contiennent soit que des variables soit que des termes complexes. Pour passer d'une variable à un terme complexe, on utilise les pointeurs éventuels qui sont dans le graphe. |