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

[ bsd3, ghc, library, template-haskell ] [ Propose Tags ] [ Report a vulnerability ]

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


[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.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.4.0
Change log CHANGELOG.md
Dependencies base (>=4.14 && <4.20), bytestring (>=0.10 && <0.13), ghc (>=8.10.7 && <9.9), ghc-boot (>=8.10.7 && <9.9), template-haskell (>=2.16.0 && <2.22) [details]
Tested with ghc ==8.10.7, ghc ==9.0.2, ghc ==9.2.8, ghc ==9.4.7, ghc ==9.6.3, ghc ==9.8.1
License BSD-3-Clause[multiple license files]
Author Zachary Wood
Maintainer amesgen@amesgen.de
Category ghc, template-haskell
Source repo head: git clone https://github.com/zacwood9/ghc-hs-meta
Uploaded by amesgen at 2023-10-10T20:49:24Z
Distributions LTSHaskell:0.1.4.0, NixOS:0.1.4.0, Stackage:0.1.4.0
Reverse Dependencies 2 direct, 21 indirect [details]
Downloads 406 total (22 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-10-10 [all 1 reports]

Readme for ghc-hs-meta-0.1.3.0

[back to package description]

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

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.