ghc-check-0.5.0.2: detect mismatches between compile-time and run-time versions of the ghc api
Safe HaskellNone
LanguageHaskell2010

GHC.Check

Synopsis

GHC version check

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 packageCheck <- ghcChecker runTimeLibdir
    res <- runGhc (Just runTimeLibdir) $ do
             setupGhcApi
             result <- packageCheck
             case guessCompatibility result of ...

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

data PackageCheckResult Source #

Constructors

PackageCheckSuccess !(NonEmpty (String, PackageCheck))

All the compile time packages tested match

PackageCheckFailure !(NonEmpty (String, PackageCheck))

Found package mismatches

PackageCheckInconclusive ![String]

None of the compile time packages could be found

PackageCheckError !SomeException

An exception arised during the package check

data PackageCheck Source #

Constructors

VersionMismatch

Different versions

AbiMismatch

Same version but different abi

VersionMatch

Same version and abi

Instances

Instances details
Eq PackageCheck Source # 
Instance details

Defined in GHC.Check

Show PackageCheck Source # 
Instance details

Defined in GHC.Check

Interpreting the results

guessCompatibility :: PackageCheckResult -> CompatibilityGuess Source #

Interpret a PackageCheckResult into a yes/no GHC compatibility answer

Exports for TH

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

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