Z-MessagePack-0.4.1.0: MessagePack
Copyright(c) Dong Han 2020
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.Data.MessagePack.Base

Description

This module provides various tools to help user define MessagePack instance, please import MessagePack to get more instances.

Synopsis

MessagePack Class

class MessagePack a where Source #

Type class for encode & decode MessagePack.

Minimal complete definition

Nothing

Methods

fromValue :: Value -> Converter a Source #

default fromValue :: (Generic a, GFromValue (Rep a)) => Value -> Converter a Source #

toValue :: a -> Value Source #

default toValue :: (Generic a, GToValue (Rep a)) => a -> Value Source #

encodeMessagePack :: a -> Builder () Source #

default encodeMessagePack :: (Generic a, GEncodeMessagePack (Rep a)) => a -> Builder () Source #

Instances

Instances details
MessagePack Bool Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Char Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Double Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Float Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Int Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Int8 Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Int16 Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Int32 Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Int64 Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Integer Source #

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Integer and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Natural Source #

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Natural and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Ordering Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Word Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Word8 Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Word16 Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Word32 Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Word64 Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack () Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter () Source #

toValue :: () -> Value Source #

encodeMessagePack :: () -> Builder () Source #

MessagePack Version Source #

Only round trip versionBranch as MessagePack array.

Instance details

Defined in Z.Data.MessagePack

MessagePack ExitCode Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CChar Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CSChar Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CUChar Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CShort Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CUShort Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CInt Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CUInt Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CLong Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CULong Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CLLong Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CULLong Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CBool Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CFloat Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CDouble Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CPtrdiff Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CSize Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CWchar Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CSigAtomic Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CClock Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CTime Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CUSeconds Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CSUSeconds Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CIntPtr Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CUIntPtr Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CIntMax Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack CUIntMax Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack String Source #

This is an INCOHERENT instance, encode String with Str.

Instance details

Defined in Z.Data.MessagePack.Base

MessagePack IntSet Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack ZonedTime Source #
YYYY-MM-DDTHH:MM:SS.SSSZ
Instance details

Defined in Z.Data.MessagePack

MessagePack LocalTime Source #
YYYY-MM-DDTHH:MM:SS.SSSZ
Instance details

Defined in Z.Data.MessagePack

MessagePack TimeOfDay Source #
HH:MM:SS.SSS
Instance details

Defined in Z.Data.MessagePack

MessagePack CalendarDiffTime Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack UTCTime Source #

MessagePack extension type Ext 0xFF

Instance details

Defined in Z.Data.MessagePack

MessagePack SystemTime Source #

MessagePack extension type Ext 0xFF

Instance details

Defined in Z.Data.MessagePack

MessagePack NominalDiffTime Source #

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype NominalDiffTime and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Z.Data.MessagePack

MessagePack DiffTime Source #

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype DiffTime and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Z.Data.MessagePack

MessagePack DayOfWeek Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack Day Source #
YYYY-MM-DD
Instance details

Defined in Z.Data.MessagePack

MessagePack CalendarDiffDays Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack Text Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter Text Source #

toValue :: Text -> Value Source #

encodeMessagePack :: Text -> Builder () Source #

MessagePack Bytes Source #

This is an INCOHERENT instance, write Bytes as Bin.

Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter Bytes Source #

toValue :: Bytes -> Value Source #

encodeMessagePack :: Bytes -> Builder () Source #

MessagePack Value Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack Scientific Source #

Note this instance doesn't reject large input

Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter Scientific Source #

toValue :: Scientific -> Value Source #

encodeMessagePack :: Scientific -> Builder () Source #

MessagePack ByteArray Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter ByteArray Source #

toValue :: ByteArray -> Value Source #

encodeMessagePack :: ByteArray -> Builder () Source #

MessagePack CBytes Source #

Write CBytes as Bin not Str.

Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter CBytes Source #

toValue :: CBytes -> Value Source #

encodeMessagePack :: CBytes -> Builder () Source #

MessagePack FlatIntSet Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter FlatIntSet Source #

toValue :: FlatIntSet -> Value Source #

encodeMessagePack :: FlatIntSet -> Builder () Source #

MessagePack a => MessagePack [a] Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter [a] Source #

toValue :: [a] -> Value Source #

encodeMessagePack :: [a] -> Builder () Source #

MessagePack a => MessagePack (Maybe a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

(MessagePack a, Integral a) => MessagePack (Ratio a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack a => MessagePack (Min a) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (Min a) Source #

toValue :: Min a -> Value Source #

encodeMessagePack :: Min a -> Builder () Source #

MessagePack a => MessagePack (Max a) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (Max a) Source #

toValue :: Max a -> Value Source #

encodeMessagePack :: Max a -> Builder () Source #

MessagePack a => MessagePack (First a) Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack a => MessagePack (Last a) Source # 
Instance details

Defined in Z.Data.MessagePack

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

Defined in Z.Data.MessagePack

MessagePack a => MessagePack (Identity a) Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack a => MessagePack (First a) Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack a => MessagePack (Last a) Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack a => MessagePack (Dual a) Source # 
Instance details

Defined in Z.Data.MessagePack

MessagePack a => MessagePack (NonEmpty a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack a => MessagePack (IntMap a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack a => MessagePack (Tree a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

MessagePack a => MessagePack (Seq a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (Seq a) Source #

toValue :: Seq a -> Value Source #

encodeMessagePack :: Seq a -> Builder () Source #

(Ord a, MessagePack a) => MessagePack (Set a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (Set a) Source #

toValue :: Set a -> Value Source #

encodeMessagePack :: Set a -> Builder () Source #

(Prim a, MessagePack a) => MessagePack (PrimVector a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (PrimVector a) Source #

toValue :: PrimVector a -> Value Source #

encodeMessagePack :: PrimVector a -> Builder () Source #

MessagePack a => MessagePack (Vector a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (Vector a) Source #

toValue :: Vector a -> Value Source #

encodeMessagePack :: Vector a -> Builder () Source #

MessagePack a => MessagePack (Array a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (Array a) Source #

toValue :: Array a -> Value Source #

encodeMessagePack :: Array a -> Builder () Source #

(Prim a, MessagePack a) => MessagePack (PrimArray a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (PrimArray a) Source #

toValue :: PrimArray a -> Value Source #

encodeMessagePack :: PrimArray a -> Builder () Source #

MessagePack a => MessagePack (SmallArray a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (SmallArray a) Source #

toValue :: SmallArray a -> Value Source #

encodeMessagePack :: SmallArray a -> Builder () Source #

(Eq a, Hashable a, MessagePack a) => MessagePack (HashSet a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (HashSet a) Source #

toValue :: HashSet a -> Value Source #

encodeMessagePack :: HashSet a -> Builder () Source #

MessagePack a => MessagePack (FlatIntMap a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (FlatIntMap a) Source #

toValue :: FlatIntMap a -> Value Source #

encodeMessagePack :: FlatIntMap a -> Builder () Source #

(Ord a, MessagePack a) => MessagePack (FlatSet a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (FlatSet a) Source #

toValue :: FlatSet a -> Value Source #

encodeMessagePack :: FlatSet a -> Builder () Source #

(MessagePack a, MessagePack b) => MessagePack (Either a b) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (Either a b) Source #

toValue :: Either a b -> Value Source #

encodeMessagePack :: Either a b -> Builder () Source #

(MessagePack a, MessagePack b) => MessagePack (a, b) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (a, b) Source #

toValue :: (a, b) -> Value Source #

encodeMessagePack :: (a, b) -> Builder () Source #

HasResolution a => MessagePack (Fixed a) Source #

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Fixed and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Z.Data.MessagePack.Base

MessagePack (Proxy a) Source #

Use Nil as Proxy a

Instance details

Defined in Z.Data.MessagePack.Base

(Ord a, MessagePack a, MessagePack b) => MessagePack (Map a b) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (Map a b) Source #

toValue :: Map a b -> Value Source #

encodeMessagePack :: Map a b -> Builder () Source #

(PrimUnlifted a, MessagePack a) => MessagePack (UnliftedArray a) Source # 
Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (UnliftedArray a) Source #

toValue :: UnliftedArray a -> Value Source #

encodeMessagePack :: UnliftedArray a -> Builder () Source #

(Eq a, Hashable a, MessagePack a, MessagePack b) => MessagePack (HashMap a b) Source #

default instance prefer later key

Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (HashMap a b) Source #

toValue :: HashMap a b -> Value Source #

encodeMessagePack :: HashMap a b -> Builder () Source #

(Ord a, MessagePack a, MessagePack b) => MessagePack (FlatMap a b) Source #

default instance prefer later key

Instance details

Defined in Z.Data.MessagePack.Base

Methods

fromValue :: Value -> Converter (FlatMap a b) Source #

toValue :: FlatMap a b -> Value Source #

encodeMessagePack :: FlatMap a b -> Builder () Source #

(MessagePack a, MessagePack b, MessagePack c) => MessagePack (a, b, c) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (a, b, c) Source #

toValue :: (a, b, c) -> Value Source #

encodeMessagePack :: (a, b, c) -> Builder () Source #

MessagePack a => MessagePack (Const a b) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (Const a b) Source #

toValue :: Const a b -> Value Source #

encodeMessagePack :: Const a b -> Builder () Source #

MessagePack b => MessagePack (Tagged a b) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (Tagged a b) Source #

toValue :: Tagged a b -> Value Source #

encodeMessagePack :: Tagged a b -> Builder () Source #

(MessagePack a, MessagePack b, MessagePack c, MessagePack d) => MessagePack (a, b, c, d) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (a, b, c, d) Source #

toValue :: (a, b, c, d) -> Value Source #

encodeMessagePack :: (a, b, c, d) -> Builder () Source #

(MessagePack (f a), MessagePack (g a)) => MessagePack (Product f g a) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (Product f g a) Source #

toValue :: Product f g a -> Value Source #

encodeMessagePack :: Product f g a -> Builder () Source #

(MessagePack (f a), MessagePack (g a), MessagePack a) => MessagePack (Sum f g a) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (Sum f g a) Source #

toValue :: Sum f g a -> Value Source #

encodeMessagePack :: Sum f g a -> Builder () Source #

(MessagePack a, MessagePack b, MessagePack c, MessagePack d, MessagePack e) => MessagePack (a, b, c, d, e) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (a, b, c, d, e) Source #

toValue :: (a, b, c, d, e) -> Value Source #

encodeMessagePack :: (a, b, c, d, e) -> Builder () Source #

MessagePack (f (g a)) => MessagePack (Compose f g a) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (Compose f g a) Source #

toValue :: Compose f g a -> Value Source #

encodeMessagePack :: Compose f g a -> Builder () Source #

(MessagePack a, MessagePack b, MessagePack c, MessagePack d, MessagePack e, MessagePack f) => MessagePack (a, b, c, d, e, f) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (a, b, c, d, e, f) Source #

toValue :: (a, b, c, d, e, f) -> Value Source #

encodeMessagePack :: (a, b, c, d, e, f) -> Builder () Source #

(MessagePack a, MessagePack b, MessagePack c, MessagePack d, MessagePack e, MessagePack f, MessagePack g) => MessagePack (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Z.Data.MessagePack

Methods

fromValue :: Value -> Converter (a, b, c, d, e, f, g) Source #

toValue :: (a, b, c, d, e, f, g) -> Value Source #

encodeMessagePack :: (a, b, c, d, e, f, g) -> Builder () Source #

data Value Source #

Representation of MessagePack data.

Constructors

Bool !Bool

true or false

Int !Int64

an integer

Float !Float

a floating point number

Double !Double

a floating point number

Str !Text

a UTF-8 string

Bin !Bytes

a byte array

Array !(Vector Value)

a sequence of objects

Map !(Vector (Value, Value))

key-value pairs of objects

Ext 

Fields

  • !Word8

    type tag

  • !Bytes

    data payload

Nil

nil

Instances

Instances details
Eq Value Source # 
Instance details

Defined in Z.Data.MessagePack.Value

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Ord Value Source # 
Instance details

Defined in Z.Data.MessagePack.Value

Methods

compare :: Value -> Value -> Ordering #

(<) :: Value -> Value -> Bool #

(<=) :: Value -> Value -> Bool #

(>) :: Value -> Value -> Bool #

(>=) :: Value -> Value -> Bool #

max :: Value -> Value -> Value #

min :: Value -> Value -> Value #

Show Value Source # 
Instance details

Defined in Z.Data.MessagePack.Value

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

Generic Value Source # 
Instance details

Defined in Z.Data.MessagePack.Value

Associated Types

type Rep Value :: Type -> Type #

Methods

from :: Value -> Rep Value x #

to :: Rep Value x -> Value #

NFData Value Source # 
Instance details

Defined in Z.Data.MessagePack.Value

Methods

rnf :: Value -> () #

Arbitrary Value Source # 
Instance details

Defined in Z.Data.MessagePack.Value

Methods

arbitrary :: Gen Value

shrink :: Value -> [Value]

Print Value Source # 
Instance details

Defined in Z.Data.MessagePack.Value

Methods

toUTF8BuilderP :: Int -> Value -> Builder ()

MessagePack Value Source # 
Instance details

Defined in Z.Data.MessagePack.Base

type Rep Value Source # 
Instance details

Defined in Z.Data.MessagePack.Value

type Rep Value = D1 ('MetaData "Value" "Z.Data.MessagePack.Value" "Z-MessagePack-0.4.1.0-inplace" 'False) (((C1 ('MetaCons "Bool" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "Int" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64))) :+: (C1 ('MetaCons "Float" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Float)) :+: (C1 ('MetaCons "Double" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Double)) :+: C1 ('MetaCons "Str" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Text))))) :+: ((C1 ('MetaCons "Bin" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Bytes)) :+: C1 ('MetaCons "Array" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (Vector Value)))) :+: (C1 ('MetaCons "Map" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (Vector (Value, Value)))) :+: (C1 ('MetaCons "Ext" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word8) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Bytes)) :+: C1 ('MetaCons "Nil" 'PrefixI 'False) (U1 :: Type -> Type)))))

defaultSettings :: Settings Source #

Settings T.pack T.pack False

data Settings Source #

Generic encode/decode Settings

Constructors

Settings 

Fields

Encode & Decode

decode :: MessagePack a => Bytes -> (Bytes, Either DecodeError a) Source #

Decode a MessagePack bytes, return any trailing bytes.

decode' :: MessagePack a => Bytes -> Either DecodeError a Source #

Decode a MessagePack doc, trailing bytes are not allowed.

decodeChunk :: MessagePack a => Bytes -> Result DecodeError a Source #

Decode a MessagePack doc chunk.

decodeChunks :: (MessagePack a, Monad m) => ParseChunks m DecodeError a Source #

Decode MessagePack doc chunks, return trailing bytes.

encode :: MessagePack a => a -> Bytes Source #

Directly encode data to MessagePack bytes.

encodeChunks :: MessagePack a => a -> [Bytes] Source #

Encode data to MessagePack bytes chunks.

type ParseError = [Text] #

type ParseChunks (m :: Type -> Type) err x = m Bytes -> Bytes -> m (Bytes, Either err x) #

parse into MessagePack Value

parseValue :: Bytes -> (Bytes, Either ParseError Value) Source #

Parse Value without consuming trailing bytes.

parseValue' :: Bytes -> Either ParseError Value Source #

Parse Value, if there're bytes left, parsing will fail.

Generic FromValue, ToValue & EncodeMessagePack

gToValue :: GToValue f => Settings -> f a -> Value Source #

gFromValue :: GFromValue f => Settings -> Value -> Converter (f a) Source #

gEncodeMessagePack :: GEncodeMessagePack f => Settings -> f a -> Builder () Source #

Convert Value to Haskell data

convertValue :: MessagePack a => Value -> Either ConvertError a Source #

Run a Converter with input value.

newtype Converter a #

Constructors

Converter 

Fields

Instances

Instances details
Monad Converter 
Instance details

Defined in Z.Data.JSON.Converter

Methods

(>>=) :: Converter a -> (a -> Converter b) -> Converter b #

(>>) :: Converter a -> Converter b -> Converter b #

return :: a -> Converter a #

Functor Converter 
Instance details

Defined in Z.Data.JSON.Converter

Methods

fmap :: (a -> b) -> Converter a -> Converter b #

(<$) :: a -> Converter b -> Converter a #

MonadFail Converter 
Instance details

Defined in Z.Data.JSON.Converter

Methods

fail :: String -> Converter a #

Applicative Converter 
Instance details

Defined in Z.Data.JSON.Converter

Methods

pure :: a -> Converter a #

(<*>) :: Converter (a -> b) -> Converter a -> Converter b #

liftA2 :: (a -> b -> c) -> Converter a -> Converter b -> Converter c #

(*>) :: Converter a -> Converter b -> Converter b #

(<*) :: Converter a -> Converter b -> Converter a #

Alternative Converter 
Instance details

Defined in Z.Data.JSON.Converter

Methods

empty :: Converter a #

(<|>) :: Converter a -> Converter a -> Converter a #

some :: Converter a -> Converter [a] #

many :: Converter a -> Converter [a] #

MonadPlus Converter 
Instance details

Defined in Z.Data.JSON.Converter

Methods

mzero :: Converter a #

mplus :: Converter a -> Converter a -> Converter a #

fail' :: Text -> Converter a #

data PathElement #

Constructors

Key !Text 
Index !Int 
Embedded 

Instances

Instances details
Eq PathElement 
Instance details

Defined in Z.Data.JSON.Converter

Ord PathElement 
Instance details

Defined in Z.Data.JSON.Converter

Show PathElement 
Instance details

Defined in Z.Data.JSON.Converter

Generic PathElement 
Instance details

Defined in Z.Data.JSON.Converter

Associated Types

type Rep PathElement :: Type -> Type #

NFData PathElement 
Instance details

Defined in Z.Data.JSON.Converter

Methods

rnf :: PathElement -> () #

type Rep PathElement 
Instance details

Defined in Z.Data.JSON.Converter

type Rep PathElement = D1 ('MetaData "PathElement" "Z.Data.JSON.Converter" "Z-Data-0.8.1.0-e14e3a5f884e920ae8487b13f376e5e63ba9eba2193145237efd17f5b1027fc9" 'False) (C1 ('MetaCons "Key" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 Text)) :+: (C1 ('MetaCons "Index" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 Int)) :+: C1 ('MetaCons "Embedded" 'PrefixI 'False) (U1 :: Type -> Type)))

data ConvertError #

Constructors

ConvertError 

Fields

Instances

Instances details
Eq ConvertError 
Instance details

Defined in Z.Data.JSON.Converter

Ord ConvertError 
Instance details

Defined in Z.Data.JSON.Converter

Show ConvertError 
Instance details

Defined in Z.Data.JSON.Converter

Generic ConvertError 
Instance details

Defined in Z.Data.JSON.Converter

Associated Types

type Rep ConvertError :: Type -> Type #

NFData ConvertError 
Instance details

Defined in Z.Data.JSON.Converter

Methods

rnf :: ConvertError -> () #

Print ConvertError 
Instance details

Defined in Z.Data.JSON.Converter

Methods

toUTF8BuilderP :: Int -> ConvertError -> Builder ()

type Rep ConvertError 
Instance details

Defined in Z.Data.JSON.Converter

type Rep ConvertError = D1 ('MetaData "ConvertError" "Z.Data.JSON.Converter" "Z-Data-0.8.1.0-e14e3a5f884e920ae8487b13f376e5e63ba9eba2193145237efd17f5b1027fc9" 'False) (C1 ('MetaCons "ConvertError" 'PrefixI 'True) (S1 ('MetaSel ('Just "errPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PathElement]) :*: S1 ('MetaSel ('Just "errMsg") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

typeMismatch Source #

Arguments

:: Text

The name of the type you are trying to convert.

-> Text

The MessagePack value type you expecting to meet.

-> Value

The actual value encountered.

-> Converter a 

Produce an error message like converting XXX failed, expected XXX, encountered XXX.

fromNil :: Text -> a -> Value -> Converter a Source #

withBool :: Text -> (Bool -> Converter a) -> Value -> Converter a Source #

withStr :: Text -> (Text -> Converter a) -> Value -> Converter a Source #

withBin :: Text -> (Bytes -> Converter a) -> Value -> Converter a Source #

withArray :: Text -> (Vector Value -> Converter a) -> Value -> Converter a Source #

withKeyValues :: Text -> (Vector (Value, Value) -> Converter a) -> Value -> Converter a Source #

Directly use Map as key-values for further converting.

withFlatMap :: Text -> (FlatMap Value Value -> Converter a) -> Value -> Converter a Source #

Take a Map as an 'FM.FlatMap Value Value', on key duplication prefer first one.

withFlatMapR :: Text -> (FlatMap Value Value -> Converter a) -> Value -> Converter a Source #

Take a Map as an 'FM.FlatMap Value Value', on key duplication prefer last one.

withBoundedScientific :: Text -> (Scientific -> Converter a) -> Value -> Converter a Source #

withBoundedScientific name f value applies f to the Scientific number when value is a Ext 0x00/0x01 with exponent less than or equal to 1024.

(.:) :: MessagePack a => FlatMap Value Value -> Text -> Converter a Source #

Retrieve the value associated with the given key of an Map. The result is empty if the key is not present or the value cannot be converted to the desired type.

This accessor is appropriate if the key and value must be present in an object for it to be valid. If the key and value are optional, use .:? instead.

(.:?) :: MessagePack a => FlatMap Value Value -> Text -> Converter (Maybe a) Source #

Retrieve the value associated with the given key of an Map. The result is Nothing if the key is not present or if its value is Nil, or fail if the value cannot be converted to the desired type.

This accessor is most useful if the key and value can be absent from an object without affecting its validity. If the key and value are mandatory, use .: instead.

(.:!) :: MessagePack a => FlatMap Value Value -> Text -> Converter (Maybe a) Source #

Retrieve the value associated with the given key of an Map. The result is Nothing if the key is not present or fail if the value cannot be converted to the desired type.

This differs from .:? by attempting to convert Nil the same as any other MessagePack value, instead of interpreting it as Nothing.

convertField Source #

Arguments

:: (Value -> Converter a)

the field converter (value part of a key value pair)

-> FlatMap Value Value 
-> Text 
-> Converter a 

convertFieldMaybe :: (Value -> Converter a) -> FlatMap Value Value -> Text -> Converter (Maybe a) Source #

Variant of .:? with explicit converter function.

convertFieldMaybe' :: (Value -> Converter a) -> FlatMap Value Value -> Text -> Converter (Maybe a) Source #

Variant of .:! with explicit converter function.

Helper for manually writing instance.

(.=) :: MessagePack v => Text -> v -> (Value, Value) infixr 8 Source #

Connect key and value to a tuple to be used with object.

object :: [(Value, Value)] -> Value Source #

Alias for Map . pack.

(.!) :: MessagePack v => Text -> v -> KVItem infixr 8 Source #

Connect key and value to a KVItem using colon, key will be escaped.

object' :: KVItem -> Builder () Source #

Write map header and KVItems.

data KVItem Source #

A newtype for Builder, whose semigroup's instance is to connect kv builder and sum kv length.

Instances

Instances details
Semigroup KVItem Source # 
Instance details

Defined in Z.Data.MessagePack.Base