Safe Haskell | None |
---|---|
Language | Haskell2010 |
Deserialization monad and deserializable types.
- class (Monad μ, Parsing μ) => Deserializer μ where
- newtype BinaryDeserializer α = BinaryDeserializer {
- binaryDeserializer :: Get α
- newtype CerealDeserializer α = CerealDeserializer {
- cerealDeserializer :: Get α
- word16H :: Deserializer μ => μ Word16
- word32H :: Deserializer μ => μ Word32
- word64H :: Deserializer μ => μ Word64
- word :: Deserializer μ => μ Word
- wordL :: Deserializer μ => μ Word
- wordB :: Deserializer μ => μ Word
- wordH :: Deserializer μ => μ Word
- int8 :: Deserializer μ => μ Int8
- int16 :: Deserializer μ => μ Int16
- int16L :: Deserializer μ => μ Int16
- int16B :: Deserializer μ => μ Int16
- int16H :: Deserializer μ => μ Int16
- int32 :: Deserializer μ => μ Int32
- int32L :: Deserializer μ => μ Int32
- int32B :: Deserializer μ => μ Int32
- int32H :: Deserializer μ => μ Int32
- int64 :: Deserializer μ => μ Int64
- int64L :: Deserializer μ => μ Int64
- int64B :: Deserializer μ => μ Int64
- int64H :: Deserializer μ => μ Int64
- int :: Deserializer μ => μ Int
- intL :: Deserializer μ => μ Int
- intB :: Deserializer μ => μ Int
- intH :: Deserializer μ => μ Int
- module Text.Parser.Combinators
- label :: Parsing μ => String -> μ α -> μ α
- module Text.Parser.LookAhead
- newtype LittleEndianDeserializer μ α = LittleEndianDeserializer {
- deserializeL :: μ α
- newtype BigEndianDeserializer μ α = BigEndianDeserializer {
- deserializeB :: μ α
- deserializeIn :: Deserializer μ => Endian -> (forall μ'. Deserializer μ' => μ' α) -> μ α
- deserializeH :: Deserializer μ => (forall μ'. Deserializer μ' => μ' α) -> μ α
- class Deserializable α where
- getIn :: (Deserializer μ, Deserializable α) => Endian -> μ α
- getL :: (Deserializer μ, Deserializable α) => μ α
- getB :: (Deserializer μ, Deserializable α) => μ α
- getH :: (Deserializer μ, Deserializable α) => μ α
- class RestDeserializable α where
Deserialization monad
class (Monad μ, Parsing μ) => Deserializer μ where Source #
Deserialization monad.
endian :: Proxy μ -> Endian Source #
Default byte order of the deserializer.
Deserialze a byte.
Deserialize an unsigned 16-bit integer in default byte order.
Deserialize an unsigned 32-bit integer in default byte order.
Deserialize an unsigned 64-bit integer in default byte order.
Deserialize an unsigned 16-bit integer in little endian.
Deserialize an unsigned 16-bit integer in big endian.
Deserialize an unsigned 32-bit integer in little endian.
Deserialize an unsigned 32-bit integer in big endian.
Deserialize an unsigned 64-bit integer in little endian.
Deserialize an unsigned 64-bit integer in big endian.
satisfy :: (Word8 -> Bool) -> μ Word8 Source #
satisfy
p deserializes a byte that satisfies the predicate p,
failing otherwise.
byte :: Word8 -> μ Word8 Source #
Deserialize the specified byte value, failing on any other input.
notByte :: Word8 -> μ Word8 Source #
notByte
c deserializes any byte that is not equal to c, failing
if c is encountered.
bytes :: ByteString -> μ ByteString Source #
bytes
bs deserializes a sequence of bytes given by bs, failing
on any other input.
Skip exactly the given number of bytes.
ensure :: Int -> μ ByteString Source #
ensure
n checks that the input has at least n more bytes and
returns a portion of the input of length greater or equal to n
(without consuming it).
ensure_ :: Int -> μ () Source #
ensure_
n fails if the input has less than n more bytes.
take :: Int -> μ ByteString Source #
Consume exactly the given number of bytes.
chunk :: μ ByteString Source #
Consume a portion of the input (the size of the returned
ByteString
is implementation dependent). Empty result means that
the eof
is reached.
newtype BinaryDeserializer α Source #
A wrapper around the Get
monad (to avoid orphan instances).
newtype CerealDeserializer α Source #
A wrapper around the Get
monad (to avoid orphan instances).
Binary word parsing
word16H :: Deserializer μ => μ Word16 Source #
Deserialize an unsigned 16-bit integer in host byte order.
word32H :: Deserializer μ => μ Word32 Source #
Deserialize an unsigned 32-bit integer in host byte order.
word64H :: Deserializer μ => μ Word64 Source #
Deserialize an unsigned 64-bit integer in host byte order.
word :: Deserializer μ => μ Word Source #
Deserialize an unsigned native-sized integer in serializer default byte order.
wordL :: Deserializer μ => μ Word Source #
Deserialize an unsigned native-sized integer in little endian.
wordB :: Deserializer μ => μ Word Source #
Deserialize an unsigned native-sized integer in big endian.
wordH :: Deserializer μ => μ Word Source #
Deserialize an unsigned native-sized integer in host byte order.
int8 :: Deserializer μ => μ Int8 Source #
Deserialize a signed 8-bit integer.
int16 :: Deserializer μ => μ Int16 Source #
Deserialize a signed 16-bit integer in serializer default byte order.
int16L :: Deserializer μ => μ Int16 Source #
Deserialize a signed 16-bit integer in little endian.
int16B :: Deserializer μ => μ Int16 Source #
Deserialize a signed 16-bit integer in big endian.
int16H :: Deserializer μ => μ Int16 Source #
Deserialize a signed 16-bit integer in host byte order.
int32 :: Deserializer μ => μ Int32 Source #
Deserialize a signed 32-bit integer in serializer default byte order.
int32L :: Deserializer μ => μ Int32 Source #
Deserialize a signed 32-bit integer in little endian.
int32B :: Deserializer μ => μ Int32 Source #
Deserialize a signed 32-bit integer in big endian.
int32H :: Deserializer μ => μ Int32 Source #
Deserialize a signed 32-bit integer in host byte order.
int64 :: Deserializer μ => μ Int64 Source #
Deserialize a signed 64-bit integer in serializer default byte order.
int64L :: Deserializer μ => μ Int64 Source #
Deserialize a signed 64-bit integer in little endian.
int64B :: Deserializer μ => μ Int64 Source #
Deserialize a signed 64-bit integer in big endian.
int64H :: Deserializer μ => μ Int64 Source #
Deserialize a signed 64-bit integer in host byte order.
int :: Deserializer μ => μ Int Source #
Deserialize a signed native-sized integer in serializer default byte order.
intL :: Deserializer μ => μ Int Source #
Deserialize a signed native-sized integer in little endian.
intB :: Deserializer μ => μ Int Source #
Deserialize a signed native-sized integer in big endian.
intH :: Deserializer μ => μ Int Source #
Deserialize a signed native-sized integer in host byte order.
Parsing combinators
module Text.Parser.Combinators
module Text.Parser.LookAhead
Endian deserializers
newtype LittleEndianDeserializer μ α Source #
Deserializer wrapper with little endian default byte order.
Monad μ => Monad (LittleEndianDeserializer μ) Source # | |
Functor μ => Functor (LittleEndianDeserializer μ) Source # | |
Applicative μ => Applicative (LittleEndianDeserializer μ) Source # | |
Alternative μ => Alternative (LittleEndianDeserializer μ) Source # | |
LookAheadParsing μ => LookAheadParsing (LittleEndianDeserializer μ) Source # | |
Parsing μ => Parsing (LittleEndianDeserializer μ) Source # | |
Deserializer μ => Deserializer (LittleEndianDeserializer μ) Source # | |
(Data (μ α), Typeable * α, Typeable (* -> *) μ) => Data (LittleEndianDeserializer μ α) Source # | |
Generic (LittleEndianDeserializer μ α) Source # | |
type Rep (LittleEndianDeserializer μ α) Source # | |
newtype BigEndianDeserializer μ α Source #
Deserializer wrapper with big endian default byte order.
Monad μ => Monad (BigEndianDeserializer μ) Source # | |
Functor μ => Functor (BigEndianDeserializer μ) Source # | |
Applicative μ => Applicative (BigEndianDeserializer μ) Source # | |
Alternative μ => Alternative (BigEndianDeserializer μ) Source # | |
LookAheadParsing μ => LookAheadParsing (BigEndianDeserializer μ) Source # | |
Parsing μ => Parsing (BigEndianDeserializer μ) Source # | |
Deserializer μ => Deserializer (BigEndianDeserializer μ) Source # | |
(Data (μ α), Typeable * α, Typeable (* -> *) μ) => Data (BigEndianDeserializer μ α) Source # | |
Generic (BigEndianDeserializer μ α) Source # | |
type Rep (BigEndianDeserializer μ α) Source # | |
deserializeIn :: Deserializer μ => Endian -> (forall μ'. Deserializer μ' => μ' α) -> μ α Source #
Force the default byte order.
deserializeH :: Deserializer μ => (forall μ'. Deserializer μ' => μ' α) -> μ α Source #
Force the default byte order to be the host byte order.
Deserializable types
class Deserializable α where Source #
get :: Deserializer μ => μ α Source #
getIn :: (Deserializer μ, Deserializable α) => Endian -> μ α Source #
Deserialize a value using the provided default byte order.
getL :: (Deserializer μ, Deserializable α) => μ α Source #
Deserialize a value using little endian as the default byte order.
getB :: (Deserializer μ, Deserializable α) => μ α Source #
Deserialize a value using big endian as the default byte order.
getH :: (Deserializer μ, Deserializable α) => μ α Source #
Deserialize a value using host byte order as the default byte order.
class RestDeserializable α where Source #
Deserializable type. getRest
must consume all the remaining input
or fail.
getRest :: Deserializer μ => μ α Source #