aboutsummaryrefslogtreecommitdiff
path: root/src/type/check.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/type/check.rs')
-rw-r--r--src/type/check.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/type/check.rs b/src/type/check.rs
index df3f4d9..d0ce807 100644
--- a/src/type/check.rs
+++ b/src/type/check.rs
@@ -81,6 +81,43 @@ impl SExp {
/// assert_eq!(Atom(Not).type_check(), Ok(arr(List(vec![Boolean]), Boolean)));
/// ```
///
+ ///
+ /// **Let-binding types**
+ ///
+ /// Let-bindings are quite interesting. Implementation is still a bit uncertain,
+ /// but at least we know that
+ /// ```rust
+ /// use myslip::{
+ /// r#type::{*, Type::*, TypeError::*, util::*},
+ /// sexp::{SExp::*, SLeaf::*, util::*},
+ /// };
+ ///
+ /// assert_eq!(
+ /// scons(
+ /// scons(Let, scons(var("x"), scons(False, Nil))),
+ /// scons(var("x"), Nil)
+ /// ).type_check(),
+ /// Ok(Boolean)
+ /// );
+ /// ```
+ ///
+ /// As such it must be that the type of the let-binding s-expression is st.
+ /// ```rust
+ /// use myslip::{
+ /// r#type::{*, Type::*, TypeError::*, util::*},
+ /// sexp::{SExp::*, SLeaf::*, util::*},
+ /// };
+ ///
+ /// assert_eq!(
+ /// scons(Let, scons(var("x"), scons(1, Nil))).type_check(),
+ /// Ok(arr(vt("T"), vt("T")))
+ /// );
+ /// ```
+ /// ie. the identity function.
+ ///
+ /// No more behavior on typing let can be defined, as typing the let-keyword
+ /// would require the yet untyped variable to be typed.
+ ///
/// Though perhaps the most important task of the type system
/// is to increase safety by being able to warn about errors
/// before evaluation. Here are some failing examples:
@@ -173,6 +210,7 @@ impl SExp {
vecof(vt("T")),
List(vec![VecType, vecof(vt("T"))])
)),
+ Atom(Let) => todo!(),
SCons(op, l) => {