Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Defines binary encoding primitives which mimic Tezos' binary encoding.
Synopsis
- newtype DynamicSize a = DynamicSize {
- unDynamicSize :: a
- buildWord8 :: Word8 -> Builder
- buildText :: Text -> Builder
- buildInteger :: Integer -> Builder
- buildNatural :: Integer -> Builder
- buildDynamic :: (a -> Builder) -> DynamicSize a -> Builder
- buildByteString :: ByteString -> Builder
- getText :: Get Text
- getNatural :: Get Integer
- getInteger :: Get Integer
- getDynamic :: Get a -> Get (DynamicSize a)
- getByteString :: Get ByteString
Documentation
newtype DynamicSize a Source #
DynamicSize | |
|
Encode
buildWord8 :: Word8 -> Builder Source #
buildInteger :: Integer -> Builder Source #
buildNatural :: Integer -> Builder Source #
Build a binary representation of a Zarith natural. This function is
partial, only defined for nonnegative Integer
s.
The reason it's not defined to accept a Natural
is mostly to avoid
fromIntegral
/toInteger
conversions at the use sites, since
not all libraries, notably cryptonite
, support Natural
.
buildDynamic :: (a -> Builder) -> DynamicSize a -> Builder Source #
buildByteString :: ByteString -> Builder Source #
Decode
getNatural :: Get Integer Source #
getInteger :: Get Integer Source #
getDynamic :: Get a -> Get (DynamicSize a) Source #