pub enum Type {
Any,
MaybeZero(Box<Type>),
Named(String, Vec<Type>),
And(Vec<Type>),
Arrow(Box<Type>, Box<Type>),
Tuple(Vec<Type>),
HTuple(Box<Type>, Constant),
Product(Vec<Type>),
Ratio(Box<Type>, Box<Type>),
Constant(Constant),
}Expand description
Each Term has at least one Type.
Types are composed of Atomic parts like Nameds. An Named type has a name and possibly some parameters. Atomic parts can be combined to form Compound parts like Arrows. Compound parts are formed by some combination of Arrows, Tuples, Products, and Ratios. At the Highest level a Compound type can be pluralized with an And to join it to other Compounds.
And types are represented in Conjunctive-Normal-Form which requires the Ands to only occupy the highest level of a type. Some basic typing algorithms may not work correctly if a type is not in Conjunctive-Normal-Form.
Subtyping is implemented with And types. An implication, A + A => B, may be rewritten as just A + B.
Variants§
Any
MaybeZero(Box<Type>)
Named(String, Vec<Type>)
And(Vec<Type>)
Arrow(Box<Type>, Box<Type>)
Tuple(Vec<Type>)
HTuple(Box<Type>, Constant)
Product(Vec<Type>)
Ratio(Box<Type>, Box<Type>)
Constant(Constant)
Implementations§
Source§impl Type
impl Type
pub fn datatype(&self) -> String
pub fn project_ratio(&self) -> (Vec<Type>, Vec<Type>)
pub fn is_ctuple(&self) -> bool
pub fn is_open(&self) -> bool
pub fn is_constant(&self) -> bool
pub fn all_named(&self) -> Vec<Type>
pub fn and(&self, other: &Type) -> Type
pub fn is_var(&self) -> bool
pub fn domain(&self) -> Type
pub fn range(&self) -> Type
pub fn vars(&self) -> Vec<String>
pub fn simplify_ratio(&self) -> Type
pub fn normalize(&self) -> Type
pub fn remove(&self, x: &Type) -> Type
pub fn substitute(&self, subs: &HashMap<Type, Type>) -> Type
pub fn is_concrete(&self) -> bool
pub fn kind(&self, kinds: &HashMap<Type, Kind>) -> Kind
pub fn narrow(&self, kinds: &HashMap<Type, Kind>, k: &Kind) -> Type
pub fn is_bottom(&self) -> bool
pub fn compile_subs(subs: &Vec<(Type, Type)>) -> Result<HashMap<Type, Type>, ()>
pub fn implies(tlc: &TLC, lt: &Type, rt: &Type) -> Type
pub fn arrow_implies( tlc: &TLC, lt: &mut Type, rt: &mut Type, inarrow: InArrow, ) -> Type
pub fn subs_implies( tlc: &TLC, subs: &mut Vec<(Type, Type)>, lt: &Type, rt: &Type, ) -> Type
pub fn nored_implies( tlc: &TLC, subs: &mut Vec<(Type, Type)>, lt: &Type, rt: &Type, ) -> Type
pub fn implication_unifier(&self, other: &Type) -> Type
pub fn subs_implication_unifier( &self, subs: &mut Vec<(Type, Type)>, other: &Type, ) -> Type
pub fn most_general_unifier(&self, other: &Type) -> Type
Trait Implementations§
Source§impl Ord for Type
impl Ord for Type
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Type
impl PartialOrd for Type
impl Eq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl UnwindSafe for Type
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