term: add get_interface_type() to get the top rung of a ladder

This commit is contained in:
Michael Sippel 2025-03-25 16:31:04 +01:00
parent aa67520184
commit deb097acd3
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -164,6 +164,24 @@ impl TypeTerm {
atom => atom
}
}
pub fn get_interface_type(&self) -> TypeTerm {
match self {
TypeTerm::Ladder(rungs) => {
if let Some(top) = rungs.first() {
top.get_interface_type()
} else {
TypeTerm::unit()
}
}
TypeTerm::App(args) => {
TypeTerm::App(args.iter().map(|a| a.get_interface_type()).collect())
}
atom => atom.clone()
}
}
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>\\