Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data PackStreamError
- newtype PackStream a = PackStream {}
- class PackStreamValue a where
- pack :: a -> ByteString
- unpack :: PackStream a
- unpackStream :: PackStream a -> ByteString -> Either PackStreamError a
- unpackFail :: (MonadFail m, PackStreamValue a) => ByteString -> m a
- unpackThrow :: (MonadError PackStreamError m, PackStreamValue a) => ByteString -> m a
- data Value
- (=:) :: ToValue a => Text -> a -> (Text, Value)
- data Structure = Structure {}
Documentation
data PackStreamError Source #
Basic PackStream
error type that is used to handle parsing errors.
NotNull | This |
NotBool | This |
NotWord | This |
NotInt | This |
NotFloat | This |
NotString | This |
NotBytes | This |
NotList | This |
NotDict | This |
NotStructure | This |
NotValue | This |
WrongStructure Text | This |
Instances
newtype PackStream a Source #
Basic parser type. It works like parser combinators for binary data that represents PackStream.
Instances
class PackStreamValue a where Source #
The data types that can be interpreted or parsed to/from PackStream
ByteString
pack :: a -> ByteString Source #
Pack a value into a PackStream
ByteString
unpack :: PackStream a Source #
Parse a value from a PackStream
ByteString
Instances
unpackStream :: PackStream a -> ByteString -> Either PackStreamError a Source #
Use specific parser combinator to parse the ByteString
that represents any PackStream
data.
unpackFail :: (MonadFail m, PackStreamValue a) => ByteString -> m a Source #
Unpack some value of the specific type from ByteString
or fail
unpackThrow :: (MonadError PackStreamError m, PackStreamValue a) => ByteString -> m a Source #
Unpack some value of the specific type from ByteString
or raise PackStreamError
PackStream offers a number of core data types, many supported by multiple binary representations, as well as a flexible extension mechanism.
N | Missing or empty value |
B Bool | True or False |
I Int | Signed 64-bit integer |
F Double | 64-bit floating point number |
U ByteString | Byte array |
T Text | Unicode text, UTF-8 |
L [Value] | Ordered collection of |
D (Map Text Value) | Collection of key-value entries (no order guaranteed) |
S Structure | Composite value with a type signature |
(=:) :: ToValue a => Text -> a -> (Text, Value) Source #
Represent a Text
key and some ToValue
data into the Map
pair.
Can be useful to work with PackStream
dictionaries.
fromList ["hello" =: 1, "world" =: False]
A structure is a composite value, comprised of fields and a unique type code. Structure encodings consist, beyond the marker, of a single byte, the tag byte, followed by a sequence of up to 15 fields, each an individual value. The size of a structure is measured as the number of fields and not the total byte size. This count does not include the tag.