aboutsummaryrefslogtreecommitdiff
path: root/src/type/util.rs
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-16 02:04:09 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-16 02:04:09 +0300
commite35522189f5217987bc455d70c3b9056541ef8c6 (patch)
tree421bcca16938157268eb9bcd4ea181ce0d099133 /src/type/util.rs
parenta97fef6f099767924c5203782a2b04b1a559ac6b (diff)
downloadmyslip-e35522189f5217987bc455d70c3b9056541ef8c6.tar.gz
myslip-e35522189f5217987bc455d70c3b9056541ef8c6.zip
feat: type conversion from (Vec/Quote X) -> X and add vec/quote to rest pattern substitutions
Diffstat (limited to 'src/type/util.rs')
-rw-r--r--src/type/util.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/type/util.rs b/src/type/util.rs
index ad85b79..d95629d 100644
--- a/src/type/util.rs
+++ b/src/type/util.rs
@@ -14,6 +14,19 @@ pub fn vecof(ty: impl Into<Box<Type>>) -> Type {
VecOf(ty.into())
}
+impl Type {
+ pub fn is_quoted_or_vectored_list(&self) -> bool {
+ match self {
+ List(v) => match v.get(0) {
+ Some(VecType) => true,
+ Some(QuoteTy) => true,
+ _ => false,
+ },
+ _ => false,
+ }
+ }
+}
+
use crate::sexp::{SExp::*, SLeaf::*};
impl SExp {
pub fn get_fun_type(self, mut ctx: HashMap<String, Type>) -> Result<Type, TypeError> {