qfunc-0.1.0.0
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Lib.QM

Description

Definition of the quantum monad (QM) and helper functions

Synopsis

The Quantum Monad

data QM a Source #

The Quantum Monad Keeps a state of the complex vector representation while allowing pseudo-random number generation

Instances

Instances details
Monad QM Source # 
Instance details

Defined in Lib.QM

Methods

(>>=) :: QM a -> (a -> QM b) -> QM b #

(>>) :: QM a -> QM b -> QM b #

return :: a -> QM a #

Functor QM Source # 
Instance details

Defined in Lib.QM

Methods

fmap :: (a -> b) -> QM a -> QM b #

(<$) :: a -> QM b -> QM a #

Applicative QM Source # 
Instance details

Defined in Lib.QM

Methods

pure :: a -> QM a #

(<*>) :: QM (a -> b) -> QM a -> QM b #

liftA2 :: (a -> b -> c) -> QM a -> QM b -> QM c #

(*>) :: QM a -> QM b -> QM b #

(<*) :: QM a -> QM b -> QM a #

Show (QM a) Source # 
Instance details

Defined in Lib.QM

Methods

showsPrec :: Int -> QM a -> ShowS #

show :: QM a -> String #

showList :: [QM a] -> ShowS #

run :: QM a -> IO a Source #

Run quantum program, discarding it's final state

runDebug :: QM a -> IO a Source #

Run quantum program, prints the final quantum state and returns the result

eval :: QM a -> IO (a, QState) Source #

Run quantum program

put :: QState -> QM () Source #

Replace the quantum state

get :: QM QState Source #

Fetch the quantum state

modify :: (QState -> QState) -> QM () Source #

Apply a function to the quantum state

io :: IO a -> QM a Source #

Perform IO action inside the quantum monad

Quantum State representation

newtype QState Source #

The program state, a complex vector representation of the qubits in the system

Constructors

QState 

Fields

Instances

Instances details
Eq QState Source # 
Instance details

Defined in Lib.QM

Methods

(==) :: QState -> QState -> Bool #

(/=) :: QState -> QState -> Bool #

Show QState Source # 
Instance details

Defined in Lib.QM

QBit

type Ix = Int Source #

Internal index type, to indicate it is a qubit index.

newtype QBit Source #

Pointer to a qubit in QState. Represents the linking function in QLambda

Constructors

Ptr 

Fields

Instances

Instances details
Show QBit Source # 
Instance details

Defined in Lib.QM

Methods

showsPrec :: Int -> QBit -> ShowS #

show :: QBit -> String #

showList :: [QBit] -> ShowS #

Helpers

checkState :: QM () Source #

Print the quantum state during operation

getState :: QM (QState, Int) Source #

Returns the quantum state together with it's size

stateSize :: QState -> Ix Source #

Given a QState, returns how many qbits it consists of.