{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
module Unison.Runtime.MCode.Serialize
( putComb,
getComb,
putCombIx,
getCombIx,
)
where
import Data.Bytes.Get
import Data.Bytes.Put
import Data.Bytes.Serial
import Data.Bytes.VarInt
import Data.Void (Void)
import Data.Word (Word64)
import GHC.Exts (IsList (..))
import Unison.Runtime.ANF (PackedTag (..))
import Unison.Runtime.Array (PrimArray)
import Unison.Runtime.Foreign.Function.Type (ForeignFunc)
import Unison.Runtime.MCode hiding (MatchT)
import Unison.Runtime.Serialize
import Unison.Util.Text qualified as Util.Text
import Prelude hiding (getChar, putChar)
data CombT = LamT | CachedClosureT
instance Tag CombT where
tag2word :: CombT -> Word8
tag2word CombT
LamT = Word8
0
tag2word CombT
CachedClosureT = Word8
1
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m CombT
word2tag Word8
0 = CombT -> m CombT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CombT
LamT
word2tag Word8
1 = CombT -> m CombT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CombT
CachedClosureT
word2tag Word8
n = String -> Word8 -> m CombT
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"CombT" Word8
n
putPackedTag :: (MonadPut m) => PackedTag -> m ()
putPackedTag :: forall (m :: * -> *). MonadPut m => PackedTag -> m ()
putPackedTag (PackedTag Word64
w) = Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
w
getPackedTag :: (MonadGet m) => m PackedTag
getPackedTag :: forall (m :: * -> *). MonadGet m => m PackedTag
getPackedTag = Word64 -> PackedTag
PackedTag (Word64 -> PackedTag) -> m Word64 -> m PackedTag
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord
putComb :: (MonadPut m) => (clos -> m ()) -> GComb clos comb -> m ()
putComb :: forall (m :: * -> *) clos comb.
MonadPut m =>
(clos -> m ()) -> GComb clos comb -> m ()
putComb clos -> m ()
pClos = \case
(Lam Int
a Int
f GSection comb
body) ->
CombT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag CombT
LamT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
a m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
f m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection comb -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection comb
body
(CachedVal Word64
w clos
v) ->
CombT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag CombT
CachedClosureT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
putNat Word64
w m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> clos -> m ()
pClos clos
v
getComb :: (MonadGet m) => m (GComb Void CombIx)
getComb :: forall (m :: * -> *). MonadGet m => m (GComb Void CombIx)
getComb =
m CombT
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m CombT
-> (CombT -> m (GComb Void CombIx)) -> m (GComb Void CombIx)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
CombT
LamT ->
Int -> Int -> GSection CombIx -> GComb Void CombIx
forall comb val. Int -> Int -> GSection comb -> GComb val comb
Lam (Int -> Int -> GSection CombIx -> GComb Void CombIx)
-> m Int -> m (Int -> GSection CombIx -> GComb Void CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (Int -> GSection CombIx -> GComb Void CombIx)
-> m Int -> m (GSection CombIx -> GComb Void CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (GSection CombIx -> GComb Void CombIx)
-> m (GSection CombIx) -> m (GComb Void CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
CombT
CachedClosureT -> String -> m (GComb Void CombIx)
forall a. HasCallStack => String -> a
error String
"getComb: Unexpected serialized Cached Closure"
getMForeignFunc :: (MonadGet m) => m ForeignFunc
getMForeignFunc :: forall (m :: * -> *). MonadGet m => m ForeignFunc
getMForeignFunc = do
Int -> ForeignFunc
forall a. Enum a => Int -> a
toEnum (Int -> ForeignFunc) -> m Int -> m ForeignFunc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
putMForeignFunc :: (MonadPut m) => ForeignFunc -> m ()
putMForeignFunc :: forall (m :: * -> *). MonadPut m => ForeignFunc -> m ()
putMForeignFunc = Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt (Int -> m ()) -> (ForeignFunc -> Int) -> ForeignFunc -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ForeignFunc -> Int
forall a. Enum a => a -> Int
fromEnum
data SectionT
= AppT
| CallT
| JumpT
| MatchT
| YieldT
| InsT
| LetT
| DieT
| ExitT
| DMatchT
| NMatchT
| RMatchT
instance Tag SectionT where
tag2word :: SectionT -> Word8
tag2word SectionT
AppT = Word8
0
tag2word SectionT
CallT = Word8
1
tag2word SectionT
JumpT = Word8
2
tag2word SectionT
MatchT = Word8
3
tag2word SectionT
YieldT = Word8
4
tag2word SectionT
InsT = Word8
5
tag2word SectionT
LetT = Word8
6
tag2word SectionT
DieT = Word8
7
tag2word SectionT
ExitT = Word8
8
tag2word SectionT
DMatchT = Word8
9
tag2word SectionT
NMatchT = Word8
10
tag2word SectionT
RMatchT = Word8
11
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m SectionT
word2tag Word8
0 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
AppT
word2tag Word8
1 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
CallT
word2tag Word8
2 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
JumpT
word2tag Word8
3 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
MatchT
word2tag Word8
4 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
YieldT
word2tag Word8
5 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
InsT
word2tag Word8
6 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
LetT
word2tag Word8
7 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
DieT
word2tag Word8
8 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
ExitT
word2tag Word8
9 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
DMatchT
word2tag Word8
10 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
NMatchT
word2tag Word8
11 = SectionT -> m SectionT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SectionT
RMatchT
word2tag Word8
i = String -> Word8 -> m SectionT
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"SectionT" Word8
i
putSection :: (MonadPut m) => GSection cix -> m ()
putSection :: forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection = \case
App Bool
b GRef cix
r Args
a -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
AppT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Bool -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => Bool -> m ()
serialize Bool
b m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GRef cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GRef cix -> m ()
putRef GRef cix
r m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Args -> m ()
forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
a
Call Bool
b CombIx
cix cix
_comb Args
a -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
CallT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Bool -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => Bool -> m ()
serialize Bool
b m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> CombIx -> m ()
forall (m :: * -> *). MonadPut m => CombIx -> m ()
putCombIx CombIx
cix m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Args -> m ()
forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
a
Jump Int
i Args
a -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
JumpT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Args -> m ()
forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
a
Match Int
i GBranch cix
b -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
MatchT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GBranch cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GBranch cix -> m ()
putBranch GBranch cix
b
Yield Args
a -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
YieldT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Args -> m ()
forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
a
Ins GInstr cix
i GSection cix
s -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
InsT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GInstr cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GInstr cix -> m ()
putInstr GInstr cix
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
s
Let GSection cix
s CombIx
ci Int
f GSection cix
bd ->
SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
LetT
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
s
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> CombIx -> m ()
forall (m :: * -> *). MonadPut m => CombIx -> m ()
putCombIx CombIx
ci
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
f
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
bd
Die String
s -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
DieT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> String -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => String -> m ()
serialize String
s
GSection cix
Exit -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
ExitT
DMatch Maybe Reference
mr Int
i GBranch cix
b -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
DMatchT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Maybe Reference -> (Reference -> m ()) -> m ()
forall (m :: * -> *) a.
MonadPut m =>
Maybe a -> (a -> m ()) -> m ()
putMaybe Maybe Reference
mr Reference -> m ()
forall (m :: * -> *). MonadPut m => Reference -> m ()
putReference m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GBranch cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GBranch cix -> m ()
putBranch GBranch cix
b
NMatch Maybe Reference
mr Int
i GBranch cix
b -> SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
NMatchT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Maybe Reference -> (Reference -> m ()) -> m ()
forall (m :: * -> *) a.
MonadPut m =>
Maybe a -> (a -> m ()) -> m ()
putMaybe Maybe Reference
mr Reference -> m ()
forall (m :: * -> *). MonadPut m => Reference -> m ()
putReference m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GBranch cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GBranch cix -> m ()
putBranch GBranch cix
b
RMatch Int
i GSection cix
pu EnumMap Word64 (GBranch cix)
bs ->
SectionT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag SectionT
RMatchT
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
pu
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Word64 -> m ())
-> (GBranch cix -> m ()) -> EnumMap Word64 (GBranch cix) -> m ()
forall (m :: * -> *) k v.
(MonadPut m, EnumKey k) =>
(k -> m ()) -> (v -> m ()) -> EnumMap k v -> m ()
putEnumMap Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord GBranch cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GBranch cix -> m ()
putBranch EnumMap Word64 (GBranch cix)
bs
getSection :: (MonadGet m) => m Section
getSection :: forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection =
m SectionT
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m SectionT
-> (SectionT -> m (GSection CombIx)) -> m (GSection CombIx)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
SectionT
AppT -> Bool -> GRef CombIx -> Args -> GSection CombIx
forall comb. Bool -> GRef comb -> Args -> GSection comb
App (Bool -> GRef CombIx -> Args -> GSection CombIx)
-> m Bool -> m (GRef CombIx -> Args -> GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Bool
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m Bool
deserialize m (GRef CombIx -> Args -> GSection CombIx)
-> m (GRef CombIx) -> m (Args -> GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GRef CombIx)
forall (m :: * -> *). MonadGet m => m (GRef CombIx)
getRef m (Args -> GSection CombIx) -> m Args -> m (GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Args
forall (m :: * -> *). MonadGet m => m Args
getArgs
SectionT
CallT -> do
Bool
skipCheck <- m Bool
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m Bool
deserialize
CombIx
cix <- m CombIx
forall (m :: * -> *). MonadGet m => m CombIx
getCombIx
Args
args <- m Args
forall (m :: * -> *). MonadGet m => m Args
getArgs
pure $ Bool -> CombIx -> CombIx -> Args -> GSection CombIx
forall comb. Bool -> CombIx -> comb -> Args -> GSection comb
Call Bool
skipCheck CombIx
cix CombIx
cix Args
args
SectionT
JumpT -> Int -> Args -> GSection CombIx
forall comb. Int -> Args -> GSection comb
Jump (Int -> Args -> GSection CombIx)
-> m Int -> m (Args -> GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (Args -> GSection CombIx) -> m Args -> m (GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Args
forall (m :: * -> *). MonadGet m => m Args
getArgs
SectionT
MatchT -> Int -> GBranch CombIx -> GSection CombIx
forall comb. Int -> GBranch comb -> GSection comb
Match (Int -> GBranch CombIx -> GSection CombIx)
-> m Int -> m (GBranch CombIx -> GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (GBranch CombIx -> GSection CombIx)
-> m (GBranch CombIx) -> m (GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GBranch CombIx)
forall (m :: * -> *). MonadGet m => m (GBranch CombIx)
getBranch
SectionT
YieldT -> Args -> GSection CombIx
forall comb. Args -> GSection comb
Yield (Args -> GSection CombIx) -> m Args -> m (GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Args
forall (m :: * -> *). MonadGet m => m Args
getArgs
SectionT
InsT -> GInstr CombIx -> GSection CombIx -> GSection CombIx
forall comb. GInstr comb -> GSection comb -> GSection comb
Ins (GInstr CombIx -> GSection CombIx -> GSection CombIx)
-> m (GInstr CombIx) -> m (GSection CombIx -> GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (GInstr CombIx)
forall (m :: * -> *). MonadGet m => m (GInstr CombIx)
getInstr m (GSection CombIx -> GSection CombIx)
-> m (GSection CombIx) -> m (GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
SectionT
LetT ->
GSection CombIx
-> CombIx -> Int -> GSection CombIx -> GSection CombIx
forall comb.
GSection comb -> CombIx -> Int -> GSection comb -> GSection comb
Let (GSection CombIx
-> CombIx -> Int -> GSection CombIx -> GSection CombIx)
-> m (GSection CombIx)
-> m (CombIx -> Int -> GSection CombIx -> GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection m (CombIx -> Int -> GSection CombIx -> GSection CombIx)
-> m CombIx -> m (Int -> GSection CombIx -> GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m CombIx
forall (m :: * -> *). MonadGet m => m CombIx
getCombIx m (Int -> GSection CombIx -> GSection CombIx)
-> m Int -> m (GSection CombIx -> GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (GSection CombIx -> GSection CombIx)
-> m (GSection CombIx) -> m (GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
SectionT
DieT -> String -> GSection CombIx
forall comb. String -> GSection comb
Die (String -> GSection CombIx) -> m String -> m (GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m String
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m String
deserialize
SectionT
ExitT -> GSection CombIx -> m (GSection CombIx)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GSection CombIx
forall comb. GSection comb
Exit
SectionT
DMatchT -> Maybe Reference -> Int -> GBranch CombIx -> GSection CombIx
forall comb.
Maybe Reference -> Int -> GBranch comb -> GSection comb
DMatch (Maybe Reference -> Int -> GBranch CombIx -> GSection CombIx)
-> m (Maybe Reference)
-> m (Int -> GBranch CombIx -> GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Reference -> m (Maybe Reference)
forall (m :: * -> *) a. MonadGet m => m a -> m (Maybe a)
getMaybe m Reference
forall (m :: * -> *). MonadGet m => m Reference
getReference m (Int -> GBranch CombIx -> GSection CombIx)
-> m Int -> m (GBranch CombIx -> GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (GBranch CombIx -> GSection CombIx)
-> m (GBranch CombIx) -> m (GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GBranch CombIx)
forall (m :: * -> *). MonadGet m => m (GBranch CombIx)
getBranch
SectionT
NMatchT -> Maybe Reference -> Int -> GBranch CombIx -> GSection CombIx
forall comb.
Maybe Reference -> Int -> GBranch comb -> GSection comb
NMatch (Maybe Reference -> Int -> GBranch CombIx -> GSection CombIx)
-> m (Maybe Reference)
-> m (Int -> GBranch CombIx -> GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Reference -> m (Maybe Reference)
forall (m :: * -> *) a. MonadGet m => m a -> m (Maybe a)
getMaybe m Reference
forall (m :: * -> *). MonadGet m => m Reference
getReference m (Int -> GBranch CombIx -> GSection CombIx)
-> m Int -> m (GBranch CombIx -> GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (GBranch CombIx -> GSection CombIx)
-> m (GBranch CombIx) -> m (GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GBranch CombIx)
forall (m :: * -> *). MonadGet m => m (GBranch CombIx)
getBranch
SectionT
RMatchT ->
Int
-> GSection CombIx
-> EnumMap Word64 (GBranch CombIx)
-> GSection CombIx
forall comb.
Int
-> GSection comb -> EnumMap Word64 (GBranch comb) -> GSection comb
RMatch (Int
-> GSection CombIx
-> EnumMap Word64 (GBranch CombIx)
-> GSection CombIx)
-> m Int
-> m (GSection CombIx
-> EnumMap Word64 (GBranch CombIx) -> GSection CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (GSection CombIx
-> EnumMap Word64 (GBranch CombIx) -> GSection CombIx)
-> m (GSection CombIx)
-> m (EnumMap Word64 (GBranch CombIx) -> GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection m (EnumMap Word64 (GBranch CombIx) -> GSection CombIx)
-> m (EnumMap Word64 (GBranch CombIx)) -> m (GSection CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Word64
-> m (GBranch CombIx) -> m (EnumMap Word64 (GBranch CombIx))
forall (m :: * -> *) k v.
(MonadGet m, EnumKey k) =>
m k -> m v -> m (EnumMap k v)
getEnumMap m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord m (GBranch CombIx)
forall (m :: * -> *). MonadGet m => m (GBranch CombIx)
getBranch
data InstrT
= UPrim1T
| UPrim2T
| BPrim1T
| BPrim2T
| ForeignCallT
| SetDynT
| CaptureT
| NameT
| InfoT
| PackT
| LitT
| PrintT
| ResetT
| ForkT
| AtomicallyT
| SeqT
| TryForceT
| RefCAST
| SandboxingFailureT
instance Tag InstrT where
tag2word :: InstrT -> Word8
tag2word InstrT
UPrim1T = Word8
0
tag2word InstrT
UPrim2T = Word8
1
tag2word InstrT
BPrim1T = Word8
2
tag2word InstrT
BPrim2T = Word8
3
tag2word InstrT
ForeignCallT = Word8
4
tag2word InstrT
SetDynT = Word8
5
tag2word InstrT
CaptureT = Word8
6
tag2word InstrT
NameT = Word8
7
tag2word InstrT
InfoT = Word8
8
tag2word InstrT
PackT = Word8
9
tag2word InstrT
LitT = Word8
10
tag2word InstrT
PrintT = Word8
11
tag2word InstrT
ResetT = Word8
12
tag2word InstrT
ForkT = Word8
13
tag2word InstrT
AtomicallyT = Word8
14
tag2word InstrT
SeqT = Word8
15
tag2word InstrT
TryForceT = Word8
16
tag2word InstrT
RefCAST = Word8
17
tag2word InstrT
SandboxingFailureT = Word8
18
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m InstrT
word2tag Word8
0 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
UPrim1T
word2tag Word8
1 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
UPrim2T
word2tag Word8
2 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
BPrim1T
word2tag Word8
3 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
BPrim2T
word2tag Word8
4 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
ForeignCallT
word2tag Word8
5 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
SetDynT
word2tag Word8
6 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
CaptureT
word2tag Word8
7 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
NameT
word2tag Word8
8 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
InfoT
word2tag Word8
9 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
PackT
word2tag Word8
10 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
LitT
word2tag Word8
11 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
PrintT
word2tag Word8
12 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
ResetT
word2tag Word8
13 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
ForkT
word2tag Word8
14 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
AtomicallyT
word2tag Word8
15 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
SeqT
word2tag Word8
16 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
TryForceT
word2tag Word8
17 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
RefCAST
word2tag Word8
18 = InstrT -> m InstrT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrT
SandboxingFailureT
word2tag Word8
n = String -> Word8 -> m InstrT
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"InstrT" Word8
n
putInstr :: (MonadPut m) => GInstr cix -> m ()
putInstr :: forall (m :: * -> *) cix. MonadPut m => GInstr cix -> m ()
putInstr = \case
(UPrim1 UPrim1
up Int
i) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
UPrim1T m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> UPrim1 -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag UPrim1
up m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
(UPrim2 UPrim2
up Int
i Int
j) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
UPrim2T m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> UPrim2 -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag UPrim2
up m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
j
(BPrim1 BPrim1
bp Int
i) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
BPrim1T m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> BPrim1 -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag BPrim1
bp m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
(BPrim2 BPrim2
bp Int
i Int
j) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
BPrim2T m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> BPrim2 -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag BPrim2
bp m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
j
(RefCAS Int
i Int
j Int
k) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
RefCAST m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
j m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
k
(ForeignCall Bool
b ForeignFunc
ff Args
a) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
ForeignCallT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Bool -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => Bool -> m ()
serialize Bool
b m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ForeignFunc -> m ()
forall (m :: * -> *). MonadPut m => ForeignFunc -> m ()
putMForeignFunc ForeignFunc
ff m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Args -> m ()
forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
a
(SetDyn Word64
w Int
i) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
SetDynT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
w m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
(Capture Word64
w) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
CaptureT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
w
(Name GRef cix
r Args
a) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
NameT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GRef cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GRef cix -> m ()
putRef GRef cix
r m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Args -> m ()
forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
a
(Info String
s) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
InfoT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> String -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => String -> m ()
serialize String
s
(Pack Reference
r PackedTag
w Args
a) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
PackT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Reference -> m ()
forall (m :: * -> *). MonadPut m => Reference -> m ()
putReference Reference
r m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> PackedTag -> m ()
forall (m :: * -> *). MonadPut m => PackedTag -> m ()
putPackedTag PackedTag
w m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Args -> m ()
forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
a
(Lit MLit
l) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
LitT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> MLit -> m ()
forall (m :: * -> *). MonadPut m => MLit -> m ()
putLit MLit
l
(Print Int
i) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
PrintT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
(Reset EnumSet Word64
s) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
ResetT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Word64 -> m ()) -> EnumSet Word64 -> m ()
forall (m :: * -> *) k.
(MonadPut m, EnumKey k) =>
(k -> m ()) -> EnumSet k -> m ()
putEnumSet Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord EnumSet Word64
s
(Fork Int
i) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
ForkT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
(Atomically Int
i) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
AtomicallyT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
(Seq Args
a) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
SeqT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Args -> m ()
forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
a
(TryForce Int
i) -> InstrT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag InstrT
TryForceT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
(SandboxingFailure {}) ->
String -> m ()
forall a. HasCallStack => String -> a
error String
"putInstr: Unexpected serialized Sandboxing Failure"
getInstr :: (MonadGet m) => m Instr
getInstr :: forall (m :: * -> *). MonadGet m => m (GInstr CombIx)
getInstr =
m InstrT
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m InstrT -> (InstrT -> m (GInstr CombIx)) -> m (GInstr CombIx)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
InstrT
UPrim1T -> UPrim1 -> Int -> GInstr CombIx
forall comb. UPrim1 -> Int -> GInstr comb
UPrim1 (UPrim1 -> Int -> GInstr CombIx)
-> m UPrim1 -> m (Int -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m UPrim1
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
UPrim2T -> UPrim2 -> Int -> Int -> GInstr CombIx
forall comb. UPrim2 -> Int -> Int -> GInstr comb
UPrim2 (UPrim2 -> Int -> Int -> GInstr CombIx)
-> m UPrim2 -> m (Int -> Int -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m UPrim2
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m (Int -> Int -> GInstr CombIx)
-> m Int -> m (Int -> GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
BPrim1T -> BPrim1 -> Int -> GInstr CombIx
forall comb. BPrim1 -> Int -> GInstr comb
BPrim1 (BPrim1 -> Int -> GInstr CombIx)
-> m BPrim1 -> m (Int -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m BPrim1
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
BPrim2T -> BPrim2 -> Int -> Int -> GInstr CombIx
forall comb. BPrim2 -> Int -> Int -> GInstr comb
BPrim2 (BPrim2 -> Int -> Int -> GInstr CombIx)
-> m BPrim2 -> m (Int -> Int -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m BPrim2
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m (Int -> Int -> GInstr CombIx)
-> m Int -> m (Int -> GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
RefCAST -> Int -> Int -> Int -> GInstr CombIx
forall comb. Int -> Int -> Int -> GInstr comb
RefCAS (Int -> Int -> Int -> GInstr CombIx)
-> m Int -> m (Int -> Int -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (Int -> Int -> GInstr CombIx)
-> m Int -> m (Int -> GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
ForeignCallT -> Bool -> ForeignFunc -> Args -> GInstr CombIx
forall comb. Bool -> ForeignFunc -> Args -> GInstr comb
ForeignCall (Bool -> ForeignFunc -> Args -> GInstr CombIx)
-> m Bool -> m (ForeignFunc -> Args -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Bool
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m Bool
deserialize m (ForeignFunc -> Args -> GInstr CombIx)
-> m ForeignFunc -> m (Args -> GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m ForeignFunc
forall (m :: * -> *). MonadGet m => m ForeignFunc
getMForeignFunc m (Args -> GInstr CombIx) -> m Args -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Args
forall (m :: * -> *). MonadGet m => m Args
getArgs
InstrT
SetDynT -> Word64 -> Int -> GInstr CombIx
forall comb. Word64 -> Int -> GInstr comb
SetDyn (Word64 -> Int -> GInstr CombIx)
-> m Word64 -> m (Int -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord m (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
CaptureT -> Word64 -> GInstr CombIx
forall comb. Word64 -> GInstr comb
Capture (Word64 -> GInstr CombIx) -> m Word64 -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord
InstrT
NameT -> GRef CombIx -> Args -> GInstr CombIx
forall comb. GRef comb -> Args -> GInstr comb
Name (GRef CombIx -> Args -> GInstr CombIx)
-> m (GRef CombIx) -> m (Args -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (GRef CombIx)
forall (m :: * -> *). MonadGet m => m (GRef CombIx)
getRef m (Args -> GInstr CombIx) -> m Args -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Args
forall (m :: * -> *). MonadGet m => m Args
getArgs
InstrT
InfoT -> String -> GInstr CombIx
forall comb. String -> GInstr comb
Info (String -> GInstr CombIx) -> m String -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m String
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m String
deserialize
InstrT
PackT -> Reference -> PackedTag -> Args -> GInstr CombIx
forall comb. Reference -> PackedTag -> Args -> GInstr comb
Pack (Reference -> PackedTag -> Args -> GInstr CombIx)
-> m Reference -> m (PackedTag -> Args -> GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Reference
forall (m :: * -> *). MonadGet m => m Reference
getReference m (PackedTag -> Args -> GInstr CombIx)
-> m PackedTag -> m (Args -> GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m PackedTag
forall (m :: * -> *). MonadGet m => m PackedTag
getPackedTag m (Args -> GInstr CombIx) -> m Args -> m (GInstr CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Args
forall (m :: * -> *). MonadGet m => m Args
getArgs
InstrT
LitT -> MLit -> GInstr CombIx
forall comb. MLit -> GInstr comb
Lit (MLit -> GInstr CombIx) -> m MLit -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m MLit
forall (m :: * -> *). MonadGet m => m MLit
getLit
InstrT
PrintT -> Int -> GInstr CombIx
forall comb. Int -> GInstr comb
Print (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
ResetT -> EnumSet Word64 -> GInstr CombIx
forall comb. EnumSet Word64 -> GInstr comb
Reset (EnumSet Word64 -> GInstr CombIx)
-> m (EnumSet Word64) -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word64 -> m (EnumSet Word64)
forall (m :: * -> *) k.
(MonadGet m, EnumKey k) =>
m k -> m (EnumSet k)
getEnumSet m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord
InstrT
ForkT -> Int -> GInstr CombIx
forall comb. Int -> GInstr comb
Fork (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
AtomicallyT -> Int -> GInstr CombIx
forall comb. Int -> GInstr comb
Atomically (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
SeqT -> Args -> GInstr CombIx
forall comb. Args -> GInstr comb
Seq (Args -> GInstr CombIx) -> m Args -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Args
forall (m :: * -> *). MonadGet m => m Args
getArgs
InstrT
TryForceT -> Int -> GInstr CombIx
forall comb. Int -> GInstr comb
TryForce (Int -> GInstr CombIx) -> m Int -> m (GInstr CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
InstrT
SandboxingFailureT -> String -> m (GInstr CombIx)
forall a. HasCallStack => String -> a
error String
"getInstr: Unexpected serialized Sandboxing Failure"
data ArgsT
= ZArgsT
| Arg1T
| Arg2T
| ArgRT
| ArgNT
| ArgVT
instance Tag ArgsT where
tag2word :: ArgsT -> Word8
tag2word ArgsT
ZArgsT = Word8
0
tag2word ArgsT
Arg1T = Word8
1
tag2word ArgsT
Arg2T = Word8
2
tag2word ArgsT
ArgRT = Word8
3
tag2word ArgsT
ArgNT = Word8
4
tag2word ArgsT
ArgVT = Word8
5
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m ArgsT
word2tag Word8
0 = ArgsT -> m ArgsT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ArgsT
ZArgsT
word2tag Word8
1 = ArgsT -> m ArgsT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ArgsT
Arg1T
word2tag Word8
2 = ArgsT -> m ArgsT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ArgsT
Arg2T
word2tag Word8
3 = ArgsT -> m ArgsT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ArgsT
ArgRT
word2tag Word8
4 = ArgsT -> m ArgsT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ArgsT
ArgNT
word2tag Word8
5 = ArgsT -> m ArgsT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ArgsT
ArgVT
word2tag Word8
n = String -> Word8 -> m ArgsT
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"ArgsT" Word8
n
putArgs :: (MonadPut m) => Args -> m ()
putArgs :: forall (m :: * -> *). MonadPut m => Args -> m ()
putArgs Args
ZArgs = ArgsT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag ArgsT
ZArgsT
putArgs (VArg1 Int
i) = ArgsT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag ArgsT
Arg1T m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
putArgs (VArg2 Int
i Int
j) = ArgsT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag ArgsT
Arg2T m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
j
putArgs (VArgR Int
i Int
j) = ArgsT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag ArgsT
ArgRT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
j
putArgs (VArgN PrimArray Int
pa) = ArgsT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag ArgsT
ArgNT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> PrimArray Int -> m ()
forall (m :: * -> *). MonadPut m => PrimArray Int -> m ()
putIntArr PrimArray Int
pa
putArgs (VArgV Int
i) = ArgsT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag ArgsT
ArgVT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
getArgs :: (MonadGet m) => m Args
getArgs :: forall (m :: * -> *). MonadGet m => m Args
getArgs =
m ArgsT
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m ArgsT -> (ArgsT -> m Args) -> m Args
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
ArgsT
ZArgsT -> Args -> m Args
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Args
ZArgs
ArgsT
Arg1T -> Int -> Args
VArg1 (Int -> Args) -> m Int -> m Args
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
ArgsT
Arg2T -> Int -> Int -> Args
VArg2 (Int -> Int -> Args) -> m Int -> m (Int -> Args)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (Int -> Args) -> m Int -> m Args
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
ArgsT
ArgRT -> Int -> Int -> Args
VArgR (Int -> Int -> Args) -> m Int -> m (Int -> Args)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt m (Int -> Args) -> m Int -> m Args
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
ArgsT
ArgNT -> PrimArray Int -> Args
VArgN (PrimArray Int -> Args) -> m (PrimArray Int) -> m Args
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (PrimArray Int)
forall (m :: * -> *). MonadGet m => m (PrimArray Int)
getIntArr
ArgsT
ArgVT -> Int -> Args
VArgV (Int -> Args) -> m Int -> m Args
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
data RefT = StkT | EnvT | DynT
instance Tag RefT where
tag2word :: RefT -> Word8
tag2word RefT
StkT = Word8
0
tag2word RefT
EnvT = Word8
1
tag2word RefT
DynT = Word8
2
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m RefT
word2tag Word8
0 = RefT -> m RefT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure RefT
StkT
word2tag Word8
1 = RefT -> m RefT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure RefT
EnvT
word2tag Word8
2 = RefT -> m RefT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure RefT
DynT
word2tag Word8
n = String -> Word8 -> m RefT
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"RefT" Word8
n
putRef :: (MonadPut m) => GRef cix -> m ()
putRef :: forall (m :: * -> *) cix. MonadPut m => GRef cix -> m ()
putRef (Stk Int
i) = RefT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag RefT
StkT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
putRef (Env CombIx
cix cix
_) = RefT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag RefT
EnvT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> CombIx -> m ()
forall (m :: * -> *). MonadPut m => CombIx -> m ()
putCombIx CombIx
cix
putRef (Dyn Word64
i) = RefT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag RefT
DynT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
i
getRef :: (MonadGet m) => m Ref
getRef :: forall (m :: * -> *). MonadGet m => m (GRef CombIx)
getRef =
m RefT
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m RefT -> (RefT -> m (GRef CombIx)) -> m (GRef CombIx)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
RefT
StkT -> Int -> GRef CombIx
forall comb. Int -> GRef comb
Stk (Int -> GRef CombIx) -> m Int -> m (GRef CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
RefT
EnvT -> do
CombIx
cix <- m CombIx
forall (m :: * -> *). MonadGet m => m CombIx
getCombIx
pure $ CombIx -> CombIx -> GRef CombIx
forall comb. CombIx -> comb -> GRef comb
Env CombIx
cix CombIx
cix
RefT
DynT -> Word64 -> GRef CombIx
forall comb. Word64 -> GRef comb
Dyn (Word64 -> GRef CombIx) -> m Word64 -> m (GRef CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord
putCombIx :: (MonadPut m) => CombIx -> m ()
putCombIx :: forall (m :: * -> *). MonadPut m => CombIx -> m ()
putCombIx (CIx Reference
r Word64
n Word64
i) = Reference -> m ()
forall (m :: * -> *). MonadPut m => Reference -> m ()
putReference Reference
r m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
n m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
i
getCombIx :: (MonadGet m) => m CombIx
getCombIx :: forall (m :: * -> *). MonadGet m => m CombIx
getCombIx = Reference -> Word64 -> Word64 -> CombIx
CIx (Reference -> Word64 -> Word64 -> CombIx)
-> m Reference -> m (Word64 -> Word64 -> CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Reference
forall (m :: * -> *). MonadGet m => m Reference
getReference m (Word64 -> Word64 -> CombIx) -> m Word64 -> m (Word64 -> CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord m (Word64 -> CombIx) -> m Word64 -> m CombIx
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord
data MLitT = MIT | MNT | MCT | MDT | MTT | MMT | MYT
instance Tag MLitT where
tag2word :: MLitT -> Word8
tag2word MLitT
MIT = Word8
0
tag2word MLitT
MNT = Word8
1
tag2word MLitT
MCT = Word8
2
tag2word MLitT
MDT = Word8
3
tag2word MLitT
MTT = Word8
4
tag2word MLitT
MMT = Word8
5
tag2word MLitT
MYT = Word8
6
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m MLitT
word2tag Word8
0 = MLitT -> m MLitT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MLitT
MIT
word2tag Word8
1 = MLitT -> m MLitT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MLitT
MNT
word2tag Word8
2 = MLitT -> m MLitT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MLitT
MCT
word2tag Word8
3 = MLitT -> m MLitT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MLitT
MDT
word2tag Word8
4 = MLitT -> m MLitT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MLitT
MTT
word2tag Word8
5 = MLitT -> m MLitT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MLitT
MMT
word2tag Word8
6 = MLitT -> m MLitT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MLitT
MYT
word2tag Word8
n = String -> Word8 -> m MLitT
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"MLitT" Word8
n
putLit :: (MonadPut m) => MLit -> m ()
putLit :: forall (m :: * -> *). MonadPut m => MLit -> m ()
putLit (MI Int
i) = MLitT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag MLitT
MIT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i
putLit (MN Word64
n) = MLitT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag MLitT
MNT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
n
putLit (MC Char
c) = MLitT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag MLitT
MCT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Char -> m ()
forall (m :: * -> *). MonadPut m => Char -> m ()
putChar Char
c
putLit (MD Double
d) = MLitT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag MLitT
MDT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Double -> m ()
forall (m :: * -> *). MonadPut m => Double -> m ()
putFloat Double
d
putLit (MT Text
t) = MLitT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag MLitT
MTT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Text -> m ()
forall (m :: * -> *). MonadPut m => Text -> m ()
putText (Text -> Text
Util.Text.toText Text
t)
putLit (MM Referent
r) = MLitT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag MLitT
MMT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Referent -> m ()
forall (m :: * -> *). MonadPut m => Referent -> m ()
putReferent Referent
r
putLit (MY Reference
r) = MLitT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag MLitT
MYT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Reference -> m ()
forall (m :: * -> *). MonadPut m => Reference -> m ()
putReference Reference
r
getLit :: (MonadGet m) => m MLit
getLit :: forall (m :: * -> *). MonadGet m => m MLit
getLit =
m MLitT
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m MLitT -> (MLitT -> m MLit) -> m MLit
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
MLitT
MIT -> Int -> MLit
MI (Int -> MLit) -> m Int -> m MLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int
forall (m :: * -> *). MonadGet m => m Int
gInt
MLitT
MNT -> Word64 -> MLit
MN (Word64 -> MLit) -> m Word64 -> m MLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord
MLitT
MCT -> Char -> MLit
MC (Char -> MLit) -> m Char -> m MLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Char
forall (m :: * -> *). MonadGet m => m Char
getChar
MLitT
MDT -> Double -> MLit
MD (Double -> MLit) -> m Double -> m MLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Double
forall (m :: * -> *). MonadGet m => m Double
getFloat
MLitT
MTT -> Text -> MLit
MT (Text -> MLit) -> (Text -> Text) -> Text -> MLit
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
Util.Text.fromText (Text -> MLit) -> m Text -> m MLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Text
forall (m :: * -> *). MonadGet m => m Text
getText
MLitT
MMT -> Referent -> MLit
MM (Referent -> MLit) -> m Referent -> m MLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Referent
forall (m :: * -> *). MonadGet m => m Referent
getReferent
MLitT
MYT -> Reference -> MLit
MY (Reference -> MLit) -> m Reference -> m MLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Reference
forall (m :: * -> *). MonadGet m => m Reference
getReference
data BranchT = Test1T | Test2T | TestWT | TestTT
instance Tag BranchT where
tag2word :: BranchT -> Word8
tag2word BranchT
Test1T = Word8
0
tag2word BranchT
Test2T = Word8
1
tag2word BranchT
TestWT = Word8
2
tag2word BranchT
TestTT = Word8
3
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m BranchT
word2tag Word8
0 = BranchT -> m BranchT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BranchT
Test1T
word2tag Word8
1 = BranchT -> m BranchT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BranchT
Test2T
word2tag Word8
2 = BranchT -> m BranchT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BranchT
TestWT
word2tag Word8
3 = BranchT -> m BranchT
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BranchT
TestTT
word2tag Word8
n = String -> Word8 -> m BranchT
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"BranchT" Word8
n
putBranch :: (MonadPut m) => GBranch cix -> m ()
putBranch :: forall (m :: * -> *) cix. MonadPut m => GBranch cix -> m ()
putBranch (Test1 Word64
w GSection cix
s GSection cix
d) =
BranchT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag BranchT
Test1T m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
w m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
s m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
d
putBranch (Test2 Word64
a GSection cix
sa Word64
b GSection cix
sb GSection cix
d) =
BranchT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag BranchT
Test2T
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
a
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
sa
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
b
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
sb
m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
d
putBranch (TestW GSection cix
d EnumMap Word64 (GSection cix)
m) =
BranchT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag BranchT
TestWT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
d m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Word64 -> m ())
-> (GSection cix -> m ()) -> EnumMap Word64 (GSection cix) -> m ()
forall (m :: * -> *) k v.
(MonadPut m, EnumKey k) =>
(k -> m ()) -> (v -> m ()) -> EnumMap k v -> m ()
putEnumMap Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection EnumMap Word64 (GSection cix)
m
putBranch (TestT GSection cix
d Map Text (GSection cix)
m) =
BranchT -> m ()
forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag BranchT
TestTT m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection GSection cix
d m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Text -> m ())
-> (GSection cix -> m ()) -> Map Text (GSection cix) -> m ()
forall (m :: * -> *) a b.
MonadPut m =>
(a -> m ()) -> (b -> m ()) -> Map a b -> m ()
putMap (Text -> m ()
forall (m :: * -> *). MonadPut m => Text -> m ()
putText (Text -> m ()) -> (Text -> Text) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
Util.Text.toText) GSection cix -> m ()
forall (m :: * -> *) cix. MonadPut m => GSection cix -> m ()
putSection Map Text (GSection cix)
m
getBranch :: (MonadGet m) => m Branch
getBranch :: forall (m :: * -> *). MonadGet m => m (GBranch CombIx)
getBranch =
m BranchT
forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag m BranchT -> (BranchT -> m (GBranch CombIx)) -> m (GBranch CombIx)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
BranchT
Test1T -> Word64 -> GSection CombIx -> GSection CombIx -> GBranch CombIx
forall comb.
Word64 -> GSection comb -> GSection comb -> GBranch comb
Test1 (Word64 -> GSection CombIx -> GSection CombIx -> GBranch CombIx)
-> m Word64
-> m (GSection CombIx -> GSection CombIx -> GBranch CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord m (GSection CombIx -> GSection CombIx -> GBranch CombIx)
-> m (GSection CombIx) -> m (GSection CombIx -> GBranch CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection m (GSection CombIx -> GBranch CombIx)
-> m (GSection CombIx) -> m (GBranch CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
BranchT
Test2T ->
Word64
-> GSection CombIx
-> Word64
-> GSection CombIx
-> GSection CombIx
-> GBranch CombIx
forall comb.
Word64
-> GSection comb
-> Word64
-> GSection comb
-> GSection comb
-> GBranch comb
Test2
(Word64
-> GSection CombIx
-> Word64
-> GSection CombIx
-> GSection CombIx
-> GBranch CombIx)
-> m Word64
-> m (GSection CombIx
-> Word64 -> GSection CombIx -> GSection CombIx -> GBranch CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord
m (GSection CombIx
-> Word64 -> GSection CombIx -> GSection CombIx -> GBranch CombIx)
-> m (GSection CombIx)
-> m (Word64
-> GSection CombIx -> GSection CombIx -> GBranch CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
m (Word64 -> GSection CombIx -> GSection CombIx -> GBranch CombIx)
-> m Word64
-> m (GSection CombIx -> GSection CombIx -> GBranch CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord
m (GSection CombIx -> GSection CombIx -> GBranch CombIx)
-> m (GSection CombIx) -> m (GSection CombIx -> GBranch CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
m (GSection CombIx -> GBranch CombIx)
-> m (GSection CombIx) -> m (GBranch CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
BranchT
TestWT -> GSection CombIx
-> EnumMap Word64 (GSection CombIx) -> GBranch CombIx
forall comb.
GSection comb -> EnumMap Word64 (GSection comb) -> GBranch comb
TestW (GSection CombIx
-> EnumMap Word64 (GSection CombIx) -> GBranch CombIx)
-> m (GSection CombIx)
-> m (EnumMap Word64 (GSection CombIx) -> GBranch CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection m (EnumMap Word64 (GSection CombIx) -> GBranch CombIx)
-> m (EnumMap Word64 (GSection CombIx)) -> m (GBranch CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Word64
-> m (GSection CombIx) -> m (EnumMap Word64 (GSection CombIx))
forall (m :: * -> *) k v.
(MonadGet m, EnumKey k) =>
m k -> m v -> m (EnumMap k v)
getEnumMap m Word64
forall (m :: * -> *). MonadGet m => m Word64
gWord m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
BranchT
TestTT -> GSection CombIx -> Map Text (GSection CombIx) -> GBranch CombIx
forall comb.
GSection comb -> Map Text (GSection comb) -> GBranch comb
TestT (GSection CombIx -> Map Text (GSection CombIx) -> GBranch CombIx)
-> m (GSection CombIx)
-> m (Map Text (GSection CombIx) -> GBranch CombIx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection m (Map Text (GSection CombIx) -> GBranch CombIx)
-> m (Map Text (GSection CombIx)) -> m (GBranch CombIx)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m Text -> m (GSection CombIx) -> m (Map Text (GSection CombIx))
forall (m :: * -> *) a b.
(MonadGet m, Ord a) =>
m a -> m b -> m (Map a b)
getMap (Text -> Text
Util.Text.fromText (Text -> Text) -> m Text -> m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Text
forall (m :: * -> *). MonadGet m => m Text
getText) m (GSection CombIx)
forall (m :: * -> *). MonadGet m => m (GSection CombIx)
getSection
gInt :: (MonadGet m) => m Int
gInt :: forall (m :: * -> *). MonadGet m => m Int
gInt = VarInt Int -> Int
forall n. VarInt n -> n
unVarInt (VarInt Int -> Int) -> m (VarInt Int) -> m Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (VarInt Int)
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m (VarInt Int)
deserialize
pInt :: (MonadPut m) => Int -> m ()
pInt :: forall (m :: * -> *). MonadPut m => Int -> m ()
pInt Int
i = VarInt Int -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => VarInt Int -> m ()
serialize (Int -> VarInt Int
forall n. n -> VarInt n
VarInt Int
i)
gWord :: (MonadGet m) => m Word64
gWord :: forall (m :: * -> *). MonadGet m => m Word64
gWord = VarInt Word64 -> Word64
forall n. VarInt n -> n
unVarInt (VarInt Word64 -> Word64) -> m (VarInt Word64) -> m Word64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (VarInt Word64)
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m (VarInt Word64)
deserialize
pWord :: (MonadPut m) => Word64 -> m ()
pWord :: forall (m :: * -> *). MonadPut m => Word64 -> m ()
pWord Word64
w = VarInt Word64 -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => VarInt Word64 -> m ()
serialize (Word64 -> VarInt Word64
forall n. n -> VarInt n
VarInt Word64
w)
putIntArr :: (MonadPut m) => PrimArray Int -> m ()
putIntArr :: forall (m :: * -> *). MonadPut m => PrimArray Int -> m ()
putIntArr PrimArray Int
pa = (Int -> m ()) -> [Int] -> m ()
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
putFoldable Int -> m ()
forall (m :: * -> *). MonadPut m => Int -> m ()
pInt ([Int] -> m ()) -> [Int] -> m ()
forall a b. (a -> b) -> a -> b
$ PrimArray Int -> [Item (PrimArray Int)]
forall l. IsList l => l -> [Item l]
toList PrimArray Int
pa
getIntArr :: (MonadGet m) => m (PrimArray Int)
getIntArr :: forall (m :: * -> *). MonadGet m => m (PrimArray Int)
getIntArr = [Int] -> PrimArray Int
[Item (PrimArray Int)] -> PrimArray Int
forall l. IsList l => [Item l] -> l
fromList ([Int] -> PrimArray Int) -> m [Int] -> m (PrimArray Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Int -> m [Int]
forall (m :: * -> *) a. MonadGet m => m a -> m [a]
getList m Int
forall (m :: * -> *). MonadGet m => m Int
gInt