Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data.Registry.MessagePack.Encoder
Synopsis
- newtype Encoder a = Encoder {
- encode :: a -> Object
- encodeByteString :: Encoder a -> a -> ByteString
- messagePackEncoder :: forall a. (MessagePack a, Typeable a) => Typed (Encoder a)
- messagePackEncoderOf :: MessagePack a => Encoder a
- showEncoder :: forall a. (Typeable a, Show a) => Typed (Encoder String -> Encoder a)
- showEncoderOf :: forall a. Show a => Encoder String -> Encoder a
- encodeMaybeOf :: forall a. Typeable a => Typed (Encoder a -> Encoder (Maybe a))
- maybeOfEncoder :: Encoder a -> Encoder (Maybe a)
- encodePairOf :: forall a b. (Typeable a, Typeable b) => Typed (Encoder a -> Encoder b -> Encoder (a, b))
- pairOfEncoder :: Encoder a -> Encoder b -> Encoder (a, b)
- encodeTripleOf :: forall a b c. (Typeable a, Typeable b, Typeable c) => Typed (Encoder a -> Encoder b -> Encoder c -> Encoder (a, b, c))
- tripleOfEncoder :: Encoder a -> Encoder b -> Encoder c -> Encoder (a, b, c)
- encodeListOf :: forall a. Typeable a => Typed (Encoder a -> Encoder [a])
- listOfEncoder :: Encoder a -> Encoder [a]
- encodeNonEmptyOf :: forall a. Typeable a => Typed (Encoder a -> Encoder (NonEmpty a))
- nonEmptyOfEncoder :: Encoder a -> Encoder (NonEmpty a)
- makeEncoder :: Name -> ExpQ
- makeEncoderQualified :: Name -> ExpQ
- makeEncoderQualifiedLast :: Name -> ExpQ
- makeEncoderWith :: Options -> Name -> ExpQ
- makeConstructorEncoder :: Options -> Con -> ExpQ
- makeConstructorsEncoder :: Options -> [Con] -> ExpQ
- makeMatchClause :: Options -> [Type] -> Con -> Integer -> MatchQ
ENCODER DATA TYPE
ENCODE VALUES
encodeByteString :: Encoder a -> a -> ByteString Source #
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)
encodeListOf :: forall a. Typeable a => Typed (Encoder a -> Encoder [a]) Source #
Create an Encoder for a list [a]
listOfEncoder :: Encoder a -> Encoder [a] Source #
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, ...]