Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Data.Registry.Aeson.Encoder
Synopsis
- newtype Encoder a = Encoder {}
- newtype ConstructorEncoder = ConstructorEncoder {
- encodeConstructor :: Options -> FromConstructor -> (Value, Encoding)
- data FromConstructor = FromConstructor {}
- newtype KeyEncoder a = KeyEncoder {
- encodeAsKey :: a -> Key
- array :: [Value] -> Value
- encodeByteString :: Encoder a -> a -> ByteString
- encodeValue :: Encoder a -> a -> Value
- encodeKey :: forall a. Typeable a => (a -> Text) -> Typed (KeyEncoder a)
- keyEncoder :: (a -> Text) -> KeyEncoder a
- 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)
- encodeSetOf :: forall a. Typeable a => Typed (Encoder a -> Encoder (Set a))
- setOfEncoder :: Encoder a -> Encoder (Set a)
- encodeListOf :: forall a. Typeable a => Typed (Encoder a -> Encoder [a])
- listOfEncoder :: Encoder a -> Encoder [a]
- encodeMapOf :: forall a b. (Typeable a, Typeable b) => Typed (KeyEncoder a -> Encoder b -> Encoder (Map a b))
- mapOfEncoder :: KeyEncoder a -> Encoder b -> Encoder (Map a b)
- encodeNonEmptyOf :: forall a. Typeable a => Typed (Encoder a -> Encoder (NonEmpty a))
- nonEmptyOfEncoder :: Encoder a -> Encoder (NonEmpty a)
- defaultEncoderOptions :: Registry _ _
- defaultConstructorEncoder :: ConstructorEncoder
- textKeyEncoder :: KeyEncoder Text
- stringKeyEncoder :: KeyEncoder String
- makeEncoderFromConstructor :: Options -> FromConstructor -> (Value, Encoding)
- modifyFromConstructorWithOptions :: Options -> FromConstructor -> FromConstructor
- makeSumEncoding :: Options -> FromConstructor -> (Value, Encoding)
- valuesToObject :: [Text] -> [(Value, Encoding)] -> (Value, Encoding)
- module Data.Registry.Aeson.TH.Encoder
- module Data.Registry.Aeson.TH.ThOptions
Documentation
newtype ConstructorEncoder Source #
A ConstructorEncoder uses configuration options + type information extracted from a given data type (with TemplateHaskell) in order to produce a Value and an Encoding
Constructors
ConstructorEncoder | |
Fields
|
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
|
Instances
Show FromConstructor Source # | |
Defined in Data.Registry.Aeson.Encoder Methods showsPrec :: Int -> FromConstructor -> ShowS # show :: FromConstructor -> String # showList :: [FromConstructor] -> ShowS # | |
Eq FromConstructor Source # | |
Defined in Data.Registry.Aeson.Encoder Methods (==) :: FromConstructor -> FromConstructor -> Bool # (/=) :: FromConstructor -> FromConstructor -> Bool # |
newtype KeyEncoder a Source #
Constructors
KeyEncoder | |
Fields
|
Instances
Contravariant KeyEncoder Source # | |
Defined in Data.Registry.Aeson.Encoder Methods contramap :: (a' -> a) -> KeyEncoder a -> KeyEncoder a' # (>$) :: b -> KeyEncoder b -> KeyEncoder a # |
encodeByteString :: Encoder a -> a -> ByteString Source #
encodeValue :: Encoder a -> a -> Value Source #
encodeKey :: forall a. Typeable a => (a -> Text) -> Typed (KeyEncoder a) Source #
Make a key encoder from a function returning some text
keyEncoder :: (a -> Text) -> KeyEncoder a Source #
jsonEncoder :: forall a. (ToJSON a, Typeable a) => Typed (Encoder a) Source #
Create an encoder from a Aeson instance
jsonEncoderOf :: ToJSON a => Encoder a Source #
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)
encodeSetOf :: forall a. Typeable a => Typed (Encoder a -> Encoder (Set a)) Source #
Create an Encoder for a Set a
encodeListOf :: forall a. Typeable a => Typed (Encoder a -> Encoder [a]) Source #
Create an Encoder for a list [a]
listOfEncoder :: Encoder a -> Encoder [a] Source #
encodeMapOf :: forall a b. (Typeable a, Typeable b) => Typed (KeyEncoder a -> Encoder b -> Encoder (Map a b)) Source #
Create an Encoder for a map a b
mapOfEncoder :: KeyEncoder a -> Encoder b -> Encoder (Map a b) Source #
encodeNonEmptyOf :: forall a. Typeable a => Typed (Encoder a -> Encoder (NonEmpty a)) Source #
Create an Encoder for a non-empty list (NonEmpty a)
defaultEncoderOptions :: Registry _ _ Source #
defaultConstructorEncoder :: ConstructorEncoder Source #
Default implementation, it can be overridden in a registry
makeEncoderFromConstructor :: Options -> FromConstructor -> (Value, Encoding) Source #
Make an Encoder from Options and the representation of a constructor for a given value to encode
modifyFromConstructorWithOptions :: Options -> FromConstructor -> FromConstructor Source #
Apply Options to the constructor name + field names and remove Nothing values if necessary
makeSumEncoding :: Options -> FromConstructor -> (Value, Encoding) Source #