ghc-check-0.4.0.0: detect mismatches between compile-time and run-time versions of the ghc api

Safe HaskellNone
LanguageHaskell2010

GHC.Check

Synopsis

Documentation

type GhcVersionChecker = String -> IO InstallationCheck Source #

Given a run-time libdir, checks the ghc installation and returns a Ghc action to check the package database

data InstallationCheck Source #

Constructors

InstallationChecked

The ghc installation looks fine. Further checks are needed for the package libraries.

Fields

InstallationMismatch

The libdir points to a different ghc version

Fields

InstallationNotFound

The libdir does not exist

Fields

makeGhcVersionChecker :: IO FilePath -> TExpQ GhcVersionChecker Source #

makeGhcVersionChecker libdir returns a function to check the run-time version of ghc against the compile-time version. It performs two checks:

  1. It checks the version of the ghc installation given the run-time libdir In some platforms, like Nix, the libdir is not fixed at compile-time
  2. It compares the version of the ghc package, if found at run-time. If not, it compares the abi of the base package.
ghcChecker :: IO(Ghc (String -> PackageCheck))
ghcChecker = $$(makeGhcVersionChecker (pure $ Just GHC.Paths.libdir))

checkGhcVersion :: IO ()
checkGhcVersion = do
    InstallationChecked ghcLibVersionChecker <- ghcChecker runTimeLibdir
    res <- runGhc (Just runTimeLibdir) $ do
             setupGhcApi
             Right Nothing <- gtry ghcLibVersionChecker
             doSomethingInteresting

checkGhcVersion :: [String] -> [(String, PackageVersion)] -> GhcVersionChecker Source #

Checks if the run-time version of the ghc package matches the given version.