module Cardano.Ledger.Binary.Decoding.Drop (
Dropper,
dropBytes,
dropInt32,
dropList,
dropMap,
dropSet,
dropTuple,
dropTriple,
dropWord8,
dropWord64,
)
where
import Cardano.Ledger.Binary.Decoding.Decoder
import Control.Monad (replicateM_)
import Data.Functor (void)
type Dropper s = Decoder s ()
dropBytes :: Dropper s
dropBytes :: forall s. Dropper s
dropBytes = forall (f :: * -> *) a. Functor f => f a -> f ()
void forall s. Decoder s ByteString
decodeBytes
dropInt32 :: Dropper s
dropInt32 :: forall s. Dropper s
dropInt32 = forall (f :: * -> *) a. Functor f => f a -> f ()
void forall s. Decoder s Int32
decodeInt32
dropList :: Dropper s -> Dropper s
dropList :: forall s. Dropper s -> Dropper s
dropList Dropper s
dropElems = do
forall s. Dropper s
decodeListLenIndef
forall r a b s.
(r -> a -> r) -> r -> (r -> b) -> Decoder s a -> Decoder s b
decodeSequenceLenIndef forall a b. a -> b -> a
const () forall a. a -> a
id Dropper s
dropElems
dropMap :: Dropper s -> Dropper s -> Dropper s
dropMap :: forall s. Dropper s -> Dropper s -> Dropper s
dropMap Dropper s
dropKey Dropper s
dropValue = do
Int
n <- forall s. Decoder s Int
decodeMapLen
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
n forall a b. (a -> b) -> a -> b
$ Dropper s
dropKey forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Dropper s
dropValue
dropSet :: Dropper s -> Dropper s
dropSet :: forall s. Dropper s -> Dropper s
dropSet Dropper s
dropElem = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall s. Decoder s Word
decodeTag
Int
n <- forall s. Decoder s Int
decodeListLen
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
n Dropper s
dropElem
dropTuple :: Dropper s -> Dropper s -> Dropper s
dropTuple :: forall s. Dropper s -> Dropper s -> Dropper s
dropTuple Dropper s
dropA Dropper s
dropB = do
forall s. Int -> Decoder s ()
decodeListLenOf Int
2
Dropper s
dropA
Dropper s
dropB
dropTriple :: Dropper s -> Dropper s -> Dropper s -> Dropper s
dropTriple :: forall s. Dropper s -> Dropper s -> Dropper s -> Dropper s
dropTriple Dropper s
dropA Dropper s
dropB Dropper s
dropC = do
forall s. Int -> Decoder s ()
decodeListLenOf Int
3
Dropper s
dropA
Dropper s
dropB
Dropper s
dropC
dropWord8 :: Dropper s
dropWord8 :: forall s. Dropper s
dropWord8 = forall (f :: * -> *) a. Functor f => f a -> f ()
void forall s. Decoder s Word8
decodeWord8
dropWord64 :: Dropper s
dropWord64 :: forall s. Dropper s
dropWord64 = forall (f :: * -> *) a. Functor f => f a -> f ()
void forall s. Decoder s Word64
decodeWord64