improve encode_type_to_symbol to handle complex types
This commit is contained in:
parent
186c12fc5d
commit
ffd190890d
1 changed files with 24 additions and 2 deletions
26
src/main.rs
26
src/main.rs
|
@ -96,9 +96,31 @@ struct LdmcPrimCMorphism {
|
||||||
fn encode_type_to_symbol(dict: &mut impl TypeDict, t: &laddertypes::TypeTerm)-> String {
|
fn encode_type_to_symbol(dict: &mut impl TypeDict, t: &laddertypes::TypeTerm)-> String {
|
||||||
match t {
|
match t {
|
||||||
laddertypes::TypeTerm::Char(c) => {
|
laddertypes::TypeTerm::Char(c) => {
|
||||||
format!("{}", (*c as u64))
|
match c {
|
||||||
|
'.' => format!("_dot_"),
|
||||||
|
_ =>
|
||||||
|
format!("{}", (*c as u64))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
t => dict.unparse(t)
|
laddertypes::TypeTerm::Num(n) => {
|
||||||
|
format!("{}", n)
|
||||||
|
}
|
||||||
|
laddertypes::TypeTerm::TypeID(ty_id) => {
|
||||||
|
if let Some(name) = dict.get_typename(ty_id) {
|
||||||
|
format!("{}", name.replace(".", "_dot_"))
|
||||||
|
} else {
|
||||||
|
format!("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
laddertypes::TypeTerm::Ladder(rs) |
|
||||||
|
laddertypes::TypeTerm::App(rs) => {
|
||||||
|
let mut s = String::new();
|
||||||
|
for r in rs {
|
||||||
|
s.push('_');
|
||||||
|
s.push_str(&encode_type_to_symbol(dict, r));
|
||||||
|
}
|
||||||
|
s
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue