serialise-0.2.0.0: A binary serialisation library for Haskell values.

Copyright(c) Duncan Coutts 2015-2017
LicenseBSD3-style (see LICENSE.txt)
Maintainerduncan@community.haskell.org
Stabilityexperimental
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Codec.Serialise.Class

Contents

Description

The Serialise class allows you to encode a given type into a CBOR object, or decode a CBOR object into the user-specified type.

Synopsis

The Serialise class

class Serialise a where Source #

Types that are instances of the Serialise class allow values to be quickly encoded or decoded directly to a CBOR representation, for object transmission or storage.

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 Decoder for a type.

Since: 0.2.0.0

decode :: (Generic a, GSerialiseDecode (Rep a)) => Decoder s a Source #

Definition of a given Decoder for a type.

Since: 0.2.0.0

encodeList :: [a] -> Encoding Source #

Utility to support specialised encoding for some list type - used for Char/String instances in this package.

Since: 0.2.0.0

decodeList :: Decoder s [a] Source #

Utility to support specialised decoding for some list type - used for Char/String instances in this package.

Since: 0.2.0.0

Instances

Serialise Bool Source #

Since: 0.2.0.0

Serialise Char Source #

Since: 0.2.0.0

Serialise Double Source #

Since: 0.2.0.0

Serialise Float Source #

Since: 0.2.0.0

Serialise Int Source #

Since: 0.2.0.0

Serialise Int8 Source #

Since: 0.2.0.0

Serialise Int16 Source #

Since: 0.2.0.0

Serialise Int32 Source #

Since: 0.2.0.0

Serialise Int64 Source #

Since: 0.2.0.0

Serialise Integer Source #

Since: 0.2.0.0

Serialise Ordering Source #

Since: 0.2.0.0

Serialise Word Source #

Since: 0.2.0.0

Serialise Word8 Source #

Since: 0.2.0.0

Serialise Word16 Source #

Since: 0.2.0.0

Serialise Word32 Source #

Since: 0.2.0.0

Serialise Word64 Source #

Since: 0.2.0.0

Serialise TypeRep Source #

Since: 0.2.0.0

Serialise () Source #

Since: 0.2.0.0

Serialise TyCon Source #

Since: 0.2.0.0

Serialise Natural Source #

Since: 0.2.0.0

Serialise Version Source #

Since: 0.2.0.0

Serialise ExitCode Source #

Since: 0.2.0.0

Serialise CChar Source #

Since: 0.2.0.0

Serialise CSChar Source #

Since: 0.2.0.0

Serialise CUChar Source #

Since: 0.2.0.0

Serialise CShort Source #

Since: 0.2.0.0

Serialise CUShort Source #

Since: 0.2.0.0

Serialise CInt Source #

Since: 0.2.0.0

Serialise CUInt Source #

Since: 0.2.0.0

Serialise CLong Source #

Since: 0.2.0.0

Serialise CULong Source #

Since: 0.2.0.0

Serialise CLLong Source #

Since: 0.2.0.0

Serialise CULLong Source #

Since: 0.2.0.0

Serialise CFloat Source #

Since: 0.2.0.0

Serialise CDouble Source #

Since: 0.2.0.0

Serialise CPtrdiff Source #

Since: 0.2.0.0

Serialise CSize Source #

Since: 0.2.0.0

Serialise CWchar Source #

Since: 0.2.0.0

Serialise CSigAtomic Source #

Since: 0.2.0.0

Serialise CClock Source #

Since: 0.2.0.0

Serialise CTime Source #

Since: 0.2.0.0

Serialise CUSeconds Source #

Since: 0.2.0.0

Serialise CSUSeconds Source #

Since: 0.2.0.0

Serialise CIntPtr Source #

Since: 0.2.0.0

Serialise CUIntPtr Source #

Since: 0.2.0.0

Serialise CIntMax Source #

Since: 0.2.0.0

Serialise CUIntMax Source #

Since: 0.2.0.0

Serialise All Source #

Since: 0.2.0.0

Serialise Any Source #

Since: 0.2.0.0

Serialise Fingerprint Source #

Since: 0.2.0.0

Serialise ShortByteString Source #

Since: 0.2.0.0

Serialise ByteString Source #

Since: 0.2.0.0

Serialise ByteString Source #

Since: 0.2.0.0

Serialise Text Source #

Since: 0.2.0.0

Serialise Term Source #

Since: 0.2.0.0

Serialise IntSet Source #

Since: 0.2.0.0

Serialise Half Source #

Since: 0.2.0.0

Serialise Text Source #

Since: 0.2.0.0

Serialise UTCTime Source #

UTCTime is encoded using the extended time format which is currently in Internet Draft state, https://tools.ietf.org/html/draft-bormann-cbor-time-tag-00.

Since: 0.2.0.0

Serialise a => Serialise [a] Source #

Since: 0.2.0.0

Methods

encode :: [a] -> Encoding Source #

decode :: Decoder s [a] Source #

encodeList :: [[a]] -> Encoding Source #

decodeList :: Decoder s [[a]] Source #

Serialise a => Serialise (Maybe a) Source #

Since: 0.2.0.0

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

Since: 0.2.0.0

Serialise a => Serialise (Identity a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Min a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Max a) Source #

Since: 0.2.0.0

Serialise a => Serialise (First a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Last a) Source #

Since: 0.2.0.0

Serialise a => Serialise (WrappedMonoid a) Source # 
Serialise a => Serialise (Option a) Source #

Since: 0.2.0.0

Serialise a => Serialise (NonEmpty a) Source #

Since: 0.2.0.0

Serialise (Fixed e) Source #

Values are serialised in units of least precision represented as Integer.

Since: 0.2.0.0

Serialise a => Serialise (Complex a) Source #

Since: 0.2.0.0

Serialise a => Serialise (ZipList a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Dual a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Sum a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Product a) Source #

Since: 0.2.0.0

Serialise a => Serialise (First a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Last a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Down a) Source #

Since: 0.2.0.0

Serialise a => Serialise (IntMap a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Tree a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Seq a) Source #

Since: 0.2.0.0

(Ord a, Serialise a) => Serialise (Set a) Source #

Since: 0.2.0.0

(Serialise a, Hashable a, Eq a) => Serialise (HashSet a) Source #

Since: 0.2.0.0

Serialise a => Serialise (Vector a) Source #

Since: 0.2.0.0

(Serialise a, Storable a) => Serialise (Vector a) Source #

Since: 0.2.0.0

(Serialise a, Unbox a) => Serialise (Vector a) Source #

Since: 0.2.0.0

(Serialise a, Prim a) => Serialise (Vector a) Source #

Since: 0.2.0.0

(Serialise a, Serialise b) => Serialise (Either a b) Source #

Since: 0.2.0.0

(Serialise a, Serialise b) => Serialise (a, b) Source #

Since: 0.2.0.0

Methods

encode :: (a, b) -> Encoding Source #

decode :: Decoder s (a, b) Source #

encodeList :: [(a, b)] -> Encoding Source #

decodeList :: Decoder s [(a, b)] Source #

Serialise (Proxy k a) Source #

Since: 0.2.0.0

(Ord k, Serialise k, Serialise v) => Serialise (Map k v) Source #

Since: 0.2.0.0

(Serialise k, Hashable k, Eq k, Serialise v) => Serialise (HashMap k v) Source #

Since: 0.2.0.0

(Serialise a, Serialise b, Serialise c) => Serialise (a, b, c) Source #

Since: 0.2.0.0

Methods

encode :: (a, b, c) -> Encoding Source #

decode :: Decoder s (a, b, c) Source #

encodeList :: [(a, b, c)] -> Encoding Source #

decodeList :: Decoder s [(a, b, c)] Source #

Serialise a => Serialise (Const k a b) Source #

Since: 0.2.0.0

Methods

encode :: Const k a b -> Encoding Source #

decode :: Decoder s (Const k a b) Source #

encodeList :: [Const k a b] -> Encoding Source #

decodeList :: Decoder s [Const k a b] Source #

Serialise (f a) => Serialise (Alt k f a) Source #

Since: 0.2.0.0

Methods

encode :: Alt k f a -> Encoding Source #

decode :: Decoder s (Alt k f a) Source #

encodeList :: [Alt k f a] -> Encoding Source #

decodeList :: Decoder s [Alt k f a] Source #

(Serialise a, Serialise b, Serialise c, Serialise d) => Serialise (a, b, c, d) Source #

Since: 0.2.0.0

Methods

encode :: (a, b, c, d) -> Encoding Source #

decode :: Decoder s (a, b, c, d) Source #

encodeList :: [(a, b, c, d)] -> Encoding Source #

decodeList :: Decoder s [(a, b, c, d)] Source #

(Serialise a, Serialise b, Serialise c, Serialise d, Serialise e) => Serialise (a, b, c, d, e) Source #

Since: 0.2.0.0

Methods

encode :: (a, b, c, d, e) -> Encoding Source #

decode :: Decoder s (a, b, c, d, e) Source #

encodeList :: [(a, b, c, d, e)] -> Encoding Source #

decodeList :: Decoder s [(a, b, c, d, e)] Source #

(Serialise a, Serialise b, Serialise c, Serialise d, Serialise e, Serialise f) => Serialise (a, b, c, d, e, f) Source #

Since: 0.2.0.0

Methods

encode :: (a, b, c, d, e, f) -> Encoding Source #

decode :: Decoder s (a, b, c, d, e, f) Source #

encodeList :: [(a, b, c, d, e, f)] -> Encoding Source #

decodeList :: Decoder s [(a, b, c, d, e, f)] Source #

(Serialise a, Serialise b, Serialise c, Serialise d, Serialise e, Serialise f, Serialise g) => Serialise (a, b, c, d, e, f, g) Source #

Since: 0.2.0.0

Methods

encode :: (a, b, c, d, e, f, g) -> Encoding Source #

decode :: Decoder s (a, b, c, d, e, f, g) Source #

encodeList :: [(a, b, c, d, e, f, g)] -> Encoding Source #

decodeList :: Decoder s [(a, b, c, d, e, f, g)] Source #

(Serialise a, Serialise b, Serialise c, Serialise d, Serialise e, Serialise f, Serialise g, Serialise h) => Serialise (a, b, c, d, e, f, g, h) Source #

Since: 0.2.0.0

Methods

encode :: (a, b, c, d, e, f, g, h) -> Encoding Source #

decode :: Decoder s (a, b, c, d, e, f, g, h) Source #

encodeList :: [(a, b, c, d, e, f, g, h)] -> Encoding Source #

decodeList :: Decoder s [(a, b, c, d, e, f, g, h)] Source #

(Serialise a, Serialise b, Serialise c, Serialise d, Serialise e, Serialise f, Serialise g, Serialise h, Serialise i) => Serialise (a, b, c, d, e, f, g, h, i) Source #

Since: 0.2.0.0

Methods

encode :: (a, b, c, d, e, f, g, h, i) -> Encoding Source #

decode :: Decoder s (a, b, c, d, e, f, g, h, i) Source #

encodeList :: [(a, b, c, d, e, f, g, h, i)] -> Encoding Source #

decodeList :: Decoder s [(a, b, c, d, e, f, g, h, i)] Source #

class GSerialiseEncode f where Source #

Since: 0.2.0.0

Minimal complete definition

gencode

Methods

gencode :: f a -> Encoding Source #

Since: 0.2.0.0

Instances

GSerialiseEncode * V1 Source #

Since: 0.2.0.0

Methods

gencode :: f a -> Encoding Source #

GSerialiseEncode * U1 Source #

Since: 0.2.0.0

Methods

gencode :: f a -> Encoding Source #

Serialise a => GSerialiseEncode * (K1 i a) Source #

Since: 0.2.0.0

Methods

gencode :: f a -> Encoding Source #

(GSerialiseSum * f, GSerialiseSum * g) => GSerialiseEncode * ((:+:) f g) Source #

Since: 0.2.0.0

Methods

gencode :: f a -> Encoding Source #

(GSerialiseProd * f, GSerialiseProd * g) => GSerialiseEncode * ((:*:) f g) Source #

Since: 0.2.0.0

Methods

gencode :: f a -> Encoding Source #

GSerialiseEncode * a => GSerialiseEncode * (M1 i c a) Source #

Since: 0.2.0.0

Methods

gencode :: f a -> Encoding Source #

class GSerialiseDecode f where Source #

Since: 0.2.0.0

Minimal complete definition

gdecode

Methods

gdecode :: Decoder s (f a) Source #

Since: 0.2.0.0

Instances

GSerialiseDecode * V1 Source #

Since: 0.2.0.0

Methods

gdecode :: Decoder s (f a) Source #

GSerialiseDecode * U1 Source #

Since: 0.2.0.0

Methods

gdecode :: Decoder s (f a) Source #

Serialise a => GSerialiseDecode * (K1 i a) Source #

Since: 0.2.0.0

Methods

gdecode :: Decoder s (f a) Source #

(GSerialiseSum * f, GSerialiseSum * g) => GSerialiseDecode * ((:+:) f g) Source #

Since: 0.2.0.0

Methods

gdecode :: Decoder s (f a) Source #

(GSerialiseProd * f, GSerialiseProd * g) => GSerialiseDecode * ((:*:) f g) Source #

Since: 0.2.0.0

Methods

gdecode :: Decoder s (f a) Source #

GSerialiseDecode * a => GSerialiseDecode * (M1 i c a) Source #

Since: 0.2.0.0

Methods

gdecode :: Decoder s (f a) Source #

class GSerialiseProd f where Source #

Serialization of product types

Minimal complete definition

nFields, encodeSeq, gdecodeSeq

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

Methods

nFields :: Proxy (U1 -> *) f -> Word Source #

encodeSeq :: f a -> Encoding Source #

gdecodeSeq :: Decoder s (f a) Source #

Serialise a => GSerialiseProd * (K1 i a) Source #

Since: 0.2.0.0

Methods

nFields :: Proxy (K1 i a -> *) f -> Word Source #

encodeSeq :: f a -> Encoding Source #

gdecodeSeq :: Decoder s (f a) Source #

(GSerialiseProd * f, GSerialiseProd * g) => GSerialiseProd * ((:*:) f g) Source #

Since: 0.2.0.0

Methods

nFields :: Proxy ((f :*: g) -> *) f -> Word Source #

encodeSeq :: f a -> Encoding Source #

gdecodeSeq :: Decoder s (f a) Source #

((~) * i S, GSerialiseProd * f) => GSerialiseProd * (M1 i c f) Source #

Since: 0.2.0.0

Methods

nFields :: Proxy (M1 i c f -> *) f -> Word Source #

encodeSeq :: f a -> Encoding Source #

gdecodeSeq :: Decoder s (f a) Source #

class GSerialiseSum f where Source #

Serialization of sum types

Since: 0.2.0.0

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

Methods

conNumber :: f a -> Word Source #

numOfFields :: f a -> Word Source #

encodeSum :: f a -> Encoding Source #

decodeSum :: Word -> Decoder s (f a) Source #

nConstructors :: Proxy ((f :+: g) -> *) f -> Word Source #

fieldsForCon :: Proxy ((f :+: g) -> *) f -> Word -> Decoder s Word Source #

((~) * i C, GSerialiseProd * f) => GSerialiseSum * (M1 i c f) Source #

Since: 0.2.0.0

Methods

conNumber :: f a -> Word Source #

numOfFields :: f a -> Word Source #

encodeSum :: f a -> Encoding Source #

decodeSum :: Word -> Decoder s (f a) Source #

nConstructors :: Proxy (M1 i c f -> *) f -> Word Source #

fieldsForCon :: Proxy (M1 i c f -> *) f -> Word -> Decoder s Word Source #

encodeVector :: (Serialise a, Vector v a) => v a -> Encoding Source #

Generic encoder for vectors. Its intended use is to allow easy definition of Serialise instances for custom vector

Since: 0.2.0.0

decodeVector :: (Serialise a, Vector v a) => Decoder s (v a) Source #

Generic decoder for vectors. Its intended use is to allow easy definition of Serialise instances for custom vector

Since: 0.2.0.0