Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fairly complete recreation of
src/ast.lisp
in coalton.There are a few uncertainties that could be resolved provided feedback about use-cases.
(ApplyGate (Gate :num))
instruction(ApplyOp ClassicalOperation)
instruction(MaybeFormal :t)
wrapper type used to wrap arguments to application instructions.I may have gone overboard (while at the same time not being strict enough, so a lose-lose) when cramming Quil's arithmetic expressions into a ADT. If this is to be useful for humans, further work might be done, or, the ADT scrapped in favor of stringly expressions to be parsed.Forked
gates does not sit well with me, but I couldn't think of anything cleaner. Forked is syntactically bizarre in that, unlike other operators, the gate-representing forms to whichForked
is applied are not, from a certain point of view, grammatically valid on their own.Most of the "room for screwing up" comes in the freedom to input formal arguments when concrete arguments are required.Instruction
andExpr
are parameterized by a free type:num
, intended to capture a number representation. Right now that type is totally unconstrained in all interfaces. It should probably be constrained byReal
so that instances of:num
values can be approximated during the construction of the rawcl-quil
types. However, doing so introduces complication in those cases where complex numbers may appear, namely in the entries to some gate definitions.TheInstruction
type allows for the construction of malformed programs that include:nested DEFCIRCUITsthe presence of quil:formals in instructions that ought to require concrete qubits or memory referencesthe nesting of DEFGATEs in DEFCIRCUITsItem 6 could be mitigated with the addition of a new typeI did end up doing this.MacroInstruction
or something that restricts the types of instructions that may appear inside of DEFCIRCUITs. Having such aMacroInstruction
type would also allow for the removal ofMaybeFormal
wrapped types in several places.Here's an example of "use"
Before I produced a test suite, I wanted to get some feedback about use and general style. Marking as draft for now.