registry-messagepack-0.3.1.0: MessagePack encoders / decoders
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Registry.MessagePack.Encoder

Synopsis

ENCODER DATA TYPE

newtype Encoder a Source #

Constructors

Encoder 

Fields

Instances

Instances details
Contravariant Encoder Source # 
Instance details

Defined in Data.Registry.MessagePack.Encoder

Methods

contramap :: (a' -> a) -> Encoder a -> Encoder a' #

(>$) :: b -> Encoder b -> Encoder a #

ENCODE VALUES

CREATE ENCODERS

messagePackEncoder :: forall a. (MessagePack a, Typeable a) => Typed (Encoder a) Source #

Create an encoder from a MessagePack instance

messagePackEncoderOf :: MessagePack a => Encoder a Source #

showEncoder :: forall a. (Typeable a, Show a) => Typed (Encoder String -> Encoder a) Source #

Create an encoder from a MessagePack instance

COMBINATORS

encodeMaybeOf :: forall a. Typeable a => Typed (Encoder a -> Encoder (Maybe a)) Source #

Create an Encoder for a (Maybe a)

encodePairOf :: forall a b. (Typeable a, Typeable b) => Typed (Encoder a -> Encoder b -> Encoder (a, b)) Source #

Create an Encoder for a pair (a, b)

encodeTripleOf :: forall a b c. (Typeable a, Typeable b, Typeable c) => Typed (Encoder a -> Encoder b -> Encoder c -> Encoder (a, b, c)) Source #

Create an Encoder for a tripe (a, b, c)

tripleOfEncoder :: Encoder a -> Encoder b -> Encoder c -> Encoder (a, b, c) Source #

encodeListOf :: forall a. Typeable a => Typed (Encoder a -> Encoder [a]) Source #

Create an Encoder for a list [a]

encodeNonEmptyOf :: forall a. Typeable a => Typed (Encoder a -> Encoder (NonEmpty a)) Source #

Create an Encoder for a non-empty list (NonEmpty a)

TEMPLATE HASKELL

makeEncoder :: Name -> ExpQ Source #

Make an Encoder for a given data type Usage: $(makeEncoder ''MyDataType <: otherEncoders)

makeEncoderQualified :: Name -> ExpQ Source #

Make an Encoder for a given data type, where all types names are qualified Usage: $(makeEncoderQualified ''MyDataType <: otherEncoders)

makeEncoderQualifiedLast :: Name -> ExpQ Source #

Make an Encoder for a given data type, where all types names are qualified Usage: $(makeEncoderQualifiedLast ''MyDataType <: otherEncoders)

makeEncoderWith :: Options -> Name -> ExpQ Source #

Make an Encoder for a given data type with a specific set of options Usage: $(makeEncoderWith (Options qualify) ''MyDataType <: otherEncoders)

makeConstructorEncoder :: Options -> Con -> ExpQ Source #

Make an Encoder for a data type with a single constructor (e0::Encoder A0) (e1::Encoder A1) ... -> Encoder $ (T a0 a1 ...) -> ObjectArray [encode e0 a0, encode e1 a1, ...]

makeConstructorsEncoder :: Options -> [Con] -> ExpQ Source #

Make an Encoder for a data type with several constructors (e0::Encoder A0) (e1::Encoder A1) (e2::Encoder A2) ... -> Encoder $ case T0 -> ObjectArray [ObjectInt 0] T1 a0 a1 ... -> ObjectArray [ObjectInt 1, encode e0 a0, encode e1 a1, ...] T2 a2 a0 ... -> ObjectArray [ObjectInt 2, encode e2 a2, encode e0 a0, ...]

makeMatchClause :: Options -> [Type] -> Con -> Integer -> MatchQ Source #

Make the match clause for a constructor given - the list of all the encoder types - the constructor name - the constructor index in the list of all the constructors for the encoded data type