Safe Haskell | None |
---|---|
Language | Haskell2010 |
Serialization monoid and serializable types.
- class (Semigroup s, Monoid s) => Serializer s where
- newtype BinarySerializer = BinarySerializer {}
- newtype CerealSerializer = CerealSerializer {}
- word16H :: Serializer s => Word16 -> s
- word32H :: Serializer s => Word32 -> s
- word64H :: Serializer s => Word64 -> s
- word :: Serializer s => Word -> s
- wordL :: Serializer s => Word -> s
- wordB :: Serializer s => Word -> s
- wordH :: Serializer s => Word -> s
- int8 :: Serializer s => Int8 -> s
- int16 :: Serializer s => Int16 -> s
- int16L :: Serializer s => Int16 -> s
- int16B :: Serializer s => Int16 -> s
- int16H :: Serializer s => Int16 -> s
- int32 :: Serializer s => Int32 -> s
- int32L :: Serializer s => Int32 -> s
- int32B :: Serializer s => Int32 -> s
- int32H :: Serializer s => Int32 -> s
- int64 :: Serializer s => Int64 -> s
- int64L :: Serializer s => Int64 -> s
- int64B :: Serializer s => Int64 -> s
- int64H :: Serializer s => Int64 -> s
- int :: Serializer s => Int -> s
- intL :: Serializer s => Int -> s
- intB :: Serializer s => Int64 -> s
- intH :: Serializer s => Int -> s
- newtype LittleEndianSerializer s = LittleEndianSerializer {
- serializeL :: s
- newtype BigEndianSerializer s = BigEndianSerializer {
- serializeB :: s
- serializeIn :: Serializer s => Endian -> (forall s'. Serializer s' => s') -> s
- serializeH :: Serializer s => (forall s'. Serializer s' => s') -> s
- class Serializable α where
- putIn :: (Serializer s, Serializable α) => Endian -> α -> s
- putL :: (Serializer s, Serializable α) => α -> s
- putB :: (Serializer s, Serializable α) => α -> s
- putH :: (Serializer s, Serializable α) => α -> s
- class Serializable α => SizedSerializable α where
- class RestSerializable α where
Serialization monoid
class (Semigroup s, Monoid s) => Serializer s where Source #
Serialization monoid.
endian :: Proxy s -> Endian Source #
Default byte order of the serializer.
Serialize a byte. word8
x = byteString
(singleton
x)
word16 :: Word16 -> s Source #
Serialize an unsigned 16-bit integer in the default byte order.
word32 :: Word32 -> s Source #
Serialize an unsigned 32-bit integer in the default byte order.
word64 :: Word64 -> s Source #
Serialize an unsigned 64-bit integer in the default byte order.
word16L :: Word16 -> s Source #
Serialize an unsigned 16-bit integer in little endian.
word16B :: Word16 -> s Source #
Serialize an unsigned 16-bit integer in big endian.
word32L :: Word32 -> s Source #
Serialize an unsigned 32-bit integer in little endian.
word32B :: Word32 -> s Source #
Serialize an unsigned 32-bit integer in big endian.
word64L :: Word64 -> s Source #
Serialize an unsigned 64-bit integer in little endian.
word64B :: Word64 -> s Source #
Serialize an unsigned 64-bit integer in big endian.
byteString :: ByteString -> s Source #
Serialize a ByteString
. Must be a monoid homomorphism.
shortByteString :: ShortByteString -> s Source #
Serialize a ShortByteString
. Must be a monoid homomorphism.
lazyByteString :: ByteString -> s Source #
Serialize a lazy ByteString
. Must be a monoid homomorphism.
builder :: Builder -> s Source #
Serialize a Builder
. Must be a monoid homomorphism.
newtype BinarySerializer Source #
A wrapper around the Put
monoid (to avoid orphan instances).
newtype CerealSerializer Source #
A wrapper around the Put
monoid (to avoid orphan instances).
Binary words serialization
word16H :: Serializer s => Word16 -> s Source #
Serialize an usigned 16-bit integer in host byte order.
word32H :: Serializer s => Word32 -> s Source #
Serialize an unsigned 32-bit integer in host byte order.
word64H :: Serializer s => Word64 -> s Source #
Serialize an unsigned 64-bit integer in host byte order.
word :: Serializer s => Word -> s Source #
Serialize an unsigned native-sized integer in serializer default byte order.
wordL :: Serializer s => Word -> s Source #
Serialize an unsigned native-sized integer in little endian.
wordB :: Serializer s => Word -> s Source #
Serialize an unsigned native-sized integer in big endian.
wordH :: Serializer s => Word -> s Source #
Serialize an unsigned native-sized integer in host byte order.
int8 :: Serializer s => Int8 -> s Source #
Serialize a signed 8-bit integer.
int16 :: Serializer s => Int16 -> s Source #
Serialize a signed 16-bit integer in serializer default byte order.
int16L :: Serializer s => Int16 -> s Source #
Serialize a signed 16-bit integer in little endian.
int16B :: Serializer s => Int16 -> s Source #
Serialize a signed 16-bit integer in big endian.
int16H :: Serializer s => Int16 -> s Source #
Serialize a signed 16-bit integer in host byte order.
int32 :: Serializer s => Int32 -> s Source #
Serialize a signed 32-bit integer in serializer default byte order.
int32L :: Serializer s => Int32 -> s Source #
Serialize a signed 32-bit integer in little endian.
int32B :: Serializer s => Int32 -> s Source #
Serialize a signed 32-bit integer in big endian.
int32H :: Serializer s => Int32 -> s Source #
Serialize a signed 32-bit integer in host byte order.
int64 :: Serializer s => Int64 -> s Source #
Serialize a signed 64-bit integer in serializer default byte order.
int64L :: Serializer s => Int64 -> s Source #
Serialize a signed 64-bit integer in little endian.
int64B :: Serializer s => Int64 -> s Source #
Serialize a signed 64-bit integer in big endian.
int64H :: Serializer s => Int64 -> s Source #
Serialize a signed 64-bit integer in host byte order.
int :: Serializer s => Int -> s Source #
Serialize a signed native-sized integer in serializer default byte order.
intL :: Serializer s => Int -> s Source #
Serialize a signed native-sized integer in little endian.
intB :: Serializer s => Int64 -> s Source #
Serialize a signed native-sized integer in big endian.
intH :: Serializer s => Int -> s Source #
Serialize a signed native-sized integer in host byte order.
Endian serializers
newtype LittleEndianSerializer s Source #
Serializer wrapper with little endian default byte order.
Data s => Data (LittleEndianSerializer s) Source # | |
Generic (LittleEndianSerializer s) Source # | |
Semigroup s => Semigroup (LittleEndianSerializer s) Source # | |
Monoid s => Monoid (LittleEndianSerializer s) Source # | |
Serializer s => Serializer (LittleEndianSerializer s) Source # | |
type Rep (LittleEndianSerializer s) Source # | |
newtype BigEndianSerializer s Source #
Serializer wrapper with big endian default byte order.
Data s => Data (BigEndianSerializer s) Source # | |
Generic (BigEndianSerializer s) Source # | |
Semigroup s => Semigroup (BigEndianSerializer s) Source # | |
Monoid s => Monoid (BigEndianSerializer s) Source # | |
Serializer s => Serializer (BigEndianSerializer s) Source # | |
type Rep (BigEndianSerializer s) Source # | |
serializeIn :: Serializer s => Endian -> (forall s'. Serializer s' => s') -> s Source #
Force the default byte order.
serializeH :: Serializer s => (forall s'. Serializer s' => s') -> s Source #
Force the default byte order to be the host byte order.
Serializable types
class Serializable α where Source #
Serializable type. put
must work under assumption that it will be
followed by more output.
put :: Serializer s => α -> s Source #
putIn :: (Serializer s, Serializable α) => Endian -> α -> s Source #
Serialize a value using the provided default byte order.
putL :: (Serializer s, Serializable α) => α -> s Source #
Serialize a value using little endian as the default byte order.
putB :: (Serializer s, Serializable α) => α -> s Source #
Serialize a value using big endian as the default byte order.
putH :: (Serializer s, Serializable α) => α -> s Source #
Serialize a value using host byte order as the default byte order.
class Serializable α => SizedSerializable α where Source #
Types with fixed serialized size.
class RestSerializable α where Source #
Serializable type. putRest
must work under assumption that it will not
be followed by any more output.
putRest :: Serializer s => α -> s Source #