stim-parser: A parser combinator library for STIM quantum circuit files

[ library, mit, parsing, physics, program ] [ Propose Tags ] [ Report a vulnerability ]

A Haskell library for parsing STIM quantum circuit files into an AST. STIM is a file format for describing quantum stabilizer circuits. This library provides parsers for gates, measurements, noise channels, annotations, and complete STIM circuits.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0
Change log CHANGELOG.md
Dependencies base (>=4.11.0.0 && <4.22), containers (>=0.5 && <0.8), megaparsec (>=8.0.0 && <10), mtl (>=2.2.2 && <2.4), stim-parser, unordered-containers (>=0.2.8 && <0.3) [details]
License MIT
Author le.niu
Maintainer le.niu@hotmail.com
Uploaded by overshiki at 2026-05-03T13:17:09Z
Category Parsing, Physics
Source repo head: git clone https://github.com/overshiki/stim-parser.git
Distributions
Executables stim-parser-example, stim-parser-unit-example
Downloads 14 total (7 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-05-03 [all 1 reports]

Readme for stim-parser-0.2.0.0

[back to package description]

stim-parser

parser combinator to parse stim's .stim file into AST.

Usage

stim-parser is expected to be used as a haskell library, for example:

import StimParser.Expr
import StimParser.Parse
import StimParser.ParseUtils (run)

-- Parse a stim gate
main :: IO ()
main = do
  -- Parse individual elements
  print $ run parseGate "CNOT 0 1 2 3"
  -- => Gate CNOT [Q 0,Q 1,Q 2,Q 3]
  
  print $ run parseMeasure "MXX(0.01) 2 3"
  -- => Measure MXX (Just 0.01) [Q 2,Q 3]
  
  -- Parse a full stim file
  s <- readFile "example.stim"
  print $ run parseStim ("!!!Start " ++ s)
  -- => StimList [...]

See data/example.stim for a sample input file.

Executables & Tests

stim-parser-example

Main example from the README usage section. Parses a sample stim file(data/example.stim):

cabal run stim-parser-example

stim-parser-unit-example

Multiple unit examples demonstrating individual parsers (gates, measurements, noise channels, annotations, etc.):

cabal run stim-parser-unit-example

Test Suite

Unit tests for all modules (Expr, ParseUtils, Parse, Trans):

cabal test