Skip to main content

MonoType

Enum MonoType 

Source
pub enum MonoType {
    Var(TyVarRef),
    Base(BaseType),
    Func(Box<Row>, Box<MonoType>, Box<MonoType>),
    Product(Vec<MonoType>),
    List(Box<MonoType>),
    Ref(Box<MonoType>),
    Record(Row),
    Variant(String, Vec<MonoType>),
    Code(Box<MonoType>),
    InlineCmd(Vec<CmdArgType>),
    BlockCmd(Vec<CmdArgType>),
    MathCmd(Vec<CmdArgType>),
}
Expand description

A monomorphic type. Mirrors v0.0.6’s mono_type (the type_main variant instantiated at mono_type_variable_info ref), minus SynonymType (no type synonyms in this port) and with Row-based records instead of a closed RecordType (see Row).

The #[subast] list names every other type in this family reachable from a field; see crate::visit for what the generated traversal covers and — importantly — what it deliberately does not.

MonoType::Var’s TyVarRef is not listed, so the traversal treats a type variable as a leaf and never follows a Bound link. That is not an oversight: see crate::visit.

Variants§

§

Var(TyVarRef)

§

Base(BaseType)

§

Func(Box<Row>, Box<MonoType>, Box<MonoType>)

?(row) dom -> cod — a function type carrying a labeled optional-argument Row (upstream FuncType of row * typ * typ, SATySFi 0.1). The row is Row::Empty for every 0.0.6-constructed function (crate::prim_types::arrow), printing nothing and unifying trivially, so 0.0.6 behavior is byte-identical. A non-empty row (Cons(label, option-payload-type, …)) records the value-level ?(l = e) labeled optional arguments the function accepts. The field is positional (no .. in any destructure) deliberately: widening this variant makes the compiler flag every match site, guarding against a silently-dropped row in the sealed-module subsumption path.

The row is boxed (Box<Row>, not inline) so widening Func does not enlarge MonoType itself: Row is a ~40-byte enum, and inlining it would make Func the largest variant, growing every stack frame holding a MonoType by value enough to tip a deep recursive typecheck over the default stack. Box<Row> keeps MonoType at its pre-widening size, so 0.0.6 stack usage is unchanged.

§

Product(Vec<MonoType>)

A tuple type, always with at least two elements.

§

List(Box<MonoType>)

§

Ref(Box<MonoType>)

§

Record(Row)

§

Variant(String, Vec<MonoType>)

A user-defined variant type applied to its arguments, e.g. Variant("option", [int]) for int option. Identified by name rather than by a fresh TypeID.t as in v0.0.6 (types.cppo.ml:318) — this port has no notion of shadowing/re-declaring a variant type under the same name within one compilation, so a String is a simpler stand-in for v0.0.6’s globally-fresh TypeID.t.

§

Code(Box<MonoType>)

code ty — the type of a quoted (&e) fragment awaiting the next stage. Upstream’s CodeType (types.cppo.ml:324). Structurally it behaves exactly like MonoType::Ref: one covariant argument, unified pointwise.

§

InlineCmd(Vec<CmdArgType>)

[...] inline-cmd (v0.0.6: HorzCommandType).

§

BlockCmd(Vec<CmdArgType>)

[...] block-cmd (v0.0.6: VertCommandType).

§

MathCmd(Vec<CmdArgType>)

[...] math-cmd (v0.0.6: MathCommandType).

Implementations§

Source§

impl MonoType

Source

pub fn visit<__T>(&self, visitor: impl IntoVisitor<__T>) -> &Self

Visit self with any Visit, returning self to chain.

Source§

impl MonoType

Source

pub fn visit_mut<__T>(&mut self, visitor: impl IntoVisitorMut<__T>) -> &mut Self

Visit self with any VisitMut, returning self to chain.

Trait Implementations§

Source§

impl Ast for MonoType

Source§

impl Clone for MonoType

Source§

fn clone(&self) -> MonoType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MonoType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for MonoType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<__F: FnMut(&MonoType)> IntoHook<MonoType> for __F

Source§

fn into_hook(self) -> impl Hook

Source§

impl<__F: FnMut(&mut MonoType)> IntoHookMut<MonoType> for __F

Source§

impl<__F: FnMut(&MonoType)> IntoVisitor<MonoType> for __F

Source§

fn into_visitor(self) -> impl Visit

Source§

impl<__F: FnMut(&mut MonoType)> IntoVisitorMut<MonoType> for __F

Source§

impl Repeater<0> for MonoType

Source§

type Type = String

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<1> for MonoType

Source§

type Type = TyVarRef

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<2> for MonoType

Source§

type Type = BaseType

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<3> for MonoType

Source§

type Type = Box<MonoType>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<4> for MonoType

Source§

type Type = Box<Row>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<5> for MonoType

Source§

type Type = Vec<CmdArgType>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<6> for MonoType

Source§

type Type = Vec<MonoType>

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.
Source§

impl Repeater<7> for MonoType

Source§

type Type = Row

The leaked type, valid in the referrer’s context via <T as Repeater<INDEX>>::Type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Clone for T
where T: Clone,

Source§

fn clone(&self) -> T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Debug for T
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Source§

impl<T> Display for T
where T: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V