h,+*+      !"#$%&'()*1.1.1.0None 01d.Structural representation of an object field. Structural representation of ". (I.e. a constant string value.) (This is the "Haskell structure" type of  references.The main reason why we need this is because of recursion, as explained below:Since the specification is at the type level, and type level haskell is strict, specifying a recursive definition the "naive" way would cause an infinitely sized type.For example this won't work: data Foo = Foo [Foo] instance HasJsonEncodingSpec Foo where type EncodingSpec Foo = JsonArray (EncodingSpec Foo) toJSONStructure = ... can't be written ... because EncodingSpec Foo* would expand strictly into an array of EncodingSpec Foo-, which would expand strictly... to infinity.Using  prevents the specification type from being infinitely sized, but what about the "structure" type which holds real values corresponding to the spec? The structure type has to have some way to reference itself or else it too would be infinitely sized.In order to "reference itself" the structure type has to go through a newtype somewhere along the way, and that's what this type is for. Whenever you use a > in the spec, the corresponding structural type will have a < newtype wrapper around the "dereferenced" structure type. For example: data Foo = Foo [Foo] instance HasJsonEncodingSpec Foo where type EncodingSpec Foo = JsonLet '[ '("Foo", JsonArray (JsonRef "Foo")) ] (JsonRef "Foo") toJSONStructure (Foo fs) = Ref [ toJSONStructure <$> fs ]Strictly speaking, we wouldn't  necessarily have to translate every  into a 4. In principal we could get away with inserting a  somewhere in every mutually recursive cycle. But the type level programming to figure that out a) probably wouldn't do any favors to compilation times, b) is beyond what I'm willing to attempted right now, and c) requires some kind of deterministic and stable choice about where to insert the 6 (which I'm not even certain exists) lest arbitrary HasJsonEncodingSpec or HasJsonDecodingSpec instances break when the members of the recursive cycle change, causing a new choice about where to place the .+Make the correct reference type by looking up the symbol, and providing the environment in which the symbol was _defined_. We mustn't use the environment in which the reference is _used_, or else   would be a dynamically scoped language, instead of a statically scoped language. spec is the Haskell type used to contain the JSON data that will be encoded or decoded according to the provided spec.Basically, we represent JSON objects as "list-like" nested tuples of the form: (Field @key1 valueType, (Field @key2 valueType, (Field @key3 valueType, ()))) recursively encode objects, and is mutually recursive with . If we tried to "recurse on the rest of the object" directly in 4 we would end up with a partial function, because 3 returns a 4 not an Object.. We would therefore have to pattern match on 4 to get the Object% back out, but we would have to call error if the 4 mysteriously somehow wasn't an Object after all. Instead of calling error because "it can't ever happen", we use this helper so the compiler can prove it never happens. This is like 5, but specialized for our custom "json representation" types (i.e. the  type family). It is also closed (i.e. not exported, so the user can't add instances), because our json representation is closed.see StructureFromJSON3 for an explaination about why we don't just use 5.Types of this class can be encoded to JSON according to a type-level  .The encoding specification. Encode the value into the structure appropriate for the specification. Given a raw Haskell structure, directly encode it directly into an aeson Value without having to go through any To/FromJSON instances. See also: . 3None 1(! Analog of   , but specialized for decoding our "json representations", and closed to the user because the haskell representation scheme is fixed and not extensible by the user.We can't just use    because the types we are using to represent "json data" (i.e. the  type family) already have ToJSON instances. Even if we were to make a bunch of newtypes or whatever to act as the json representation (and therefor also force the user to do a lot of wrapping and unwrapping), that still wouldn't be sufficient because someone could always write an overlapping (or incoherent) ToJSON instance of our newtype! This way we don't have to worry about any of that, and the types that the user must deal with when implementing  fromJSONRepr can be simple tuples and such."Types of this class can be JSON decoded according to a type-level  .# The decoding  . $Given the structural encoding of the JSON data, parse the structure into the final type. The reason this returns a 6 a instead of just a plain a is because there may still be some invariants of the JSON data that the   language is not able to express, and so you may need to fail parsing in those cases. For instance,   is not powerful enough to express "this field must contain only prime numbers".%Directly decode some JSON accoring to a spec without going through any To/FromJSON instances.%"#$!7None*L&Helper for defining 5 and 8 instances based on HasEncodingJsonSpec.Use with -XDerivingVia like: data MyObj = MyObj { foo :: Int , bar :: Text } deriving (ToJSON, FromJSON) via (SpecJSON MyObj) instance HasEncodingSpec MyObj where ... instance HasDecodingSpec MyObj where ...)% &'("#$!   )   "#$&'(% !9        !"#$%&'()*+,---./0123456789:;<=>?@ABCDBEFBCGHBI json-spec-1.1.1.0-inplace Data.JsonSpec json-specData.JsonSpec.Spec Data.TimeUTCTimeData.JsonSpec.Encode eitherDecodeData.JsonSpec.Decode Data.AesonFromJSONFieldTagRefunRef JSONStructure::?::: FieldSpecRequiredOptional Specification JsonObject JsonStringJsonNumJsonInt JsonArrayJsonBool JsonNullable JsonEitherJsonTag JsonDateTimeJsonLetJsonRefJsonRawunFieldStructureToJSONHasJsonEncodingSpec EncodingSpectoJSONStructureencodeStructureFromJSONHasJsonDecodingSpec DecodingSpecfromJSONStructureSpecJSON unSpecJson$fFromJSONSpecJSON$fToJSONSpecJSON LookupRef ghc-internalGHC.Internal.RecordsHasFieldghc-prim GHC.TypesBoolscientific-0.3.8.0-f4d235e38ca75a3856362d6094726140a95280d098364abf44f90f8bb4b1b694Data.Scientific Scientifictext-2.1.1-ac74Data.Text.InternalTextsymJStruct ToJSONObject reprToJSONaeson-2.2.3.0-12b7710b866d4cabb21c48f6fa19dd1c51b4352be3be3ce9a18059c93459e6daData.Aeson.Types.InternalValueData.Aeson.Types.ToJSONToJSONParser reprParseJSONData.Aeson.Types.FromJSON