aboutsummaryrefslogtreecommitdiff
path: root/src/type/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/type/mod.rs')
-rw-r--r--src/type/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/type/mod.rs b/src/type/mod.rs
index 8761cee..8977d85 100644
--- a/src/type/mod.rs
+++ b/src/type/mod.rs
@@ -14,6 +14,8 @@ pub enum Type {
Integer,
+ Boolean,
+
Arrow(Box<Type>, Box<Type>),
List(Vec<Type>),
@@ -63,19 +65,21 @@ impl Type {
/// use myslip::r#type::{*, Type::*, TypeError::*, util::*};
///
/// assert_eq!(Integer.is_concrete(), Ok(()));
+ /// assert_eq!(Boolean.is_concrete(), Ok(()));
/// assert_eq!(
/// VarType("a".to_string()).is_concrete(),
/// Err("a".to_string())
/// );
///
/// assert_eq!(arr(Integer, Integer).is_concrete(), Ok(()));
+ /// assert_eq!(arr(Integer, Boolean).is_concrete(), Ok(()));
/// assert_eq!(
/// arr(VarType("b".to_string()), Integer).is_concrete(),
/// Err("b".to_string())
/// );
///
/// assert_eq!(
- /// List(vec![Integer, Integer, arr(Integer, Integer)]).is_concrete(),
+ /// List(vec![Integer, Boolean, arr(Integer, Integer)]).is_concrete(),
/// Ok(())
/// );
/// assert_eq!(
@@ -87,6 +91,7 @@ impl Type {
pub fn is_concrete(&self) -> Result<(), String> {
match self {
Integer => Ok(()),
+ Boolean => todo!(),
Arrow(a, b) => b.is_concrete().and_then(|_ok| a.is_concrete()),
List(v) => {
let mut res = Ok(());