pub enum DependentType {
Base(ParametricType),
Vector {
length: IndexExpr,
element_type: Box<DependentType>,
},
Matrix {
rows: IndexExpr,
cols: IndexExpr,
element_type: Box<DependentType>,
},
Tensor {
shape: Vec<IndexExpr>,
element_type: Box<DependentType>,
},
DependentFunction {
param_name: String,
param_type: Box<DependentType>,
return_type: Box<DependentType>,
},
Refinement {
var_name: String,
base_type: Box<DependentType>,
predicate: Term,
},
Constrained {
base_type: Box<DependentType>,
constraints: Vec<DimConstraint>,
},
}Expand description
Dependent type: types that depend on runtime values.
Examples:
Vec<n, T>: Vector of length n with elements of type TMatrix<m, n, T>: Matrix with dimensions m×n(x: Int) -> Vec<x, Bool>: Function returning a vector of length x
Variants§
Base(ParametricType)
Base parametric type (non-dependent)
Vector
Vector with dependent length: Vec<n, T>
Matrix
Matrix with dependent dimensions: Matrix<rows, cols, T>
Tensor
Tensor with dependent shape: Tensor<[d1, d2, …], T>
DependentFunction
Dependent function type: (x: T1) -> T2(x)
Refinement
Refinement type: {x: T | P(x)}
Constrained
Constrained type: T where C
Implementations§
Source§impl DependentType
impl DependentType
Sourcepub fn base(param_type: ParametricType) -> Self
pub fn base(param_type: ParametricType) -> Self
Create a base non-dependent type
Sourcepub fn vector(length: IndexExpr, element_type: impl Into<String>) -> Self
pub fn vector(length: IndexExpr, element_type: impl Into<String>) -> Self
Create a dependent vector type
Sourcepub fn matrix(
rows: IndexExpr,
cols: IndexExpr,
element_type: impl Into<String>,
) -> Self
pub fn matrix( rows: IndexExpr, cols: IndexExpr, element_type: impl Into<String>, ) -> Self
Create a dependent matrix type
Sourcepub fn tensor(shape: Vec<IndexExpr>, element_type: impl Into<String>) -> Self
pub fn tensor(shape: Vec<IndexExpr>, element_type: impl Into<String>) -> Self
Create a dependent tensor type
Sourcepub fn dependent_function(
param_name: impl Into<String>,
param_type: DependentType,
return_type: DependentType,
) -> Self
pub fn dependent_function( param_name: impl Into<String>, param_type: DependentType, return_type: DependentType, ) -> Self
Create a dependent function type
Sourcepub fn refinement(
var_name: impl Into<String>,
base_type: DependentType,
predicate: Term,
) -> Self
pub fn refinement( var_name: impl Into<String>, base_type: DependentType, predicate: Term, ) -> Self
Create a refinement type
Sourcepub fn with_constraints(self, constraints: Vec<DimConstraint>) -> Self
pub fn with_constraints(self, constraints: Vec<DimConstraint>) -> Self
Add constraints to a type
Sourcepub fn free_index_vars(&self) -> HashSet<String>
pub fn free_index_vars(&self) -> HashSet<String>
Get all free index variables
Sourcepub fn is_well_formed(&self) -> bool
pub fn is_well_formed(&self) -> bool
Check if this type is well-formed (no unbound index variables)
Trait Implementations§
Source§impl Clone for DependentType
impl Clone for DependentType
Source§fn clone(&self) -> DependentType
fn clone(&self) -> DependentType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DependentType
impl Debug for DependentType
Source§impl<'de> Deserialize<'de> for DependentType
impl<'de> Deserialize<'de> for DependentType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for DependentType
impl Display for DependentType
Source§impl Hash for DependentType
impl Hash for DependentType
Source§impl PartialEq for DependentType
impl PartialEq for DependentType
Source§impl Serialize for DependentType
impl Serialize for DependentType
impl Eq for DependentType
impl StructuralPartialEq for DependentType
Auto Trait Implementations§
impl Freeze for DependentType
impl RefUnwindSafe for DependentType
impl Send for DependentType
impl Sync for DependentType
impl Unpin for DependentType
impl UnwindSafe for DependentType
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
Mutably borrows from an owned value. Read more