|
| Data.Binary.Strict.Get | | Portability | portable to Hugs and GHC. | | Stability | experimental | | Maintainer | Adam Langley <agl@imperialviolet.org> |
|
|
|
|
|
| Description |
This is a strict version of the Get monad from the binary package. It's
pretty much just a copy and paste job from the original source code.
The binary team are currently unsure about their future plans w.r.t.
strictness, so this is a stop gap measure.
To use, write a function in the Get monad:
import Data.Binary.Strict.Get as BinStrict
import Data.ByteString as BS
parse :: BinStrict.Get
parse = getWord16be
main = print $ runGet parse $ BS.pack [1, 1]
This results in a tuple of (Right 257, "") (where the second element is
just the remaining data after the parser has run)
|
|
| Synopsis |
|
|
|
|
| The Get type
|
|
|
Instances | |
|
|
|
| Run a parser on the given input and return the result (either an error
string from a call to fail, or the parsing result) and the remainder of
of the input.
|
|
| Parsing
|
|
|
| Run ga, but return without consuming its input.
Fails if ga fails.
|
|
|
| Like lookAhead, but consume the input if gma returns 'Just _'.
Fails if gma fails.
|
|
|
| Like lookAhead, but consume the input if gea returns 'Right _'.
Fails if gea fails.
|
|
|
|
|
|
|
|
| Utility
|
|
|
| Skip ahead n bytes. Fails if fewer than n bytes are available.
|
|
|
| Get the total number of bytes read to this point.
|
|
|
| Get the number of remaining unparsed bytes.
Useful for checking whether all input has been consumed.
|
|
|
| Test whether all input has been consumed,
i.e. there are no remaining unparsed bytes.
|
|
| Parsing particular types
|
|
|
|
| ByteStrings
|
|
|
| An efficient get method for strict ByteStrings. Fails if fewer
than n bytes are left in the input.
|
|
| Big-endian reads
|
|
|
|
|
|
|
|
| Little-endian reads
|
|
|
|
|
|
|
|
| Host-endian, unaligned reads
|
|
|
|
|
|
|
|
|
|
| Floating point
|
|
|
|
|
|
| Produced by Haddock version 2.4.2 |