pretty format: use different colors for variables
This commit is contained in:
parent
62a80fcd2f
commit
b0ebf49d03
1 changed files with 12 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::TypeDict,
|
||||
crate::{TypeDict, dict::TypeID},
|
||||
crate::sugar::SugaredTypeTerm,
|
||||
tiny_ansi::TinyAnsi
|
||||
};
|
||||
|
@ -9,11 +9,18 @@ impl SugaredTypeTerm {
|
|||
let indent_width = 4;
|
||||
match self {
|
||||
SugaredTypeTerm::TypeID(id) => {
|
||||
format!("{}", dict.get_typename(id).unwrap_or("??".bright_red())).bright_blue()
|
||||
match id {
|
||||
TypeID::Var(varid) => {
|
||||
format!("{}", dict.get_typename(id).unwrap_or("??".bright_red())).bright_magenta()
|
||||
},
|
||||
TypeID::Fun(funid) => {
|
||||
format!("{}", dict.get_typename(id).unwrap_or("??".bright_red())).blue().bold()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
SugaredTypeTerm::Num(n) => {
|
||||
format!("{}", n).bright_cyan()
|
||||
format!("{}", n).green().bold()
|
||||
}
|
||||
|
||||
SugaredTypeTerm::Char(c) => {
|
||||
|
@ -34,7 +41,7 @@ impl SugaredTypeTerm {
|
|||
|
||||
SugaredTypeTerm::Spec(args) => {
|
||||
let mut s = String::new();
|
||||
s.push_str(&"<".yellow().bold());
|
||||
s.push_str(&"<".yellow());
|
||||
for i in 0..args.len() {
|
||||
let arg = &args[i];
|
||||
if i > 0 {
|
||||
|
@ -42,7 +49,7 @@ impl SugaredTypeTerm {
|
|||
}
|
||||
s.push_str( &arg.pretty(dict,indent+1) );
|
||||
}
|
||||
s.push_str(&">".yellow().bold());
|
||||
s.push_str(&">".yellow());
|
||||
s
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue