Skip to content

Commit

Permalink
Rename FunctionType::pure -> closed
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Nov 1, 2023
1 parent 4691a24 commit 6b0249d
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 28 deletions.
6 changes: 4 additions & 2 deletions src/builder/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ mod test {
fn basic_module_cfg() -> Result<(), BuildError> {
let build_result = {
let mut module_builder = ModuleBuilder::new();
let mut func_builder = module_builder
.define_function("main", FunctionType::new(vec![NAT], type_row![NAT]).pure())?;
let mut func_builder = module_builder.define_function(
"main",
FunctionType::new(vec![NAT], type_row![NAT]).closed(),
)?;
let _f_id = {
let [int] = func_builder.input_wires_arr();

Expand Down
4 changes: 2 additions & 2 deletions src/builder/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mod test {
#[test]
fn simple_linear() {
let build_res = build_main(
FunctionType::new(type_row![QB, QB], type_row![QB, QB]).pure(),
FunctionType::new(type_row![QB, QB], type_row![QB, QB]).closed(),
|mut f_build| {
let wires = f_build.input_wires().collect();

Expand Down Expand Up @@ -184,7 +184,7 @@ mod test {
.into(),
);
let build_res = build_main(
FunctionType::new(type_row![QB, QB, NAT], type_row![QB, QB, BOOL_T]).pure(),
FunctionType::new(type_row![QB, QB, NAT], type_row![QB, QB, BOOL_T]).closed(),
|mut f_build| {
let [q0, q1, angle]: [Wire; 3] = f_build.input_wires_arr();

Expand Down
2 changes: 1 addition & 1 deletion src/builder/conditional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ mod test {
let mut module_builder = ModuleBuilder::new();
let mut fbuild = module_builder.define_function(
"main",
FunctionType::new(type_row![NAT], type_row![NAT]).pure(),
FunctionType::new(type_row![NAT], type_row![NAT]).closed(),
)?;
let tru_const = fbuild.add_constant(Const::true_val(), ExtensionSet::new())?;
let _fdef = {
Expand Down
12 changes: 6 additions & 6 deletions src/builder/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub(crate) mod test {
let _f_id = {
let mut func_builder = module_builder.define_function(
"main",
FunctionType::new(type_row![NAT, QB], type_row![NAT, QB]).pure(),
FunctionType::new(type_row![NAT, QB], type_row![NAT, QB]).closed(),
)?;

let [int, qb] = func_builder.input_wires_arr();
Expand Down Expand Up @@ -272,7 +272,7 @@ pub(crate) mod test {

let f_build = module_builder.define_function(
"main",
FunctionType::new(type_row![BOOL_T], type_row![BOOL_T, BOOL_T]).pure(),
FunctionType::new(type_row![BOOL_T], type_row![BOOL_T, BOOL_T]).closed(),
)?;

f(f_build)?;
Expand Down Expand Up @@ -322,7 +322,7 @@ pub(crate) mod test {

let f_build = module_builder.define_function(
"main",
FunctionType::new(type_row![QB], type_row![QB, QB]).pure(),
FunctionType::new(type_row![QB], type_row![QB, QB]).closed(),
)?;

let [q1] = f_build.input_wires_arr();
Expand All @@ -339,7 +339,7 @@ pub(crate) mod test {
let builder = || -> Result<Hugr, BuildError> {
let mut f_build = FunctionBuilder::new(
"main",
FunctionType::new(type_row![BIT], type_row![BIT]).pure(),
FunctionType::new(type_row![BIT], type_row![BIT]).closed(),
)?;

let [i1] = f_build.input_wires_arr();
Expand All @@ -363,7 +363,7 @@ pub(crate) mod test {
fn error_on_linear_inter_graph_edge() -> Result<(), BuildError> {
let mut f_build = FunctionBuilder::new(
"main",
FunctionType::new(type_row![QB], type_row![QB]).pure(),
FunctionType::new(type_row![QB], type_row![QB]).closed(),
)?;

let [i1] = f_build.input_wires_arr();
Expand Down Expand Up @@ -407,7 +407,7 @@ pub(crate) mod test {
{
let mut f_build = module_builder.define_function(
"main",
FunctionType::new(type_row![BIT], type_row![BIT]).pure(),
FunctionType::new(type_row![BIT], type_row![BIT]).closed(),
)?;

let [i1] = f_build.input_wires_arr();
Expand Down
8 changes: 4 additions & 4 deletions src/builder/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ mod test {

let f_id = module_builder.declare(
"main",
FunctionType::new(type_row![NAT], type_row![NAT]).pure(),
FunctionType::new(type_row![NAT], type_row![NAT]).closed(),
)?;

let mut f_build = module_builder.define_declaration(&f_id)?;
Expand All @@ -217,7 +217,7 @@ mod test {
vec![qubit_state_type.get_alias_type()],
vec![qubit_state_type.get_alias_type()],
)
.pure(),
.closed(),
)?;
n_identity(f_build)?;
module_builder.finish_hugr(&EMPTY_REG)
Expand All @@ -233,11 +233,11 @@ mod test {

let mut f_build = module_builder.define_function(
"main",
FunctionType::new(type_row![NAT], type_row![NAT]).pure(),
FunctionType::new(type_row![NAT], type_row![NAT]).closed(),
)?;
let local_build = f_build.define_function(
"local",
FunctionType::new(type_row![NAT], type_row![NAT]).pure(),
FunctionType::new(type_row![NAT], type_row![NAT]).closed(),
)?;
let [wire] = local_build.input_wires_arr();
let f_id = local_build.finish_with_outputs([wire])?;
Expand Down
2 changes: 1 addition & 1 deletion src/hugr/rewrite/outline_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ mod test {
let mut fbuild = module_builder
.define_function(
"main",
FunctionType::new(type_row![USIZE_T], type_row![USIZE_T]).pure(),
FunctionType::new(type_row![USIZE_T], type_row![USIZE_T]).closed(),
)
.unwrap();
let [i1] = fbuild.input_wires_arr();
Expand Down
2 changes: 1 addition & 1 deletion src/hugr/rewrite/simple_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub(in crate::hugr::rewrite) mod test {
let _f_id = {
let mut func_builder = module_builder.define_function(
"main",
FunctionType::new(type_row![QB, QB, QB], type_row![QB, QB, QB]).pure(),
FunctionType::new(type_row![QB, QB, QB], type_row![QB, QB, QB]).closed(),
)?;

let [qb0, qb1, qb2] = func_builder.input_wires_arr();
Expand Down
4 changes: 2 additions & 2 deletions src/hugr/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ pub mod test {

let t_row = vec![Type::new_sum(vec![NAT, QB])];
let mut f_build = module_builder
.define_function("main", FunctionType::new(t_row.clone(), t_row).pure())
.define_function("main", FunctionType::new(t_row.clone(), t_row).closed())
.unwrap();

let outputs = f_build
Expand Down Expand Up @@ -393,7 +393,7 @@ pub mod test {
let mut module_builder = ModuleBuilder::new();
let t_row = vec![Type::new_sum(vec![NAT, QB])];
let mut f_build = module_builder
.define_function("main", FunctionType::new(t_row.clone(), t_row).pure())
.define_function("main", FunctionType::new(t_row.clone(), t_row).closed())
.unwrap();

let outputs = f_build
Expand Down
4 changes: 2 additions & 2 deletions src/hugr/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ mod test {
let mut module_builder = ModuleBuilder::new();
let mut main = module_builder.define_function(
"main",
FunctionType::new(type_row![NAT], type_row![NAT]).pure(),
FunctionType::new(type_row![NAT], type_row![NAT]).closed(),
)?;
let [main_input] = main.input_wires_arr();

Expand Down Expand Up @@ -1220,7 +1220,7 @@ mod test {
fn too_many_extension() -> Result<(), BuildError> {
let mut module_builder = ModuleBuilder::new();

let main_sig = FunctionType::new(type_row![NAT], type_row![NAT]).pure();
let main_sig = FunctionType::new(type_row![NAT], type_row![NAT]).closed();

let mut main = module_builder.define_function("main", main_sig)?;
let [main_input] = main.input_wires_arr();
Expand Down
2 changes: 1 addition & 1 deletion src/hugr/views/descendants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub(super) mod test {
let (f_id, inner_id) = {
let mut func_builder = module_builder.define_function(
"main",
FunctionType::new(type_row![NAT, QB], type_row![NAT, QB]).pure(),
FunctionType::new(type_row![NAT, QB], type_row![NAT, QB]).closed(),
)?;

let [int, qb] = func_builder.input_wires_arr();
Expand Down
2 changes: 1 addition & 1 deletion src/hugr/views/sibling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ mod test {
fn nested_flat() -> Result<(), Box<dyn std::error::Error>> {
let mut module_builder = ModuleBuilder::new();
let fty = FunctionType::new(type_row![NAT], type_row![NAT]);
let mut fbuild = module_builder.define_function("main", fty.clone().pure())?;
let mut fbuild = module_builder.define_function("main", fty.clone().closed())?;
let dfg = fbuild.dfg_builder(fty, None, fbuild.input_wires())?;
let ins = dfg.input_wires();
let sub_dfg = dfg.finish_with_outputs(ins)?;
Expand Down
6 changes: 3 additions & 3 deletions src/hugr/views/sibling_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ mod tests {
let mut mod_builder = ModuleBuilder::new();
let func = mod_builder.declare(
"test",
FunctionType::new_linear(type_row![QB_T, QB_T, QB_T]).pure(),
FunctionType::new_linear(type_row![QB_T, QB_T, QB_T]).closed(),
)?;
let func_id = {
let mut dfg = mod_builder.define_declaration(&func)?;
Expand All @@ -750,7 +750,7 @@ mod tests {
fn build_3not_hugr() -> Result<(Hugr, Node), BuildError> {
let mut mod_builder = ModuleBuilder::new();
let func =
mod_builder.declare("test", FunctionType::new_linear(type_row![BOOL_T]).pure())?;
mod_builder.declare("test", FunctionType::new_linear(type_row![BOOL_T]).closed())?;
let func_id = {
let mut dfg = mod_builder.define_declaration(&func)?;
let outs1 = dfg.add_dataflow_op(not_op(), dfg.input_wires())?;
Expand All @@ -769,7 +769,7 @@ mod tests {
let mut mod_builder = ModuleBuilder::new();
let func = mod_builder.declare(
"test",
FunctionType::new(type_row![BOOL_T], type_row![BOOL_T]).pure(),
FunctionType::new(type_row![BOOL_T], type_row![BOOL_T]).closed(),
)?;
let func_id = {
let mut dfg = mod_builder.define_declaration(&func)?;
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub(crate) use impl_box_clone;
/// const U: Type = Type::UNIT;
/// let static_row: TypeRow = type_row![U, U];
/// let dynamic_row: TypeRow = vec![U, U, U].into();
/// let sig = FunctionType::new(static_row, dynamic_row).pure();
/// let sig = FunctionType::new(static_row, dynamic_row).closed();
///
/// let repeated_row: TypeRow = type_row![U; 3];
/// assert_eq!(repeated_row, *sig.output());
Expand Down
2 changes: 1 addition & 1 deletion src/types/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl FunctionType {
}

/// Instantiate a signature with the empty set of extensions
pub fn pure(self) -> Signature {
pub fn closed(self) -> Signature {
self.with_input_extensions(ExtensionSet::new())
}
}
Expand Down

0 comments on commit 6b0249d

Please sign in to comment.