pub struct AdtDecl {
pub name: Symbol,
pub params: Vec<AdtParam>,
pub variants: Vec<AdtVariant>,
}Expand description
A type declaration for an algebraic data type.
This only describes the type surface (params + variants). It does not
introduce any runtime values by itself. Runtime values are created by
injecting constructor schemes into the environment (see inject_adt).
Fields§
§name: Symbol§params: Vec<AdtParam>§variants: Vec<AdtVariant>Implementations§
Source§impl AdtDecl
impl AdtDecl
pub fn new( name: &Symbol, param_names: &[Symbol], supply: &mut TypeVarSupply, ) -> AdtDecl
pub fn param_type(&self, name: &Symbol) -> Option<Type>
pub fn add_variant(&mut self, name: Symbol, args: Vec<Type>)
pub fn result_type(&self) -> Type
Sourcepub fn constructor_schemes(&self) -> Vec<(Symbol, Scheme)>
pub fn constructor_schemes(&self) -> Vec<(Symbol, Scheme)>
Build constructor schemes of the form:
C :: a1 -> a2 -> ... -> T params.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AdtDecl
impl RefUnwindSafe for AdtDecl
impl Send for AdtDecl
impl Sync for AdtDecl
impl Unpin for AdtDecl
impl UnsafeUnpin for AdtDecl
impl UnwindSafe for AdtDecl
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