Utility functions for testing Megaparsec parsers with Hspec


Version on this page:2.2.0
LTS Haskell 22.30:2.2.1
Stackage Nightly 2024-07-22:2.2.1
Latest on Hackage:2.2.1

See all snapshots hspec-megaparsec appears in

BSD-3-Clause licensed and maintained by Mark Karpov
This version can be pinned in stack with:hspec-megaparsec-2.2.0@sha256:679b9b91ea0ed0c36d6782d6051a08e0825409d10adbab8c8cfa9c8bd8bfc245,1802

Module documentation for 2.2.0

Hspec Megaparsec

License BSD3 Hackage Stackage Nightly Stackage LTS CI

The package is the recommended library for testing Megaparsec parsers with with Hspec. As of Megaparsec 5.1.0, its test suite is re-written with Hspec and this package with a few ad-hoc helpers.

Consult the Haddocks for usage, which should be trivial. Also see test suite of this package or Megaparsec test suite.


Issues, bugs, and questions may be reported in the GitHub issue tracker for this project.

Pull requests are also welcome.


Copyright © 2016–present Mark Karpov

Distributed under BSD 3 clause license.


Hspec Megaparsec 2.2.0

  • Works with Megaparsec 9.

Hspec Megaparsec 2.1.0

  • Works with Megaparsec 8.

  • Dropped support for GHC 8.2.

Hspec Megaparsec 2.0.1

  • Adjusted shouldParse to use shouldBe from hspec under the hood to take advantage of its pretty colorful error reporting.

  • Dropped support for GHC 8.0 and older.

Hspec Megaparsec 2.0.0

  • To be used with Megaparsec 7.

  • Added functions: shouldFailWithM and initialPosState.

  • Dropped support for GHC 7.8.

Hspec Megaparsec 1.1.0

  • Add HasCallStack constraint to combinators to improve detection of locations where test failures happen.

Hspec Megaparsec 1.0.0

  • To be used with Megaparsec 6.

Hspec Megaparsec 0.3.1

  • Support for Megaparsec 5.2.0.

  • Drop support for GHC 7.6.

Hspec Megaparsec 0.3.0

  • Added helpers for parse error construction (useful with shouldFailWith): err, posI, posN, utok, utoks, ulabel, ueof, etok, etoks, elabel, eeof, cstm. Also added an auxiliary type EC.

Hspec Megaparsec 0.2.1

  • Refreshed obsolete documentation for shouldFailWith and how it reports not matching parse errors.

Hspec Megaparsec 0.2.0

  • This version of hspec-megaparsec should be used with Megaparsec 5.

Hspec Megaparsec 0.1.1

  • Make it pass tests with Megaparsec 4.4.0 and later.

Hspec Megaparsec 0.1.0

  • Initial release.