aboutsummaryrefslogtreecommitdiff
path: root/src/type
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-14 15:31:27 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-14 15:31:27 +0300
commit928a3358483f60db84dc2918415882b35adc006b (patch)
tree0b35b8e601f3ca93cdeb7f8d45bb1d06cf274e66 /src/type
parent907bd54d19f6bf14a130a136df6f37cc5d256468 (diff)
downloadmyslip-928a3358483f60db84dc2918415882b35adc006b.tar.gz
myslip-928a3358483f60db84dc2918415882b35adc006b.zip
fix: removed obsolete code for handling types as they are now parsed directly to atoms
Diffstat (limited to 'src/type')
-rw-r--r--src/type/check.rs3
-rw-r--r--src/type/display.rs22
-rw-r--r--src/type/util.rs8
3 files changed, 16 insertions, 17 deletions
diff --git a/src/type/check.rs b/src/type/check.rs
index 69e9141..ad6be13 100644
--- a/src/type/check.rs
+++ b/src/type/check.rs
@@ -127,7 +127,7 @@ impl SExp {
/// };
///
/// let varlist = scons(var("a"), scons(var("b"), Nil));
- /// let typelist = scons(Ty(Integer), scons(Ty(Integer), Nil));
+ /// let typelist = scons(Ty(List(vec![Integer])), Nil);
/// let ret = Atom(Ty(Boolean));
/// let body = scons(Eq, varlist.clone());
/// assert_eq!(
@@ -256,7 +256,6 @@ impl SExp {
Atom(Let) => Ok(LetType),
Atom(Print) => Ok(arr(vt("_"), List(vec![]))),
Atom(Ty(_)) => Ok(TypeLit),
- Atom(Arr) => Ok(arr(List(vec![TypeLit, TypeLit]), TypeLit)),
Atom(Fun) => Err(FunAsAtom),
Atom(Case) => Err(CaseAsAtom),
Atom(RestPat(_)) => Err(RestAsAtom),
diff --git a/src/type/display.rs b/src/type/display.rs
index 56b22b6..27f1427 100644
--- a/src/type/display.rs
+++ b/src/type/display.rs
@@ -19,21 +19,21 @@ impl fmt::Display for Type {
/// Examples:
/// ```rust
/// use myslip::r#type::{Type::*, util::*};
- /// assert_eq!(Integer.to_string(), "int".to_string());
- /// assert_eq!(Boolean.to_string(), "bool".to_string());
- /// assert_eq!(arr(Integer, Boolean).to_string(), "(int -> bool)".to_string());
- /// assert_eq!(List(vec![Integer, Boolean, Integer]).to_string(), "(int bool int)".to_string());
+ /// assert_eq!(Integer.to_string(), "Int".to_string());
+ /// assert_eq!(Boolean.to_string(), "Bool".to_string());
+ /// assert_eq!(arr(Integer, Boolean).to_string(), "(Int -> Bool)".to_string());
+ /// assert_eq!(List(vec![Integer, Boolean, Integer]).to_string(), "(Int Bool Int)".to_string());
/// ```
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
- Integer => write!(f, "{}", "int"),
- Boolean => write!(f, "{}", "bool"),
+ Integer => write!(f, "{}", "Int"),
+ Boolean => write!(f, "{}", "Bool"),
QuoteTy => write!(f, "{}", "Quote"),
VecType => write!(f, "{}", "Vector"),
LetType => write!(f, "{}", "Let"),
- NilType => write!(f, "()"),
+ NilType => write!(f, "Nil"),
TypeLit => write!(f, "[type literal]"),
- VecOf(ty) => write!(f, "({} ... {})", *ty, *ty),
+ VecOf(ty) => write!(f, "({} ...)", *ty),
Arrow(a, b) => write!(f, "({} -> {})", a, b),
List(types) => write!(
f,
@@ -67,7 +67,7 @@ impl fmt::Display for TypeError {
/// expected: arr(VarType("?".to_string()), VarType("?".to_string())),
/// found: Integer
/// }.to_string(),
- /// "invalid operator: '1'\nexpected: '(? -> ?)'\nfound: 'int'".to_string()
+ /// "invalid operator: '1'\nexpected: '(? -> ?)'\nfound: 'Int'".to_string()
/// );
/// assert_eq!(
/// InvalidArgList {
@@ -75,7 +75,7 @@ impl fmt::Display for TypeError {
/// expected: List(vec![Integer, Integer]),
/// found: List(vec![Integer, Integer, Integer]),
/// }.to_string(),
- /// "invalid argument list: '(1 2 3)'\nexpected: '(int int)'\nfound: '(int int int)'".to_string()
+ /// "invalid argument list: '(1 2 3)'\nexpected: '(Int Int)'\nfound: '(Int Int Int)'".to_string()
/// );
/// assert_eq!(
/// UnboundGeneric(String::from("?")).to_string(),
@@ -86,7 +86,7 @@ impl fmt::Display for TypeError {
/// argtype: Integer,
/// generictype: arr(VarType("T".to_string()), Integer)
/// }.to_string(),
- /// "incompatible argument type 'int' and generic operator type '(T -> int)'".to_string()
+ /// "incompatible argument type 'Int' and generic operator type '(T -> Int)'".to_string()
/// );
/// ```
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/src/type/util.rs b/src/type/util.rs
index 23f8d1f..ad85b79 100644
--- a/src/type/util.rs
+++ b/src/type/util.rs
@@ -24,7 +24,7 @@ impl SExp {
let argnames = ls.get(1)
.ok_or(InvalidFunDef(self.clone(), NoArgumentList))?
.clone().parts();
- let argtypes = ls.get(2)
+ let argtype = ls.get(2)
.ok_or(InvalidFunDef(self.clone(), NoTypeList))?
.clone();
let rettype = ls.get(3)
@@ -40,9 +40,9 @@ impl SExp {
}?);
}
- let argtypes = match argtypes.clone().multistep() {
- Ok(Atom(Ty(List(v)))) => Ok(v),
- Ok(Atom(Ty(t))) => Ok(vec![t]),
+ let argtypes = match argtype {
+ Atom(Ty(List(v))) => Ok(v),
+ Atom(Ty(t)) => Ok(vec![t]),
_ => {
Err(InvalidFunDef(self.clone(), InvalidArgumentList))
},