bytes-0.17.4: Sharing code for serialization between binary and cereal

Copyright | (c) Edward Kmett 2013-2015
License | BSD3
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | Trustworthy
Language | Haskell2010

Data.Bytes.Serial

Contents

- Serialization
- Specifying endianness
- Higher-order
- Storable
- Generics

Description

This module contains two main classes, each providing methods to serialize and deserialize types. `Serial` is the primary class, to be used for the canonical way to serialize a specific type. `SerialEndian` is used to provide endian-specific methods for serializing a type.

Synopsis

- class Serial a where
  - serialize :: MonadPut m => a -> m ()
  - deserialize :: MonadGet m => m a
- class SerialEndian a where
  - serializeBE :: MonadPut m => a -> m ()
  - deserializeBE :: MonadGet m => m a
  - serializeLE :: MonadPut m => a -> m ()
  - deserializeLE :: MonadGet m => m a
  - serializeHost :: MonadPut m => a -> m ()
  - deserializeHost :: MonadGet m => m a
- class Serial1 (f :: Type -> Type) where
  - serializeWith :: MonadPut m => (a -> m ()) -> f a -> m ()
  - deserializeWith :: MonadGet m => m a -> m (f a)
- serialize1 :: (MonadPut m, Serial1 f, Serial a) => f a -> m ()
- deserialize1 :: (MonadGet m, Serial1 f, Serial a) => m (f a)
- class Serial2 (f :: Type -> Type -> Type) where
  - serializeWith2 :: MonadPut m => (a -> m ()) -> (b -> m ()) -> f a b -> m ()
  - deserializeWith2 :: MonadGet m => m a -> m b -> m (f a b)
- serialize2 :: (MonadPut m, Serial2 f, Serial a, Serial b) => f a b -> m ()
- deserialize2 :: (MonadGet m, Serial2 f, Serial a, Serial b) => m (f a b)
- store :: (MonadPut m, Storable a) => a -> m ()
- restore :: (MonadGet m, Storable a) => m a
- class GSerial (f :: Type -> Type) where
  - gserialize :: MonadPut m => f a -> m ()
  - gdeserialize :: MonadGet m => m (f a)
- class GSerialEndian (f :: Type -> Type) where
  - gserializeBE :: MonadPut m => f a -> m ()
  - gdeserializeBE :: MonadGet m => m (f a)
  - gserializeLE :: MonadPut m => f a -> m ()
  - gdeserializeLE :: MonadGet m => m (f a)
- class GSerial1 (f :: Type -> Type) where
  - gserializeWith :: MonadPut m => (a -> m ()) -> f a -> m ()
  - gdeserializeWith :: MonadGet m => m a -> m (f a)

# Serialization

class Serial a where Source #

Methods to serialize and deserialize type `a` to a binary representation

Instances provided here for fixed-with Integers and Words are big endian. Instances for strict and lazy bytestrings store also the length of bytestring big endian. Instances for Word and Int are host endian as they are machine-specific types.

Minimal complete definition

Nothing

Methods

serialize :: MonadPut m => a -> m () Source #

default serialize :: (MonadPut m, GSerial (Rep a), Generic a) => a -> m () Source #

deserialize :: MonadGet m => m a Source #

default deserialize :: (MonadGet m, GSerial (Rep a), Generic a) => m a Source #

#### Instances

Instances details

Serial ByteString Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => ByteString -> m () Source # deserialize :: MonadGet m => m ByteString Source #
Serial ByteString Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => ByteString -> m () Source # deserialize :: MonadGet m => m ByteString Source #
Serial IntSet Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => IntSet -> m () Source # deserialize :: MonadGet m => m IntSet Source #
Serial Void Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Void -> m () Source # deserialize :: MonadGet m => m Void Source #
Serial All Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => All -> m () Source # deserialize :: MonadGet m => m All Source #
Serial Any Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Any -> m () Source # deserialize :: MonadGet m => m Any Source #
Serial Version Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Version -> m () Source # deserialize :: MonadGet m => m Version Source #
Serial Int16 Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Int16 -> m () Source # deserialize :: MonadGet m => m Int16 Source #
Serial Int32 Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Int32 -> m () Source # deserialize :: MonadGet m => m Int32 Source #
Serial Int64 Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Int64 -> m () Source # deserialize :: MonadGet m => m Int64 Source #
Serial Int8 Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Int8 -> m () Source # deserialize :: MonadGet m => m Int8 Source #
Serial Word16 Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Word16 -> m () Source # deserialize :: MonadGet m => m Word16 Source #
Serial Word32 Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Word32 -> m () Source # deserialize :: MonadGet m => m Word32 Source #
Serial Word64 Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Word64 -> m () Source # deserialize :: MonadGet m => m Word64 Source #
Serial Word8 Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Word8 -> m () Source # deserialize :: MonadGet m => m Word8 Source #

Serial Ordering Source #

    >>> runGetL deserialize $ runPutL $ serialize LT::Ordering
    LT
    >>> runGetL deserialize $ runPutL $ serialize EQ::Ordering
    EQ
    >>> runGetL deserialize $ runPutL $ serialize GT::Ordering
    GT

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Ordering -> m () Source # deserialize :: MonadGet m => m Ordering Source #
Serial Scientific Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Scientific -> m () Source # deserialize :: MonadGet m => m Scientific Source #
Serial Text Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Text -> m () Source # deserialize :: MonadGet m => m Text Source #
Serial Text Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Text -> m () Source # deserialize :: MonadGet m => m Text Source #

Serial Day Source #

    >>> (runGetL deserialize $ runPutL $ serialize (ModifiedJulianDay 1))::Day
    1858-11-18

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Day -> m () Source # deserialize :: MonadGet m => m Day Source #

Serial AbsoluteTime Source #

    >>> (runGetL deserialize $ runPutL $ serialize (addAbsoluteTime 18.2 taiEpoch))::AbsoluteTime
    1858-11-17 00:00:18.2 TAI

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => AbsoluteTime -> m () Source # deserialize :: MonadGet m => m AbsoluteTime Source #

Serial DiffTime Source #

    >>> (runGetL deserialize $ runPutL $ serialize (1.82::DiffTime))::DiffTime
    1.82s

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => DiffTime -> m () Source # deserialize :: MonadGet m => m DiffTime Source #

Serial NominalDiffTime Source #

    >>> (runGetL deserialize $ runPutL $ serialize (1.82::DiffTime))::DiffTime
    1.82s

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => NominalDiffTime -> m () Source # deserialize :: MonadGet m => m NominalDiffTime Source #

Serial UTCTime Source #

    >>> (runGetL deserialize $ runPutL $ serialize (read "2014-01-01 10:54:42.478031 UTC"::UTCTime))::UTCTime
    2014-01-01 10:54:42.478031 UTC

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => UTCTime -> m () Source # deserialize :: MonadGet m => m UTCTime Source #

Serial UniversalTime Source #

    >>> getModJulianDate $ (runGetL deserialize $ runPutL $ serialize (ModJulianDate $ 5 % 11)::UniversalTime)
    5 % 11

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => UniversalTime -> m () Source # deserialize :: MonadGet m => m UniversalTime Source #
Serial LocalTime Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => LocalTime -> m () Source # deserialize :: MonadGet m => m LocalTime Source #
Serial TimeOfDay Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => TimeOfDay -> m () Source # deserialize :: MonadGet m => m TimeOfDay Source #
Serial TimeZone Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => TimeZone -> m () Source # deserialize :: MonadGet m => m TimeZone Source #
Serial ZonedTime Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => ZonedTime -> m () Source # deserialize :: MonadGet m => m ZonedTime Source #

Serial Integer Source #

    >>> (runGetL deserialize $ runPutL $ serialize (1822304234^100::Integer))::Integer

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Integer -> m () Source # deserialize :: MonadGet m => m Integer Source #

Serial Natural Source #

    >>> runGetL deserialize (runPutL (serialize (10^10::Natural))) :: Natural
    10000000000

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Natural -> m () Source # deserialize :: MonadGet m => m Natural Source #
Serial () Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => () -> m () Source # deserialize :: MonadGet m => m () Source #
Serial Bool Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Bool -> m () Source # deserialize :: MonadGet m => m Bool Source #
Serial Char Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Char -> m () Source # deserialize :: MonadGet m => m Char Source #
Serial Double Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Double -> m () Source # deserialize :: MonadGet m => m Double Source #
Serial Float Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Float -> m () Source # deserialize :: MonadGet m => m Float Source #
Serial Int Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Int -> m () Source # deserialize :: MonadGet m => m Int Source #
Serial Word Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Word -> m () Source # deserialize :: MonadGet m => m Word Source #

(Bits n, Integral n, Bits (Unsigned n), Integral (Unsigned n)) => Serial (VarInt n) Source #

Integer/Word types serialized to base-128 variable-width ints.

    >>> import Data.Monoid (mconcat)
    >>> import qualified Data.ByteString.Lazy as BSL
    >>> mconcat $ BSL.toChunks $ runPutL $ serialize (97 :: Word64)
    "\NUL\NUL\NUL\NUL\NUL\NUL\NULa"
    >>> mconcat $ BSL.toChunks $ runPutL $ serialize (97 :: VarInt Word64)
    "a"

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => VarInt n -> m () Source # deserialize :: MonadGet m => m (VarInt n) Source #
Serial v => Serial (IntMap v) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => IntMap v -> m () Source # deserialize :: MonadGet m => m (IntMap v) Source #
Serial a => Serial (Seq a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Seq a -> m () Source # deserialize :: MonadGet m => m (Seq a) Source #
(Serial a, Ord a) => Serial (Set a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Set a -> m () Source # deserialize :: MonadGet m => m (Set a) Source #
Serial a => Serial (NonEmpty a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => NonEmpty a -> m () Source # deserialize :: MonadGet m => m (NonEmpty a) Source #
Serial a => Serial (Identity a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Identity a -> m () Source # deserialize :: MonadGet m => m (Identity a) Source #
Serial a => Serial (First a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => First a -> m () Source # deserialize :: MonadGet m => m (First a) Source #
Serial a => Serial (Last a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Last a -> m () Source # deserialize :: MonadGet m => m (Last a) Source #
Serial a => Serial (Down a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Down a -> m () Source # deserialize :: MonadGet m => m (Down a) Source #
Serial a => Serial (Dual a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Dual a -> m () Source # deserialize :: MonadGet m => m (Dual a) Source #
Serial a => Serial (Product a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Product a -> m () Source # deserialize :: MonadGet m => m (Product a) Source #
Serial a => Serial (Sum a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Sum a -> m () Source # deserialize :: MonadGet m => m (Sum a) Source #
Serial a => Serial (ZipList a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => ZipList a -> m () Source # deserialize :: MonadGet m => m (ZipList a) Source #

(Serial a, Integral a) => Serial (Ratio a) Source #

    >>> (runGetL deserialize $ runPutL $ serialize (5 % 11::Ratio Int))::Ratio Int
    5 % 11

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Ratio a -> m () Source # deserialize :: MonadGet m => m (Ratio a) Source #
(Serial v, Hashable v, Eq v) => Serial (HashSet v) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => HashSet v -> m () Source # deserialize :: MonadGet m => m (HashSet v) Source #
Serial a => Serial (Maybe a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Maybe a -> m () Source # deserialize :: MonadGet m => m (Maybe a) Source #
Serial a => Serial [a] Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => [a] -> m () Source # deserialize :: MonadGet m => m [a] Source #

HasResolution a => Serial (Fixed a) Source #

    >>> (runGetL deserialize $ runPutL $ serialize (1.82::Fixed E2))::Fixed E2
    1.82

Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Fixed a -> m () Source # deserialize :: MonadGet m => m (Fixed a) Source #
(Serial k, Serial v, Ord k) => Serial (Map k v) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Map k v -> m () Source # deserialize :: MonadGet m => m (Map k v) Source #
(Serial a, Serial b) => Serial (Either a b) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Either a b -> m () Source # deserialize :: MonadGet m => m (Either a b) Source #
(Serial k, Serial v, Hashable k, Eq k) => Serial (HashMap k v) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => HashMap k v -> m () Source # deserialize :: MonadGet m => m (HashMap k v) Source #
(Serial a, Serial b) => Serial (a, b) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => (a, b) -> m () Source # deserialize :: MonadGet m => m (a, b) Source #
Serial a => Serial (Constant a b) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Constant a b -> m () Source # deserialize :: MonadGet m => m (Constant a b) Source #
Serial (f a) => Serial (Reverse f a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Reverse f a -> m () Source # deserialize :: MonadGet m => m (Reverse f a) Source #
(Serial a, Serial b, Serial c) => Serial (a, b, c) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => (a, b, c) -> m () Source # deserialize :: MonadGet m => m (a, b, c) Source #
(Serial (f a), Serial (g a)) => Serial (Product f g a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => Product f g a -> m () Source # deserialize :: MonadGet m => m (Product f g a) Source #
(Serial a, Serial b, Serial c, Serial d) => Serial (a, b, c, d) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => (a, b, c, d) -> m () Source # deserialize :: MonadGet m => m (a, b, c, d) Source #
(Serial a, Serial b, Serial c, Serial d, Serial e) => Serial (a, b, c, d, e) Source # |
Instance details Defined in Data.Bytes.Serial Methods serialize :: MonadPut m => (a, b, c, d, e) -> m () Source # deserialize :: MonadGet m => m (a, b, c, d, e) Source #

# Specifying endianness

class SerialEndian a where Source #

Methods to serialize and deserialize type `a` to a big and little endian binary representations. Methods suffixed with "host" are automatically defined to use equal the methods corresponding to the current machine's native endianness, but they can be overridden.

Minimal complete definition

Nothing

Methods

serializeBE :: MonadPut m => a -> m () Source #

default serializeBE :: (MonadPut m, GSerialEndian (Rep a), Generic a) => a -> m () Source #

deserializeBE :: MonadGet m => m a Source #

default deserializeBE :: (MonadGet m, GSerialEndian (Rep a), Generic a) => m a Source #

serializeLE :: MonadPut m => a -> m () Source #

default serializeLE :: (MonadPut m, GSerialEndian (Rep a), Generic a) => a -> m () Source #

deserializeLE :: MonadGet m => m a Source #

default deserializeLE :: (MonadGet m, GSerialEndian (Rep a), Generic a) => m a Source #

serializeHost :: MonadPut m => a -> m () Source #

deserializeHost :: MonadGet m => m a Source #

#### Instances

Instances details

SerialEndian Int16 Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Int16 -> m () Source # deserializeBE :: MonadGet m => m Int16 Source # serializeLE :: MonadPut m => Int16 -> m () Source # deserializeLE :: MonadGet m => m Int16 Source # serializeHost :: MonadPut m => Int16 -> m () Source # deserializeHost :: MonadGet m => m Int16 Source #
SerialEndian Int32 Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Int32 -> m () Source # deserializeBE :: MonadGet m => m Int32 Source # serializeLE :: MonadPut m => Int32 -> m () Source # deserializeLE :: MonadGet m => m Int32 Source # serializeHost :: MonadPut m => Int32 -> m () Source # deserializeHost :: MonadGet m => m Int32 Source #
SerialEndian Int64 Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Int64 -> m () Source # deserializeBE :: MonadGet m => m Int64 Source # serializeLE :: MonadPut m => Int64 -> m () Source # deserializeLE :: MonadGet m => m Int64 Source # serializeHost :: MonadPut m => Int64 -> m () Source # deserializeHost :: MonadGet m => m Int64 Source #
SerialEndian Word16 Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Word16 -> m () Source # deserializeBE :: MonadGet m => m Word16 Source # serializeLE :: MonadPut m => Word16 -> m () Source # deserializeLE :: MonadGet m => m Word16 Source # serializeHost :: MonadPut m => Word16 -> m () Source # deserializeHost :: MonadGet m => m Word16 Source #
SerialEndian Word32 Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Word32 -> m () Source # deserializeBE :: MonadGet m => m Word32 Source # serializeLE :: MonadPut m => Word32 -> m () Source # deserializeLE :: MonadGet m => m Word32 Source # serializeHost :: MonadPut m => Word32 -> m () Source # deserializeHost :: MonadGet m => m Word32 Source #
SerialEndian Word64 Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Word64 -> m () Source # deserializeBE :: MonadGet m => m Word64 Source # serializeLE :: MonadPut m => Word64 -> m () Source # deserializeLE :: MonadGet m => m Word64 Source # serializeHost :: MonadPut m => Word64 -> m () Source # deserializeHost :: MonadGet m => m Word64 Source #
SerialEndian Char Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Char -> m () Source # deserializeBE :: MonadGet m => m Char Source # serializeLE :: MonadPut m => Char -> m () Source # deserializeLE :: MonadGet m => m Char Source # serializeHost :: MonadPut m => Char -> m () Source # deserializeHost :: MonadGet m => m Char Source #
SerialEndian Double Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Double -> m () Source # deserializeBE :: MonadGet m => m Double Source # serializeLE :: MonadPut m => Double -> m () Source # deserializeLE :: MonadGet m => m Double Source # serializeHost :: MonadPut m => Double -> m () Source # deserializeHost :: MonadGet m => m Double Source #
SerialEndian Float Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeBE :: MonadPut m => Float -> m () Source # deserializeBE :: MonadGet m => m Float Source # serializeLE :: MonadPut m => Float -> m () Source # deserializeLE :: MonadGet m => m Float Source # serializeHost :: MonadPut m => Float -> m () Source # deserializeHost :: MonadGet m => m Float Source #

# Higher-order

These classes provide us with the ability to serialize containers that need polymorphic recursion.

class Serial1 (f :: Type -> Type) where Source #

Minimal complete definition

Nothing

Methods

serializeWith :: MonadPut m => (a -> m ()) -> f a -> m () Source #

default serializeWith :: (MonadPut m, GSerial1 (Rep1 f), Generic1 f) => (a -> m ()) -> f a -> m () Source #

deserializeWith :: MonadGet m => m a -> m (f a) Source #

default deserializeWith :: (MonadGet m, GSerial1 (Rep1 f), Generic1 f) => m a -> m (f a) Source #

#### Instances

Instances details

Serial1 IntMap Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a -> m ()) -> IntMap a -> m () Source # deserializeWith :: MonadGet m => m a -> m (IntMap a) Source #
Serial1 Seq Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a -> m ()) -> Seq a -> m () Source # deserializeWith :: MonadGet m => m a -> m (Seq a) Source #
Serial1 NonEmpty Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a -> m ()) -> NonEmpty a -> m () Source # deserializeWith :: MonadGet m => m a -> m (NonEmpty a) Source #
Serial1 Maybe Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a -> m ()) -> Maybe a -> m () Source # deserializeWith :: MonadGet m => m a -> m (Maybe a) Source #
Serial1 [] Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a -> m ()) -> [a] -> m () Source # deserializeWith :: MonadGet m => m a -> m [a] Source #
(Ord k, Serial k) => Serial1 (Map k) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a -> m ()) -> Map k a -> m () Source # deserializeWith :: MonadGet m => m a -> m (Map k a) Source #
Serial a => Serial1 (Either a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a0 -> m ()) -> Either a a0 -> m () Source # deserializeWith :: MonadGet m => m a0 -> m (Either a a0) Source #
(Hashable k, Eq k, Serial k) => Serial1 (HashMap k) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a -> m ()) -> HashMap k a -> m () Source # deserializeWith :: MonadGet m => m a -> m (HashMap k a) Source #
Serial a => Serial1 ((,) a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a0 -> m ()) -> (a, a0) -> m () Source # deserializeWith :: MonadGet m => m a0 -> m (a, a0) Source #
(Serial a, Serial b) => Serial1 ((,,) a b) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a0 -> m ()) -> (a, b, a0) -> m () Source # deserializeWith :: MonadGet m => m a0 -> m (a, b, a0) Source #
(Serial a, Serial b, Serial c) => Serial1 ((,,,) a b c) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a0 -> m ()) -> (a, b, c, a0) -> m () Source # deserializeWith :: MonadGet m => m a0 -> m (a, b, c, a0) Source #
(Serial a, Serial b, Serial c, Serial d) => Serial1 ((,,,,) a b c d) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith :: MonadPut m => (a0 -> m ()) -> (a, b, c, d, a0) -> m () Source # deserializeWith :: MonadGet m => m a0 -> m (a, b, c, d, a0) Source #

serialize1 :: (MonadPut m, Serial1 f, Serial a) => f a -> m () Source #

deserialize1 :: (MonadGet m, Serial1 f, Serial a) => m (f a) Source #

class Serial2 (f :: Type -> Type -> Type) where Source #

Methods

serializeWith2 :: MonadPut m => (a -> m ()) -> (b -> m ()) -> f a b -> m () Source #

deserializeWith2 :: MonadGet m => m a -> m b -> m (f a b) Source #

#### Instances

Instances details

Serial2 Either Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith2 :: MonadPut m => (a -> m ()) -> (b -> m ()) -> Either a b -> m () Source # deserializeWith2 :: MonadGet m => m a -> m b -> m (Either a b) Source #
Serial2 (,) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith2 :: MonadPut m => (a -> m ()) -> (b -> m ()) -> (a, b) -> m () Source # deserializeWith2 :: MonadGet m => m a -> m b -> m (a, b) Source #
Serial a => Serial2 ((,,) a) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith2 :: MonadPut m => (a0 -> m ()) -> (b -> m ()) -> (a, a0, b) -> m () Source # deserializeWith2 :: MonadGet m => m a0 -> m b -> m (a, a0, b) Source #
(Serial a, Serial b) => Serial2 ((,,,) a b) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith2 :: MonadPut m => (a0 -> m ()) -> (b0 -> m ()) -> (a, b, a0, b0) -> m () Source # deserializeWith2 :: MonadGet m => m a0 -> m b0 -> m (a, b, a0, b0) Source #
(Serial a, Serial b, Serial c) => Serial2 ((,,,,) a b c) Source # |
Instance details Defined in Data.Bytes.Serial Methods serializeWith2 :: MonadPut m => (a0 -> m ()) -> (b0 -> m ()) -> (a, b, c, a0, b0) -> m () Source # deserializeWith2 :: MonadGet m => m a0 -> m b0 -> m (a, b, c, a0, b0) Source #

serialize2 :: (MonadPut m, Serial2 f, Serial a, Serial b) => f a b -> m () Source #

deserialize2 :: (MonadGet m, Serial2 f, Serial a, Serial b) => m (f a b) Source #

# Storable

store :: (MonadPut m, Storable a) => a -> m () Source #

serialize any `Storable` in a host-specific format.

restore :: (MonadGet m, Storable a) => m a Source #

deserialize any `Storable` in a host-specific format.

# Generics

You probably will never need to care that these exist except they provide us with default definitions for `Serial` and `SerialEndian`

class GSerial (f :: Type -> Type) where Source #

Used internally to provide generic serialization

Methods

gserialize :: MonadPut m => f a -> m () Source #

gdeserialize :: MonadGet m => m (f a) Source #

#### Instances

Instances details

GSerial (U1 :: Type -> Type) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserialize :: MonadPut m => U1 a -> m () Source # gdeserialize :: MonadGet m => m (U1 a) Source #
GSerial (V1 :: Type -> Type) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserialize :: MonadPut m => V1 a -> m () Source # gdeserialize :: MonadGet m => m (V1 a) Source #
(GSerial f, GSerial g) => GSerial (f :*: g) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserialize :: MonadPut m => (f :*: g) a -> m () Source # gdeserialize :: MonadGet m => m ((f :*: g) a) Source #
(GSerial f, GSerial g) => GSerial (f :+: g) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserialize :: MonadPut m => (f :+: g) a -> m () Source # gdeserialize :: MonadGet m => m ((f :+: g) a) Source #
Serial a => GSerial (K1 i a :: Type -> Type) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserialize :: MonadPut m => K1 i a a0 -> m () Source # gdeserialize :: MonadGet m => m (K1 i a a0) Source #
GSerial f => GSerial (M1 i c f) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserialize :: MonadPut m => M1 i c f a -> m () Source # gdeserialize :: MonadGet m => m (M1 i c f a) Source #

class GSerialEndian (f :: Type -> Type) where Source #

Used internally to provide generic big-endian serialization

Minimal complete definition

Nothing

Methods

gserializeBE :: MonadPut m => f a -> m () Source #

default gserializeBE :: (MonadPut m, GSerial f) => f a -> m () Source #

gdeserializeBE :: MonadGet m => m (f a) Source #

default gdeserializeBE :: (MonadGet m, GSerial f) => m (f a) Source #

gserializeLE :: MonadPut m => f a -> m () Source #

default gserializeLE :: (MonadPut m, GSerial f) => f a -> m () Source #

gdeserializeLE :: MonadGet m => m (f a) Source #

default gdeserializeLE :: (MonadGet m, GSerial f) => m (f a) Source #

#### Instances

Instances details

SerialEndian a => GSerialEndian (K1 i a :: Type -> Type) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeBE :: MonadPut m => K1 i a a0 -> m () Source # gdeserializeBE :: MonadGet m => m (K1 i a a0) Source # gserializeLE :: MonadPut m => K1 i a a0 -> m () Source # gdeserializeLE :: MonadGet m => m (K1 i a a0) Source #

class GSerial1 (f :: Type -> Type) where Source #

Used internally to provide generic serialization

Methods

gserializeWith :: MonadPut m => (a -> m ()) -> f a -> m () Source #

gdeserializeWith :: MonadGet m => m a -> m (f a) Source #

#### Instances

Instances details

GSerial1 Par1 Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a -> m ()) -> Par1 a -> m () Source # gdeserializeWith :: MonadGet m => m a -> m (Par1 a) Source #
GSerial1 (U1 :: Type -> Type) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a -> m ()) -> U1 a -> m () Source # gdeserializeWith :: MonadGet m => m a -> m (U1 a) Source #
GSerial1 (V1 :: Type -> Type) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a -> m ()) -> V1 a -> m () Source # gdeserializeWith :: MonadGet m => m a -> m (V1 a) Source #
Serial1 f => GSerial1 (Rec1 f) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a -> m ()) -> Rec1 f a -> m () Source # gdeserializeWith :: MonadGet m => m a -> m (Rec1 f a) Source #
(GSerial1 f, GSerial1 g) => GSerial1 (f :*: g) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a -> m ()) -> (f :*: g) a -> m () Source # gdeserializeWith :: MonadGet m => m a -> m ((f :*: g) a) Source #
(GSerial1 f, GSerial1 g) => GSerial1 (f :+: g) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a -> m ()) -> (f :+: g) a -> m () Source # gdeserializeWith :: MonadGet m => m a -> m ((f :+: g) a) Source #
Serial a => GSerial1 (K1 i a :: Type -> Type) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a0 -> m ()) -> K1 i a a0 -> m () Source # gdeserializeWith :: MonadGet m => m a0 -> m (K1 i a a0) Source #
(Serial1 f, GSerial1 g) => GSerial1 (f :.: g) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a -> m ()) -> (f :.: g) a -> m () Source # gdeserializeWith :: MonadGet m => m a -> m ((f :.: g) a) Source #
GSerial1 f => GSerial1 (M1 i c f) Source # |
Instance details Defined in Data.Bytes.Serial Methods gserializeWith :: MonadPut m => (a -> m ()) -> M1 i c f a -> m () Source # gdeserializeWith :: MonadGet m => m a -> m (M1 i c f a) Source #