Substitution monotypes
This commit is contained in:
parent
1de1cd9cfd
commit
a26da934f4
@ -77,6 +77,19 @@ impl MonoType {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO maybe this should be type self, and consume?
|
||||||
|
fn apply_substitution(&self, s: &Substitution) -> MonoType {
|
||||||
|
use self::MonoType::*;
|
||||||
|
match self {
|
||||||
|
Const(t) => Const(t.clone()),
|
||||||
|
Var(a) => s.0.get(a).map(|x| x.clone()).unwrap_or(Var(a.clone())),
|
||||||
|
Function(a, b) => Function(
|
||||||
|
Box::new(a.apply_substitution(s)),
|
||||||
|
Box::new(b.apply_substitution(s))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
@ -87,6 +100,10 @@ impl PolyType {
|
|||||||
let mtype = self.1.free_vars();
|
let mtype = self.1.free_vars();
|
||||||
self.0.difference(&mtype).cloned().collect()
|
self.0.difference(&mtype).cloned().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn apply_substitution(&self, s: &Substitution) -> PolyType {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
Loading…
Reference in New Issue
Block a user