CQCL / hugr

Hierarchical Unified Graph Representation for quantum and classical programs
https://crates.io/crates/hugr
Apache License 2.0
18 stars 5 forks source link

Parametrize Type by trait MaybeRV #1236

Closed acl-cqc closed 3 months ago

acl-cqc commented 3 months ago

This enforces "no RowVars in a Type" via Rust, rather than via our checks - we have TypeBase<NoRV> or TypeBase<RowVariable>, with NoRV an empty enum.

There's a bunch more boilerplate (trivial function definitions for NoRV + RowVariable), so overall it's longer, but it removes the less-than-ideal manual checks and asserts and things, including removing the Implies struct :-)

proptest threw up some tricky bits, as I can't declare MaybeRV: Arbitrary (without making non-test builds depend upon proptest....). There are a couple of non-compiling commits before the last if you want to see other things I tried...I was puzzled why #[derive(Arbitrary)] on struct Signature<RV: MaybeRV> seemed to be generating an impl <RV: MaybeRV> Arbitrary for Signature that didn't bound on RV: MaybeRV + Arbitrary, the #[proptest(no_bound)] exists to remove said Arbitrary if you don't need it but there doesn't seem to be the opposite #[proptest(yes_bound)] :-(....hence in the end the #[cfg(test)] fn arb.

See what you think??

acl-cqc commented 3 months ago

Thanks, @doug-q - I've fmtd and fixed cargo doc, OK to merge this into #1138 ?