-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | A binary serialisation library for Haskell values.
--   
--   This package (formerly binary-serialise-cbor) provides pure,
--   efficient serialization of Haskell values directly into
--   ByteStrings for storage or transmission purposes. By
--   providing a set of type class instances, you can also serialise any
--   custom data type you have as well.
--   
--   The underlying binary format used is the 'Concise Binary Object
--   Representation', or CBOR, specified in RFC 7049. As a result,
--   serialised Haskell values have implicit structure outside of the
--   Haskell program itself, meaning they can be inspected or analyzed
--   without custom tools.
--   
--   An implementation of the standard bijection between CBOR and JSON is
--   provided by the cborg-json package. Also see cbor-tool
--   for a convenient command-line utility for working with CBOR data.
@package serialise
@version 0.2.6.1

-- | High level API for decoding values that were encoded with the
--   Codec.Serialise.Encoding module, using a Monad
--   based interface.
module Codec.Serialise.Decoding

-- | A continuation-based decoder, used for decoding values that were
--   previously encoded using the Codec.CBOR.Encoding module. As
--   Decoder has a Monad instance, you can easily write
--   Decoders monadically for building your deserialisation logic.
data Decoder s a

-- | An action, representing a step for a decoder to taken and a
--   continuation to invoke with the expected value.
data DecodeAction s a
ConsumeWord :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeWord8 :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeWord16 :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeWord32 :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeNegWord :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeInt :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeInt8 :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeInt16 :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeInt32 :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeListLen :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeMapLen :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeTag :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeInteger :: (Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeFloat :: (Float# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeDouble :: (Double# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBytes :: (ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeByteArray :: (ByteArray -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeString :: (Text -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeUtf8ByteArray :: (ByteArray -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBool :: (Bool -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeSimple :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBytesIndef :: ST s (DecodeAction s a) -> DecodeAction s a
ConsumeStringIndef :: ST s (DecodeAction s a) -> DecodeAction s a
ConsumeListLenIndef :: ST s (DecodeAction s a) -> DecodeAction s a
ConsumeMapLenIndef :: ST s (DecodeAction s a) -> DecodeAction s a
ConsumeNull :: ST s (DecodeAction s a) -> DecodeAction s a
ConsumeListLenOrIndef :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeMapLenOrIndef :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBreakOr :: (Bool -> ST s (DecodeAction s a)) -> DecodeAction s a
PeekTokenType :: (TokenType -> ST s (DecodeAction s a)) -> DecodeAction s a
PeekAvailable :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
PeekByteOffset :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeWordCanonical :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeWord8Canonical :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeWord16Canonical :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeWord32Canonical :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeNegWordCanonical :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeIntCanonical :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeInt8Canonical :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeInt16Canonical :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeInt32Canonical :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeListLenCanonical :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeMapLenCanonical :: (Int# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeTagCanonical :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeIntegerCanonical :: (Integer -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeFloat16Canonical :: (Float# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeFloatCanonical :: (Float# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeDoubleCanonical :: (Double# -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeBytesCanonical :: (ByteString -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeByteArrayCanonical :: (ByteArray -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeStringCanonical :: (Text -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeUtf8ByteArrayCanonical :: (ByteArray -> ST s (DecodeAction s a)) -> DecodeAction s a
ConsumeSimpleCanonical :: (Word# -> ST s (DecodeAction s a)) -> DecodeAction s a
Fail :: String -> DecodeAction s a
Done :: a -> DecodeAction s a

-- | Given a Decoder, give us the DecodeAction
getDecodeAction :: Decoder s a -> ST s (DecodeAction s a)

-- | Decode a Word.
decodeWord :: Decoder s Word

-- | Decode a Word8.
decodeWord8 :: Decoder s Word8

-- | Decode a Word16.
decodeWord16 :: Decoder s Word16

-- | Decode a Word32.
decodeWord32 :: Decoder s Word32

-- | Decode a Word64.
decodeWord64 :: Decoder s Word64

-- | Decode a negative Word.
decodeNegWord :: Decoder s Word

-- | Decode a negative Word64.
decodeNegWord64 :: Decoder s Word64

-- | Decode an Int.
decodeInt :: Decoder s Int

-- | Decode an Int8.
decodeInt8 :: Decoder s Int8

-- | Decode an Int16.
decodeInt16 :: Decoder s Int16

-- | Decode an Int32.
decodeInt32 :: Decoder s Int32

-- | Decode an Int64.
decodeInt64 :: Decoder s Int64

-- | Decode an Integer.
decodeInteger :: Decoder s Integer

-- | Decode a Float.
decodeFloat :: Decoder s Float

-- | Decode a Double.
decodeDouble :: Decoder s Double

-- | Decode a string of bytes as a ByteString.
decodeBytes :: Decoder s ByteString

-- | Decode a token marking the beginning of an indefinite length set of
--   bytes.
decodeBytesIndef :: Decoder s ()

-- | Decode a string of bytes as a ByteArray.
--   
--   Also note that this will eagerly copy the content out of the input to
--   ensure that the input does not leak in the event that the
--   ByteArray is live but not forced.
decodeByteArray :: Decoder s ByteArray

-- | Decode a textual string as a piece of Text.
decodeString :: Decoder s Text

-- | Decode a token marking the beginning of an indefinite length string.
decodeStringIndef :: Decoder s ()

-- | Decode a textual string as UTF-8 encoded ByteArray. Note that
--   the result is not validated to be well-formed UTF-8.
--   
--   Also note that this will eagerly copy the content out of the input to
--   ensure that the input does not leak in the event that the
--   ByteArray is live but not forced.
decodeUtf8ByteArray :: Decoder s ByteArray

-- | Decode the length of a list.
decodeListLen :: Decoder s Int

-- | Decode a token marking the beginning of a list of indefinite length.
decodeListLenIndef :: Decoder s ()

-- | Decode the length of a map.
decodeMapLen :: Decoder s Int

-- | Decode a token marking the beginning of a map of indefinite length.
decodeMapLenIndef :: Decoder s ()

-- | Decode an arbitrary tag and return it as a Word.
decodeTag :: Decoder s Word

-- | Decode an arbitrary 64-bit tag and return it as a Word64.
decodeTag64 :: Decoder s Word64

-- | Decode a bool.
decodeBool :: Decoder s Bool

-- | Decode a nullary value, and return a unit value.
decodeNull :: Decoder s ()

-- | Decode a simple CBOR value and give back a Word8. You
--   probably don't ever need to use this.
decodeSimple :: Decoder s Word8

-- | Attempt to decode a word with decodeWord, and ensure the word
--   is exactly as expected, or fail.
decodeWordOf :: Word -> Decoder s ()

-- | Attempt to decode a list length using decodeListLen, and ensure
--   it is exactly the specified length, or fail.
decodeListLenOf :: Int -> Decoder s ()

-- | Attempt to decode a token for the length of a finite, known list, or
--   an indefinite list. If Nothing is returned, then an indefinite
--   length list occurs afterwords. If Just x is returned,
--   then a list of length x is encoded.
decodeListLenOrIndef :: Decoder s (Maybe Int)

-- | Attempt to decode a token for the length of a finite, known map, or an
--   indefinite map. If Nothing is returned, then an indefinite
--   length map occurs afterwords. If Just x is returned,
--   then a map of length x is encoded.
decodeMapLenOrIndef :: Decoder s (Maybe Int)

-- | Attempt to decode a Break token, and if that was successful,
--   return True. If the token was of any other type, return
--   False.
decodeBreakOr :: Decoder s Bool

-- | Peek at the current token we're about to decode, and return a
--   TokenType specifying what it is.
peekTokenType :: Decoder s TokenType

-- | Peek and return the length of the current buffer that we're running
--   our decoder on.
peekAvailable :: Decoder s Int

-- | The type of a token, which a decoder can ask for at an arbitrary time.
data TokenType
TypeUInt :: TokenType
TypeUInt64 :: TokenType
TypeNInt :: TokenType
TypeNInt64 :: TokenType
TypeInteger :: TokenType
TypeFloat16 :: TokenType
TypeFloat32 :: TokenType
TypeFloat64 :: TokenType
TypeBytes :: TokenType
TypeBytesIndef :: TokenType
TypeString :: TokenType
TypeStringIndef :: TokenType
TypeListLen :: TokenType
TypeListLen64 :: TokenType
TypeListLenIndef :: TokenType
TypeMapLen :: TokenType
TypeMapLen64 :: TokenType
TypeMapLenIndef :: TokenType
TypeTag :: TokenType
TypeTag64 :: TokenType
TypeBool :: TokenType
TypeNull :: TokenType
TypeSimple :: TokenType
TypeBreak :: TokenType
TypeInvalid :: TokenType

-- | Decode an indefinite sequence length.
decodeSequenceLenIndef :: (r -> a -> r) -> r -> (r -> r') -> Decoder s a -> Decoder s r'

-- | Decode a sequence length.
decodeSequenceLenN :: (r -> a -> r) -> r -> (r -> r') -> Int -> Decoder s a -> Decoder s r'

-- | High level API for encoding values, for later serialization into CBOR
--   binary format, using a Monoid based interface.
module Codec.Serialise.Encoding

-- | An intermediate form used during serialisation, specified as a
--   Monoid. It supports efficient concatenation, and is equivalent
--   to a specialised Endo Tokens type.
--   
--   It is used for the stage in serialisation where we flatten out the
--   Haskell data structure but it is independent of any specific external
--   binary or text format.
--   
--   Traditionally, to build any arbitrary Encoding value, you
--   specify larger structures from smaller ones and append the small ones
--   together using mconcat.
newtype Encoding
Encoding :: (Tokens -> Tokens) -> Encoding

-- | A flattened representation of a term, which is independent of any
--   underlying binary representation, but which we later serialise into
--   CBOR format.
data Tokens
TkWord :: {-# UNPACK #-} !Word -> Tokens -> Tokens
TkWord64 :: {-# UNPACK #-} !Word64 -> Tokens -> Tokens
TkInt :: {-# UNPACK #-} !Int -> Tokens -> Tokens
TkInt64 :: {-# UNPACK #-} !Int64 -> Tokens -> Tokens
TkBytes :: {-# UNPACK #-} !ByteString -> Tokens -> Tokens
TkBytesBegin :: Tokens -> Tokens
TkByteArray :: {-# UNPACK #-} !SlicedByteArray -> Tokens -> Tokens
TkString :: {-# UNPACK #-} !Text -> Tokens -> Tokens
TkUtf8ByteArray :: {-# UNPACK #-} !SlicedByteArray -> Tokens -> Tokens
TkStringBegin :: Tokens -> Tokens
TkListLen :: {-# UNPACK #-} !Word -> Tokens -> Tokens
TkListBegin :: Tokens -> Tokens
TkMapLen :: {-# UNPACK #-} !Word -> Tokens -> Tokens
TkMapBegin :: Tokens -> Tokens
TkTag :: {-# UNPACK #-} !Word -> Tokens -> Tokens
TkTag64 :: {-# UNPACK #-} !Word64 -> Tokens -> Tokens
TkInteger :: !Integer -> Tokens -> Tokens
TkNull :: Tokens -> Tokens
TkUndef :: Tokens -> Tokens
TkBool :: !Bool -> Tokens -> Tokens
TkSimple :: {-# UNPACK #-} !Word8 -> Tokens -> Tokens
TkFloat16 :: {-# UNPACK #-} !Float -> Tokens -> Tokens
TkFloat32 :: {-# UNPACK #-} !Float -> Tokens -> Tokens
TkFloat64 :: {-# UNPACK #-} !Double -> Tokens -> Tokens
TkBreak :: Tokens -> Tokens
TkEncoded :: {-# UNPACK #-} !ByteString -> Tokens -> Tokens
TkEnd :: Tokens

-- | Encode a Word in a flattened format.
encodeWord :: Word -> Encoding

-- | Encode a Word8 in a flattened format.
encodeWord8 :: Word8 -> Encoding

-- | Encode a Word16 in a flattened format.
encodeWord16 :: Word16 -> Encoding

-- | Encode a Word32 in a flattened format.
encodeWord32 :: Word32 -> Encoding

-- | Encode a Word64 in a flattened format.
encodeWord64 :: Word64 -> Encoding

-- | Encode an Int in a flattened format.
encodeInt :: Int -> Encoding

-- | Encode an Int8 in a flattened format.
encodeInt8 :: Int8 -> Encoding

-- | Encode an Int16 in a flattened format.
encodeInt16 :: Int16 -> Encoding

-- | Encode an Int32 in a flattened format.
encodeInt32 :: Int32 -> Encoding

-- | Encode an @Int64 in a flattened format.
encodeInt64 :: Int64 -> Encoding

-- | Encode an arbitrarily large @Integer in a flattened format.
encodeInteger :: Integer -> Encoding

-- | Encode an arbitrary strict ByteString in a flattened format.
encodeBytes :: ByteString -> Encoding

-- | Encode a token specifying the beginning of a string of bytes of
--   indefinite length. In reality, this specifies a stream of many
--   occurrences of encodeBytes, each specifying a single chunk of
--   the overall string. After all the bytes desired have been encoded, you
--   should follow it with a break token (see encodeBreak).
encodeBytesIndef :: Encoding

-- | Encode a bytestring in a flattened format.
encodeByteArray :: SlicedByteArray -> Encoding

-- | Encode a Text in a flattened format.
encodeString :: Text -> Encoding

-- | Encode the beginning of an indefinite string.
encodeStringIndef :: Encoding

-- | Encode a UTF-8 string in a flattened format. Note that the contents is
--   not validated to be well-formed UTF-8.
encodeUtf8ByteArray :: SlicedByteArray -> Encoding

-- | Encode the length of a list, used to indicate that the following
--   tokens represent the list values.
encodeListLen :: Word -> Encoding

-- | Encode a token specifying that this is the beginning of an indefinite
--   list of unknown size. Tokens representing the list are expected
--   afterwords, followed by a break token (see encodeBreak) when
--   the list has ended.
encodeListLenIndef :: Encoding

-- | Encode the length of a Map, used to indicate that the following tokens
--   represent the map values.
encodeMapLen :: Word -> Encoding

-- | Encode a token specifying that this is the beginning of an indefinite
--   map of unknown size. Tokens representing the map are expected
--   afterwords, followed by a break token (see encodeBreak) when
--   the map has ended.
encodeMapLenIndef :: Encoding

-- | Encode a 'break', used to specify the end of indefinite length objects
--   like maps or lists.
encodeBreak :: Encoding

-- | Encode an arbitrary Word tag.
encodeTag :: Word -> Encoding

-- | Encode an arbitrary 64-bit Word64 tag.
encodeTag64 :: Word64 -> Encoding

-- | Encode a Bool.
encodeBool :: Bool -> Encoding

-- | Encode an Undef value.
encodeUndef :: Encoding

-- | Encode a Null value.
encodeNull :: Encoding

-- | Encode a 'simple' CBOR token that can be represented with an 8-bit
--   word. You probably don't ever need this.
encodeSimple :: Word8 -> Encoding

-- | Encode a small 16-bit Float in a flattened format.
encodeFloat16 :: Float -> Encoding

-- | Encode a full precision Float in a flattened format.
encodeFloat :: Float -> Encoding

-- | Encode a Double in a flattened format.
encodeDouble :: Double -> Encoding

module Codec.Serialise.Internal.GeneralisedUTF8

-- | Encode a string as (generalized) UTF-8. In addition to the encoding,
--   we return a flag indicating whether the encoded string contained any
--   surrogate characters, in which case the output is generalized UTF-8.
encodeGenUTF8 :: String -> (SlicedByteArray, UTF8Encoding)
data UTF8Encoding
ConformantUTF8 :: UTF8Encoding
GeneralisedUTF8 :: UTF8Encoding
decodeGenUTF8 :: ByteArray -> String

-- | Is a Char a UTF-16 surrogate?
isSurrogate :: Char -> Bool

-- | Is the given byte sequence valid under the given encoding?
isValid :: UTF8Encoding -> [Word8] -> Bool
instance GHC.Classes.Eq Codec.Serialise.Internal.GeneralisedUTF8.UTF8Encoding
instance GHC.Internal.Show.Show Codec.Serialise.Internal.GeneralisedUTF8.UTF8Encoding

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

-- | 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.
class Serialise a

-- | Definition for encoding a given type into a binary representation,
--   using the Encoding Monoid.
encode :: Serialise a => a -> Encoding
($dmencode) :: (Serialise a, Generic a, GSerialiseEncode (Rep a)) => a -> Encoding

-- | Definition of a given Decoder for a type.
decode :: Serialise a => Decoder s a
($dmdecode) :: (Serialise a, Generic a, GSerialiseDecode (Rep a)) => Decoder s a

-- | Utility to support specialised encoding for some list type - used for
--   Char/String instances in this package.
encodeList :: Serialise a => [a] -> Encoding

-- | Utility to support specialised decoding for some list type - used for
--   Char/String instances in this package.
decodeList :: Serialise a => Decoder s [a]

class GSerialiseEncode (f :: k -> Type)

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

class GSerialiseDecode (f :: k -> Type)

gdecode :: forall s (a :: k). GSerialiseDecode f => Decoder s (f a)

-- | Serialization of product types
class GSerialiseProd (f :: k -> Type)

-- | Number of fields in product type
nFields :: GSerialiseProd f => Proxy f -> Word

-- | Encode fields sequentially without writing header
encodeSeq :: forall (a :: k). GSerialiseProd f => f a -> Encoding

-- | Decode fields sequentially without reading header
gdecodeSeq :: forall s (a :: k). GSerialiseProd f => Decoder s (f a)

-- | Serialization of sum types
class GSerialiseSum (f :: k -> Type)

-- | Number of constructor of given value
conNumber :: forall (a :: k). GSerialiseSum f => f a -> Word

-- | Number of fields of given value
numOfFields :: forall (a :: k). GSerialiseSum f => f a -> Word

-- | Encode field
encodeSum :: forall (a :: k). GSerialiseSum f => f a -> Encoding

-- | Decode field
decodeSum :: forall s (a :: k). GSerialiseSum f => Word -> Decoder s (f a)

-- | Number of constructors
nConstructors :: GSerialiseSum f => Proxy f -> Word

-- | Number of fields for given constructor number
fieldsForCon :: GSerialiseSum f => Proxy f -> Word -> Decoder s Word

-- | Generic encoder for vectors. Its intended use is to allow easy
--   definition of Serialise instances for custom vector
encodeVector :: (Serialise a, Vector v a) => v a -> Encoding

-- | Generic decoder for vectors. Its intended use is to allow easy
--   definition of Serialise instances for custom vector
decodeVector :: (Serialise a, Vector v a) => Decoder s (v a)

-- | Patch functions together to obtain an Encoding for a container.
encodeContainerSkel :: (Word -> Encoding) -> (container -> Int) -> (accumFunc -> Encoding -> container -> Encoding) -> accumFunc -> container -> Encoding

-- | A helper function for encoding maps.
encodeMapSkel :: (Serialise k, Serialise v) => (m -> Int) -> ((k -> v -> Encoding -> Encoding) -> Encoding -> m -> Encoding) -> m -> Encoding

-- | A utility function to construct a Decoder for maps.
decodeMapSkel :: (Serialise k, Serialise v) => ([(k, v)] -> m) -> Decoder s m
instance forall k (f :: k -> *) (g :: k -> *). (Codec.Serialise.Class.GSerialiseProd f, Codec.Serialise.Class.GSerialiseProd g) => Codec.Serialise.Class.GSerialiseDecode (f GHC.Internal.Generics.:*: g)
instance forall k (f :: k -> *) (g :: k -> *). (Codec.Serialise.Class.GSerialiseSum f, Codec.Serialise.Class.GSerialiseSum g) => Codec.Serialise.Class.GSerialiseDecode (f GHC.Internal.Generics.:+: g)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.GSerialiseDecode (GHC.Internal.Generics.K1 i a)
instance forall k (a :: k -> *) i (c :: GHC.Internal.Generics.Meta). Codec.Serialise.Class.GSerialiseDecode a => Codec.Serialise.Class.GSerialiseDecode (GHC.Internal.Generics.M1 i c a)
instance Codec.Serialise.Class.GSerialiseDecode GHC.Internal.Generics.U1
instance Codec.Serialise.Class.GSerialiseDecode GHC.Internal.Generics.V1
instance forall k (f :: k -> *) (g :: k -> *). (Codec.Serialise.Class.GSerialiseProd f, Codec.Serialise.Class.GSerialiseProd g) => Codec.Serialise.Class.GSerialiseEncode (f GHC.Internal.Generics.:*: g)
instance forall k (f :: k -> *) (g :: k -> *). (Codec.Serialise.Class.GSerialiseSum f, Codec.Serialise.Class.GSerialiseSum g) => Codec.Serialise.Class.GSerialiseEncode (f GHC.Internal.Generics.:+: g)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.GSerialiseEncode (GHC.Internal.Generics.K1 i a)
instance forall k (a :: k -> *) i (c :: GHC.Internal.Generics.Meta). Codec.Serialise.Class.GSerialiseEncode a => Codec.Serialise.Class.GSerialiseEncode (GHC.Internal.Generics.M1 i c a)
instance Codec.Serialise.Class.GSerialiseEncode GHC.Internal.Generics.U1
instance Codec.Serialise.Class.GSerialiseEncode GHC.Internal.Generics.V1
instance forall k (f :: k -> *) (g :: k -> *). (Codec.Serialise.Class.GSerialiseProd f, Codec.Serialise.Class.GSerialiseProd g) => Codec.Serialise.Class.GSerialiseProd (f GHC.Internal.Generics.:*: g)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.GSerialiseProd (GHC.Internal.Generics.K1 i a)
instance forall k i (f :: k -> *) (c :: GHC.Internal.Generics.Meta). (i GHC.Types.~ GHC.Internal.Generics.S, Codec.Serialise.Class.GSerialiseProd f) => Codec.Serialise.Class.GSerialiseProd (GHC.Internal.Generics.M1 i c f)
instance Codec.Serialise.Class.GSerialiseProd GHC.Internal.Generics.U1
instance forall k (f :: k -> *) (g :: k -> *). (Codec.Serialise.Class.GSerialiseSum f, Codec.Serialise.Class.GSerialiseSum g) => Codec.Serialise.Class.GSerialiseSum (f GHC.Internal.Generics.:+: g)
instance forall k i (f :: k -> *) (c :: GHC.Internal.Generics.Meta). (i GHC.Types.~ GHC.Internal.Generics.C, Codec.Serialise.Class.GSerialiseProd f) => Codec.Serialise.Class.GSerialiseSum (GHC.Internal.Generics.M1 i c f)
instance Codec.Serialise.Class.Serialise GHC.Internal.Data.Semigroup.Internal.All
instance forall k (f :: k -> *) (a :: k). Codec.Serialise.Class.Serialise (f a) => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Semigroup.Internal.Alt f a)
instance Codec.Serialise.Class.Serialise GHC.Internal.Data.Semigroup.Internal.Any
instance Codec.Serialise.Class.Serialise GHC.Types.Bool
instance Codec.Serialise.Class.Serialise Data.ByteString.Lazy.Internal.ByteString
instance Codec.Serialise.Class.Serialise Data.ByteString.Internal.Type.ByteString
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CChar
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CClock
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CDouble
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CFloat
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CInt
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CIntMax
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CIntPtr
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CLLong
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CLong
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CPtrdiff
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CSChar
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CSUSeconds
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CShort
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CSigAtomic
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CSize
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CTime
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CUChar
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CUInt
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CUIntMax
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CUIntPtr
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CULLong
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CULong
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CUSeconds
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CUShort
instance Codec.Serialise.Class.Serialise GHC.Internal.Foreign.C.Types.CWchar
instance Codec.Serialise.Class.Serialise GHC.Types.Char
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Complex.Complex a)
instance forall k a (b :: k). Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Functor.Const.Const a b)
instance Codec.Serialise.Class.Serialise GHC.Types.Double
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Ord.Down a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Semigroup.Internal.Dual a)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b) => Codec.Serialise.Class.Serialise (Data.Strict.Either.Either a b)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b) => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Either.Either a b)
instance Codec.Serialise.Class.Serialise GHC.Internal.IO.Exception.ExitCode
instance Codec.Serialise.Class.Serialise GHC.Internal.Fingerprint.Type.Fingerprint
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Semigroup.First a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Monoid.First a)
instance forall k (e :: k). Codec.Serialise.Class.Serialise (Data.Fixed.Fixed e)
instance Codec.Serialise.Class.Serialise GHC.Types.Float
instance Codec.Serialise.Class.Serialise Numeric.Half.Internal.Half
instance (Codec.Serialise.Class.Serialise k, Data.Hashable.Class.Hashable k, GHC.Classes.Eq k, Codec.Serialise.Class.Serialise v) => Codec.Serialise.Class.Serialise (Data.HashMap.Internal.HashMap k v)
instance (Codec.Serialise.Class.Serialise a, Data.Hashable.Class.Hashable a, GHC.Classes.Eq a) => Codec.Serialise.Class.Serialise (Data.HashSet.Internal.HashSet a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Functor.Identity.Identity a)
instance Codec.Serialise.Class.Serialise GHC.Types.Int
instance Codec.Serialise.Class.Serialise GHC.Internal.Int.Int16
instance Codec.Serialise.Class.Serialise GHC.Internal.Int.Int32
instance Codec.Serialise.Class.Serialise GHC.Internal.Int.Int64
instance Codec.Serialise.Class.Serialise GHC.Internal.Int.Int8
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.IntMap.Internal.IntMap a)
instance Codec.Serialise.Class.Serialise Data.IntSet.Internal.IntSet
instance Codec.Serialise.Class.Serialise GHC.Num.Integer.Integer
instance Codec.Serialise.Class.Serialise GHC.Types.KindRep
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Semigroup.Last a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Monoid.Last a)
instance Codec.Serialise.Class.Serialise GHC.Types.Levity
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise [a]
instance (GHC.Classes.Ord k, Codec.Serialise.Class.Serialise k, Codec.Serialise.Class.Serialise v) => Codec.Serialise.Class.Serialise (Data.Map.Internal.Map k v)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Semigroup.Max a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Strict.Maybe.Maybe a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Maybe.Maybe a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Semigroup.Min a)
instance Codec.Serialise.Class.Serialise GHC.Num.Natural.Natural
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Base.NonEmpty a)
instance Codec.Serialise.Class.Serialise GHC.Types.Ordering
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b) => Codec.Serialise.Class.Serialise (Data.Strict.Tuple.Pair a b)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Semigroup.Internal.Product a)
instance forall k (a :: k). Codec.Serialise.Class.Serialise (GHC.Internal.Data.Proxy.Proxy a)
instance (Codec.Serialise.Class.Serialise a, GHC.Internal.Real.Integral a) => Codec.Serialise.Class.Serialise (GHC.Internal.Real.Ratio a)
instance Codec.Serialise.Class.Serialise GHC.Types.RuntimeRep
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Sequence.Internal.Seq a)
instance (GHC.Classes.Ord a, Codec.Serialise.Class.Serialise a) => Codec.Serialise.Class.Serialise (Data.Set.Internal.Set a)
instance Codec.Serialise.Class.Serialise Data.ByteString.Short.Internal.ShortByteString
instance Codec.Serialise.Class.Serialise GHC.Internal.Data.Typeable.Internal.SomeTypeRep
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Semigroup.Internal.Sum a)
instance Codec.Serialise.Class.Serialise Codec.CBOR.Term.Term
instance Codec.Serialise.Class.Serialise Data.Text.Internal.Lazy.Text
instance Codec.Serialise.Class.Serialise Data.Text.Internal.Text
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b) => Codec.Serialise.Class.Serialise (Data.Strict.These.These a b)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b) => Codec.Serialise.Class.Serialise (Data.These.These a b)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Tree.Tree a)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b) => Codec.Serialise.Class.Serialise (a, b)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b, Codec.Serialise.Class.Serialise c) => Codec.Serialise.Class.Serialise (a, b, c)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b, Codec.Serialise.Class.Serialise c, Codec.Serialise.Class.Serialise d) => Codec.Serialise.Class.Serialise (a, b, c, d)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b, Codec.Serialise.Class.Serialise c, Codec.Serialise.Class.Serialise d, Codec.Serialise.Class.Serialise e) => Codec.Serialise.Class.Serialise (a, b, c, d, e)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b, Codec.Serialise.Class.Serialise c, Codec.Serialise.Class.Serialise d, Codec.Serialise.Class.Serialise e, Codec.Serialise.Class.Serialise f) => Codec.Serialise.Class.Serialise (a, b, c, d, e, f)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b, Codec.Serialise.Class.Serialise c, Codec.Serialise.Class.Serialise d, Codec.Serialise.Class.Serialise e, Codec.Serialise.Class.Serialise f, Codec.Serialise.Class.Serialise g) => Codec.Serialise.Class.Serialise (a, b, c, d, e, f, g)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b, Codec.Serialise.Class.Serialise c, Codec.Serialise.Class.Serialise d, Codec.Serialise.Class.Serialise e, Codec.Serialise.Class.Serialise f, Codec.Serialise.Class.Serialise g, Codec.Serialise.Class.Serialise h) => Codec.Serialise.Class.Serialise (a, b, c, d, e, f, g, h)
instance (Codec.Serialise.Class.Serialise a, Codec.Serialise.Class.Serialise b, Codec.Serialise.Class.Serialise c, Codec.Serialise.Class.Serialise d, Codec.Serialise.Class.Serialise e, Codec.Serialise.Class.Serialise f, Codec.Serialise.Class.Serialise g, Codec.Serialise.Class.Serialise h, Codec.Serialise.Class.Serialise i) => Codec.Serialise.Class.Serialise (a, b, c, d, e, f, g, h, i)
instance Codec.Serialise.Class.Serialise GHC.Types.TyCon
instance Codec.Serialise.Class.Serialise GHC.Types.TypeLitSort
instance forall k (a :: k). GHC.Internal.Data.Typeable.Internal.Typeable a => Codec.Serialise.Class.Serialise (GHC.Internal.Data.Typeable.Internal.TypeRep a)
instance Codec.Serialise.Class.Serialise Data.Time.Clock.Internal.UTCTime.UTCTime
instance Codec.Serialise.Class.Serialise ()
instance Codec.Serialise.Class.Serialise GHC.Types.VecCount
instance Codec.Serialise.Class.Serialise GHC.Types.VecElem
instance (Codec.Serialise.Class.Serialise a, Data.Primitive.Types.Prim a) => Codec.Serialise.Class.Serialise (Data.Vector.Primitive.Vector a)
instance (Codec.Serialise.Class.Serialise a, GHC.Internal.Foreign.Storable.Storable a) => Codec.Serialise.Class.Serialise (Data.Vector.Storable.Vector a)
instance (Codec.Serialise.Class.Serialise a, Data.Vector.Unboxed.Base.Unbox a) => Codec.Serialise.Class.Serialise (Data.Vector.Unboxed.Base.Vector a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Vector.Vector a)
instance Codec.Serialise.Class.Serialise GHC.Internal.Data.Version.Version
instance Codec.Serialise.Class.Serialise GHC.Internal.Base.Void
instance Codec.Serialise.Class.Serialise GHC.Types.Word
instance Codec.Serialise.Class.Serialise GHC.Internal.Word.Word16
instance Codec.Serialise.Class.Serialise GHC.Internal.Word.Word32
instance Codec.Serialise.Class.Serialise GHC.Internal.Word.Word64
instance Codec.Serialise.Class.Serialise GHC.Internal.Word.Word8
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (Data.Semigroup.WrappedMonoid a)
instance Codec.Serialise.Class.Serialise a => Codec.Serialise.Class.Serialise (GHC.Internal.Functor.ZipList.ZipList a)

-- | This module provides functions to serialise and deserialise Haskell
--   values for storage or transmission, to and from lazy
--   ByteStrings. It also provides a type class and
--   utilities to help you make your types serialisable.
--   
--   For a full tutorial on using this module, see
--   Codec.Serialise.Tutorial.
module Codec.Serialise

-- | Serialise a Haskell value to an external binary representation.
--   
--   The output is represented as a lazy ByteString and is
--   constructed incrementally.
serialise :: Serialise a => a -> ByteString

-- | Deserialise a Haskell value from the external binary representation
--   (which must have been made using serialise or related
--   function).
--   
--   Throws: DeserialiseFailure if the given
--   external representation is invalid or does not correspond to a value
--   of the expected type.
deserialise :: Serialise a => ByteString -> a

-- | Deserialise a Haskell value from the external binary representation,
--   or get back a DeserialiseFailure.
deserialiseOrFail :: Serialise a => ByteString -> Either DeserialiseFailure a

-- | An exception type that may be returned (by pure functions) or thrown
--   (by IO actions) that fail to deserialise a given input.
data DeserialiseFailure
DeserialiseFailure :: ByteOffset -> String -> DeserialiseFailure

-- | Serialise a Haskell value to an external binary representation.
--   
--   The output is represented as a Builder and is constructed
--   incrementally. The representation as a Builder allows efficient
--   concatenation with other data.
serialiseIncremental :: Serialise a => a -> Builder

-- | Deserialise a Haskell value from the external binary representation.
--   
--   This allows input data to be provided incrementally, rather
--   than all in one go. It also gives an explicit representation of
--   deserialisation errors.
--   
--   Note that the incremental behaviour is only for the input data, not
--   the output value: the final deserialised value is constructed and
--   returned as a whole, not incrementally.
deserialiseIncremental :: Serialise a => ST s (IDecode s a)

-- | An Incremental decoder, used to represent the result of attempting to
--   run a decoder over a given input, and return a value of type
--   a.
data IDecode s a

-- | The decoder has consumed the available input and needs more to
--   continue. Provide Just if more input is available and
--   Nothing otherwise, and you will get a new IDecode.
Partial :: (Maybe ByteString -> ST s (IDecode s a)) -> IDecode s a

-- | The decoder has successfully finished. Except for the output value you
--   also get any unused input as well as the number of bytes consumed.
Done :: !ByteString -> {-# UNPACK #-} !ByteOffset -> a -> IDecode s a

-- | The decoder ran into an error. The decoder either used fail or
--   was not provided enough input. Contains any unconsumed input, the
--   number of bytes consumed, and a DeserialiseFailure exception
--   describing the reason why the failure occurred.
Fail :: !ByteString -> {-# UNPACK #-} !ByteOffset -> DeserialiseFailure -> IDecode s a

-- | 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.
class Serialise a

-- | Definition for encoding a given type into a binary representation,
--   using the Encoding Monoid.
encode :: Serialise a => a -> Encoding
($dmencode) :: (Serialise a, Generic a, GSerialiseEncode (Rep a)) => a -> Encoding

-- | Definition of a given Decoder for a type.
decode :: Serialise a => Decoder s a
($dmdecode) :: (Serialise a, Generic a, GSerialiseDecode (Rep a)) => Decoder s a

-- | Utility to support specialised encoding for some list type - used for
--   Char/String instances in this package.
encodeList :: Serialise a => [a] -> Encoding

-- | Utility to support specialised decoding for some list type - used for
--   Char/String instances in this package.
decodeList :: Serialise a => Decoder s [a]

-- | Serialise a ByteString and write it directly to the
--   specified file.
writeFileSerialise :: Serialise a => FilePath -> a -> IO ()

-- | Read the specified file (internally, by reading a
--   ByteString) and attempt to decode it into a Haskell
--   value using deserialise (the type of which is
--   determined by the choice of the result type).
--   
--   Throws: DeserialiseFailure if the file fails to
--   deserialise properly.
readFileDeserialise :: Serialise a => FilePath -> IO a

-- | Serialise a ByteString (via serialise)
--   and write it directly to the specified Handle.
hPutSerialise :: Serialise a => Handle -> a -> IO ()

-- | High-level file-based API for serialising and deserialising values.
module Codec.Serialise.IO

-- | Serialise a ByteString and write it directly to the
--   specified file.
writeFileSerialise :: Serialise a => FilePath -> a -> IO ()

-- | Read the specified file (internally, by reading a
--   ByteString) and attempt to decode it into a Haskell
--   value using deserialise (the type of which is
--   determined by the choice of the result type).
--   
--   Throws: DeserialiseFailure if the file fails to
--   deserialise properly.
readFileDeserialise :: Serialise a => FilePath -> IO a

-- | Serialise a ByteString (via serialise)
--   and write it directly to the specified Handle.
hPutSerialise :: Serialise a => Handle -> a -> IO ()

-- | This module contains a set of generally useful properties, which
--   instance authors are encouraged to use in order to test their
--   instances of the Serialise class. For example, if you
--   have a data type which you might derive or write instances for:
--   
--   
--   data Foo = Foo { fooInt :: Int, fooBool :: Bool }
--     deriving (Eq, Show, Generic)
--   -- or, alternatively
--   instance Serialise Foo where
--     encode = ...
--     decode = ...
--   
--   
--   Then you can use this module to easily derive some quick properties:
--   
--   
--   import qualified Codec.Serialise.Properties as Props
--   
--   fooSerialiseId :: Foo -> Bool
--   fooSerialiseId = Props.serialiseIdentity
--   
--   fooFlatTermId :: Foo -> Bool
--   fooFlatTermId = Props.flatTermIdentity
--   
--   fooHasValidFlatTerm :: Foo -> Bool
--   fooHasValidFlatTerm = Props.hasValidFlatTerm
--   
--   
--   You can then conveniently use these three functions with QuickCheck,
--   for example.
module Codec.Serialise.Properties

-- | Ensure that serializing and deserializing some value results in the
--   original value being returned.
serialiseIdentity :: (Serialise a, Eq a) => a -> Bool

-- | Ensure that serializing and deserializing a value with the
--   FlatTerm form results in the original value being
--   returned.
flatTermIdentity :: (Serialise a, Eq a) => a -> Bool

-- | Ensure that serializing a value into a FlatTerm gives
--   us a valid FlatTerm back.
hasValidFlatTerm :: Serialise a => a -> Bool

-- | serialise library is built on cborg, they implement
--   CBOR (Concise Binary Object Representation, specified by IETF RFC
--   7049) and serialisers/deserializers for it.
module Codec.Serialise.Tutorial
