From 21befc8c8ab2e91632f5341b4fa9425cf3c815ff Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Mon, 13 Oct 2025 09:18:10 +0200 Subject: update from workshop 2bis --- lambda-calcul/rust/src/ast.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lambda-calcul/rust/src/ast.rs') 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), } } -- cgit v1.2.3