module Hhp.Ghc (
withGHC
, withGHC'
, initializeFlagsWithCradle
, boot
, browse
, check
, info
, types
, modules
, Symbol
, SymMdlDb
, getSymMdlDb
, lookupSym
, getSystemLibDir
, liftIO
, runGhc
, getMainFileToBeDeleted
, Ghc
) where
import Hhp.Boot
import Hhp.Browse
import Hhp.Check
import Hhp.Find
import Hhp.GHCApi
import Hhp.Gap
import Hhp.Info
import Hhp.List
import GHC (runGhc)
import CoreMonad (liftIO)
import GHC (Ghc)
import qualified GHC as G
import Data.Maybe (fromMaybe)
getMainFileToBeDeleted :: FilePath -> Ghc (Maybe FilePath)
getMainFileToBeDeleted :: FilePath -> Ghc (Maybe FilePath)
getMainFileToBeDeleted FilePath
file = FilePath -> Maybe ModSummary -> Maybe FilePath
isSameMainFile FilePath
file (Maybe ModSummary -> Maybe FilePath)
-> Ghc (Maybe ModSummary) -> Ghc (Maybe FilePath)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ghc (Maybe ModSummary)
getModSummaryForMain
isSameMainFile :: FilePath -> Maybe G.ModSummary -> Maybe FilePath
isSameMainFile :: FilePath -> Maybe ModSummary -> Maybe FilePath
isSameMainFile FilePath
_ Maybe ModSummary
Nothing = Maybe FilePath
forall a. Maybe a
Nothing
isSameMainFile FilePath
file (Just ModSummary
x)
| FilePath
mainfile FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
== FilePath
file = Maybe FilePath
forall a. Maybe a
Nothing
| Bool
otherwise = FilePath -> Maybe FilePath
forall a. a -> Maybe a
Just FilePath
mainfile
where
mmainfile :: Maybe FilePath
mmainfile = ModLocation -> Maybe FilePath
G.ml_hs_file (ModSummary -> ModLocation
G.ms_location ModSummary
x)
mainfile :: FilePath
mainfile = FilePath -> Maybe FilePath -> FilePath
forall a. a -> Maybe a -> a
fromMaybe (ModSummary -> FilePath
G.ms_hspp_file ModSummary
x) Maybe FilePath
mmainfile