Safe Haskell | None |
---|---|
Language | Haskell2010 |
Get utilities
Synopsis
- data Get a
- runGet :: Get a -> Buffer -> Either String a
- runGetOrFail :: Get a -> Buffer -> a
- isEmpty :: Get Bool
- remaining :: Get Word
- skip :: Word -> Get ()
- uncheckedSkip :: Word -> Get ()
- skipAlign :: Word -> Word -> Get ()
- uncheckedSkipAlign :: Word -> Word -> Get ()
- countBytes :: Get a -> Get (Word, a)
- alignAfter :: Word -> Get a -> Get a
- consumeExactly :: Word -> Get a -> Get a
- consumeAtMost :: Word -> Get a -> Get a
- lookAhead :: Get a -> Get a
- lookAheadM :: Get (Maybe a) -> Get (Maybe a)
- lookAheadE :: Get (Either a b) -> Get (Either a b)
- getRemaining :: Get Buffer
- getBuffer :: Word -> Get Buffer
- getBufferNul :: Get Buffer
- getWord8 :: Get Word8
- getWord16le :: Get Word16
- getWord16be :: Get Word16
- getWord32le :: Get Word32
- getWord32be :: Get Word32
- getWord64le :: Get Word64
- getWord64be :: Get Word64
- getWhile :: (a -> Bool) -> Get a -> Get [a]
- getWhole :: Get a -> Get [a]
- getBitGet :: BitOrder -> BitGet a -> (a -> Get b) -> Get b
- getManyAtMost :: Word -> Get (Maybe a) -> Get [a]
- getManyBounded :: Maybe Word -> Maybe Word -> Get (Maybe a) -> Get (Maybe [a])
Documentation
The Get monad is an Exception and State monad.
Instances
Monad Get | |
Functor Get | |
MonadFail Get | |
Defined in Data.Serialize.Get | |
Applicative Get | |
Alternative Get | |
MonadPlus Get | |
runGetOrFail :: Get a -> Buffer -> a Source #
Run a getter and throw an exception on error
Size & alignment
uncheckedSkip :: Word -> Get () Source #
Skip ahead n bytes. No error if there isn't enough bytes.
skipAlign :: Word -> Word -> Get () Source #
Skip to align n to al. Fails if fewer than n bytes are available.
uncheckedSkipAlign :: Word -> Word -> Get () Source #
Skip to align n to al. Fails if fewer than n bytes are available.
alignAfter :: Word -> Get a -> Get a Source #
Execute the getter and align on the given number of Word8
Isolation
consumeExactly :: Word -> Get a -> Get a Source #
Require an action to consume exactly the given number of bytes, fail otherwise
consumeAtMost :: Word -> Get a -> Get a Source #
Require an action to consume at most the given number of bytes, fail otherwise
Look-ahead
lookAheadM :: Get (Maybe a) -> Get (Maybe a) Source #
Run the getter. Consume its input if Just _ returned. Fails if it fails
lookAheadE :: Get (Either a b) -> Get (Either a b) Source #
Run the getter. Consume its input if Right _ returned. Fails if it fails
Read
getRemaining :: Get Buffer Source #
Get remaining bytes
getBufferNul :: Get Buffer Source #
Get Buffer terminated with 0 (consume 0)
getWord16le :: Get Word16 Source #
Get Word16 little-endian
getWord16be :: Get Word16 Source #
Get Word16 big-endian
getWord32le :: Get Word32 Source #
Get Word32 little-endian
getWord32be :: Get Word32 Source #
Get Word32 big-endian
getWord64le :: Get Word64 Source #
Get Word64 little-endian
getWord64be :: Get Word64 Source #
Get Word64 big-endian
Utilities
getWhile :: (a -> Bool) -> Get a -> Get [a] Source #
Get while True (read and discard the ending element)