-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Type driven generic aeson instance customisation
--   
--   This package provides a newtype wrapper with FromJSON/ToJSON instances
--   customisable via a phantom type parameter. The instances can be
--   rendered to the original type using DerivingVia.
@package deriving-aeson
@version 0.2.9


-- | Type-directed aeson instance CustomJSONisation
module Deriving.Aeson

-- | A newtype wrapper which gives FromJSON/ToJSON instances with modified
--   options.
newtype CustomJSON t a
CustomJSON :: a -> CustomJSON t a
[unCustomJSON] :: CustomJSON t a -> a

-- | Function applied to field labels. Handy for removing common record
--   prefixes for example.
data FieldLabelModifier t

-- | Function applied to constructor tags which could be handy for
--   lower-casing them for example.
data ConstructorTagModifier t

-- | Record fields with a Nothing value will be omitted from the resulting
--   object.
data OmitNothingFields

-- | JSON Documents mapped to records with unmatched keys will be rejected
data RejectUnknownFields

-- | Encode types with a single constructor as sums, so that
--   allNullaryToStringTag and sumEncoding apply.
data TagSingleConstructors

-- | the encoding will always follow the <a>sumEncoding</a>.
data NoAllNullaryToStringTag

-- | Unpack single-field records
data UnwrapUnaryRecords

-- | <pre>
--   { "tag": t, "content": c}
--   </pre>
data SumTaggedObject t c

-- | <pre>
--   CONTENT
--   </pre>
data SumUntaggedValue

-- | <pre>
--   { TAG: CONTENT }
--   </pre>
data SumObjectWithSingleField

-- | <pre>
--   [TAG, CONTENT]
--   </pre>
data SumTwoElemArray

-- | Strip prefix <tt>t</tt>. If it doesn't have the prefix, keep it as-is.
data StripPrefix t

-- | Generic CamelTo constructor taking in a separator char
data CamelTo (separator :: Symbol)

-- | CamelCase to kebab-case
type CamelToKebab = CamelTo "-"

-- | CamelCase to snake_case
type CamelToSnake = CamelTo "_"

-- | Rename fields called <tt>from</tt> to <tt>to</tt>.
data Rename (from :: Symbol) (to :: Symbol)

-- | Reify <a>Options</a> from a type-level list
class AesonOptions xs
aesonOptions :: AesonOptions xs => Options

-- | Reify a function which modifies names
class StringModifier t
getStringModifier :: StringModifier t => String -> String
class () => FromJSON a
class () => ToJSON a
class () => Generic a
instance forall k (t :: k) a. (Deriving.Aeson.AesonOptions t, GHC.Generics.Generic a, Data.Aeson.Types.FromJSON.GFromJSON Data.Aeson.Types.Generic.Zero (GHC.Generics.Rep a)) => Data.Aeson.Types.FromJSON.FromJSON (Deriving.Aeson.CustomJSON t a)
instance forall k (t :: k) a. (Deriving.Aeson.AesonOptions t, GHC.Generics.Generic a, Data.Aeson.Types.Class.GToJSON Data.Aeson.Types.Generic.Zero (GHC.Generics.Rep a), Data.Aeson.Types.Class.GToEncoding Data.Aeson.Types.Generic.Zero (GHC.Generics.Rep a)) => Data.Aeson.Types.ToJSON.ToJSON (Deriving.Aeson.CustomJSON t a)
instance Deriving.Aeson.AesonOptions '[]
instance Deriving.Aeson.AesonOptions xs => Deriving.Aeson.AesonOptions (Deriving.Aeson.UnwrapUnaryRecords : xs)
instance Deriving.Aeson.AesonOptions xs => Deriving.Aeson.AesonOptions (Deriving.Aeson.OmitNothingFields : xs)
instance Deriving.Aeson.AesonOptions xs => Deriving.Aeson.AesonOptions (Deriving.Aeson.RejectUnknownFields : xs)
instance forall k (f :: k) (xs :: [*]). (Deriving.Aeson.StringModifier f, Deriving.Aeson.AesonOptions xs) => Deriving.Aeson.AesonOptions (Deriving.Aeson.FieldLabelModifier f : xs)
instance forall k (f :: k) (xs :: [*]). (Deriving.Aeson.StringModifier f, Deriving.Aeson.AesonOptions xs) => Deriving.Aeson.AesonOptions (Deriving.Aeson.ConstructorTagModifier f : xs)
instance Deriving.Aeson.AesonOptions xs => Deriving.Aeson.AesonOptions (Deriving.Aeson.TagSingleConstructors : xs)
instance Deriving.Aeson.AesonOptions xs => Deriving.Aeson.AesonOptions (Deriving.Aeson.NoAllNullaryToStringTag : xs)
instance (GHC.TypeLits.KnownSymbol t, GHC.TypeLits.KnownSymbol c, Deriving.Aeson.AesonOptions xs) => Deriving.Aeson.AesonOptions (Deriving.Aeson.SumTaggedObject t c : xs)
instance Deriving.Aeson.AesonOptions xs => Deriving.Aeson.AesonOptions (Deriving.Aeson.SumUntaggedValue : xs)
instance Deriving.Aeson.AesonOptions xs => Deriving.Aeson.AesonOptions (Deriving.Aeson.SumObjectWithSingleField : xs)
instance Deriving.Aeson.AesonOptions xs => Deriving.Aeson.AesonOptions (Deriving.Aeson.SumTwoElemArray : xs)
instance (GHC.TypeLits.KnownSymbol separator, Deriving.Aeson.NonEmptyString separator) => Deriving.Aeson.StringModifier (Deriving.Aeson.CamelTo separator)
instance GHC.TypeLits.KnownSymbol k => Deriving.Aeson.StringModifier (Deriving.Aeson.StripPrefix k)
instance Deriving.Aeson.StringModifier '[]
instance forall a1 (a2 :: a1) (as :: [a1]). (Deriving.Aeson.StringModifier a2, Deriving.Aeson.StringModifier as) => Deriving.Aeson.StringModifier (a2 : as)
instance (Deriving.Aeson.StringModifier a, Deriving.Aeson.StringModifier b) => Deriving.Aeson.StringModifier (a, b)
instance (Deriving.Aeson.StringModifier a, Deriving.Aeson.StringModifier b, Deriving.Aeson.StringModifier c) => Deriving.Aeson.StringModifier (a, b, c)
instance (Deriving.Aeson.StringModifier a, Deriving.Aeson.StringModifier b, Deriving.Aeson.StringModifier c, Deriving.Aeson.StringModifier d) => Deriving.Aeson.StringModifier (a, b, c, d)
instance (GHC.TypeLits.KnownSymbol from, GHC.TypeLits.KnownSymbol to) => Deriving.Aeson.StringModifier (Deriving.Aeson.Rename from to)

module Deriving.Aeson.Stock

-- | Field names are prefixed by <tt>str</tt>; strip them from JSON
--   representation
type Prefixed str = CustomJSON '[FieldLabelModifier (StripPrefix str)]

-- | Strip <tt>str</tt> prefices and convert from CamelCase to snake_case
type PrefixedSnake str = CustomJSON '[FieldLabelModifier '[StripPrefix str, CamelToSnake]]

-- | Convert from CamelCase to snake_case
type Snake = CustomJSON '[FieldLabelModifier CamelToSnake]

-- | No customisation
type Vanilla = CustomJSON ('[] :: [Type])

-- | A newtype wrapper which gives FromJSON/ToJSON instances with modified
--   options.
newtype CustomJSON t a
CustomJSON :: a -> CustomJSON t a
[unCustomJSON] :: CustomJSON t a -> a
class () => FromJSON a
class () => ToJSON a
class () => Generic a
