Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Encoder a = Encoder {}
- encodeByteString :: Encoder a -> a -> ByteString
- encodeValue :: Encoder a -> a -> Value
- fromValue :: (a -> Value) -> Encoder a
- jsonEncoder :: forall a. (ToJSON a, Typeable a) => Typed (Encoder a)
- jsonEncoderOf :: ToJSON a => 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)
- array :: [Value] -> Value
- makeEncoder :: Name -> ExpQ
- makeConstructorsEncoder :: [Con] -> ExpQ
- makeMatchClause :: [Name] -> [Type] -> Con -> MatchQ
- data FromConstructor = FromConstructor {}
- modifyFromConstructorWithOptions :: Options -> FromConstructor -> FromConstructor
- makeEncoderFromConstructor :: Options -> FromConstructor -> (Value, Encoding)
- makeSumEncoding :: Options -> FromConstructor -> (Value, Encoding)
- valuesToObject :: [Text] -> [(Value, Encoding)] -> (Value, Encoding)
ENCODER DATA TYPE
ENCODE VALUES
encodeByteString :: Encoder a -> a -> ByteString Source #
encodeValue :: Encoder a -> a -> Value Source #
CREATE ENCODERS
jsonEncoder :: forall a. (ToJSON a, Typeable a) => Typed (Encoder a) Source #
Create an encoder from a Aeson instance
jsonEncoderOf :: ToJSON a => Encoder a Source #
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
makeConstructorsEncoder :: [Con] -> ExpQ Source #
makeMatchClause :: [Name] -> [Type] -> Con -> 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 T1 a0 a1 ... -> makeEncoderFromConstructor o (FromConstructor names types cName fieldNames values)
data FromConstructor Source #
Minimum set of data extracted from a given type with Template Haskell in order to create the appropriate encoder given an Options value
FromConstructor | |
|
Instances
Eq FromConstructor Source # | |
Defined in Data.Registry.Aeson.Encoder (==) :: FromConstructor -> FromConstructor -> Bool # (/=) :: FromConstructor -> FromConstructor -> Bool # | |
Show FromConstructor Source # | |
Defined in Data.Registry.Aeson.Encoder showsPrec :: Int -> FromConstructor -> ShowS # show :: FromConstructor -> String # showList :: [FromConstructor] -> ShowS # |
modifyFromConstructorWithOptions :: Options -> FromConstructor -> FromConstructor Source #
Apply Options to the constructor name + field names and remove Nothing values if necessary
makeEncoderFromConstructor :: Options -> FromConstructor -> (Value, Encoding) Source #
Make an Encoder from Options and the representation of a constructor for a given value to encode
makeSumEncoding :: Options -> FromConstructor -> (Value, Encoding) Source #