From 7121624f770120c8154d2ca515d7b07a2b2fb4a0 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 17 May 2018 02:25:36 -0700 Subject: [PATCH] Type Env --- schala-lang/src/typechecking.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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),