Skip to content

Commit

Permalink
feat!(tket2-hseries): Add tket2.wasm extension
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Change the signature of `FutureOpBuilder::add_read` to
return a `Wire` instead of a `[Wire;1]`
  • Loading branch information
doug-q committed Dec 27, 2024
1 parent 0c6101b commit bc7385a
Show file tree
Hide file tree
Showing 7 changed files with 843 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tket2-hseries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ derive_more = { workspace = true, features = [
"from",
"into",
] }
typetag.workspace = true

[dev-dependencies]
cool_asserts.workspace = true
Expand Down
1 change: 1 addition & 0 deletions tket2-hseries/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
pub mod futures;
pub mod qsystem;
pub mod result;
pub mod wasm;
6 changes: 3 additions & 3 deletions tket2-hseries/src/extension/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl TryFrom<&OpType> for FutureOpDef {
/// operations.
pub trait FutureOpBuilder: Dataflow {
/// Add a "tket2.futures.Read" op.
fn add_read(&mut self, lifted: Wire, typ: Type) -> Result<[Wire; 1], BuildError> {
fn add_read(&mut self, lifted: Wire, typ: Type) -> Result<Wire, BuildError> {
Ok(self
.add_dataflow_op(
FutureOp {
Expand All @@ -220,7 +220,7 @@ pub trait FutureOpBuilder: Dataflow {
},
[lifted],
)?
.outputs_arr())
.out_wire(0))
}

/// Add a "tket2.futures.Dup" op.
Expand Down Expand Up @@ -305,7 +305,7 @@ pub(crate) mod test {
let [future_w] = func_builder.input_wires_arr();
let [future_w, lazy_dup_w] = func_builder.add_dup(future_w, t.clone()).unwrap();
func_builder.add_free(future_w, t.clone()).unwrap();
let [t_w] = func_builder.add_read(lazy_dup_w, t).unwrap();
let t_w = func_builder.add_read(lazy_dup_w, t).unwrap();
func_builder.finish_hugr_with_outputs([t_w]).unwrap()
};
hugr.validate().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tket2-hseries/src/extension/qsystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ mod test {
.unwrap();
let [qb] = func_builder.input_wires_arr();
let [qb, lazy_b] = func_builder.add_lazy_measure(qb).unwrap();
let [b] = func_builder.add_read(lazy_b, bool_t()).unwrap();
let b = func_builder.add_read(lazy_b, bool_t()).unwrap();
func_builder.finish_hugr_with_outputs([qb, b]).unwrap()
};
assert_matches!(hugr.validate(), Ok(_));
Expand Down
Loading

0 comments on commit bc7385a

Please sign in to comment.