| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
PlutusCore.Flat.Decoder
Description
Strict Decoder
Synopsis
- strictDecoder :: Get a -> ListT IO a) #
Decode a list of values, one value at a time.
Useful in case that the decoded values takes a lot more memory than the encoded ones.
See ../test/Big.hs for a test and an example of use.
See also Flat.AsBin.
Since: 0.5
type Decoded a = Either DecodeException a #
A decoded value
data DecodeException #
An exception during decoding
Constructors
| NotEnoughSpace Env | |
| TooMuchSpace Env | |
| BadEncoding Env String | |
| BadOp String |
Instances
| Exception DecodeException # | |
Defined in PlutusCore.Flat.Decoder.Types Methods toException :: DecodeException -> SomeException # | |
| Show DecodeException # | |
Defined in PlutusCore.Flat.Decoder.Types Methods showsPrec :: Int -> DecodeException -> ShowS # show :: DecodeException -> String # showList :: [DecodeException] -> ShowS # | |
| Eq DecodeException # | |
Defined in PlutusCore.Flat.Decoder.Types Methods (==) :: DecodeException -> DecodeException -> Bool # (/=) :: DecodeException -> DecodeException -> Bool # | |
| Ord DecodeException # | |
Defined in PlutusCore.Flat.Decoder.Types Methods compare :: DecodeException -> DecodeException -> Ordering # (<) :: DecodeException -> DecodeException -> Bool # (<=) :: DecodeException -> DecodeException -> Bool # (>) :: DecodeException -> DecodeException -> Bool # (>=) :: DecodeException -> DecodeException -> Bool # max :: DecodeException -> DecodeException -> DecodeException # min :: DecodeException -> DecodeException -> DecodeException # | |
A decoder.
Given:
- end of input buffer
- current position in input buffer
Returns:
- decoded value
- new position in input buffer
decodeArrayWith :: Get a -> Get [a] #
decodeListWith :: Get a -> Get [a] #
dBEBits8 :: Int -> Get Word8 #
Return the n most significant bits (up to maximum of 8)
The bits are returned right shifted:
>>>unflatWith (dBEBits8 3) [0b11100001::Word8] == Right 0b00000111True
>>>unflatWith (dBEBits8 9) [0b11100001::Word8,0b11111111]Left (BadOp "read8: cannot read 9 bits")
dBEBits16 :: Int -> Get Word16 #
Return the n most significant bits (up to maximum of 16)
The bits are returned right shifted:
>>>pPrint . asBits <$> unflatWith (dBEBits16 11) [0b10110111::Word8,0b11100001]Right 00000101 10111111
If more than 16 bits are requested, only the last 16 are returned:
>>>pPrint . asBits <$> unflatWith (dBEBits16 19) [0b00000000::Word8,0b11111111,0b11100001]Right 00000111 11111111
dBEBits32 :: Int -> Get Word32 #
Return the n most significant bits (up to maximum of 32) The bits are returned right shifted.
dBEBits64 :: Int -> Get Word64 #
Return the n most significant bits (up to maximum of 64) The bits are returned right shifted.
A special state, optimised for constructor decoding.
It consists of:
- The bits to parse, the top bit being the first to parse (could use a Word16 instead, no difference in performance)
- The number of decoded bits
Supports up to 512 constructors (9 bits).