| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
GHC.Cabal
Description
One of the challenges of using the GHC API for external tooling
is handling integration with Cabal. This library provides a simple
interface for configuring GHC's DynFlags as Cabal would have,
allowing seamless tooling use on Cabal projects.
A typical usage might look like,
import GHC
import qualified GHC.Paths
import qualified Distribution.Verbosity as Verbosity
import GHC.Cabal
main = runGhc (Just GHC.Paths.libdir) $ do
dflags <- GHC.getSessionDynFlags
-- Use default DynFlags if we aren't in a Cabal project
dflags' <- fromMaybe dflags <$> liftIO (initCabalDynFlags Verbosity.normal dflags)
GHC.setSessionDynFlags dflags'
-- Standard GHC API usage goes here