Safe Haskell | None |
---|

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.Internal.CircLifting.

## Synopsis

- type QEq qc = QCData qc
- q_is_equal :: QEq qc => qc -> qc -> Circ (qc, qc, Qubit)
- q_is_not_equal :: QEq qc => qc -> qc -> Circ (qc, qc, Qubit)
- class (QEq qa, QData qa) => QOrd qa where
- q_lt :: QOrd qa => qa -> qa -> Circ (qa, qa, Qubit)
- q_gt :: QOrd qa => qa -> qa -> Circ (qa, qa, Qubit)
- q_le :: QOrd qa => qa -> qa -> Circ (qa, qa, Qubit)
- q_ge :: QOrd qa => qa -> qa -> Circ (qa, qa, Qubit)

# The type class QEq

type QEq qc = QCData qc 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.

# 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).

Nothing

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.