pub struct TypeClass {
pub name: Name,
pub params: Vec<Name>,
pub ty: Expr,
pub methods: Vec<Method>,
pub super_classes: Vec<Name>,
pub is_prop: bool,
}Expand description
A type class declaration.
For example, class Add (α : Type) declares a type class named Add with
one type parameter and one method add : α → α → α.
Fields§
§name: NameName of the class (e.g., Add, Mul, Inhabited).
params: Vec<Name>Names of the type parameters.
ty: ExprThe full type of the class (as a Pi-type).
methods: Vec<Method>Methods declared in the class, in declaration order.
super_classes: Vec<Name>Names of super-classes that instances must also implement.
is_prop: boolWhether this class is in Prop (proof-irrelevant).
Implementations§
Source§impl TypeClass
impl TypeClass
Sourcepub fn new(name: Name, params: Vec<Name>, ty: Expr) -> Self
pub fn new(name: Name, params: Vec<Name>, ty: Expr) -> Self
Create a new type class with no methods or super-classes.
Sourcepub fn add_method(&mut self, method: Method)
pub fn add_method(&mut self, method: Method)
Add a method to the class.
Sourcepub fn find_method(&self, name: &Name) -> Option<&Method>
pub fn find_method(&self, name: &Name) -> Option<&Method>
Look up a method by name.
Sourcepub fn has_super(&self, name: &Name) -> bool
pub fn has_super(&self, name: &Name) -> bool
Check whether the class has a super-class with the given name.
Sourcepub fn method_count(&self) -> usize
pub fn method_count(&self) -> usize
Count methods in the class.
Sourcepub fn method_names(&self) -> impl Iterator<Item = &Name>
pub fn method_names(&self) -> impl Iterator<Item = &Name>
Iterate over all method names.
Sourcepub fn has_super_classes(&self) -> bool
pub fn has_super_classes(&self) -> bool
Check whether the class has any super-classes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypeClass
impl RefUnwindSafe for TypeClass
impl Send for TypeClass
impl Sync for TypeClass
impl Unpin for TypeClass
impl UnsafeUnpin for TypeClass
impl UnwindSafe for TypeClass
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