| Copyright | (c) Duncan Coutts 2015-2017 | 
|---|---|
| License | BSD3-style (see LICENSE.txt) | 
| Maintainer | duncan@community.haskell.org | 
| Stability | experimental | 
| Portability | non-portable (GHC extensions) | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Codec.Serialise.Class
Contents
Description
The  class allows you to encode a given type into a
 CBOR object, or decode a CBOR object into the user-specified type.Serialise
- class Serialise a where
 - class GSerialiseEncode f where
 - class GSerialiseDecode f where
 - class GSerialiseProd f where
 - class GSerialiseSum f where
 - encodeVector :: (Serialise a, Vector v a) => v a -> Encoding
 - decodeVector :: (Serialise a, Vector v a) => Decoder s (v a)
 
The Serialise class
class Serialise a where Source #
Types that are instances of the  class allow values
 to be quickly encoded or decoded directly to a CBOR representation,
 for object transmission or storage.Serialise
Since: 0.2.0.0
Methods
encode :: a -> Encoding Source #
Definition for encoding a given type into a binary
 representation, using the Encoding.Monoid
Since: 0.2.0.0
encode :: (Generic a, GSerialiseEncode (Rep a)) => a -> Encoding Source #
Definition for encoding a given type into a binary
 representation, using the Encoding.Monoid
Since: 0.2.0.0
decode :: Decoder s a Source #
Definition of a given  for a type.Decoder
Since: 0.2.0.0
decode :: (Generic a, GSerialiseDecode (Rep a)) => Decoder s a Source #
Definition of a given  for a type.Decoder
Since: 0.2.0.0
encodeList :: [a] -> Encoding Source #
Utility to support specialised encoding for some list type -
 used for /Char instances in this package.String
Since: 0.2.0.0
decodeList :: Decoder s [a] Source #
Instances
class GSerialiseEncode f where Source #
Since: 0.2.0.0
Minimal complete definition
Instances
| GSerialiseEncode * V1 Source # | Since: 0.2.0.0  | 
| GSerialiseEncode * U1 Source # | Since: 0.2.0.0  | 
| Serialise a => GSerialiseEncode * (K1 i a) Source # | Since: 0.2.0.0  | 
| (GSerialiseSum * f, GSerialiseSum * g) => GSerialiseEncode * ((:+:) f g) Source # | Since: 0.2.0.0  | 
| (GSerialiseProd * f, GSerialiseProd * g) => GSerialiseEncode * ((:*:) f g) Source # | Since: 0.2.0.0  | 
| GSerialiseEncode * a => GSerialiseEncode * (M1 i c a) Source # | Since: 0.2.0.0  | 
class GSerialiseDecode f where Source #
Since: 0.2.0.0
Minimal complete definition
Instances
| GSerialiseDecode * V1 Source # | Since: 0.2.0.0  | 
| GSerialiseDecode * U1 Source # | Since: 0.2.0.0  | 
| Serialise a => GSerialiseDecode * (K1 i a) Source # | Since: 0.2.0.0  | 
| (GSerialiseSum * f, GSerialiseSum * g) => GSerialiseDecode * ((:+:) f g) Source # | Since: 0.2.0.0  | 
| (GSerialiseProd * f, GSerialiseProd * g) => GSerialiseDecode * ((:*:) f g) Source # | Since: 0.2.0.0  | 
| GSerialiseDecode * a => GSerialiseDecode * (M1 i c a) Source # | Since: 0.2.0.0  | 
class GSerialiseProd f where Source #
Serialization of product types
Minimal complete definition
Methods
nFields :: Proxy f -> Word Source #
Number of fields in product type
encodeSeq :: f a -> Encoding Source #
Encode fields sequentially without writing header
gdecodeSeq :: Decoder s (f a) Source #
Decode fields sequentially without reading header
Instances
| GSerialiseProd * U1 Source # | Since: 0.2.0.0  | 
| Serialise a => GSerialiseProd * (K1 i a) Source # | Since: 0.2.0.0  | 
| (GSerialiseProd * f, GSerialiseProd * g) => GSerialiseProd * ((:*:) f g) Source # | Since: 0.2.0.0  | 
| ((~) * i S, GSerialiseProd * f) => GSerialiseProd * (M1 i c f) Source # | Since: 0.2.0.0  | 
class GSerialiseSum f where Source #
Serialization of sum types
Since: 0.2.0.0
Minimal complete definition
conNumber, numOfFields, encodeSum, decodeSum, nConstructors, fieldsForCon
Methods
conNumber :: f a -> Word Source #
Number of constructor of given value
numOfFields :: f a -> Word Source #
Number of fields of given value
encodeSum :: f a -> Encoding Source #
Encode field
decodeSum :: Word -> Decoder s (f a) Source #
Decode field
nConstructors :: Proxy f -> Word Source #
Number of constructors
fieldsForCon :: Proxy f -> Word -> Decoder s Word Source #
Number of fields for given constructor number
Instances
| (GSerialiseSum * f, GSerialiseSum * g) => GSerialiseSum * ((:+:) f g) Source # | Since: 0.2.0.0  | 
| ((~) * i C, GSerialiseProd * f) => GSerialiseSum * (M1 i c f) Source # | Since: 0.2.0.0  |