From adeaac24d9519454028c3a7bd3787cbb59a4ed14 Mon Sep 17 00:00:00 2001 From: JJ Date: Tue, 11 Apr 2023 21:39:32 -0700 Subject: more util helpers, cut down test code verbosity --- src/util.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-70-g09d2