Skip to content

CQCL/brat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

BRAT is a functional programming language designed for writing quantum experiments. For an introduction to BRAT, see the extended abstract submitted to PLanQC 2024.

Installation

To build BRAT from source, you will need:

  • GHC 9.6.4 (can be installed with the ghcup tool)
  • The stack build tool for Haskell

Then, navigate to the brat directory and run stack install.

This will add the brat and brat-lsp binaries to ~/.local/bin, and copy configuration for the emacs editor mode to ~/.local/share/brat/.

There is also a plugin for the VS Code editor. To install this, look at vscode/README.md.

Usage

Typechecking

By default, the installed brat executable will typecheck a program given as an argument, e.g.:

brat my-program.brat

which, if my-program typechecks, will print out the parsed versions of the declarations and a list of remaining holes.

Compiling

The --compile flag can be used to compile the BRAT program to the hugr IR and print the JSON representation to the command line.

Validating

There is a tool in the root of the repository called hugr_validator (install by cd hugr_validator && cargo install --path .) which is used to check that the JSON output from BRAT constitutes a valid hugr. This is invoked by:

brat --compile my-program.brat | hugr_validator

Reference

The brat/examples directory contains some examples of BRAT programs. For example:

This directory also contains tests of syntax features which, while terse, may serve as a reference in the short term. For example: