Skip to content

refactor(hugrv2)!: Rename Terms to clarify (runtime) Types from static parameter Kinds#3019

Open
acl-cqc wants to merge 6 commits intomainfrom
acl/rename_type_kind
Open

refactor(hugrv2)!: Rename Terms to clarify (runtime) Types from static parameter Kinds#3019
acl-cqc wants to merge 6 commits intomainfrom
acl/rename_type_kind

Conversation

@acl-cqc
Copy link
Copy Markdown
Contributor

@acl-cqc acl-cqc commented Apr 7, 2026

[Note: this will textually conflict with #3022, will have to merge whichever is approved second but I think should b straightforward.]

Using Type to mean a static parameter (that accepts a static Term argument) is confusing; instead keep Type as meaning a type of runtime values

  • Term::RuntimeType becomes Term::TypeKind
  • Term::XXXType becomes Term:::XXXKind (e.g. StringType -> StringKind, ListType -> ListKind)
  • Term::RuntimeXXX becomes Term::XXXType (e.g. Term::RuntimeExtension -> Term::ExtensionType)
  • check_term_type -> check_term_kind

Question Should we also change TermTypeError::TypeMismatch { term, type_} to TermTypeError::KindMismatch {value, kind}? I guess we should??

BREAKING CHANGE: many renames of variants of Term; ...Types are now Kinds, Runtime... are now Types. Also check_term_type is now check_term_kind

@acl-cqc acl-cqc changed the title Acl/rename type kind refactor(hugrv2)!: Rename Terms to distinguish (runtime) Types from static parameter Kinds Apr 7, 2026
@acl-cqc acl-cqc changed the title refactor(hugrv2)!: Rename Terms to distinguish (runtime) Types from static parameter Kinds refactor(hugrv2)!: Rename Terms to clarify (runtime) Types from static parameter Kinds Apr 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 77.30769% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.34%. Comparing base (2dec804) to head (9dbfbc3).

Files with missing lines Patch % Lines
hugr-core/src/types/type_param.rs 70.22% 39 Missing ⚠️
hugr-core/src/types/serialize.rs 84.00% 4 Missing ⚠️
hugr-core/src/extension/op_def.rs 25.00% 0 Missing and 3 partials ⚠️
hugr-core/src/extension/resolution/types.rs 57.14% 3 Missing ⚠️
hugr-core/src/extension/resolution/types_mut.rs 57.14% 3 Missing ⚠️
hugr-core/src/import.rs 66.66% 2 Missing and 1 partial ⚠️
hugr-core/src/export.rs 83.33% 2 Missing ⚠️
hugr-core/src/extension/type_def.rs 75.00% 1 Missing ⚠️
hugr-core/src/types/type_row.rs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           acl/boundless_type    #3019      +/-   ##
======================================================
- Coverage               81.34%   81.34%   -0.01%     
======================================================
  Files                     239      239              
  Lines                   45285    45284       -1     
  Branches                39053    39052       -1     
======================================================
- Hits                    36837    36836       -1     
  Misses                   6446     6446              
  Partials                 2002     2002              
Flag Coverage Δ
python 88.89% <ø> (ø)
rust 80.13% <77.30%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 28, 2026

Merging this PR will improve performance by 17.58%

⚡ 1 improved benchmark
✅ 28 untouched benchmarks
⏩ 6 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
construction 20.2 µs 17.1 µs +17.58%

Comparing acl/rename_type_kind (9dbfbc3) with acl/type_wraps_term (aa82fb6)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@acl-cqc acl-cqc changed the base branch from acl/type_wraps_term to acl/boundless_type April 28, 2026 11:07
@acl-cqc acl-cqc force-pushed the acl/boundless_type branch from 2dec804 to b45e61f Compare May 5, 2026 12:48
@hugrbot
Copy link
Copy Markdown
Collaborator

hugrbot commented May 5, 2026

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary
    Building hugr v0.27.1 (current)
     Built [  34.403s] (current)
   Parsing hugr v0.27.1 (current)
    Parsed [   0.004s] (current)
  Building hugr v0.27.1 (baseline)
     Built [  34.753s] (baseline)
   Parsing hugr v0.27.1 (baseline)
    Parsed [   0.004s] (baseline)
  Checking hugr v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.012s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  70.706s] hugr
  Building hugr-cli v0.27.1 (current)
     Built [  28.363s] (current)
   Parsing hugr-cli v0.27.1 (current)
    Parsed [   0.006s] (current)
  Building hugr-cli v0.27.1 (baseline)
     Built [  28.398s] (baseline)
   Parsing hugr-cli v0.27.1 (baseline)
    Parsed [   0.006s] (baseline)
  Checking hugr-cli v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.016s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  58.107s] hugr-cli
  Building hugr-core v0.27.1 (current)
     Built [  24.815s] (current)
   Parsing hugr-core v0.27.1 (current)
    Parsed [   0.084s] (current)
  Building hugr-core v0.27.1 (baseline)
     Built [  24.900s] (baseline)
   Parsing hugr-core v0.27.1 (baseline)
    Parsed [   0.078s] (baseline)
  Checking hugr-core v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.209s] 196 checks: 189 pass, 7 fail, 0 warn, 56 skip

--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/enum_missing.ron

Failed in:
enum hugr_core::types::NoRV, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/row_var.rs:55
enum hugr_core::types::TypeEnum, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types.rs:332

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/enum_variant_missing.ron

Failed in:
variant Term::Runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:100
variant Term::Runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:100
variant Term::Runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:100
variant Term::Runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:100
variant Term::Runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:100
variant SignatureError::RowVarWhereTypeExpected, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/extension.rs:523

--- failure function_requires_different_generic_type_params: function now requires a different number of generic type parameters ---

Description:
A function now requires a different number of generic type parameters than it used to. Uses of this function that supplied the previous number of generic types (e.g. via turbofish syntax) will be broken.
      ref: https://doc.rust-lang.org/reference/items/generics.html
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/function_requires_different_generic_type_params.ron

Failed in:
function resolve_type_extensions (1 -> 0 generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/extension/resolution.rs:45

--- failure inherent_associated_pub_const_missing: inherent impl's associated pub const removed ---

Description:
An inherent impl's associated public constant is removed or renamed
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/inherent_associated_pub_const_missing.ron

Failed in:
Term::UNIT, previously at /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:284
Term::UNIT, previously at /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:284
Term::UNIT, previously at /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:284
Term::UNIT, previously at /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:284
Term::UNIT, previously at /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:284

--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/inherent_method_missing.ron

Failed in:
FuncTypeBase::find_rowvar, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/signature.rs:139
AliasID::get_alias_type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/ops/handle.rs:93
SumType::as_unary_option, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types.rs:295
Term::new_list_concat, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:311
Term::as_runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:338
Term::new_list_concat, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:311
Term::as_runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:338
Term::new_list_concat, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:311
Term::as_runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:338
Term::new_list_concat, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:311
Term::as_runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:338
Term::new_list_concat, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:311
Term::as_runtime, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:338

--- failure method_requires_different_generic_type_params: method now requires a different number of generic type parameters ---

Description:
A method now requires a different number of generic type parameters than it used to. Uses of this method that supplied the previous number of generic types will be broken.
      ref: https://doc.rust-lang.org/reference/items/generics.html
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/method_requires_different_generic_type_params.ron

Failed in:
hugr_core::extension::resolution::ExtensionCollectionError::dropped_signature takes 0 generic types instead of 1, in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/extension/resolution.rs:260
hugr_core::extension::resolution::ExtensionCollectionError::dropped_type takes 0 generic types instead of 1, in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/extension/resolution.rs:271
hugr_core::types::type_param::TypeArg::new_list takes 1 generic types instead of 0, in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/types/type_param.rs:193
hugr_core::types::TypeArg::new_list takes 1 generic types instead of 0, in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/types/type_param.rs:193
hugr_core::types::type_param::TypeParam::new_list takes 1 generic types instead of 0, in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/types/type_param.rs:193
hugr_core::types::type_param::Term::new_list takes 1 generic types instead of 0, in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/types/type_param.rs:193
hugr_core::types::Term::new_list takes 1 generic types instead of 0, in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/types/type_param.rs:193

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/struct_missing.ron

Failed in:
struct hugr_core::types::RowVariable, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/row_var.rs:17
struct hugr_core::types::type_param::ListPartIter, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:765
struct hugr_core::types::TypeBase, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types.rs:403
struct hugr_core::types::type_row::TypeRowBase, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_row.rs:23
struct hugr_core::types::type_param::TuplePartIter, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-core/src/types/type_param.rs:800

   Summary semver requires new major version: 7 major and 0 minor checks failed
  Finished [  51.234s] hugr-core
  Building hugr-llvm v0.27.1 (current)
     Built [  29.217s] (current)
   Parsing hugr-llvm v0.27.1 (current)
    Parsed [   0.011s] (current)
  Building hugr-llvm v0.27.1 (baseline)
     Built [  29.161s] (baseline)
   Parsing hugr-llvm v0.27.1 (baseline)
    Parsed [   0.011s] (baseline)
  Checking hugr-llvm v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.043s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  60.052s] hugr-llvm
  Building hugr-model v0.27.1 (current)
     Built [  10.645s] (current)
   Parsing hugr-model v0.27.1 (current)
    Parsed [   0.015s] (current)
  Building hugr-model v0.27.1 (baseline)
     Built [  10.637s] (baseline)
   Parsing hugr-model v0.27.1 (baseline)
    Parsed [   0.015s] (baseline)
  Checking hugr-model v0.27.1 -> v0.27.1 (assume minor change)
   Checked [   0.030s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  22.016s] hugr-model
  Building hugr-persistent v0.6.1 (current)
     Built [  21.900s] (current)
   Parsing hugr-persistent v0.6.1 (current)
    Parsed [   0.008s] (current)
  Building hugr-persistent v0.6.1 (baseline)
     Built [  22.037s] (baseline)
   Parsing hugr-persistent v0.6.1 (baseline)
    Parsed [   0.007s] (baseline)
  Checking hugr-persistent v0.6.1 -> v0.6.1 (assume minor change)
   Checked [   0.013s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  45.441s] hugr-persistent

@acl-cqc acl-cqc force-pushed the acl/rename_type_kind branch from 45f1367 to 6ea5e65 Compare May 5, 2026 14:36
@acl-cqc acl-cqc changed the base branch from acl/boundless_type to main May 5, 2026 14:41
@acl-cqc acl-cqc marked this pull request as ready for review May 5, 2026 14:44
@acl-cqc acl-cqc requested a review from a team as a code owner May 5, 2026 14:44
@acl-cqc acl-cqc requested a review from cqc-alec May 5, 2026 14:44
Copy link
Copy Markdown
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Should we also change TermTypeError::TypeMismatch { term, type_} to TermTypeError::KindMismatch {value, kind}? I guess we should??

Yes I guess we should do that as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants