Copyright | Lennart Kolmodin Galois Inc. 2009 |
---|---|
License | BSD3-style (see LICENSE) |
Maintainer | Trevor Elliott <trevor@galois.com> |
Stability | |
Portability | |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- class Serialize t where
- encode :: Serialize a => a -> ByteString
- encodeLazy :: Serialize a => a -> ByteString
- decode :: Serialize a => ByteString -> Either String a
- decodeLazy :: Serialize a => ByteString -> Either String a
- expect :: (Eq a, Serialize a) => a -> Get a
- module Data.Serialize.Get
- module Data.Serialize.Put
- module Data.Serialize.IEEE754
- class GSerializePut f where
- class GSerializeGet f where
The Serialize class
class Serialize t where Source #
If your compiler has support for the DeriveGeneric
and
DefaultSignatures
language extensions (ghc >= 7.2.1
), the put
and get
methods will have default generic implementations.
To use this option, simply add a deriving
clause to your datatype
and declare a Generic
Serialize
instance for it without giving a definition for
put
and get
.
Nothing
Encode a value in the Put monad.
Decode a value in the Get monad
Instances
Serialize serialisation
encode :: Serialize a => a -> ByteString Source #
Encode a value using binary serialization to a strict ByteString.
encodeLazy :: Serialize a => a -> ByteString Source #
Encode a value using binary serialization to a lazy ByteString.
decode :: Serialize a => ByteString -> Either String a Source #
Decode a value from a strict ByteString, reconstructing the original structure.
decodeLazy :: Serialize a => ByteString -> Either String a Source #
Decode a value from a lazy ByteString, reconstructing the original structure.
expect :: (Eq a, Serialize a) => a -> Get a Source #
Perform an action, failing if the read result does not match the argument provided.
module Data.Serialize.Get
module Data.Serialize.Put
module Data.Serialize.IEEE754
Generic deriving
class GSerializePut f where Source #
Instances
GSerializePut (V1 :: Type -> Type) Source # | Always fails to serialize |
GSerializePut (U1 :: Type -> Type) Source # | |
Serialize a => GSerializePut (K1 i a :: Type -> Type) Source # | |
(PutSum a, PutSum b, SumSize a, SumSize b) => GSerializePut (a :+: b) Source # | |
(GSerializePut a, GSerializePut b) => GSerializePut (a :*: b) Source # | |
GSerializePut a => GSerializePut (M1 i c a) Source # | |
class GSerializeGet f where Source #
Instances
GSerializeGet (V1 :: Type -> Type) Source # | Always fails to deserialize |
GSerializeGet (U1 :: Type -> Type) Source # | |
Serialize a => GSerializeGet (K1 i a :: Type -> Type) Source # | |
(GetSum a, GetSum b, SumSize a, SumSize b) => GSerializeGet (a :+: b) Source # | |
(GSerializeGet a, GSerializeGet b) => GSerializeGet (a :*: b) Source # | |
GSerializeGet a => GSerializeGet (M1 i c a) Source # | |