{-# LANGUAGE TemplateHaskell #-}
module GHC.Check
( VersionCheck(..)
, checkGhcVersion
, compileTimeVersion
, ghcCompileTimeVersion
, runTimeVersion
) where
import Data.Version (Version)
import GHC
import GHC.Check.Internal
ghcCompileTimeVersion :: Version
ghcCompileTimeVersion = $$(compileTimeVersion guessLibdir "ghc")
runTimeVersion :: Ghc (Maybe Version)
runTimeVersion = getGhcVersion
data VersionCheck
= Match
| Mismatch { compileTime :: Version
, runTime :: Maybe Version
}
deriving (Eq, Show)
checkGhcVersion :: Ghc VersionCheck
checkGhcVersion = do
v <- getGhcVersion
return $ if v == Just ghcCompileTimeVersion
then GHC.Check.Match
else Mismatch ghcCompileTimeVersion v