ghc-hs-meta: Translate Haskell source to Template Haskell expression

[ bsd3, ghc, library, template-haskell ] [ Propose Tags ]

Translate from Haskell source code to Template Haskell expressions using the GHC parser

[Skip to Readme]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,
Change log
Dependencies base (>=4.14 && <4.19), bytestring (>=0.10 && <0.13), ghc (>=8.10.7 && <9.7), ghc-boot (>=8.10.7 && <9.7), template-haskell (>=2.16.0 && <2.21) [details]
License BSD-3-Clause[multiple license files]
Author Zachary Wood
Revised Revision 1 made by amesgen at 2023-09-02T15:28:28Z
Category ghc, template-haskell
Source repo head: git clone
Uploaded by amesgen at 2023-06-17T21:29:36Z
Distributions NixOS:, Stackage:
Reverse Dependencies 2 direct, 21 indirect [details]
Downloads 185 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-06-17 [all 1 reports]

Readme for ghc-hs-meta-

[back to package description]


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 and 9.6.


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.