diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-10 18:38:49 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-10 18:38:49 +0300 |
commit | 06798d622327707ca3f3b42d65fc3d1a25ae3c57 (patch) | |
tree | c230f8ffc43f34a4077cf71b480e93357dbb24b1 /src/type/display.rs | |
parent | 2274a96d1cbd7a5b89bb6b5f51f6bbb0a0513587 (diff) | |
download | myslip-06798d622327707ca3f3b42d65fc3d1a25ae3c57.tar.gz myslip-06798d622327707ca3f3b42d65fc3d1a25ae3c57.zip |
Added term level type literals (for function type signatures)
Diffstat (limited to 'src/type/display.rs')
-rw-r--r-- | src/type/display.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/type/display.rs b/src/type/display.rs index 72e3693..cd60673 100644 --- a/src/type/display.rs +++ b/src/type/display.rs @@ -10,19 +10,20 @@ 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, "()"), + TypeLit => write!(f, "[type literal]"), VecOf(ty) => write!(f, "({} ... {})", *ty, *ty), Arrow(a, b) => write!(f, "({} -> {})", a, b), List(types) => write!( @@ -57,7 +58,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 { @@ -65,7 +66,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(), @@ -76,7 +77,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 { |