Overview of ghc-lib and ghc-lib-parser
masterThe ghc-lib project provides a way to use the GHC API as a library independently of the specific GHC compiler version installed on your system. This allows you to mix and match GHC API versions and work with different GHC versions within the same tool without heavy C preprocessor usage.
There are two primary packages:
ghc-lib-parser: A subset of the GHC API sufficient for parsing Haskell code. It can serve as a replacement forhaskell-src-exts.ghc-lib: Extends and re-exportsghc-lib-parserwith the full GHC API.
Key Capabilities:
- Parse Haskell code.
- Compile Haskell code as far as GHC's Core language (including renaming and type checking).
Limitations:
- No Runtime: You cannot run code produced by
ghc-lib(e.g., noTemplateHaskellsupport). - No Package Database: It does not ship with a package database (like
base), making it difficult to compile off-the-shelf code without building your own database. - Version Constraints: It can only read package databases and
.hifiles for one particular version of GHC at a time.