Safe Haskell | None |
---|---|
Language | Haskell98 |
This module uses a state transformer monad to rebuild a circuit from the CircInfoState representation. This can only be as lazy as the Quipper ASCII output allows, as subroutine definitions need to be known before a subroutine can be called.
Synopsis
- data WireState = WireState {}
- empty_wirestate :: Map BoxId Sub -> WireState
- type ASCIICirc a = StateT WireState Circ a
- set_in_sub :: ASCIICirc ()
- provide_qubit :: Int -> ASCIICirc Qubit
- provide_bit :: Int -> ASCIICirc Bit
- provide_wire :: Int -> ASCIICirc Wire
- add_qubit :: Int -> Qubit -> ASCIICirc ()
- add_bit :: Int -> Bit -> ASCIICirc ()
- remove_wire :: Int -> ASCIICirc ()
- provide_control :: Signed Int -> ASCIICirc (Signed Wire)
- provide_controls :: [Signed Int] -> ASCIICirc [Signed Wire]
- lift_ncf :: Bool -> Circ a -> ASCIICirc a
- do_gate :: Gate -> ASCIICirc ()
- allocate_input :: (Endpoint, Endpoint) -> ASCIICirc ()
- run_gates :: [Gate] -> Maybe [(Wire, Wiretype)] -> [Endpoint] -> [Endpoint] -> ASCIICirc [Endpoint]
- run_asciicirc :: Map BoxId Sub -> (a -> ASCIICirc b) -> a -> Circ b
- run :: Maybe [(Wire, Wiretype)] -> [Gate] -> Map BoxId Sub -> CircInfoState -> ([Endpoint], [Endpoint] -> Circ [Endpoint])
- set_qubit :: (Wire, Maybe Wiretype) -> (Wire, Wiretype)
Documentation
In the Quipper ASCII output, wires are identified by integers. We have to map these to Quipper's native wires and types.
empty_wirestate :: Map BoxId Sub -> WireState Source #
An initial, empty WireState, with the given subroutines_in_scope
set_in_sub :: ASCIICirc () Source #
The in_sub
flag can be set to True, as slightly different behavior is
required when evaluating a subroutine.
provide_qubit :: Int -> ASCIICirc Qubit Source #
Look up the qubit corresponding to a ASCII integer representation of a qubit. If it doesn't already exist then initialize a new qubit.
provide_bit :: Int -> ASCIICirc Bit Source #
Look up the bit corresponding to a ASCII integer representation of a bit. If it doesn't already exist then initialize a new bit.
provide_wire :: Int -> ASCIICirc Wire Source #
Look up the wire corresponding to a ASCII integer representation of a bit or qubit. If it doesn't already exist then initialize a new qubit.
remove_wire :: Int -> ASCIICirc () Source #
Remove a wire from the state
provide_control :: Signed Int -> ASCIICirc (Signed Wire) Source #
A helper function for providing the qubits within a control structure
provide_controls :: [Signed Int] -> ASCIICirc [Signed Wire] Source #
provides quantum wires for the controls in a control list
lift_ncf :: Bool -> Circ a -> ASCIICirc a Source #
Lift a Quipper circuit, preventing the addition of controls depending on the given boolean.
allocate_input :: (Endpoint, Endpoint) -> ASCIICirc () Source #
Allocate an input endpoint, to an endpoint in the ASCIICirc, by adding it to the map of wires in scope.
Unpacking ASCIICirc
run_gates :: [Gate] -> Maybe [(Wire, Wiretype)] -> [Endpoint] -> [Endpoint] -> ASCIICirc [Endpoint] Source #
Execute a parsed circuit, i.e. a CircInfoState, in the ASCIICirc monad
run_asciicirc :: Map BoxId Sub -> (a -> ASCIICirc b) -> a -> Circ b Source #
Run function for the ASCIICirc
monad: execute the actions and
produce a circuit.