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

feat!: Move arrays from prelude into new extension #1770

Merged
merged 9 commits into from
Dec 11, 2024
2 changes: 2 additions & 0 deletions hugr-cli/tests/gen_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ fn test_extension_dump(mut cmd: Command) {
"arithmetic/int.json",
"arithmetic/float.json",
"arithmetic/conversions.json",
"collections/array.json",
"collections/list.json",
];
// check all paths exist
for path in expected_paths.iter() {
Expand Down
33 changes: 0 additions & 33 deletions hugr-core/src/extension/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ mod unwrap_builder;

pub use unwrap_builder::UnwrapBuilder;

/// Array type and operations.
pub mod array;
pub use array::{array_type, new_array_op, ArrayOp, ArrayOpDef, ARRAY_TYPE_NAME, NEW_ARRAY_OP_ID};

/// Name of prelude extension.
pub const PRELUDE_ID: ExtensionId = ExtensionId::new_unchecked("prelude");
/// Extension version.
Expand Down Expand Up @@ -77,14 +73,6 @@ lazy_static! {
extension_ref,
)
.unwrap();
prelude.add_type(
TypeName::new_inline(ARRAY_TYPE_NAME),
vec![ TypeParam::max_nat(), TypeBound::Any.into()],
"array".into(),
TypeDefBound::from_params(vec![1] ),
extension_ref,
)
.unwrap();
prelude
.add_type(
TypeName::new_inline("qubit"),
Expand Down Expand Up @@ -121,9 +109,6 @@ lazy_static! {
TupleOpDef::load_all_ops(prelude, extension_ref).unwrap();
NoopDef.add_to_extension(prelude, extension_ref).unwrap();
LiftDef.add_to_extension(prelude, extension_ref).unwrap();
array::ArrayOpDef::load_all_ops(prelude, extension_ref).unwrap();
array::ArrayRepeatDef.add_to_extension(prelude, extension_ref).unwrap();
array::ArrayScanDef.add_to_extension(prelude, extension_ref).unwrap();
})
};

Expand Down Expand Up @@ -1032,24 +1017,6 @@ mod test {
assert_eq!(new_op, op);
}

#[test]
/// Test building a HUGR involving a new_array operation.
fn test_new_array() {
let mut b = DFGBuilder::new(inout_sig(
vec![qb_t(), qb_t()],
array_type(TypeArg::BoundedNat { n: 2 }, qb_t()),
))
.unwrap();

let [q1, q2] = b.input_wires_arr();

let op = new_array_op(qb_t(), 2);

let out = b.add_dataflow_op(op, [q1, q2]).unwrap();

b.finish_hugr_with_outputs(out.outputs()).unwrap();
}

#[test]
fn test_option() {
let typ: Type = option_type(bool_t()).into();
Expand Down
Loading
Loading