Codec.Serialise.Class

serialise-0.2.6.1: 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 :: k -> Type) where
  - gencode :: forall (a :: k). f a -> Encoding
- class GSerialiseDecode (f :: k -> Type) where
  - gdecode :: forall s (a :: k). Decoder s (f a)
- class GSerialiseProd (f :: k -> Type) where
  - nFields :: Proxy f -> Word
  - encodeSeq :: forall (a :: k). f a -> Encoding
  - gdecodeSeq :: forall s (a :: k). Decoder s (f a)
- class GSerialiseSum (f :: k -> Type) where
  - conNumber :: forall (a :: k). f a -> Word
  - numOfFields :: forall (a :: k). f a -> Word
  - encodeSum :: forall (a :: k). f a -> Encoding
  - decodeSum :: forall s (a :: k). 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 #

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 #

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 #

decode :: Decoder s a #

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

Since: 0.2.0.0

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

encodeList :: [a] -> Encoding #

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] #

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

class GSerialiseEncode (f :: k -> Type) where #

Since: 0.2.0.0

Methods

gencode :: forall (a :: k). f a -> Encoding #

Since: 0.2.0.0

#### Instances

Instances details

GSerialiseEncode (U1 :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gencode :: forall (a :: k). U1 a -> Encoding #
GSerialiseEncode (V1 :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gencode :: forall (a :: k). V1 a -> Encoding #
(GSerialiseProd f, GSerialiseProd g) => GSerialiseEncode (f :*: g :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gencode :: forall (a :: k). (f :*: g) a -> Encoding #
(GSerialiseSum f, GSerialiseSum g) => GSerialiseEncode (f :+: g :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gencode :: forall (a :: k). (f :+: g) a -> Encoding #
Serialise a => GSerialiseEncode (K1 i a :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gencode :: forall (a0 :: k). K1 i a a0 -> Encoding #
GSerialiseEncode a => GSerialiseEncode (M1 i c a :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gencode :: forall (a0 :: k). M1 i c a a0 -> Encoding #

class GSerialiseDecode (f :: k -> Type) where #

Since: 0.2.0.0

Methods

gdecode :: forall s (a :: k). Decoder s (f a) #

Since: 0.2.0.0

#### Instances

Instances details

GSerialiseDecode (U1 :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gdecode :: forall s (a :: k). Decoder s (U1 a) #
GSerialiseDecode (V1 :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gdecode :: forall s (a :: k). Decoder s (V1 a) #
(GSerialiseProd f, GSerialiseProd g) => GSerialiseDecode (f :*: g :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gdecode :: forall s (a :: k). Decoder s ((f :*: g) a) #
(GSerialiseSum f, GSerialiseSum g) => GSerialiseDecode (f :+: g :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gdecode :: forall s (a :: k). Decoder s ((f :+: g) a) #
Serialise a => GSerialiseDecode (K1 i a :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gdecode :: forall s (a0 :: k). Decoder s (K1 i a a0) #
GSerialiseDecode a => GSerialiseDecode (M1 i c a :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods gdecode :: forall s (a0 :: k). Decoder s (M1 i c a a0) #

class GSerialiseProd (f :: k -> Type) where #

Serialization of product types

Methods

nFields :: Proxy f -> Word #

Number of fields in product type

encodeSeq :: forall (a :: k). f a -> Encoding #

Encode fields sequentially without writing header

gdecodeSeq :: forall s (a :: k). Decoder s (f a) #

Decode fields sequentially without reading header

#### Instances

Instances details

GSerialiseProd (U1 :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods nFields :: Proxy (U1 :: k -> Type) -> Word # encodeSeq :: forall (a :: k). U1 a -> Encoding # gdecodeSeq :: forall s (a :: k). Decoder s (U1 a) #
(GSerialiseProd f, GSerialiseProd g) => GSerialiseProd (f :*: g :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods nFields :: Proxy (f :*: g) -> Word # encodeSeq :: forall (a :: k). (f :*: g) a -> Encoding # gdecodeSeq :: forall s (a :: k). Decoder s ((f :*: g) a) #
Serialise a => GSerialiseProd (K1 i a :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods nFields :: Proxy (K1 i a :: k -> Type) -> Word # encodeSeq :: forall (a0 :: k). K1 i a a0 -> Encoding # gdecodeSeq :: forall s (a0 :: k). Decoder s (K1 i a a0) #
(i ~ S, GSerialiseProd f) => GSerialiseProd (M1 i c f :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods nFields :: Proxy (M1 i c f) -> Word # encodeSeq :: forall (a :: k). M1 i c f a -> Encoding # gdecodeSeq :: forall s (a :: k). Decoder s (M1 i c f a) #

class GSerialiseSum (f :: k -> Type) where #

Serialization of sum types

Since: 0.2.0.0

Methods

conNumber :: forall (a :: k). f a -> Word #

Number of constructor of given value

numOfFields :: forall (a :: k). f a -> Word #

Number of fields of given value

encodeSum :: forall (a :: k). f a -> Encoding #

Encode field

decodeSum :: forall s (a :: k). Word -> Decoder s (f a) #

Decode field

nConstructors :: Proxy f -> Word #

Number of constructors

fieldsForCon :: Proxy f -> Word -> Decoder s Word #

Number of fields for given constructor number

#### Instances

Instances details

(GSerialiseSum f, GSerialiseSum g) => GSerialiseSum (f :+: g :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods conNumber :: forall (a :: k). (f :+: g) a -> Word # numOfFields :: forall (a :: k). (f :+: g) a -> Word # encodeSum :: forall (a :: k). (f :+: g) a -> Encoding # decodeSum :: forall s (a :: k). Word -> Decoder s ((f :+: g) a) # nConstructors :: Proxy (f :+: g) -> Word # fieldsForCon :: Proxy (f :+: g) -> Word -> Decoder s Word #
(i ~ C, GSerialiseProd f) => GSerialiseSum (M1 i c f :: k -> Type) # | Since: 0.2.0.0
Instance details Defined in Codec.Serialise.Class Methods conNumber :: forall (a :: k). M1 i c f a -> Word # numOfFields :: forall (a :: k). M1 i c f a -> Word # encodeSum :: forall (a :: k). M1 i c f a -> Encoding # decodeSum :: forall s (a :: k). Word -> Decoder s (M1 i c f a) # nConstructors :: Proxy (M1 i c f) -> Word # fieldsForCon :: Proxy (M1 i c f) -> Word -> Decoder s Word #

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

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) #

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

Since: 0.2.0.0

encodeContainerSkel #

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 #

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 #

Arguments

:: (Serialise k, Serialise v) |
=> ([(k, v)] -> m) | fromList
-> Decoder s m |

A utility function to construct a `Decoder` for maps.