Skip to content

Conversation

@acl-cqc
Copy link
Collaborator

@acl-cqc acl-cqc commented Dec 17, 2025

  • Refactor parent outside HugrOp
  • Make abstract Hugr/Graph type.
    • TODO: More renaming. e.g. the new Hugr could just be HugrGraph(edit: done)
    • Stores 2-way edges
    • separates parent from op, and separates out the root.
    • parent-ness is now set when the name is created, not when the op is set (which may be later).
    • Also contains Namespace
    • and may record 2 children of each op to order first in output. This is hackily used for Conditionals so
    • TODO: make that a list not a pair
    • TODO: since we now have setFirstChildren we can remove the freshNodeWithIO and newWithIO from HugrGraph and do that work in the compile monad.
  • Hence, also drop ordering of HugrOp, remove index from Case.

What do you think of onHugr? My thoughts were

  • (blah ->) HugrGraph -> (a, HugrGraph) becoming (blah ->) State HugrGraph a seems like a win
  • but State HugrGraph () rather than HugrGraph -> HugrGraph seems a bit clunky in HugrGraph.hs
    • I could keep those as HG->HG if I added another function like onHugr (probably using modify \s -> s {hugr=f (hugr s)}), but is it worth having two onHugrs?

No actual splicing of Hugrs yet but everything we need for that is here.

A nice follow-up would probably be to move parent into the Compile monad, but nvm.

Done on main as that has the most test-cases for Hugr generation (compilation of many classical cases removed in stack-machine branch so would not be as well-tested there).

  • TODO: failure in closures.brat (malformed Bratgraph?) needs turning into an issue

@acl-cqc acl-cqc marked this pull request as ready for review December 18, 2025 13:36
@acl-cqc acl-cqc force-pushed the refactor/hugr_graph branch from b242b34 to 0651887 Compare December 20, 2025 09:24
@acl-cqc acl-cqc requested a review from croyzor December 20, 2025 09:28
@acl-cqc acl-cqc force-pushed the refactor/hugr_graph branch from 0651887 to 365dddc Compare December 20, 2025 10:12
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.

2 participants