module GHC.Types.SourceFile
( HscSource(..)
, SourceModified (..)
, isHsBootOrSig
, isHsigFile
, hscSourceString
)
where
import GHC.Prelude
import GHC.Utils.Binary
data HscSource
= HsSrcFile
| HsBootFile
| HsigFile
deriving (HscSource -> HscSource -> Bool
(HscSource -> HscSource -> Bool)
-> (HscSource -> HscSource -> Bool) -> Eq HscSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HscSource -> HscSource -> Bool
$c/= :: HscSource -> HscSource -> Bool
== :: HscSource -> HscSource -> Bool
$c== :: HscSource -> HscSource -> Bool
Eq, Eq HscSource
Eq HscSource
-> (HscSource -> HscSource -> Ordering)
-> (HscSource -> HscSource -> Bool)
-> (HscSource -> HscSource -> Bool)
-> (HscSource -> HscSource -> Bool)
-> (HscSource -> HscSource -> Bool)
-> (HscSource -> HscSource -> HscSource)
-> (HscSource -> HscSource -> HscSource)
-> Ord HscSource
HscSource -> HscSource -> Bool
HscSource -> HscSource -> Ordering
HscSource -> HscSource -> HscSource
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: HscSource -> HscSource -> HscSource
$cmin :: HscSource -> HscSource -> HscSource
max :: HscSource -> HscSource -> HscSource
$cmax :: HscSource -> HscSource -> HscSource
>= :: HscSource -> HscSource -> Bool
$c>= :: HscSource -> HscSource -> Bool
> :: HscSource -> HscSource -> Bool
$c> :: HscSource -> HscSource -> Bool
<= :: HscSource -> HscSource -> Bool
$c<= :: HscSource -> HscSource -> Bool
< :: HscSource -> HscSource -> Bool
$c< :: HscSource -> HscSource -> Bool
compare :: HscSource -> HscSource -> Ordering
$ccompare :: HscSource -> HscSource -> Ordering
Ord, Int -> HscSource -> ShowS
[HscSource] -> ShowS
HscSource -> String
(Int -> HscSource -> ShowS)
-> (HscSource -> String)
-> ([HscSource] -> ShowS)
-> Show HscSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HscSource] -> ShowS
$cshowList :: [HscSource] -> ShowS
show :: HscSource -> String
$cshow :: HscSource -> String
showsPrec :: Int -> HscSource -> ShowS
$cshowsPrec :: Int -> HscSource -> ShowS
Show)
instance Binary HscSource where
put_ :: BinHandle -> HscSource -> IO ()
put_ BinHandle
bh HscSource
HsSrcFile = BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
0
put_ BinHandle
bh HscSource
HsBootFile = BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
1
put_ BinHandle
bh HscSource
HsigFile = BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
2
get :: BinHandle -> IO HscSource
get BinHandle
bh = do
Word8
h <- BinHandle -> IO Word8
getByte BinHandle
bh
case Word8
h of
Word8
0 -> HscSource -> IO HscSource
forall (m :: * -> *) a. Monad m => a -> m a
return HscSource
HsSrcFile
Word8
1 -> HscSource -> IO HscSource
forall (m :: * -> *) a. Monad m => a -> m a
return HscSource
HsBootFile
Word8
_ -> HscSource -> IO HscSource
forall (m :: * -> *) a. Monad m => a -> m a
return HscSource
HsigFile
hscSourceString :: HscSource -> String
hscSourceString :: HscSource -> String
hscSourceString HscSource
HsSrcFile = String
""
hscSourceString HscSource
HsBootFile = String
"[boot]"
hscSourceString HscSource
HsigFile = String
"[sig]"
isHsBootOrSig :: HscSource -> Bool
isHsBootOrSig :: HscSource -> Bool
isHsBootOrSig HscSource
HsBootFile = Bool
True
isHsBootOrSig HscSource
HsigFile = Bool
True
isHsBootOrSig HscSource
_ = Bool
False
isHsigFile :: HscSource -> Bool
isHsigFile :: HscSource -> Bool
isHsigFile HscSource
HsigFile = Bool
True
isHsigFile HscSource
_ = Bool
False
data SourceModified
= SourceModified
| SourceUnmodified
| SourceUnmodifiedAndStable