diff options
Diffstat (limited to 'src/type')
-rw-r--r-- | src/type/check.rs | 6 | ||||
-rw-r--r-- | src/type/display.rs | 1 | ||||
-rw-r--r-- | src/type/mod.rs | 3 | ||||
-rw-r--r-- | src/type/subst.rs | 2 | ||||
-rw-r--r-- | src/type/util.rs | 4 |
5 files changed, 12 insertions, 4 deletions
diff --git a/src/type/check.rs b/src/type/check.rs index 81a43a4..c3bdcb4 100644 --- a/src/type/check.rs +++ b/src/type/check.rs @@ -28,7 +28,7 @@ impl SExp { /// /// assert_eq!( /// scons(Quote, scons(1, scons(False, Nil))).type_check(), - /// Ok(List(vec![Integer, Boolean])) + /// Ok(List(vec![QuoteTy, List(vec![Integer, Boolean])])) /// ); /// ``` /// Though so is Nil given too: @@ -150,8 +150,8 @@ impl SExp { Atom(Not) => Ok(arr(List(vec!(Boolean)), Boolean)), Atom(Nil) => Ok(List(vec![])), Atom(Quote) => Ok(arr( - VarType("T".to_string()), - VarType("T".to_string()) + vt("T"), + List(vec![QuoteTy, vt("T")]) )), SCons(op, l) => { diff --git a/src/type/display.rs b/src/type/display.rs index 3e4f49c..8eb0647 100644 --- a/src/type/display.rs +++ b/src/type/display.rs @@ -19,6 +19,7 @@ impl fmt::Display for Type { match self { Integer => write!(f, "{}", "Int"), Boolean => write!(f, "{}", "Bool"), + QuoteTy => write!(f, "{}", "Quote"), Arrow(a, b) => write!(f, "({} -> {})", a, b), List(types) => write!( f, diff --git a/src/type/mod.rs b/src/type/mod.rs index e4c0841..e29e069 100644 --- a/src/type/mod.rs +++ b/src/type/mod.rs @@ -16,6 +16,8 @@ pub enum Type { Boolean, + QuoteTy, + Arrow(Box<Type>, Box<Type>), List(Vec<Type>), @@ -92,6 +94,7 @@ impl Type { match self { Integer => Ok(()), Boolean => Ok(()), + QuoteTy => Ok(()), Arrow(a, b) => b.is_concrete().and_then(|_ok| a.is_concrete()), List(v) => { let mut res = Ok(()); diff --git a/src/type/subst.rs b/src/type/subst.rs index 79c5fe1..d63f71b 100644 --- a/src/type/subst.rs +++ b/src/type/subst.rs @@ -38,8 +38,8 @@ impl Type { VarType(s) => VarType(s), Integer => Integer, - Boolean => Boolean, + QuoteTy => QuoteTy, } } diff --git a/src/type/util.rs b/src/type/util.rs index 27fc661..9be8c6e 100644 --- a/src/type/util.rs +++ b/src/type/util.rs @@ -5,3 +5,7 @@ pub fn arr(a: impl Into<Box<Type>>, b: impl Into<Box<Type>>) -> Type { Arrow(a.into(), b.into()) } +pub fn vt(name: &str) -> Type { + VarType(name.to_string()) +} + |