{-# LANGUAGE TemplateHaskell #-}
module GHC.Check
( VersionCheck(..)
, checkGhcVersion
, compileTimeVersion
, compileTimeVersionFromLibdir
, runTimeVersion
) where
import Data.Version (Version)
import GHC
import GHC.Check.Internal
compileTimeVersion :: Version
compileTimeVersion = $$(compileTimeVersionFromLibdir guessLibdir)
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 compileTimeVersion
then GHC.Check.Match
else Mismatch compileTimeVersion v