serialise-0.2.6.0: A binary serialisation library for Haskell values.
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

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

Minimal complete definition

Nothing

Methods

encode :: 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

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

Instances details
Serialise Bool Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Char Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Double Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Float Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Int Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Int8 Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Int16 Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Int32 Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Int64 Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Integer Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Natural Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Ordering Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Word Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Word8 Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Word16 Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Word32 Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Word64 Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise RuntimeRep Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise VecCount Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise VecElem Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise SomeTypeRep Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise () Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise TyCon Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise KindRep Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise TypeLitSort Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Void Source #

Since: 0.2.4.0

Instance details

Defined in Codec.Serialise.Class

Serialise Version Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise ExitCode Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise All Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Any Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CChar Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CSChar Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CUChar Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CShort Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CUShort Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CInt Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CUInt Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CLong Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CULong Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CLLong Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CULLong Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CFloat Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CDouble Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CPtrdiff Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CSize Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CWchar Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CSigAtomic Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CClock Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CTime Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CUSeconds Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CSUSeconds Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CIntPtr Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CUIntPtr Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CIntMax Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise CUIntMax Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Fingerprint Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise ShortByteString Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise ByteString Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise ByteString Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Text Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Term Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise IntSet Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Half Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise Text Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise [a] Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Maybe a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Complex a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Min a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Max a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( First a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Last a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( WrappedMonoid a) Source #
Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Option a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( ZipList a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Identity a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( First a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Last a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Dual a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Sum a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Product a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Down a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( NonEmpty a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( IntMap a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Tree a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Seq a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Maybe a) Source #

Since: 0.2.4.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => Serialise ( Vector a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Typeable a => Serialise ( TypeRep a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise ( Fixed e) Source #

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise ( Proxy a) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.4.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.4.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.4.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.4.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

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

Instance details

Defined in Codec.Serialise.Class

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

Instance details

Defined in Codec.Serialise.Class

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

Instance details

Defined in Codec.Serialise.Class

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

Instance details

Defined in Codec.Serialise.Class

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

Methods

gencode :: f a -> Encoding Source #

Since: 0.2.0.0

Instances

Instances details
GSerialiseEncode ( U1 :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gencode :: forall (a :: k0). U1 a -> Encoding Source #

GSerialiseEncode ( V1 :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gencode :: forall (a :: k0). V1 a -> Encoding Source #

Serialise a => GSerialiseEncode ( K1 i a :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gencode :: forall (a0 :: k0). K1 i a a0 -> Encoding Source #

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gencode :: forall (a :: k0). (f :*: g) a -> Encoding Source #

( GSerialiseSum f, GSerialiseSum g) => GSerialiseEncode (f :+: g :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gencode :: forall (a :: k0). (f :+: g) a -> Encoding Source #

GSerialiseEncode a => GSerialiseEncode ( M1 i c a :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gencode :: forall (a0 :: k0). M1 i c a a0 -> Encoding Source #

class GSerialiseDecode f where Source #

Since: 0.2.0.0

Methods

gdecode :: Decoder s (f a) Source #

Since: 0.2.0.0

Instances

Instances details
GSerialiseDecode ( U1 :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gdecode :: forall s (a :: k0). Decoder s ( U1 a) Source #

GSerialiseDecode ( V1 :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gdecode :: forall s (a :: k0). Decoder s ( V1 a) Source #

Serialise a => GSerialiseDecode ( K1 i a :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gdecode :: forall s (a0 :: k0). Decoder s ( K1 i a a0) Source #

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gdecode :: forall s (a :: k0). Decoder s ((f :*: g) a) Source #

( GSerialiseSum f, GSerialiseSum g) => GSerialiseDecode (f :+: g :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gdecode :: forall s (a :: k0). Decoder s ((f :+: g) a) Source #

GSerialiseDecode a => GSerialiseDecode ( M1 i c a :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

gdecode :: forall s (a0 :: k0). Decoder s ( M1 i c a a0) Source #

class GSerialiseProd f where Source #

Serialization of product types

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

Instances details
GSerialiseProd ( U1 :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Serialise a => GSerialiseProd ( K1 i a :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

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

encodeSeq :: forall (a0 :: k0). K1 i a a0 -> Encoding Source #

gdecodeSeq :: forall s (a0 :: k0). Decoder s ( K1 i a a0) Source #

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

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

(i ~ S , GSerialiseProd f) => GSerialiseProd ( M1 i c f :: k -> Type ) Source #

Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

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

encodeSeq :: forall (a :: k0). M1 i c f a -> Encoding Source #

gdecodeSeq :: forall s (a :: k0). Decoder s ( M1 i c 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

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

encodeContainerSkel Source #

Arguments

:: ( Word -> Encoding )

encoder of the length

-> (container -> Int )

length

-> (accumFunc -> Encoding -> container -> Encoding )

foldr

-> accumFunc
-> container
-> Encoding

Patch functions together to obtain an Encoding for a container.

encodeMapSkel Source #

Arguments

:: ( Serialise k, Serialise v)
=> (m -> Int )

obtain the length

-> ((k -> v -> Encoding -> Encoding ) -> Encoding -> m -> Encoding )
-> m
-> Encoding

A helper function for encoding maps.

decodeMapSkel Source #

Arguments

:: ( Serialise k, Serialise v)
=> ([(k, v)] -> m)

fromList

-> Decoder s m

A utility function to construct a Decoder for maps.