{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module HiFileParser
( Interface(..)
, List(..)
, Dictionary(..)
, Module(..)
, Usage(..)
, Dependencies(..)
, getInterface
, fromFile
) where
import Control.Monad (replicateM, replicateM_)
import Data.Binary (Word64,Word32,Word8)
import qualified Data.Binary.Get as G (Get, Decoder (..), bytesRead,
getByteString, getInt64be,
getWord32be, getWord64be,
getWord8, lookAhead,
runGetIncremental, skip)
import Data.Bool (bool)
import Data.ByteString.Lazy.Internal (defaultChunkSize)
import Data.Char (chr)
import Data.Functor (void, ($>))
import Data.List (find)
import Data.Maybe (catMaybes)
import Data.Semigroup ((<>))
import qualified Data.Vector as V
import GHC.IO.IOMode (IOMode (..))
import Numeric (showHex)
import RIO.ByteString as B (ByteString, hGetSome, null)
import RIO (Int64,Generic, NFData)
import System.IO (withBinaryFile)
import Data.Bits (FiniteBits(..),testBit,
unsafeShiftL,(.|.),clearBit,
complement)
import Control.Monad.State
import qualified Debug.Trace
newtype IfaceGetState = IfaceGetState
{ IfaceGetState -> Bool
useLEB128 :: Bool
}
type Get a = StateT IfaceGetState G.Get a
enableDebug :: Bool
enableDebug :: Bool
enableDebug = Bool
False
traceGet :: String -> Get ()
traceGet :: String -> Get ()
traceGet String
s
| Bool
enableDebug = String -> Get () -> Get ()
forall a. String -> a -> a
Debug.Trace.trace String
s (() -> Get ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
| Bool
otherwise = () -> Get ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceShow :: Show a => String -> Get a -> Get a
traceShow :: String -> Get a -> Get a
traceShow String
s Get a
g
| Bool -> Bool
not Bool
enableDebug = Get a
g
| Bool
otherwise = do
a
a <- Get a
g
String -> Get ()
traceGet (String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
a)
a -> Get a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
runGetIncremental :: Get a -> G.Decoder a
runGetIncremental :: Get a -> Decoder a
runGetIncremental Get a
g = Get a -> Decoder a
forall a. Get a -> Decoder a
G.runGetIncremental (Get a -> IfaceGetState -> Get a
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT Get a
g IfaceGetState
emptyState)
where
emptyState :: IfaceGetState
emptyState = Bool -> IfaceGetState
IfaceGetState Bool
False
getByteString :: Int -> Get ByteString
getByteString :: Int -> Get ByteString
getByteString Int
i = Get ByteString -> Get ByteString
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Int -> Get ByteString
G.getByteString Int
i)
getWord8 :: Get Word8
getWord8 :: Get Word8
getWord8 = Get Word8 -> Get Word8
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Word8
G.getWord8
bytesRead :: Get Int64
bytesRead :: Get Int64
bytesRead = Get Int64 -> Get Int64
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Int64
G.bytesRead
skip :: Int -> Get ()
skip :: Int -> Get ()
skip = Get () -> Get ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Get () -> Get ()) -> (Int -> Get ()) -> Int -> Get ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Get ()
G.skip
uleb :: Get a -> Get a -> Get a
uleb :: Get a -> Get a -> Get a
uleb Get a
f Get a
g = do
Bool
c <- (IfaceGetState -> Bool) -> StateT IfaceGetState Get Bool
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets IfaceGetState -> Bool
useLEB128
if Bool
c then Get a
f else Get a
g
getWord32be :: Get Word32
getWord32be :: Get Word32
getWord32be = Get Word32 -> Get Word32 -> Get Word32
forall a. Get a -> Get a -> Get a
uleb Get Word32
forall a. (Integral a, FiniteBits a) => Get a
getULEB128 (Get Word32 -> Get Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Word32
G.getWord32be)
getWord64be :: Get Word64
getWord64be :: Get Word64
getWord64be = Get Word64 -> Get Word64 -> Get Word64
forall a. Get a -> Get a -> Get a
uleb Get Word64
forall a. (Integral a, FiniteBits a) => Get a
getULEB128 (Get Word64 -> Get Word64
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Word64
G.getWord64be)
getInt64be :: Get Int64
getInt64be :: Get Int64
getInt64be = Get Int64 -> Get Int64 -> Get Int64
forall a. Get a -> Get a -> Get a
uleb Get Int64
forall a. (Integral a, FiniteBits a) => Get a
getSLEB128 (Get Int64 -> Get Int64
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Int64
G.getInt64be)
lookAhead :: Get b -> Get b
lookAhead :: Get b -> Get b
lookAhead Get b
g = do
IfaceGetState
s <- StateT IfaceGetState Get IfaceGetState
forall s (m :: * -> *). MonadState s m => m s
get
Get b -> Get b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Get b -> Get b) -> Get b -> Get b
forall a b. (a -> b) -> a -> b
$ Get b -> Get b
forall a. Get a -> Get a
G.lookAhead (Get b -> IfaceGetState -> Get b
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT Get b
g IfaceGetState
s)
getPtr :: Get Word32
getPtr :: Get Word32
getPtr = Get Word32 -> Get Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Word32
G.getWord32be
type IsBoot = Bool
type ModuleName = ByteString
newtype List a = List
{ List a -> [a]
unList :: [a]
} deriving newtype (Int -> List a -> String -> String
[List a] -> String -> String
List a -> String
(Int -> List a -> String -> String)
-> (List a -> String)
-> ([List a] -> String -> String)
-> Show (List a)
forall a. Show a => Int -> List a -> String -> String
forall a. Show a => [List a] -> String -> String
forall a. Show a => List a -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [List a] -> String -> String
$cshowList :: forall a. Show a => [List a] -> String -> String
show :: List a -> String
$cshow :: forall a. Show a => List a -> String
showsPrec :: Int -> List a -> String -> String
$cshowsPrec :: forall a. Show a => Int -> List a -> String -> String
Show, List a -> ()
(List a -> ()) -> NFData (List a)
forall a. NFData a => List a -> ()
forall a. (a -> ()) -> NFData a
rnf :: List a -> ()
$crnf :: forall a. NFData a => List a -> ()
NFData)
newtype Dictionary = Dictionary
{ Dictionary -> Vector ByteString
unDictionary :: V.Vector ByteString
} deriving newtype (Int -> Dictionary -> String -> String
[Dictionary] -> String -> String
Dictionary -> String
(Int -> Dictionary -> String -> String)
-> (Dictionary -> String)
-> ([Dictionary] -> String -> String)
-> Show Dictionary
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Dictionary] -> String -> String
$cshowList :: [Dictionary] -> String -> String
show :: Dictionary -> String
$cshow :: Dictionary -> String
showsPrec :: Int -> Dictionary -> String -> String
$cshowsPrec :: Int -> Dictionary -> String -> String
Show, Dictionary -> ()
(Dictionary -> ()) -> NFData Dictionary
forall a. (a -> ()) -> NFData a
rnf :: Dictionary -> ()
$crnf :: Dictionary -> ()
NFData)
newtype Module = Module
{ Module -> ByteString
unModule :: ModuleName
} deriving newtype (Int -> Module -> String -> String
[Module] -> String -> String
Module -> String
(Int -> Module -> String -> String)
-> (Module -> String)
-> ([Module] -> String -> String)
-> Show Module
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Module] -> String -> String
$cshowList :: [Module] -> String -> String
show :: Module -> String
$cshow :: Module -> String
showsPrec :: Int -> Module -> String -> String
$cshowsPrec :: Int -> Module -> String -> String
Show, Module -> ()
(Module -> ()) -> NFData Module
forall a. (a -> ()) -> NFData a
rnf :: Module -> ()
$crnf :: Module -> ()
NFData)
newtype Usage = Usage
{ Usage -> String
unUsage :: FilePath
} deriving newtype (Int -> Usage -> String -> String
[Usage] -> String -> String
Usage -> String
(Int -> Usage -> String -> String)
-> (Usage -> String) -> ([Usage] -> String -> String) -> Show Usage
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Usage] -> String -> String
$cshowList :: [Usage] -> String -> String
show :: Usage -> String
$cshow :: Usage -> String
showsPrec :: Int -> Usage -> String -> String
$cshowsPrec :: Int -> Usage -> String -> String
Show, Usage -> ()
(Usage -> ()) -> NFData Usage
forall a. (a -> ()) -> NFData a
rnf :: Usage -> ()
$crnf :: Usage -> ()
NFData)
data Dependencies = Dependencies
{ Dependencies -> List (ByteString, Bool)
dmods :: List (ModuleName, IsBoot)
, Dependencies -> List (ByteString, Bool)
dpkgs :: List (ModuleName, Bool)
, Dependencies -> List Module
dorphs :: List Module
, Dependencies -> List Module
dfinsts :: List Module
, Dependencies -> List ByteString
dplugins :: List ModuleName
} deriving (Int -> Dependencies -> String -> String
[Dependencies] -> String -> String
Dependencies -> String
(Int -> Dependencies -> String -> String)
-> (Dependencies -> String)
-> ([Dependencies] -> String -> String)
-> Show Dependencies
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Dependencies] -> String -> String
$cshowList :: [Dependencies] -> String -> String
show :: Dependencies -> String
$cshow :: Dependencies -> String
showsPrec :: Int -> Dependencies -> String -> String
$cshowsPrec :: Int -> Dependencies -> String -> String
Show, (forall x. Dependencies -> Rep Dependencies x)
-> (forall x. Rep Dependencies x -> Dependencies)
-> Generic Dependencies
forall x. Rep Dependencies x -> Dependencies
forall x. Dependencies -> Rep Dependencies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Dependencies x -> Dependencies
$cfrom :: forall x. Dependencies -> Rep Dependencies x
Generic)
instance NFData Dependencies
data Interface = Interface
{ Interface -> Dependencies
deps :: Dependencies
, Interface -> List Usage
usage :: List Usage
} deriving (Int -> Interface -> String -> String
[Interface] -> String -> String
Interface -> String
(Int -> Interface -> String -> String)
-> (Interface -> String)
-> ([Interface] -> String -> String)
-> Show Interface
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Interface] -> String -> String
$cshowList :: [Interface] -> String -> String
show :: Interface -> String
$cshow :: Interface -> String
showsPrec :: Int -> Interface -> String -> String
$cshowsPrec :: Int -> Interface -> String -> String
Show, (forall x. Interface -> Rep Interface x)
-> (forall x. Rep Interface x -> Interface) -> Generic Interface
forall x. Rep Interface x -> Interface
forall x. Interface -> Rep Interface x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Interface x -> Interface
$cfrom :: forall x. Interface -> Rep Interface x
Generic)
instance NFData Interface
withBlockPrefix :: Get a -> Get a
withBlockPrefix :: Get a -> Get a
withBlockPrefix Get a
f = Get Word32
getPtr Get Word32 -> Get a -> Get a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get a
f
getBool :: Get Bool
getBool :: StateT IfaceGetState Get Bool
getBool = Int -> Bool
forall a. Enum a => Int -> a
toEnum (Int -> Bool) -> (Word8 -> Int) -> Word8 -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word8 -> Bool) -> Get Word8 -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word8
getWord8
getString :: Get String
getString :: Get String
getString = (Word32 -> Char) -> [Word32] -> String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> Char
chr (Int -> Char) -> (Word32 -> Int) -> Word32 -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) ([Word32] -> String)
-> (List Word32 -> [Word32]) -> List Word32 -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List Word32 -> [Word32]
forall a. List a -> [a]
unList (List Word32 -> String)
-> StateT IfaceGetState Get (List Word32) -> Get String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32 -> StateT IfaceGetState Get (List Word32)
forall a. Get a -> Get (List a)
getList Get Word32
getWord32be
getMaybe :: Get a -> Get (Maybe a)
getMaybe :: Get a -> Get (Maybe a)
getMaybe Get a
f = Get (Maybe a) -> Get (Maybe a) -> Bool -> Get (Maybe a)
forall a. a -> a -> Bool -> a
bool (Maybe a -> Get (Maybe a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe a
forall a. Maybe a
Nothing) (a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> Get a -> Get (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get a
f) (Bool -> Get (Maybe a))
-> StateT IfaceGetState Get Bool -> Get (Maybe a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< StateT IfaceGetState Get Bool
getBool
getList :: Get a -> Get (List a)
getList :: Get a -> Get (List a)
getList Get a
f = do
Bool
use_uleb <- (IfaceGetState -> Bool) -> StateT IfaceGetState Get Bool
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets IfaceGetState -> Bool
useLEB128
if Bool
use_uleb
then do
Int64
l <- (Get Int64
forall a. (Integral a, FiniteBits a) => Get a
getSLEB128 :: Get Int64)
[a] -> List a
forall a. [a] -> List a
List ([a] -> List a) -> StateT IfaceGetState Get [a] -> Get (List a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Get a -> StateT IfaceGetState Get [a]
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM (Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
l) Get a
f
else do
Word8
i <- Get Word8
getWord8
Word32
l <-
if Word8
i Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
0xff
then Get Word32
getWord32be
else Word32 -> Get Word32
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word8 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
i :: Word32)
[a] -> List a
forall a. [a] -> List a
List ([a] -> List a) -> StateT IfaceGetState Get [a] -> Get (List a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Get a -> StateT IfaceGetState Get [a]
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
l) Get a
f
getTuple :: Get a -> Get b -> Get (a, b)
getTuple :: Get a -> Get b -> Get (a, b)
getTuple Get a
f Get b
g = (,) (a -> b -> (a, b))
-> Get a -> StateT IfaceGetState Get (b -> (a, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get a
f StateT IfaceGetState Get (b -> (a, b)) -> Get b -> Get (a, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get b
g
getByteStringSized :: Get ByteString
getByteStringSized :: Get ByteString
getByteStringSized = do
Int64
size <- Get Int64
getInt64be
Int -> Get ByteString
getByteString (Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
size)
getDictionary :: Int -> Get Dictionary
getDictionary :: Int -> Get Dictionary
getDictionary Int
ptr = do
Int64
offset <- Get Int64
bytesRead
Int -> Get ()
skip (Int -> Get ()) -> Int -> Get ()
forall a b. (a -> b) -> a -> b
$ Int
ptr Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
offset
Int
size <- Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int) -> Get Int64 -> StateT IfaceGetState Get Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int64
getInt64be
String -> Get ()
traceGet (String
"Dictionary size: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
size)
Dictionary
dict <- Vector ByteString -> Dictionary
Dictionary (Vector ByteString -> Dictionary)
-> StateT IfaceGetState Get (Vector ByteString) -> Get Dictionary
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> Get ByteString -> StateT IfaceGetState Get (Vector ByteString)
forall (m :: * -> *) a. Monad m => Int -> m a -> m (Vector a)
V.replicateM Int
size Get ByteString
getByteStringSized
String -> Get ()
traceGet (String
"Dictionary: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Dictionary -> String
forall a. Show a => a -> String
show Dictionary
dict)
Dictionary -> Get Dictionary
forall (m :: * -> *) a. Monad m => a -> m a
return Dictionary
dict
getCachedBS :: Dictionary -> Get ByteString
getCachedBS :: Dictionary -> Get ByteString
getCachedBS Dictionary
d = Word32 -> Get ByteString
forall a (f :: * -> *).
(Integral a, MonadFail f, Show a) =>
a -> f ByteString
go (Word32 -> Get ByteString) -> Get Word32 -> Get ByteString
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< String -> Get Word32 -> Get Word32
forall a. Show a => String -> Get a -> Get a
traceShow String
"Dict index:" Get Word32
getWord32be
where
go :: a -> f ByteString
go a
i =
case Dictionary -> Vector ByteString
unDictionary Dictionary
d Vector ByteString -> Int -> Maybe ByteString
forall a. Vector a -> Int -> Maybe a
V.!? a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i of
Just ByteString
bs -> ByteString -> f ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure ByteString
bs
Maybe ByteString
Nothing -> String -> f ByteString
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> f ByteString) -> String -> f ByteString
forall a b. (a -> b) -> a -> b
$ String
"Invalid dictionary index: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> a -> String
forall a. Show a => a -> String
show a
i
getFP' :: Get String
getFP' :: Get String
getFP' = do
Word64
x <- Get Word64
getWord64be
Word64
y <- Get Word64
getWord64be
String -> Get String
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64 -> String -> String
forall a. (Integral a, Show a) => a -> String -> String
showHex Word64
x (Word64 -> String -> String
forall a. (Integral a, Show a) => a -> String -> String
showHex Word64
y String
""))
getFP :: Get ()
getFP :: Get ()
getFP = Get String -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get String
getFP'
getInterface721 :: Dictionary -> Get Interface
getInterface721 :: Dictionary -> Get Interface
getInterface721 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
2 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d)
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies (List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
List ByteString -> StateT IfaceGetState Get (List ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ByteString] -> List ByteString
forall a. [a] -> List a
List [])
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface741 :: Dictionary -> Get Interface
getInterface741 :: Dictionary -> Get Interface
getInterface741 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d)
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies (List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
List ByteString -> StateT IfaceGetState Get (List ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ByteString] -> List ByteString
forall a. [a] -> List a
List [])
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
2 -> Usage -> Maybe Usage
forall a. a -> Maybe a
Just (Usage -> Maybe Usage)
-> (String -> Usage) -> String -> Maybe Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage (String -> Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString Get (Maybe Usage) -> Get Word64 -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get Word64
getWord64be Get (Maybe Usage) -> Get Word64 -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get Word64
getWord64be
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface761 :: Dictionary -> Get Interface
getInterface761 :: Dictionary -> Get Interface
getInterface761 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d)
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies (List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
List ByteString -> StateT IfaceGetState Get (List ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ByteString] -> List ByteString
forall a. [a] -> List a
List [])
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
2 -> Usage -> Maybe Usage
forall a. a -> Maybe a
Just (Usage -> Maybe Usage)
-> (String -> Usage) -> String -> Maybe Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage (String -> Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString Get (Maybe Usage) -> Get Word64 -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get Word64
getWord64be Get (Maybe Usage) -> Get Word64 -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get Word64
getWord64be
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface781 :: Dictionary -> Get Interface
getInterface781 :: Dictionary -> Get Interface
getInterface781 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d)
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies (List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
List ByteString -> StateT IfaceGetState Get (List ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ByteString] -> List ByteString
forall a. [a] -> List a
List [])
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
2 -> Usage -> Maybe Usage
forall a. a -> Maybe a
Just (Usage -> Maybe Usage)
-> (String -> Usage) -> String -> Maybe Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage (String -> Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString Get (Maybe Usage) -> Get () -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface801 :: Dictionary -> Get Interface
getInterface801 :: Dictionary -> Get Interface
getInterface801 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
Get Word8 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d)
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies (List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
List ByteString -> StateT IfaceGetState Get (List ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ByteString] -> List ByteString
forall a. [a] -> List a
List [])
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
2 -> Usage -> Maybe Usage
forall a. a -> Maybe a
Just (Usage -> Maybe Usage)
-> (String -> Usage) -> String -> Maybe Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage (String -> Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString Get (Maybe Usage) -> Get () -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
3 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get () -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface821 :: Dictionary -> Get Interface
getInterface821 :: Dictionary -> Get Interface
getInterface821 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get (Maybe Module) -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get (Maybe Module) -> Get ())
-> StateT IfaceGetState Get (Maybe Module) -> Get ()
forall a b. (a -> b) -> a -> b
$ StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (Maybe Module)
forall a. Get a -> Get (Maybe a)
getMaybe StateT IfaceGetState Get Module
getModule
Get Word8 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = do
Word8
idType <- Get Word8
getWord8
case Word8
idType of
Word8
0 -> Get ByteString -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Get ByteString -> Get ()) -> Get ByteString -> Get ()
forall a b. (a -> b) -> a -> b
$ Dictionary -> Get ByteString
getCachedBS Dictionary
d
Word8
_ ->
StateT IfaceGetState Get (List (ByteString, Module)) -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get (List (ByteString, Module)) -> Get ())
-> StateT IfaceGetState Get (List (ByteString, Module)) -> Get ()
forall a b. (a -> b) -> a -> b
$
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get (List (ByteString, Module))
-> StateT IfaceGetState Get (List (ByteString, Module))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get (ByteString, Module)
-> StateT IfaceGetState Get (List (ByteString, Module))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Module -> Get (ByteString, Module)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Module
getModule)
ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies (List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
List ByteString -> StateT IfaceGetState Get (List ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ByteString] -> List ByteString
forall a. [a] -> List a
List [])
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
2 -> Usage -> Maybe Usage
forall a. a -> Maybe a
Just (Usage -> Maybe Usage)
-> (String -> Usage) -> String -> Maybe Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage (String -> Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString Get (Maybe Usage) -> Get () -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
3 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get () -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface841 :: Dictionary -> Get Interface
getInterface841 :: Dictionary -> Get Interface
getInterface841 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get (Maybe Module) -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get (Maybe Module) -> Get ())
-> StateT IfaceGetState Get (Maybe Module) -> Get ()
forall a b. (a -> b) -> a -> b
$ StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (Maybe Module)
forall a. Get a -> Get (Maybe a)
getMaybe StateT IfaceGetState Get Module
getModule
Get Word8 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
5 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = do
Word8
idType <- Get Word8
getWord8
case Word8
idType of
Word8
0 -> Get ByteString -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Get ByteString -> Get ()) -> Get ByteString -> Get ()
forall a b. (a -> b) -> a -> b
$ Dictionary -> Get ByteString
getCachedBS Dictionary
d
Word8
_ ->
StateT IfaceGetState Get (List (ByteString, Module)) -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get (List (ByteString, Module)) -> Get ())
-> StateT IfaceGetState Get (List (ByteString, Module)) -> Get ()
forall a b. (a -> b) -> a -> b
$
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get (List (ByteString, Module))
-> StateT IfaceGetState Get (List (ByteString, Module))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get (ByteString, Module)
-> StateT IfaceGetState Get (List (ByteString, Module))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Module -> Get (ByteString, Module)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Module
getModule)
ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies (List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
List ByteString -> StateT IfaceGetState Get (List ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ByteString] -> List ByteString
forall a. [a] -> List a
List [])
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
2 -> Usage -> Maybe Usage
forall a. a -> Maybe a
Just (Usage -> Maybe Usage)
-> (String -> Usage) -> String -> Maybe Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage (String -> Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString Get (Maybe Usage) -> Get () -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
3 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get () -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface861 :: Dictionary -> Get Interface
getInterface861 :: Dictionary -> Get Interface
getInterface861 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get (Maybe Module) -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get (Maybe Module) -> Get ())
-> StateT IfaceGetState Get (Maybe Module) -> Get ()
forall a b. (a -> b) -> a -> b
$ StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (Maybe Module)
forall a. Get a -> Get (Maybe a)
getMaybe StateT IfaceGetState Get Module
getModule
Get Word8 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
6 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = do
Word8
idType <- Get Word8
getWord8
case Word8
idType of
Word8
0 -> Get ByteString -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Get ByteString -> Get ()) -> Get ByteString -> Get ()
forall a b. (a -> b) -> a -> b
$ Dictionary -> Get ByteString
getCachedBS Dictionary
d
Word8
_ ->
StateT IfaceGetState Get (List (ByteString, Module)) -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get (List (ByteString, Module)) -> Get ())
-> StateT IfaceGetState Get (List (ByteString, Module)) -> Get ()
forall a b. (a -> b) -> a -> b
$
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get (List (ByteString, Module))
-> StateT IfaceGetState Get (List (ByteString, Module))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get (ByteString, Module)
-> StateT IfaceGetState Get (List (ByteString, Module))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Module -> Get (ByteString, Module)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Module
getModule)
ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies (List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool) StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Get ByteString -> StateT IfaceGetState Get (List ByteString)
forall a. Get a -> Get (List a)
getList (Dictionary -> Get ByteString
getCachedBS Dictionary
d)
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
2 -> Usage -> Maybe Usage
forall a. a -> Maybe a
Just (Usage -> Maybe Usage)
-> (String -> Usage) -> String -> Maybe Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage (String -> Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString Get (Maybe Usage) -> Get () -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
3 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get () -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface8101 :: Dictionary -> Get Interface
getInterface8101 :: Dictionary -> Get Interface
getInterface8101 Dictionary
d = do
StateT IfaceGetState Get Module -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get Module -> Get ())
-> StateT IfaceGetState Get Module -> Get ()
forall a b. (a -> b) -> a -> b
$ String
-> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get Module
forall a. Show a => String -> Get a -> Get a
traceShow String
"Module:" StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get (Maybe Module) -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get (Maybe Module) -> Get ())
-> StateT IfaceGetState Get (Maybe Module) -> Get ()
forall a b. (a -> b) -> a -> b
$ String
-> StateT IfaceGetState Get (Maybe Module)
-> StateT IfaceGetState Get (Maybe Module)
forall a. Show a => String -> Get a -> Get a
traceShow String
"Sig:" (StateT IfaceGetState Get (Maybe Module)
-> StateT IfaceGetState Get (Maybe Module))
-> StateT IfaceGetState Get (Maybe Module)
-> StateT IfaceGetState Get (Maybe Module)
forall a b. (a -> b) -> a -> b
$ StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (Maybe Module)
forall a. Get a -> Get (Maybe a)
getMaybe StateT IfaceGetState Get Module
getModule
Get Word8 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
Int -> Get () -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
6 Get ()
getFP
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
StateT IfaceGetState Get Bool -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Bool
getBool
Dependencies -> List Usage -> Interface
Interface (Dependencies -> List Usage -> Interface)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get (List Usage -> Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Show a => String -> Get a -> Get a
traceShow String
"Dependencies:" StateT IfaceGetState Get Dependencies
getDependencies StateT IfaceGetState Get (List Usage -> Interface)
-> StateT IfaceGetState Get (List Usage) -> Get Interface
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> String
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Show a => String -> Get a -> Get a
traceShow String
"Usage:" StateT IfaceGetState Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = do
Word8
idType <- String -> Get Word8 -> Get Word8
forall a. Show a => String -> Get a -> Get a
traceShow String
"Unit type:" Get Word8
getWord8
case Word8
idType of
Word8
0 -> Get ByteString -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Get ByteString -> Get ()) -> Get ByteString -> Get ()
forall a b. (a -> b) -> a -> b
$ Dictionary -> Get ByteString
getCachedBS Dictionary
d
Word8
1 ->
StateT IfaceGetState Get (List (ByteString, Module)) -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (StateT IfaceGetState Get (List (ByteString, Module)) -> Get ())
-> StateT IfaceGetState Get (List (ByteString, Module)) -> Get ()
forall a b. (a -> b) -> a -> b
$
Dictionary -> Get ByteString
getCachedBS Dictionary
d Get ByteString
-> StateT IfaceGetState Get (List (ByteString, Module))
-> StateT IfaceGetState Get (List (ByteString, Module))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get (ByteString, Module)
-> StateT IfaceGetState Get (List (ByteString, Module))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Module -> Get (ByteString, Module)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Module
getModule)
Word8
_ -> String -> Get ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get ()) -> String -> Get ()
forall a b. (a -> b) -> a -> b
$ String
"Invalid unit type: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
idType
ByteString -> Module
Module (ByteString -> Module)
-> Get ByteString -> StateT IfaceGetState Get Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ByteString
getCachedBS Dictionary
d
getDependencies :: StateT IfaceGetState Get Dependencies
getDependencies =
StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies)
-> StateT IfaceGetState Get Dependencies
-> StateT IfaceGetState Get Dependencies
forall a b. (a -> b) -> a -> b
$
List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies
Dependencies
(List (ByteString, Bool)
-> List (ByteString, Bool)
-> List Module
-> List Module
-> List ByteString
-> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool)
StateT
IfaceGetState
Get
(List (ByteString, Bool)
-> List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List (ByteString, Bool))
-> StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (ByteString, Bool)
-> StateT IfaceGetState Get (List (ByteString, Bool))
forall a. Get a -> Get (List a)
getList (Get ByteString
-> StateT IfaceGetState Get Bool -> Get (ByteString, Bool)
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ByteString
getCachedBS Dictionary
d) StateT IfaceGetState Get Bool
getBool)
StateT
IfaceGetState
Get
(List Module -> List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule
StateT
IfaceGetState Get (List Module -> List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List Module)
-> StateT IfaceGetState Get (List ByteString -> Dependencies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get (List Module)
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule
StateT IfaceGetState Get (List ByteString -> Dependencies)
-> StateT IfaceGetState Get (List ByteString)
-> StateT IfaceGetState Get Dependencies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get ByteString -> StateT IfaceGetState Get (List ByteString)
forall a. Get a -> Get (List a)
getList (Dictionary -> Get ByteString
getCachedBS Dictionary
d)
getUsage :: StateT IfaceGetState Get (List Usage)
getUsage = StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a. Get a -> Get a
withBlockPrefix (StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage))
-> StateT IfaceGetState Get (List Usage)
-> StateT IfaceGetState Get (List Usage)
forall a b. (a -> b) -> a -> b
$ [Usage] -> List Usage
forall a. [a] -> List a
List ([Usage] -> List Usage)
-> (List (Maybe Usage) -> [Usage])
-> List (Maybe Usage)
-> List Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Usage] -> [Usage]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Usage] -> [Usage])
-> (List (Maybe Usage) -> [Maybe Usage])
-> List (Maybe Usage)
-> [Usage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. List (Maybe Usage) -> [Maybe Usage]
forall a. List a -> [a]
unList (List (Maybe Usage) -> List Usage)
-> StateT IfaceGetState Get (List (Maybe Usage))
-> StateT IfaceGetState Get (List Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Maybe Usage) -> StateT IfaceGetState Get (List (Maybe Usage))
forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- String -> Get Word8 -> Get Word8
forall a. Show a => String -> Get a -> Get a
traceShow String
"Usage type:" Get Word8
getWord8
case Word8
usageType of
Word8
0 -> String
-> StateT IfaceGetState Get Module
-> StateT IfaceGetState Get Module
forall a. Show a => String -> Get a -> Get a
traceShow String
"Module:" StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
1 ->
String -> Get ByteString -> Get ByteString
forall a. Show a => String -> Get a -> Get a
traceShow String
"Home module:" (Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ByteString -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get ()
-> StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (Maybe ())
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get () -> StateT IfaceGetState Get (Maybe ())
forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP StateT IfaceGetState Get (Maybe ())
-> StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get (List (ByteString, ()))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get (ByteString, ())
-> StateT IfaceGetState Get (List (ByteString, ()))
forall a. Get a -> Get (List a)
getList (Get ByteString -> Get () -> Get (ByteString, ())
forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 Get Word8 -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ByteString
getCachedBS Dictionary
d) Get ()
getFP) StateT IfaceGetState Get (List (ByteString, ()))
-> StateT IfaceGetState Get Bool -> StateT IfaceGetState Get Bool
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
StateT IfaceGetState Get Bool
getBool StateT IfaceGetState Get Bool -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
2 -> Usage -> Maybe Usage
forall a. a -> Maybe a
Just (Usage -> Maybe Usage)
-> (String -> Usage) -> String -> Maybe Usage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage (String -> Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Get String -> Get String
forall a. Show a => String -> Get a -> Get a
traceShow String
"File:" Get String
getString Get (Maybe Usage) -> Get String -> Get (Maybe Usage)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* String -> Get String -> Get String
forall a. Show a => String -> Get a -> Get a
traceShow String
"FP:" Get String
getFP'
Word8
3 -> StateT IfaceGetState Get Module
getModule StateT IfaceGetState Get Module -> Get () -> Get ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP Get () -> Maybe Usage -> Get (Maybe Usage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Maybe Usage
forall a. Maybe a
Nothing
Word8
_ -> String -> Get (Maybe Usage)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get (Maybe Usage)) -> String -> Get (Maybe Usage)
forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word8 -> String
forall a. Show a => a -> String
show Word8
usageType
getInterface :: Get Interface
getInterface :: Get Interface
getInterface = do
let enableLEB128 :: Get ()
enableLEB128 = (IfaceGetState -> IfaceGetState) -> Get ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\IfaceGetState
c -> IfaceGetState
c { useLEB128 :: Bool
useLEB128 = Bool
True})
Word32
magic <- Get Word32 -> Get Word32
forall a. Get a -> Get a
lookAhead Get Word32
getWord32be Get Word32 -> (Word32 -> Get Word32) -> Get Word32
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Word32
0x1face -> Get Word32
getWord32be
Word32
0x1face64 -> Get Word32
getWord32be
Word32
m -> do
Get Word32 -> Get Word32
forall a. Get a -> Get a
lookAhead (Get ()
enableLEB128 Get () -> Get Word32 -> Get Word32
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Get Word32
getWord32be) Get Word32 -> (Word32 -> Get Word32) -> Get Word32
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Word32
0x1face -> Get ()
enableLEB128 Get () -> Get Word32 -> Get Word32
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Get Word32
getWord32be
Word32
0x1face64 -> Get ()
enableLEB128 Get () -> Get Word32 -> Get Word32
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Get Word32
getWord32be
Word32
_ -> String -> Get Word32
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get Word32) -> String -> Get Word32
forall a b. (a -> b) -> a -> b
$ String
"Invalid magic: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Word32 -> String -> String
forall a. (Integral a, Show a) => a -> String -> String
showHex Word32
m String
""
String -> Get ()
traceGet (String
"Magic: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Word32 -> String -> String
forall a. (Integral a, Show a) => a -> String -> String
showHex Word32
magic String
"")
case Word32
magic of
Word32
0x1face -> do
Word32
e <- Get Word32 -> Get Word32
forall a. Get a -> Get a
lookAhead Get Word32
getWord32be
if Word32
e Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== Word32
0
then Get Word32 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word32
getWord32be
else Get ()
enableLEB128
Word32
0x1face64 -> do
Word64
e <- Get Word64 -> Get Word64
forall a. Get a -> Get a
lookAhead Get Word64
getWord64be
if Word64
e Word64 -> Word64 -> Bool
forall a. Eq a => a -> a -> Bool
== Word64
0
then Get Word64 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word64
getWord64be
else Get ()
enableLEB128
Word32
_ -> () -> Get ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
String
version <- Get String
getString
String -> Get ()
traceGet (String
"Version: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
version)
String
way <- Get String
getString
String -> Get ()
traceGet (String
"Ways: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
forall a. Show a => a -> String
show String
way)
Bool -> Get () -> Get ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (String
version String -> String -> Bool
forall a. Ord a => a -> a -> Bool
>= String
"9001") (Get () -> Get ()) -> Get () -> Get ()
forall a b. (a -> b) -> a -> b
$ Get Word32 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word32
getPtr
Word32
dictPtr <- Get Word32
getPtr
String -> Get ()
traceGet (String
"Dict ptr: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Word32 -> String
forall a. Show a => a -> String
show Word32
dictPtr)
Dictionary
dict <- Get Dictionary -> Get Dictionary
forall a. Get a -> Get a
lookAhead (Get Dictionary -> Get Dictionary)
-> Get Dictionary -> Get Dictionary
forall a b. (a -> b) -> a -> b
$ Int -> Get Dictionary
getDictionary (Int -> Get Dictionary) -> Int -> Get Dictionary
forall a b. (a -> b) -> a -> b
$ Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
dictPtr
Get Word32 -> Get ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word32
getPtr
let versions :: [(String, Dictionary -> Get Interface)]
versions =
[ (String
"8101", Dictionary -> Get Interface
getInterface8101)
, (String
"8061", Dictionary -> Get Interface
getInterface861)
, (String
"8041", Dictionary -> Get Interface
getInterface841)
, (String
"8021", Dictionary -> Get Interface
getInterface821)
, (String
"8001", Dictionary -> Get Interface
getInterface801)
, (String
"7081", Dictionary -> Get Interface
getInterface781)
, (String
"7061", Dictionary -> Get Interface
getInterface761)
, (String
"7041", Dictionary -> Get Interface
getInterface741)
, (String
"7021", Dictionary -> Get Interface
getInterface721)
]
case (String, Dictionary -> Get Interface)
-> Dictionary -> Get Interface
forall a b. (a, b) -> b
snd ((String, Dictionary -> Get Interface)
-> Dictionary -> Get Interface)
-> Maybe (String, Dictionary -> Get Interface)
-> Maybe (Dictionary -> Get Interface)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((String, Dictionary -> Get Interface) -> Bool)
-> [(String, Dictionary -> Get Interface)]
-> Maybe (String, Dictionary -> Get Interface)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find ((String
version String -> String -> Bool
forall a. Ord a => a -> a -> Bool
>=) (String -> Bool)
-> ((String, Dictionary -> Get Interface) -> String)
-> (String, Dictionary -> Get Interface)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, Dictionary -> Get Interface) -> String
forall a b. (a, b) -> a
fst) [(String, Dictionary -> Get Interface)]
versions of
Just Dictionary -> Get Interface
f -> Dictionary -> Get Interface
f Dictionary
dict
Maybe (Dictionary -> Get Interface)
Nothing -> String -> Get Interface
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get Interface) -> String -> Get Interface
forall a b. (a -> b) -> a -> b
$ String
"Unsupported version: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
version
fromFile :: FilePath -> IO (Either String Interface)
fromFile :: String -> IO (Either String Interface)
fromFile String
fp = String
-> IOMode
-> (Handle -> IO (Either String Interface))
-> IO (Either String Interface)
forall r. String -> IOMode -> (Handle -> IO r) -> IO r
withBinaryFile String
fp IOMode
ReadMode Handle -> IO (Either String Interface)
forall (f :: * -> *).
MonadIO f =>
Handle -> f (Either String Interface)
go
where
go :: Handle -> f (Either String Interface)
go Handle
h =
let feed :: Decoder b -> f (Either String b)
feed (G.Done ByteString
_ Int64
_ b
iface) = Either String b -> f (Either String b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either String b -> f (Either String b))
-> Either String b -> f (Either String b)
forall a b. (a -> b) -> a -> b
$ b -> Either String b
forall a b. b -> Either a b
Right b
iface
feed (G.Fail ByteString
_ Int64
_ String
msg) = Either String b -> f (Either String b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either String b -> f (Either String b))
-> Either String b -> f (Either String b)
forall a b. (a -> b) -> a -> b
$ String -> Either String b
forall a b. a -> Either a b
Left String
msg
feed (G.Partial Maybe ByteString -> Decoder b
k) = do
ByteString
chunk <- Handle -> Int -> f ByteString
forall (m :: * -> *). MonadIO m => Handle -> Int -> m ByteString
hGetSome Handle
h Int
defaultChunkSize
Decoder b -> f (Either String b)
feed (Decoder b -> f (Either String b))
-> Decoder b -> f (Either String b)
forall a b. (a -> b) -> a -> b
$ Maybe ByteString -> Decoder b
k (Maybe ByteString -> Decoder b) -> Maybe ByteString -> Decoder b
forall a b. (a -> b) -> a -> b
$ if ByteString -> Bool
B.null ByteString
chunk then Maybe ByteString
forall a. Maybe a
Nothing else ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
chunk
in Decoder Interface -> f (Either String Interface)
forall (f :: * -> *) b.
MonadIO f =>
Decoder b -> f (Either String b)
feed (Decoder Interface -> f (Either String Interface))
-> Decoder Interface -> f (Either String Interface)
forall a b. (a -> b) -> a -> b
$ Get Interface -> Decoder Interface
forall a. Get a -> Decoder a
runGetIncremental Get Interface
getInterface
getULEB128 :: forall a. (Integral a, FiniteBits a) => Get a
getULEB128 :: Get a
getULEB128 =
Int -> a -> Get a
go Int
0 a
0
where
go :: Int -> a -> Get a
go :: Int -> a -> Get a
go Int
shift a
w = do
Word8
b <- Get Word8
getWord8
let !hasMore :: Bool
hasMore = Word8 -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
testBit Word8
b Int
7
let !val :: a
val = a
w a -> a -> a
forall a. Bits a => a -> a -> a
.|. (a -> Int -> a
forall a. Bits a => a -> Int -> a
clearBit (Word8 -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
b) Int
7 a -> Int -> a
forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
shift) :: a
if Bool
hasMore
then do
Int -> a -> Get a
go (Int
shiftInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
7) a
val
else
a -> Get a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Get a) -> a -> Get a
forall a b. (a -> b) -> a -> b
$! a
val
getSLEB128 :: forall a. (Integral a, FiniteBits a) => Get a
getSLEB128 :: Get a
getSLEB128 = do
(a
val,Int
shift,Bool
signed) <- Int -> a -> Get (a, Int, Bool)
go Int
0 a
0
if Bool
signed Bool -> Bool -> Bool
&& (Int
shift Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< a -> Int
forall b. FiniteBits b => b -> Int
finiteBitSize a
val )
then a -> Get a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Get a) -> a -> Get a
forall a b. (a -> b) -> a -> b
$! ((a -> a
forall a. Bits a => a -> a
complement a
0 a -> Int -> a
forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
shift) a -> a -> a
forall a. Bits a => a -> a -> a
.|. a
val)
else a -> Get a
forall (m :: * -> *) a. Monad m => a -> m a
return a
val
where
go :: Int -> a -> Get (a,Int,Bool)
go :: Int -> a -> Get (a, Int, Bool)
go Int
shift a
val = do
Word8
byte <- Get Word8
getWord8
let !byteVal :: a
byteVal = Word8 -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word8 -> Int -> Word8
forall a. Bits a => a -> Int -> a
clearBit Word8
byte Int
7) :: a
let !val' :: a
val' = a
val a -> a -> a
forall a. Bits a => a -> a -> a
.|. (a
byteVal a -> Int -> a
forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
shift)
let !more :: Bool
more = Word8 -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
testBit Word8
byte Int
7
let !shift' :: Int
shift' = Int
shiftInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
7
if Bool
more
then Int -> a -> Get (a, Int, Bool)
go Int
shift' a
val'
else do
let !signed :: Bool
signed = Word8 -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
testBit Word8
byte Int
6
(a, Int, Bool) -> Get (a, Int, Bool)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
val',Int
shift',Bool
signed)