pub enum TypeExpr {
OptRowFun {
opt_dom: TypeOptDomV1,
dom: TypeProd,
arrow: ArrowTok,
cod: Box<TypeExpr>,
},
Fun {
dom: TypeProd,
arrow: ArrowTok,
cod: Box<TypeExpr>,
},
Atom(TypeProd),
}Expand description
A type-expression grammar (typ/typ_prod/typ_app/typ_bot,
parser_v1.mly:685-752, simplified — same scope as
crate::cst::ast::TypeExpr). Spells products (length * length,
TypeProd) and prefix type application (list int, TypeApp) —
without them a type bind could declare almost nothing — plus the
?(…) labeled-optional domain prefix
(TypeExpr::OptRowFun), where a
row-variable TAIL (?(… | ?'r) ->) parses but is rejected at
lowering (it needs signature-level row quantification, not yet
implemented). Self-recursive only through Fun’s/OptRowFun’s
codomain (right recursion); parenthesized nesting goes through
super::TyErasedV1.
Variants§
OptRowFun
?(l : ty, … [| ?'r]) dom -> cod (typ :688-693, typ_opt_dom
:753-758). ?-headed — neither
Fun/Atom (headed by TypeProd) can start with
OptionalTypeTok, so declared order relative to them is
safety-neutral; declared first to mirror the upstream typ
production order. Lowered (v1/lower.rs) to
cst::ast::TypeExpr::OptRowFun, thence (typecheck.rs) to
MonoType::Func(Row::Cons(l1, ty1, … Row::Empty), dom, cod) — a
CLOSED row, matching what Ast::LambdaOpt infers,
so an explicit ?(l:τ)-> signature unifies against an actual
?(l=x)-taking function.
Fun
dom -> cod (right-associative). This field is TypeExpr’s own
self-loop (the root SCC). dom widened from TypeAtom to
TypeProd so e.g. 'a option -> 'b option and
'a * 'b -> 'c both parse at their expected precedence.
Atom(TypeProd)
Trait Implementations§
Source§impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for TypeExpr
impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for TypeExpr
Source§type Error = <TypeExpr as ParseRanked8909385c15d27adc<(((),),), __SyanMacro_Atom>>::Error
type Error = <TypeExpr as ParseRanked8909385c15d27adc<(((),),), __SyanMacro_Atom>>::Error
<FieldTy as Parse<Atom>>::Error: Into<…> predicate re-creates a projection cycle on a
recursive field (E0275), which decycle’s bound-peeling does not break.