CQCL / hugr

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

Detect special type cases in python deserialisation #1483

Open aborgna-q opened 2 weeks ago

aborgna-q commented 2 weeks ago

Convert Sums into UnitSum / Tuple / Option / Result as appropriate.

Auto detection on round trip was left as a todo/future consideration because it also has implications how how we treat implementer of AsExtOp. Said operations would also have to register themselves with deserialization. Probably worth making an issue about this to discuss.

Originally posted by @ss2165 in https://github.com/CQCL/hugr/issues/1481#issuecomment-2317520884

ss2165 commented 2 weeks ago

A related problem is when different instances are equivalent in internal representation. I.e. if a user specified a Result<T, ()> should a roundtrip happily turn that in to Option<T>? Not ideal.

aborgna-q commented 2 weeks ago

Not ideal, but it's unavoidable unless we want to encode every different specialisation as serialisation variants.