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


-- | Deriving instances with GHC.Generics and related utilities
--   
--   Generic implementations of standard type classes. Operations on
--   generic representations to help using <a>GHC.Generics</a>. See README.
@package generic-data
@version 0.7.0.0

module Generic.Data.Internal.Compat
readPrec1 :: (Read1 f, Read a) => ReadPrec (f a)
type family Div (a :: Nat) (b :: Nat) :: Nat


-- | Generic deriving for <a>Enum</a>.
module Generic.Data.Internal.Enum

-- | Generic <a>toEnum</a> generated with the <a>StandardEnum</a> option.
--   
--   <pre>
--   instance <a>Enum</a> MyType where
--     <a>toEnum</a> = <a>gtoEnum</a>
--     <a>fromEnum</a> = <a>gfromEnum</a>
--     <a>enumFrom</a> = <a>genumFrom</a>
--     <a>enumFromThen</a> = <a>genumFromThen</a>
--     <a>enumFromTo</a> = <a>genumFromTo</a>
--     <a>enumFromThenTo</a> = <a>genumFromThenTo</a>
--   </pre>
gtoEnum :: forall a. (Generic a, GEnum StandardEnum (Rep a)) => Int -> a

-- | Generic <a>fromEnum</a> generated with the <a>StandardEnum</a> option.
--   
--   See also <a>gtoEnum</a>.
gfromEnum :: (Generic a, GEnum StandardEnum (Rep a)) => a -> Int

-- | Generic <a>enumFrom</a> generated with the <a>StandardEnum</a> option.
--   
--   See also <a>gtoEnum</a>.
genumFrom :: (Generic a, GEnum StandardEnum (Rep a)) => a -> [a]

-- | Generic <a>enumFromThen</a> generated with the <a>StandardEnum</a>
--   option.
--   
--   See also <a>gtoEnum</a>.
genumFromThen :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromTo</a> generated with the <a>StandardEnum</a>
--   option.
--   
--   See also <a>gtoEnum</a>.
genumFromTo :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromThenTo</a> generated with the <a>StandardEnum</a>
--   option.
--   
--   See also <a>gtoEnum</a>.
genumFromThenTo :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> a -> [a]

-- | Generic <a>toEnum</a> generated with the <a>FiniteEnum</a> option.
--   
--   <pre>
--   instance <a>Enum</a> MyType where
--     <a>toEnum</a> = <a>gtoFiniteEnum</a>
--     <a>fromEnum</a> = <a>gfromFiniteEnum</a>
--     <a>enumFrom</a> = <a>gfiniteEnumFrom</a>
--     <a>enumFromThen</a> = <a>gfiniteEnumFromThen</a>
--     <a>enumFromTo</a> = <a>gfiniteEnumFromTo</a>
--     <a>enumFromThenTo</a> = <a>gfiniteEnumFromThenTo</a>
--   </pre>
gtoFiniteEnum :: forall a. (Generic a, GEnum FiniteEnum (Rep a)) => Int -> a

-- | Generic <a>fromEnum</a> generated with the <a>FiniteEnum</a> option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfromFiniteEnum :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> Int

-- | Generic <a>enumFrom</a> generated with the <a>FiniteEnum</a> option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfiniteEnumFrom :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> [a]

-- | Generic <a>enumFromThen</a> generated with the <a>FiniteEnum</a>
--   option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfiniteEnumFromThen :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromTo</a> generated with the <a>FiniteEnum</a> option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfiniteEnumFromTo :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromThenTo</a> generated with the <a>FiniteEnum</a>
--   option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfiniteEnumFromThenTo :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> a -> [a]

-- | Unsafe generic <a>toEnum</a>. Does not check whether the argument is
--   within valid bounds. Use <a>gtoEnum</a> or <a>gtoFiniteEnum</a>
--   instead.
gtoEnumRaw' :: forall opts a. (Generic a, GEnum opts (Rep a)) => Int -> a

-- | Generic <a>toEnum</a>. Use <a>gfromEnum</a> or <a>gfromFiniteEnum</a>
--   instead.
gtoEnum' :: forall opts a. (Generic a, GEnum opts (Rep a)) => String -> Int -> a

-- | Generic <a>fromEnum</a>. Use <a>gfromEnum</a> or
--   <a>gfromFiniteEnum</a> instead.
gfromEnum' :: forall opts a. (Generic a, GEnum opts (Rep a)) => a -> Int

-- | <pre>
--   genumMin == gfromEnum gminBound
--   </pre>
genumMin :: Int

-- | <pre>
--   genumMax == gfromEnum gmaxBound
--   </pre>
genumMax :: forall opts a. (Generic a, GEnum opts (Rep a)) => Int

-- | Generic <a>enumFrom</a>. Use <a>genumFrom</a> or
--   <a>gfiniteEnumFrom</a> instead.
genumFrom' :: forall opts a. (Generic a, GEnum opts (Rep a)) => a -> [a]

-- | Generic <a>enumFromThen</a>. Use <a>genumFromThen</a> or
--   <a>gfiniteEnumFromThen</a> instead.
genumFromThen' :: forall opts a. (Generic a, GEnum opts (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromTo</a>. Use <a>genumFromTo</a> or
--   <a>gfiniteEnumFromTo</a> instead.
genumFromTo' :: forall opts a. (Generic a, GEnum opts (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromThenTo</a>. Use <a>genumFromThenTo</a> or
--   <a>gfiniteEnumFromThenTo</a> instead.
genumFromThenTo' :: forall opts a. (Generic a, GEnum opts (Rep a)) => a -> a -> a -> [a]

-- | Generic <a>minBound</a>.
--   
--   <pre>
--   instance <a>Bounded</a> MyType where
--     <a>minBound</a> = <a>gminBound</a>
--     <a>maxBound</a> = <a>gmaxBound</a>
--   </pre>
gminBound :: (Generic a, GBounded (Rep a)) => a

-- | Generic <a>maxBound</a>.
--   
--   See also <a>gminBound</a>.
gmaxBound :: (Generic a, GBounded (Rep a)) => a

-- | Generic representation of <a>Enum</a> types.
--   
--   The <tt>opts</tt> parameter is a type-level option to select different
--   implementations.
class GEnum opts f
gCardinality :: GEnum opts f => Int
gFromEnum :: GEnum opts f => f p -> Int
gToEnum :: GEnum opts f => Int -> f p

-- | Standard option for <a>GEnum</a>: derive <a>Enum</a> for types with
--   only nullary constructors (the same restrictions as in the <a>Haskell
--   2010 report</a>).
data StandardEnum

-- | Extends the <a>StandardEnum</a> option for <a>GEnum</a> to allow all
--   constructors to have arbitrary many fields. Each field type must be an
--   instance of both <a>Enum</a> and <a>Bounded</a>. Two restrictions
--   require the user's caution:
--   
--   <ul>
--   <li>The <a>Enum</a> instances of the field types need to start
--   enumerating from 0. Particularly <a>Int</a> is an unfit field type,
--   because the enumeration of the negative values starts before 0.</li>
--   <li>There can only be up to <tt><a>maxBound</a> :: <a>Int</a></tt>
--   values (because the implementation represents the cardinality
--   explicitly as an <a>Int</a>). This restriction makes <a>Word</a> an
--   invalid field type. Notably, it is insufficient for each individual
--   field types to stay below this limit. Instead it applies to the
--   generic type as a whole.</li>
--   </ul>
--   
--   The resulting <a>GEnum</a> instance starts enumerating from <tt>0</tt>
--   up to <tt>(cardinality - 1)</tt> and respects the generic <a>Ord</a>
--   instance (defined by <a>gcompare</a>). The values from different
--   constructors are enumerated sequentially; they are not interleaved.
--   
--   <pre>
--   data Example = C0 Bool Bool | C1 Bool
--     deriving (<a>Eq</a>, <a>Ord</a>, <a>Show</a>, <a>Generic</a>)
--   
--   cardinality = 6  -- 2    * 2    + 2
--                    -- Bool * Bool | Bool
--   
--   enumeration =
--       [ C0 False False
--       , C0 False  True
--       , C0  True False
--       , C0  True  True
--       , C1 False
--       , C1 True
--       ]
--   
--   enumeration == map <a>gtoFiniteEnum</a> [0 .. 5]
--   [0 .. 5] == map <a>gfromFiniteEnum</a> enumeration
--   </pre>
data FiniteEnum

-- | Generic representation of <a>Bounded</a> types.
class GBounded f
gMinBound :: GBounded f => f p
gMaxBound :: GBounded f => f p
instance Generic.Data.Internal.Enum.GBounded f => Generic.Data.Internal.Enum.GBounded (GHC.Generics.M1 i c f)
instance Generic.Data.Internal.Enum.GBounded GHC.Generics.U1
instance GHC.Enum.Bounded c => Generic.Data.Internal.Enum.GBounded (GHC.Generics.K1 i c)
instance (Generic.Data.Internal.Enum.GBounded f, Generic.Data.Internal.Enum.GBounded g) => Generic.Data.Internal.Enum.GBounded (f GHC.Generics.:+: g)
instance (Generic.Data.Internal.Enum.GBounded f, Generic.Data.Internal.Enum.GBounded g) => Generic.Data.Internal.Enum.GBounded (f GHC.Generics.:*: g)
instance (Generic.Data.Internal.Enum.GEnum Generic.Data.Internal.Enum.FiniteEnum f, Generic.Data.Internal.Enum.GEnum Generic.Data.Internal.Enum.FiniteEnum g) => Generic.Data.Internal.Enum.GEnum Generic.Data.Internal.Enum.FiniteEnum (f GHC.Generics.:*: g)
instance (GHC.Enum.Bounded c, GHC.Enum.Enum c) => Generic.Data.Internal.Enum.GEnum Generic.Data.Internal.Enum.FiniteEnum (GHC.Generics.K1 i c)
instance Generic.Data.Internal.Enum.GEnum opts f => Generic.Data.Internal.Enum.GEnum opts (GHC.Generics.M1 i c f)
instance (Generic.Data.Internal.Enum.GEnum opts f, Generic.Data.Internal.Enum.GEnum opts g) => Generic.Data.Internal.Enum.GEnum opts (f GHC.Generics.:+: g)
instance Generic.Data.Internal.Enum.GEnum opts GHC.Generics.U1


-- | Type level functions on generic representations.
module Generic.Data.Internal.Functions

-- | Number of constructors of a data type.
type family NConstructors (r :: k -> Type) :: Nat

-- | Number of constructors of a data type.
nconstructors :: forall r. KnownNat (NConstructors r) => Integer

-- | Arity of a constructor.
type family NFields (r :: k -> Type) :: Nat

-- | Arity of a constructor.
nfields :: forall r. KnownNat (NFields r) => Integer


-- | Type metadata accessors
--   
--   Type names, constructor names...
module Generic.Data.Internal.Meta

-- | Name of the first data constructor in a type as a string.
--   
--   <pre>
--   <a>gdatatypeName</a> @(<a>Maybe</a> AnyType) = "Maybe"
--   </pre>
gdatatypeName :: forall a. (Generic a, GDatatype (Rep a)) => String

-- | Name of the module where the first type constructor is defined.
--   
--   <pre>
--   <a>gmoduleName</a> @(<a>Maybe</a> AnyType) = "GHC.Base"
--   </pre>
gmoduleName :: forall a. (Generic a, GDatatype (Rep a)) => String

-- | Name of the package where the first type constructor is defined.
--   
--   <pre>
--   <a>gpackageName</a> @(<a>Maybe</a> AnyType) = "base"
--   </pre>
gpackageName :: forall a. (Generic a, GDatatype (Rep a)) => String

-- | <a>True</a> if the first type constructor is a newtype.
gisNewtype :: forall a. (Generic a, GDatatype (Rep a)) => Bool
fromDatatype :: forall d r. Datatype d => (M1 D d Proxy () -> r) -> r

-- | Generic representations that contain datatype metadata.
class GDatatype f
gDatatypeName :: GDatatype f => String
gModuleName :: GDatatype f => String
gPackageName :: GDatatype f => String
gIsNewtype :: GDatatype f => Bool

-- | Name of the first constructor in a value.
--   
--   <pre>
--   <a>gconName</a> (<a>Just</a> 0) = "Just"
--   </pre>
gconName :: forall a. Constructors a => a -> String

-- | The fixity of the first constructor.
--   
--   <pre>
--   <a>gconFixity</a> (<a>Just</a> 0) = <a>Prefix</a>
--   <a>gconFixity</a> ([] :*: id) = <a>Infix</a> <a>RightAssociative</a> 6
--   </pre>
gconFixity :: forall a. Constructors a => a -> Fixity

-- | <a>True</a> if the constructor is a record.
--   
--   <pre>
--   <a>gconIsRecord</a> (<a>Just</a> 0) = <a>False</a>
--   <a>gconIsRecord</a> (<a>Sum</a> 0) = <a>True</a>
--   -- newtype <a>Sum</a> a = Sum { getSum :: a }
--   </pre>
gconIsRecord :: forall a. Constructors a => a -> Bool

-- | Number of constructors.
--   
--   <pre>
--   <a>gconNum</a> @(<a>Maybe</a> AnyType) = 2
--   </pre>
gconNum :: forall a. Constructors a => Int

-- | Index of a constructor.
--   
--   <pre>
--   <a>gconIndex</a> Nothing = 0
--   <a>gconIndex</a> (Just "test") = 1
--   </pre>
gconIndex :: forall a. Constructors a => a -> Int

-- | An opaque identifier for a constructor.
newtype ConId a
ConId :: Int -> ConId a

-- | Identifier of a constructor.
conId :: forall a. Constructors a => a -> ConId a

-- | Index of a constructor, given its identifier. See also
--   <a>gconIndex</a>.
conIdToInt :: forall a. ConId a -> Int

-- | Name of a constructor. See also <a>gconName</a>.
conIdToString :: forall a. Constructors a => ConId a -> String

-- | All constructor identifiers.
--   
--   <pre>
--   <a>gconNum</a> @a = length (<a>conIdEnum</a> @a)
--   </pre>
conIdEnum :: forall a. Constructors a => [ConId a]

-- | This must not be called on an empty type.
conIdMin :: forall a. Constructors a => ConId a

-- | This must not be called on an empty type.
conIdMax :: forall a. Constructors a => ConId a

-- | Constraint synonym for <a>Generic</a> and <a>GConstructors</a>.
class (Generic a, GConstructors (Rep a)) => Constructors a
newtype GConId r
GConId :: Int -> GConId r
gConIdToInt :: GConId r -> Int
toConId :: forall a. Generic a => GConId (Rep a) -> ConId a
fromConId :: forall a. Generic a => ConId a -> GConId (Rep a)
reGConId :: GConId r -> GConId s
gConIdMin :: forall r. GConstructors r => GConId r
gConIdMax :: forall r. GConstructors r => GConId r

-- | Generic representations that contain constructor metadata.
class GConstructors r
gConIdToString :: GConstructors r => GConId r -> String
gConId :: GConstructors r => r p -> GConId r
gConNum :: GConstructors r => Int
gConFixity :: GConstructors r => r p -> Fixity
gConIsRecord :: GConstructors r => r p -> Bool

-- | <a>Meta</a> field of the <a>M1</a> type constructor.
type family MetaOf (f :: * -> *) :: Meta

-- | Name of the data type (<a>MetaData</a>).
type family MetaDataName (m :: Meta) :: Symbol

-- | Name of the module where the data type is defined (<a>MetaData</a>)
type family MetaDataModule (m :: Meta) :: Symbol

-- | Name of the package where the data type is defined (<a>MetaData</a>)
type family MetaDataPackage (m :: Meta) :: Symbol

-- | <tt>True</tt> if the data type is a newtype (<a>MetaData</a>).
type family MetaDataNewtype (m :: Meta) :: Bool

-- | Name of the constructor (<a>MetaCons</a>).
type family MetaConsName (m :: Meta) :: Symbol

-- | Fixity of the constructor (<a>MetaCons</a>).
type family MetaConsFixity (m :: Meta) :: FixityI

-- | <tt>True</tt> for a record constructor (<a>MetaCons</a>).
type family MetaConsRecord (m :: Meta) :: Bool

-- | <tt>Just</tt> the name of the record field, if it is one
--   (<a>MetaSel</a>).
type family MetaSelNameM (m :: Meta) :: Maybe Symbol

-- | Name of the record field; undefined for non-record fields
--   (<a>MetaSel</a>).
type family MetaSelName (m :: Meta) :: Symbol

-- | Unpackedness annotation of a field (<a>MetaSel</a>).
type family MetaSelUnpack (m :: Meta) :: SourceUnpackedness

-- | Strictness annotation of a field (<a>MetaSel</a>).
type family MetaSelSourceStrictness (m :: Meta) :: SourceStrictness

-- | Inferred strictness of a field (<a>MetaSel</a>).
type family MetaSelStrictness (m :: Meta) :: DecidedStrictness

-- | A placeholder for <a>Meta</a> values.
type DummyMeta = 'MetaData "" "" "" 'False

-- | Remove an <a>M1</a> type constructor.
type family UnM1 (f :: k -> *) :: k -> *
instance forall k (r :: k). GHC.Classes.Ord (Generic.Data.Internal.Meta.GConId r)
instance forall k (r :: k). GHC.Classes.Eq (Generic.Data.Internal.Meta.GConId r)
instance forall k (a :: k). GHC.Classes.Ord (Generic.Data.Internal.Meta.ConId a)
instance forall k (a :: k). GHC.Classes.Eq (Generic.Data.Internal.Meta.ConId a)
instance (GHC.Generics.Generic a, Generic.Data.Internal.Meta.GConstructors (GHC.Generics.Rep a)) => Generic.Data.Internal.Meta.Constructors a
instance forall k (f :: k -> *) (c :: GHC.Generics.Meta). Generic.Data.Internal.Meta.GConstructors f => Generic.Data.Internal.Meta.GConstructors (GHC.Generics.M1 GHC.Generics.D c f)
instance forall k (f :: k -> *) (g :: k -> *). (Generic.Data.Internal.Meta.GConstructors f, Generic.Data.Internal.Meta.GConstructors g) => Generic.Data.Internal.Meta.GConstructors (f GHC.Generics.:+: g)
instance forall k (c :: GHC.Generics.Meta) (f :: k -> *). GHC.Generics.Constructor c => Generic.Data.Internal.Meta.GConstructors (GHC.Generics.M1 GHC.Generics.C c f)
instance forall k (d :: GHC.Generics.Meta) (f :: k -> *). GHC.Generics.Datatype d => Generic.Data.Internal.Meta.GDatatype (GHC.Generics.M1 GHC.Generics.D d f)


-- | Pack/unpack newtypes.
module Generic.Data.Internal.Newtype

-- | Class of newtypes. There is an instance <tt><a>Newtype</a> a</tt> if
--   and only if <tt>a</tt> is a newtype and an instance of <a>Generic</a>.
class (Generic a, Coercible a (Old a), Newtype' a) => Newtype a

-- | The type wrapped by a newtype.
--   
--   <pre>
--   newtype Foo = Foo { bar :: Bar } deriving <a>Generic</a>
--   -- Old Foo ~ Bar
--   </pre>
type Old a = GOld (Rep a)
type family GOld (f :: * -> *)

-- | Use <a>Newtype</a> instead.
type Newtype' a = NewtypeErr a (MetaDataNewtype (MetaOf (Rep a)))
type family NewtypeErr a (b :: Bool) :: Constraint

-- | Generic newtype destructor.
unpack :: Newtype a => a -> Old a

-- | Generic newtype constructor.
pack :: Newtype a => Old a -> a
instance (GHC.Generics.Generic a, GHC.Types.Coercible a (Generic.Data.Internal.Newtype.Old a), Generic.Data.Internal.Newtype.Newtype' a) => Generic.Data.Internal.Newtype.Newtype a

module Generic.Data.Internal.Resolvers

-- | A newtype whose instances for simple classes (<a>Eq</a>, <a>Ord</a>,
--   <a>Read</a>, <a>Show</a>) use higher-kinded class instances for
--   <tt>f</tt> (<a>Eq1</a>, <a>Ord1</a>, <a>Read1</a>, <a>Show1</a>).
newtype Id1 f a
Id1 :: f a -> Id1 f a
[unId1] :: Id1 f a -> f a

-- | A newtype with trivial instances, that considers every value
--   equivalent to every other one, and shows as just <tt>"_"</tt>.
newtype Opaque a
Opaque :: a -> Opaque a
[unOpaque] :: Opaque a -> a

-- | A higher-kinded version of <a>Opaque</a>.
newtype Opaque1 f a
Opaque1 :: f a -> Opaque1 f a
[unOpaque1] :: Opaque1 f a -> f a
instance Data.Functor.Classes.Show1 f => Data.Functor.Classes.Show1 (Generic.Data.Internal.Resolvers.Id1 f)
instance Data.Functor.Classes.Read1 f => Data.Functor.Classes.Read1 (Generic.Data.Internal.Resolvers.Id1 f)
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (Generic.Data.Internal.Resolvers.Id1 f)
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (Generic.Data.Internal.Resolvers.Id1 f)
instance GHC.Classes.Eq (Generic.Data.Internal.Resolvers.Opaque1 f a)
instance GHC.Classes.Ord (Generic.Data.Internal.Resolvers.Opaque1 f a)
instance GHC.Show.Show (Generic.Data.Internal.Resolvers.Opaque1 f a)
instance Data.Functor.Classes.Eq1 (Generic.Data.Internal.Resolvers.Opaque1 f)
instance Data.Functor.Classes.Ord1 (Generic.Data.Internal.Resolvers.Opaque1 f)
instance Data.Functor.Classes.Show1 (Generic.Data.Internal.Resolvers.Opaque1 f)
instance GHC.Classes.Eq (Generic.Data.Internal.Resolvers.Opaque a)
instance GHC.Classes.Ord (Generic.Data.Internal.Resolvers.Opaque a)
instance GHC.Show.Show (Generic.Data.Internal.Resolvers.Opaque a)
instance Data.Functor.Classes.Eq1 Generic.Data.Internal.Resolvers.Opaque
instance Data.Functor.Classes.Ord1 Generic.Data.Internal.Resolvers.Opaque
instance Data.Functor.Classes.Show1 Generic.Data.Internal.Resolvers.Opaque
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Generic.Data.Internal.Resolvers.Id1 f a)
instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => GHC.Classes.Ord (Generic.Data.Internal.Resolvers.Id1 f a)
instance (Data.Functor.Classes.Read1 f, GHC.Read.Read a) => GHC.Read.Read (Generic.Data.Internal.Resolvers.Id1 f a)
instance (Data.Functor.Classes.Show1 f, GHC.Show.Show a) => GHC.Show.Show (Generic.Data.Internal.Resolvers.Id1 f a)

module Generic.Data.Internal.Show

-- | Generic <a>showsPrec</a>.
--   
--   <pre>
--   instance <a>Show</a> MyType where
--     <a>showsPrec</a> = <a>gshowsPrec</a>
--   </pre>
gshowsPrec :: (Generic a, GShow0 (Rep a)) => Int -> a -> ShowS
gprecShows :: (Generic a, GShow0 (Rep a)) => a -> PrecShowS

-- | Generic representation of <a>Show</a> types.
type GShow0 = GShow Proxy

-- | Generic <a>liftShowsPrec</a>.
gliftShowsPrec :: (Generic1 f, GShow1 (Rep1 f)) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
gLiftPrecShows :: GShow1 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> f a -> PrecShowS
type ShowsPrec a = (Int -> a -> ShowS, [a] -> ShowS)

-- | Generic representation of <a>Show1</a> types.
type GShow1 = GShow Identity
class GShow p f
gPrecShows :: GShow p f => p (ShowsPrec a) -> f a -> PrecShowS
class GShowC p c f
gPrecShowsC :: GShowC p c f => p (ShowsPrec a) -> String -> Fixity -> M1 C c f a -> PrecShowS
class GShowFields p f
gPrecShowsFields :: GShowFields p f => p (ShowsPrec a) -> f a -> [PrecShowS]
class GShowNamed p f
gPrecShowsNamed :: GShowNamed p f => p (ShowsPrec a) -> f a -> ShowFields
class GShowSingle p f
gPrecShowsSingle :: GShowSingle p f => p (ShowsPrec a) -> f a -> PrecShowS
instance Generic.Data.Internal.Show.GShowSingle p f => Generic.Data.Internal.Show.GShowFields p (GHC.Generics.M1 GHC.Generics.S c f)
instance (GHC.Generics.Selector c, Generic.Data.Internal.Show.GShowSingle p f) => Generic.Data.Internal.Show.GShowNamed p (GHC.Generics.M1 GHC.Generics.S c f)
instance GHC.Show.Show a => Generic.Data.Internal.Show.GShowSingle p (GHC.Generics.K1 i a)
instance Data.Functor.Classes.Show1 f => Generic.Data.Internal.Show.GShowSingle Data.Functor.Identity.Identity (GHC.Generics.Rec1 f)
instance Generic.Data.Internal.Show.GShowSingle Data.Functor.Identity.Identity GHC.Generics.Par1
instance (Data.Functor.Classes.Show1 f, Generic.Data.Internal.Show.GShowSingle p g) => Generic.Data.Internal.Show.GShowSingle p (f GHC.Generics.:.: g)
instance Generic.Data.Internal.Show.GShowNamed p f => Generic.Data.Internal.Show.GShowC p ('GHC.Generics.MetaCons s y 'GHC.Types.True) f
instance (Generic.Data.Internal.Show.GShowNamed p f, Generic.Data.Internal.Show.GShowNamed p g) => Generic.Data.Internal.Show.GShowNamed p (f GHC.Generics.:*: g)
instance Generic.Data.Internal.Show.GShowNamed p GHC.Generics.U1
instance Generic.Data.Internal.Show.GShowFields p f => Generic.Data.Internal.Show.GShowC p ('GHC.Generics.MetaCons s y 'GHC.Types.False) f
instance (Generic.Data.Internal.Show.GShowFields p f, Generic.Data.Internal.Show.GShowFields p g) => Generic.Data.Internal.Show.GShowFields p (f GHC.Generics.:*: g)
instance Generic.Data.Internal.Show.GShowFields p GHC.Generics.U1
instance (GHC.Generics.Constructor c, Generic.Data.Internal.Show.GShowC p c f) => Generic.Data.Internal.Show.GShow p (GHC.Generics.M1 GHC.Generics.C c f)
instance Generic.Data.Internal.Show.GShow p f => Generic.Data.Internal.Show.GShow p (GHC.Generics.M1 GHC.Generics.D d f)
instance (Generic.Data.Internal.Show.GShow p f, Generic.Data.Internal.Show.GShow p g) => Generic.Data.Internal.Show.GShow p (f GHC.Generics.:+: g)
instance Generic.Data.Internal.Show.GShow p GHC.Generics.V1


-- | Generic representations as data types.
module Generic.Data.Internal.Data

-- | Synthetic data type.
--   
--   A wrapper to view a generic <a>Rep</a> as the datatype it's supposed
--   to represent, without needing a declaration.
newtype Data r p
Data :: r p -> Data r p
[unData] :: Data r p -> r p

-- | Conversion between a generic type and the synthetic type made using
--   its representation. Inverse of <a>fromData</a>.
toData :: Generic a => a -> Data (Rep a) p

-- | Inverse of <a>toData</a>.
fromData :: Generic a => Data (Rep a) p -> a
instance GHC.Base.Monoid (r p) => GHC.Base.Monoid (Generic.Data.Internal.Data.Data r p)
instance GHC.Base.Semigroup (r p) => GHC.Base.Semigroup (Generic.Data.Internal.Data.Data r p)
instance Data.Functor.Classes.Ord1 r => Data.Functor.Classes.Ord1 (Generic.Data.Internal.Data.Data r)
instance Data.Functor.Classes.Eq1 r => Data.Functor.Classes.Eq1 (Generic.Data.Internal.Data.Data r)
instance GHC.Classes.Ord (r p) => GHC.Classes.Ord (Generic.Data.Internal.Data.Data r p)
instance GHC.Classes.Eq (r p) => GHC.Classes.Eq (Generic.Data.Internal.Data.Data r p)
instance Data.Functor.Contravariant.Contravariant r => Data.Functor.Contravariant.Contravariant (Generic.Data.Internal.Data.Data r)
instance GHC.Base.MonadPlus r => GHC.Base.MonadPlus (Generic.Data.Internal.Data.Data r)
instance GHC.Base.Monad r => GHC.Base.Monad (Generic.Data.Internal.Data.Data r)
instance GHC.Base.Alternative r => GHC.Base.Alternative (Generic.Data.Internal.Data.Data r)
instance GHC.Base.Applicative r => GHC.Base.Applicative (Generic.Data.Internal.Data.Data r)
instance Data.Traversable.Traversable r => Data.Traversable.Traversable (Generic.Data.Internal.Data.Data r)
instance Data.Foldable.Foldable r => Data.Foldable.Foldable (Generic.Data.Internal.Data.Data r)
instance GHC.Base.Functor r => GHC.Base.Functor (Generic.Data.Internal.Data.Data r)
instance (GHC.Base.Functor r, Data.Functor.Contravariant.Contravariant r) => GHC.Generics.Generic (Generic.Data.Internal.Data.Data r p)
instance GHC.Generics.Generic1 (Generic.Data.Internal.Data.Data r)
instance (Generic.Data.Internal.Show.GShow1 r, GHC.Show.Show p) => GHC.Show.Show (Generic.Data.Internal.Data.Data r p)
instance Generic.Data.Internal.Show.GShow1 r => Data.Functor.Classes.Show1 (Generic.Data.Internal.Data.Data r)
instance Generic.Data.Internal.Enum.GEnum Generic.Data.Internal.Enum.StandardEnum r => GHC.Enum.Enum (Generic.Data.Internal.Data.Data r p)
instance Generic.Data.Internal.Enum.GBounded r => GHC.Enum.Bounded (Generic.Data.Internal.Data.Data r p)

module Generic.Data.Internal.Utils

-- | Convert between types with representationally equivalent generic
--   representations.
gcoerce :: (Generic a, Generic b, Coercible (Rep a) (Rep b)) => a -> b

-- | Compose <a>gcoerce</a> with a binary operation.
gcoerceBinop :: (Generic a, Generic b, Coercible (Rep a) (Rep b)) => (a -> a -> a) -> b -> b -> b

-- | Coerce while preserving the type index.
coerce' :: Coercible (f x) (g x) => f x -> g x
coerce1 :: Coercible f g => f x -> g x

-- | Elimination of <tt>V1</tt>.
absurd1 :: V1 x -> a

-- | A helper for better type inference.
from' :: Generic a => a -> Rep a ()

-- | A helper for better type inference.
to' :: Generic a => Rep a () -> a

-- | Lift binary combinators generically.
liftG2 :: Generic1 f => (Rep1 f a -> Rep1 f b -> Rep1 f c) -> f a -> f b -> f c


-- | Generic deriving for standard classes in base
module Generic.Data.Internal.Prelude

-- | Generic <tt>(<a>==</a>)</tt>.
--   
--   <pre>
--   instance <a>Eq</a> MyType where
--     (<a>==</a>) = <a>geq</a>
--   </pre>
geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool

-- | Generic <a>compare</a>.
--   
--   <pre>
--   instance <a>Ord</a> MyType where
--     <a>compare</a> = <a>gcompare</a>
--   </pre>
gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering

-- | Generic <tt>(<a>&lt;&gt;</a>)</tt> (or <a>mappend</a>).
--   
--   <pre>
--   instance <a>Semigroup</a> MyType where
--     (<a>&lt;&gt;</a>) = <a>gmappend</a>
--   </pre>
--   
--   See also <a>gmempty</a>.
gmappend :: (Generic a, Semigroup (Rep a ())) => a -> a -> a

-- | Generic <a>mempty</a>.
--   
--   <pre>
--   instance <a>Monoid</a> MyType where
--     <a>mempty</a> = <a>gmempty</a>
--   </pre>
gmempty :: (Generic a, Monoid (Rep a ())) => a

-- | Generic <tt>(<a>&lt;&gt;</a>)</tt> (or <tt><a>mappend</a></tt>).
--   
--   The difference from <a>gmappend</a> is the <a>Monoid</a> constraint
--   instead of <a>Semigroup</a>, for older versions of base where
--   <a>Semigroup</a> is not a superclass of <a>Monoid</a>.
gmappend' :: (Generic a, Monoid (Rep a ())) => a -> a -> a

-- | Generic <a>fmap</a>.
--   
--   <pre>
--   instance <a>Functor</a> MyTypeF where
--     <a>fmap</a> = <a>gfmap</a>
--   </pre>
gfmap :: (Generic1 f, Functor (Rep1 f)) => (a -> b) -> f a -> f b

-- | Generic <tt>(<a>&lt;$</a>)</tt>.
--   
--   See also <a>gfmap</a>.
gconstmap :: (Generic1 f, Functor (Rep1 f)) => a -> f b -> f a

-- | Generic <a>pure</a>.
--   
--   <pre>
--   instance <a>Applicative</a> MyTypeF where
--     <a>pure</a> = <a>gpure</a>
--     (<a>&lt;*&gt;</a>) = <a>gap</a>
--   </pre>
gpure :: (Generic1 f, Applicative (Rep1 f)) => a -> f a

-- | Generic <tt>(<a>&lt;*&gt;</a>)</tt> (or <a>ap</a>).
--   
--   See also <a>gpure</a>.
gap :: (Generic1 f, Applicative (Rep1 f)) => f (a -> b) -> f a -> f b

-- | Generic <a>liftA2</a>.
--   
--   See also <a>gpure</a>.
gliftA2 :: (Generic1 f, Applicative (Rep1 f)) => (a -> b -> c) -> f a -> f b -> f c

-- | Generic <a>empty</a>.
--   
--   <pre>
--   instance <a>Alternative</a> MyTypeF where
--     <a>empty</a> = <a>gempty</a>
--     (<a>&lt;|&gt;</a>) = <a>galt</a>
--   </pre>
gempty :: (Generic1 f, Alternative (Rep1 f)) => f a

-- | Generic (<a>&lt;|&gt;</a>).
--   
--   See also <a>gempty</a>.
galt :: (Generic1 f, Alternative (Rep1 f)) => f a -> f a -> f a

-- | Generic <a>foldMap</a>.
--   
--   <pre>
--   instance <a>Foldable</a> MyTypeF where
--     <a>foldMap</a> = <a>gfoldMap</a>
--   </pre>
gfoldMap :: (Generic1 f, Foldable (Rep1 f), Monoid m) => (a -> m) -> f a -> m

-- | Generic <a>foldr</a>.
--   
--   <pre>
--   instance <a>Foldable</a> MyTypeF where
--     <a>foldr</a> = <a>gfoldr</a>
--   </pre>
--   
--   See also <a>gfoldMap</a>.
gfoldr :: (Generic1 f, Foldable (Rep1 f)) => (a -> b -> b) -> b -> f a -> b

-- | Generic <a>traverse</a>.
--   
--   <pre>
--   instance <a>Traversable</a> MyTypeF where
--     <a>traverse</a> = <a>gtraverse</a>
--   </pre>
gtraverse :: (Generic1 f, Traversable (Rep1 f), Applicative m) => (a -> m b) -> f a -> m (f b)

-- | Generic <a>sequenceA</a>.
--   
--   <pre>
--   instance <a>Traversable</a> MyTypeF where
--     <a>sequenceA</a> = <a>gsequenceA</a>
--   </pre>
--   
--   See also <a>gtraverse</a>.
gsequenceA :: (Generic1 f, Traversable (Rep1 f), Applicative m) => f (m a) -> m (f a)

-- | Generic <a>liftEq</a>.
gliftEq :: (Generic1 f, Eq1 (Rep1 f)) => (a -> b -> Bool) -> f a -> f b -> Bool

-- | Generic <a>liftCompare</a>.
gliftCompare :: (Generic1 f, Ord1 (Rep1 f)) => (a -> b -> Ordering) -> f a -> f b -> Ordering


-- | Newtypes with instances implemented using generic combinators.
module Generic.Data.Internal.Generically

-- | Type with instances derived via <a>Generic</a>.
newtype Generically a
Generically :: a -> Generically a
[unGenerically] :: Generically a -> a

-- | Type with <a>Enum</a> instance derived via <a>Generic</a> with
--   <a>FiniteEnum</a> option.
newtype FiniteEnumeration a
FiniteEnumeration :: a -> FiniteEnumeration a
[unFiniteEnumeration] :: FiniteEnumeration a -> a

-- | Type with instances derived via <a>Generic1</a>.
newtype Generically1 f a
Generically1 :: f a -> Generically1 f a
[unGenerically1] :: Generically1 f a -> f a
instance GHC.Generics.Generic (f a) => GHC.Generics.Generic (Generic.Data.Internal.Generically.Generically1 f a)
instance GHC.Generics.Generic1 f => GHC.Generics.Generic1 (Generic.Data.Internal.Generically.Generically1 f)
instance (GHC.Generics.Generic1 f, Data.Functor.Classes.Eq1 (GHC.Generics.Rep1 f)) => Data.Functor.Classes.Eq1 (Generic.Data.Internal.Generically.Generically1 f)
instance (GHC.Generics.Generic1 f, Data.Functor.Classes.Eq1 (GHC.Generics.Rep1 f), GHC.Classes.Eq a) => GHC.Classes.Eq (Generic.Data.Internal.Generically.Generically1 f a)
instance (GHC.Generics.Generic1 f, Data.Functor.Classes.Ord1 (GHC.Generics.Rep1 f)) => Data.Functor.Classes.Ord1 (Generic.Data.Internal.Generically.Generically1 f)
instance (GHC.Generics.Generic1 f, Data.Functor.Classes.Ord1 (GHC.Generics.Rep1 f), GHC.Classes.Ord a) => GHC.Classes.Ord (Generic.Data.Internal.Generically.Generically1 f a)
instance (GHC.Generics.Generic1 f, Generic.Data.Internal.Show.GShow1 (GHC.Generics.Rep1 f)) => Data.Functor.Classes.Show1 (Generic.Data.Internal.Generically.Generically1 f)
instance (GHC.Generics.Generic1 f, Generic.Data.Internal.Show.GShow1 (GHC.Generics.Rep1 f), GHC.Show.Show a) => GHC.Show.Show (Generic.Data.Internal.Generically.Generically1 f a)
instance (GHC.Generics.Generic1 f, GHC.Base.Functor (GHC.Generics.Rep1 f)) => GHC.Base.Functor (Generic.Data.Internal.Generically.Generically1 f)
instance (GHC.Generics.Generic1 f, GHC.Base.Applicative (GHC.Generics.Rep1 f)) => GHC.Base.Applicative (Generic.Data.Internal.Generically.Generically1 f)
instance (GHC.Generics.Generic1 f, GHC.Base.Alternative (GHC.Generics.Rep1 f)) => GHC.Base.Alternative (Generic.Data.Internal.Generically.Generically1 f)
instance (GHC.Generics.Generic1 f, Data.Foldable.Foldable (GHC.Generics.Rep1 f)) => Data.Foldable.Foldable (Generic.Data.Internal.Generically.Generically1 f)
instance (GHC.Generics.Generic1 f, Data.Traversable.Traversable (GHC.Generics.Rep1 f)) => Data.Traversable.Traversable (Generic.Data.Internal.Generically.Generically1 f)
instance GHC.Generics.Generic a => GHC.Generics.Generic (Generic.Data.Internal.Generically.FiniteEnumeration a)
instance (GHC.Generics.Generic a, Generic.Data.Internal.Enum.GEnum Generic.Data.Internal.Enum.FiniteEnum (GHC.Generics.Rep a)) => GHC.Enum.Enum (Generic.Data.Internal.Generically.FiniteEnumeration a)
instance GHC.Generics.Generic a => GHC.Generics.Generic (Generic.Data.Internal.Generically.Generically a)
instance (GHC.Generics.Generic a, GHC.Classes.Eq (GHC.Generics.Rep a ())) => GHC.Classes.Eq (Generic.Data.Internal.Generically.Generically a)
instance (GHC.Generics.Generic a, GHC.Classes.Ord (GHC.Generics.Rep a ())) => GHC.Classes.Ord (Generic.Data.Internal.Generically.Generically a)
instance (GHC.Generics.Generic a, Generic.Data.Internal.Show.GShow0 (GHC.Generics.Rep a)) => GHC.Show.Show (Generic.Data.Internal.Generically.Generically a)
instance (GHC.Generics.Generic a, GHC.Base.Semigroup (GHC.Generics.Rep a ())) => GHC.Base.Semigroup (Generic.Data.Internal.Generically.Generically a)
instance (GHC.Base.Semigroup a, GHC.Generics.Generic a, GHC.Base.Monoid (GHC.Generics.Rep a ())) => GHC.Base.Monoid (Generic.Data.Internal.Generically.Generically a)
instance (GHC.Generics.Generic a, Generic.Data.Internal.Enum.GEnum Generic.Data.Internal.Enum.StandardEnum (GHC.Generics.Rep a)) => GHC.Enum.Enum (Generic.Data.Internal.Generically.Generically a)
instance (GHC.Generics.Generic a, Generic.Data.Internal.Enum.GBounded (GHC.Generics.Rep a)) => GHC.Enum.Bounded (Generic.Data.Internal.Generically.Generically a)


-- | Generic combinators to derive type class instances.
--   
--   <i>base</i> classes that GHC can not derive instances for, as of
--   version 8.2:
--   
--   <ul>
--   <li><a>Semigroup</a>, <a>Monoid</a>, <a>Applicative</a>,
--   <a>Alternative</a>, <a>Eq1</a>, <a>Ord1</a>, <a>Show1</a>.</li>
--   </ul>
--   
--   On <i>base</i> &lt; 4.12 (i.e., GHC &lt; 8.6), import
--   <a>Generic.Data.Orphans</a> to obtain instances needed internally to
--   derive those.
--   
--   GHC can derive instances for other classes here, although there may be
--   types supported by one method but not the other or vice versa.
module Generic.Data

-- | Generic <tt>(<a>&lt;&gt;</a>)</tt> (or <a>mappend</a>).
--   
--   <pre>
--   instance <a>Semigroup</a> MyType where
--     (<a>&lt;&gt;</a>) = <a>gmappend</a>
--   </pre>
--   
--   See also <a>gmempty</a>.
gmappend :: (Generic a, Semigroup (Rep a ())) => a -> a -> a

-- | Generic <a>mempty</a>.
--   
--   <pre>
--   instance <a>Monoid</a> MyType where
--     <a>mempty</a> = <a>gmempty</a>
--   </pre>
gmempty :: (Generic a, Monoid (Rep a ())) => a

-- | Generic <tt>(<a>&lt;&gt;</a>)</tt> (or <tt><a>mappend</a></tt>).
--   
--   The difference from <a>gmappend</a> is the <a>Monoid</a> constraint
--   instead of <a>Semigroup</a>, for older versions of base where
--   <a>Semigroup</a> is not a superclass of <a>Monoid</a>.
gmappend' :: (Generic a, Monoid (Rep a ())) => a -> a -> a

-- | Generic <tt>(<a>==</a>)</tt>.
--   
--   <pre>
--   instance <a>Eq</a> MyType where
--     (<a>==</a>) = <a>geq</a>
--   </pre>
geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool

-- | Generic <a>compare</a>.
--   
--   <pre>
--   instance <a>Ord</a> MyType where
--     <a>compare</a> = <a>gcompare</a>
--   </pre>
gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering

-- | Generic <a>showsPrec</a>.
--   
--   <pre>
--   instance <a>Show</a> MyType where
--     <a>showsPrec</a> = <a>gshowsPrec</a>
--   </pre>
gshowsPrec :: (Generic a, GShow0 (Rep a)) => Int -> a -> ShowS

-- | Generic representation of <a>Show</a> types.
type GShow0 = GShow Proxy

-- | Generic representation of <a>Enum</a> types.
--   
--   The <tt>opts</tt> parameter is a type-level option to select different
--   implementations.
class GEnum opts f

-- | Standard option for <a>GEnum</a>: derive <a>Enum</a> for types with
--   only nullary constructors (the same restrictions as in the <a>Haskell
--   2010 report</a>).
data StandardEnum

-- | Generic <a>toEnum</a> generated with the <a>StandardEnum</a> option.
--   
--   <pre>
--   instance <a>Enum</a> MyType where
--     <a>toEnum</a> = <a>gtoEnum</a>
--     <a>fromEnum</a> = <a>gfromEnum</a>
--     <a>enumFrom</a> = <a>genumFrom</a>
--     <a>enumFromThen</a> = <a>genumFromThen</a>
--     <a>enumFromTo</a> = <a>genumFromTo</a>
--     <a>enumFromThenTo</a> = <a>genumFromThenTo</a>
--   </pre>
gtoEnum :: forall a. (Generic a, GEnum StandardEnum (Rep a)) => Int -> a

-- | Generic <a>fromEnum</a> generated with the <a>StandardEnum</a> option.
--   
--   See also <a>gtoEnum</a>.
gfromEnum :: (Generic a, GEnum StandardEnum (Rep a)) => a -> Int

-- | Generic <a>enumFrom</a> generated with the <a>StandardEnum</a> option.
--   
--   See also <a>gtoEnum</a>.
genumFrom :: (Generic a, GEnum StandardEnum (Rep a)) => a -> [a]

-- | Generic <a>enumFromThen</a> generated with the <a>StandardEnum</a>
--   option.
--   
--   See also <a>gtoEnum</a>.
genumFromThen :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromTo</a> generated with the <a>StandardEnum</a>
--   option.
--   
--   See also <a>gtoEnum</a>.
genumFromTo :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromThenTo</a> generated with the <a>StandardEnum</a>
--   option.
--   
--   See also <a>gtoEnum</a>.
genumFromThenTo :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> a -> [a]

-- | Extends the <a>StandardEnum</a> option for <a>GEnum</a> to allow all
--   constructors to have arbitrary many fields. Each field type must be an
--   instance of both <a>Enum</a> and <a>Bounded</a>. Two restrictions
--   require the user's caution:
--   
--   <ul>
--   <li>The <a>Enum</a> instances of the field types need to start
--   enumerating from 0. Particularly <a>Int</a> is an unfit field type,
--   because the enumeration of the negative values starts before 0.</li>
--   <li>There can only be up to <tt><a>maxBound</a> :: <a>Int</a></tt>
--   values (because the implementation represents the cardinality
--   explicitly as an <a>Int</a>). This restriction makes <a>Word</a> an
--   invalid field type. Notably, it is insufficient for each individual
--   field types to stay below this limit. Instead it applies to the
--   generic type as a whole.</li>
--   </ul>
--   
--   The resulting <a>GEnum</a> instance starts enumerating from <tt>0</tt>
--   up to <tt>(cardinality - 1)</tt> and respects the generic <a>Ord</a>
--   instance (defined by <a>gcompare</a>). The values from different
--   constructors are enumerated sequentially; they are not interleaved.
--   
--   <pre>
--   data Example = C0 Bool Bool | C1 Bool
--     deriving (<a>Eq</a>, <a>Ord</a>, <a>Show</a>, <a>Generic</a>)
--   
--   cardinality = 6  -- 2    * 2    + 2
--                    -- Bool * Bool | Bool
--   
--   enumeration =
--       [ C0 False False
--       , C0 False  True
--       , C0  True False
--       , C0  True  True
--       , C1 False
--       , C1 True
--       ]
--   
--   enumeration == map <a>gtoFiniteEnum</a> [0 .. 5]
--   [0 .. 5] == map <a>gfromFiniteEnum</a> enumeration
--   </pre>
data FiniteEnum

-- | Generic <a>toEnum</a> generated with the <a>FiniteEnum</a> option.
--   
--   <pre>
--   instance <a>Enum</a> MyType where
--     <a>toEnum</a> = <a>gtoFiniteEnum</a>
--     <a>fromEnum</a> = <a>gfromFiniteEnum</a>
--     <a>enumFrom</a> = <a>gfiniteEnumFrom</a>
--     <a>enumFromThen</a> = <a>gfiniteEnumFromThen</a>
--     <a>enumFromTo</a> = <a>gfiniteEnumFromTo</a>
--     <a>enumFromThenTo</a> = <a>gfiniteEnumFromThenTo</a>
--   </pre>
gtoFiniteEnum :: forall a. (Generic a, GEnum FiniteEnum (Rep a)) => Int -> a

-- | Generic <a>fromEnum</a> generated with the <a>FiniteEnum</a> option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfromFiniteEnum :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> Int

-- | Generic <a>enumFrom</a> generated with the <a>FiniteEnum</a> option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfiniteEnumFrom :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> [a]

-- | Generic <a>enumFromThen</a> generated with the <a>FiniteEnum</a>
--   option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfiniteEnumFromThen :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromTo</a> generated with the <a>FiniteEnum</a> option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfiniteEnumFromTo :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> [a]

-- | Generic <a>enumFromThenTo</a> generated with the <a>FiniteEnum</a>
--   option.
--   
--   See also <a>gtoFiniteEnum</a>.
gfiniteEnumFromThenTo :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> a -> [a]

-- | Generic <a>minBound</a>.
--   
--   <pre>
--   instance <a>Bounded</a> MyType where
--     <a>minBound</a> = <a>gminBound</a>
--     <a>maxBound</a> = <a>gmaxBound</a>
--   </pre>
gminBound :: (Generic a, GBounded (Rep a)) => a

-- | Generic <a>maxBound</a>.
--   
--   See also <a>gminBound</a>.
gmaxBound :: (Generic a, GBounded (Rep a)) => a

-- | Generic representation of <a>Bounded</a> types.
class GBounded f

-- | Generic <a>fmap</a>.
--   
--   <pre>
--   instance <a>Functor</a> MyTypeF where
--     <a>fmap</a> = <a>gfmap</a>
--   </pre>
gfmap :: (Generic1 f, Functor (Rep1 f)) => (a -> b) -> f a -> f b

-- | Generic <tt>(<a>&lt;$</a>)</tt>.
--   
--   See also <a>gfmap</a>.
gconstmap :: (Generic1 f, Functor (Rep1 f)) => a -> f b -> f a

-- | Generic <a>foldMap</a>.
--   
--   <pre>
--   instance <a>Foldable</a> MyTypeF where
--     <a>foldMap</a> = <a>gfoldMap</a>
--   </pre>
gfoldMap :: (Generic1 f, Foldable (Rep1 f), Monoid m) => (a -> m) -> f a -> m

-- | Generic <a>foldr</a>.
--   
--   <pre>
--   instance <a>Foldable</a> MyTypeF where
--     <a>foldr</a> = <a>gfoldr</a>
--   </pre>
--   
--   See also <a>gfoldMap</a>.
gfoldr :: (Generic1 f, Foldable (Rep1 f)) => (a -> b -> b) -> b -> f a -> b

-- | Generic <a>traverse</a>.
--   
--   <pre>
--   instance <a>Traversable</a> MyTypeF where
--     <a>traverse</a> = <a>gtraverse</a>
--   </pre>
gtraverse :: (Generic1 f, Traversable (Rep1 f), Applicative m) => (a -> m b) -> f a -> m (f b)

-- | Generic <a>sequenceA</a>.
--   
--   <pre>
--   instance <a>Traversable</a> MyTypeF where
--     <a>sequenceA</a> = <a>gsequenceA</a>
--   </pre>
--   
--   See also <a>gtraverse</a>.
gsequenceA :: (Generic1 f, Traversable (Rep1 f), Applicative m) => f (m a) -> m (f a)

-- | Generic <a>pure</a>.
--   
--   <pre>
--   instance <a>Applicative</a> MyTypeF where
--     <a>pure</a> = <a>gpure</a>
--     (<a>&lt;*&gt;</a>) = <a>gap</a>
--   </pre>
gpure :: (Generic1 f, Applicative (Rep1 f)) => a -> f a

-- | Generic <tt>(<a>&lt;*&gt;</a>)</tt> (or <a>ap</a>).
--   
--   See also <a>gpure</a>.
gap :: (Generic1 f, Applicative (Rep1 f)) => f (a -> b) -> f a -> f b

-- | Generic <a>liftA2</a>.
--   
--   See also <a>gpure</a>.
gliftA2 :: (Generic1 f, Applicative (Rep1 f)) => (a -> b -> c) -> f a -> f b -> f c

-- | Generic <a>empty</a>.
--   
--   <pre>
--   instance <a>Alternative</a> MyTypeF where
--     <a>empty</a> = <a>gempty</a>
--     (<a>&lt;|&gt;</a>) = <a>galt</a>
--   </pre>
gempty :: (Generic1 f, Alternative (Rep1 f)) => f a

-- | Generic (<a>&lt;|&gt;</a>).
--   
--   See also <a>gempty</a>.
galt :: (Generic1 f, Alternative (Rep1 f)) => f a -> f a -> f a

-- | Generic <a>liftEq</a>.
gliftEq :: (Generic1 f, Eq1 (Rep1 f)) => (a -> b -> Bool) -> f a -> f b -> Bool

-- | Generic <a>liftCompare</a>.
gliftCompare :: (Generic1 f, Ord1 (Rep1 f)) => (a -> b -> Ordering) -> f a -> f b -> Ordering

-- | Generic <a>liftShowsPrec</a>.
gliftShowsPrec :: (Generic1 f, GShow1 (Rep1 f)) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS

-- | Generic representation of <a>Show1</a> types.
type GShow1 = GShow Identity

-- | A newtype whose instances for simple classes (<a>Eq</a>, <a>Ord</a>,
--   <a>Read</a>, <a>Show</a>) use higher-kinded class instances for
--   <tt>f</tt> (<a>Eq1</a>, <a>Ord1</a>, <a>Read1</a>, <a>Show1</a>).
newtype Id1 f a
Id1 :: f a -> Id1 f a
[unId1] :: Id1 f a -> f a

-- | A newtype with trivial instances, that considers every value
--   equivalent to every other one, and shows as just <tt>"_"</tt>.
newtype Opaque a
Opaque :: a -> Opaque a
[unOpaque] :: Opaque a -> a

-- | A higher-kinded version of <a>Opaque</a>.
newtype Opaque1 f a
Opaque1 :: f a -> Opaque1 f a
[unOpaque1] :: Opaque1 f a -> f a

-- | Type with instances derived via <a>Generic</a>.
newtype Generically a
Generically :: a -> Generically a
[unGenerically] :: Generically a -> a

-- | Type with <a>Enum</a> instance derived via <a>Generic</a> with
--   <a>FiniteEnum</a> option.
newtype FiniteEnumeration a
FiniteEnumeration :: a -> FiniteEnumeration a
[unFiniteEnumeration] :: FiniteEnumeration a -> a

-- | Type with instances derived via <a>Generic1</a>.
newtype Generically1 f a
Generically1 :: f a -> Generically1 f a
[unGenerically1] :: Generically1 f a -> f a

-- | Class of newtypes. There is an instance <tt><a>Newtype</a> a</tt> if
--   and only if <tt>a</tt> is a newtype and an instance of <a>Generic</a>.
class (Generic a, Coercible a (Old a), Newtype' a) => Newtype a

-- | Generic newtype constructor.
pack :: Newtype a => Old a -> a

-- | Generic newtype destructor.
unpack :: Newtype a => a -> Old a

-- | Convert between types with representationally equivalent generic
--   representations.
gcoerce :: (Generic a, Generic b, Coercible (Rep a) (Rep b)) => a -> b

-- | Compose <a>gcoerce</a> with a binary operation.
gcoerceBinop :: (Generic a, Generic b, Coercible (Rep a) (Rep b)) => (a -> a -> a) -> b -> b -> b

-- | Name of the first data constructor in a type as a string.
--   
--   <pre>
--   <a>gdatatypeName</a> @(<a>Maybe</a> AnyType) = "Maybe"
--   </pre>
gdatatypeName :: forall a. (Generic a, GDatatype (Rep a)) => String

-- | Name of the module where the first type constructor is defined.
--   
--   <pre>
--   <a>gmoduleName</a> @(<a>Maybe</a> AnyType) = "GHC.Base"
--   </pre>
gmoduleName :: forall a. (Generic a, GDatatype (Rep a)) => String

-- | Name of the package where the first type constructor is defined.
--   
--   <pre>
--   <a>gpackageName</a> @(<a>Maybe</a> AnyType) = "base"
--   </pre>
gpackageName :: forall a. (Generic a, GDatatype (Rep a)) => String

-- | <a>True</a> if the first type constructor is a newtype.
gisNewtype :: forall a. (Generic a, GDatatype (Rep a)) => Bool

-- | Generic representations that contain datatype metadata.
class GDatatype f

-- | Name of the first constructor in a value.
--   
--   <pre>
--   <a>gconName</a> (<a>Just</a> 0) = "Just"
--   </pre>
gconName :: forall a. Constructors a => a -> String

-- | The fixity of the first constructor.
--   
--   <pre>
--   <a>gconFixity</a> (<a>Just</a> 0) = <a>Prefix</a>
--   <a>gconFixity</a> ([] :*: id) = <a>Infix</a> <a>RightAssociative</a> 6
--   </pre>
gconFixity :: forall a. Constructors a => a -> Fixity

-- | <a>True</a> if the constructor is a record.
--   
--   <pre>
--   <a>gconIsRecord</a> (<a>Just</a> 0) = <a>False</a>
--   <a>gconIsRecord</a> (<a>Sum</a> 0) = <a>True</a>
--   -- newtype <a>Sum</a> a = Sum { getSum :: a }
--   </pre>
gconIsRecord :: forall a. Constructors a => a -> Bool

-- | Number of constructors.
--   
--   <pre>
--   <a>gconNum</a> @(<a>Maybe</a> AnyType) = 2
--   </pre>
gconNum :: forall a. Constructors a => Int

-- | Index of a constructor.
--   
--   <pre>
--   <a>gconIndex</a> Nothing = 0
--   <a>gconIndex</a> (Just "test") = 1
--   </pre>
gconIndex :: forall a. Constructors a => a -> Int

-- | Constraint synonym for <a>Generic</a> and <a>GConstructors</a>.
class (Generic a, GConstructors (Rep a)) => Constructors a

-- | Generic representations that contain constructor metadata.
class GConstructors r

-- | An opaque identifier for a constructor.
data ConId a

-- | Identifier of a constructor.
conId :: forall a. Constructors a => a -> ConId a

-- | Index of a constructor, given its identifier. See also
--   <a>gconIndex</a>.
conIdToInt :: forall a. ConId a -> Int

-- | Name of a constructor. See also <a>gconName</a>.
conIdToString :: forall a. Constructors a => ConId a -> String

-- | All constructor identifiers.
--   
--   <pre>
--   <a>gconNum</a> @a = length (<a>conIdEnum</a> @a)
--   </pre>
conIdEnum :: forall a. Constructors a => [ConId a]

-- | <a>Meta</a> field of the <a>M1</a> type constructor.
type family MetaOf (f :: * -> *) :: Meta

-- | Name of the data type (<a>MetaData</a>).
type family MetaDataName (m :: Meta) :: Symbol

-- | Name of the module where the data type is defined (<a>MetaData</a>)
type family MetaDataModule (m :: Meta) :: Symbol

-- | Name of the package where the data type is defined (<a>MetaData</a>)
type family MetaDataPackage (m :: Meta) :: Symbol

-- | <tt>True</tt> if the data type is a newtype (<a>MetaData</a>).
type family MetaDataNewtype (m :: Meta) :: Bool

-- | Name of the constructor (<a>MetaCons</a>).
type family MetaConsName (m :: Meta) :: Symbol

-- | Fixity of the constructor (<a>MetaCons</a>).
type family MetaConsFixity (m :: Meta) :: FixityI

-- | <tt>True</tt> for a record constructor (<a>MetaCons</a>).
type family MetaConsRecord (m :: Meta) :: Bool

-- | <tt>Just</tt> the name of the record field, if it is one
--   (<a>MetaSel</a>).
type family MetaSelNameM (m :: Meta) :: Maybe Symbol

-- | Name of the record field; undefined for non-record fields
--   (<a>MetaSel</a>).
type family MetaSelName (m :: Meta) :: Symbol

-- | Unpackedness annotation of a field (<a>MetaSel</a>).
type family MetaSelUnpack (m :: Meta) :: SourceUnpackedness

-- | Strictness annotation of a field (<a>MetaSel</a>).
type family MetaSelSourceStrictness (m :: Meta) :: SourceStrictness

-- | Inferred strictness of a field (<a>MetaSel</a>).
type family MetaSelStrictness (m :: Meta) :: DecidedStrictness


-- | Orphan instances. They should probably be upstreamed.
module Generic.Data.Orphans
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (GHC.Generics.M1 i c f)
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (GHC.Generics.M1 i c f)
instance Data.Functor.Classes.Eq1 GHC.Generics.V1
instance Data.Functor.Classes.Ord1 GHC.Generics.V1
instance Data.Functor.Classes.Eq1 GHC.Generics.U1
instance Data.Functor.Classes.Ord1 GHC.Generics.U1
instance GHC.Classes.Eq c => Data.Functor.Classes.Eq1 (GHC.Generics.K1 i c)
instance GHC.Classes.Ord c => Data.Functor.Classes.Ord1 (GHC.Generics.K1 i c)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (f GHC.Generics.:*: g)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (f GHC.Generics.:*: g)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (f GHC.Generics.:+: g)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (f GHC.Generics.:+: g)
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (GHC.Generics.Rec1 f)
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (GHC.Generics.Rec1 f)
instance Data.Functor.Classes.Eq1 GHC.Generics.Par1
instance Data.Functor.Classes.Ord1 GHC.Generics.Par1
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (f GHC.Generics.:.: g)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (f GHC.Generics.:.: g)


-- | Utilities to derive and transform generic types.
module Generic.Data.Types

-- | Synthetic data type.
--   
--   A wrapper to view a generic <a>Rep</a> as the datatype it's supposed
--   to represent, without needing a declaration.
newtype Data r p
Data :: r p -> Data r p
[unData] :: Data r p -> r p

-- | Conversion between a generic type and the synthetic type made using
--   its representation. Inverse of <a>fromData</a>.
toData :: Generic a => a -> Data (Rep a) p

-- | Inverse of <a>toData</a>.
fromData :: Generic a => Data (Rep a) p -> a


-- | Surgeries that are just <a>coerce</a>.
module Generic.Data.Internal.Microsurgery

-- | Apply a microsurgery <tt>s</tt> to a type <tt>a</tt> for
--   <tt>DerivingVia</tt>.
--   
--   <h3><b>Example</b></h3>
--   
--   <pre>
--   {-# LANGUAGE DerivingVia #-}
--   
--   -- The constructors must be visible.
--   import <a>Generic.Data.Microsurgery</a>
--     (<a>Surgery</a>, <a>Surgery'</a>(..), <a>Generically</a>(..), <a>Derecordify</a>)
--   
--   data T = T { unT :: Int }
--     deriving <a>Show</a> via (<a>Surgery</a> <a>Derecordify</a> T)
--   
--   -- T won't be shown as a record:
--   --   show (T {unT = 3}) == "T 3"
--   </pre>
type Surgery (s :: *) (a :: *) = Generically (Surgery' s a)

-- | See <a>Surgery</a>.
newtype Surgery' (s :: *) (a :: *)
Surgery' :: a -> Surgery' (s :: *) (a :: *)
[unSurgery'] :: Surgery' (s :: *) (a :: *) -> a

-- | Apply a microsurgery represented by a symbol <tt>s</tt> (declared as a
--   dummy data type) to a generic representation <tt>f</tt>.
type family GSurgery (s :: *) (f :: k -> *) :: k -> *
derecordify :: Coercible (GSurgery Derecordify f) f => Data f p -> Data (GSurgery Derecordify f) p
underecordify :: Coercible f (GSurgery Derecordify f) => Data (GSurgery Derecordify f) p -> Data f p

-- | Forget that a type was declared using record syntax.
--   
--   <pre>
--   data Foo = Bar { baz :: Zap }
--   
--   -- becomes --
--   
--   data Foo = Bar Zap
--   </pre>
--   
--   Concretely, set the last field of <a>MetaCons</a> to <a>False</a> and
--   forget field names.
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data Derecordify :: *
type family GDerecordify (f :: k -> *) :: k -> *
typeage :: Coercible (GSurgery Typeage f) f => Data f p -> Data (GSurgery Typeage f) p
untypeage :: Coercible f (GSurgery Typeage f) => Data (GSurgery Typeage f) p -> Data f p

-- | Forget that a type is a <tt>newtype</tt>. (The pun is that "aging" a
--   type makes it no longer "new".)
--   
--   <pre>
--   newtype Foo = Bar Baz
--   
--   -- becomes --
--   
--   data Foo = Bar Baz
--   </pre>
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data Typeage :: *
renameFields :: forall rnm f p. Coercible (GSurgery (RenameFields rnm) f) f => Data f p -> Data (GSurgery (RenameFields rnm) f) p
unrenameFields :: forall rnm f p. Coercible (GSurgery (RenameFields rnm) f) f => Data f p -> Data (GSurgery (RenameFields rnm) f) p
renameConstrs :: forall rnm f p. Coercible (GSurgery (RenameConstrs rnm) f) f => Data f p -> Data (GSurgery (RenameConstrs rnm) f) p
unrenameConstrs :: forall rnm f p. Coercible (GSurgery (RenameConstrs rnm) f) f => Data f p -> Data (GSurgery (RenameConstrs rnm) f) p

-- | Rename fields using the function <tt>rnm</tt> given as a parameter.
--   
--   <pre>
--   data Foo = Bar { baz :: Zap }
--   
--   -- becomes, renaming "baz" to "bag" --
--   
--   data Foo = Bar { bag :: Zap }
--   </pre>
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data RenameFields (rnm :: *) :: *
type family GRenameFields (rnm :: *) (f :: k -> *) :: k -> *

-- | Rename constructors using the function <tt>rnm</tt> given as a
--   parameter.
--   
--   <pre>
--   data Foo = Bar { baz :: Zap }
--   
--   -- becomes, renaming "Bar" to "Car" --
--   
--   data Foo = Car { baz :: Zap }
--   </pre>
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data RenameConstrs (rnm :: *) :: *
type family GRenameConstrs (rnm :: *) (f :: k -> *) :: k -> *

-- | <tt>f @@ s</tt> is the application of a type-level function symbolized
--   by <tt>f</tt> to a <tt>s :: <a>Symbol</a></tt>.
--   
--   A function <tt>FooToBar</tt> can be defined as follows:
--   
--   <pre>
--   data FooToBar
--   type instance FooToBar <a>@@</a> "foo" = "bar"
--   </pre>
type family (f :: *) @@ (s :: Symbol) :: Symbol

-- | Identity function <tt><a>Symbol</a> -&gt; <a>Symbol</a></tt>.
data SId

-- | Empty function (compile-time error when applied).
data SError

-- | Constant function.
data SConst (s :: Symbol)

-- | Define a function for a fixed set of strings, and fall back to
--   <tt>f</tt> for the others.
data SRename (xs :: [(Symbol, Symbol)]) (f :: *)

-- | Closed type family for <a>SRename</a>.
type family SRename' (xs :: [(Symbol, Symbol)]) (f :: *) (s :: Symbol)

-- | Unify the "spines" of two generic representations (the "spine" is
--   everything except the field types).
class UnifyRep (f :: k -> *) (g :: k -> *)

-- | <pre>
--   onData :: _ =&gt; (Data r x -&gt; Data s y) -&gt; (Data r x -&gt; Data s y)  -- possible specialization
--   </pre>
--   
--   Can be used with <tt>generic-lens</tt> for type-changing field updates
--   with <tt>field_</tt> (and possibly other generic optics).
--   
--   A specialization of the identity function to be used to fix types of
--   functions on <a>Data</a>, unifying the "spines" of input and output
--   generic representations (the "spine" is everything except field types,
--   which may thus change).
onData :: (UnifyRep r s, UnifyRep s r) => p (Data r x) (Data s y) -> p (Data r x) (Data s y)

-- | Apply a type constructor <tt>f</tt> to every field type of a generic
--   representation <tt>r</tt>.
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data OnFields (f :: * -> *) :: *
type family GOnFields (f :: * -> *) (g :: k -> *) :: k -> *

-- | Apply a type constructor to every field type of a type <tt>a</tt> to
--   make a synthetic type.
type DOnFields (f :: * -> *) (a :: *) = Data (GSurgery (OnFields f) (Rep a)) ()
instance forall k (g' :: k -> *) s (c :: GHC.Generics.Meta) (g :: k -> *) (f :: k -> *). (g' GHC.Types.~ GHC.Generics.M1 s c g, Generic.Data.Internal.Microsurgery.UnifyRep f g) => Generic.Data.Internal.Microsurgery.UnifyRep (GHC.Generics.M1 s c f) g'
instance forall k (g' :: k -> *) (g1 :: k -> *) (g2 :: k -> *) (f1 :: k -> *) (f2 :: k -> *). (g' GHC.Types.~ (g1 GHC.Generics.:+: g2), Generic.Data.Internal.Microsurgery.UnifyRep f1 g1, Generic.Data.Internal.Microsurgery.UnifyRep f2 g2) => Generic.Data.Internal.Microsurgery.UnifyRep (f1 GHC.Generics.:+: f2) g'
instance forall k (g' :: k -> *) (g1 :: k -> *) (g2 :: k -> *) (f1 :: k -> *) (f2 :: k -> *). (g' GHC.Types.~ (g1 GHC.Generics.:*: g2), Generic.Data.Internal.Microsurgery.UnifyRep f1 g1, Generic.Data.Internal.Microsurgery.UnifyRep f2 g2) => Generic.Data.Internal.Microsurgery.UnifyRep (f1 GHC.Generics.:*: f2) g'
instance forall k (g' :: k -> *) i b a. (g' GHC.Types.~ GHC.Generics.K1 i b) => Generic.Data.Internal.Microsurgery.UnifyRep (GHC.Generics.K1 i a) g'
instance forall k (g' :: k -> *). (g' GHC.Types.~ GHC.Generics.U1) => Generic.Data.Internal.Microsurgery.UnifyRep GHC.Generics.U1 g'
instance forall k (g' :: k -> *). (g' GHC.Types.~ GHC.Generics.V1) => Generic.Data.Internal.Microsurgery.UnifyRep GHC.Generics.V1 g'
instance (GHC.Generics.Generic a, GHC.Types.Coercible (Generic.Data.Internal.Microsurgery.GSurgery s (GHC.Generics.Rep a)) (GHC.Generics.Rep a)) => GHC.Generics.Generic (Generic.Data.Internal.Microsurgery.Surgery' s a)


-- | Simple operations on generic representations, that only change the
--   type-level metadata used by certain generic functions.
--   
--   More complex ones can be found in <a>generic-data-surgery</a> but
--   also, perhaps surprisingly, in <a>generic-lens</a> (read more about
--   this just below) and <a>one-liner</a>.
module Generic.Data.Microsurgery

-- | Apply a microsurgery <tt>s</tt> to a type <tt>a</tt> for
--   <tt>DerivingVia</tt>.
--   
--   <h3><b>Example</b></h3>
--   
--   <pre>
--   {-# LANGUAGE DerivingVia #-}
--   
--   -- The constructors must be visible.
--   import <a>Generic.Data.Microsurgery</a>
--     (<a>Surgery</a>, <a>Surgery'</a>(..), <a>Generically</a>(..), <a>Derecordify</a>)
--   
--   data T = T { unT :: Int }
--     deriving <a>Show</a> via (<a>Surgery</a> <a>Derecordify</a> T)
--   
--   -- T won't be shown as a record:
--   --   show (T {unT = 3}) == "T 3"
--   </pre>
type Surgery (s :: *) (a :: *) = Generically (Surgery' s a)

-- | See <a>Surgery</a>.
newtype Surgery' (s :: *) (a :: *)
Surgery' :: a -> Surgery' (s :: *) (a :: *)
[unSurgery'] :: Surgery' (s :: *) (a :: *) -> a

-- | Apply a microsurgery represented by a symbol <tt>s</tt> (declared as a
--   dummy data type) to a generic representation <tt>f</tt>.
type family GSurgery (s :: *) (f :: k -> *) :: k -> *

-- | Type with instances derived via <a>Generic</a>.
newtype Generically a
Generically :: a -> Generically a
[unGenerically] :: Generically a -> a

-- | Synthetic data type.
--   
--   A wrapper to view a generic <a>Rep</a> as the datatype it's supposed
--   to represent, without needing a declaration.
data Data r p

-- | Conversion between a generic type and the synthetic type made using
--   its representation. Inverse of <a>fromData</a>.
toData :: Generic a => a -> Data (Rep a) p

-- | Inverse of <a>toData</a>.
fromData :: Generic a => Data (Rep a) p -> a

-- | <pre>
--   onData :: _ =&gt; (Data r x -&gt; Data s y) -&gt; (Data r x -&gt; Data s y)  -- possible specialization
--   </pre>
--   
--   Can be used with <tt>generic-lens</tt> for type-changing field updates
--   with <tt>field_</tt> (and possibly other generic optics).
--   
--   A specialization of the identity function to be used to fix types of
--   functions on <a>Data</a>, unifying the "spines" of input and output
--   generic representations (the "spine" is everything except field types,
--   which may thus change).
onData :: (UnifyRep r s, UnifyRep s r) => p (Data r x) (Data s y) -> p (Data r x) (Data s y)

-- | Forget that a type was declared using record syntax.
--   
--   <pre>
--   data Foo = Bar { baz :: Zap }
--   
--   -- becomes --
--   
--   data Foo = Bar Zap
--   </pre>
--   
--   Concretely, set the last field of <a>MetaCons</a> to <a>False</a> and
--   forget field names.
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data Derecordify :: *
derecordify :: Coercible (GSurgery Derecordify f) f => Data f p -> Data (GSurgery Derecordify f) p
underecordify :: Coercible f (GSurgery Derecordify f) => Data (GSurgery Derecordify f) p -> Data f p

-- | Forget that a type is a <tt>newtype</tt>. (The pun is that "aging" a
--   type makes it no longer "new".)
--   
--   <pre>
--   newtype Foo = Bar Baz
--   
--   -- becomes --
--   
--   data Foo = Bar Baz
--   </pre>
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data Typeage :: *
typeage :: Coercible (GSurgery Typeage f) f => Data f p -> Data (GSurgery Typeage f) p
untypeage :: Coercible f (GSurgery Typeage f) => Data (GSurgery Typeage f) p -> Data f p

-- | Rename fields using the function <tt>rnm</tt> given as a parameter.
--   
--   <pre>
--   data Foo = Bar { baz :: Zap }
--   
--   -- becomes, renaming "baz" to "bag" --
--   
--   data Foo = Bar { bag :: Zap }
--   </pre>
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data RenameFields (rnm :: *) :: *
renameFields :: forall rnm f p. Coercible (GSurgery (RenameFields rnm) f) f => Data f p -> Data (GSurgery (RenameFields rnm) f) p
unrenameFields :: forall rnm f p. Coercible (GSurgery (RenameFields rnm) f) f => Data f p -> Data (GSurgery (RenameFields rnm) f) p

-- | Rename constructors using the function <tt>rnm</tt> given as a
--   parameter.
--   
--   <pre>
--   data Foo = Bar { baz :: Zap }
--   
--   -- becomes, renaming "Bar" to "Car" --
--   
--   data Foo = Car { baz :: Zap }
--   </pre>
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data RenameConstrs (rnm :: *) :: *
renameConstrs :: forall rnm f p. Coercible (GSurgery (RenameConstrs rnm) f) f => Data f p -> Data (GSurgery (RenameConstrs rnm) f) p
unrenameConstrs :: forall rnm f p. Coercible (GSurgery (RenameConstrs rnm) f) f => Data f p -> Data (GSurgery (RenameConstrs rnm) f) p

-- | <tt>f @@ s</tt> is the application of a type-level function symbolized
--   by <tt>f</tt> to a <tt>s :: <a>Symbol</a></tt>.
--   
--   A function <tt>FooToBar</tt> can be defined as follows:
--   
--   <pre>
--   data FooToBar
--   type instance FooToBar <a>@@</a> "foo" = "bar"
--   </pre>
type family (f :: *) @@ (s :: Symbol) :: Symbol

-- | Identity function <tt><a>Symbol</a> -&gt; <a>Symbol</a></tt>.
data SId

-- | Empty function (compile-time error when applied).
data SError

-- | Constant function.
data SConst (s :: Symbol)

-- | Define a function for a fixed set of strings, and fall back to
--   <tt>f</tt> for the others.
data SRename (xs :: [(Symbol, Symbol)]) (f :: *)

-- | Apply a type constructor <tt>f</tt> to every field type of a generic
--   representation <tt>r</tt>.
--   
--   This is a defunctionalized symbol, applied using <a>GSurgery</a> or
--   <a>Surgery</a>.
data OnFields (f :: * -> *) :: *

-- | Apply a type constructor to every field type of a type <tt>a</tt> to
--   make a synthetic type.
type DOnFields (f :: * -> *) (a :: *) = Data (GSurgery (OnFields f) (Rep a)) ()
