{-# LANGUAGE PatternSynonyms #-}
module GHC.Types.SourceFile
( HscSource(HsBootFile, HsigFile, ..)
, HsBootOrSig(..)
, hscSourceToIsBoot
, isHsBootOrSig
, isHsBootFile, isHsigFile
, hscSourceString
)
where
import GHC.Prelude
import GHC.Utils.Binary
import GHC.Unit.Types
data HsBootOrSig
= HsBoot
| Hsig
deriving (HsBootOrSig -> HsBootOrSig -> Bool
(HsBootOrSig -> HsBootOrSig -> Bool)
-> (HsBootOrSig -> HsBootOrSig -> Bool) -> Eq HsBootOrSig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HsBootOrSig -> HsBootOrSig -> Bool
== :: HsBootOrSig -> HsBootOrSig -> Bool
$c/= :: HsBootOrSig -> HsBootOrSig -> Bool
/= :: HsBootOrSig -> HsBootOrSig -> Bool
Eq, Eq HsBootOrSig
Eq HsBootOrSig =>
(HsBootOrSig -> HsBootOrSig -> Ordering)
-> (HsBootOrSig -> HsBootOrSig -> Bool)
-> (HsBootOrSig -> HsBootOrSig -> Bool)
-> (HsBootOrSig -> HsBootOrSig -> Bool)
-> (HsBootOrSig -> HsBootOrSig -> Bool)
-> (HsBootOrSig -> HsBootOrSig -> HsBootOrSig)
-> (HsBootOrSig -> HsBootOrSig -> HsBootOrSig)
-> Ord HsBootOrSig
HsBootOrSig -> HsBootOrSig -> Bool
HsBootOrSig -> HsBootOrSig -> Ordering
HsBootOrSig -> HsBootOrSig -> HsBootOrSig
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
$ccompare :: HsBootOrSig -> HsBootOrSig -> Ordering
compare :: HsBootOrSig -> HsBootOrSig -> Ordering
$c< :: HsBootOrSig -> HsBootOrSig -> Bool
< :: HsBootOrSig -> HsBootOrSig -> Bool
$c<= :: HsBootOrSig -> HsBootOrSig -> Bool
<= :: HsBootOrSig -> HsBootOrSig -> Bool
$c> :: HsBootOrSig -> HsBootOrSig -> Bool
> :: HsBootOrSig -> HsBootOrSig -> Bool
$c>= :: HsBootOrSig -> HsBootOrSig -> Bool
>= :: HsBootOrSig -> HsBootOrSig -> Bool
$cmax :: HsBootOrSig -> HsBootOrSig -> HsBootOrSig
max :: HsBootOrSig -> HsBootOrSig -> HsBootOrSig
$cmin :: HsBootOrSig -> HsBootOrSig -> HsBootOrSig
min :: HsBootOrSig -> HsBootOrSig -> HsBootOrSig
Ord, Int -> HsBootOrSig -> ShowS
[HsBootOrSig] -> ShowS
HsBootOrSig -> String
(Int -> HsBootOrSig -> ShowS)
-> (HsBootOrSig -> String)
-> ([HsBootOrSig] -> ShowS)
-> Show HsBootOrSig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HsBootOrSig -> ShowS
showsPrec :: Int -> HsBootOrSig -> ShowS
$cshow :: HsBootOrSig -> String
show :: HsBootOrSig -> String
$cshowList :: [HsBootOrSig] -> ShowS
showList :: [HsBootOrSig] -> ShowS
Show)
data HscSource
= HsSrcFile
| HsBootOrSig !HsBootOrSig
deriving (HscSource -> HscSource -> Bool
(HscSource -> HscSource -> Bool)
-> (HscSource -> HscSource -> Bool) -> Eq HscSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HscSource -> HscSource -> Bool
== :: HscSource -> HscSource -> Bool
$c/= :: HscSource -> HscSource -> Bool
/= :: 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
$ccompare :: HscSource -> HscSource -> Ordering
compare :: HscSource -> HscSource -> Ordering
$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
>= :: HscSource -> HscSource -> Bool
$cmax :: HscSource -> HscSource -> HscSource
max :: HscSource -> HscSource -> HscSource
$cmin :: HscSource -> HscSource -> HscSource
min :: HscSource -> HscSource -> HscSource
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
$cshowsPrec :: Int -> HscSource -> ShowS
showsPrec :: Int -> HscSource -> ShowS
$cshow :: HscSource -> String
show :: HscSource -> String
$cshowList :: [HscSource] -> ShowS
showList :: [HscSource] -> ShowS
Show)
{-# COMPLETE HsSrcFile, HsBootFile, HsigFile #-}
pattern HsBootFile, HsigFile :: HscSource
pattern $mHsBootFile :: forall {r}. HscSource -> ((# #) -> r) -> ((# #) -> r) -> r
$bHsBootFile :: HscSource
HsBootFile = HsBootOrSig HsBoot
pattern $mHsigFile :: forall {r}. HscSource -> ((# #) -> r) -> ((# #) -> r) -> r
$bHsigFile :: HscSource
HsigFile = HsBootOrSig Hsig
hscSourceToIsBoot :: HscSource -> IsBootInterface
hscSourceToIsBoot :: HscSource -> IsBootInterface
hscSourceToIsBoot HscSource
HsBootFile = IsBootInterface
IsBoot
hscSourceToIsBoot HscSource
_ = IsBootInterface
NotBoot
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 a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HscSource
HsSrcFile
Word8
1 -> HscSource -> IO HscSource
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HscSource
HsBootFile
Word8
_ -> HscSource -> IO HscSource
forall a. a -> IO a
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 (HsBootOrSig HsBootOrSig
_) = Bool
True
isHsBootOrSig HscSource
HsSrcFile = Bool
False
isHsBootFile :: HscSource -> Bool
isHsBootFile :: HscSource -> Bool
isHsBootFile HscSource
HsBootFile = Bool
True
isHsBootFile HscSource
_ = Bool
False
isHsigFile :: HscSource -> Bool
isHsigFile :: HscSource -> Bool
isHsigFile HscSource
HsigFile = Bool
True
isHsigFile HscSource
_ = Bool
False