diff --git a/schala-lang/src/typechecking.rs b/schala-lang/src/typechecking.rs index f3cf6cf..5252499 100644 --- a/schala-lang/src/typechecking.rs +++ b/schala-lang/src/typechecking.rs @@ -118,6 +118,24 @@ impl PolyType { struct Substitution(HashMap, MonoType>); +#[derive(Debug)] +struct TypeEnvironment { + map: HashMap, 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),