repr tree: create reprtree with a single path from type ladder
This commit is contained in:
parent
fe4b571b8c
commit
2c2268c918
1 changed files with 10 additions and 6 deletions
|
@ -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);
|
||||||
|
|
||||||
|
let mut branches = HashMap::new();
|
||||||
|
if lnf.len() > 0 {
|
||||||
|
branches.insert( lnf[0].clone(), ReprTree::new_arc(TypeTerm::Ladder(lnf)) );
|
||||||
|
}
|
||||||
|
|
||||||
assert!(type_tag.is_flat());
|
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue