aeson-deriving-0.1.1.1: data types for compositional, type-directed serialization

Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Deriving.Generic

Contents

Synopsis

Typeclass for aeson Options

class ToAesonOptions a where Source #

A class for defining Options for Aeson's Generic deriving support. It is generally instantiated by overriding specific fields using the instance for (type-level) list values. It can also be instantiated in a more exhaustive way using the GenericOptions type. In both cases fields are specified in a record-like form using the '(:=)' data type for explicitness.

See the ReadMe or tests for examples.

Users may also provide instances for their own phantom data types if desired.

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

ToAesonOptions ([] :: [k]) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

(TypeError ToAesonOptionsListError :: Constraint) => ToAesonOptions ([a] :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

(ToAesonOptionsField x, ToAesonOptions xs) => ToAesonOptions (x ': xs :: [a]) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (x ': xs) -> Options Source #

(TypeError ToAesonOptionsListError :: Constraint) => ToAesonOptions [] Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

newtypes for Generic encodings

Main data type for Generic encodings

newtype GenericEncoded opts a Source #

Specify your encoding scheme in terms of aeson's out-of-the box Generic functionality. This type is never used directly, only "coerced through". Use some of the pre-defined types supplied here for the opts phantom parameter, or define your with an instance of ToAesonOptions.

Constructors

GenericEncoded a 

Data type for encodings of composite "sum-of-records" types

newtype RecordSumEncoded (tagKey :: Symbol) (tagModifier :: k) (a :: Type) Source #

An encoding scheme for sums of records that are defined as distinct data types. If we have a number of record types we want to combine under a sum, a straightforward solution is to ensure that each each inner type uses a constructor tag, and then derive the sum with SumEncoding := UntaggedValue. This works fine for the happy path, but makes for very bad error messages, since it means that decoding proceeds by trying each case in sequence. Thus error messages always pertain to the last type in the sum, even when it wasn't the intended payload. This newtype improves on that solution by providing the relevant error messages, by remembering the correspondence between the constructor tag and the intended inner type/parser.

In order to work correctly, the inner types must use the TaggedObject encoding. The same tag field name and ConstructorTagModifier must be supplied to this type.

Constructors

RecordSumEncoded a 
Instances
(Generic a, GToJSON Zero (Rep a)) => ToJSON (RecordSumEncoded tagKey tagModifier a) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toJSON :: RecordSumEncoded tagKey tagModifier a -> Value #

toEncoding :: RecordSumEncoded tagKey tagModifier a -> Encoding #

toJSONList :: [RecordSumEncoded tagKey tagModifier a] -> Value #

toEncodingList :: [RecordSumEncoded tagKey tagModifier a] -> Encoding #

(Generic a, GFromJSON Zero (Rep a), GTagParserMap (Rep a), Rep a ~ D1 meta cs, Datatype meta, StringFunction tagModifier, KnownSymbol tagKey) => FromJSON (RecordSumEncoded tagKey tagModifier a) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

parseJSON :: Value -> Parser (RecordSumEncoded tagKey tagModifier a) #

parseJSONList :: Value -> Parser [RecordSumEncoded tagKey tagModifier a] #

Phantom types for specifying Options

Many-parameter type for explicitly providing all Options fields.

data GenericOptions :: fieldLabelModifier -> constructorTagModifier -> allNullaryToStringTag -> omitNothingFields -> sumEncoding -> unwrapUnaryRecords -> tagSingleConstructors -> Type Source #

Type-level representation of the Aeson Generic deriving Options. This representation is useful for explicitly setting all options.

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

Types for supplying specific Options fields

Type representing field assignment

data field := (value :: k) infix 3 Source #

Phantom data type to make explicit which fields we pass for Aeson options. Polykinded in the second argument so it can take i.e. Booleans or Symbols where needed.

Also used for specifying constant values added to, or required from, an encoding. See Data.Aeson.Deriving.WithConstantFields.

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

(KnownJSONObject fields, KnownSymbol key, KnownJSON val) => KnownJSONObject ((key := val) ': fields :: [Type]) Source # 
Instance details

Defined in Data.Aeson.Deriving.Known

Methods

objectVal :: Proxy ((key := val) ': fields) -> Object Source #

KnownBool b => ToAesonOptionsField (TagSingleConstructors := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

KnownBool b => ToAesonOptionsField (UnwrapUnaryRecords := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

KnownBool b => ToAesonOptionsField (OmitNothingFields := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

KnownBool b => ToAesonOptionsField (AllNullaryToStringTag := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction f => ToAesonOptionsField (ConstructorTagModifier := f :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction f => ToAesonOptionsField (FieldLabelModifier := f :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

ToSumEncoding se => ToAesonOptionsField (SumEncoding := se :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Typeclass for Options fields

class ToAesonOptionsField x Source #

A class that knows about fields of aeson's Options.

Minimal complete definition

toAesonOptionsField

Instances
KnownBool b => ToAesonOptionsField (TagSingleConstructors := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

KnownBool b => ToAesonOptionsField (UnwrapUnaryRecords := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

KnownBool b => ToAesonOptionsField (OmitNothingFields := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

KnownBool b => ToAesonOptionsField (AllNullaryToStringTag := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction f => ToAesonOptionsField (ConstructorTagModifier := f :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction f => ToAesonOptionsField (FieldLabelModifier := f :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

ToSumEncoding se => ToAesonOptionsField (SumEncoding := se :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Types representing Options fields

data FieldLabelModifier Source #

Represents an aeson Options field to be set with `(:=)`. See ToAesonOptions

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

StringFunction f => ToAesonOptionsField (FieldLabelModifier := f :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

data ConstructorTagModifier Source #

Represents an aeson Options field to be set with `(:=)`. See ToAesonOptions

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

StringFunction f => ToAesonOptionsField (ConstructorTagModifier := f :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

data AllNullaryToStringTag Source #

Represents an aeson Options field to be set with `(:=)`. See ToAesonOptions

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

KnownBool b => ToAesonOptionsField (AllNullaryToStringTag := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

data OmitNothingFields Source #

Represents an aeson Options field to be set with `(:=)`. See ToAesonOptions

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

KnownBool b => ToAesonOptionsField (OmitNothingFields := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

data SumEncoding #

Specifies how to encode constructors of a sum datatype.

Instances
Eq SumEncoding 
Instance details

Defined in Data.Aeson.Types.Internal

Show SumEncoding 
Instance details

Defined in Data.Aeson.Types.Internal

(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

ToSumEncoding se => ToAesonOptionsField (SumEncoding := se :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

data UnwrapUnaryRecords Source #

Represents an aeson Options field to be set with `(:=)`. See ToAesonOptions

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

KnownBool b => ToAesonOptionsField (UnwrapUnaryRecords := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

data TagSingleConstructors Source #

Represents an aeson Options field to be set with `(:=)`. See ToAesonOptions

Instances
(All (StringFunction :: k2 -> Constraint) (fieldLabelModifier ': (constructorTagModifier ': ([] :: [k2]))), ToSumEncoding sumEncoding, All KnownBool (allNullaryToStringTag ': (omitNothingFields ': (unwrapUnaryRecords ': (tagSingleConstructors ': ([] :: [Bool])))))) => ToAesonOptions (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors) :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toAesonOptions :: Proxy (GenericOptions (FieldLabelModifier := fieldLabelModifier) (ConstructorTagModifier := constructorTagModifier) (AllNullaryToStringTag := allNullaryToStringTag) (OmitNothingFields := omitNothingFields) (SumEncoding := sumEncoding) (UnwrapUnaryRecords := unwrapUnaryRecords) (TagSingleConstructors := tagSingleConstructors)) -> Options Source #

KnownBool b => ToAesonOptionsField (TagSingleConstructors := b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

class StringFunction (a :: k) where Source #

Instances
StringFunction DropLowercasePrefix Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction Lowercase Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction Uppercase Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction SnakeCase Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction Id Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction ([] :: [k]) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

KnownSymbol str => StringFunction (DropSuffix str :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

KnownSymbol str => StringFunction (DropPrefix str :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

StringFunction a => StringFunction (FirstChar a :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

(StringFunction x, StringFunction xs) => StringFunction (x ': xs :: [a]) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

stringFunction :: Proxy (x ': xs) -> String -> String Source #

All KnownSymbol (a ': (b ': ([] :: [Symbol]))) => StringFunction (a ==> b :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

stringFunction :: Proxy (a ==> b) -> String -> String Source #

data DropLowercasePrefix Source #

Applies dropLowercasePrefix, dropping until the first uppercase character.

data DropPrefix (str :: Symbol) Source #

Instances
KnownSymbol str => StringFunction (DropPrefix str :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

data DropSuffix (str :: Symbol) Source #

Instances
KnownSymbol str => StringFunction (DropSuffix str :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

data Id Source #

snakeCase :: String -> String Source #

Field name modifier function that separates camel-case words by underscores (i.e. on capital letters). Also knows to handle a consecutive sequence of capitals as a single word.

dropLowercasePrefix :: String -> String Source #

Drop the first lowercase sequence (i.e. until isUpper returns True) from the start of a string. Used for the common idiom where fields are prefixed by the type name in all lowercase. The definition is taken from the aeson-casing package.

data TaggedObject (tagFieldName :: Symbol) (contentsFieldName :: Symbol) Source #

A constructor will be encoded to an object with a field tagFieldName which specifies the constructor tag (modified by the constructorTagModifier). If the constructor is a record the encoded record fields will be unpacked into this object. So make sure that your record doesn't have a field with the same label as the tagFieldName. Otherwise the tag gets overwritten by the encoded value of that field! If the constructor is not a record the encoded constructor contents will be stored under the contentsFieldName field.

Instances
(KnownSymbol tag, KnownSymbol contents) => ToSumEncoding (TaggedObject tag contents :: Type) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toSumEncoding :: Proxy (TaggedObject tag contents) -> SumEncoding Source #

Safety class

type family LoopWarning (n :: Type -> Type) (a :: Type) :: Constraint where ... Source #

Used in FromJSON/ToJSON superclass constraints for newtypes that recursively modify the instances. A guard against the common mistake of deriving encoders in terms of such a newtype over the naked base type instead of the GenericEncoded version. This can lead to nasty runtime bugs.

This error can be disabled by wrapping your type in DisableLoopWarning. This should never be necessary to use the functionality of this package. It may be required if you, for example, combine our newtypes with another library's types for generating aeson instances.

Equations

LoopWarning n (GenericEncoded opts a) = () 
LoopWarning n (RecordSumEncoded tagKey tagValMod a) = () 
LoopWarning n (DisableLoopWarning a) = () 
LoopWarning n (x & f) = LoopWarning n (f x) 
LoopWarning n (f x) = LoopWarning n x 
LoopWarning n x = TypeError (((((((((((((((((Text "Uh oh! Watch out for those infinite loops!" :$$: Text "Newtypes that recursively modify aeson instances, namely:") :$$: Text "") :$$: (Text " " :<>: ShowType n)) :$$: Text "") :$$: Text "must only be used atop a type that creates the instances non-recursively: ") :$$: Text "") :$$: Text " \65518 GenericEncoded") :$$: Text " \65518 RecordSumEncoded") :$$: Text "") :$$: Text "We observe instead the inner type: ") :$$: Text "") :$$: (Text " " :<>: ShowType x)) :$$: Text "") :$$: Text "You probably created an infinitely recursive encoder/decoder pair.") :$$: Text "See `LoopWarning` for details.") :$$: Text "This check can be disabled by wrapping the inner type in `DisableLoopWarning`.") :$$: Text "") 

newtype DisableLoopWarning a Source #

Assert that you know what you're doing and to nullify the LoopWarning constraint family. This should not be necessary.

Constructors

DisableLoopWarning a 

Convenience newtype

newtype x & f infixl 2 Source #

Constructors

Ampersand (f x) 
Instances
ToJSON (f x) => ToJSON (x & f) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

toJSON :: (x & f) -> Value #

toEncoding :: (x & f) -> Encoding #

toJSONList :: [x & f] -> Value #

toEncodingList :: [x & f] -> Encoding #

FromJSON (f x) => FromJSON (x & f) Source # 
Instance details

Defined in Data.Aeson.Deriving.Internal.Generic

Methods

parseJSON :: Value -> Parser (x & f) #

parseJSONList :: Value -> Parser [x & f] #

unAmpersand :: (&) x f -> f x Source #