Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 #
InstallationChecked | The ghc installation looks fine. Further checks are needed for the package libraries. |
| |
InstallationMismatch | The libdir points to a different ghc version |
| |
InstallationNotFound | The libdir does not exist |
type PackageCheck = Maybe (String, PackageMismatch) Source #
data PackageMismatch Source #
Instances
Eq PackageMismatch Source # | |
Defined in GHC.Check (==) :: PackageMismatch -> PackageMismatch -> Bool # (/=) :: PackageMismatch -> PackageMismatch -> Bool # | |
Show PackageMismatch Source # | |
Defined in GHC.Check 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
ghc
package, if found at run-time. If not, it compares theabi
of thebase
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.