module GHC.Unit.Module.Location
   ( ModLocation(..)
   , addBootSuffix
   , addBootSuffix_maybe
   , addBootSuffixLocn_maybe
   , addBootSuffixLocn
   , addBootSuffixLocnOut
   , removeBootSuffix
   )
where
import GHC.Prelude
import GHC.Unit.Types
import GHC.Utils.Outputable
data ModLocation
   = ModLocation {
        ModLocation -> Maybe FilePath
ml_hs_file   :: Maybe FilePath,
                
                
        ModLocation -> FilePath
ml_hi_file   :: FilePath,
                
                
                
        ModLocation -> FilePath
ml_dyn_hi_file :: FilePath,
                
                
        ModLocation -> FilePath
ml_obj_file  :: FilePath,
                
                
                
                
        ModLocation -> FilePath
ml_dyn_obj_file :: FilePath,
                
                
        ModLocation -> FilePath
ml_hie_file  :: FilePath
                
                
  } deriving Int -> ModLocation -> ShowS
[ModLocation] -> ShowS
ModLocation -> FilePath
(Int -> ModLocation -> ShowS)
-> (ModLocation -> FilePath)
-> ([ModLocation] -> ShowS)
-> Show ModLocation
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ModLocation -> ShowS
showsPrec :: Int -> ModLocation -> ShowS
$cshow :: ModLocation -> FilePath
show :: ModLocation -> FilePath
$cshowList :: [ModLocation] -> ShowS
showList :: [ModLocation] -> ShowS
Show
instance Outputable ModLocation where
   ppr :: ModLocation -> SDoc
ppr = FilePath -> SDoc
text (FilePath -> SDoc)
-> (ModLocation -> FilePath) -> ModLocation -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModLocation -> FilePath
forall a. Show a => a -> FilePath
show
addBootSuffix :: FilePath -> FilePath
addBootSuffix :: ShowS
addBootSuffix FilePath
path = FilePath
path FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ FilePath
"-boot"
removeBootSuffix :: FilePath -> FilePath
removeBootSuffix :: ShowS
removeBootSuffix FilePath
"-boot" = []
removeBootSuffix (Char
x:FilePath
xs)  = Char
x Char -> ShowS
forall a. a -> [a] -> [a]
: ShowS
removeBootSuffix FilePath
xs
removeBootSuffix []      = ShowS
forall a. HasCallStack => FilePath -> a
error FilePath
"removeBootSuffix: no -boot suffix"
addBootSuffix_maybe :: IsBootInterface -> FilePath -> FilePath
addBootSuffix_maybe :: IsBootInterface -> ShowS
addBootSuffix_maybe IsBootInterface
is_boot FilePath
path = case IsBootInterface
is_boot of
  IsBootInterface
IsBoot -> ShowS
addBootSuffix FilePath
path
  IsBootInterface
NotBoot -> FilePath
path
addBootSuffixLocn_maybe :: IsBootInterface -> ModLocation -> ModLocation
addBootSuffixLocn_maybe :: IsBootInterface -> ModLocation -> ModLocation
addBootSuffixLocn_maybe IsBootInterface
is_boot ModLocation
locn = case IsBootInterface
is_boot of
  IsBootInterface
IsBoot -> ModLocation -> ModLocation
addBootSuffixLocn ModLocation
locn
  IsBootInterface
_ -> ModLocation
locn
addBootSuffixLocn :: ModLocation -> ModLocation
addBootSuffixLocn :: ModLocation -> ModLocation
addBootSuffixLocn ModLocation
locn
  = ModLocation
locn { ml_hs_file :: Maybe FilePath
ml_hs_file  = ShowS -> Maybe FilePath -> Maybe FilePath
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShowS
addBootSuffix (ModLocation -> Maybe FilePath
ml_hs_file ModLocation
locn)
         , ml_hi_file :: FilePath
ml_hi_file  = ShowS
addBootSuffix (ModLocation -> FilePath
ml_hi_file ModLocation
locn)
         , ml_dyn_hi_file :: FilePath
ml_dyn_hi_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_dyn_hi_file ModLocation
locn)
         , ml_obj_file :: FilePath
ml_obj_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_obj_file ModLocation
locn)
         , ml_dyn_obj_file :: FilePath
ml_dyn_obj_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_dyn_obj_file ModLocation
locn)
         , ml_hie_file :: FilePath
ml_hie_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_hie_file ModLocation
locn) }
addBootSuffixLocnOut :: ModLocation -> ModLocation
addBootSuffixLocnOut :: ModLocation -> ModLocation
addBootSuffixLocnOut ModLocation
locn
  = ModLocation
locn { ml_hi_file :: FilePath
ml_hi_file  = ShowS
addBootSuffix (ModLocation -> FilePath
ml_hi_file ModLocation
locn)
         , ml_dyn_hi_file :: FilePath
ml_dyn_hi_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_dyn_hi_file ModLocation
locn)
         , ml_obj_file :: FilePath
ml_obj_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_obj_file ModLocation
locn)
         , ml_dyn_obj_file :: FilePath
ml_dyn_obj_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_dyn_obj_file ModLocation
locn)
         , ml_hie_file :: FilePath
ml_hie_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_hie_file ModLocation
locn)
         }