code: def circuit_to_pyquil(circuit: Circuit) -> pyquil.Program:
      
      prog = pyquil.Program()
  
      for elem in circuit.elements:
          if isinstance(elem, Gate) and elem.name in QUIL_GATES:
              params = list(elem.params.values()) if elem.params else []
              prog.gate(elem.name, params, elem.qubits)
          elif isinstance(elem, Measure):
              prog.measure(elem.qubit, elem.cbit)
          else:
              # FIXME: more informative error message
              raise ValueError('Cannot convert operation to pyquil')
  
      return prog
docs: Convert a QuantumFlow circuit to a pyQuil program