| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
GHC.Check
Synopsis
- type GhcVersionChecker = String -> IO InstallationCheck
- data InstallationCheck
- = InstallationChecked { }
- | InstallationMismatch {
- libdir :: !String
- compileTime, runTime :: !Version
- | InstallationNotFound { }
- type PackageCheck = Maybe (String, PackageMismatch)
- data PackageMismatch
- = VersionMismatch {
- compileTime, runTime :: !Version
- | AbiMismatch { }
- = VersionMismatch {
- makeGhcVersionChecker :: IO FilePath -> TExpQ GhcVersionChecker
- checkGhcVersion :: [String] -> [(String, PackageVersion)] -> GhcVersionChecker
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 |
type PackageCheck = Maybe (String, PackageMismatch) Source #
data PackageMismatch Source #
Constructors
| VersionMismatch | |
Fields
| |
| AbiMismatch | |
Fields | |
Instances
| Eq PackageMismatch Source # | |
Defined in GHC.Check Methods (==) :: PackageMismatch -> PackageMismatch -> Bool # (/=) :: PackageMismatch -> PackageMismatch -> Bool # | |
| Show PackageMismatch Source # | |
Defined in GHC.Check Methods showsPrec :: Int -> PackageMismatch -> ShowS # show :: PackageMismatch -> String # showList :: [PackageMismatch] -> ShowS # | |
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:
- 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
- It compares the version of the
ghcpackage, if found at run-time. If not, it compares theabiof thebasepackage.
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
doSomethingInterestingcheckGhcVersion :: [String] -> [(String, PackageVersion)] -> GhcVersionChecker Source #
Checks if the run-time version of the ghc package matches the given version.