Put mk_type! in typechecking module

This commit is contained in:
greg 2019-02-17 03:36:12 -08:00
parent e38ae1c3f1
commit 9d4f086a04
3 changed files with 9 additions and 8 deletions

View File

@ -86,12 +86,6 @@ impl PrefixOp {
} }
} }
//TODO make this macro exportable?
macro_rules! mk_type {
($type_name:ident) => { Type::Const(TypeConst::$type_name) };
($t1:ident -> $t2:ident) => { Type::Arrow(Box::new(mk_type!($t1)), Box::new(mk_type!($t2))) };
($t1:ident -> $t2:ident -> $t3:ident) => { Type::Arrow(Box::new(mk_type!($t1)), Box::new(mk_type!($t2 -> $t3))) };
}
lazy_static! { lazy_static! {
static ref PREFIX_OPS: HashMap<&'static str, (Type, ())> = static ref PREFIX_OPS: HashMap<&'static str, (Type, ())> =

View File

@ -28,13 +28,14 @@ macro_rules! bx {
($e:expr) => { Box::new($e) } ($e:expr) => { Box::new($e) }
} }
#[macro_use]
mod typechecking;
mod util; mod util;
mod builtin;
mod tokenizing; mod tokenizing;
mod ast; mod ast;
mod parsing; mod parsing;
mod symbol_table; mod symbol_table;
mod typechecking; mod builtin;
mod reduced_ast; mod reduced_ast;
mod eval; mod eval;

View File

@ -78,6 +78,12 @@ impl Type {
} }
} }
macro_rules! mk_type {
($type_name:ident) => { Type::Const(TypeConst::$type_name) };
($t1:ident -> $t2:ident) => { Type::Arrow(Box::new(mk_type!($t1)), Box::new(mk_type!($t2))) };
($t1:ident -> $t2:ident -> $t3:ident) => { Type::Arrow(Box::new(mk_type!($t1)), Box::new(mk_type!($t2 -> $t3))) };
}
/* /*
/// `Type` is parameterized by whether the type variables can be just universal, or universal or /// `Type` is parameterized by whether the type variables can be just universal, or universal or
/// existential. /// existential.