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 { impl ReprTree {
pub fn new(type_tag: impl Into<TypeTerm>) -> Self { pub fn new(typ: impl Into<TypeTerm>) -> Self {
let type_tag = type_tag.into(); 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 { ReprTree {
halo: TypeTerm::unit(), halo: TypeTerm::unit(),
type_tag: type_tag.clone(), type_tag: head_type,
branches: HashMap::new(), branches,
leaf: None leaf: None
} }
} }