On behalf of Digital Asset I am excited to share with you the latest release of ghc-lib
.
As described in detail in the ghc-lib
README, the ghc-lib
project lets you use the GHC API for parsing and analyzing Haskell code without tying you to a specific GHC version.
What's new
The GHC source code in this release is updated to GHC HEAD as of April the 4th, 2019. Accordingly, the mini-hlint
example in the ghc-lib
repo was adjusted to accomodate GHC API changes to the ParseResult
datatype and parser error handling.
By far the biggest change though is this : the ghc-lib
project now provides two packages, ghc-lib-parser
and ghc-lib
. The packages are released on Hackage, and can be installed as usual e.g. cabal install ghc-lib
.
Some projects don't require the ability to compile Haskell to GHC's Core language. If lexical analysis alone is sufficient for your project's needs, then the ghc-lib-parser
package alone will do for that. The build time for ghc-lib-parser
is roughly half of the combined build times of ghc-lib-parser
and ghc-lib
. That is, in this case, switching to the new release will decrease the build time for your project. Note that if your project does require compiling Haskell to Core, then your project will now depend on both the ghc-lib-parser
and ghc-lib
packages.
The ghc-lib
package "re-exports" the modules of the ghc-lib-parser
package. So, if you depend upon the ghc-lib
package, you'll get the ghc-lib-parser
modules "for free". Sadly though, at this time, package import syntax (and we do recommend using package import syntax for these packages) doesn't quite work like you'd expect so that if you, import "ghc-lib" DynFlags
for example, this will fail because DynFlags
is in fact in the ghc-lib-parser
package. In this case, you'd write, import "ghc-lib-parser" DynFlags
and all would be well. The mini-compile example in the ghc-lib
repo demonstrates mixing modules from both packages.
Digital Asset make extensive use of the ghc-lib
packages in the DAML smart contract language compiler and hope you continue to benefit from this project too!