QIO-1.2: The Quantum IO Monad is a library for defining quantum computations in Haskell

Safe HaskellSafe-Infered



This module defines the functions that can be used run the classical subset of QIO. That is, QIO computations that only use classical unitary operations.



newtype UnitaryC Source

A classical unitary operation is defined as a function that will update the current classical state.




unU :: Int -> HeapMap -> HeapMap


Monoid UnitaryC

The classical unitary type forms a Monoid

uRotC :: Qbit -> Rotation -> UnitaryCSource

A single qubit rotation can be converted into the classical unitary type, if it is indeed classical (otherwise an error is thrown).

uSwapC :: Qbit -> Qbit -> UnitaryCSource

A swap operation can be defined in the classical unitary type.

uCondC :: Qbit -> (Bool -> UnitaryC) -> UnitaryCSource

A conditional operation can be defined in the classical unitary type.

uLetC :: Bool -> (Qbit -> UnitaryC) -> UnitaryCSource

A let operation can be defined in the classical unitary type.

runUC :: U -> UnitaryCSource

A unitary can be run by converting it into the classical unitary type.

data StateC Source

A classical state consists of the next free qubit reference, along with a Heap that represents the overall state of the current qubits in scope.




fv :: Int
heap :: HeapMap

initialStateC :: StateCSource

An initial state is defined as an empty heap, with 0 set as the next free qubit referece

runQStateC :: QIO a -> State StateC aSource

A QIO computation can be converted into a stateful computation, over a state of type StateC.

runC :: QIO a -> aSource

We can run a classical QIO computation by converting it into a stateful computation, and evaluating that using the initial state.