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


-- | Generic Programming using True Sums of Products
--   
--   A library to support the definition of generic functions. Datatypes
--   are viewed in a uniform, structured way: the choice between
--   constructors is represented using an n-ary sum, and the arguments of
--   each constructor are represented using an n-ary product.
--   
--   The module <a>Generics.SOP</a> is the main module of this library and
--   contains more detailed documentation.
--   
--   Since version 0.4.0.0, this package is now based on
--   <tt><a>sop-core</a></tt>. The core package contains all the
--   functionality of n-ary sums and products, whereas this package
--   provides the datatype-generic programming support on top.
--   
--   Examples of using this library are provided by the following packages:
--   
--   <ul>
--   <li><tt><a>basic-sop</a></tt> basic examples,</li>
--   <li><tt><a>pretty-sop</a></tt> generic pretty printing,</li>
--   <li><tt><a>lens-sop</a></tt> generically computed lenses,</li>
--   <li><tt><a>json-sop</a></tt> generic JSON conversions.</li>
--   </ul>
--   
--   A detailed description of the ideas behind this library is provided by
--   the paper:
--   
--   <ul>
--   <li>Edsko de Vries and Andres Löh. <a>True Sums of Products</a>.
--   Workshop on Generic Programming (WGP) 2014.</li>
--   </ul>
@package generics-sop
@version 0.4.0.1

module Generics.SOP.BasicFunctors

module Generics.SOP.Classes

module Generics.SOP.Constraint

module Generics.SOP.Dict

module Generics.SOP.NP


-- | Metadata about what a datatype looks like
--   
--   In <tt>generics-sop</tt>, the metadata is completely independent of
--   the main universe. Many generic functions will use this metadata, but
--   other don't, and yet others might need completely different metadata.
--   
--   This module defines a datatype to represent standard metadata, i.e.,
--   names of the datatype, its constructors, and possibly its record
--   selectors. Metadata descriptions are in general GADTs indexed by the
--   code of the datatype they're associated with, so matching on the
--   metadata will reveal information about the shape of the datatype.
module Generics.SOP.Metadata

-- | The fixity of an infix constructor.
type Fixity = Int

-- | The name of a field / record selector.
type FieldName = String

-- | The name of a data constructor.
type ConstructorName = String

-- | The name of a module.
type ModuleName = String

-- | The name of a datatype.
type DatatypeName = String

-- | For records, this functor maps the component to its selector name.
data FieldInfo :: Type -> Type
[FieldInfo] :: FieldName -> FieldInfo a

-- | Metadata for a single constructors.
--   
--   This is indexed by the product structure of the constructor
--   components.
data ConstructorInfo :: [Type] -> Type
[Constructor] :: SListI xs => ConstructorName -> ConstructorInfo xs
[Infix] :: ConstructorName -> Associativity -> Fixity -> ConstructorInfo '[x, y]
[Record] :: SListI xs => ConstructorName -> NP FieldInfo xs -> ConstructorInfo xs

-- | Metadata for a datatype.
--   
--   A value of type <tt><a>DatatypeInfo</a> c</tt> contains the
--   information about a datatype that is not contained in
--   <tt><tt>Code</tt> c</tt>. This information consists primarily of the
--   names of the datatype, its constructors, and possibly its record
--   selectors.
--   
--   The constructor indicates whether the datatype has been declared using
--   <tt>newtype</tt> or not.
data DatatypeInfo :: [[Type]] -> Type
[ADT] :: ModuleName -> DatatypeName -> NP ConstructorInfo xss -> DatatypeInfo xss
[Newtype] :: ModuleName -> DatatypeName -> ConstructorInfo '[x] -> DatatypeInfo '['[x]]

-- | The module name where a datatype is defined.
moduleName :: DatatypeInfo xss -> ModuleName

-- | The name of a datatype (or newtype).
datatypeName :: DatatypeInfo xss -> DatatypeName

-- | The constructor info for a datatype (or newtype).
constructorInfo :: DatatypeInfo xss -> NP ConstructorInfo xss

-- | The name of a constructor.
constructorName :: ConstructorInfo xs -> ConstructorName

-- | The name of a field.
fieldName :: FieldInfo a -> FieldName

-- | Datatype to represent the associativity of a constructor
data Associativity
LeftAssociative :: Associativity
RightAssociative :: Associativity
NotAssociative :: Associativity
instance GHC.Base.Functor Generics.SOP.Metadata.FieldInfo
instance GHC.Classes.Ord (Generics.SOP.Metadata.FieldInfo a)
instance GHC.Classes.Eq (Generics.SOP.Metadata.FieldInfo a)
instance GHC.Show.Show (Generics.SOP.Metadata.FieldInfo a)
instance Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Show.Show Generics.SOP.Metadata.ConstructorInfo) xs => GHC.Show.Show (Generics.SOP.Metadata.DatatypeInfo xs)
instance Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Eq Generics.SOP.Metadata.ConstructorInfo) xs => GHC.Classes.Eq (Generics.SOP.Metadata.DatatypeInfo xs)
instance (Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Eq Generics.SOP.Metadata.ConstructorInfo) xs, Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Ord Generics.SOP.Metadata.ConstructorInfo) xs) => GHC.Classes.Ord (Generics.SOP.Metadata.DatatypeInfo xs)
instance Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Show.Show Generics.SOP.Metadata.FieldInfo) xs => GHC.Show.Show (Generics.SOP.Metadata.ConstructorInfo xs)
instance Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Eq Generics.SOP.Metadata.FieldInfo) xs => GHC.Classes.Eq (Generics.SOP.Metadata.ConstructorInfo xs)
instance (Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Eq Generics.SOP.Metadata.FieldInfo) xs, Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Ord Generics.SOP.Metadata.FieldInfo) xs) => GHC.Classes.Ord (Generics.SOP.Metadata.ConstructorInfo xs)

module Generics.SOP.NS

module Generics.SOP.Sing


-- | Type-level metadata
--   
--   This module provides datatypes (to be used promoted) that can
--   represent the metadata of Haskell datatypes on the type level.
--   
--   We do not reuse the term-level metadata types, because these are GADTs
--   that incorporate additional invariants. We could (at least in GHC 8)
--   impose the same invariants on the type level as well, but some tests
--   have revealed that the resulting type are rather inconvenient to work
--   with.
--   
--   So we use simple datatypes to represent the type-level metadata, even
--   if this means that some invariants are not explicitly captured.
--   
--   We establish a relation between the term- and type-level versions of
--   the metadata by automatically computing the term-level version from
--   the type-level version.
--   
--   As we now have two versions of metadata (term-level and type-level)
--   with very similar, yet slightly different datatype definitions, the
--   names between the modules clash, and this module is recommended to be
--   imported qualified when needed.
--   
--   The interface exported by this module is still somewhat experimental.
module Generics.SOP.Type.Metadata

-- | Class for computing term-level associativity information from
--   type-level associativity information.
class DemoteAssociativity (a :: Associativity)

-- | Given a proxy of some type-level associativity information, return the
--   corresponding term-level information.
demoteAssociativity :: DemoteAssociativity a => proxy a -> Associativity

-- | Class for computing term-level field information from type-level field
--   information.
class DemoteFieldInfo (x :: FieldInfo) (a :: Type)

-- | Given a proxy of some type-level field information, return the
--   corresponding term-level information.
demoteFieldInfo :: DemoteFieldInfo x a => proxy x -> FieldInfo a

-- | Class for computing term-level field information from type-level field
--   information.
class SListI xs => DemoteFieldInfos (fs :: [FieldInfo]) (xs :: [Type])

-- | Given a proxy of some type-level field information, return the
--   corresponding term-level information as a product.
demoteFieldInfos :: DemoteFieldInfos fs xs => proxy fs -> NP FieldInfo xs

-- | Class for computing term-level constructor information from type-level
--   constructor information.
class DemoteConstructorInfo (x :: ConstructorInfo) (xs :: [Type])

-- | Given a proxy of some type-level constructor information, return the
--   corresponding term-level information.
demoteConstructorInfo :: DemoteConstructorInfo x xs => proxy x -> ConstructorInfo xs

-- | Class for computing term-level constructor information from type-level
--   constructor information.
class DemoteConstructorInfos (cs :: [ConstructorInfo]) (xss :: [[Type]])

-- | Given a proxy of some type-level constructor information, return the
--   corresponding term-level information as a product.
demoteConstructorInfos :: DemoteConstructorInfos cs xss => proxy cs -> NP ConstructorInfo xss

-- | Class for computing term-level datatype information from type-level
--   datatype information.
class DemoteDatatypeInfo (x :: DatatypeInfo) (xss :: [[Type]])

-- | Given a proxy of some type-level datatype information, return the
--   corresponding term-level information.
demoteDatatypeInfo :: DemoteDatatypeInfo x xss => proxy x -> DatatypeInfo xss

-- | The fixity of an infix constructor.
type Fixity = Nat

-- | The name of a field / record selector.
type FieldName = Symbol

-- | The name of a data constructor.
type ConstructorName = Symbol

-- | The name of a module.
type ModuleName = Symbol

-- | The name of a datatype.
type DatatypeName = Symbol

-- | Metadata for a single record field (to be used promoted).
data FieldInfo
FieldInfo :: FieldName -> FieldInfo

-- | Metadata for a single constructors (to be used promoted).
data ConstructorInfo

-- | Normal constructor
Constructor :: ConstructorName -> ConstructorInfo

-- | Infix constructor
Infix :: ConstructorName -> Associativity -> Fixity -> ConstructorInfo

-- | Record constructor
Record :: ConstructorName -> [FieldInfo] -> ConstructorInfo

-- | Metadata for a datatype (to be used promoted).
--   
--   A type of kind <tt><a>DatatypeInfo</a></tt> contains meta-information
--   about a datatype that is not contained in its code. This information
--   consists primarily of the names of the datatype, its constructors, and
--   possibly its record selectors.
--   
--   The constructor indicates whether the datatype has been declared using
--   <tt>newtype</tt> or not.
data DatatypeInfo

-- | Standard algebraic datatype
ADT :: ModuleName -> DatatypeName -> [ConstructorInfo] -> DatatypeInfo

-- | Newtype
Newtype :: ModuleName -> DatatypeName -> ConstructorInfo -> DatatypeInfo

-- | Datatype to represent the associativity of a constructor
data Associativity
LeftAssociative :: Associativity
RightAssociative :: Associativity
NotAssociative :: Associativity
instance (GHC.TypeLits.KnownSymbol s, Generics.SOP.Type.Metadata.DemoteAssociativity a, GHC.TypeNats.KnownNat f) => Generics.SOP.Type.Metadata.DemoteConstructorInfo ('Generics.SOP.Type.Metadata.Infix s a f) '[y, z]
instance Generics.SOP.Type.Metadata.DemoteAssociativity 'GHC.Generics.LeftAssociative
instance Generics.SOP.Type.Metadata.DemoteAssociativity 'GHC.Generics.RightAssociative
instance Generics.SOP.Type.Metadata.DemoteAssociativity 'GHC.Generics.NotAssociative
instance (Generics.SOP.Type.Metadata.DemoteFieldInfo f x, Generics.SOP.Type.Metadata.DemoteFieldInfos fs xs) => Generics.SOP.Type.Metadata.DemoteFieldInfos (f : fs) (x : xs)
instance GHC.TypeLits.KnownSymbol s => Generics.SOP.Type.Metadata.DemoteFieldInfo ('Generics.SOP.Type.Metadata.FieldInfo s) a
instance (GHC.TypeLits.KnownSymbol s, Generics.SOP.Type.Metadata.DemoteFieldInfos fs xs) => Generics.SOP.Type.Metadata.DemoteConstructorInfo ('Generics.SOP.Type.Metadata.Record s fs) xs
instance Generics.SOP.Type.Metadata.DemoteFieldInfos '[] '[]
instance (GHC.TypeLits.KnownSymbol m, GHC.TypeLits.KnownSymbol d, Generics.SOP.Type.Metadata.DemoteConstructorInfo c '[x]) => Generics.SOP.Type.Metadata.DemoteDatatypeInfo ('Generics.SOP.Type.Metadata.Newtype m d c) '[ '[x]]
instance (Generics.SOP.Type.Metadata.DemoteConstructorInfo c xs, Generics.SOP.Type.Metadata.DemoteConstructorInfos cs xss) => Generics.SOP.Type.Metadata.DemoteConstructorInfos (c : cs) (xs : xss)
instance (GHC.TypeLits.KnownSymbol s, Data.SOP.Constraint.SListI xs) => Generics.SOP.Type.Metadata.DemoteConstructorInfo ('Generics.SOP.Type.Metadata.Constructor s) xs
instance (GHC.TypeLits.KnownSymbol m, GHC.TypeLits.KnownSymbol d, Generics.SOP.Type.Metadata.DemoteConstructorInfos cs xss) => Generics.SOP.Type.Metadata.DemoteDatatypeInfo ('Generics.SOP.Type.Metadata.ADT m d cs) xss
instance Generics.SOP.Type.Metadata.DemoteConstructorInfos '[] '[]


-- | Derive <tt>generics-sop</tt> boilerplate instances from GHC's
--   <a>Generic</a>.
--   
--   The technique being used here is described in the following paper:
--   
--   <ul>
--   <li>José Pedro Magalhães and Andres Löh. <a>Generic Generic
--   Programming</a>. Practical Aspects of Declarative Languages (PADL)
--   2014.</li>
--   </ul>
module Generics.SOP.GGP

-- | Compute the SOP code of a datatype.
--   
--   This requires that <a>Rep</a> is defined, which in turn requires that
--   the type has a <a>Generic</a> (from module <a>GHC.Generics</a>)
--   instance.
--   
--   This is the default definition for <a>Code</a>. For more info, see
--   <a>Generic</a>.
type GCode (a :: Type) = ToSumCode (Rep a) '[]

-- | Constraint for the class that computes <a>gfrom</a>.
type GFrom a = GSumFrom (Rep a)

-- | Constraint for the class that computes <a>gto</a>.
type GTo a = GSumTo (Rep a)

-- | Constraint for the class that computes <a>gdatatypeInfo</a>.
type GDatatypeInfo a = DemoteDatatypeInfo (GDatatypeInfoOf a) (GCode a)

-- | Compute the datatype info of a datatype.
type GDatatypeInfoOf (a :: Type) = ToInfo (Rep a)

-- | An automatically computed version of <a>from</a>.
--   
--   This requires that the type being converted has a <a>Generic</a> (from
--   module <a>GHC.Generics</a>) instance.
--   
--   This is the default definition for <a>from</a>. For more info, see
--   <a>Generic</a>.
gfrom :: (GFrom a, Generic a) => a -> SOP I (GCode a)

-- | An automatically computed version of <a>to</a>.
--   
--   This requires that the type being converted has a <a>Generic</a> (from
--   module <a>GHC.Generics</a>) instance.
--   
--   This is the default definition for <a>to</a>. For more info, see
--   <a>Generic</a>.
gto :: forall a. (GTo a, Generic a) => SOP I (GCode a) -> a

-- | An automatically computed version of <a>datatypeInfo</a>.
--   
--   This requires that the type being converted has a <a>Generic</a> (from
--   module <a>GHC.Generics</a>) instance.
--   
--   This is the default definition for <a>datatypeInfo</a>. For more info,
--   see <a>HasDatatypeInfo</a>.
gdatatypeInfo :: forall proxy a. GDatatypeInfo a => proxy a -> DatatypeInfo (GCode a)
instance Generics.SOP.GGP.GSumTo GHC.Generics.V1
instance (Generics.SOP.GGP.GSumTo a, Generics.SOP.GGP.GSumTo b) => Generics.SOP.GGP.GSumTo (a GHC.Generics.:+: b)
instance Generics.SOP.GGP.GProductTo a => Generics.SOP.GGP.GSumTo (GHC.Generics.M1 GHC.Generics.C c a)
instance Generics.SOP.GGP.GSumTo a => Generics.SOP.GGP.GSumTo (GHC.Generics.M1 GHC.Generics.D c a)
instance Generics.SOP.GGP.GSumFrom GHC.Generics.V1
instance (Generics.SOP.GGP.GSumFrom a, Generics.SOP.GGP.GSumFrom b) => Generics.SOP.GGP.GSumFrom (a GHC.Generics.:+: b)
instance Generics.SOP.GGP.GSumFrom a => Generics.SOP.GGP.GSumFrom (GHC.Generics.M1 GHC.Generics.D c a)
instance Generics.SOP.GGP.GProductFrom a => Generics.SOP.GGP.GSumFrom (GHC.Generics.M1 GHC.Generics.C c a)
instance (Generics.SOP.GGP.GProductTo a, Generics.SOP.GGP.GProductTo b) => Generics.SOP.GGP.GProductTo (a GHC.Generics.:*: b)
instance Generics.SOP.GGP.GSingleTo a => Generics.SOP.GGP.GProductTo (GHC.Generics.M1 GHC.Generics.S c a)
instance Generics.SOP.GGP.GProductTo GHC.Generics.U1
instance Generics.SOP.GGP.GSingleTo (GHC.Generics.K1 i a)
instance (Generics.SOP.GGP.GProductFrom a, Generics.SOP.GGP.GProductFrom b) => Generics.SOP.GGP.GProductFrom (a GHC.Generics.:*: b)
instance Generics.SOP.GGP.GProductFrom GHC.Generics.U1
instance Generics.SOP.GGP.GSingleFrom a => Generics.SOP.GGP.GProductFrom (GHC.Generics.M1 GHC.Generics.S c a)
instance Generics.SOP.GGP.GSingleFrom (GHC.Generics.K1 i a)
instance (Generics.SOP.GGP.GFieldInfos a, Generics.SOP.GGP.GFieldInfos b) => Generics.SOP.GGP.GFieldInfos (a GHC.Generics.:*: b)
instance Generics.SOP.GGP.GFieldInfos GHC.Generics.U1
instance GHC.Generics.Selector c => Generics.SOP.GGP.GFieldInfos (GHC.Generics.M1 GHC.Generics.S c a)


-- | Codes and interpretations
module Generics.SOP.Universe

-- | The (generic) representation of a datatype.
--   
--   A datatype is isomorphic to the sum-of-products of its code. The
--   isomorphism is witnessed by <a>from</a> and <a>to</a> from the
--   <a>Generic</a> class.
type Rep a = SOP I (Code a)

-- | The class of representable datatypes.
--   
--   The SOP approach to generic programming is based on viewing datatypes
--   as a representation (<a>Rep</a>) built from the sum of products of its
--   components. The components of are datatype are specified using the
--   <a>Code</a> type family.
--   
--   The isomorphism between the original Haskell datatype and its
--   representation is witnessed by the methods of this class, <a>from</a>
--   and <a>to</a>. So for instances of this class, the following laws
--   should (in general) hold:
--   
--   <pre>
--   <a>to</a> <a>.</a> <a>from</a> === <a>id</a> :: a -&gt; a
--   <a>from</a> <a>.</a> <a>to</a> === <a>id</a> :: <a>Rep</a> a -&gt; <a>Rep</a> a
--   </pre>
--   
--   You typically don't define instances of this class by hand, but rather
--   derive the class instance automatically.
--   
--   <i>Option 1:</i> Derive via the built-in GHC-generics. For this, you
--   need to use the <tt>DeriveGeneric</tt> extension to first derive an
--   instance of the <a>Generic</a> class from module <a>GHC.Generics</a>.
--   With this, you can then give an empty instance for <a>Generic</a>, and
--   the default definitions will just work. The pattern looks as follows:
--   
--   <pre>
--   import qualified <a>GHC.Generics</a> as GHC
--   import <a>Generics.SOP</a>
--   
--   ...
--   
--   data T = ... deriving (GHC.<a>Generic</a>, ...)
--   
--   instance <a>Generic</a> T -- empty
--   instance <a>HasDatatypeInfo</a> T -- empty, if you want/need metadata
--   </pre>
--   
--   <i>Option 2:</i> Derive via Template Haskell. For this, you need to
--   enable the <tt>TemplateHaskell</tt> extension. You can then use
--   <a>deriveGeneric</a> from module <a>Generics.SOP.TH</a> to have the
--   instance generated for you. The pattern looks as follows:
--   
--   <pre>
--   import <a>Generics.SOP</a>
--   import <a>Generics.SOP.TH</a>
--   
--   ...
--   
--   data T = ...
--   
--   <a>deriveGeneric</a> ''T -- derives <a>HasDatatypeInfo</a> as well
--   </pre>
--   
--   <i>Tradeoffs:</i> Whether to use Option 1 or 2 is mainly a matter of
--   personal taste. The version based on Template Haskell probably has
--   less run-time overhead.
--   
--   <i>Non-standard instances:</i> It is possible to give <a>Generic</a>
--   instances manually that deviate from the standard scheme, as long as
--   at least
--   
--   <pre>
--   <a>to</a> <a>.</a> <a>from</a> === <a>id</a> :: a -&gt; a
--   </pre>
--   
--   still holds.
class (All SListI (Code a)) => Generic (a :: Type) where {
    
    -- | The code of a datatype.
    --   
    --   This is a list of lists of its components. The outer list contains one
    --   element per constructor. The inner list contains one element per
    --   constructor argument (field).
    --   
    --   <i>Example:</i> The datatype
    --   
    --   <pre>
    --   data Tree = Leaf Int | Node Tree Tree
    --   </pre>
    --   
    --   is supposed to have the following code:
    --   
    --   <pre>
    --   type instance Code (Tree a) =
    --     '[ '[ Int ]
    --      , '[ Tree, Tree ]
    --      ]
    --   </pre>
    type family Code a :: [[Type]];
    type Code a = GCode a;
}

-- | Converts from a value to its structural representation.
from :: Generic a => a -> Rep a

-- | Converts from a value to its structural representation.
from :: (Generic a, GFrom a, Generic a, Rep a ~ SOP I (GCode a)) => a -> Rep a

-- | Converts from a structural representation back to the original value.
to :: Generic a => Rep a -> a

-- | Converts from a structural representation back to the original value.
to :: (Generic a, GTo a, Generic a, Rep a ~ SOP I (GCode a)) => Rep a -> a

-- | A class of datatypes that have associated metadata.
--   
--   It is possible to use the sum-of-products approach to generic
--   programming without metadata. If you need metadata in a function, an
--   additional constraint on this class is in order.
--   
--   You typically don't define instances of this class by hand, but rather
--   derive the class instance automatically. See the documentation of
--   <a>Generic</a> for the options.
class Generic a => HasDatatypeInfo a where {
    
    -- | Type-level datatype info
    type family DatatypeInfoOf a :: DatatypeInfo;
    type DatatypeInfoOf a = GDatatypeInfoOf a;
}

-- | Term-level datatype info; by default, the term-level datatype info is
--   produced from the type-level info.
datatypeInfo :: HasDatatypeInfo a => proxy a -> DatatypeInfo (Code a)

-- | Term-level datatype info; by default, the term-level datatype info is
--   produced from the type-level info.
datatypeInfo :: (HasDatatypeInfo a, GDatatypeInfo a, GCode a ~ Code a) => proxy a -> DatatypeInfo (Code a)

-- | Constraint that captures that a datatype is a product type, i.e., a
--   type with a single constructor.
--   
--   It also gives access to the code for the arguments of that
--   constructor.
type IsProductType (a :: Type) (xs :: [Type]) = (Generic a, Code a ~ '[xs])

-- | Direct access to the part of the code that is relevant for a product
--   type.
type ProductCode (a :: Type) = Head (Code a)

-- | Convert from a product type to its product representation.
productTypeFrom :: IsProductType a xs => a -> NP I xs

-- | Convert a product representation to the original type.
productTypeTo :: IsProductType a xs => NP I xs -> a

-- | Constraint that captures that a datatype is an enumeration type, i.e.,
--   none of the constructors have any arguments.
type IsEnumType (a :: Type) = (Generic a, All ((~) '[]) (Code a))

-- | Convert from an enum type to its sum representation.
enumTypeFrom :: IsEnumType a => a -> NS (K ()) (Code a)

-- | Convert a sum representation to ihe original type.
enumTypeTo :: IsEnumType a => NS (K ()) (Code a) -> a

-- | Constraint that captures that a datatype is a single-constructor,
--   single-field datatype. This always holds for newtype-defined types,
--   but it can also be true for data-defined types.
--   
--   The constraint also gives access to the type that is wrapped.
type IsWrappedType (a :: Type) (x :: Type) = (Generic a, Code a ~ '['[x]])

-- | Direct access to the part of the code that is relevant for wrapped
--   types and newtypes.
type WrappedCode (a :: Type) = Head (Head (Code a))

-- | Convert from a wrapped type to its inner type.
wrappedTypeFrom :: IsWrappedType a x => a -> x

-- | Convert a type to a wrapped type.
wrappedTypeTo :: IsWrappedType a x => x -> a

-- | Constraint that captures that a datatype is a newtype. This makes use
--   of the fact that newtypes are always coercible to the type they wrap,
--   whereas datatypes are not.
type IsNewtype (a :: Type) (x :: Type) = (IsWrappedType a x, Coercible a x)

-- | Convert a newtype to its inner type.
--   
--   This is a specialised synonym for <a>coerce</a>.
newtypeFrom :: IsNewtype a x => a -> x

-- | Convert a type to a newtype.
--   
--   This is a specialised synonym for <a>coerce</a>.
newtypeTo :: IsNewtype a x => x -> a


-- | Generate <tt>generics-sop</tt> boilerplate instances using Template
--   Haskell.
module Generics.SOP.TH

-- | Generate <tt>generics-sop</tt> boilerplate for the given datatype.
--   
--   This function takes the name of a datatype and generates:
--   
--   <ul>
--   <li>a <a>Code</a> instance</li>
--   <li>a <a>Generic</a> instance</li>
--   <li>a <a>HasDatatypeInfo</a> instance</li>
--   </ul>
--   
--   Note that the generated code will require the <tt>TypeFamilies</tt>
--   and <tt>DataKinds</tt> extensions to be enabled for the module.
--   
--   <i>Example:</i> If you have the datatype
--   
--   <pre>
--   data Tree = Leaf Int | Node Tree Tree
--   </pre>
--   
--   and say
--   
--   <pre>
--   deriveGeneric ''Tree
--   </pre>
--   
--   then you get code that is equivalent to:
--   
--   <pre>
--   instance Generic Tree where
--   
--     type Code Tree = '[ '[Int], '[Tree, Tree] ]
--   
--     from (Leaf x)   = SOP (   Z (I x :* Nil))
--     from (Node l r) = SOP (S (Z (I l :* I r :* Nil)))
--   
--     to (SOP    (Z (I x :* Nil)))         = Leaf x
--     to (SOP (S (Z (I l :* I r :* Nil)))) = Node l r
--     to (SOP (S (S x)))                   = x `seq` error "inaccessible"
--   
--   instance HasDatatypeInfo Tree where
--     type DatatypeInfoOf Tree =
--       T.ADT "Main" "Tree"
--         '[ T.Constructor "Leaf", T.Constructor "Node" ]
--   
--     datatypeInfo _ =
--       T.demoteDatatypeInfo (Proxy :: Proxy (DatatypeInfoOf Tree))
--   </pre>
--   
--   <i>Limitations:</i> Generation does not work for GADTs, for datatypes
--   that involve existential quantification, for datatypes with unboxed
--   fields.
deriveGeneric :: Name -> Q [Dec]

-- | Like <a>deriveGeneric</a>, but omit the <a>HasDatatypeInfo</a>
--   instance.
deriveGenericOnly :: Name -> Q [Dec]

-- | Variant of <a>deriveGeneric</a> that allows to restrict the type
--   parameters.
--   
--   Experimental function, exposed primarily for benchmarking.
deriveGenericSubst :: Name -> (Name -> Q Type) -> Q [Dec]

-- | Variant of <a>deriveGenericOnly</a> that allows to restrict the type
--   parameters.
--   
--   Experimental function, exposed primarily for benchmarking.
deriveGenericOnlySubst :: Name -> (Name -> Q Type) -> Q [Dec]

-- | Like <a>deriveGenericOnly</a>, but don't derive class instance, only
--   functions.
--   
--   <i>Example:</i> If you say
--   
--   <pre>
--   deriveGenericFunctions ''Tree "TreeCode" "fromTree" "toTree"
--   </pre>
--   
--   then you get code that is equivalent to:
--   
--   <pre>
--   type TreeCode = '[ '[Int], '[Tree, Tree] ]
--   
--   fromTree :: Tree -&gt; SOP I TreeCode
--   fromTree (Leaf x)   = SOP (   Z (I x :* Nil))
--   fromTree (Node l r) = SOP (S (Z (I l :* I r :* Nil)))
--   
--   toTree :: SOP I TreeCode -&gt; Tree
--   toTree (SOP    (Z (I x :* Nil)))         = Leaf x
--   toTree (SOP (S (Z (I l :* I r :* Nil)))) = Node l r
--   toTree (SOP (S (S x)))                   = x `seq` error "inaccessible"
--   </pre>
deriveGenericFunctions :: Name -> String -> String -> String -> Q [Dec]

-- | Derive <tt>DatatypeInfo</tt> value for the type.
--   
--   <i>Example:</i> If you say
--   
--   <pre>
--   deriveMetadataValue ''Tree "TreeCode" "treeDatatypeInfo"
--   </pre>
--   
--   then you get code that is equivalent to:
--   
--   <pre>
--   treeDatatypeInfo :: DatatypeInfo TreeCode
--   treeDatatypeInfo = ADT "Main" "Tree"
--       (Constructor "Leaf" :* Constructor "Node" :* Nil)
--   </pre>
--   
--   <i>Note:</i> CodeType needs to be derived with
--   <a>deriveGenericFunctions</a>.

-- | <i>Deprecated: Use <a>deriveMetadataType</a> and
--   <tt>demoteDatatypeInfo</tt> instead.</i>
deriveMetadataValue :: Name -> String -> String -> Q [Dec]

-- | Derive <tt>DatatypeInfo</tt> type for the type.
--   
--   <i>Example:</i> If you say
--   
--   <pre>
--   deriveMetadataType ''Tree "TreeDatatypeInfo"
--   </pre>
--   
--   then you get code that is equivalent to:
--   
--   <pre>
--   type TreeDatatypeInfo =
--     T.ADT "Main" "Tree"
--       [ T.Constructor "Leaf", T.Constructor "Node" ]
--   </pre>
deriveMetadataType :: Name -> String -> Q [Dec]


-- | Instances for <tt>Generic</tt> and <tt>HasMetadata</tt>.
--   
--   We define instances for datatypes from <tt>generics-sop</tt> and
--   <tt>base</tt> that are supported.
--   
--   (There are only instances defined in this module, so the documentation
--   is empty.)
module Generics.SOP.Instances
instance Generics.SOP.Universe.Generic Text.Read.Lex.Number
instance Generics.SOP.Universe.HasDatatypeInfo Text.Read.Lex.Number
instance Generics.SOP.Universe.Generic Text.Read.Lex.Lexeme
instance Generics.SOP.Universe.HasDatatypeInfo Text.Read.Lex.Lexeme
instance Generics.SOP.Universe.Generic Text.Printf.FormatParse
instance Generics.SOP.Universe.HasDatatypeInfo Text.Printf.FormatParse
instance Generics.SOP.Universe.Generic Text.Printf.FormatSign
instance Generics.SOP.Universe.HasDatatypeInfo Text.Printf.FormatSign
instance Generics.SOP.Universe.Generic Text.Printf.FormatAdjustment
instance Generics.SOP.Universe.HasDatatypeInfo Text.Printf.FormatAdjustment
instance Generics.SOP.Universe.Generic Text.Printf.FieldFormat
instance Generics.SOP.Universe.HasDatatypeInfo Text.Printf.FieldFormat
instance Generics.SOP.Universe.Generic GHC.IO.Handle.Types.NewlineMode
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Handle.Types.NewlineMode
instance Generics.SOP.Universe.Generic GHC.IO.Handle.Types.Newline
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Handle.Types.Newline
instance Generics.SOP.Universe.Generic GHC.IO.Device.SeekMode
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Device.SeekMode
instance Generics.SOP.Universe.Generic GHC.IO.Handle.Types.BufferMode
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Handle.Types.BufferMode
instance Generics.SOP.Universe.Generic GHC.IO.IOMode.IOMode
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.IOMode.IOMode
instance Generics.SOP.Universe.Generic GHC.IO.Exception.ExitCode
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.ExitCode
instance Generics.SOP.Universe.Generic (System.Console.GetOpt.ArgDescr a)
instance Generics.SOP.Universe.HasDatatypeInfo (System.Console.GetOpt.ArgDescr a)
instance Generics.SOP.Universe.Generic (System.Console.GetOpt.OptDescr a)
instance Generics.SOP.Universe.HasDatatypeInfo (System.Console.GetOpt.OptDescr a)
instance Generics.SOP.Universe.Generic (System.Console.GetOpt.ArgOrder a)
instance Generics.SOP.Universe.HasDatatypeInfo (System.Console.GetOpt.ArgOrder a)
instance Generics.SOP.Universe.Generic GHC.Stats.GCDetails
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Stats.GCDetails
instance Generics.SOP.Universe.Generic GHC.Stats.RTSStats
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Stats.RTSStats
instance Generics.SOP.Universe.Generic GHC.StaticPtr.StaticPtrInfo
instance Generics.SOP.Universe.HasDatatypeInfo GHC.StaticPtr.StaticPtrInfo
instance Generics.SOP.Universe.Generic GHC.Stack.Types.CallStack
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Stack.Types.CallStack
instance Generics.SOP.Universe.Generic GHC.Stack.Types.SrcLoc
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Stack.Types.SrcLoc
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.ParFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.ParFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.TickyFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.TickyFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.TraceFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.TraceFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.DoTrace
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.DoTrace
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.ProfFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.ProfFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.DoHeapProfile
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.DoHeapProfile
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.CCFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.CCFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.DoCostCentres
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.DoCostCentres
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.DebugFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.DebugFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.MiscFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.MiscFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.ConcFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.ConcFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.GCFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.GCFlags
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.GiveGCStats
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.GiveGCStats
instance Generics.SOP.Universe.Generic GHC.RTS.Flags.RTSFlags
instance Generics.SOP.Universe.HasDatatypeInfo GHC.RTS.Flags.RTSFlags
instance Generics.SOP.Universe.Generic GHC.IO.Handle.Lock.LockMode
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Handle.Lock.LockMode
instance Generics.SOP.Universe.Generic GHC.IO.Handle.HandlePosn
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Handle.HandlePosn
instance Generics.SOP.Universe.Generic GHC.IO.Exception.IOErrorType
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.IOErrorType
instance Generics.SOP.Universe.Generic GHC.IO.Exception.FixIOException
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.FixIOException
instance Generics.SOP.Universe.Generic GHC.Float.FFFormat
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Float.FFFormat
instance Generics.SOP.Universe.Generic GHC.Fingerprint.Type.Fingerprint
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Fingerprint.Type.Fingerprint
instance Generics.SOP.Universe.Generic GHC.IO.Encoding.Failure.CodingFailureMode
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Encoding.Failure.CodingFailureMode
instance Generics.SOP.Universe.Generic GHC.IO.Encoding.Types.CodingProgress
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Encoding.Types.CodingProgress
instance Generics.SOP.Universe.Generic (GHC.IO.Encoding.Types.BufferCodec from to state)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.IO.Encoding.Types.BufferCodec from to state)
instance Generics.SOP.Universe.Generic GHC.IO.Device.IODeviceType
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Device.IODeviceType
instance Generics.SOP.Universe.Generic GHC.IO.Buffer.BufferState
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Buffer.BufferState
instance Generics.SOP.Universe.Generic (GHC.IO.Buffer.Buffer e)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.IO.Buffer.Buffer e)
instance Generics.SOP.Universe.Generic GHC.Generics.Fixity
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.Fixity
instance Generics.SOP.Universe.Generic GHC.Generics.SourceUnpackedness
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.SourceUnpackedness
instance Generics.SOP.Universe.Generic GHC.Generics.SourceStrictness
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.SourceStrictness
instance Generics.SOP.Universe.Generic GHC.Generics.DecidedStrictness
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.DecidedStrictness
instance Generics.SOP.Universe.Generic GHC.Generics.Associativity
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.Associativity
instance Generics.SOP.Universe.Generic ((GHC.Generics.:.:) f g p)
instance Generics.SOP.Universe.HasDatatypeInfo ((GHC.Generics.:.:) f g p)
instance Generics.SOP.Universe.Generic ((GHC.Generics.:+:) f g p)
instance Generics.SOP.Universe.HasDatatypeInfo ((GHC.Generics.:+:) f g p)
instance Generics.SOP.Universe.Generic ((GHC.Generics.:*:) f g p)
instance Generics.SOP.Universe.HasDatatypeInfo ((GHC.Generics.:*:) f g p)
instance Generics.SOP.Universe.Generic GHC.Generics.C
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.C
instance Generics.SOP.Universe.Generic GHC.Generics.D
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.D
instance Generics.SOP.Universe.Generic GHC.Generics.S
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.S
instance Generics.SOP.Universe.Generic GHC.Generics.R
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Generics.R
instance Generics.SOP.Universe.Generic (GHC.Generics.M1 i c f p)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.Generics.M1 i c f p)
instance Generics.SOP.Universe.Generic (GHC.Generics.Par1 p)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.Generics.Par1 p)
instance Generics.SOP.Universe.Generic (GHC.Generics.V1 p)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.Generics.V1 p)
instance Generics.SOP.Universe.Generic (GHC.Generics.U1 p)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.Generics.U1 p)
instance Generics.SOP.Universe.Generic (GHC.Generics.K1 i c p)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.Generics.K1 i c p)
instance Generics.SOP.Universe.Generic GHC.Exts.SpecConstrAnnotation
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Exts.SpecConstrAnnotation
instance Generics.SOP.Universe.Generic GHC.Types.VecElem
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Types.VecElem
instance Generics.SOP.Universe.Generic GHC.Types.VecCount
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Types.VecCount
instance Generics.SOP.Universe.Generic GHC.Types.RuntimeRep
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Types.RuntimeRep
instance Generics.SOP.Universe.Generic GHC.ExecutionStack.Internal.SrcLoc
instance Generics.SOP.Universe.HasDatatypeInfo GHC.ExecutionStack.Internal.SrcLoc
instance Generics.SOP.Universe.Generic GHC.ExecutionStack.Internal.Location
instance Generics.SOP.Universe.HasDatatypeInfo GHC.ExecutionStack.Internal.Location
instance Generics.SOP.Universe.Generic GHC.Conc.Sync.BlockReason
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Conc.Sync.BlockReason
instance Generics.SOP.Universe.Generic GHC.Conc.Sync.ThreadStatus
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Conc.Sync.ThreadStatus
instance Generics.SOP.Universe.Generic GHC.ByteOrder.ByteOrder
instance Generics.SOP.Universe.HasDatatypeInfo GHC.ByteOrder.ByteOrder
instance Generics.SOP.Universe.Generic Foreign.C.Types.CDouble
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CDouble
instance Generics.SOP.Universe.Generic Foreign.C.Types.CFloat
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CFloat
instance Generics.SOP.Universe.Generic Foreign.C.Types.CSUSeconds
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CSUSeconds
instance Generics.SOP.Universe.Generic Foreign.C.Types.CUSeconds
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CUSeconds
instance Generics.SOP.Universe.Generic Foreign.C.Types.CTime
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CTime
instance Generics.SOP.Universe.Generic Foreign.C.Types.CClock
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CClock
instance Generics.SOP.Universe.Generic Foreign.C.Types.CUIntMax
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CUIntMax
instance Generics.SOP.Universe.Generic Foreign.C.Types.CIntMax
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CIntMax
instance Generics.SOP.Universe.Generic Foreign.C.Types.CUIntPtr
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CUIntPtr
instance Generics.SOP.Universe.Generic Foreign.C.Types.CIntPtr
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CIntPtr
instance Generics.SOP.Universe.Generic Foreign.C.Types.CULLong
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CULLong
instance Generics.SOP.Universe.Generic Foreign.C.Types.CLLong
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CLLong
instance Generics.SOP.Universe.Generic Foreign.C.Types.CSigAtomic
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CSigAtomic
instance Generics.SOP.Universe.Generic Foreign.C.Types.CWchar
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CWchar
instance Generics.SOP.Universe.Generic Foreign.C.Types.CSize
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CSize
instance Generics.SOP.Universe.Generic Foreign.C.Types.CPtrdiff
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CPtrdiff
instance Generics.SOP.Universe.Generic Foreign.C.Types.CULong
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CULong
instance Generics.SOP.Universe.Generic Foreign.C.Types.CLong
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CLong
instance Generics.SOP.Universe.Generic Foreign.C.Types.CUInt
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CUInt
instance Generics.SOP.Universe.Generic Foreign.C.Types.CInt
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CInt
instance Generics.SOP.Universe.Generic Foreign.C.Types.CUShort
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CUShort
instance Generics.SOP.Universe.Generic Foreign.C.Types.CShort
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CShort
instance Generics.SOP.Universe.Generic Foreign.C.Types.CUChar
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CUChar
instance Generics.SOP.Universe.Generic Foreign.C.Types.CSChar
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CSChar
instance Generics.SOP.Universe.Generic Foreign.C.Types.CChar
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Types.CChar
instance Generics.SOP.Universe.Generic Foreign.C.Error.Errno
instance Generics.SOP.Universe.HasDatatypeInfo Foreign.C.Error.Errno
instance Generics.SOP.Universe.Generic Data.Void.Void
instance Generics.SOP.Universe.HasDatatypeInfo Data.Void.Void
instance Generics.SOP.Universe.Generic Data.Version.Version
instance Generics.SOP.Universe.HasDatatypeInfo Data.Version.Version
instance Generics.SOP.Universe.Generic (Data.Semigroup.Arg a b)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Arg a b)
instance Generics.SOP.Universe.Generic (Data.Semigroup.Option a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Option a)
instance Generics.SOP.Universe.Generic (Data.Semigroup.WrappedMonoid m)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.WrappedMonoid m)
instance Generics.SOP.Universe.Generic (Data.Semigroup.Last a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Last a)
instance Generics.SOP.Universe.Generic (Data.Semigroup.First a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.First a)
instance Generics.SOP.Universe.Generic (Data.Semigroup.Max a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Max a)
instance Generics.SOP.Universe.Generic (Data.Semigroup.Min a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Min a)
instance Generics.SOP.Universe.Generic (Data.Proxy.Proxy t)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Proxy.Proxy t)
instance Generics.SOP.Universe.Generic (Data.Ord.Down a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Ord.Down a)
instance Generics.SOP.Universe.Generic (Data.Semigroup.Internal.Alt f a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Internal.Alt f a)
instance Generics.SOP.Universe.Generic (Data.Monoid.Last a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Monoid.Last a)
instance Generics.SOP.Universe.Generic (Data.Monoid.First a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Monoid.First a)
instance Generics.SOP.Universe.Generic (Data.Semigroup.Internal.Product a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Internal.Product a)
instance Generics.SOP.Universe.Generic (Data.Semigroup.Internal.Sum a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Internal.Sum a)
instance Generics.SOP.Universe.Generic Data.Semigroup.Internal.Any
instance Generics.SOP.Universe.HasDatatypeInfo Data.Semigroup.Internal.Any
instance Generics.SOP.Universe.Generic Data.Semigroup.Internal.All
instance Generics.SOP.Universe.HasDatatypeInfo Data.Semigroup.Internal.All
instance Generics.SOP.Universe.Generic (Data.Semigroup.Internal.Endo a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Internal.Endo a)
instance Generics.SOP.Universe.Generic (Data.Semigroup.Internal.Dual a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Semigroup.Internal.Dual a)
instance Generics.SOP.Universe.Generic (GHC.Base.NonEmpty a)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.Base.NonEmpty a)
instance Generics.SOP.Universe.Generic (Data.Functor.Sum.Sum f g a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Functor.Sum.Sum f g a)
instance Generics.SOP.Universe.Generic (Data.Functor.Product.Product f g a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Functor.Product.Product f g a)
instance Generics.SOP.Universe.Generic (Data.Functor.Identity.Identity a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Functor.Identity.Identity a)
instance Generics.SOP.Universe.Generic (Data.Functor.Const.Const a b)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Functor.Const.Const a b)
instance Generics.SOP.Universe.Generic (Data.Functor.Compose.Compose f g a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Functor.Compose.Compose f g a)
instance Generics.SOP.Universe.Generic Data.Fixed.E12
instance Generics.SOP.Universe.HasDatatypeInfo Data.Fixed.E12
instance Generics.SOP.Universe.Generic Data.Fixed.E9
instance Generics.SOP.Universe.HasDatatypeInfo Data.Fixed.E9
instance Generics.SOP.Universe.Generic Data.Fixed.E6
instance Generics.SOP.Universe.HasDatatypeInfo Data.Fixed.E6
instance Generics.SOP.Universe.Generic Data.Fixed.E3
instance Generics.SOP.Universe.HasDatatypeInfo Data.Fixed.E3
instance Generics.SOP.Universe.Generic Data.Fixed.E2
instance Generics.SOP.Universe.HasDatatypeInfo Data.Fixed.E2
instance Generics.SOP.Universe.Generic Data.Fixed.E1
instance Generics.SOP.Universe.HasDatatypeInfo Data.Fixed.E1
instance Generics.SOP.Universe.Generic Data.Fixed.E0
instance Generics.SOP.Universe.HasDatatypeInfo Data.Fixed.E0
instance Generics.SOP.Universe.Generic (Data.Fixed.Fixed a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Fixed.Fixed a)
instance Generics.SOP.Universe.Generic Data.Data.ConstrRep
instance Generics.SOP.Universe.HasDatatypeInfo Data.Data.ConstrRep
instance Generics.SOP.Universe.Generic Data.Data.Fixity
instance Generics.SOP.Universe.HasDatatypeInfo Data.Data.Fixity
instance Generics.SOP.Universe.Generic Data.Data.DataRep
instance Generics.SOP.Universe.HasDatatypeInfo Data.Data.DataRep
instance Generics.SOP.Universe.Generic (Data.Complex.Complex a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Complex.Complex a)
instance Generics.SOP.Universe.Generic GHC.Unicode.GeneralCategory
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Unicode.GeneralCategory
instance Generics.SOP.Universe.Generic GHC.IO.MaskingState
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.MaskingState
instance Generics.SOP.Universe.Generic Control.Exception.Base.TypeError
instance Generics.SOP.Universe.HasDatatypeInfo Control.Exception.Base.TypeError
instance Generics.SOP.Universe.Generic GHC.Exception.ErrorCall
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Exception.ErrorCall
instance Generics.SOP.Universe.Generic Control.Exception.Base.RecUpdError
instance Generics.SOP.Universe.HasDatatypeInfo Control.Exception.Base.RecUpdError
instance Generics.SOP.Universe.Generic Control.Exception.Base.RecSelError
instance Generics.SOP.Universe.HasDatatypeInfo Control.Exception.Base.RecSelError
instance Generics.SOP.Universe.Generic Control.Exception.Base.RecConError
instance Generics.SOP.Universe.HasDatatypeInfo Control.Exception.Base.RecConError
instance Generics.SOP.Universe.Generic Control.Exception.Base.PatternMatchFail
instance Generics.SOP.Universe.HasDatatypeInfo Control.Exception.Base.PatternMatchFail
instance Generics.SOP.Universe.Generic Control.Exception.Base.NoMethodError
instance Generics.SOP.Universe.HasDatatypeInfo Control.Exception.Base.NoMethodError
instance Generics.SOP.Universe.Generic GHC.IO.Exception.Deadlock
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.Deadlock
instance Generics.SOP.Universe.Generic GHC.IO.Exception.AllocationLimitExceeded
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.AllocationLimitExceeded
instance Generics.SOP.Universe.Generic GHC.IO.Exception.BlockedIndefinitelyOnSTM
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.BlockedIndefinitelyOnSTM
instance Generics.SOP.Universe.Generic GHC.IO.Exception.BlockedIndefinitelyOnMVar
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.BlockedIndefinitelyOnMVar
instance Generics.SOP.Universe.Generic Control.Exception.Base.NestedAtomically
instance Generics.SOP.Universe.HasDatatypeInfo Control.Exception.Base.NestedAtomically
instance Generics.SOP.Universe.Generic Control.Exception.Base.NonTermination
instance Generics.SOP.Universe.HasDatatypeInfo Control.Exception.Base.NonTermination
instance Generics.SOP.Universe.Generic GHC.IO.Exception.AsyncException
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.AsyncException
instance Generics.SOP.Universe.Generic GHC.IO.Exception.AssertionFailed
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.AssertionFailed
instance Generics.SOP.Universe.Generic GHC.IO.Exception.ArrayException
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.ArrayException
instance Generics.SOP.Universe.Generic GHC.Exception.Type.ArithException
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Exception.Type.ArithException
instance Generics.SOP.Universe.Generic GHC.IO.Exception.IOException
instance Generics.SOP.Universe.HasDatatypeInfo GHC.IO.Exception.IOException
instance Generics.SOP.Universe.Generic [a]
instance Generics.SOP.Universe.HasDatatypeInfo [a]
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t26, t27, t28, t29)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t26, t27, t28, t29)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t26, t27, t28)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t26, t27, t28)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t26, t27)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t26, t27)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t26)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, t26)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l, m)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k, l)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k, l)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j, k)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j, k)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i, j)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i, j)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h, i)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h, i)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g, h)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g, h)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f, g)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f, g)
instance Generics.SOP.Universe.Generic (a, b, c, d, e, f)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e, f)
instance Generics.SOP.Universe.Generic (a, b, c, d, e)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d, e)
instance Generics.SOP.Universe.Generic (a, b, c, d)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c, d)
instance Generics.SOP.Universe.Generic (a, b, c)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b, c)
instance Generics.SOP.Universe.Generic (a, b)
instance Generics.SOP.Universe.HasDatatypeInfo (a, b)
instance Generics.SOP.Universe.Generic ()
instance Generics.SOP.Universe.HasDatatypeInfo ()
instance Generics.SOP.Universe.Generic (Data.Either.Either a b)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.Either.Either a b)
instance Generics.SOP.Universe.Generic (GHC.Maybe.Maybe a)
instance Generics.SOP.Universe.HasDatatypeInfo (GHC.Maybe.Maybe a)
instance Generics.SOP.Universe.Generic GHC.Types.Ordering
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Types.Ordering
instance Generics.SOP.Universe.Generic GHC.Types.Bool
instance Generics.SOP.Universe.HasDatatypeInfo GHC.Types.Bool
instance Generics.SOP.Universe.Generic ((Data.SOP.Classes.-.->) f g a)
instance Generics.SOP.Universe.HasDatatypeInfo ((Data.SOP.Classes.-.->) f g a)
instance Generics.SOP.Universe.Generic ((Data.SOP.BasicFunctors.:.:) f g p)
instance Generics.SOP.Universe.HasDatatypeInfo ((Data.SOP.BasicFunctors.:.:) f g p)
instance Generics.SOP.Universe.Generic (Data.SOP.BasicFunctors.K a b)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.SOP.BasicFunctors.K a b)
instance Generics.SOP.Universe.Generic (Data.SOP.BasicFunctors.I a)
instance Generics.SOP.Universe.HasDatatypeInfo (Data.SOP.BasicFunctors.I a)


-- | Main module of <tt>generics-sop</tt>
--   
--   In most cases, you will probably want to import just this module, and
--   possibly <a>Generics.SOP.TH</a> if you want to use Template Haskell to
--   generate <a>Generic</a> instances for you.
--   
--   <h1>Generic programming with sums of products</h1>
--   
--   You need this library if you want to define your own generic functions
--   in the sum-of-products SOP style. Generic programming in the SOP style
--   follows the following idea:
--   
--   <ol>
--   <li>A large class of datatypes can be viewed in a uniform, structured
--   way: the choice between constructors is represented using an n-ary sum
--   (called <a>NS</a>), and the arguments of each constructor are
--   represented using an n-ary product (called <a>NP</a>).</li>
--   <li>The library captures the notion of a datatype being representable
--   in the following way. There is a class <a>Generic</a>, which for a
--   given datatype <tt>A</tt>, associates the isomorphic SOP
--   representation with the original type under the name <tt><a>Rep</a>
--   A</tt>. The class also provides functions <a>from</a> and <a>to</a>
--   that convert between <tt>A</tt> and <tt><a>Rep</a> A</tt> and witness
--   the isomorphism.</li>
--   <li>Since all <a>Rep</a> types are sums of products, you can define
--   functions over them by performing induction on the structure, of by
--   using predefined combinators that the library provides. Such functions
--   then work for all <a>Rep</a> types.</li>
--   <li>By combining the conversion functions <a>from</a> and <a>to</a>
--   with the function that works on <a>Rep</a> types, we obtain a function
--   that works on all types that are in the <a>Generic</a> class.</li>
--   <li>Most types can very easily be made an instance of <a>Generic</a>.
--   For example, if the datatype can be represented using GHC's built-in
--   approach to generic programming and has an instance for the
--   <a>Generic</a> class from module <a>GHC.Generics</a>, then an instance
--   of the SOP <a>Generic</a> can automatically be derived. There is also
--   Template Haskell code in <a>Generics.SOP.TH</a> that allows to
--   auto-generate an instance of <a>Generic</a> for most types.</li>
--   </ol>
--   
--   <h1>Example</h1>
--   
--   <h2>Instantiating a datatype for use with SOP generics</h2>
--   
--   Let's assume we have the datatypes:
--   
--   <pre>
--   data A   = C Bool | D A Int | E (B ())
--   data B a = F | G a Char Bool
--   </pre>
--   
--   To create <a>Generic</a> instances for <tt>A</tt> and <tt>B</tt> via
--   <a>GHC.Generics</a>, we say
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import qualified GHC.Generics as GHC
--   import Generics.SOP
--   
--   data A   = C Bool | D A Int | E (B ())
--     deriving (Show, GHC.Generic)
--   data B a = F | G a Char Bool
--     deriving (Show, GHC.Generic)
--   
--   instance Generic A     -- empty
--   instance Generic (B a) -- empty
--   </pre>
--   
--   Now we can convert between <tt>A</tt> and <tt><a>Rep</a> A</tt> (and
--   between <tt>B</tt> and <tt><a>Rep</a> B</tt>). For example,
--   
--   <pre>
--   &gt;&gt;&gt; from (D (C True) 3) :: Rep A
--   SOP (S (Z (I (C True) :* I 3 :* Nil)))
--   
--   &gt;&gt;&gt; to it :: A
--   D (C True) 3
--   </pre>
--   
--   Note that the transformation is shallow: In <tt>D (C True) 3</tt>, the
--   inner value <tt>C True</tt> of type <tt>A</tt> is not affected by the
--   transformation.
--   
--   For more details about <tt><a>Rep</a> A</tt>, have a look at the
--   <a>Generics.SOP.Universe</a> module.
--   
--   <h2>Defining a generic function</h2>
--   
--   As an example of a generic function, let us define a generic version
--   of <a>rnf</a> from the <tt>deepseq</tt> package.
--   
--   The type of <a>rnf</a> is
--   
--   <pre>
--   NFData a =&gt; a -&gt; ()
--   </pre>
--   
--   and the idea is that for a term <tt>x</tt> of type <tt>a</tt> in the
--   <a>NFData</a> class, <tt>rnf x</tt> forces complete evaluation of
--   <tt>x</tt> (i.e., evaluation to <i>normal form</i>), and returns
--   <tt>()</tt>.
--   
--   We call the generic version of this function <tt>grnf</tt>. A direct
--   definition in SOP style, making use of structural recursion on the
--   sums and products, looks as follows:
--   
--   <pre>
--   grnf :: (<a>Generic</a> a, <a>All2</a> NFData (<a>Code</a> a)) =&gt; a -&gt; ()
--   grnf x = grnfS (<a>from</a> x)
--   
--   grnfS :: (<a>All2</a> NFData xss) =&gt; <a>SOP</a> <a>I</a> xss -&gt; ()
--   grnfS (<a>SOP</a> (<a>Z</a> xs))  = grnfP xs
--   grnfS (<a>SOP</a> (<a>S</a> xss)) = grnfS (<a>SOP</a> xss)
--   
--   grnfP :: (<a>All</a> NFData xs) =&gt; <a>NP</a> <a>I</a> xs -&gt; ()
--   grnfP <a>Nil</a>         = ()
--   grnfP (<a>I</a> x <a>:*</a> xs) = x `deepseq` (grnfP xs)
--   </pre>
--   
--   The <tt>grnf</tt> function performs the conversion between <tt>a</tt>
--   and <tt><a>Rep</a> a</tt> by applying <a>from</a> and then applies
--   <tt>grnfS</tt>. The type of <tt>grnf</tt> indicates that <tt>a</tt>
--   must be in the <a>Generic</a> class so that we can apply <a>from</a>,
--   and that all the components of <tt>a</tt> (i.e., all the types that
--   occur as constructor arguments) must be in the <tt>NFData</tt> class
--   (<a>All2</a>).
--   
--   The function <tt>grnfS</tt> traverses the outer sum structure of the
--   sum of products (note that <tt><a>Rep</a> a = <a>SOP</a> <a>I</a>
--   (<a>Code</a> a)</tt>). It encodes which constructor was used to
--   construct the original argument of type <tt>a</tt>. Once we've found
--   the constructor in question (<a>Z</a>), we traverse the arguments of
--   that constructor using <tt>grnfP</tt>.
--   
--   The function <tt>grnfP</tt> traverses the product structure of the
--   constructor arguments. Each argument is evaluated using the
--   <a>deepseq</a> function from the <a>NFData</a> class. This requires
--   that all components of the product must be in the <tt>NFData</tt>
--   class (<a>All</a>) and triggers the corresponding constraints on the
--   other functions. Once the end of the product is reached (<a>Nil</a>),
--   we return <tt>()</tt>.
--   
--   <h2>Defining a generic function using combinators</h2>
--   
--   In many cases, generic functions can be written in a much more concise
--   way by avoiding the explicit structural recursion and resorting to the
--   powerful combinators provided by this library instead.
--   
--   For example, the <tt>grnf</tt> function can also be defined as a
--   one-liner as follows:
--   
--   <pre>
--   grnf :: (<a>Generic</a> a, <a>All2</a> NFData (<a>Code</a> a)) =&gt; a -&gt; ()
--   grnf = <tt>rnf</tt> . <a>hcollapse</a> . <a>hcmap</a> (<a>Proxy</a> :: <a>Proxy</a> NFData) (<a>mapIK</a> rnf) . <a>from</a>
--   </pre>
--   
--   <a>mapIK</a> and friends (<a>mapII</a>, <a>mapKI</a>, etc.) are small
--   helpers for working with <a>I</a> and <a>K</a> functors, for example
--   <a>mapIK</a> is defined as <tt><a>mapIK</a> f = \ (<a>I</a> x) -&gt;
--   <a>K</a> (f x)</tt>
--   
--   The following interaction should provide an idea of the individual
--   transformation steps:
--   
--   <pre>
--   &gt;&gt;&gt; let x = G 2.5 'A' False :: B Double
--   
--   &gt;&gt;&gt; from x
--   SOP (S (Z (I 2.5 :* I 'A' :* I False :* Nil)))
--   
--   &gt;&gt;&gt; hcmap (Proxy :: Proxy NFData) (mapIK rnf) it
--   SOP (S (Z (K () :* K () :* K () :* Nil)))
--   
--   &gt;&gt;&gt; hcollapse it
--   [(),(),()]
--   
--   &gt;&gt;&gt; rnf it
--   ()
--   </pre>
--   
--   The <a>from</a> call converts into the structural representation. Via
--   <a>hcmap</a>, we apply <tt>rnf</tt> to all the components. The result
--   is a sum of products of the same shape, but the components are no
--   longer heterogeneous (<a>I</a>), but homogeneous (<tt><a>K</a>
--   ()</tt>). A homogeneous structure can be collapsed (<a>hcollapse</a>)
--   into a normal Haskell list. Finally, <tt>rnf</tt> actually forces
--   evaluation of this list (and thereby actually drives the evaluation of
--   all the previous steps) and produces the final result.
--   
--   <h2>Using a generic function</h2>
--   
--   We can directly invoke <tt>grnf</tt> on any type that is an instance
--   of class <a>Generic</a>.
--   
--   <pre>
--   &gt;&gt;&gt; grnf (G 2.5 'A' False)
--   ()
--   
--   &gt;&gt;&gt; grnf (G 2.5 undefined False)
--   *** Exception: Prelude.undefined
--   ...
--   </pre>
--   
--   Note that the type of <tt>grnf</tt> requires that all components of
--   the type are in the <a>NFData</a> class. For a recursive datatype such
--   as <tt>B</tt>, this means that we have to make <tt>A</tt> (and in this
--   case, also <tt>B</tt>) an instance of <a>NFData</a> in order to be
--   able to use the <tt>grnf</tt> function. But we can use <tt>grnf</tt>
--   to supply the instance definitions:
--   
--   <pre>
--   instance NFData A where rnf = grnf
--   instance NFData a =&gt; NFData (B a) where rnf = grnf
--   </pre>
--   
--   <h1>More examples</h1>
--   
--   The best way to learn about how to define generic functions in the SOP
--   style is to look at a few simple examples. Examples are provided by
--   the following packages:
--   
--   <ul>
--   <li><tt><a>basic-sop</a></tt> basic examples,</li>
--   <li><tt><a>pretty-sop</a></tt> generic pretty printing,</li>
--   <li><tt><a>lens-sop</a></tt> generically computed lenses,</li>
--   <li><tt><a>json-sop</a></tt> generic JSON conversions.</li>
--   </ul>
--   
--   The generic functions in these packages use a wide variety of the
--   combinators that are offered by the library.
--   
--   <h1>Paper</h1>
--   
--   A detailed description of the ideas behind this library is provided by
--   the paper:
--   
--   <ul>
--   <li>Edsko de Vries and Andres Löh. <a>True Sums of Products</a>.
--   Workshop on Generic Programming (WGP) 2014.</li>
--   </ul>
module Generics.SOP

-- | The class of representable datatypes.
--   
--   The SOP approach to generic programming is based on viewing datatypes
--   as a representation (<a>Rep</a>) built from the sum of products of its
--   components. The components of are datatype are specified using the
--   <a>Code</a> type family.
--   
--   The isomorphism between the original Haskell datatype and its
--   representation is witnessed by the methods of this class, <a>from</a>
--   and <a>to</a>. So for instances of this class, the following laws
--   should (in general) hold:
--   
--   <pre>
--   <a>to</a> <a>.</a> <a>from</a> === <a>id</a> :: a -&gt; a
--   <a>from</a> <a>.</a> <a>to</a> === <a>id</a> :: <a>Rep</a> a -&gt; <a>Rep</a> a
--   </pre>
--   
--   You typically don't define instances of this class by hand, but rather
--   derive the class instance automatically.
--   
--   <i>Option 1:</i> Derive via the built-in GHC-generics. For this, you
--   need to use the <tt>DeriveGeneric</tt> extension to first derive an
--   instance of the <a>Generic</a> class from module <a>GHC.Generics</a>.
--   With this, you can then give an empty instance for <a>Generic</a>, and
--   the default definitions will just work. The pattern looks as follows:
--   
--   <pre>
--   import qualified <a>GHC.Generics</a> as GHC
--   import <a>Generics.SOP</a>
--   
--   ...
--   
--   data T = ... deriving (GHC.<a>Generic</a>, ...)
--   
--   instance <a>Generic</a> T -- empty
--   instance <a>HasDatatypeInfo</a> T -- empty, if you want/need metadata
--   </pre>
--   
--   <i>Option 2:</i> Derive via Template Haskell. For this, you need to
--   enable the <tt>TemplateHaskell</tt> extension. You can then use
--   <a>deriveGeneric</a> from module <a>Generics.SOP.TH</a> to have the
--   instance generated for you. The pattern looks as follows:
--   
--   <pre>
--   import <a>Generics.SOP</a>
--   import <a>Generics.SOP.TH</a>
--   
--   ...
--   
--   data T = ...
--   
--   <a>deriveGeneric</a> ''T -- derives <a>HasDatatypeInfo</a> as well
--   </pre>
--   
--   <i>Tradeoffs:</i> Whether to use Option 1 or 2 is mainly a matter of
--   personal taste. The version based on Template Haskell probably has
--   less run-time overhead.
--   
--   <i>Non-standard instances:</i> It is possible to give <a>Generic</a>
--   instances manually that deviate from the standard scheme, as long as
--   at least
--   
--   <pre>
--   <a>to</a> <a>.</a> <a>from</a> === <a>id</a> :: a -&gt; a
--   </pre>
--   
--   still holds.
class (All SListI (Code a)) => Generic (a :: Type) where {
    
    -- | The code of a datatype.
    --   
    --   This is a list of lists of its components. The outer list contains one
    --   element per constructor. The inner list contains one element per
    --   constructor argument (field).
    --   
    --   <i>Example:</i> The datatype
    --   
    --   <pre>
    --   data Tree = Leaf Int | Node Tree Tree
    --   </pre>
    --   
    --   is supposed to have the following code:
    --   
    --   <pre>
    --   type instance Code (Tree a) =
    --     '[ '[ Int ]
    --      , '[ Tree, Tree ]
    --      ]
    --   </pre>
    type family Code a :: [[Type]];
    type Code a = GCode a;
}

-- | Converts from a value to its structural representation.
from :: Generic a => a -> Rep a

-- | Converts from a value to its structural representation.
from :: (Generic a, GFrom a, Generic a, Rep a ~ SOP I (GCode a)) => a -> Rep a

-- | Converts from a structural representation back to the original value.
to :: Generic a => Rep a -> a

-- | Converts from a structural representation back to the original value.
to :: (Generic a, GTo a, Generic a, Rep a ~ SOP I (GCode a)) => Rep a -> a

-- | The (generic) representation of a datatype.
--   
--   A datatype is isomorphic to the sum-of-products of its code. The
--   isomorphism is witnessed by <a>from</a> and <a>to</a> from the
--   <a>Generic</a> class.
type Rep a = SOP I (Code a)

-- | Constraint that captures that a datatype is a product type, i.e., a
--   type with a single constructor.
--   
--   It also gives access to the code for the arguments of that
--   constructor.
type IsProductType (a :: Type) (xs :: [Type]) = (Generic a, Code a ~ '[xs])

-- | Constraint that captures that a datatype is an enumeration type, i.e.,
--   none of the constructors have any arguments.
type IsEnumType (a :: Type) = (Generic a, All ((~) '[]) (Code a))

-- | Constraint that captures that a datatype is a single-constructor,
--   single-field datatype. This always holds for newtype-defined types,
--   but it can also be true for data-defined types.
--   
--   The constraint also gives access to the type that is wrapped.
type IsWrappedType (a :: Type) (x :: Type) = (Generic a, Code a ~ '['[x]])

-- | Constraint that captures that a datatype is a newtype. This makes use
--   of the fact that newtypes are always coercible to the type they wrap,
--   whereas datatypes are not.
type IsNewtype (a :: Type) (x :: Type) = (IsWrappedType a x, Coercible a x)
data NP (a :: k -> Type) (b :: [k]) :: forall k. () => k -> Type -> [k] -> Type
[Nil] :: forall k (a :: k -> Type) (b :: [k]). () => NP a ([] :: [k])
[:*] :: forall k (a :: k -> Type) (b :: [k]) (x :: k) (xs :: [k]). () => a x -> NP a xs -> NP a (x : xs)
data NS (a :: k -> Type) (b :: [k]) :: forall k. () => k -> Type -> [k] -> Type
[Z] :: forall k (a :: k -> Type) (b :: [k]) (x :: k) (xs :: [k]). () => a x -> NS a (x : xs)
[S] :: forall k (a :: k -> Type) (b :: [k]) (xs :: [k]) (x :: k). () => NS a xs -> NS a (x : xs)
newtype SOP (f :: k -> Type) (xss :: [[k]]) :: forall k. () => k -> Type -> [[k]] -> Type
SOP :: NS (NP f) xss -> SOP
unSOP :: () => SOP f xss -> NS (NP f) xss
newtype POP (f :: k -> Type) (xss :: [[k]]) :: forall k. () => k -> Type -> [[k]] -> Type
POP :: NP (NP f) xss -> POP
unPOP :: () => POP f xss -> NP (NP f) xss

-- | Metadata for a datatype.
--   
--   A value of type <tt><a>DatatypeInfo</a> c</tt> contains the
--   information about a datatype that is not contained in
--   <tt><tt>Code</tt> c</tt>. This information consists primarily of the
--   names of the datatype, its constructors, and possibly its record
--   selectors.
--   
--   The constructor indicates whether the datatype has been declared using
--   <tt>newtype</tt> or not.
data DatatypeInfo :: [[Type]] -> Type
[ADT] :: ModuleName -> DatatypeName -> NP ConstructorInfo xss -> DatatypeInfo xss
[Newtype] :: ModuleName -> DatatypeName -> ConstructorInfo '[x] -> DatatypeInfo '['[x]]

-- | The module name where a datatype is defined.
moduleName :: DatatypeInfo xss -> ModuleName

-- | The name of a datatype (or newtype).
datatypeName :: DatatypeInfo xss -> DatatypeName

-- | The constructor info for a datatype (or newtype).
constructorInfo :: DatatypeInfo xss -> NP ConstructorInfo xss

-- | Metadata for a single constructors.
--   
--   This is indexed by the product structure of the constructor
--   components.
data ConstructorInfo :: [Type] -> Type
[Constructor] :: SListI xs => ConstructorName -> ConstructorInfo xs
[Infix] :: ConstructorName -> Associativity -> Fixity -> ConstructorInfo '[x, y]
[Record] :: SListI xs => ConstructorName -> NP FieldInfo xs -> ConstructorInfo xs

-- | The name of a constructor.
constructorName :: ConstructorInfo xs -> ConstructorName

-- | For records, this functor maps the component to its selector name.
data FieldInfo :: Type -> Type
[FieldInfo] :: FieldName -> FieldInfo a

-- | The name of a field.
fieldName :: FieldInfo a -> FieldName

-- | A class of datatypes that have associated metadata.
--   
--   It is possible to use the sum-of-products approach to generic
--   programming without metadata. If you need metadata in a function, an
--   additional constraint on this class is in order.
--   
--   You typically don't define instances of this class by hand, but rather
--   derive the class instance automatically. See the documentation of
--   <a>Generic</a> for the options.
class Generic a => HasDatatypeInfo a where {
    
    -- | Type-level datatype info
    type family DatatypeInfoOf a :: DatatypeInfo;
    type DatatypeInfoOf a = GDatatypeInfoOf a;
}

-- | Term-level datatype info; by default, the term-level datatype info is
--   produced from the type-level info.
datatypeInfo :: HasDatatypeInfo a => proxy a -> DatatypeInfo (Code a)

-- | Term-level datatype info; by default, the term-level datatype info is
--   produced from the type-level info.
datatypeInfo :: (HasDatatypeInfo a, GDatatypeInfo a, GCode a ~ Code a) => proxy a -> DatatypeInfo (Code a)

-- | The name of a datatype.
type DatatypeName = String

-- | The name of a module.
type ModuleName = String

-- | The name of a data constructor.
type ConstructorName = String

-- | The name of a field / record selector.
type FieldName = String

-- | Datatype to represent the associativity of a constructor
data Associativity
LeftAssociative :: Associativity
RightAssociative :: Associativity
NotAssociative :: Associativity

-- | The fixity of an infix constructor.
type Fixity = Int
class HPure (h :: k -> Type -> l -> Type)
hpure :: (HPure h, SListIN h xs) => (forall (a :: k). () => f a) -> h f xs
hcpure :: (HPure h, AllN h c xs) => proxy c -> (forall (a :: k). c a => f a) -> h f xs
hd :: () => NP f (x : xs) -> f x
tl :: () => NP f (x : xs) -> NP f xs
type Projection (f :: k -> Type) (xs :: [k]) = (K NP f xs :: k -> Type) -.-> f
projections :: SListI xs => NP (Projection f xs) xs
shiftProjection :: () => Projection f xs a2 -> Projection f (x : xs) a2
newtype (-.->) (f :: k -> Type) (g :: k -> Type) (a :: k) :: forall k. () => k -> Type -> k -> Type -> k -> Type
Fn :: (f a -> g a) -> (-.->)
[apFn] :: (-.->) -> f a -> g a
fn :: () => (f a -> f' a) -> (f -.-> f') a
fn_2 :: () => (f a -> f' a -> f'' a) -> (f -.-> (f' -.-> f'')) a
fn_3 :: () => (f a -> f' a -> f'' a -> f''' a) -> (f -.-> (f' -.-> (f'' -.-> f'''))) a
fn_4 :: () => (f a -> f' a -> f'' a -> f''' a -> f'''' a) -> (f -.-> (f' -.-> (f'' -.-> (f''' -.-> f'''')))) a
type family Prod (h :: k -> Type -> l -> Type) :: k -> Type -> l -> Type
class (Prod Prod h ~ Prod h, HPure Prod h) => HAp (h :: k -> Type -> l -> Type)
hap :: HAp h => Prod h (f -.-> g) xs -> h f xs -> h g xs
hliftA :: (SListIN (Prod h) xs, HAp h) => (forall (a :: k). () => f a -> f' a) -> h f xs -> h f' xs
hliftA2 :: (SListIN (Prod h) xs, HAp h, HAp (Prod h)) => (forall (a :: k). () => f a -> f' a -> f'' a) -> Prod h f xs -> h f' xs -> h f'' xs
hliftA3 :: (SListIN (Prod h) xs, HAp h, HAp (Prod h)) => (forall (a :: k). () => f a -> f' a -> f'' a -> f''' a) -> Prod h f xs -> Prod h f' xs -> h f'' xs -> h f''' xs
hcliftA :: (AllN (Prod h) c xs, HAp h) => proxy c -> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcliftA2 :: (AllN (Prod h) c xs, HAp h, HAp (Prod h)) => proxy c -> (forall (a :: k). c a => f a -> f' a -> f'' a) -> Prod h f xs -> h f' xs -> h f'' xs
hcliftA3 :: (AllN (Prod h) c xs, HAp h, HAp (Prod h)) => proxy c -> (forall (a :: k). c a => f a -> f' a -> f'' a -> f''' a) -> Prod h f xs -> Prod h f' xs -> h f'' xs -> h f''' xs
hmap :: (SListIN (Prod h) xs, HAp h) => (forall (a :: k). () => f a -> f' a) -> h f xs -> h f' xs
hzipWith :: (SListIN (Prod h) xs, HAp h, HAp (Prod h)) => (forall (a :: k). () => f a -> f' a -> f'' a) -> Prod h f xs -> h f' xs -> h f'' xs
hzipWith3 :: (SListIN (Prod h) xs, HAp h, HAp (Prod h)) => (forall (a :: k). () => f a -> f' a -> f'' a -> f''' a) -> Prod h f xs -> Prod h f' xs -> h f'' xs -> h f''' xs
hcmap :: (AllN (Prod h) c xs, HAp h) => proxy c -> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hczipWith :: (AllN (Prod h) c xs, HAp h, HAp (Prod h)) => proxy c -> (forall (a :: k). c a => f a -> f' a -> f'' a) -> Prod h f xs -> h f' xs -> h f'' xs
hczipWith3 :: (AllN (Prod h) c xs, HAp h, HAp (Prod h)) => proxy c -> (forall (a :: k). c a => f a -> f' a -> f'' a -> f''' a) -> Prod h f xs -> Prod h f' xs -> h f'' xs -> h f''' xs
type Injection (f :: k -> Type) (xs :: [k]) = f -.-> (K NS f xs :: k -> Type)
injections :: SListI xs => NP (Injection f xs) xs
shift :: () => Injection f xs a2 -> Injection f (x : xs) a2
shiftInjection :: () => Injection f xs a2 -> Injection f (x : xs) a2
type family UnProd (h :: k -> Type -> l -> Type) :: k -> Type -> l -> Type
class UnProd Prod h ~ h => HApInjs (h :: k -> Type -> l -> Type)
hapInjs :: (HApInjs h, SListIN h xs) => Prod h f xs -> [h f xs]
apInjs_NP :: SListI xs => NP f xs -> [NS f xs]
apInjs_POP :: SListI xss => POP f xss -> [SOP f xss]
unZ :: () => NS f (x : ([] :: [k])) -> f x
class HIndex (h :: k -> Type -> l -> Type)
hindex :: HIndex h => h f xs -> Int
hcliftA' :: (All2 c xss, Prod h ~ (NP :: ([k] -> Type) -> [[k]] -> Type), HAp h) => proxy c -> (forall (xs :: [k]). All c xs => f xs -> f' xs) -> h f xss -> h f' xss
hcliftA2' :: (All2 c xss, Prod h ~ (NP :: ([k] -> Type) -> [[k]] -> Type), HAp h) => proxy c -> (forall (xs :: [k]). All c xs => f xs -> f' xs -> f'' xs) -> Prod h f xss -> h f' xss -> h f'' xss
hcliftA3' :: (All2 c xss, Prod h ~ (NP :: ([k] -> Type) -> [[k]] -> Type), HAp h) => proxy c -> (forall (xs :: [k]). All c xs => f xs -> f' xs -> f'' xs -> f''' xs) -> Prod h f xss -> Prod h f' xss -> h f'' xss -> h f''' xss
compare_NS :: () => r -> (forall (x :: k). () => f x -> g x -> r) -> r -> NS f xs -> NS g xs -> r
ccompare_NS :: All c xs => proxy c -> r -> (forall (x :: k). c x => f x -> g x -> r) -> r -> NS f xs -> NS g xs -> r
compare_SOP :: () => r -> (forall (xs :: [k]). () => NP f xs -> NP g xs -> r) -> r -> SOP f xss -> SOP g xss -> r
ccompare_SOP :: All2 c xss => proxy c -> r -> (forall (xs :: [k]). All c xs => NP f xs -> NP g xs -> r) -> r -> SOP f xss -> SOP g xss -> r
type family CollapseTo (h :: k -> Type -> l -> Type) x :: Type
class HCollapse (h :: k -> Type -> l -> Type)
hcollapse :: (HCollapse h, SListIN h xs) => h (K a :: k -> Type) xs -> CollapseTo h a
class HTraverse_ (h :: k -> Type -> l -> Type)
hctraverse_ :: (HTraverse_ h, AllN h c xs, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g ()) -> h f xs -> g ()
htraverse_ :: (HTraverse_ h, SListIN h xs, Applicative g) => (forall (a :: k). () => f a -> g ()) -> h f xs -> g ()
hcfoldMap :: (HTraverse_ h, AllN h c xs, Monoid m) => proxy c -> (forall (a :: k). c a => f a -> m) -> h f xs -> m
hcfor_ :: (HTraverse_ h, AllN h c xs, Applicative g) => proxy c -> h f xs -> (forall (a :: k). c a => f a -> g ()) -> g ()
class HAp h => HSequence (h :: k -> Type -> l -> Type)
hsequence' :: (HSequence h, SListIN h xs, Applicative f) => h (f :.: g) xs -> f (h g xs)
hctraverse' :: (HSequence h, AllN h c xs, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g (f' a)) -> h f xs -> g (h f' xs)
htraverse' :: (HSequence h, SListIN h xs, Applicative g) => (forall (a :: k). () => f a -> g (f' a)) -> h f xs -> g (h f' xs)
hsequence :: (SListIN h xs, SListIN (Prod h) xs, HSequence h, Applicative f) => h f xs -> f (h I xs)
hsequenceK :: (SListIN h xs, SListIN (Prod h) xs, Applicative f, HSequence h) => h (K (f a) :: k -> Type) xs -> f (h (K a :: k -> Type) xs)
hctraverse :: (HSequence h, AllN h c xs, Applicative g) => proxy c -> (forall a. c a => f a -> g a) -> h f xs -> g (h I xs)
hcfor :: (HSequence h, AllN h c xs, Applicative g) => proxy c -> h f xs -> (forall a. c a => f a -> g a) -> g (h I xs)
class HExpand (h :: k -> Type -> l -> Type)
hexpand :: (HExpand h, SListIN (Prod h) xs) => (forall (x :: k). () => f x) -> h f xs -> Prod h f xs
hcexpand :: (HExpand h, AllN (Prod h) c xs) => proxy c -> (forall (x :: k). c x => f x) -> h f xs -> Prod h f xs
class ((Same h1 :: k2 -> Type -> l2 -> Type) ~ h2, (Same h2 :: k1 -> Type -> l1 -> Type) ~ h1) => HTrans (h1 :: k1 -> Type -> l1 -> Type) (h2 :: k2 -> Type -> l2 -> Type)
htrans :: (HTrans h1 h2, AllZipN (Prod h1) c xs ys) => proxy c -> (forall (x :: k1) (y :: k2). c x y => f x -> g y) -> h1 f xs -> h2 g ys
hcoerce :: (HTrans h1 h2, AllZipN (Prod h1) (LiftedCoercible f g) xs ys, HTrans h1 h2) => h1 f xs -> h2 g ys
hfromI :: (AllZipN (Prod h1) (LiftedCoercible I f) xs ys, HTrans h1 h2) => h1 I xs -> h2 f ys
htoI :: (AllZipN (Prod h1) (LiftedCoercible f I) xs ys, HTrans h1 h2) => h1 f xs -> h2 I ys
fromList :: SListI xs => [a] -> Maybe (NP (K a :: k -> Type) xs)
newtype K a (b :: k) :: forall k. () => Type -> k -> Type
K :: a -> K a
unK :: () => K a b -> a
newtype I a
I :: a -> I a
unI :: () => I a -> a
newtype (:.:) (f :: l -> Type) (g :: k -> l) (p :: k) :: forall l k. () => l -> Type -> k -> l -> k -> Type
Comp :: f (g p) -> (:.:)
unComp :: () => (f :.: g) p -> f (g p)
mapII :: () => (a -> b) -> I a -> I b
mapIK :: () => (a -> b) -> I a -> K b c
mapKI :: () => (a -> b) -> K a c -> I b
mapKK :: () => (a -> b) -> K a c -> K b d
mapIII :: () => (a -> b -> c) -> I a -> I b -> I c
mapIIK :: () => (a -> b -> c) -> I a -> I b -> K c d
mapIKI :: () => (a -> b -> c) -> I a -> K b d -> I c
mapIKK :: () => (a -> b -> c) -> I a -> K b d -> K c e
mapKII :: () => (a -> b -> c) -> K a d -> I b -> I c
mapKIK :: () => (a -> b -> c) -> K a d -> I b -> K c e
mapKKI :: () => (a -> b -> c) -> K a d -> K b e -> I c
mapKKK :: () => (a -> b -> c) -> K a d -> K b e -> K c f
class (AllF c xs, SListI xs) => All (c :: k -> Constraint) (xs :: [k])
type All2 (c :: k -> Constraint) = All All c
cpara_SList :: All c xs => proxy c -> r ([] :: [k]) -> (forall (y :: k) (ys :: [k]). (c y, All c ys) => r ys -> r (y : ys)) -> r xs
ccase_SList :: All c xs => proxy c -> r ([] :: [k]) -> (forall (y :: k) (ys :: [k]). (c y, All c ys) => r (y : ys)) -> r xs
class (SListI xs, SListI ys, SameShapeAs xs ys, SameShapeAs ys xs, AllZipF c xs ys) => AllZip (c :: a -> b -> Constraint) (xs :: [a]) (ys :: [b])
class (AllZipF AllZip f xss yss, SListI xss, SListI yss, SameShapeAs xss yss, SameShapeAs yss xss) => AllZip2 (f :: a -> b -> Constraint) (xss :: [[a]]) (yss :: [[b]])
type family AllN (h :: k -> Type -> l -> Type) (c :: k -> Constraint) :: l -> Constraint
type family AllZipN (h :: k -> Type -> l -> Type) (c :: k1 -> k2 -> Constraint) :: l1 -> l2 -> Constraint
class f g x => Compose (f :: k -> Constraint) (g :: k1 -> k) (x :: k1)
class (f x, g x) => And (f :: k -> Constraint) (g :: k -> Constraint) (x :: k)
class Top (x :: k)
class Coercible f x g y => LiftedCoercible (f :: k -> k0) (g :: k1 -> k0) (x :: k) (y :: k1)
type family SameShapeAs (xs :: [a]) (ys :: [b]) :: Constraint
data SList (a :: [k]) :: forall k. () => [k] -> Type
[SNil] :: forall k (a :: [k]). () => SList ([] :: [k])
[SCons] :: forall k (a :: [k]) (xs :: [k]) (x :: k). SListI xs => SList (x : xs)
type SListI = All (Top :: k -> Constraint)
type SListI2 = All (SListI :: [k] -> Constraint)
sList :: SListI xs => SList xs
para_SList :: SListI xs => r ([] :: [k]) -> (forall (y :: k) (ys :: [k]). SListI ys => r ys -> r (y : ys)) -> r xs
case_SList :: SListI xs => r ([] :: [k]) -> (forall (y :: k) (ys :: [k]). SListI ys => r (y : ys)) -> r xs
data Shape (a :: [k]) :: forall k. () => [k] -> Type
[ShapeNil] :: forall k (a :: [k]). () => Shape ([] :: [k])
[ShapeCons] :: forall k (a :: [k]) (xs :: [k]) (x :: k). SListI xs => Shape xs -> Shape (x : xs)
shape :: SListI xs => Shape xs
lengthSList :: SListI xs => proxy xs -> Int

-- | <a>Proxy</a> is a type that holds no data, but has a phantom parameter
--   of arbitrary type (or even kind). Its use is to provide type
--   information, even though there is no value available of that type (or
--   it may be too costly to create one).
--   
--   Historically, <tt><a>Proxy</a> :: <a>Proxy</a> a</tt> is a safer
--   alternative to the <tt>'undefined :: a'</tt> idiom.
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy (Void, Int -&gt; Int)
--   Proxy
--   </pre>
--   
--   Proxy can even hold types of higher kinds,
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy Either
--   Proxy
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy Functor
--   Proxy
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy complicatedStructure
--   Proxy
--   </pre>
data Proxy (t :: k) :: forall k. () => k -> Type
Proxy :: Proxy
