ghc-hs-meta

Translate Haskell source to Template Haskell expression

LTS Haskell 23.7:0.1.5.0
Stackage Nightly 2025-02-05:0.1.5.0
Latest on Hackage:0.1.5.0

See all snapshots ghc-hs-meta appears in

BSD-3-Clause licensed by Zachary Wood
Maintained by [email protected]
This version can be pinned in stack with:ghc-hs-meta-0.1.5.0@sha256:b354f93a535396bf341f7fb0daf8c8f2898e3463632f0b1cfd2b1423ba9f8a07,1377

Module documentation for 0.1.5.0

ghc-hs-meta

Generate Template Haskell expressions from Haskell source code using the GHC parser. This package runs on GHC versions 8.10, 9.0, 9.2, 9.4, 9.6, 9.8 and 9.10.

Usage

Pass a String containing Haskell source code to parseExp. Example from the tests:

case parseExp "a @b" of
    Right exp -> exp `shouldBe` TH.AppTypeE (TH.VarE (TH.mkName "a")) (TH.VarT (TH.mkName "b"))
    Left (_, _, errMsg) -> error errMsg

See Hackage documentation for more documentation.

Thank you, PyF

This code originated from the excellent parser included in the PyF package. I extracted the relevant code and refactored/renamed things to be usable in a more general context. Without PyF, this could wouldn’t have been possible. Thank you!

The original license for PyF can be found in the LICENSE-PyF file included in this repository.

Changes

0.1.5.0

  • Support GHC 9.12

0.1.4.0

  • Support GHC 9.10

0.1.3.0

  • Support GHC 9.8

0.1.2.0

  • Support GHC 9.6

0.1.1.0

  • Support GHC 9.4

0.1.0.0

Initial release.