registry-aeson-0.2.0.0: Aeson encoders / decoders
Safe HaskellNone
LanguageHaskell2010

Data.Registry.Aeson.Encoder

Synopsis

ENCODER DATA TYPE

newtype Encoder a Source #

Constructors

Encoder 

Fields

Instances

Instances details
Contravariant Encoder Source # 
Instance details

Defined in Data.Registry.Aeson.Encoder

Methods

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

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

ENCODE VALUES

CREATE ENCODERS

fromValue :: (a -> Value) -> Encoder a Source #

Create an Encoder from a function returning a Value

jsonEncoder :: forall a. (ToJSON a, Typeable a) => Typed (Encoder a) Source #

Create an encoder from a Aeson 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)

array :: [Value] -> Value Source #

Shortcut function to create arrays

TEMPLATE HASKELL

makeEncoder :: Name -> ExpQ Source #

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

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

Constructors

FromConstructor 

Fields

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

valuesToObject :: [Text] -> [(Value, Encoding)] -> (Value, Encoding) Source #

Create an Object from a list of field names and a list of Values both as a Value and as an Encoding