You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Includes removing Row Variables and <RV> parametrization from Types, instead using Term::ListConcat/TupleConcat.
Add Term::RuntimeSum - i.e. equivalent to Type::Sum, storing a SumType. (Serializes to core.adt, code already present)
SumType could become either
A Term of type Term::ListType(Term::ListType(Term::RuntimeType(x))) if we want to allow the number of variants to be extensible, or
A Vec<Term> each of type Term::ListType(Term::RuntimeType(x)) if we want fixed #variants but variable number of elements in each variant - this is equivalent to current SumType storing a Vec<Vec<Type<RV>
May also want the Simple/Unit(num variants) option for efficient storage
May want to cache the computed TypeBound inside the SumType, as we do not have Term/TermEnum (like current Type/TypeEnum) so cannot cache the bound there
Add Term::RuntimeFunc - to support row vars, this stores a Term for inputs and another for outputs, each of type Term::ListType(Term::RuntimeType(x))
Add Term::RuntimeExtension i.e. paralleling current Type::Extension (but currently for runtime types only. In model-style Custom constructors in hugr-core, i.e. TypeDef -> TermDef #2296 we'll make this into Term::Extension that can be any term, so perhaps best to call it that now, even if a little inconsistent.)
Each of these check_term_types against Term::RuntimeType (of appropriate TypeBound)
Remove Term::Runtime and define type Type = Term for now. However, anything that was Type (i.e. TypeBase<NoRV>) now needs to be check_term_typed against Term::RuntimeType(TypeBound::Linear) - this may be a large part of the PR (making up for the loss of the Type/Term distinction in Rust), and/or may just mean combining check_term_type with TypeBase::validate.
Signature (no toplevel row vars) has Vec<Term> (each element of type Term::RuntimeType) for inputs/outputs
Note difference between SumType (has row vars) and Vec<Vec<Type>> (no RowVars); we can convert rowvar-less sumtypes into the latter form by matching Term::List (not ListConcat).
Serialization
Believe no change to hugr-model here so serialization should remain backwards-compatible; more of hugr-model becomes convertible into hugr-core, but (until we do any of the followup issues) remains invalid in hugr-core. Likely quite breaking for Rust code using hugr-core....
Merging Types and Terms would allow runtime types to profit from the sharing enabled by reference counted terms (see feat!: Reference counted terms #2338). Runtime types are the primary source of heavily duplicated terms, so this could have a large performance benefit (especially on model deserialisation).
Includes removing Row Variables and
<RV>parametrization from Types, instead using Term::ListConcat/TupleConcat.core.adt, code already present)Term::ListType(Term::ListType(Term::RuntimeType(x)))if we want to allow the number of variants to be extensible, orVec<Term>each of typeTerm::ListType(Term::RuntimeType(x))if we want fixed #variants but variable number of elements in each variant - this is equivalent to current SumType storing aVec<Vec<Type<RV>Term::ListType(Term::RuntimeType(x))Term::RuntimeExtensioni.e. paralleling current Type::Extension (but currently for runtime types only. In model-style Custom constructors in hugr-core, i.e. TypeDef -> TermDef #2296 we'll make this into Term::Extension that can be any term, so perhaps best to call it that now, even if a little inconsistent.)check_term_types againstTerm::RuntimeType(of appropriate TypeBound)type Type = Termfor now. However, anything that wasType(i.e.TypeBase<NoRV>) now needs to becheck_term_typed againstTerm::RuntimeType(TypeBound::Linear)- this may be a large part of the PR (making up for the loss of the Type/Term distinction in Rust), and/or may just mean combiningcheck_term_typewithTypeBase::validate.TypeRVis more like a list of type; again we have lost Rust automatically checking of what's got RVs vs not, i.e. reverting refactor!: Separate Signature from FuncValueType by parametrizing Type(/Row)/etc. #1138, but theListConcat/TupleConcatis much nicer than what we had before refactor!: Separate Signature from FuncValueType by parametrizing Type(/Row)/etc. #1138.)Signature(no toplevel row vars) hasVec<Term>(each element of type Term::RuntimeType) for inputs/outputsVec<Vec<Type>>(no RowVars); we can convert rowvar-less sumtypes into the latter form by matching Term::List (not ListConcat).Serialization
Believe no change to hugr-model here so serialization should remain backwards-compatible; more of hugr-model becomes convertible into hugr-core, but (until we do any of the followup issues) remains invalid in hugr-core. Likely quite breaking for Rust code using hugr-core....
Related Issues
Types andTerms would allow runtime types to profit from the sharing enabled by reference counted terms (see feat!: Reference counted terms #2338). Runtime types are the primary source of heavily duplicated terms, so this could have a large performance benefit (especially on model deserialisation).