module GHC.Unit.Module.Location
( ModLocation(..)
, addBootSuffix
, addBootSuffix_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_obj_file :: FilePath,
ModLocation -> FilePath
ml_hie_file :: FilePath
} deriving Int -> ModLocation -> ShowS
[ModLocation] -> ShowS
ModLocation -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [ModLocation] -> ShowS
$cshowList :: [ModLocation] -> ShowS
show :: ModLocation -> FilePath
$cshow :: ModLocation -> FilePath
showsPrec :: Int -> ModLocation -> ShowS
$cshowsPrec :: Int -> ModLocation -> ShowS
Show
instance Outputable ModLocation where
ppr :: ModLocation -> SDoc
ppr = FilePath -> SDoc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> FilePath
show
addBootSuffix :: FilePath -> FilePath
addBootSuffix :: ShowS
addBootSuffix FilePath
path = FilePath
path forall a. [a] -> [a] -> [a]
++ FilePath
"-boot"
removeBootSuffix :: FilePath -> FilePath
removeBootSuffix :: ShowS
removeBootSuffix FilePath
"-boot" = []
removeBootSuffix (Char
x:FilePath
xs) = Char
x forall a. a -> [a] -> [a]
: ShowS
removeBootSuffix FilePath
xs
removeBootSuffix [] = 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 :: ModLocation -> ModLocation
addBootSuffixLocn :: ModLocation -> ModLocation
addBootSuffixLocn ModLocation
locn
= ModLocation
locn { ml_hs_file :: Maybe FilePath
ml_hs_file = 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_obj_file :: FilePath
ml_obj_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_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_obj_file :: FilePath
ml_obj_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_obj_file ModLocation
locn)
, ml_hie_file :: FilePath
ml_hie_file = ShowS
addBootSuffix (ModLocation -> FilePath
ml_hie_file ModLocation
locn) }