summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJJ2023-04-12 04:39:32 +0000
committerJJ2023-04-12 04:39:32 +0000
commitadeaac24d9519454028c3a7bd3787cbb59a4ed14 (patch)
tree5ffac83b56c96248fbfb00e6f52b23eeb1da2c97 /src
parent7b4442af8549b212d38e8ecfbf8a62217db7b220 (diff)
more util helpers, cut down test code verbosity
Diffstat (limited to 'src')
-rw-r--r--src/util.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/util.rs b/src/util.rs
index 9ed38d1..b2b3035 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -24,9 +24,9 @@ pub fn Ann(expr: Expression, kind: Type) -> Expression {
};
}
-pub fn Const(val: Value, kind: Type) -> Expression {
+pub fn Const(val: Value) -> Expression {
return Expression::Constant {
- term: Term {val, kind}
+ term: Term {val, kind: Type::Empty}
};
}
@@ -58,3 +58,15 @@ pub fn Cond(if_cond: Expression, if_then: Expression, if_else: Expression) -> Ex
};
}
+pub fn Func(from: Type, to: Type) -> Type {
+ return Type::Function {
+ from: Box::new(from),
+ to: Box::new(to)
+ }
+}
+
+pub const Empty: Type = Type::Empty;
+pub const Unit: Type = Type::Unit;
+pub const Bool: Type = Type::Boolean;
+pub const Nat: Type = Type::Natural;
+pub const Int: Type = Type::Integer;