 
Summary: Chapter 1
Shor in Haskell
The Quantum IO Monad
Alexander S. Green1, Thorsten Altenkirch1
Category: Research
Abstract: We present an interface from Haskell to quantum programming: the
Quantum IO monad, and use it to implement Shor's factorisation algorithm. The
QIO monad separates reversible (i.e. unitary) and irreversible (i.e. probabilistic)
computations and provides a reversible let operation (ulet), allowing us to use
ancillas (auxiliary qubits) in a modular fashion. Exploiting Haskell's class system
we can present our algorithms in a high level way, implementing abstractions in
the functional paradigm. We describe the implementation of Shor's algorithm in
some detail also covering the necessary reversible arithmetic. QIO programs can
be simulated either by calculating a probability distribution or by embedding it
into the IO monad using the random number generator.
1.1 INTRODUCTION
Quantum programming exploits the strange nature of quantum physics to achieve
classically impossible tasks. Most famously Shor's algorithm shows that on a
quantum computer we can factor a number in polynomial time, hence we could
break many encryption schemes. While physicists are working on building work
