qir-alliance / pyqir

PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR).
https://qir-alliance.github.io/pyqir
MIT License
58 stars 24 forks source link

Support external functions in generator #76

Closed bamarsha closed 2 years ago

bamarsha commented 2 years ago

Resolves #63. The additions to the API are:

I chose this representation for the types based on two main design goals:

  1. Basic LLVM type system rules should be statically checkable by mypy. For example, Void can be used as a return type, but not as the type of a value. In the future there will be additional rules, like Function can't be used as the type of a value unless it's wrapped in a Pointer (we don't support pointer types yet).
  2. Inspecting a type should work well with Python 3.10 match statements and mypy exhaustiveness checking. mypy has special support for enum.Enum exhaustiveness, so I created singleton enums for the types that don't have any fields. This is difficult to do in Rust, so I defined them in a pure Python module and manually converted them to Rust types.
bamarsha commented 2 years ago

@cgranade do you still have any concerns about the API or did my replies to your comments address them?

cgranade commented 2 years ago

No remaining concerns, no. Thanks for the detailed context!