{-# LANGUAGE PatternSynonyms #-}
module Unison.Runtime.Serialize where
import Control.Monad (replicateM)
import Data.Bits (Bits)
import Data.ByteString qualified as B
import Data.Bytes.Get hiding (getBytes)
import Data.Bytes.Get qualified as Ser
import Data.Bytes.Put
import Data.Bytes.Serial
import Data.Bytes.Signed (Unsigned)
import Data.Bytes.VarInt
import Data.Foldable (traverse_)
import Data.Int (Int64)
import Data.Map.Strict as Map (Map, fromList, toList)
import Data.Text (Text)
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Data.Vector.Primitive qualified as BA
import Data.Word (Word64, Word8)
import GHC.Exts as IL (IsList (..))
import Unison.ConstructorReference (ConstructorReference, GConstructorReference (..))
import Unison.ConstructorType qualified as CT
import Unison.Hash (Hash)
import Unison.Hash qualified as Hash
import Unison.Reference (Id' (..), Reference, Reference' (Builtin, DerivedId), pattern Derived)
import Unison.Referent (Referent, pattern Con, pattern Ref)
import Unison.Runtime.Array qualified as PA
import Unison.Runtime.Exception
import Unison.Runtime.MCode
( BPrim1 (..),
BPrim2 (..),
UPrim1 (..),
UPrim2 (..),
)
import Unison.Util.Bytes qualified as Bytes
import Unison.Util.EnumContainers as EC
unknownTag :: (MonadGet m) => String -> Word8 -> m a
unknownTag :: forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
t Word8
w =
m (Remaining m)
forall (m :: * -> *). MonadGet m => m (Remaining m)
remaining m (Remaining m) -> (Remaining m -> m a) -> m a
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Remaining m
r ->
String -> m a
forall a. HasCallStack => String -> a
exn (String -> m a) -> String -> m a
forall a b. (a -> b) -> a -> b
$
String
"unknown "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
t
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" word: "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Word8 -> String
forall a. Show a => a -> String
show Word8
w
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" ("
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (forall a b. (Integral a, Num b) => a -> b
fromIntegral @_ @Int Remaining m
r)
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" bytes remaining)"
class Tag t where
tag2word :: t -> Word8
word2tag :: (MonadGet m) => Word8 -> m t
putTag :: (MonadPut m) => (Tag t) => t -> m ()
putTag :: forall (m :: * -> *) t. (MonadPut m, Tag t) => t -> m ()
putTag = Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 (Word8 -> m ()) -> (t -> Word8) -> t -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> Word8
forall t. Tag t => t -> Word8
tag2word
getTag :: (MonadGet m) => (Tag t) => m t
getTag :: forall (m :: * -> *) t. (MonadGet m, Tag t) => m t
getTag = Word8 -> m t
forall t (m :: * -> *). (Tag t, MonadGet m) => Word8 -> m t
forall (m :: * -> *). MonadGet m => Word8 -> m t
word2tag (Word8 -> m t) -> m Word8 -> m t
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< m Word8
forall (m :: * -> *). MonadGet m => m Word8
getWord8
putChar :: (MonadPut m) => Char -> m ()
putChar :: forall (m :: * -> *). MonadPut m => Char -> m ()
putChar = VarInt Int -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => VarInt Int -> m ()
serialize (VarInt Int -> m ()) -> (Char -> VarInt Int) -> Char -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> VarInt Int
forall n. n -> VarInt n
VarInt (Int -> VarInt Int) -> (Char -> Int) -> Char -> VarInt Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
forall a. Enum a => a -> Int
fromEnum
getChar :: (MonadGet m) => m Char
getChar :: forall (m :: * -> *). MonadGet m => m Char
getChar = Int -> Char
forall a. Enum a => Int -> a
toEnum (Int -> Char) -> (VarInt Int -> Int) -> VarInt Int -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VarInt Int -> Int
forall n. VarInt n -> n
unVarInt (VarInt Int -> Char) -> m (VarInt Int) -> m Char
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
putFloat :: (MonadPut m) => Double -> m ()
putFloat :: forall (m :: * -> *). MonadPut m => Double -> m ()
putFloat = Double -> m ()
forall a (m :: * -> *). (SerialEndian a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => Double -> m ()
serializeBE
getFloat :: (MonadGet m) => m Double
getFloat :: forall (m :: * -> *). MonadGet m => m Double
getFloat = m Double
forall a (m :: * -> *). (SerialEndian a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m Double
deserializeBE
putBool :: (MonadPut m) => Bool -> m ()
putBool :: forall (m :: * -> *). MonadPut m => Bool -> m ()
putBool Bool
b = Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 (if Bool
b then Word8
1 else Word8
0)
getBool :: (MonadGet m) => m Bool
getBool :: forall (m :: * -> *). MonadGet m => m Bool
getBool = Word8 -> m Bool
forall {a} {f :: * -> *}.
(Eq a, Num a, Applicative f, Show a) =>
a -> f Bool
d (Word8 -> m Bool) -> m Word8 -> m Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< m Word8
forall (m :: * -> *). MonadGet m => m Word8
getWord8
where
d :: a -> f Bool
d a
0 = Bool -> f Bool
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False
d a
1 = Bool -> f Bool
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
True
d a
n = String -> f Bool
forall a. HasCallStack => String -> a
exn (String -> f Bool) -> String -> f Bool
forall a b. (a -> b) -> a -> b
$ String
"getBool: bad tag: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
n
putNat :: (MonadPut m) => Word64 -> m ()
putNat :: forall (m :: * -> *). MonadPut m => Word64 -> m ()
putNat = Word64 -> m ()
forall (m :: * -> *). MonadPut m => Word64 -> m ()
putWord64be
getNat :: (MonadGet m) => m Word64
getNat :: forall (m :: * -> *). MonadGet m => m Word64
getNat = m Word64
forall (m :: * -> *). MonadGet m => m Word64
getWord64be
putInt :: (MonadPut m) => Int64 -> m ()
putInt :: forall (m :: * -> *). MonadPut m => Int64 -> m ()
putInt = Int64 -> m ()
forall a (m :: * -> *). (SerialEndian a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => Int64 -> m ()
serializeBE
getInt :: (MonadGet m) => m Int64
getInt :: forall (m :: * -> *). MonadGet m => m Int64
getInt = m Int64
forall a (m :: * -> *). (SerialEndian a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m Int64
deserializeBE
putLength ::
( MonadPut m,
Integral n,
Integral (Unsigned n),
Bits n,
Bits (Unsigned n)
) =>
n ->
m ()
putLength :: forall (m :: * -> *) n.
(MonadPut m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
n -> m ()
putLength = VarInt n -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => VarInt n -> m ()
serialize (VarInt n -> m ()) -> (n -> VarInt n) -> n -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. n -> VarInt n
forall n. n -> VarInt n
VarInt
getLength ::
( MonadGet m,
Integral n,
Integral (Unsigned n),
Bits n,
Bits (Unsigned n)
) =>
m n
getLength :: forall (m :: * -> *) n.
(MonadGet m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
m n
getLength = VarInt n -> n
forall n. VarInt n -> n
unVarInt (VarInt n -> n) -> m (VarInt n) -> m n
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (VarInt n)
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m (VarInt n)
deserialize
putPositive ::
(MonadPut m, Bits n, Bits (Unsigned n), Integral n, Integral (Unsigned n)) =>
n ->
m ()
putPositive :: forall (m :: * -> *) n.
(MonadPut m, Bits n, Bits (Unsigned n), Integral n,
Integral (Unsigned n)) =>
n -> m ()
putPositive n
n
| n
n n -> n -> Bool
forall a. Ord a => a -> a -> Bool
< n
0 = String -> m ()
forall a. HasCallStack => String -> a
exn (String -> m ()) -> String -> m ()
forall a b. (a -> b) -> a -> b
$ String
"putPositive: negative number: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show (n -> Integer
forall a. Integral a => a -> Integer
toInteger n
n)
| Bool
otherwise = VarInt n -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
forall (m :: * -> *). MonadPut m => VarInt n -> m ()
serialize (n -> VarInt n
forall n. n -> VarInt n
VarInt n
n)
getPositive :: forall m n. (Bounded n, Integral n, MonadGet m) => m n
getPositive :: forall (m :: * -> *) n. (Bounded n, Integral n, MonadGet m) => m n
getPositive = Integer -> m n
validate (Integer -> m n)
-> (VarInt Integer -> Integer) -> VarInt Integer -> m n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VarInt Integer -> Integer
forall n. VarInt n -> n
unVarInt (VarInt Integer -> m n) -> m (VarInt Integer) -> m n
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< m (VarInt Integer)
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
forall (m :: * -> *). MonadGet m => m (VarInt Integer)
deserialize
where
mx0 :: n
mx0 :: n
mx0 = n
forall a. Bounded a => a
maxBound
mx :: Integer
mx :: Integer
mx = n -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral n
mx0
validate :: Integer -> m n
validate :: Integer -> m n
validate Integer
n
| Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Integer
mx = n -> m n
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (n -> m n) -> n -> m n
forall a b. (a -> b) -> a -> b
$ Integer -> n
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
n
| Bool
otherwise = String -> m n
forall a. String -> m a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> m n) -> String -> m n
forall a b. (a -> b) -> a -> b
$ String
"getPositive: overflow: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
n
putFoldable ::
(Foldable f, MonadPut m) => (a -> m ()) -> f a -> m ()
putFoldable :: forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
putFoldable a -> m ()
putA f a
as = do
Int -> m ()
forall (m :: * -> *) n.
(MonadPut m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
n -> m ()
putLength (f a -> Int
forall a. f a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length f a
as)
(a -> m ()) -> f a -> m ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ a -> m ()
putA f a
as
putMap :: (MonadPut m) => (a -> m ()) -> (b -> m ()) -> Map a b -> m ()
putMap :: forall (m :: * -> *) a b.
MonadPut m =>
(a -> m ()) -> (b -> m ()) -> Map a b -> m ()
putMap a -> m ()
putA b -> m ()
putB Map a b
m = ((a, b) -> m ()) -> [(a, b)] -> m ()
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
putFoldable ((a -> m ()) -> (b -> m ()) -> (a, b) -> m ()
forall (m :: * -> *) a b.
MonadPut m =>
(a -> m ()) -> (b -> m ()) -> (a, b) -> m ()
putPair a -> m ()
putA b -> m ()
putB) (Map a b -> [(a, b)]
forall k a. Map k a -> [(k, a)]
Map.toList Map a b
m)
getList :: (MonadGet m) => m a -> m [a]
getList :: forall (m :: * -> *) a. MonadGet m => m a -> m [a]
getList m a
a = m Int
forall (m :: * -> *) n.
(MonadGet m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
m n
getLength m Int -> (Int -> m [a]) -> m [a]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Int -> m a -> m [a]
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
`replicateM` m a
a)
getMap :: (MonadGet m, Ord a) => m a -> m b -> m (Map a b)
getMap :: forall (m :: * -> *) a b.
(MonadGet m, Ord a) =>
m a -> m b -> m (Map a b)
getMap m a
getA m b
getB = [(a, b)] -> Map a b
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(a, b)] -> Map a b) -> m [(a, b)] -> m (Map a b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, b) -> m [(a, b)]
forall (m :: * -> *) a. MonadGet m => m a -> m [a]
getList (m a -> m b -> m (a, b)
forall (m :: * -> *) a b. MonadGet m => m a -> m b -> m (a, b)
getPair m a
getA m b
getB)
putEnumMap ::
(MonadPut m) =>
(EnumKey k) =>
(k -> m ()) ->
(v -> m ()) ->
EnumMap k v ->
m ()
putEnumMap :: forall (m :: * -> *) k v.
(MonadPut m, EnumKey k) =>
(k -> m ()) -> (v -> m ()) -> EnumMap k v -> m ()
putEnumMap k -> m ()
pk v -> m ()
pv EnumMap k v
m = ((k, v) -> m ()) -> [(k, v)] -> m ()
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
putFoldable ((k -> m ()) -> (v -> m ()) -> (k, v) -> m ()
forall (m :: * -> *) a b.
MonadPut m =>
(a -> m ()) -> (b -> m ()) -> (a, b) -> m ()
putPair k -> m ()
pk v -> m ()
pv) (EnumMap k v -> [(k, v)]
forall k a. EnumKey k => EnumMap k a -> [(k, a)]
mapToList EnumMap k v
m)
getEnumMap :: (MonadGet m) => (EnumKey k) => m k -> m v -> m (EnumMap k v)
getEnumMap :: forall (m :: * -> *) k v.
(MonadGet m, EnumKey k) =>
m k -> m v -> m (EnumMap k v)
getEnumMap m k
gk m v
gv = [(k, v)] -> EnumMap k v
forall k a. EnumKey k => [(k, a)] -> EnumMap k a
mapFromList ([(k, v)] -> EnumMap k v) -> m [(k, v)] -> m (EnumMap k v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (k, v) -> m [(k, v)]
forall (m :: * -> *) a. MonadGet m => m a -> m [a]
getList (m k -> m v -> m (k, v)
forall (m :: * -> *) a b. MonadGet m => m a -> m b -> m (a, b)
getPair m k
gk m v
gv)
putEnumSet :: (MonadPut m) => (EnumKey k) => (k -> m ()) -> EnumSet k -> m ()
putEnumSet :: forall (m :: * -> *) k.
(MonadPut m, EnumKey k) =>
(k -> m ()) -> EnumSet k -> m ()
putEnumSet k -> m ()
pk EnumSet k
s = Int -> m ()
forall (m :: * -> *) n.
(MonadPut m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
n -> m ()
putLength (EnumSet k -> Int
forall k. EnumSet k -> Int
setSize EnumSet k
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
*> (k -> m ()) -> EnumSet k -> m ()
forall (f :: * -> *) k.
(Applicative f, EnumKey k) =>
(k -> f ()) -> EnumSet k -> f ()
traverseSet_ k -> m ()
pk EnumSet k
s
getEnumSet :: (MonadGet m) => (EnumKey k) => m k -> m (EnumSet k)
getEnumSet :: forall (m :: * -> *) k.
(MonadGet m, EnumKey k) =>
m k -> m (EnumSet k)
getEnumSet m k
gk = [k] -> EnumSet k
forall k. EnumKey k => [k] -> EnumSet k
setFromList ([k] -> EnumSet k) -> m [k] -> m (EnumSet k)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m k -> m [k]
forall (m :: * -> *) a. MonadGet m => m a -> m [a]
getList m k
gk
putMaybe :: (MonadPut m) => Maybe a -> (a -> m ()) -> m ()
putMaybe :: forall (m :: * -> *) a.
MonadPut m =>
Maybe a -> (a -> m ()) -> m ()
putMaybe Maybe a
Nothing a -> m ()
_ = Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 Word8
0
putMaybe (Just a
a) a -> m ()
putA = Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 Word8
1 m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> a -> m ()
putA a
a
getMaybe :: (MonadGet m) => m a -> m (Maybe a)
getMaybe :: forall (m :: * -> *) a. MonadGet m => m a -> m (Maybe a)
getMaybe m a
getA =
m Word8
forall (m :: * -> *). MonadGet m => m Word8
getWord8 m Word8 -> (Word8 -> m (Maybe a)) -> m (Maybe a)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Word8
tag -> case Word8
tag of
Word8
0 -> Maybe a -> m (Maybe a)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe a
forall a. Maybe a
Nothing
Word8
1 -> a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> m a -> m (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
getA
Word8
_ -> String -> Word8 -> m (Maybe a)
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"Maybe" Word8
tag
putPair :: (MonadPut m) => (a -> m ()) -> (b -> m ()) -> (a, b) -> m ()
putPair :: forall (m :: * -> *) a b.
MonadPut m =>
(a -> m ()) -> (b -> m ()) -> (a, b) -> m ()
putPair a -> m ()
putA b -> m ()
putB (a
a, b
b) = a -> m ()
putA a
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
*> b -> m ()
putB b
b
getPair :: (MonadGet m) => m a -> m b -> m (a, b)
getPair :: forall (m :: * -> *) a b. MonadGet m => m a -> m b -> m (a, b)
getPair = (a -> b -> (a, b)) -> m a -> m b -> m (a, b)
forall a b c. (a -> b -> c) -> m a -> m b -> m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (,)
getBytes :: (MonadGet m) => m Bytes.Bytes
getBytes :: forall (m :: * -> *). MonadGet m => m Bytes
getBytes = [Chunk] -> Bytes
Bytes.fromChunks ([Chunk] -> Bytes) -> m [Chunk] -> m Bytes
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Chunk -> m [Chunk]
forall (m :: * -> *) a. MonadGet m => m a -> m [a]
getList m Chunk
forall (m :: * -> *). MonadGet m => m Chunk
getBlock
putBytes :: (MonadPut m) => Bytes.Bytes -> m ()
putBytes :: forall (m :: * -> *). MonadPut m => Bytes -> m ()
putBytes = (Chunk -> m ()) -> [Chunk] -> m ()
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
putFoldable Chunk -> m ()
forall (m :: * -> *). MonadPut m => Chunk -> m ()
putBlock ([Chunk] -> m ()) -> (Bytes -> [Chunk]) -> Bytes -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bytes -> [Chunk]
Bytes.chunks
getByteArray :: (MonadGet m) => m PA.ByteArray
getByteArray :: forall (m :: * -> *). MonadGet m => m ByteArray
getByteArray = [Word8] -> ByteArray
forall a. Prim a => [a] -> ByteArray
PA.byteArrayFromList ([Word8] -> ByteArray) -> m [Word8] -> m ByteArray
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Word8 -> m [Word8]
forall (m :: * -> *) a. MonadGet m => m a -> m [a]
getList m Word8
forall (m :: * -> *). MonadGet m => m Word8
getWord8
putByteArray :: (MonadPut m) => PA.ByteArray -> m ()
putByteArray :: forall (m :: * -> *). MonadPut m => ByteArray -> m ()
putByteArray ByteArray
a = (Word8 -> m ()) -> [Word8] -> m ()
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
putFoldable Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 (ByteArray -> [Item ByteArray]
forall l. IsList l => l -> [Item l]
IL.toList ByteArray
a)
getArray :: (MonadGet m) => m a -> m (PA.Array a)
getArray :: forall (m :: * -> *) a. MonadGet m => m a -> m (Array a)
getArray m a
getThing = [a] -> Array a
forall a. [a] -> Array a
PA.arrayFromList ([a] -> Array a) -> m [a] -> m (Array a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m [a]
forall (m :: * -> *) a. MonadGet m => m a -> m [a]
getList m a
getThing
putArray :: (MonadPut m) => (a -> m ()) -> PA.Array a -> m ()
putArray :: forall (m :: * -> *) a.
MonadPut m =>
(a -> m ()) -> Array a -> m ()
putArray a -> m ()
putThing Array a
a = (a -> m ()) -> [a] -> m ()
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
putFoldable a -> m ()
putThing (Array a -> [Item (Array a)]
forall l. IsList l => l -> [Item l]
IL.toList Array a
a)
getBlock :: (MonadGet m) => m Bytes.Chunk
getBlock :: forall (m :: * -> *). MonadGet m => m Chunk
getBlock = m Int
forall (m :: * -> *) n.
(MonadGet m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
m n
getLength m Int -> (Int -> m Chunk) -> m Chunk
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ByteString -> Chunk) -> m ByteString -> m Chunk
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Chunk
Bytes.byteStringToChunk (m ByteString -> m Chunk)
-> (Int -> m ByteString) -> Int -> m Chunk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m ByteString
forall (m :: * -> *). MonadGet m => Int -> m ByteString
getByteString
putBlock :: (MonadPut m) => Bytes.Chunk -> m ()
putBlock :: forall (m :: * -> *). MonadPut m => Chunk -> m ()
putBlock Chunk
b = Int -> m ()
forall (m :: * -> *) n.
(MonadPut m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
n -> m ()
putLength (Chunk -> Int
forall a. Prim a => Vector a -> Int
BA.length Chunk
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
*> ByteString -> m ()
forall (m :: * -> *). MonadPut m => ByteString -> m ()
putByteString (Chunk -> ByteString
Bytes.chunkToByteString Chunk
b)
putHash :: (MonadPut m) => Hash -> m ()
putHash :: forall (m :: * -> *). MonadPut m => Hash -> m ()
putHash Hash
h = do
let bs :: ByteString
bs = Hash -> ByteString
Hash.toByteString Hash
h
Int -> m ()
forall (m :: * -> *) n.
(MonadPut m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
n -> m ()
putLength (ByteString -> Int
B.length ByteString
bs)
ByteString -> m ()
forall (m :: * -> *). MonadPut m => ByteString -> m ()
putByteString ByteString
bs
getHash :: (MonadGet m) => m Hash
getHash :: forall (m :: * -> *). MonadGet m => m Hash
getHash = do
Int
len <- m Int
forall (m :: * -> *) n.
(MonadGet m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
m n
getLength
ByteString
bs <- ByteString -> ByteString
B.copy (ByteString -> ByteString) -> m ByteString -> m ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> m ByteString
forall (m :: * -> *). MonadGet m => Int -> m ByteString
Ser.getBytes Int
len
pure $ ByteString -> Hash
Hash.fromByteString ByteString
bs
putReferent :: (MonadPut m) => Referent -> m ()
putReferent :: forall (m :: * -> *). MonadPut m => Referent -> m ()
putReferent = \case
Ref TermReference
r -> do
Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 Word8
0
TermReference -> m ()
forall (m :: * -> *). MonadPut m => TermReference -> m ()
putReference TermReference
r
Con ConstructorReference
r ConstructorType
ct -> do
Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 Word8
1
ConstructorReference -> m ()
forall (m :: * -> *). MonadPut m => ConstructorReference -> m ()
putConstructorReference ConstructorReference
r
ConstructorType -> m ()
forall (m :: * -> *). MonadPut m => ConstructorType -> m ()
putConstructorType ConstructorType
ct
getReferent :: (MonadGet m) => m Referent
getReferent :: forall (m :: * -> *). MonadGet m => m Referent
getReferent = do
Word8
tag <- m Word8
forall (m :: * -> *). MonadGet m => m Word8
getWord8
case Word8
tag of
Word8
0 -> TermReference -> Referent
Ref (TermReference -> Referent) -> m TermReference -> m Referent
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m TermReference
forall (m :: * -> *). MonadGet m => m TermReference
getReference
Word8
1 -> ConstructorReference -> ConstructorType -> Referent
Con (ConstructorReference -> ConstructorType -> Referent)
-> m ConstructorReference -> m (ConstructorType -> Referent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m ConstructorReference
forall (m :: * -> *). MonadGet m => m ConstructorReference
getConstructorReference m (ConstructorType -> Referent) -> m ConstructorType -> m Referent
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m ConstructorType
forall (m :: * -> *). MonadGet m => m ConstructorType
getConstructorType
Word8
_ -> String -> Word8 -> m Referent
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"getReferent" Word8
tag
getConstructorType :: (MonadGet m) => m CT.ConstructorType
getConstructorType :: forall (m :: * -> *). MonadGet m => m ConstructorType
getConstructorType =
m Word8
forall (m :: * -> *). MonadGet m => m Word8
getWord8 m Word8 -> (Word8 -> m ConstructorType) -> m ConstructorType
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Word8
0 -> ConstructorType -> m ConstructorType
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ConstructorType
CT.Data
Word8
1 -> ConstructorType -> m ConstructorType
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ConstructorType
CT.Effect
Word8
t -> String -> Word8 -> m ConstructorType
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"getConstructorType" Word8
t
putConstructorType :: (MonadPut m) => CT.ConstructorType -> m ()
putConstructorType :: forall (m :: * -> *). MonadPut m => ConstructorType -> m ()
putConstructorType = \case
ConstructorType
CT.Data -> Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 Word8
0
ConstructorType
CT.Effect -> Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 Word8
1
putText :: (MonadPut m) => Text -> m ()
putText :: forall (m :: * -> *). MonadPut m => Text -> m ()
putText Text
text = do
let bs :: ByteString
bs = Text -> ByteString
encodeUtf8 Text
text
Int -> m ()
forall (m :: * -> *) n.
(MonadPut m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
n -> m ()
putLength (Int -> m ()) -> Int -> m ()
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
bs
ByteString -> m ()
forall (m :: * -> *). MonadPut m => ByteString -> m ()
putByteString ByteString
bs
getText :: (MonadGet m) => m Text
getText :: forall (m :: * -> *). MonadGet m => m Text
getText = do
Int
len <- m Int
forall (m :: * -> *) n.
(MonadGet m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
m n
getLength
ByteString
bs <- ByteString -> ByteString
B.copy (ByteString -> ByteString) -> m ByteString -> m ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> m ByteString
forall (m :: * -> *). MonadGet m => Int -> m ByteString
Ser.getBytes Int
len
pure $ ByteString -> Text
decodeUtf8 ByteString
bs
putReference :: (MonadPut m) => Reference -> m ()
putReference :: forall (m :: * -> *). MonadPut m => TermReference -> m ()
putReference TermReference
r = case TermReference
r of
Builtin Text
name -> do
Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 Word8
0
Text -> m ()
forall (m :: * -> *). MonadPut m => Text -> m ()
putText Text
name
Derived Hash
hash Word64
i -> do
Word8 -> m ()
forall (m :: * -> *). MonadPut m => Word8 -> m ()
putWord8 Word8
1
Hash -> m ()
forall (m :: * -> *). MonadPut m => Hash -> m ()
putHash Hash
hash
Word64 -> m ()
forall (m :: * -> *) n.
(MonadPut m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
n -> m ()
putLength Word64
i
getReference :: (MonadGet m) => m Reference
getReference :: forall (m :: * -> *). MonadGet m => m TermReference
getReference = do
Word8
tag <- m Word8
forall (m :: * -> *). MonadGet m => m Word8
getWord8
case Word8
tag of
Word8
0 -> Text -> TermReference
forall t h. t -> Reference' t h
Builtin (Text -> TermReference) -> m Text -> m TermReference
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Text
forall (m :: * -> *). MonadGet m => m Text
getText
Word8
1 -> Id' Hash -> TermReference
forall h t. Id' h -> Reference' t h
DerivedId (Id' Hash -> TermReference) -> m (Id' Hash) -> m TermReference
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Hash -> Word64 -> Id' Hash
forall h. h -> Word64 -> Id' h
Id (Hash -> Word64 -> Id' Hash) -> m Hash -> m (Word64 -> Id' Hash)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Hash
forall (m :: * -> *). MonadGet m => m Hash
getHash m (Word64 -> Id' Hash) -> m Word64 -> m (Id' Hash)
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 :: * -> *) n.
(MonadGet m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
m n
getLength)
Word8
_ -> String -> Word8 -> m TermReference
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"Reference" Word8
tag
putConstructorReference :: (MonadPut m) => ConstructorReference -> m ()
putConstructorReference :: forall (m :: * -> *). MonadPut m => ConstructorReference -> m ()
putConstructorReference (ConstructorReference TermReference
r Word64
i) = do
TermReference -> m ()
forall (m :: * -> *). MonadPut m => TermReference -> m ()
putReference TermReference
r
Word64 -> m ()
forall (m :: * -> *) n.
(MonadPut m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
n -> m ()
putLength Word64
i
getConstructorReference :: (MonadGet m) => m ConstructorReference
getConstructorReference :: forall (m :: * -> *). MonadGet m => m ConstructorReference
getConstructorReference =
TermReference -> Word64 -> ConstructorReference
forall r. r -> Word64 -> GConstructorReference r
ConstructorReference (TermReference -> Word64 -> ConstructorReference)
-> m TermReference -> m (Word64 -> ConstructorReference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m TermReference
forall (m :: * -> *). MonadGet m => m TermReference
getReference m (Word64 -> ConstructorReference)
-> m Word64 -> m ConstructorReference
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 :: * -> *) n.
(MonadGet m, Integral n, Integral (Unsigned n), Bits n,
Bits (Unsigned n)) =>
m n
getLength
instance Tag UPrim1 where
tag2word :: UPrim1 -> Word8
tag2word UPrim1
DECI = Word8
0
tag2word UPrim1
DECN = Word8
1
tag2word UPrim1
INCI = Word8
2
tag2word UPrim1
INCN = Word8
3
tag2word UPrim1
NEGI = Word8
4
tag2word UPrim1
SGNI = Word8
5
tag2word UPrim1
LZRO = Word8
6
tag2word UPrim1
TZRO = Word8
7
tag2word UPrim1
COMN = Word8
8
tag2word UPrim1
COMI = Word8
9
tag2word UPrim1
POPC = Word8
10
tag2word UPrim1
ABSF = Word8
11
tag2word UPrim1
EXPF = Word8
12
tag2word UPrim1
LOGF = Word8
13
tag2word UPrim1
SQRT = Word8
14
tag2word UPrim1
COSF = Word8
15
tag2word UPrim1
ACOS = Word8
16
tag2word UPrim1
COSH = Word8
17
tag2word UPrim1
ACSH = Word8
18
tag2word UPrim1
SINF = Word8
19
tag2word UPrim1
ASIN = Word8
20
tag2word UPrim1
SINH = Word8
21
tag2word UPrim1
ASNH = Word8
22
tag2word UPrim1
TANF = Word8
23
tag2word UPrim1
ATAN = Word8
24
tag2word UPrim1
TANH = Word8
25
tag2word UPrim1
ATNH = Word8
26
tag2word UPrim1
ITOF = Word8
27
tag2word UPrim1
NTOF = Word8
28
tag2word UPrim1
CEIL = Word8
29
tag2word UPrim1
FLOR = Word8
30
tag2word UPrim1
TRNF = Word8
31
tag2word UPrim1
RNDF = Word8
32
tag2word UPrim1
TRNC = Word8
33
tag2word UPrim1
NOTB = Word8
34
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m UPrim1
word2tag Word8
0 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
DECI
word2tag Word8
1 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
DECN
word2tag Word8
2 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
INCI
word2tag Word8
3 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
INCN
word2tag Word8
4 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
NEGI
word2tag Word8
5 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
SGNI
word2tag Word8
6 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
LZRO
word2tag Word8
7 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
TZRO
word2tag Word8
8 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
COMN
word2tag Word8
9 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
COMI
word2tag Word8
10 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
POPC
word2tag Word8
11 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
ABSF
word2tag Word8
12 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
EXPF
word2tag Word8
13 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
LOGF
word2tag Word8
14 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
SQRT
word2tag Word8
15 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
COSF
word2tag Word8
16 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
ACOS
word2tag Word8
17 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
COSH
word2tag Word8
18 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
ACSH
word2tag Word8
19 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
SINF
word2tag Word8
20 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
ASIN
word2tag Word8
21 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
SINH
word2tag Word8
22 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
ASNH
word2tag Word8
23 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
TANF
word2tag Word8
24 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
ATAN
word2tag Word8
25 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
TANH
word2tag Word8
26 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
ATNH
word2tag Word8
27 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
ITOF
word2tag Word8
28 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
NTOF
word2tag Word8
29 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
CEIL
word2tag Word8
30 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
FLOR
word2tag Word8
31 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
TRNF
word2tag Word8
32 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
RNDF
word2tag Word8
33 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
TRNC
word2tag Word8
34 = UPrim1 -> m UPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim1
NOTB
word2tag Word8
n = String -> Word8 -> m UPrim1
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"UPrim1" Word8
n
instance Tag UPrim2 where
tag2word :: UPrim2 -> Word8
tag2word UPrim2
ADDI = Word8
0
tag2word UPrim2
ADDN = Word8
1
tag2word UPrim2
SUBI = Word8
2
tag2word UPrim2
SUBN = Word8
3
tag2word UPrim2
MULI = Word8
4
tag2word UPrim2
MULN = Word8
5
tag2word UPrim2
DIVI = Word8
6
tag2word UPrim2
MODI = Word8
7
tag2word UPrim2
DIVN = Word8
8
tag2word UPrim2
MODN = Word8
9
tag2word UPrim2
SHLI = Word8
10
tag2word UPrim2
SHLN = Word8
11
tag2word UPrim2
SHRI = Word8
12
tag2word UPrim2
SHRN = Word8
13
tag2word UPrim2
POWI = Word8
14
tag2word UPrim2
POWN = Word8
15
tag2word UPrim2
EQLI = Word8
16
tag2word UPrim2
NEQI = Word8
17
tag2word UPrim2
EQLN = Word8
18
tag2word UPrim2
NEQN = Word8
19
tag2word UPrim2
LEQI = Word8
20
tag2word UPrim2
LEQN = Word8
21
tag2word UPrim2
LESI = Word8
22
tag2word UPrim2
LESN = Word8
23
tag2word UPrim2
ANDN = Word8
24
tag2word UPrim2
ANDI = Word8
25
tag2word UPrim2
IORN = Word8
26
tag2word UPrim2
IORI = Word8
27
tag2word UPrim2
XORN = Word8
28
tag2word UPrim2
XORI = Word8
29
tag2word UPrim2
EQLF = Word8
30
tag2word UPrim2
NEQF = Word8
31
tag2word UPrim2
LEQF = Word8
32
tag2word UPrim2
LESF = Word8
33
tag2word UPrim2
ADDF = Word8
34
tag2word UPrim2
SUBF = Word8
35
tag2word UPrim2
MULF = Word8
36
tag2word UPrim2
DIVF = Word8
37
tag2word UPrim2
ATN2 = Word8
38
tag2word UPrim2
POWF = Word8
39
tag2word UPrim2
LOGB = Word8
40
tag2word UPrim2
MAXF = Word8
41
tag2word UPrim2
MINF = Word8
42
tag2word UPrim2
CAST = Word8
43
tag2word UPrim2
DRPN = Word8
44
tag2word UPrim2
ANDB = Word8
45
tag2word UPrim2
IORB = Word8
46
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m UPrim2
word2tag Word8
0 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
ADDI
word2tag Word8
1 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
ADDN
word2tag Word8
2 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
SUBI
word2tag Word8
3 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
SUBN
word2tag Word8
4 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
MULI
word2tag Word8
5 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
MULN
word2tag Word8
6 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
DIVI
word2tag Word8
7 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
MODI
word2tag Word8
8 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
DIVN
word2tag Word8
9 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
MODN
word2tag Word8
10 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
SHLI
word2tag Word8
11 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
SHLN
word2tag Word8
12 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
SHRI
word2tag Word8
13 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
SHRN
word2tag Word8
14 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
POWI
word2tag Word8
15 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
POWN
word2tag Word8
16 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
EQLI
word2tag Word8
17 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
NEQI
word2tag Word8
18 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
EQLN
word2tag Word8
19 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
NEQN
word2tag Word8
20 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
LEQI
word2tag Word8
21 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
LEQN
word2tag Word8
22 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
LESI
word2tag Word8
23 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
LESN
word2tag Word8
24 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
ANDN
word2tag Word8
25 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
ANDI
word2tag Word8
26 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
IORN
word2tag Word8
27 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
IORI
word2tag Word8
28 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
XORN
word2tag Word8
29 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
XORI
word2tag Word8
30 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
EQLF
word2tag Word8
31 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
NEQF
word2tag Word8
32 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
LEQF
word2tag Word8
33 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
LESF
word2tag Word8
34 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
ADDF
word2tag Word8
35 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
SUBF
word2tag Word8
36 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
MULF
word2tag Word8
37 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
DIVF
word2tag Word8
38 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
ATN2
word2tag Word8
39 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
POWF
word2tag Word8
40 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
LOGB
word2tag Word8
41 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
MAXF
word2tag Word8
42 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
MINF
word2tag Word8
43 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
CAST
word2tag Word8
44 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
DRPN
word2tag Word8
45 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
ANDB
word2tag Word8
46 = UPrim2 -> m UPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UPrim2
IORB
word2tag Word8
n = String -> Word8 -> m UPrim2
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"UPrim2" Word8
n
instance Tag BPrim1 where
tag2word :: BPrim1 -> Word8
tag2word BPrim1
SIZT = Word8
0
tag2word BPrim1
USNC = Word8
1
tag2word BPrim1
UCNS = Word8
2
tag2word BPrim1
ITOT = Word8
3
tag2word BPrim1
NTOT = Word8
4
tag2word BPrim1
FTOT = Word8
5
tag2word BPrim1
TTOI = Word8
6
tag2word BPrim1
TTON = Word8
7
tag2word BPrim1
TTOF = Word8
8
tag2word BPrim1
PAKT = Word8
9
tag2word BPrim1
UPKT = Word8
10
tag2word BPrim1
VWLS = Word8
11
tag2word BPrim1
VWRS = Word8
12
tag2word BPrim1
SIZS = Word8
13
tag2word BPrim1
PAKB = Word8
14
tag2word BPrim1
UPKB = Word8
15
tag2word BPrim1
SIZB = Word8
16
tag2word BPrim1
FLTB = Word8
17
tag2word BPrim1
MISS = Word8
18
tag2word BPrim1
CACH = Word8
19
tag2word BPrim1
LKUP = Word8
20
tag2word BPrim1
LOAD = Word8
21
tag2word BPrim1
CVLD = Word8
22
tag2word BPrim1
VALU = Word8
23
tag2word BPrim1
TLTT = Word8
24
tag2word BPrim1
DBTX = Word8
25
tag2word BPrim1
SDBL = Word8
26
tag2word BPrim1
REFN = Word8
27
tag2word BPrim1
REFR = Word8
28
tag2word BPrim1
RRFC = Word8
29
tag2word BPrim1
TIKR = Word8
30
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m BPrim1
word2tag Word8
0 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
SIZT
word2tag Word8
1 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
USNC
word2tag Word8
2 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
UCNS
word2tag Word8
3 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
ITOT
word2tag Word8
4 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
NTOT
word2tag Word8
5 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
FTOT
word2tag Word8
6 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
TTOI
word2tag Word8
7 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
TTON
word2tag Word8
8 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
TTOF
word2tag Word8
9 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
PAKT
word2tag Word8
10 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
UPKT
word2tag Word8
11 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
VWLS
word2tag Word8
12 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
VWRS
word2tag Word8
13 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
SIZS
word2tag Word8
14 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
PAKB
word2tag Word8
15 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
UPKB
word2tag Word8
16 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
SIZB
word2tag Word8
17 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
FLTB
word2tag Word8
18 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
MISS
word2tag Word8
19 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
CACH
word2tag Word8
20 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
LKUP
word2tag Word8
21 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
LOAD
word2tag Word8
22 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
CVLD
word2tag Word8
23 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
VALU
word2tag Word8
24 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
TLTT
word2tag Word8
25 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
DBTX
word2tag Word8
26 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
SDBL
word2tag Word8
27 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
REFN
word2tag Word8
28 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
REFR
word2tag Word8
29 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
RRFC
word2tag Word8
30 = BPrim1 -> m BPrim1
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim1
TIKR
word2tag Word8
n = String -> Word8 -> m BPrim1
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"BPrim1" Word8
n
instance Tag BPrim2 where
tag2word :: BPrim2 -> Word8
tag2word BPrim2
EQLU = Word8
0
tag2word BPrim2
LEQU = Word8
1
tag2word BPrim2
LESU = Word8
2
tag2word BPrim2
CMPU = Word8
3
tag2word BPrim2
DRPT = Word8
4
tag2word BPrim2
CATT = Word8
5
tag2word BPrim2
TAKT = Word8
6
tag2word BPrim2
EQLT = Word8
7
tag2word BPrim2
LEQT = Word8
8
tag2word BPrim2
LEST = Word8
9
tag2word BPrim2
DRPS = Word8
10
tag2word BPrim2
CATS = Word8
11
tag2word BPrim2
TAKS = Word8
12
tag2word BPrim2
CONS = Word8
13
tag2word BPrim2
SNOC = Word8
14
tag2word BPrim2
IDXS = Word8
15
tag2word BPrim2
SPLL = Word8
16
tag2word BPrim2
SPLR = Word8
17
tag2word BPrim2
TAKB = Word8
18
tag2word BPrim2
DRPB = Word8
19
tag2word BPrim2
IDXB = Word8
20
tag2word BPrim2
CATB = Word8
21
tag2word BPrim2
THRO = Word8
22
tag2word BPrim2
TRCE = Word8
23
tag2word BPrim2
SDBX = Word8
24
tag2word BPrim2
IXOT = Word8
25
tag2word BPrim2
IXOB = Word8
26
tag2word BPrim2
SDBV = Word8
27
tag2word BPrim2
REFW = Word8
28
word2tag :: forall (m :: * -> *). MonadGet m => Word8 -> m BPrim2
word2tag Word8
0 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
EQLU
word2tag Word8
1 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
LEQU
word2tag Word8
2 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
LESU
word2tag Word8
3 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
CMPU
word2tag Word8
4 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
DRPT
word2tag Word8
5 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
CATT
word2tag Word8
6 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
TAKT
word2tag Word8
7 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
EQLT
word2tag Word8
8 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
LEQT
word2tag Word8
9 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
LEST
word2tag Word8
10 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
DRPS
word2tag Word8
11 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
CATS
word2tag Word8
12 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
TAKS
word2tag Word8
13 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
CONS
word2tag Word8
14 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
SNOC
word2tag Word8
15 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
IDXS
word2tag Word8
16 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
SPLL
word2tag Word8
17 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
SPLR
word2tag Word8
18 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
TAKB
word2tag Word8
19 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
DRPB
word2tag Word8
20 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
IDXB
word2tag Word8
21 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
CATB
word2tag Word8
22 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
THRO
word2tag Word8
23 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
TRCE
word2tag Word8
24 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
SDBX
word2tag Word8
25 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
IXOT
word2tag Word8
26 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
IXOB
word2tag Word8
27 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
SDBV
word2tag Word8
28 = BPrim2 -> m BPrim2
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BPrim2
REFW
word2tag Word8
n = String -> Word8 -> m BPrim2
forall (m :: * -> *) a. MonadGet m => String -> Word8 -> m a
unknownTag String
"BPrim2" Word8
n