pub enum SemanticType {
Show 18 variants
Number,
Integer,
Bool,
String,
Option(Box<SemanticType>),
Result {
ok_type: Box<SemanticType>,
err_type: Option<Box<SemanticType>>,
},
Array(Box<SemanticType>),
Struct {
name: String,
fields: Vec<(String, SemanticType)>,
},
Enum {
name: String,
variants: Vec<EnumVariant>,
type_params: Vec<String>,
},
Interface {
name: String,
methods: Vec<(String, FunctionSignature)>,
},
TypeVar(TypeVarId),
Named(String),
Generic {
name: String,
args: Vec<SemanticType>,
},
Ref(Box<SemanticType>),
RefMut(Box<SemanticType>),
Never,
Void,
Function(Box<FunctionSignature>),
}Expand description
Semantic types - what the user sees in type annotations
Variants§
Number
Floating-point number (f64)
Integer
Integer (i64)
Bool
Boolean
String
String
Option(Box<SemanticType>)
Optional value: Option
- For numeric T: Uses NaN sentinel in storage
- For other T: Uses discriminated union
Result
Result type: Result
- err_type = None means universal Error type
Array(Box<SemanticType>)
Array of values: Vec
Struct
Struct type with name and fields
Enum
Enum type with variants
Interface
Interface/trait type
TypeVar(TypeVarId)
Type variable for inference (α, β, γ)
Named(String)
Named type reference (before resolution)
Generic
Generic type instantiation: MyType<A, B>
Ref(Box<SemanticType>)
Shared reference to a value: &T
RefMut(Box<SemanticType>)
Exclusive (mutable) reference to a value: &mut T
Never
Bottom type - computation that never returns (e.g., panic, infinite loop)
Void
Void - no value
Function(Box<FunctionSignature>)
Function type
Implementations§
Source§impl SemanticType
impl SemanticType
Sourcepub fn option(inner: SemanticType) -> Self
pub fn option(inner: SemanticType) -> Self
Create Option
Sourcepub fn result(ok_type: SemanticType) -> Self
pub fn result(ok_type: SemanticType) -> Self
Create Result
Sourcepub fn result_with_error(ok_type: SemanticType, err_type: SemanticType) -> Self
pub fn result_with_error(ok_type: SemanticType, err_type: SemanticType) -> Self
Create Result<T, E> type with specific error
Sourcepub fn array(element: SemanticType) -> Self
pub fn array(element: SemanticType) -> Self
Create Vec
Create shared reference type: &T
Sourcepub fn exclusive_ref(inner: SemanticType) -> Self
pub fn exclusive_ref(inner: SemanticType) -> Self
Create exclusive reference type: &mut T
Sourcepub fn function(params: Vec<SemanticType>, return_type: SemanticType) -> Self
pub fn function(params: Vec<SemanticType>, return_type: SemanticType) -> Self
Create function type
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Check if type is numeric (for propagating operators)
Sourcepub fn is_integer_family(&self) -> bool
pub fn is_integer_family(&self) -> bool
Check if this semantic type is in the integer family.
Sourcepub fn is_number_family(&self) -> bool
pub fn is_number_family(&self) -> bool
Check if this semantic type is in the floating-point family.
Sourcepub fn is_reference(&self) -> bool
pub fn is_reference(&self) -> bool
Check if this is a reference type (&T or &mut T).
Sourcepub fn is_exclusive_ref(&self) -> bool
pub fn is_exclusive_ref(&self) -> bool
Check if this is an exclusive (mutable) reference type (&mut T).
Sourcepub fn deref_type(&self) -> Option<&SemanticType>
pub fn deref_type(&self) -> Option<&SemanticType>
Get the inner type of a reference (&T → T, &mut T → T).
Sourcepub fn auto_deref(&self) -> &SemanticType
pub fn auto_deref(&self) -> &SemanticType
Strip reference wrappers to get the underlying value type. For non-reference types, returns self.
Sourcepub fn option_inner(&self) -> Option<&SemanticType>
pub fn option_inner(&self) -> Option<&SemanticType>
Get inner type of Option
Sourcepub fn result_ok_type(&self) -> Option<&SemanticType>
pub fn result_ok_type(&self) -> Option<&SemanticType>
Get ok type of Result<T, E>
Sourcepub fn has_type_vars(&self) -> bool
pub fn has_type_vars(&self) -> bool
Check if type contains unresolved type variables
Sourcepub fn to_type_info(&self) -> TypeInfo
pub fn to_type_info(&self) -> TypeInfo
Convert semantic type to wire protocol TypeInfo
This bridges the compile-time type system with the wire format used for REPL display and external tool integration.
Source§impl SemanticType
impl SemanticType
Sourcepub fn to_inference_type(&self) -> Type
pub fn to_inference_type(&self) -> Type
Convert SemanticType to inference Type
This allows using semantic types in the inference engine.
Trait Implementations§
Source§impl Clone for SemanticType
impl Clone for SemanticType
Source§fn clone(&self) -> SemanticType
fn clone(&self) -> SemanticType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SemanticType
impl Debug for SemanticType
Source§impl Display for SemanticType
impl Display for SemanticType
Source§impl Hash for SemanticType
impl Hash for SemanticType
Source§impl PartialEq for SemanticType
impl PartialEq for SemanticType
impl Eq for SemanticType
impl StructuralPartialEq for SemanticType
Auto Trait Implementations§
impl Freeze for SemanticType
impl RefUnwindSafe for SemanticType
impl Send for SemanticType
impl Sync for SemanticType
impl Unpin for SemanticType
impl UnsafeUnpin for SemanticType
impl UnwindSafe for SemanticType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.