Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge kind specific HugrView methods #506

Closed
ss2165 opened this issue Sep 7, 2023 · 0 comments · Fixed by #680
Closed

Edge kind specific HugrView methods #506

ss2165 opened this issue Sep 7, 2023 · 0 comments · Fixed by #680
Assignees
Labels
enhancement New feature or request

Comments

@ss2165
Copy link
Member

ss2165 commented Sep 7, 2023

Building on from #499, given we have a finite number of edge kinds and restrictions on their use, we should have specific methods for querying those connections. I propose:

    // just value ports
    fn value_ports(&self, node: Node, direction: Direction) -> Self::PortLinks<'_>;
    fn value_neighbours(&self, node: Node, direction: Direction) -> Self::Neighbours<'_>;
    // companion to linked_ports, a linear value port must have one target
    fn linked_liner_port(&self, node: Node, port: Port) -> Option<(Node, Port)>;

    // all Value + Order neighbours
    fn dataflow_neighbours(&self, node: Node, direction: Direction) -> Self::Neighbours<'_>;
    
    fn order_neighbours(&self, node: Node, direction: Direction) -> impl Iterator<Item=Node>;

    // can only be one static input
    fn static_source(&self, node: Node) -> Option<Node>;

    // can be many static targets from one port
    fn static_targets(&self, node: Node) -> impl Iterator<Node>;

    // same as static but for cfg nodes
    fn previous_block(&self, node: Node) -> Option<Node>;
    fn next_blocks(&self, node: Node) -> impl Iterator<Node>;

with these we should be able to minimise/nullify the use of OpType methods like other_edge_kind static_port other_edge_port (so this is also an alternative to #495)

@ss2165 ss2165 added enhancement New feature or request P-medium labels Sep 7, 2023
@ss2165 ss2165 self-assigned this Nov 9, 2023
github-merge-queue bot pushed a commit that referenced this issue Nov 15, 2023
- [x] Closes #495
- [x] Closes #521
- [x] Closes #655
- [x] Closes #499
- [x] Closes #506 
- [x] Closes #653
- [x] `OpType::signature` returns option (non-dataflow ops don't return
signature)
- [x] Implement `try_into` from OpType references in to inner
references.

Doesn't necessarily do exactly as those issues specify - instead
considers them holistically for a more unified interface. Easiest to
review commit by commit.

Uses rust_version crate to use return position impl for the new
`HugrView` methods that return iterators. This will be stable with 1.75
(which enters beta in a few days).

BREAKING_CHANGES: `OpType` and `FunctionType` methods renamed for
clarity; `OpType::signature` returns `Option<FuncType>`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant