repr tree: create reprtree with a single path from type ladder

This commit is contained in:
Michael Sippel 2024-11-03 01:39:57 +01:00
parent fe4b571b8c
commit 2c2268c918
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -50,15 +50,19 @@ impl std::fmt::Debug for ReprTree {
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
impl ReprTree {
pub fn new(type_tag: impl Into<TypeTerm>) -> Self {
let type_tag = type_tag.into();
pub fn new(typ: impl Into<TypeTerm>) -> Self {
let mut lnf = typ.into().get_lnf_vec();
let head_type = lnf.remove(0);
assert!(type_tag.is_flat());
let mut branches = HashMap::new();
if lnf.len() > 0 {
branches.insert( lnf[0].clone(), ReprTree::new_arc(TypeTerm::Ladder(lnf)) );
}
ReprTree {
halo: TypeTerm::unit(),
type_tag: type_tag.clone(),
branches: HashMap::new(),
type_tag: head_type,
branches,
leaf: None
}
}