This commit is contained in:
greg 2018-05-17 02:25:36 -07:00
parent 48e795decc
commit 7121624f77
1 changed files with 18 additions and 0 deletions

View File

@ -118,6 +118,24 @@ impl PolyType {
struct Substitution(HashMap<Rc<String>, MonoType>);
#[derive(Debug)]
struct TypeEnvironment {
map: HashMap<Rc<String>, PolyType>,
}
impl TypeEnvironment {
fn apply_substitution(&self, s: &Substitution) -> TypeEnvironment {
let mut map = HashMap::new();
for (name, polytype) in self.map.iter() {
map.insert(name.clone(), polytype.apply_substitution(s));
}
TypeEnvironment { map }
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum Type {
Const(TConstOld),