Welcome to the homepage of the QML compiler

A functional quantum programming language implemented in Haskell.

This site contains a copy of Jonathan Grattage's thesis, and the development code for a QML compiler. The compiler is a work-in-progress (as is QML), and an earlier version of the code is discussed in the thesis.

The final version of this thesis is now available: QML: A functional quantum programming language. Please contact Jon with any comments.

Code for chapters 2 and 4: Reversible & irreversible classical computation in Haskell.

Code for the QML compiler, now including a Happy parser and lexer, can be found here: ZIP. (© Jonathan Grattage, 2008). The latest version, with up-to-date bug fixes, new features, and new examples, can be found on the QML darcs repository. To get the code, install darcs and then type darcs get --verbose http://fop.cs.nott.ac.uk/qml/compiler/qmlcomp.

The files "test.qml" and "teleport.qml" contain some example functions (using Haskell syntax highlighting is recommended). To run, type ghci qml, and to run your functions type runX "#filename" "#function", where runX is:

  • runTC: Returns a typed-circuit (FQC morphism);
  • runI: Returns a pair (Int,Isom) where the Int gives the size of any garbage, and Isom is a matrix of the computation, which initialises heap to False;
  • runS: Returns a Super(operator) representation of the function, which also traces out garbage (but is very slow);
  • runCon: outputs the context used by the function.
For example, runI "teleport.qml" "Tele". Again, please contact Jon with any comments.

The compiler contains the following files:

  • QCirc.lhs: Haskell code for quantum circuits (Chapter 3);
  • QAux.lhs: Auxiliary Haskell code used by the QML compiler;
  • QVec.lhs: Haskell code for linear algebra (Ch. 3);
  • QShow.lhs: show functions for QVec, Qcirc, and QSuper;
  • QSuper.lhs: Haskell code for isometries and superoperators (Ch. 5);
  • QSyn.lhs: The abstract syntax of QML as a Haskell datatype (Ch. 6);
  • QTyCirc.lhs: Haskell code for typed quantum circuits (FQC objects);
  • QOrth.hs: Code for evaluating the orthogonality judgements (Ch. 6/7);
  • QComp.hs: Code for compiling QML terms into typed circuits (Ch. 6/7);
  • qml.{ly|hs}: A Happy parser, lexer, and preprocessor for QML;
  • teleport.qml: An example implementation of the telportation algorithm.
The Haskell GHCi compiler is required to run this program, and Happy is required to compile the parser.

Jonanthan is currently employed by the QICS project as a European CNRS Research Fellow. He is a member of the Quantum computation in Grenoble group, located in the Laboratoire d'Information de Grenoble.