summaryrefslogtreecommitdiff
path: root/lambda-calcul/rust/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lambda-calcul/rust/src/ast.rs')
-rw-r--r--lambda-calcul/rust/src/ast.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/lambda-calcul/rust/src/ast.rs b/lambda-calcul/rust/src/ast.rs
index bdfb963..2b9bcfc 100644
--- a/lambda-calcul/rust/src/ast.rs
+++ b/lambda-calcul/rust/src/ast.rs
@@ -14,7 +14,11 @@ pub enum Type {
impl Display for Type {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "Type")
+ match self {
+ Type::Num => write!(f, "Num"),
+ Type::Bool => write!(f, "Bool"),
+ Type::Arr(l, r) => write!(f, "({} -> {})", l, r),
+ }
}
}
@@ -39,7 +43,7 @@ pub enum Value {
// this is unsound as we are not in a dependently typed language
// but useful to unify external representation (AST). In theory,
// we should separate AST from Terms
- Type(Type)
+ Type(Type),
}
use Value::*;
@@ -76,7 +80,7 @@ impl Display for Value {
Value::Lam(var, body) => write!(f, "(lam {} {})", var, body),
Value::Def(var, value) => write!(f, "(def {} {})", var, value),
Value::Let(var, value, body) => write!(f, "(let ({} {}) {})", var, value, body),
- Value::TLam(var,typ, body) => write!(f, "(tlam ({} {}) {})", var, typ, body),
+ Value::TLam(var, typ, body) => write!(f, "(tlam ({} {}) {})", var, typ, body),
Value::Type(typ) => write!(f, ":{}", typ),
}
}