serialise-0.2.3.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

Contents

- The 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

- class Serialise a where
  - encode :: a -> Encoding
  - decode :: Decoder s a
  - encodeList :: [a] -> Encoding
  - decodeList :: Decoder s [a]
- class GSerialiseEncode f where
  - gencode :: f a -> Encoding
- class GSerialiseDecode f where
  - gdecode :: Decoder s (f a)
- class GSerialiseProd f where
  - nFields :: Proxy f -> Word
  - encodeSeq :: f a -> Encoding
  - gdecodeSeq :: Decoder s (f a)
- class GSerialiseSum f where
  - conNumber :: f a -> Word
  - numOfFields :: f a -> Word
  - encodeSum :: f a -> Encoding
  - decodeSum :: Word -> Decoder s (f a)
  - nConstructors :: Proxy f -> Word
  - fieldsForCon :: Proxy f -> Word -> Decoder s Word
- encodeVector :: (Serialise a, Vector v a) => v a -> Encoding
- decodeVector :: (Serialise a, Vector v a) => Decoder s (v a)
- encodeContainerSkel :: (Word -> Encoding) -> (container -> Int) -> (accumFunc -> Encoding -> container -> Encoding) -> accumFunc -> container -> Encoding
- encodeMapSkel :: (Serialise k, Serialise v) => (m -> Int) -> ((k -> v -> Encoding -> Encoding) -> Encoding -> m -> Encoding) -> m -> Encoding
- decodeMapSkel :: (Serialise k, Serialise v) => ([(k, v)] -> m) -> Decoder s m

# 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

default encode :: (Generic a, GSerialiseEncode (Rep a)) => a -> Encoding Source #

decode :: Decoder s a Source #

Definition of a given ``Decoder`` for a type.

Since: 0.2.0.0

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

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 Methods encode :: Bool -> Encoding Source # decode :: Decoder s Bool Source # encodeList :: [Bool] -> Encoding Source # decodeList :: Decoder s [Bool] Source #
Serialise Char Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Char -> Encoding Source # decode :: Decoder s Char Source # encodeList :: [Char] -> Encoding Source # decodeList :: Decoder s [Char] Source #
Serialise Double Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Double -> Encoding Source # decode :: Decoder s Double Source # encodeList :: [Double] -> Encoding Source # decodeList :: Decoder s [Double] Source #
Serialise Float Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Float -> Encoding Source # decode :: Decoder s Float Source # encodeList :: [Float] -> Encoding Source # decodeList :: Decoder s [Float] Source #
Serialise Int Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Int -> Encoding Source # decode :: Decoder s Int Source # encodeList :: [Int] -> Encoding Source # decodeList :: Decoder s [Int] Source #
Serialise Int8 Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Int8 -> Encoding Source # decode :: Decoder s Int8 Source # encodeList :: [Int8] -> Encoding Source # decodeList :: Decoder s [Int8] Source #
Serialise Int16 Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Int16 -> Encoding Source # decode :: Decoder s Int16 Source # encodeList :: [Int16] -> Encoding Source # decodeList :: Decoder s [Int16] Source #
Serialise Int32 Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Int32 -> Encoding Source # decode :: Decoder s Int32 Source # encodeList :: [Int32] -> Encoding Source # decodeList :: Decoder s [Int32] Source #
Serialise Int64 Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Int64 -> Encoding Source # decode :: Decoder s Int64 Source # encodeList :: [Int64] -> Encoding Source # decodeList :: Decoder s [Int64] Source #
Serialise Integer Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Integer -> Encoding Source # decode :: Decoder s Integer Source # encodeList :: [Integer] -> Encoding Source # decodeList :: Decoder s [Integer] Source #
Serialise Natural Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Natural -> Encoding Source # decode :: Decoder s Natural Source # encodeList :: [Natural] -> Encoding Source # decodeList :: Decoder s [Natural] Source #
Serialise Ordering Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Ordering -> Encoding Source # decode :: Decoder s Ordering Source # encodeList :: [Ordering] -> Encoding Source # decodeList :: Decoder s [Ordering] Source #
Serialise Word Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Word -> Encoding Source # decode :: Decoder s Word Source # encodeList :: [Word] -> Encoding Source # decodeList :: Decoder s [Word] Source #
Serialise Word8 Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Word8 -> Encoding Source # decode :: Decoder s Word8 Source # encodeList :: [Word8] -> Encoding Source # decodeList :: Decoder s [Word8] Source #
Serialise Word16 Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Word16 -> Encoding Source # decode :: Decoder s Word16 Source # encodeList :: [Word16] -> Encoding Source # decodeList :: Decoder s [Word16] Source #
Serialise Word32 Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Word32 -> Encoding Source # decode :: Decoder s Word32 Source # encodeList :: [Word32] -> Encoding Source # decodeList :: Decoder s [Word32] Source #
Serialise Word64 Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Word64 -> Encoding Source # decode :: Decoder s Word64 Source # encodeList :: [Word64] -> Encoding Source # decodeList :: Decoder s [Word64] Source #
Serialise RuntimeRep Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: RuntimeRep -> Encoding Source # decode :: Decoder s RuntimeRep Source # encodeList :: [RuntimeRep] -> Encoding Source # decodeList :: Decoder s [RuntimeRep] Source #
Serialise VecCount Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: VecCount -> Encoding Source # decode :: Decoder s VecCount Source # encodeList :: [VecCount] -> Encoding Source # decodeList :: Decoder s [VecCount] Source #
Serialise VecElem Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: VecElem -> Encoding Source # decode :: Decoder s VecElem Source # encodeList :: [VecElem] -> Encoding Source # decodeList :: Decoder s [VecElem] Source #
Serialise SomeTypeRep Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: SomeTypeRep -> Encoding Source # decode :: Decoder s SomeTypeRep Source # encodeList :: [SomeTypeRep] -> Encoding Source # decodeList :: Decoder s [SomeTypeRep] Source #
Serialise () Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: () -> Encoding Source # decode :: Decoder s () Source # encodeList :: [()] -> Encoding Source # decodeList :: Decoder s [()] Source #
Serialise TyCon Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: TyCon -> Encoding Source # decode :: Decoder s TyCon Source # encodeList :: [TyCon] -> Encoding Source # decodeList :: Decoder s [TyCon] Source #
Serialise KindRep Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: KindRep -> Encoding Source # decode :: Decoder s KindRep Source # encodeList :: [KindRep] -> Encoding Source # decodeList :: Decoder s [KindRep] Source #
Serialise TypeLitSort Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: TypeLitSort -> Encoding Source # decode :: Decoder s TypeLitSort Source # encodeList :: [TypeLitSort] -> Encoding Source # decodeList :: Decoder s [TypeLitSort] Source #
Serialise ByteString Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: ByteString -> Encoding Source # decode :: Decoder s ByteString Source # encodeList :: [ByteString] -> Encoding Source # decodeList :: Decoder s [ByteString] Source #
Serialise Text Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Text -> Encoding Source # decode :: Decoder s Text Source # encodeList :: [Text] -> Encoding Source # decodeList :: Decoder s [Text] Source #
Serialise ByteString Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: ByteString -> Encoding Source # decode :: Decoder s ByteString Source # encodeList :: [ByteString] -> Encoding Source # decodeList :: Decoder s [ByteString] Source #
Serialise Term Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Term -> Encoding Source # decode :: Decoder s Term Source # encodeList :: [Term] -> Encoding Source # decodeList :: Decoder s [Term] Source #
Serialise Half Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Half -> Encoding Source # decode :: Decoder s Half Source # encodeList :: [Half] -> Encoding Source # decodeList :: Decoder s [Half] Source #
Serialise CInt Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CInt -> Encoding Source # decode :: Decoder s CInt Source # encodeList :: [CInt] -> Encoding Source # decodeList :: Decoder s [CInt] Source #
Serialise Any Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Any -> Encoding Source # decode :: Decoder s Any Source # encodeList :: [Any] -> Encoding Source # decodeList :: Decoder s [Any] Source #
Serialise CULong Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CULong -> Encoding Source # decode :: Decoder s CULong Source # encodeList :: [CULong] -> Encoding Source # decodeList :: Decoder s [CULong] Source #
Serialise CSize Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CSize -> Encoding Source # decode :: Decoder s CSize Source # encodeList :: [CSize] -> Encoding Source # decodeList :: Decoder s [CSize] Source #
Serialise CChar Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CChar -> Encoding Source # decode :: Decoder s CChar Source # encodeList :: [CChar] -> Encoding Source # decodeList :: Decoder s [CChar] Source #
Serialise ShortByteString Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: ShortByteString -> Encoding Source # decode :: Decoder s ShortByteString Source # encodeList :: [ShortByteString] -> Encoding Source # decodeList :: Decoder s [ShortByteString] Source #
Serialise All Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: All -> Encoding Source # decode :: Decoder s All Source # encodeList :: [All] -> Encoding Source # decodeList :: Decoder s [All] Source #
Serialise CClock Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CClock -> Encoding Source # decode :: Decoder s CClock Source # encodeList :: [CClock] -> Encoding Source # decodeList :: Decoder s [CClock] Source #
Serialise CDouble Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CDouble -> Encoding Source # decode :: Decoder s CDouble Source # encodeList :: [CDouble] -> Encoding Source # decodeList :: Decoder s [CDouble] Source #
Serialise CFloat Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CFloat -> Encoding Source # decode :: Decoder s CFloat Source # encodeList :: [CFloat] -> Encoding Source # decodeList :: Decoder s [CFloat] Source #
Serialise CIntMax Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CIntMax -> Encoding Source # decode :: Decoder s CIntMax Source # encodeList :: [CIntMax] -> Encoding Source # decodeList :: Decoder s [CIntMax] Source #
Serialise CIntPtr Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CIntPtr -> Encoding Source # decode :: Decoder s CIntPtr Source # encodeList :: [CIntPtr] -> Encoding Source # decodeList :: Decoder s [CIntPtr] Source #
Serialise CLLong Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CLLong -> Encoding Source # decode :: Decoder s CLLong Source # encodeList :: [CLLong] -> Encoding Source # decodeList :: Decoder s [CLLong] Source #
Serialise CLong Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CLong -> Encoding Source # decode :: Decoder s CLong Source # encodeList :: [CLong] -> Encoding Source # decodeList :: Decoder s [CLong] Source #
Serialise CPtrdiff Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CPtrdiff -> Encoding Source # decode :: Decoder s CPtrdiff Source # encodeList :: [CPtrdiff] -> Encoding Source # decodeList :: Decoder s [CPtrdiff] Source #
Serialise CSChar Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CSChar -> Encoding Source # decode :: Decoder s CSChar Source # encodeList :: [CSChar] -> Encoding Source # decodeList :: Decoder s [CSChar] Source #
Serialise CSUSeconds Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CSUSeconds -> Encoding Source # decode :: Decoder s CSUSeconds Source # encodeList :: [CSUSeconds] -> Encoding Source # decodeList :: Decoder s [CSUSeconds] Source #
Serialise CShort Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CShort -> Encoding Source # decode :: Decoder s CShort Source # encodeList :: [CShort] -> Encoding Source # decodeList :: Decoder s [CShort] Source #
Serialise CSigAtomic Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CSigAtomic -> Encoding Source # decode :: Decoder s CSigAtomic Source # encodeList :: [CSigAtomic] -> Encoding Source # decodeList :: Decoder s [CSigAtomic] Source #
Serialise CTime Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CTime -> Encoding Source # decode :: Decoder s CTime Source # encodeList :: [CTime] -> Encoding Source # decodeList :: Decoder s [CTime] Source #
Serialise CUChar Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CUChar -> Encoding Source # decode :: Decoder s CUChar Source # encodeList :: [CUChar] -> Encoding Source # decodeList :: Decoder s [CUChar] Source #
Serialise CUInt Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CUInt -> Encoding Source # decode :: Decoder s CUInt Source # encodeList :: [CUInt] -> Encoding Source # decodeList :: Decoder s [CUInt] Source #
Serialise CUIntMax Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CUIntMax -> Encoding Source # decode :: Decoder s CUIntMax Source # encodeList :: [CUIntMax] -> Encoding Source # decodeList :: Decoder s [CUIntMax] Source #
Serialise CUIntPtr Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CUIntPtr -> Encoding Source # decode :: Decoder s CUIntPtr Source # encodeList :: [CUIntPtr] -> Encoding Source # decodeList :: Decoder s [CUIntPtr] Source #
Serialise CULLong Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CULLong -> Encoding Source # decode :: Decoder s CULLong Source # encodeList :: [CULLong] -> Encoding Source # decodeList :: Decoder s [CULLong] Source #
Serialise CUSeconds Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CUSeconds -> Encoding Source # decode :: Decoder s CUSeconds Source # encodeList :: [CUSeconds] -> Encoding Source # decodeList :: Decoder s [CUSeconds] Source #
Serialise CUShort Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CUShort -> Encoding Source # decode :: Decoder s CUShort Source # encodeList :: [CUShort] -> Encoding Source # decodeList :: Decoder s [CUShort] Source #
Serialise CWchar Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: CWchar -> Encoding Source # decode :: Decoder s CWchar Source # encodeList :: [CWchar] -> Encoding Source # decodeList :: Decoder s [CWchar] Source #
Serialise Version Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Version -> Encoding Source # decode :: Decoder s Version Source # encodeList :: [Version] -> Encoding Source # decodeList :: Decoder s [Version] Source #
Serialise IntSet Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: IntSet -> Encoding Source # decode :: Decoder s IntSet Source # encodeList :: [IntSet] -> Encoding Source # decodeList :: Decoder s [IntSet] Source #
Serialise Text Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Text -> Encoding Source # decode :: Decoder s Text Source # encodeList :: [Text] -> Encoding Source # decodeList :: Decoder s [Text] Source #
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 Methods encode :: UTCTime -> Encoding Source # decode :: Decoder s UTCTime Source # encodeList :: [UTCTime] -> Encoding Source # decodeList :: Decoder s [UTCTime] Source #
Serialise ExitCode Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: ExitCode -> Encoding Source # decode :: Decoder s ExitCode Source # encodeList :: [ExitCode] -> Encoding Source # decodeList :: Decoder s [ExitCode] Source #
Serialise Fingerprint Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Fingerprint -> Encoding Source # decode :: Decoder s Fingerprint Source # encodeList :: [Fingerprint] -> Encoding Source # decodeList :: Decoder s [Fingerprint] Source #
Serialise a => Serialise [a] Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class 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
Instance details Defined in Codec.Serialise.Class Methods encode :: Maybe a -> Encoding Source # decode :: Decoder s (Maybe a) Source # encodeList :: [Maybe a] -> Encoding Source # decodeList :: Decoder s [Maybe a] Source #
(Serialise a, Integral a) => Serialise (Ratio a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Ratio a -> Encoding Source # decode :: Decoder s (Ratio a) Source # encodeList :: [Ratio a] -> Encoding Source # decodeList :: Decoder s [Ratio a] Source #
Serialise a => Serialise (Identity a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Identity a -> Encoding Source # decode :: Decoder s (Identity a) Source # encodeList :: [Identity a] -> Encoding Source # decodeList :: Decoder s [Identity a] Source #
(Serialise a, Hashable a, Eq a) => Serialise (HashSet a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: HashSet a -> Encoding Source # decode :: Decoder s (HashSet a) Source # encodeList :: [HashSet a] -> Encoding Source # decodeList :: Decoder s [HashSet a] Source #
(Serialise a, Unbox a) => Serialise (Vector a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Vector a -> Encoding Source # decode :: Decoder s (Vector a) Source # encodeList :: [Vector a] -> Encoding Source # decodeList :: Decoder s [Vector a] Source #
(Serialise a, Storable a) => Serialise (Vector a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Vector a -> Encoding Source # decode :: Decoder s (Vector a) Source # encodeList :: [Vector a] -> Encoding Source # decodeList :: Decoder s [Vector a] Source #
(Serialise a, Prim a) => Serialise (Vector a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Vector a -> Encoding Source # decode :: Decoder s (Vector a) Source # encodeList :: [Vector a] -> Encoding Source # decodeList :: Decoder s [Vector a] Source #
Serialise a => Serialise (Vector a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Vector a -> Encoding Source # decode :: Decoder s (Vector a) Source # encodeList :: [Vector a] -> Encoding Source # decodeList :: Decoder s [Vector a] Source #
Serialise a => Serialise (NonEmpty a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: NonEmpty a -> Encoding Source # decode :: Decoder s (NonEmpty a) Source # encodeList :: [NonEmpty a] -> Encoding Source # decodeList :: Decoder s [NonEmpty a] Source #
Serialise a => Serialise (Dual a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Dual a -> Encoding Source # decode :: Decoder s (Dual a) Source # encodeList :: [Dual a] -> Encoding Source # decodeList :: Decoder s [Dual a] Source #
Serialise a => Serialise (Product a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Product a -> Encoding Source # decode :: Decoder s (Product a) Source # encodeList :: [Product a] -> Encoding Source # decodeList :: Decoder s [Product a] Source #
Serialise a => Serialise (Sum a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Sum a -> Encoding Source # decode :: Decoder s (Sum a) Source # encodeList :: [Sum a] -> Encoding Source # decodeList :: Decoder s [Sum a] Source #
Serialise a => Serialise (Down a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Down a -> Encoding Source # decode :: Decoder s (Down a) Source # encodeList :: [Down a] -> Encoding Source # decodeList :: Decoder s [Down a] Source #
Serialise a => Serialise (First a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: First a -> Encoding Source # decode :: Decoder s (First a) Source # encodeList :: [First a] -> Encoding Source # decodeList :: Decoder s [First a] Source #
Serialise a => Serialise (Last a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Last a -> Encoding Source # decode :: Decoder s (Last a) Source # encodeList :: [Last a] -> Encoding Source # decodeList :: Decoder s [Last a] Source #
Serialise a => Serialise (First a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: First a -> Encoding Source # decode :: Decoder s (First a) Source # encodeList :: [First a] -> Encoding Source # decodeList :: Decoder s [First a] Source #
Serialise a => Serialise (Last a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Last a -> Encoding Source # decode :: Decoder s (Last a) Source # encodeList :: [Last a] -> Encoding Source # decodeList :: Decoder s [Last a] Source #
Serialise a => Serialise (Max a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Max a -> Encoding Source # decode :: Decoder s (Max a) Source # encodeList :: [Max a] -> Encoding Source # decodeList :: Decoder s [Max a] Source #
Serialise a => Serialise (Min a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Min a -> Encoding Source # decode :: Decoder s (Min a) Source # encodeList :: [Min a] -> Encoding Source # decodeList :: Decoder s [Min a] Source #
Serialise a => Serialise (ZipList a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: ZipList a -> Encoding Source # decode :: Decoder s (ZipList a) Source # encodeList :: [ZipList a] -> Encoding Source # decodeList :: Decoder s [ZipList a] Source #
Serialise a => Serialise (Complex a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Complex a -> Encoding Source # decode :: Decoder s (Complex a) Source # encodeList :: [Complex a] -> Encoding Source # decodeList :: Decoder s [Complex a] Source #
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 Methods encode :: Fixed e -> Encoding Source # decode :: Decoder s (Fixed e) Source # encodeList :: [Fixed e] -> Encoding Source # decodeList :: Decoder s [Fixed e] Source #
Serialise a => Serialise (Option a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Option a -> Encoding Source # decode :: Decoder s (Option a) Source # encodeList :: [Option a] -> Encoding Source # decodeList :: Decoder s [Option a] Source #
Serialise a => Serialise (WrappedMonoid a) Source # |
Instance details Defined in Codec.Serialise.Class Methods encode :: WrappedMonoid a -> Encoding Source # decode :: Decoder s (WrappedMonoid a) Source # encodeList :: [WrappedMonoid a] -> Encoding Source # decodeList :: Decoder s [WrappedMonoid a] Source #
Serialise a => Serialise (Seq a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Seq a -> Encoding Source # decode :: Decoder s (Seq a) Source # encodeList :: [Seq a] -> Encoding Source # decodeList :: Decoder s [Seq a] Source #
(Ord a, Serialise a) => Serialise (Set a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Set a -> Encoding Source # decode :: Decoder s (Set a) Source # encodeList :: [Set a] -> Encoding Source # decodeList :: Decoder s [Set a] Source #
Serialise a => Serialise (IntMap a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: IntMap a -> Encoding Source # decode :: Decoder s (IntMap a) Source # encodeList :: [IntMap a] -> Encoding Source # decodeList :: Decoder s [IntMap a] Source #
Serialise a => Serialise (Tree a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Tree a -> Encoding Source # decode :: Decoder s (Tree a) Source # encodeList :: [Tree a] -> Encoding Source # decodeList :: Decoder s [Tree a] Source #
(Serialise a, Serialise b) => Serialise (Either a b) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Either a b -> Encoding Source # decode :: Decoder s (Either a b) Source # encodeList :: [Either a b] -> Encoding Source # decodeList :: Decoder s [Either a b] Source #
Typeable a => Serialise (TypeRep a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: TypeRep a -> Encoding Source # decode :: Decoder s (TypeRep a) Source # encodeList :: [TypeRep a] -> Encoding Source # decodeList :: Decoder s [TypeRep a] Source #
(Serialise a, Serialise b) => Serialise (a, b) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: (a, b) -> Encoding Source # decode :: Decoder s (a, b) Source # encodeList :: [(a, b)] -> Encoding Source # decodeList :: Decoder s [(a, b)] Source #
(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 Methods encode :: HashMap k v -> Encoding Source # decode :: Decoder s (HashMap k v) Source # encodeList :: [HashMap k v] -> Encoding Source # decodeList :: Decoder s [HashMap k v] Source #
Serialise (Proxy a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Proxy a -> Encoding Source # decode :: Decoder s (Proxy a) Source # encodeList :: [Proxy a] -> Encoding Source # decodeList :: Decoder s [Proxy a] Source #
(Ord k, Serialise k, Serialise v) => Serialise (Map k v) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Map k v -> Encoding Source # decode :: Decoder s (Map k v) Source # encodeList :: [Map k v] -> Encoding Source # decodeList :: Decoder s [Map k v] Source #
(Serialise a, Serialise b, Serialise c) => Serialise (a, b, c) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class 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 (f a) => Serialise (Alt f a) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Alt f a -> Encoding Source # decode :: Decoder s (Alt f a) Source # encodeList :: [Alt f a] -> Encoding Source # decodeList :: Decoder s [Alt f a] Source #
Serialise a => Serialise (Const a b) Source # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods encode :: Const a b -> Encoding Source # decode :: Decoder s (Const a b) Source # encodeList :: [Const a b] -> Encoding Source # decodeList :: Decoder s [Const a b] Source #
(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 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
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 Methods nFields :: Proxy U1 -> Word Source # encodeSeq :: forall (a :: k0). U1 a -> Encoding Source # gdecodeSeq :: forall s (a :: k0). Decoder s (U1 a) Source #
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 Methods nFields :: Proxy (f :*: g) -> Word Source # encodeSeq :: forall (a :: k0). (f :*: g) a -> Encoding Source # gdecodeSeq :: forall s (a :: k0). Decoder s ((f :*: g) a) Source #
(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

#### Instances

Instances details

(GSerialiseSum f, GSerialiseSum g) => GSerialiseSum (f :+: g :: k -> Type) Source # | Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

conNumber :: forall (a :: k0). (f :+: g) a -> Word Source #

numOfFields :: forall (a :: k0). (f :+: g) a -> Word Source #

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

decodeSum :: forall s (a :: k0). Word -> Decoder s ((f :+: g) a) Source #

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

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

(i ~ C, GSerialiseProd f) => GSerialiseSum (M1 i c f :: k -> Type) Source # | Since: 0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Methods

conNumber :: forall (a :: k0). M1 i c f a -> Word Source #

numOfFields :: forall (a :: k0). M1 i c f a -> Word Source #

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

decodeSum :: forall s (a :: k0). Word -> Decoder s (M1 i c f a) Source #

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

fieldsForCon :: Proxy (M1 i c 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

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.