Safe Haskell | None |
---|---|

Language | Haskell2010 |

This module defines quantum analogues of some Haskell type
classes. For instance, Haskell’s

has one method`Eq`

a

(==) :: a -> a -> Bool.

Correspondingly, our

has a method`QEq`

a qa ca

q_is_equal :: qa -> qa -> Circ (qa,qa,Qubit).

All quantum type classes assume that their instance types are
`QData`

(or sometimes `QCData`

).

Quantum type classes are designed to play nicely with the translation of Quipper.CircLifting.

# The type class QEq

class QCData qc => QEq qc where Source #

This is a quantum analogue of Haskell’s `Eq`

type class. Default
implementations are provided; by default, equality is bitwise
equality of the underlying data structure. However, specific
instances can provide custom implementations. In this case,
`q_is_equal`

is a minimal complete definition.

q_is_equal :: qc -> qc -> Circ (qc, qc, Qubit) Source #

Test for equality.

q_is_not_equal :: qc -> qc -> Circ (qc, qc, Qubit) Source #

Test for inequality.

# The type class QOrd

class (QEq qa, QData qa) => QOrd qa where Source #

This is a quantum analogue of Haskell's `Ord`

type class. Its
purpose is to define a total ordering on each of its instances. The
functions in this class are assumed dirty in the sense that they do
not uncompute ancillas, and some of the inputs may be returned as
outputs. The functions are also assumed to be non-linear safe,
i.e., they apply no gates to their inputs except as control
sources. Minimal complete definition: `q_less`

or `q_greater`

. The default
implementations of `q_max`

and `q_min`

assume that both arguments
are of the same shape (for example, numbers of the same length).

q_less :: qa -> qa -> Circ Qubit Source #

Test for less than.

q_greater :: qa -> qa -> Circ Qubit Source #

Test for greater than.

q_leq :: qa -> qa -> Circ Qubit Source #

Test for less than or equal.

q_geq :: qa -> qa -> Circ Qubit Source #

Test for greater than or equal.

q_max :: qa -> qa -> Circ qa Source #

Compute the maximum of two values.

q_min :: qa -> qa -> Circ qa Source #

Compute the minimum of two values.