The Quipper System

Safe HaskellNone

Quipper.Printing

Contents

Description

Pretty-printing of low-level quantum circuits.

Synopsis

ASCII representation of circuits

ascii_of_bcircuit :: BCircuit -> String Source #

Generate an ASCII representation of a low-level boxed quantum circuit.

print_dbcircuit_ascii :: ErrMsg -> DBCircuit a -> IO () Source #

Interactively output a DBCircuit to standard output. This supports dynamic lifting by prompting the user for bit values when a dynamic lifting operation is encountered. Effectively the user is asked to behave like a quantum device.

getBit :: IO Bool Source #

Interactively read a bit (either 0 or 1) from standard input. This is intended for interactive user input, so it skips white space until a 0 or 1 is encountered. In case the first non-whitespace character isn't 0 or 1 or #, the rest of the line is ignored and the user is prompted to try again.

However, this also works for non-interactive input, so that the input can be redirected from a file. In this case, the characters 0 and 1 and whitespace, including newlines, can be interspersed freely. '#' starts a comment that extends until the end of the line.

Gate counts

print_gatecounts_bcircuit :: BCircuit -> IO () Source #

Print gate counts for a boxed circuit: first the simple gate count for each subroutine separately, then the aggregated count for the whole circuit.

Graphical representation of circuits

render_dbcircuit :: FormatStyle -> ErrMsg -> DBCircuit a -> Document () Source #

Render a low-level dynamic quantum circuit as a graphical Document. If there are subroutines, each of them is placed on a separate page. If the circuit uses dynamic lifting, an error is produced.

Previewing

preview_bcircuit :: BCircuit -> IO () Source #

Display the circuit directly in Acrobat Reader. This may not be portable. It requires the external program "acroread" to be installed.

Printing to multiple formats

data Format Source #

Available output formats.

Constructors

EPS

Encapsulated PostScript graphics.

PDF

Portable Document Format. One circuit per page.

PS

PostScript. One circuit per page.

ASCII

A textual representation of circuits.

Preview

Don't print anything, but preview directly on screen (requires the external program acroread).

GateCount

Print statistics on gate counts.

CustomStyle FormatStyle 

Instances

data FormatStyle Source #

A data type that holds all the customizable parameters.

Constructors

FormatStyle 

Fields

pdf :: FormatStyle Source #

The default PDF Style.

eps :: FormatStyle Source #

The default EPS Style.

ps :: FormatStyle Source #

The default PS Style.

format_enum :: [(String, Format)] Source #

A mapping from lower-case strings (to be used, e.g., with command line options) to available formats.

print_dbcircuit :: Format -> ErrMsg -> DBCircuit a -> IO () Source #

Print a low-level quantum circuit directly to the IO monad, using the specified format.

print_of_document :: Format -> Document a -> IO a Source #

Print a document to the requested format, which must be one of PS, PDF, EPS, or Preview.

print_of_document_custom :: Custom -> Format -> Document a -> IO a Source #

Like print_of_document, but also takes a Custom data structure.

Generic printing

print_unary :: QCData qa => Format -> (qa -> Circ b) -> qa -> IO () Source #

Print a circuit generating function to the specified format; this requires a shape parameter.

print_generic :: (QCData qa, QCurry qfun qa b, Curry fun qa (IO ())) => Format -> qfun -> fun Source #

Print a circuit generating function to the specified format. Unlike print_unary, this can be applied to a circuit-generating function in curried form with n arguments, for any n >= 0. It then requires n shape parameters.

The type of this heavily overloaded function is difficult to read. In more readable form, it has all of the following types:

print_generic :: Format -> Circ qa -> IO ()
print_generic :: (QCData qa) => Format -> (qa -> Circ qb) -> a -> IO ()
print_generic :: (QCData qa, QCData qb) => Format -> (qa -> qb -> Circ qc) -> a -> b -> IO ()

and so forth.

print_simple :: (QCData qa, QCurry qfun qa b, Curry fun qa (IO ()), QCData_Simple qa) => Format -> qfun -> IO () Source #

Like print_generic, but only works at simple types, and therefore requires no shape parameters.