Skip to content

Convert Haskell source code to Template Haskell expressions using GHC's parser

License

BSD-3-Clause, BSD-3-Clause licenses found

Licenses found

BSD-3-Clause
LICENSE
BSD-3-Clause
LICENSE-PyF
Notifications You must be signed in to change notification settings

zacwood9/ghc-hs-meta

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.

About

Convert Haskell source code to Template Haskell expressions using GHC's parser

Resources

License

BSD-3-Clause, BSD-3-Clause licenses found

Licenses found

BSD-3-Clause
LICENSE
BSD-3-Clause
LICENSE-PyF

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published