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

-- | True Sums of Products
--   
--   Implementation of n-ary sums and n-ary products.
--   
--   The module Data.SOP is the main module of this library and
--   contains more detailed documentation.
--   
--   The main use case of this package is to serve as the core of
--   generics-sop.
--   
--   A detailed description of the ideas behind this library is provided by
--   the paper:
--   
--   
--   
- Edsko de Vries and Andres Löh. True Sums of Products.
--   Workshop on Generic Programming (WGP) 2014.
--   
@package sop-core
@version 0.5.0.2

-- | Basic functors.
--   
--   Definitions of the type-level equivalents of const, id,
--   and (.), and a definition of the lifted function space.
--   
--   These datatypes are generally useful, but in this library, they're
--   primarily used as parameters for the NP, NS,
--   POP, and SOP types.
--   
--   We define own variants of Const, Identity and
--   Compose for various reasons.
--   
--   
--   
- Const and Compose become kind polymorphic only in
--   base-4.9.0.0 (transformers-0.5.0.0).
--   
- Shorter names are convenient, and pattern synonyms aren't (yet)
--   powerful enough, particularly exhaustiveness check doesn't work
--   properly. See
--   https://ghc.haskell.org/trac/ghc/ticket/8779.
--   
module Data.SOP.BasicFunctors

-- | The constant type functor.
--   
--   Like Constant, but kind-polymorphic in its second argument and
--   with a shorter name.
newtype K a (b :: k)
K :: a -> K a (b :: k)

-- | Extract the contents of a K value.
unK :: forall {k} a (b :: k). K a b -> a

-- | The identity type functor.
--   
--   Like Identity, but with a shorter name.
newtype I a
I :: a -> I a

-- | Extract the contents of an I value.
unI :: I a -> a

-- | Composition of functors.
--   
--   Like Compose, but kind-polymorphic and with a shorter name.
newtype ( (f :: l -> Type) :.: (g :: k -> l) ) (p :: k)
Comp :: f (g p) -> (:.:) (f :: l -> Type) (g :: k -> l) (p :: k)
infixr 7 :.:

-- | Extract the contents of a Comp value.
unComp :: forall {l} {k} f (g :: k -> l) (p :: k). (f :.: g) p -> f (g p)

-- | Lift the given function.
mapII :: (a -> b) -> I a -> I b

-- | Lift the given function.
mapIK :: forall {k} a b (c :: k). (a -> b) -> I a -> K b c

-- | Lift the given function.
mapKI :: forall {k} a b (c :: k). (a -> b) -> K a c -> I b

-- | Lift the given function.
mapKK :: forall {k1} {k2} a b (c :: k1) (d :: k2). (a -> b) -> K a c -> K b d

-- | Lift the given function.
mapIII :: (a -> b -> c) -> I a -> I b -> I c

-- | Lift the given function.
mapIIK :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> I b -> K c d

-- | Lift the given function.
mapIKI :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> K b d -> I c

-- | Lift the given function.
mapIKK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> I a -> K b d -> K c e

-- | Lift the given function.
mapKII :: forall {k} a b c (d :: k). (a -> b -> c) -> K a d -> I b -> I c

-- | Lift the given function.
mapKIK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> I b -> K c e

-- | Lift the given function.
mapKKI :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> K b e -> I c

-- | Lift the given function.
mapKKK :: forall {k1} {k2} {k3} a b c (d :: k1) (e :: k2) (f :: k3). (a -> b -> c) -> K a d -> K b e -> K c f
instance (GHC.Internal.Base.Applicative f, GHC.Internal.Base.Applicative g) => GHC.Internal.Base.Applicative (f Data.SOP.BasicFunctors.:.: g)
instance GHC.Internal.Base.Applicative Data.SOP.BasicFunctors.I
instance GHC.Internal.Base.Monoid a => GHC.Internal.Base.Applicative (Data.SOP.BasicFunctors.K a)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (f Data.SOP.BasicFunctors.:.: g)
instance Data.Functor.Classes.Eq1 Data.SOP.BasicFunctors.I
instance GHC.Classes.Eq a => Data.Functor.Classes.Eq1 (Data.SOP.BasicFunctors.K a)
instance Data.Functor.Classes.Eq2 Data.SOP.BasicFunctors.K
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, GHC.Classes.Eq a) => GHC.Classes.Eq ((Data.SOP.BasicFunctors.:.:) f g a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.SOP.BasicFunctors.I a)
instance forall k a (b :: k). GHC.Classes.Eq a => GHC.Classes.Eq (Data.SOP.BasicFunctors.K a b)
instance (GHC.Internal.Data.Foldable.Foldable f, GHC.Internal.Data.Foldable.Foldable g) => GHC.Internal.Data.Foldable.Foldable (f Data.SOP.BasicFunctors.:.: g)
instance GHC.Internal.Data.Foldable.Foldable Data.SOP.BasicFunctors.I
instance GHC.Internal.Data.Foldable.Foldable (Data.SOP.BasicFunctors.K a)
instance (GHC.Internal.Base.Functor f, GHC.Internal.Base.Functor g) => GHC.Internal.Base.Functor (f Data.SOP.BasicFunctors.:.: g)
instance GHC.Internal.Base.Functor Data.SOP.BasicFunctors.I
instance GHC.Internal.Base.Functor (Data.SOP.BasicFunctors.K a)
instance forall l (f :: l -> *) k (g :: k -> l) (p :: k). GHC.Internal.Generics.Generic ((Data.SOP.BasicFunctors.:.:) f g p)
instance GHC.Internal.Generics.Generic (Data.SOP.BasicFunctors.I a)
instance forall a k (b :: k). GHC.Internal.Generics.Generic (Data.SOP.BasicFunctors.K a b)
instance GHC.Internal.Base.Monad Data.SOP.BasicFunctors.I
instance forall l k (f :: l -> *) (g :: k -> l) (x :: k). GHC.Internal.Base.Monoid (f (g x)) => GHC.Internal.Base.Monoid ((Data.SOP.BasicFunctors.:.:) f g x)
instance GHC.Internal.Base.Monoid a => GHC.Internal.Base.Monoid (Data.SOP.BasicFunctors.I a)
instance forall k a (b :: k). GHC.Internal.Base.Monoid a => GHC.Internal.Base.Monoid (Data.SOP.BasicFunctors.K a b)
instance (Control.DeepSeq.NFData1 f, Control.DeepSeq.NFData1 g) => Control.DeepSeq.NFData1 (f Data.SOP.BasicFunctors.:.: g)
instance Control.DeepSeq.NFData1 Data.SOP.BasicFunctors.I
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData1 (Data.SOP.BasicFunctors.K a)
instance Control.DeepSeq.NFData2 Data.SOP.BasicFunctors.K
instance forall l k (f :: l -> *) (g :: k -> l) (a :: k). Control.DeepSeq.NFData (f (g a)) => Control.DeepSeq.NFData ((Data.SOP.BasicFunctors.:.:) f g a)
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.SOP.BasicFunctors.I a)
instance forall k a (b :: k). Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.SOP.BasicFunctors.K a b)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (f Data.SOP.BasicFunctors.:.: g)
instance Data.Functor.Classes.Ord1 Data.SOP.BasicFunctors.I
instance GHC.Classes.Ord a => Data.Functor.Classes.Ord1 (Data.SOP.BasicFunctors.K a)
instance Data.Functor.Classes.Ord2 Data.SOP.BasicFunctors.K
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g, GHC.Classes.Ord a) => GHC.Classes.Ord ((Data.SOP.BasicFunctors.:.:) f g a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.SOP.BasicFunctors.I a)
instance forall k a (b :: k). GHC.Classes.Ord a => GHC.Classes.Ord (Data.SOP.BasicFunctors.K a b)
instance (Data.Functor.Classes.Read1 f, Data.Functor.Classes.Read1 g) => Data.Functor.Classes.Read1 (f Data.SOP.BasicFunctors.:.: g)
instance Data.Functor.Classes.Read1 Data.SOP.BasicFunctors.I
instance GHC.Internal.Read.Read a => Data.Functor.Classes.Read1 (Data.SOP.BasicFunctors.K a)
instance Data.Functor.Classes.Read2 Data.SOP.BasicFunctors.K
instance (Data.Functor.Classes.Read1 f, Data.Functor.Classes.Read1 g, GHC.Internal.Read.Read a) => GHC.Internal.Read.Read ((Data.SOP.BasicFunctors.:.:) f g a)
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.SOP.BasicFunctors.I a)
instance forall k a (b :: k). GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.SOP.BasicFunctors.K a b)
instance forall l k (f :: l -> *) (g :: k -> l) (x :: k). GHC.Internal.Base.Semigroup (f (g x)) => GHC.Internal.Base.Semigroup ((Data.SOP.BasicFunctors.:.:) f g x)
instance GHC.Internal.Base.Semigroup a => GHC.Internal.Base.Semigroup (Data.SOP.BasicFunctors.I a)
instance forall k a (b :: k). GHC.Internal.Base.Semigroup a => GHC.Internal.Base.Semigroup (Data.SOP.BasicFunctors.K a b)
instance (Data.Functor.Classes.Show1 f, Data.Functor.Classes.Show1 g) => Data.Functor.Classes.Show1 (f Data.SOP.BasicFunctors.:.: g)
instance Data.Functor.Classes.Show1 Data.SOP.BasicFunctors.I
instance GHC.Internal.Show.Show a => Data.Functor.Classes.Show1 (Data.SOP.BasicFunctors.K a)
instance Data.Functor.Classes.Show2 Data.SOP.BasicFunctors.K
instance (Data.Functor.Classes.Show1 f, Data.Functor.Classes.Show1 g, GHC.Internal.Show.Show a) => GHC.Internal.Show.Show ((Data.SOP.BasicFunctors.:.:) f g a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.SOP.BasicFunctors.I a)
instance forall k a (b :: k). GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.SOP.BasicFunctors.K a b)
instance (GHC.Internal.Data.Traversable.Traversable f, GHC.Internal.Data.Traversable.Traversable g) => GHC.Internal.Data.Traversable.Traversable (f Data.SOP.BasicFunctors.:.: g)
instance GHC.Internal.Data.Traversable.Traversable Data.SOP.BasicFunctors.I
instance GHC.Internal.Data.Traversable.Traversable (Data.SOP.BasicFunctors.K a)

-- | Constraints for indexed datatypes.
--   
--   This module contains code that helps to specify that all elements of
--   an indexed structure must satisfy a particular constraint.
module Data.SOP.Constraint

-- | Composition of constraints.
--   
--   Note that the result of the composition must be a constraint, and
--   therefore, in Compose f g, the kind of f is
--   k -> Constraint. The kind of g, however,
--   is l -> k and can thus be a normal type constructor.
--   
--   A typical use case is in connection with All on an NP or
--   an NS. For example, in order to denote that all elements on an
--   NP f xs satisfy Show, we can say All
--   (Compose Show f) xs.
class f g x => Compose (f :: k -> Constraint) (g :: k1 -> k) (x :: k1)
infixr 9 `Compose`

-- | Pairing of constraints.
class (f x, g x) => And (f :: k -> Constraint) (g :: k -> Constraint) (x :: k)
infixl 7 `And`

-- | Require a constraint for every element of a list.
--   
--   If you have a datatype that is indexed over a type-level list, then
--   you can use All to indicate that all elements of that
--   type-level list must satisfy a given constraint.
--   
--   Example: The constraint
--   
--   
--   All Eq '[ Int, Bool, Char ]
--   
--   
--   is equivalent to the constraint
--   
--   
--   (Eq Int, Eq Bool, Eq Char)
--   
--   
--   Example: A type signature such as
--   
--   
--   f :: All Eq xs => NP I xs -> ...
--   
--   
--   means that f can assume that all elements of the n-ary
--   product satisfy Eq.
--   
--   Note on superclasses: ghc cannot deduce superclasses from All
--   constraints. You might expect the following to compile
--   
--   
--   class (Eq a) => MyClass a
--   
--   foo :: (All Eq xs) => NP f xs -> z
--   foo = [..]
--   
--   bar :: (All MyClass xs) => NP f xs -> x
--   bar = foo
--   
--   
--   but it will fail with an error saying that it was unable to deduce the
--   class constraint AllF Eq xs (or similar) in the
--   definition of bar. In cases like this you can use Dict
--   from Data.SOP.Dict to prove conversions between constraints.
--   See this answer on SO for more details.
class (AllF c xs, SListI xs) => All (c :: k -> Constraint) (xs :: [k])

-- | Constrained paramorphism for a type-level list.
--   
--   The advantage of writing functions in terms of cpara_SList is
--   that they are then typically not recursive, and can be unfolded
--   statically if the type-level list is statically known.
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

-- | Require a constraint for every element of a list of lists.
--   
--   If you have a datatype that is indexed over a type-level list of
--   lists, then you can use All2 to indicate that all elements of
--   the inner lists must satisfy a given constraint.
--   
--   Example: The constraint
--   
--   
--   All2 Eq '[ '[ Int ], '[ Bool, Char ] ]
--   
--   
--   is equivalent to the constraint
--   
--   
--   (Eq Int, Eq Bool, Eq Char)
--   
--   
--   Example: A type signature such as
--   
--   
--   f :: All2 Eq xss => SOP I xs -> ...
--   
--   
--   means that f can assume that all elements of the sum of
--   product satisfy Eq.
--   
--   Since 0.4.0.0, this is merely a synonym for 'All (All c)'.
type All2 (c :: k -> Constraint) = All All c

-- | Constrained case distinction on a type-level list.
ccase_SList :: forall {a} c (xs :: [a]) proxy r. All c xs => proxy c -> r ('[] :: [a]) -> (forall (y :: a) (ys :: [a]). (c y, All c ys) => r (y ': ys)) -> r xs

-- | Require a constraint pointwise for every pair of elements from two
--   lists.
--   
--   Example: The constraint
--   
--   
--   AllZip (~) '[ Int, Bool, Char ] '[ a, b, c ]
--   
--   
--   is equivalent to the constraint
--   
--   
--   (Int ~ a, Bool ~ b, Char ~ c)
--   
class (SListI xs, SListI ys, SameShapeAs xs ys, SameShapeAs ys xs, AllZipF c xs ys) => AllZip (c :: a -> b -> Constraint) (xs :: [a]) (ys :: [b])

-- | Require a constraint pointwise for every pair of elements from two
--   lists of lists.
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]])

-- | A generalization of All and All2.
--   
--   The family AllN expands to All or All2 depending
--   on whether the argument is indexed by a list or a list of lists.
type family AllN (h :: k -> Type -> l -> Type) (c :: k -> Constraint) :: l -> Constraint

-- | A generalization of AllZip and AllZip2.
--   
--   The family AllZipN expands to AllZip or AllZip2
--   depending on whther the argument is indexed by a list or a list of
--   lists.
type family AllZipN (h :: k -> Type -> l -> Type) (c :: k1 -> k2 -> Constraint) :: l1 -> l2 -> Constraint

-- | A constraint that can always be satisfied.
class Top (x :: k)

-- | The constraint LiftedCoercible f g x y is equivalent
--   to Coercible (f x) (g y).
class Coercible f x g y => LiftedCoercible (f :: k -> k1) (g :: k2 -> k1) (x :: k) (y :: k2)

-- | Type family that forces a type-level list to be of the same shape as
--   the given type-level list.
--   
--   Since 0.5.0.0, this only tests the top-level structure of the list,
--   and is intended to be used in conjunction with a separate construct
--   (such as the AllZip, AllZipF combination to tie the
--   recursive knot). The reason is that making SameShapeAs directly
--   recursive leads to quadratic compile times.
--   
--   The main use of this constraint is to help type inference to learn
--   something about otherwise unknown type-level lists.
type family SameShapeAs (xs :: [a]) (ys :: [b])

-- | Implicit singleton list.
--   
--   A singleton list can be used to reveal the structure of a type-level
--   list argument that the function is quantified over.
--   
--   Since 0.4.0.0, this is now defined in terms of All. A singleton
--   list provides a witness for a type-level list where the elements need
--   not satisfy any additional constraints.
type SListI = All Top :: k -> Constraint

-- | Require a singleton for every inner list in a list of lists.
type SListI2 = All SListI :: [k] -> Constraint

-- | Type family used to implement All.
type family AllF (c :: k -> Constraint) (xs :: [k])

-- | Type family used to implement AllZip.
type family AllZipF (c :: a -> b -> Constraint) (xs :: [a]) (ys :: [b])

-- | Utility function to compute the head of a type-level list.
type family Head (xs :: [a]) :: a

-- | Utility function to compute the tail of a type-level list.
type family Tail (xs :: [a]) :: [a]

-- | A generalization of SListI.
--   
--   The family SListIN expands to SListI or SListI2
--   depending on whether the argument is indexed by a list or a list of
--   lists.
type family SListIN (h :: k -> Type -> l -> Type) :: l -> Constraint

-- | The kind of lifted constraints
type Constraint = CONSTRAINT LiftedRep
instance forall a b (f :: a -> b -> GHC.Types.Constraint) (xss :: [[a]]) (yss :: [[b]]). (Data.SOP.Constraint.AllZipF (Data.SOP.Constraint.AllZip f) xss yss, Data.SOP.Constraint.SListI xss, Data.SOP.Constraint.SListI yss, Data.SOP.Constraint.SameShapeAs xss yss, Data.SOP.Constraint.SameShapeAs yss xss) => Data.SOP.Constraint.AllZip2 f xss yss
instance forall a b (xs :: [a]) (ys :: [b]) (c :: a -> b -> GHC.Types.Constraint). (Data.SOP.Constraint.SListI xs, Data.SOP.Constraint.SListI ys, Data.SOP.Constraint.SameShapeAs xs ys, Data.SOP.Constraint.SameShapeAs ys xs, Data.SOP.Constraint.AllZipF c xs ys) => Data.SOP.Constraint.AllZip c xs ys
instance forall a (c :: a -> GHC.Types.Constraint) (x :: a) (xs :: [a]). (c x, Data.SOP.Constraint.All c xs) => Data.SOP.Constraint.All c (x : xs)
instance forall k (c :: k -> GHC.Types.Constraint). Data.SOP.Constraint.All c '[]
instance forall k (f :: k -> GHC.Types.Constraint) (x :: k) (g :: k -> GHC.Types.Constraint). (f x, g x) => Data.SOP.Constraint.And f g x
instance forall k1 k2 (f :: k1 -> GHC.Types.Constraint) (g :: k2 -> k1) (x :: k2). f (g x) => Data.SOP.Constraint.Compose f g x
instance forall k1 k2 k3 (f :: k1 -> k2) (x :: k1) (g :: k3 -> k2) (y :: k3). GHC.Types.Coercible (f x) (g y) => Data.SOP.Constraint.LiftedCoercible f g x y
instance forall k (x :: k). Data.SOP.Constraint.Top x

-- | Classes for generalized combinators on SOP types.
--   
--   In the SOP approach to generic programming, we're predominantly
--   concerned with four structured datatypes:
--   
--   
--   NP  :: (k -> Type) -> ( [k]  -> Type)   -- n-ary product
--   NS  :: (k -> Type) -> ( [k]  -> Type)   -- n-ary sum
--   POP :: (k -> Type) -> ([[k]] -> Type)   -- product of products
--   SOP :: (k -> Type) -> ([[k]] -> Type)   -- sum of products
--   
--   
--   All of these have a kind that fits the following pattern:
--   
--   
--   (k -> Type) -> (l -> Type)
--   
--   
--   These four types support similar interfaces. In order to allow reusing
--   the same combinator names for all of these types, we define various
--   classes in this module that allow the necessary generalization.
--   
--   The classes typically lift concepts that exist for kinds
--   Type or Type -> Type to
--   datatypes of kind (k -> Type) -> (l ->
--   Type). This module also derives a number of derived
--   combinators.
--   
--   The actual instances are defined in Data.SOP.NP and
--   Data.SOP.NS.
module Data.SOP.Classes

-- | A generalization of pure or return to higher kinds.
class HPure (h :: k -> Type -> l -> Type)

-- | Corresponds to pure directly.
--   
--   Instances:
--   
--   
--   hpure, pure_NP  :: SListI  xs  => (forall a. f a) -> NP  f xs
--   hpure, pure_POP :: SListI2 xss => (forall a. f a) -> POP f xss
--   
hpure :: forall (xs :: l) f. (HPure h, SListIN h xs) => (forall (a :: k). () => f a) -> h f xs

-- | A variant of hpure that allows passing in a constrained
--   argument.
--   
--   Calling hcpure f s where s :: h f xs causes
--   f to be applied at all the types that are contained in
--   xs. Therefore, the constraint c has to be satisfied
--   for all elements of xs, which is what AllN h c
--   xs states.
--   
--   Instances:
--   
--   
--   hcpure, cpure_NP  :: (All  c xs ) => proxy c -> (forall a. c a => f a) -> NP  f xs
--   hcpure, cpure_POP :: (All2 c xss) => proxy c -> (forall a. c a => f a) -> POP f xss
--   
hcpure :: forall c (xs :: l) proxy f. (HPure h, AllN h c xs) => proxy c -> (forall (a :: k). c a => f a) -> h f xs

-- | Lifted functions.
newtype ( (f :: k -> Type) -.-> (g :: k -> Type) ) (a :: k)
Fn :: (f a -> g a) -> (-.->) (f :: k -> Type) (g :: k -> Type) (a :: k)
[apFn] :: (-.->) (f :: k -> Type) (g :: k -> Type) (a :: k) -> f a -> g a
infixr 1 -.->

-- | Construct a lifted function.
--   
--   Same as Fn. Only available for uniformity with the higher-arity
--   versions.
fn :: forall {k} f (a :: k) f'. (f a -> f' a) -> (f -.-> f') a

-- | Construct a binary lifted function.
fn_2 :: forall {k} f (a :: k) f' f''. (f a -> f' a -> f'' a) -> (f -.-> (f' -.-> f'')) a

-- | Construct a ternary lifted function.
fn_3 :: forall {k} f (a :: k) f' f'' f'''. (f a -> f' a -> f'' a -> f''' a) -> (f -.-> (f' -.-> (f'' -.-> f'''))) a

-- | Construct a quarternary lifted function.
fn_4 :: forall {k} f (a :: k) f' f'' f''' f''''. (f a -> f' a -> f'' a -> f''' a -> f'''' a) -> (f -.-> (f' -.-> (f'' -.-> (f''' -.-> f'''')))) a

-- | Maps a structure to the same structure.
type family Same (h :: k1 -> Type -> l1 -> Type) :: k2 -> Type -> l2 -> Type

-- | Maps a structure containing sums to the corresponding product
--   structure.
type family Prod (h :: k -> Type -> l -> Type) :: k -> Type -> l -> Type

-- | A generalization of <*>.
class (Prod Prod h ~ Prod h, HPure Prod h) => HAp (h :: k -> Type -> l -> Type)

-- | Corresponds to <*>.
--   
--   For products (NP) as well as products of products (POP),
--   the correspondence is rather direct. We combine a structure containing
--   (lifted) functions and a compatible structure containing corresponding
--   arguments into a compatible structure containing results.
--   
--   The same combinator can also be used to combine a product structure of
--   functions with a sum structure of arguments, which then results in
--   another sum structure of results. The sum structure determines which
--   part of the product structure will be used.
--   
--   Instances:
--   
--   
--   hap, ap_NP  :: NP  (f -.-> g) xs  -> NP  f xs  -> NP  g xs
--   hap, ap_NS  :: NP  (f -.-> g) xs  -> NS  f xs  -> NS  g xs
--   hap, ap_POP :: POP (f -.-> g) xss -> POP f xss -> POP g xss
--   hap, ap_SOP :: POP (f -.-> g) xss -> SOP f xss -> SOP g xss
--   
hap :: forall (f :: k -> Type) (g :: k -> Type) (xs :: l). HAp h => Prod h (f -.-> g) xs -> h f xs -> h g xs

-- | A generalized form of liftA, which in turn is a generalized
--   map.
--   
--   Takes a lifted function and applies it to every element of a structure
--   while preserving its shape.
--   
--   Specification:
--   
--   
--   hliftA f xs = hpure (fn f) ` <a>hap</a> ` xs
--   
--   
--   Instances:
--   
--   
--   hliftA, liftA_NP  :: SListI  xs  => (forall a. f a -> f' a) -> NP  f xs  -> NP  f' xs
--   hliftA, liftA_NS  :: SListI  xs  => (forall a. f a -> f' a) -> NS  f xs  -> NS  f' xs
--   hliftA, liftA_POP :: SListI2 xss => (forall a. f a -> f' a) -> POP f xss -> POP f' xss
--   hliftA, liftA_SOP :: SListI2 xss => (forall a. f a -> f' a) -> SOP f xss -> SOP f' xss
--   
hliftA :: forall {k} {l} h (xs :: l) f f'. (SListIN (Prod h) xs, HAp h) => (forall (a :: k). () => f a -> f' a) -> h f xs -> h f' xs

-- | A generalized form of liftA2, which in turn is a generalized
--   zipWith.
--   
--   Takes a lifted binary function and uses it to combine two structures
--   of equal shape into a single structure.
--   
--   It either takes two product structures to a product structure, or one
--   product and one sum structure to a sum structure.
--   
--   Specification:
--   
--   
--   hliftA2 f xs ys = hpure (fn_2 f) ` <a>hap</a> ` xs ` <a>hap</a> ` ys
--   
--   
--   Instances:
--   
--   
--   hliftA2, liftA2_NP  :: SListI  xs  => (forall a. f a -> f' a -> f'' a) -> NP  f xs  -> NP  f' xs  -> NP  f'' xs
--   hliftA2, liftA2_NS  :: SListI  xs  => (forall a. f a -> f' a -> f'' a) -> NP  f xs  -> NS  f' xs  -> NS  f'' xs
--   hliftA2, liftA2_POP :: SListI2 xss => (forall a. f a -> f' a -> f'' a) -> POP f xss -> POP f' xss -> POP f'' xss
--   hliftA2, liftA2_SOP :: SListI2 xss => (forall a. f a -> f' a -> f'' a) -> POP f xss -> SOP f' xss -> SOP f'' xss
--   
hliftA2 :: forall {k} {l} h (xs :: l) f f' f''. (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

-- | A generalized form of liftA3, which in turn is a generalized
--   zipWith3.
--   
--   Takes a lifted ternary function and uses it to combine three
--   structures of equal shape into a single structure.
--   
--   It either takes three product structures to a product structure, or
--   two product structures and one sum structure to a sum structure.
--   
--   Specification:
--   
--   
--   hliftA3 f xs ys zs = hpure (fn_3 f) ` <a>hap</a> ` xs ` <a>hap</a> ` ys ` <a>hap</a> ` zs
--   
--   
--   Instances:
--   
--   
--   hliftA3, liftA3_NP  :: SListI  xs  => (forall a. f a -> f' a -> f'' a -> f''' a) -> NP  f xs  -> NP  f' xs  -> NP  f'' xs  -> NP  f''' xs
--   hliftA3, liftA3_NS  :: SListI  xs  => (forall a. f a -> f' a -> f'' a -> f''' a) -> NP  f xs  -> NP  f' xs  -> NS  f'' xs  -> NS  f''' xs
--   hliftA3, liftA3_POP :: SListI2 xss => (forall a. f a -> f' a -> f'' a -> f''' a) -> POP f xss -> POP f' xss -> POP f'' xss -> POP f''' xs
--   hliftA3, liftA3_SOP :: SListI2 xss => (forall a. f a -> f' a -> f'' a -> f''' a) -> POP f xss -> POP f' xss -> SOP f'' xss -> SOP f''' xs
--   
hliftA3 :: forall {k} {l} h (xs :: l) f f' f'' f'''. (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

-- | Another name for hliftA.
hmap :: forall {k} {l} h (xs :: l) f f'. (SListIN (Prod h) xs, HAp h) => (forall (a :: k). () => f a -> f' a) -> h f xs -> h f' xs

-- | Another name for hliftA2.
hzipWith :: forall {k} {l} h (xs :: l) f f' f''. (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

-- | Another name for hliftA3.
hzipWith3 :: forall {k} {l} h (xs :: l) f f' f'' f'''. (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

-- | Variant of hliftA that takes a constrained function.
--   
--   Specification:
--   
--   
--   hcliftA p f xs = hcpure p (fn f) ` <a>hap</a> ` xs
--   
hcliftA :: forall {k} {l} h c (xs :: l) proxy f f'. (AllN (Prod h) c xs, HAp h) => proxy c -> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs

-- | Variant of hliftA2 that takes a constrained function.
--   
--   Specification:
--   
--   
--   hcliftA2 p f xs ys = hcpure p (fn_2 f) ` <a>hap</a> ` xs ` <a>hap</a> ` ys
--   
hcliftA2 :: forall {k} {l} h c (xs :: l) proxy f f' f''. (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

-- | Variant of hliftA3 that takes a constrained function.
--   
--   Specification:
--   
--   
--   hcliftA3 p f xs ys zs = hcpure p (fn_3 f) ` <a>hap</a> ` xs ` <a>hap</a> ` ys ` <a>hap</a> ` zs
--   
hcliftA3 :: forall {k} {l} h c (xs :: l) proxy f f' f'' f'''. (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

-- | Another name for hcliftA.
hcmap :: forall {k} {l} h c (xs :: l) proxy f f'. (AllN (Prod h) c xs, HAp h) => proxy c -> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs

-- | Another name for hcliftA2.
hczipWith :: forall {k} {l} h c (xs :: l) proxy f f' f''. (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

-- | Another name for hcliftA3.
hczipWith3 :: forall {k} {l} h c (xs :: l) proxy f f' f'' f'''. (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

-- | Maps products to lists, and sums to identities.
type family CollapseTo (h :: k -> Type -> l -> Type) x

-- | A class for collapsing a heterogeneous structure into a homogeneous
--   one.
class HCollapse (h :: k -> Type -> l -> Type)

-- | Collapse a heterogeneous structure with homogeneous elements into a
--   homogeneous structure.
--   
--   If a heterogeneous structure is instantiated to the constant functor
--   K, then it is in fact homogeneous. This function maps such a
--   value to a simpler Haskell datatype reflecting that. An NS
--   (K a) contains a single a, and an NP
--   (K a) contains a list of as.
--   
--   Instances:
--   
--   
--   hcollapse, collapse_NP  :: NP  (K a) xs  ->  [a]
--   hcollapse, collapse_NS  :: NS  (K a) xs  ->   a
--   hcollapse, collapse_POP :: POP (K a) xss -> [[a]]
--   hcollapse, collapse_SOP :: SOP (K a) xss ->  [a]
--   
hcollapse :: forall (xs :: l) a. (HCollapse h, SListIN h xs) => h (K a :: k -> Type) xs -> CollapseTo h a

-- | A generalization of traverse_ or foldMap.
class HTraverse_ (h :: k -> Type -> l -> Type)

-- | Corresponds to traverse_.
--   
--   Instances:
--   
--   
--   hctraverse_, ctraverse__NP  :: (All  c xs , Applicative g) => proxy c -> (forall a. c a => f a -> g ()) -> NP  f xs  -> g ()
--   hctraverse_, ctraverse__NS  :: (All2 c xs , Applicative g) => proxy c -> (forall a. c a => f a -> g ()) -> NS  f xs  -> g ()
--   hctraverse_, ctraverse__POP :: (All  c xss, Applicative g) => proxy c -> (forall a. c a => f a -> g ()) -> POP f xss -> g ()
--   hctraverse_, ctraverse__SOP :: (All2 c xss, Applicative g) => proxy c -> (forall a. c a => f a -> g ()) -> SOP f xss -> g ()
--   
hctraverse_ :: forall c (xs :: l) g proxy f. (HTraverse_ h, AllN h c xs, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g ()) -> h f xs -> g ()

-- | Unconstrained version of hctraverse_.
--   
--   Instances:
--   
--   
--   traverse_, traverse__NP  :: (SListI  xs , Applicative g) => (forall a. f a -> g ()) -> NP  f xs  -> g ()
--   traverse_, traverse__NS  :: (SListI  xs , Applicative g) => (forall a. f a -> g ()) -> NS  f xs  -> g ()
--   traverse_, traverse__POP :: (SListI2 xss, Applicative g) => (forall a. f a -> g ()) -> POP f xss -> g ()
--   traverse_, traverse__SOP :: (SListI2 xss, Applicative g) => (forall a. f a -> g ()) -> SOP f xss -> g ()
--   
htraverse_ :: forall (xs :: l) g f. (HTraverse_ h, SListIN h xs, Applicative g) => (forall (a :: k). () => f a -> g ()) -> h f xs -> g ()

-- | A generalization of sequenceA.
class HAp h => HSequence (h :: k -> Type -> l -> Type)

-- | Corresponds to sequenceA.
--   
--   Lifts an applicative functor out of a structure.
--   
--   Instances:
--   
--   
--   hsequence', sequence'_NP  :: (SListI  xs , Applicative f) => NP  (f :.: g) xs  -> f (NP  g xs )
--   hsequence', sequence'_NS  :: (SListI  xs , Applicative f) => NS  (f :.: g) xs  -> f (NS  g xs )
--   hsequence', sequence'_POP :: (SListI2 xss, Applicative f) => POP (f :.: g) xss -> f (POP g xss)
--   hsequence', sequence'_SOP :: (SListI2 xss, Applicative f) => SOP (f :.: g) xss -> f (SOP g xss)
--   
hsequence' :: forall (xs :: l) f (g :: k -> Type). (HSequence h, SListIN h xs, Applicative f) => h (f :.: g) xs -> f (h g xs)

-- | Corresponds to traverse.
--   
--   Instances:
--   
--   
--   hctraverse', ctraverse'_NP  :: (All  c xs , Applicative g) => proxy c -> (forall a. c a => f a -> g (f' a)) -> NP  f xs  -> g (NP  f' xs )
--   hctraverse', ctraverse'_NS  :: (All2 c xs , Applicative g) => proxy c -> (forall a. c a => f a -> g (f' a)) -> NS  f xs  -> g (NS  f' xs )
--   hctraverse', ctraverse'_POP :: (All  c xss, Applicative g) => proxy c -> (forall a. c a => f a -> g (f' a)) -> POP f xss -> g (POP f' xss)
--   hctraverse', ctraverse'_SOP :: (All2 c xss, Applicative g) => proxy c -> (forall a. c a => f a -> g (f' a)) -> SOP f xss -> g (SOP f' xss)
--   
hctraverse' :: forall c (xs :: l) g proxy f f'. (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)

-- | Unconstrained variant of hctraverse'.
--   
--   Instances:
--   
--   
--   htraverse', traverse'_NP  :: (SListI  xs , Applicative g) => (forall a. c a => f a -> g (f' a)) -> NP  f xs  -> g (NP  f' xs )
--   htraverse', traverse'_NS  :: (SListI2 xs , Applicative g) => (forall a. c a => f a -> g (f' a)) -> NS  f xs  -> g (NS  f' xs )
--   htraverse', traverse'_POP :: (SListI  xss, Applicative g) => (forall a. c a => f a -> g (f' a)) -> POP f xss -> g (POP f' xss)
--   htraverse', traverse'_SOP :: (SListI2 xss, Applicative g) => (forall a. c a => f a -> g (f' a)) -> SOP f xss -> g (SOP f' xss)
--   
htraverse' :: forall (xs :: l) g f f'. (HSequence h, SListIN h xs, Applicative g) => (forall (a :: k). () => f a -> g (f' a)) -> h f xs -> g (h f' xs)

-- | Special case of hctraverse_.
hcfoldMap :: forall {k} {l} h c (xs :: l) m proxy f. (HTraverse_ h, AllN h c xs, Monoid m) => proxy c -> (forall (a :: k). c a => f a -> m) -> h f xs -> m

-- | Flipped version of hctraverse_.
hcfor_ :: forall {k} {l} h c (xs :: l) g proxy f. (HTraverse_ h, AllN h c xs, Applicative g) => proxy c -> h f xs -> (forall (a :: k). c a => f a -> g ()) -> g ()

-- | Special case of hsequence' where g = I.
hsequence :: forall {l} h (xs :: l) f. (SListIN h xs, SListIN (Prod h) xs, HSequence h, Applicative f) => h f xs -> f (h I xs)

-- | Special case of hsequence' where g = K a.
hsequenceK :: forall {k} {l} h (xs :: l) f a. (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)

-- | Special case of hctraverse' where f' = I.
hctraverse :: forall {l} h c (xs :: l) g proxy f. (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)

-- | Flipped version of hctraverse.
hcfor :: forall {l} h c (xs :: l) g proxy f. (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)

-- | A class for determining which choice in a sum-like structure a value
--   represents.
class HIndex (h :: k -> Type -> l -> Type)

-- | If h is a sum-like structure representing a choice between
--   n different options, and x is a value of type h
--   f xs, then hindex x returns a number between
--   0 and n - 1 representing the index of the choice
--   made by x.
--   
--   Instances:
--   
--   
--   hindex, index_NS  :: NS  f xs -> Int
--   hindex, index_SOP :: SOP f xs -> Int
--   
--   
--   Examples:
--   
--   
--   >>> hindex (S (S (Z (I False))))
--   2
--   
--   >>> hindex (Z (K ()))
--   0
--   
--   >>> hindex (SOP (S (Z (I True :* I 'x' :* Nil))))
--   1
--   
hindex :: forall (f :: k -> Type) (xs :: l). HIndex h => h f xs -> Int

-- | Maps a structure containing products to the corresponding sum
--   structure.
type family UnProd (h :: k -> Type -> l -> Type) :: k -> Type -> l -> Type

-- | A class for applying all injections corresponding to a sum-like
--   structure to a table containing suitable arguments.
class UnProd Prod h ~ h => HApInjs (h :: k -> Type -> l -> Type)

-- | For a given table (product-like structure), produce a list where each
--   element corresponds to the application of an injection function into
--   the corresponding sum-like structure.
--   
--   Instances:
--   
--   
--   hapInjs, apInjs_NP  :: SListI  xs  => NP  f xs -> [NS  f xs ]
--   hapInjs, apInjs_SOP :: SListI2 xss => POP f xs -> [SOP f xss]
--   
--   
--   Examples:
--   
--   
--   >>> hapInjs (I 'x' :* I True :* I 2 :* Nil) :: [NS I '[Char, Bool, Int]]
--   [Z (I 'x'),S (Z (I True)),S (S (Z (I 2)))]
--   
--   
--   
--   >>> hapInjs (POP ((I 'x' :* Nil) :* (I True :* I 2 :* Nil) :* Nil)) :: [SOP I '[ '[Char], '[Bool, Int]]]
--   [SOP (Z (I 'x' :* Nil)),SOP (S (Z (I True :* I 2 :* Nil)))]
--   
--   
--   Unfortunately the type-signatures are required in GHC-7.10 and older.
hapInjs :: forall (xs :: l) (f :: k -> Type). (HApInjs h, SListIN h xs) => Prod h f xs -> [h f xs]

-- | A class for expanding sum structures into corresponding product
--   structures, filling in the slots not targeted by the sum with default
--   values.
class HExpand (h :: k -> Type -> l -> Type)

-- | Expand a given sum structure into a corresponding product structure by
--   placing the value contained in the sum into the corresponding position
--   in the product, and using the given default value for all other
--   positions.
--   
--   Instances:
--   
--   
--   hexpand, expand_NS  :: SListI xs   => (forall x . f x) -> NS  f xs  -> NP  f xs
--   hexpand, expand_SOP :: SListI2 xss => (forall x . f x) -> SOP f xss -> POP f xss
--   
--   
--   Examples:
--   
--   
--   >>> hexpand Nothing (S (Z (Just 3))) :: NP Maybe '[Char, Int, Bool]
--   Nothing :* Just 3 :* Nothing :* Nil
--   
--   >>> hexpand [] (SOP (S (Z ([1,2] :* "xyz" :* Nil)))) :: POP [] '[ '[Bool], '[Int, Char] ]
--   POP (([] :* Nil) :* ([1,2] :* "xyz" :* Nil) :* Nil)
--   
hexpand :: forall (xs :: l) f. (HExpand h, SListIN (Prod h) xs) => (forall (x :: k). () => f x) -> h f xs -> Prod h f xs

-- | Variant of hexpand that allows passing a constrained default.
--   
--   Instances:
--   
--   
--   hcexpand, cexpand_NS  :: All  c xs  => proxy c -> (forall x . c x => f x) -> NS  f xs  -> NP  f xs
--   hcexpand, cexpand_SOP :: All2 c xss => proxy c -> (forall x . c x => f x) -> SOP f xss -> POP f xss
--   
--   
--   Examples:
--   
--   
--   >>> hcexpand (Proxy :: Proxy Bounded) (I minBound) (S (Z (I 20))) :: NP I '[Bool, Int, Ordering]
--   I False :* I 20 :* I LT :* Nil
--   
--   >>> hcexpand (Proxy :: Proxy Num) (I 0) (SOP (S (Z (I 1 :* I 2 :* Nil)))) :: POP I '[ '[Double], '[Int, Int] ]
--   POP ((I 0.0 :* Nil) :* (I 1 :* I 2 :* Nil) :* Nil)
--   
hcexpand :: forall c (xs :: l) proxy f. (HExpand h, AllN (Prod h) c xs) => proxy c -> (forall (x :: k). c x => f x) -> h f xs -> Prod h f xs

-- | A class for transforming structures into related structures with a
--   different index list, as long as the index lists have the same shape
--   and the elements and interpretation functions are suitably related.
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)

-- | Transform a structure into a related structure given a conversion
--   function for the elements.
htrans :: forall c (xs :: l1) (ys :: l2) proxy f g. (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

-- | Safely coerce a structure into a representationally equal structure.
--   
--   This is a special case of htrans, but can be implemented more
--   efficiently; for example in terms of unsafeCoerce.
--   
--   Examples:
--   
--   
--   >>> hcoerce (I (Just LT) :* I (Just 'x') :* I (Just True) :* Nil) :: NP Maybe '[Ordering, Char, Bool]
--   Just LT :* Just 'x' :* Just True :* Nil
--   
--   >>> hcoerce (SOP (Z (K True :* K False :* Nil))) :: SOP I '[ '[Bool, Bool], '[Bool] ]
--   SOP (Z (I True :* I False :* Nil))
--   
hcoerce :: forall (f :: k1 -> Type) (g :: k2 -> Type) (xs :: l1) (ys :: l2). (HTrans h1 h2, AllZipN (Prod h1) (LiftedCoercible f g) xs ys) => h1 f xs -> h2 g ys

-- | Specialization of hcoerce.
hfromI :: forall {l1} {k2} {l2} h1 (f :: k2 -> Type) (xs :: l1) (ys :: l2) h2. (AllZipN (Prod h1) (LiftedCoercible I f) xs ys, HTrans h1 h2) => h1 I xs -> h2 f ys

-- | Specialization of hcoerce.
htoI :: forall {k1} {l1} {l2} h1 (f :: k1 -> Type) (xs :: l1) (ys :: l2) h2. (AllZipN (Prod h1) (LiftedCoercible f I) xs ys, HTrans h1 h2) => h1 f xs -> h2 I ys

-- | Singleton types corresponding to type-level data structures.
--   
--   The implementation is similar, but subtly different to that of the
--   singletons package. See the "True Sums of
--   Products" paper for details.
module Data.SOP.Sing

-- | Explicit singleton list.
--   
--   A singleton list can be used to reveal the structure of a type-level
--   list argument that the function is quantified over. For every
--   type-level list xs, there is one non-bottom value of type
--   SList xs.
--   
--   Note that these singleton lists are polymorphic in the list elements;
--   we do not require a singleton representation for them.
data SList (a :: [k])
[SNil] :: forall {k}. SList ('[] :: [k])
[SCons] :: forall {k} (xs :: [k]) (x :: k). SListI xs => SList (x ': xs)

-- | Implicit singleton list.
--   
--   A singleton list can be used to reveal the structure of a type-level
--   list argument that the function is quantified over.
--   
--   Since 0.4.0.0, this is now defined in terms of All. A singleton
--   list provides a witness for a type-level list where the elements need
--   not satisfy any additional constraints.
type SListI = All Top :: k -> Constraint

-- | Get hold of an explicit singleton (that one can then pattern match on)
--   for a type-level list
sList :: forall {k} (xs :: [k]). SListI xs => SList xs

-- | Paramorphism for a type-level list.
para_SList :: forall {a} (xs :: [a]) r. SListI xs => r ('[] :: [a]) -> (forall (y :: a) (ys :: [a]). SListI ys => r ys -> r (y ': ys)) -> r xs

-- | Case distinction on a type-level list.
case_SList :: forall {a} (xs :: [a]) r. SListI xs => r ('[] :: [a]) -> (forall (y :: a) (ys :: [a]). SListI ys => r (y ': ys)) -> r xs

-- | Occasionally it is useful to have an explicit, term-level,
--   representation of type-level lists (esp because of
--   https://ghc.haskell.org/trac/ghc/ticket/9108 )
data Shape (a :: [k])
[ShapeNil] :: forall {k}. Shape ('[] :: [k])
[ShapeCons] :: forall {k} (xs :: [k]) (x :: k). SListI xs => Shape xs -> Shape (x ': xs)

-- | The shape of a type-level list.
shape :: forall k (xs :: [k]). SListI xs => Shape xs

-- | The length of a type-level list.
lengthSList :: forall k (xs :: [k]) proxy. SListI xs => proxy xs -> Int
instance forall k (xs :: [k]). GHC.Classes.Eq (Data.SOP.Sing.SList xs)
instance forall k (xs :: [k]). GHC.Classes.Eq (Data.SOP.Sing.Shape xs)
instance forall k (xs :: [k]). GHC.Classes.Ord (Data.SOP.Sing.SList xs)
instance forall k (xs :: [k]). GHC.Classes.Ord (Data.SOP.Sing.Shape xs)
instance forall k (xs :: [k]). GHC.Internal.Show.Show (Data.SOP.Sing.SList xs)
instance forall k (xs :: [k]). GHC.Internal.Show.Show (Data.SOP.Sing.Shape xs)

-- | n-ary products (and products of products)
module Data.SOP.NP

-- | An n-ary product.
--   
--   The product is parameterized by a type constructor f and
--   indexed by a type-level list xs. The length of the list
--   determines the number of elements in the product, and if the
--   i-th element of the list is of type x, then the
--   i-th element of the product is of type f x.
--   
--   The constructor names are chosen to resemble the names of the list
--   constructors.
--   
--   Two common instantiations of f are the identity functor
--   I and the constant functor K. For I, the product
--   becomes a heterogeneous list, where the type-level list describes the
--   types of its components. For K a, the product becomes
--   a homogeneous list, where the contents of the type-level list are
--   ignored, but its length still specifies the number of elements.
--   
--   In the context of the SOP approach to generic programming, an n-ary
--   product describes the structure of the arguments of a single data
--   constructor.
--   
--   Examples:
--   
--   
--   I 'x'    :* I True  :* Nil  ::  NP I       '[ Char, Bool ]
--   K 0      :* K 1     :* Nil  ::  NP (K Int) '[ Char, Bool ]
--   Just 'x' :* Nothing :* Nil  ::  NP Maybe   '[ Char, Bool ]
--   
data NP (a :: k -> Type) (b :: [k])
[Nil] :: forall {k} (a :: k -> Type). NP a ('[] :: [k])
[:*] :: forall {k} (a :: k -> Type) (x :: k) (xs :: [k]). a x -> NP a xs -> NP a (x ': xs)
infixr 5 :*

-- | A product of products.
--   
--   This is a 'newtype' for an NP of an NP. The elements of
--   the inner products are applications of the parameter f. The
--   type POP is indexed by the list of lists that determines the
--   lengths of both the outer and all the inner products, as well as the
--   types of all the elements of the inner products.
--   
--   A POP is reminiscent of a two-dimensional table (but the inner
--   lists can all be of different length). In the context of the SOP
--   approach to generic programming, a POP is useful to represent
--   information that is available for all arguments of all constructors of
--   a datatype.
newtype POP (f :: k -> Type) (xss :: [[k]])
POP :: NP (NP f) xss -> POP (f :: k -> Type) (xss :: [[k]])

-- | Unwrap a product of products.
unPOP :: forall {k} (f :: k -> Type) (xss :: [[k]]). POP f xss -> NP (NP f) xss

-- | Specialization of hpure.
--   
--   The call pure_NP x generates a product that contains
--   x in every element position.
--   
--   Example:
--   
--   
--   >>> pure_NP [] :: NP [] '[Char, Bool]
--   "" :* [] :* Nil
--   
--   >>> pure_NP (K 0) :: NP (K Int) '[Double, Int, String]
--   K 0 :* K 0 :* K 0 :* Nil
--   
pure_NP :: forall {k} f (xs :: [k]). SListI xs => (forall (a :: k). () => f a) -> NP f xs

-- | Specialization of hpure.
--   
--   The call pure_POP x generates a product of products
--   that contains x in every element position.
pure_POP :: forall {k} (xss :: [[k]]) f. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a) -> POP f xss

-- | Specialization of hcpure.
--   
--   The call cpure_NP p x generates a product that
--   contains x in every element position.
cpure_NP :: forall {k} c (xs :: [k]) proxy f. All c xs => proxy c -> (forall (a :: k). c a => f a) -> NP f xs

-- | Specialization of hcpure.
--   
--   The call cpure_NP p x generates a product of products
--   that contains x in every element position.
cpure_POP :: forall {k} c (xss :: [[k]]) proxy f. All2 c xss => proxy c -> (forall (a :: k). c a => f a) -> POP f xss

-- | Construct a homogeneous n-ary product from a normal Haskell list.
--   
--   Returns Nothing if the length of the list does not exactly
--   match the expected size of the product.
fromList :: forall {k} (xs :: [k]) a. SListI xs => [a] -> Maybe (NP (K a :: k -> Type) xs)

-- | Specialization of hap.
--   
--   Applies a product of (lifted) functions pointwise to a product of
--   suitable arguments.
ap_NP :: forall {k} (f :: k -> Type) (g :: k -> Type) (xs :: [k]). NP (f -.-> g) xs -> NP f xs -> NP g xs

-- | Specialization of hap.
--   
--   Applies a product of (lifted) functions pointwise to a product of
--   suitable arguments.
ap_POP :: forall {k} (f :: k -> Type) (g :: k -> Type) (xss :: [[k]]). POP (f -.-> g) xss -> POP f xss -> POP g xss

-- | Obtain the head of an n-ary product.
hd :: forall {k} f (x :: k) (xs :: [k]). NP f (x ': xs) -> f x

-- | Obtain the tail of an n-ary product.
tl :: forall {k} (f :: k -> Type) (x :: k) (xs :: [k]). NP f (x ': xs) -> NP f xs

-- | The type of projections from an n-ary product.
--   
--   A projection is a function from the n-ary product to a single element.
type Projection (f :: k -> Type) (xs :: [k]) = K NP f xs :: k -> Type -.-> f

-- | Compute all projections from an n-ary product.
--   
--   Each element of the resulting product contains one of the projections.
projections :: forall {k} (xs :: [k]) (f :: k -> Type). SListI xs => NP (Projection f xs) xs
shiftProjection :: forall {a1} (f :: a1 -> Type) (xs :: [a1]) (a2 :: a1) (x :: a1). Projection f xs a2 -> Projection f (x ': xs) a2

-- | Specialization of hliftA.
liftA_NP :: forall {k} (xs :: [k]) f g. SListI xs => (forall (a :: k). () => f a -> g a) -> NP f xs -> NP g xs

-- | Specialization of hliftA.
liftA_POP :: forall {k} (xss :: [[k]]) f g. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a) -> POP f xss -> POP g xss

-- | Specialization of hliftA2.
liftA2_NP :: forall {k} (xs :: [k]) f g h. SListI xs => (forall (a :: k). () => f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs

-- | Specialization of hliftA2.
liftA2_POP :: forall {k} (xss :: [[k]]) f g h. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss

-- | Specialization of hliftA3.
liftA3_NP :: forall {k} (xs :: [k]) f g h i. SListI xs => (forall (a :: k). () => f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs

-- | Specialization of hliftA3.
liftA3_POP :: forall {k} (xss :: [[k]]) f g h i. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss

-- | Specialization of hmap, which is equivalent to hliftA.
map_NP :: forall {k} (xs :: [k]) f g. SListI xs => (forall (a :: k). () => f a -> g a) -> NP f xs -> NP g xs

-- | Specialization of hmap, which is equivalent to hliftA.
map_POP :: forall {k} (xss :: [[k]]) f g. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a) -> POP f xss -> POP g xss

-- | Specialization of hzipWith, which is equivalent to
--   hliftA2.
zipWith_NP :: forall {k} (xs :: [k]) f g h. SListI xs => (forall (a :: k). () => f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs

-- | Specialization of hzipWith, which is equivalent to
--   hliftA2.
zipWith_POP :: forall {k} (xss :: [[k]]) f g h. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss

-- | Specialization of hzipWith3, which is equivalent to
--   hliftA3.
zipWith3_NP :: forall {k} (xs :: [k]) f g h i. SListI xs => (forall (a :: k). () => f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs

-- | Specialization of hzipWith3, which is equivalent to
--   hliftA3.
zipWith3_POP :: forall {k} (xss :: [[k]]) f g h i. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss

-- | Specialization of hcliftA.
cliftA_NP :: forall {k} c (xs :: [k]) proxy f g. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a) -> NP f xs -> NP g xs

-- | Specialization of hcliftA.
cliftA_POP :: forall {k} c (xss :: [[k]]) proxy f g. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a) -> POP f xss -> POP g xss

-- | Specialization of hcliftA2.
cliftA2_NP :: forall {k} c (xs :: [k]) proxy f g h. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs

-- | Specialization of hcliftA2.
cliftA2_POP :: forall {k} c (xss :: [[k]]) proxy f g h. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss

-- | Specialization of hcliftA3.
cliftA3_NP :: forall {k} c (xs :: [k]) proxy f g h i. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs

-- | Specialization of hcliftA3.
cliftA3_POP :: forall {k} c (xss :: [[k]]) proxy f g h i. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss

-- | Specialization of hcmap, which is equivalent to hcliftA.
cmap_NP :: forall {k} c (xs :: [k]) proxy f g. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a) -> NP f xs -> NP g xs

-- | Specialization of hcmap, which is equivalent to hcliftA.
cmap_POP :: forall {k} c (xss :: [[k]]) proxy f g. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a) -> POP f xss -> POP g xss

-- | Specialization of hczipWith, which is equivalent to
--   hcliftA2.
czipWith_NP :: forall {k} c (xs :: [k]) proxy f g h. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a -> h a) -> NP f xs -> NP g xs -> NP h xs

-- | Specialization of hczipWith, which is equivalent to
--   hcliftA2.
czipWith_POP :: forall {k} c (xss :: [[k]]) proxy f g h. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a -> h a) -> POP f xss -> POP g xss -> POP h xss

-- | Specialization of hczipWith3, which is equivalent to
--   hcliftA3.
czipWith3_NP :: forall {k} c (xs :: [k]) proxy f g h i. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a -> h a -> i a) -> NP f xs -> NP g xs -> NP h xs -> NP i xs

-- | Specialization of hczipWith3, which is equivalent to
--   hcliftA3.
czipWith3_POP :: forall {k} c (xss :: [[k]]) proxy f g h i. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a -> h a -> i a) -> POP f xss -> POP g xss -> POP h xss -> POP i xss

-- | Lift a constrained function operating on a list-indexed structure to a
--   function on a list-of-list-indexed structure.
--   
--   This is a variant of hcliftA.
--   
--   Specification:
--   
--   
--   hcliftA' p f xs = hpure (fn_2 $ \ AllDictC -> f) ` <a>hap</a> ` allDict_NP p ` <a>hap</a> ` xs
--   
--   
--   Instances:
--   
--   
--   hcliftA' :: All2 c xss => proxy c -> (forall xs. All c xs => f xs -> f' xs) -> NP f xss -> NP f' xss
--   hcliftA' :: All2 c xss => proxy c -> (forall xs. All c xs => f xs -> f' xs) -> NS f xss -> NS f' xss
--   

-- | Deprecated: Use hcliftA or hcmap instead.
hcliftA' :: forall {k} (c :: k -> Constraint) (xss :: [[k]]) h proxy f f'. (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

-- | Like hcliftA', but for binary functions.

-- | Deprecated: Use hcliftA2 or hczipWith instead.
hcliftA2' :: forall {k} (c :: k -> Constraint) (xss :: [[k]]) h proxy f f' f''. (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

-- | Like hcliftA', but for ternary functions.

-- | Deprecated: Use hcliftA3 or hczipWith3 instead.
hcliftA3' :: forall {k} (c :: k -> Constraint) (xss :: [[k]]) h proxy f f' f'' f'''. (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

-- | Specialization of hcliftA2'.

-- | Deprecated: Use cliftA2_NP instead.
cliftA2'_NP :: forall {k} (c :: k -> Constraint) (xss :: [[k]]) proxy f g h. All2 c xss => proxy c -> (forall (xs :: [k]). All c xs => f xs -> g xs -> h xs) -> NP f xss -> NP g xss -> NP h xss

-- | Specialization of hcollapse.
--   
--   Example:
--   
--   
--   >>> collapse_NP (K 1 :* K 2 :* K 3 :* Nil)
--   [1,2,3]
--   
collapse_NP :: forall {k} a (xs :: [k]). NP (K a :: k -> Type) xs -> [a]

-- | Specialization of hcollapse.
--   
--   Example:
--   
--   
--   >>> collapse_POP (POP ((K 'a' :* Nil) :* (K 'b' :* K 'c' :* Nil) :* Nil) :: POP (K Char) '[ '[(a :: Type)], '[b, c] ])
--   ["a","bc"]
--   
--   
--   (The type signature is only necessary in this case to fix the kind of
--   the type variables.)
collapse_POP :: forall {k} (xss :: [[k]]) a. SListI xss => POP (K a :: k -> Type) xss -> [[a]]

-- | Specialization of hctraverse_.
ctraverse__NP :: forall {k} c proxy (xs :: [k]) f g. (All c xs, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g ()) -> NP f xs -> g ()

-- | Specialization of hctraverse_.
ctraverse__POP :: forall {k} c proxy (xss :: [[k]]) f g. (All2 c xss, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g ()) -> POP f xss -> g ()

-- | Specialization of htraverse_.
traverse__NP :: forall {k} (xs :: [k]) f g. (SListI xs, Applicative g) => (forall (a :: k). () => f a -> g ()) -> NP f xs -> g ()

-- | Specialization of htraverse_.
traverse__POP :: forall {k} (xss :: [[k]]) f g. (SListI2 xss, Applicative g) => (forall (a :: k). () => f a -> g ()) -> POP f xss -> g ()

-- | Specialization of hcfoldMap.
cfoldMap_NP :: forall {k} c (xs :: [k]) m proxy f. (All c xs, Monoid m) => proxy c -> (forall (a :: k). c a => f a -> m) -> NP f xs -> m

-- | Specialization of hcfoldMap.
cfoldMap_POP :: forall {k} c (xs :: [[k]]) m proxy f. (All2 c xs, Monoid m) => proxy c -> (forall (a :: k). c a => f a -> m) -> POP f xs -> m

-- | Specialization of hsequence'.
sequence'_NP :: forall {k} f (g :: k -> Type) (xs :: [k]). Applicative f => NP (f :.: g) xs -> f (NP g xs)

-- | Specialization of hsequence'.
sequence'_POP :: forall {k} (xss :: [[k]]) f (g :: k -> Type). (SListI xss, Applicative f) => POP (f :.: g) xss -> f (POP g xss)

-- | Specialization of hsequence.
--   
--   Example:
--   
--   
--   >>> sequence_NP (Just 1 :* Just 2 :* Nil)
--   Just (I 1 :* I 2 :* Nil)
--   
sequence_NP :: forall (xs :: [Type]) f. (SListI xs, Applicative f) => NP f xs -> f (NP I xs)

-- | Specialization of hsequence.
--   
--   Example:
--   
--   
--   >>> sequence_POP (POP ((Just 1 :* Nil) :* (Just 2 :* Just 3 :* Nil) :* Nil))
--   Just (POP ((I 1 :* Nil) :* (I 2 :* I 3 :* Nil) :* Nil))
--   
sequence_POP :: forall (xss :: [[Type]]) f. (All (SListI :: [Type] -> Constraint) xss, Applicative f) => POP f xss -> f (POP I xss)

-- | Specialization of hctraverse'.
ctraverse'_NP :: forall {k} c proxy (xs :: [k]) f f' g. (All c xs, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g (f' a)) -> NP f xs -> g (NP f' xs)

-- | Specialization of hctraverse'.
ctraverse'_POP :: forall {k} c (xss :: [[k]]) g proxy f f'. (All2 c xss, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g (f' a)) -> POP f xss -> g (POP f' xss)

-- | Specialization of htraverse'.
traverse'_NP :: forall {k} (xs :: [k]) f f' g. (SListI xs, Applicative g) => (forall (a :: k). () => f a -> g (f' a)) -> NP f xs -> g (NP f' xs)

-- | Specialization of hctraverse'.
traverse'_POP :: forall {k} (xss :: [[k]]) g f f'. (SListI2 xss, Applicative g) => (forall (a :: k). () => f a -> g (f' a)) -> POP f xss -> g (POP f' xss)

-- | Specialization of hctraverse.
ctraverse_NP :: forall c (xs :: [Type]) g proxy f. (All c xs, Applicative g) => proxy c -> (forall a. c a => f a -> g a) -> NP f xs -> g (NP I xs)

-- | Specialization of hctraverse.
ctraverse_POP :: forall c (xs :: [[Type]]) g proxy f. (All2 c xs, Applicative g) => proxy c -> (forall a. c a => f a -> g a) -> POP f xs -> g (POP I xs)

-- | Catamorphism for NP.
--   
--   This is a suitable generalization of foldr. It takes parameters
--   on what to do for Nil and :*. Since the input list is
--   heterogeneous, the result is also indexed by a type-level list.
cata_NP :: forall {a} r f (xs :: [a]). r ('[] :: [a]) -> (forall (y :: a) (ys :: [a]). () => f y -> r ys -> r (y ': ys)) -> NP f xs -> r xs

-- | Constrained catamorphism for NP.
--   
--   The difference compared to cata_NP is that the function for the
--   cons-case can make use of the fact that the specified constraint holds
--   for all the types in the signature of the product.
ccata_NP :: forall {a} c proxy r f (xs :: [a]). All c xs => proxy c -> r ('[] :: [a]) -> (forall (y :: a) (ys :: [a]). c y => f y -> r ys -> r (y ': ys)) -> NP f xs -> r xs

-- | Anamorphism for NP.
--   
--   In contrast to the anamorphism for normal lists, the generating
--   function does not return an Either, but simply an element and a
--   new seed value.
--   
--   This is because the decision on whether to generate a Nil or a
--   :* is determined by the types.
ana_NP :: forall {k} s f (xs :: [k]). SListI xs => (forall (y :: k) (ys :: [k]). () => s (y ': ys) -> (f y, s ys)) -> s xs -> NP f xs

-- | Constrained anamorphism for NP.
--   
--   Compared to ana_NP, the generating function can make use of the
--   specified constraint here for the elements that it generates.
cana_NP :: forall {k} c proxy s f (xs :: [k]). All c xs => proxy c -> (forall (y :: k) (ys :: [k]). c y => s (y ': ys) -> (f y, s ys)) -> s xs -> NP f xs

-- | Specialization of htrans.
trans_NP :: forall {k1} {k2} c (xs :: [k1]) (ys :: [k2]) proxy f g. AllZip c xs ys => proxy c -> (forall (x :: k1) (y :: k2). c x y => f x -> g y) -> NP f xs -> NP g ys

-- | Specialization of htrans.
trans_POP :: forall {k1} {k2} c (xss :: [[k1]]) (yss :: [[k2]]) proxy f g. AllZip2 c xss yss => proxy c -> (forall (x :: k1) (y :: k2). c x y => f x -> g y) -> POP f xss -> POP g yss

-- | Specialization of hcoerce.
coerce_NP :: forall {k1} {k2} (f :: k1 -> Type) (g :: k2 -> Type) (xs :: [k1]) (ys :: [k2]). AllZip (LiftedCoercible f g) xs ys => NP f xs -> NP g ys

-- | Specialization of hcoerce.
coerce_POP :: forall {k1} {k2} (f :: k1 -> Type) (g :: k2 -> Type) (xss :: [[k1]]) (yss :: [[k2]]). AllZip2 (LiftedCoercible f g) xss yss => POP f xss -> POP g yss

-- | Specialization of hfromI.
fromI_NP :: forall {k} (f :: k -> Type) (xs :: [Type]) (ys :: [k]). AllZip (LiftedCoercible I f) xs ys => NP I xs -> NP f ys

-- | Specialization of hfromI.
fromI_POP :: forall {k} (f :: k -> Type) (xss :: [[Type]]) (yss :: [[k]]). AllZip2 (LiftedCoercible I f) xss yss => POP I xss -> POP f yss

-- | Specialization of htoI.
toI_NP :: forall {k} (f :: k -> Type) (xs :: [k]) (ys :: [Type]). AllZip (LiftedCoercible f I) xs ys => NP f xs -> NP I ys

-- | Specialization of htoI.
toI_POP :: forall {k} (f :: k -> Type) (xss :: [[k]]) (yss :: [[Type]]). AllZip2 (LiftedCoercible f I) xss yss => POP f xss -> POP I yss
instance forall k (f :: k -> *) (xs :: [k]). Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Eq f) xs => GHC.Classes.Eq (Data.SOP.NP.NP f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). GHC.Classes.Eq (Data.SOP.NP.NP (Data.SOP.NP.NP f) xss) => GHC.Classes.Eq (Data.SOP.NP.POP f xss)
instance Data.SOP.Classes.HAp Data.SOP.NP.NP
instance Data.SOP.Classes.HAp Data.SOP.NP.POP
instance Data.SOP.Classes.HCollapse Data.SOP.NP.NP
instance Data.SOP.Classes.HCollapse Data.SOP.NP.POP
instance Data.SOP.Classes.HPure Data.SOP.NP.NP
instance Data.SOP.Classes.HPure Data.SOP.NP.POP
instance Data.SOP.Classes.HSequence Data.SOP.NP.NP
instance Data.SOP.Classes.HSequence Data.SOP.NP.POP
instance Data.SOP.Classes.HTrans Data.SOP.NP.NP Data.SOP.NP.NP
instance Data.SOP.Classes.HTrans Data.SOP.NP.POP Data.SOP.NP.POP
instance Data.SOP.Classes.HTraverse_ Data.SOP.NP.NP
instance Data.SOP.Classes.HTraverse_ Data.SOP.NP.POP
instance forall k (f :: k -> *) (xs :: [k]). (Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Internal.Base.Monoid f) xs, Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Internal.Base.Semigroup f) xs) => GHC.Internal.Base.Monoid (Data.SOP.NP.NP f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). GHC.Internal.Base.Monoid (Data.SOP.NP.NP (Data.SOP.NP.NP f) xss) => GHC.Internal.Base.Monoid (Data.SOP.NP.POP f xss)
instance forall k (f :: k -> *) (xs :: [k]). Data.SOP.Constraint.All (Data.SOP.Constraint.Compose Control.DeepSeq.NFData f) xs => Control.DeepSeq.NFData (Data.SOP.NP.NP f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). Control.DeepSeq.NFData (Data.SOP.NP.NP (Data.SOP.NP.NP f) xss) => Control.DeepSeq.NFData (Data.SOP.NP.POP f xss)
instance forall k (f :: k -> *) (xs :: [k]). (Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Eq f) xs, Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Ord f) xs) => GHC.Classes.Ord (Data.SOP.NP.NP f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). GHC.Classes.Ord (Data.SOP.NP.NP (Data.SOP.NP.NP f) xss) => GHC.Classes.Ord (Data.SOP.NP.POP f xss)
instance forall k (f :: k -> *) (xs :: [k]). Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Internal.Base.Semigroup f) xs => GHC.Internal.Base.Semigroup (Data.SOP.NP.NP f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). GHC.Internal.Base.Semigroup (Data.SOP.NP.NP (Data.SOP.NP.NP f) xss) => GHC.Internal.Base.Semigroup (Data.SOP.NP.POP f xss)
instance forall k (f :: k -> *) (xs :: [k]). Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Internal.Show.Show f) xs => GHC.Internal.Show.Show (Data.SOP.NP.NP f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). GHC.Internal.Show.Show (Data.SOP.NP.NP (Data.SOP.NP.NP f) xss) => GHC.Internal.Show.Show (Data.SOP.NP.POP f xss)

-- | n-ary sums (and sums of products)
module Data.SOP.NS

-- | An n-ary sum.
--   
--   The sum is parameterized by a type constructor f and indexed
--   by a type-level list xs. The length of the list determines
--   the number of choices in the sum and if the i-th element of
--   the list is of type x, then the i-th choice of the
--   sum is of type f x.
--   
--   The constructor names are chosen to resemble Peano-style natural
--   numbers, i.e., Z is for "zero", and S is for
--   "successor". Chaining S and Z chooses the corresponding
--   component of the sum.
--   
--   Examples:
--   
--   
--   Z         :: f x -> NS f (x ': xs)
--   S . Z     :: f y -> NS f (x ': y ': xs)
--   S . S . Z :: f z -> NS f (x ': y ': z ': xs)
--   ...
--   
--   
--   Note that empty sums (indexed by an empty list) have no non-bottom
--   elements.
--   
--   Two common instantiations of f are the identity functor
--   I and the constant functor K. For I, the sum
--   becomes a direct generalization of the Either type to
--   arbitrarily many choices. For K a, the result is a
--   homogeneous choice type, where the contents of the type-level list are
--   ignored, but its length specifies the number of options.
--   
--   In the context of the SOP approach to generic programming, an n-ary
--   sum describes the top-level structure of a datatype, which is a choice
--   between all of its constructors.
--   
--   Examples:
--   
--   
--   Z (I 'x')      :: NS I       '[ Char, Bool ]
--   S (Z (I True)) :: NS I       '[ Char, Bool ]
--   S (Z (K 1))    :: NS (K Int) '[ Char, Bool ]
--   
data NS (a :: k -> Type) (b :: [k])
[Z] :: forall {k} (a :: k -> Type) (x :: k) (xs :: [k]). a x -> NS a (x ': xs)
[S] :: forall {k} (a :: k -> Type) (xs :: [k]) (x :: k). NS a xs -> NS a (x ': xs)

-- | A sum of products.
--   
--   This is a 'newtype' for an NS of an NP. The elements of
--   the (inner) products are applications of the parameter f. The
--   type SOP is indexed by the list of lists that determines the
--   sizes of both the (outer) sum and all the (inner) products, as well as
--   the types of all the elements of the inner products.
--   
--   A SOP I reflects the structure of a normal
--   Haskell datatype. The sum structure represents the choice between the
--   different constructors, the product structure represents the arguments
--   of each constructor.
newtype SOP (f :: k -> Type) (xss :: [[k]])
SOP :: NS (NP f) xss -> SOP (f :: k -> Type) (xss :: [[k]])

-- | Unwrap a sum of products.
unSOP :: forall {k} (f :: k -> Type) (xss :: [[k]]). SOP f xss -> NS (NP f) xss

-- | The type of injections into an n-ary sum.
--   
--   If you expand the type synonyms and newtypes involved, you get
--   
--   
--   Injection f xs a = (f -.-> K (NS f xs)) a ~= f a -> K (NS f xs) a ~= f a -> NS f xs
--   
--   
--   If we pick a to be an element of xs, this indeed
--   corresponds to an injection into the sum.
type Injection (f :: k -> Type) (xs :: [k]) = f -.-> K NS f xs :: k -> Type

-- | Compute all injections into an n-ary sum.
--   
--   Each element of the resulting product contains one of the injections.
injections :: forall {k} (xs :: [k]) (f :: k -> Type). SListI xs => NP (Injection f xs) xs

-- | Shift an injection.
--   
--   Given an injection, return an injection into a sum that is one
--   component larger.

-- | Deprecated: Use shiftInjection instead.
shift :: forall {a1} (f :: a1 -> Type) (xs :: [a1]) (a2 :: a1) (x :: a1). Injection f xs a2 -> Injection f (x ': xs) a2

-- | Shift an injection.
--   
--   Given an injection, return an injection into a sum that is one
--   component larger.
shiftInjection :: forall {a1} (f :: a1 -> Type) (xs :: [a1]) (a2 :: a1) (x :: a1). Injection f xs a2 -> Injection f (x ': xs) a2

-- | Apply injections to a product.
--   
--   Given a product containing all possible choices, produce a list of
--   sums by applying each injection to the appropriate element.
--   
--   Example:
--   
--   
--   >>> apInjs_NP (I 'x' :* I True :* I 2 :* Nil)
--   [Z (I 'x'),S (Z (I True)),S (S (Z (I 2)))]
--   
apInjs_NP :: forall {k} (xs :: [k]) (f :: k -> Type). SListI xs => NP f xs -> [NS f xs]

-- | apInjs_NP without hcollapse.
--   
--   
--   >>> apInjs'_NP (I 'x' :* I True :* I 2 :* Nil)
--   K (Z (I 'x')) :* K (S (Z (I True))) :* K (S (S (Z (I 2)))) :* Nil
--   
apInjs'_NP :: forall {k} (xs :: [k]) (f :: k -> Type). SListI xs => NP f xs -> NP (K (NS f xs) :: k -> Type) xs

-- | Apply injections to a product of product.
--   
--   This operates on the outer product only. Given a product containing
--   all possible choices (that are products), produce a list of sums (of
--   products) by applying each injection to the appropriate element.
--   
--   Example:
--   
--   
--   >>> apInjs_POP (POP ((I 'x' :* Nil) :* (I True :* I 2 :* Nil) :* Nil))
--   [SOP (Z (I 'x' :* Nil)),SOP (S (Z (I True :* I 2 :* Nil)))]
--   
apInjs_POP :: forall {k} (xss :: [[k]]) (f :: k -> Type). SListI xss => POP f xss -> [SOP f xss]

-- | apInjs_POP without hcollapse.
--   
--   Example:
--   
--   
--   >>> apInjs'_POP (POP ((I 'x' :* Nil) :* (I True :* I 2 :* Nil) :* Nil))
--   K (SOP (Z (I 'x' :* Nil))) :* K (SOP (S (Z (I True :* I 2 :* Nil)))) :* Nil
--   
apInjs'_POP :: forall {k} (xss :: [[k]]) (f :: k -> Type). SListI xss => POP f xss -> NP (K (SOP f xss) :: [k] -> Type) xss

-- | Extract the payload from a unary sum.
--   
--   For larger sums, this function would be partial, so it is only
--   provided with a rather restrictive type.
--   
--   Example:
--   
--   
--   >>> unZ (Z (I 'x'))
--   I 'x'
--   
unZ :: forall {k} f (x :: k). NS f '[x] -> f x

-- | Obtain the index from an n-ary sum.
--   
--   An n-nary sum represents a choice between n different options. This
--   function returns an integer between 0 and n - 1 indicating the option
--   chosen by the given value.
--   
--   Examples:
--   
--   
--   >>> index_NS (S (S (Z (I False))))
--   2
--   
--   >>> index_NS (Z (K ()))
--   0
--   
index_NS :: forall {k} (f :: k -> Type) (xs :: [k]). NS f xs -> Int

-- | Obtain the index from an n-ary sum of products.
--   
--   An n-nary sum represents a choice between n different options. This
--   function returns an integer between 0 and n - 1 indicating the option
--   chosen by the given value.
--   
--   Specification:
--   
--   
--   index_SOP = index_NS . unSOP
--   
--   
--   Example:
--   
--   
--   >>> index_SOP (SOP (S (Z (I True :* I 'x' :* Nil))))
--   1
--   
index_SOP :: forall {k} (f :: k -> Type) (xs :: [[k]]). SOP f xs -> Int

-- | The type of ejections from an n-ary sum.
--   
--   An ejection is the pattern matching function for one part of the n-ary
--   sum.
--   
--   It is the opposite of an Injection.
type Ejection (f :: k -> Type) (xs :: [k]) = K NS f xs :: k -> Type -.-> Maybe :.: f

-- | Compute all ejections from an n-ary sum.
--   
--   Each element of the resulting product contains one of the ejections.
ejections :: forall {k} (xs :: [k]) (f :: k -> Type). SListI xs => NP (Ejection f xs) xs

shiftEjection :: forall {a1} (f :: a1 -> Type) (x :: a1) (xs :: [a1]) (a2 :: a1). Ejection f xs a2 -> Ejection f (x ': xs) a2

-- | Specialization of hap.
ap_NS :: forall {k} (f :: k -> Type) (g :: k -> Type) (xs :: [k]). NP (f -.-> g) xs -> NS f xs -> NS g xs

-- | Specialization of hap.
ap_SOP :: forall {k} (f :: k -> Type) (g :: k -> Type) (xss :: [[k]]). POP (f -.-> g) xss -> SOP f xss -> SOP g xss

-- | Specialization of hliftA.
liftA_NS :: forall {k} (xs :: [k]) f g. SListI xs => (forall (a :: k). () => f a -> g a) -> NS f xs -> NS g xs

-- | Specialization of hliftA.
liftA_SOP :: forall {k} (xss :: [[k]]) f g. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a) -> SOP f xss -> SOP g xss

-- | Specialization of hliftA2.
liftA2_NS :: forall {k} (xs :: [k]) f g h. SListI xs => (forall (a :: k). () => f a -> g a -> h a) -> NP f xs -> NS g xs -> NS h xs

-- | Specialization of hliftA2.
liftA2_SOP :: forall {k} (xss :: [[k]]) f g h. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a -> h a) -> POP f xss -> SOP g xss -> SOP h xss

-- | Specialization of hcliftA.
cliftA_NS :: forall {k} c (xs :: [k]) proxy f g. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a) -> NS f xs -> NS g xs

-- | Specialization of hcliftA.
cliftA_SOP :: forall {k} c (xss :: [[k]]) proxy f g. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a) -> SOP f xss -> SOP g xss

-- | Specialization of hcliftA2.
cliftA2_NS :: forall {k} c (xs :: [k]) proxy f g h. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a -> h a) -> NP f xs -> NS g xs -> NS h xs

-- | Specialization of hcliftA2.
cliftA2_SOP :: forall {k} c (xss :: [[k]]) proxy f g h. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a -> h a) -> POP f xss -> SOP g xss -> SOP h xss

-- | Specialization of hmap, which is equivalent to hliftA.
map_NS :: forall {k} (xs :: [k]) f g. SListI xs => (forall (a :: k). () => f a -> g a) -> NS f xs -> NS g xs

-- | Specialization of hmap, which is equivalent to hliftA.
map_SOP :: forall {k} (xss :: [[k]]) f g. All (SListI :: [k] -> Constraint) xss => (forall (a :: k). () => f a -> g a) -> SOP f xss -> SOP g xss

-- | Specialization of hcmap, which is equivalent to hcliftA.
cmap_NS :: forall {k} c (xs :: [k]) proxy f g. All c xs => proxy c -> (forall (a :: k). c a => f a -> g a) -> NS f xs -> NS g xs

-- | Specialization of hcmap, which is equivalent to hcliftA.
cmap_SOP :: forall {k} c (xss :: [[k]]) proxy f g. All2 c xss => proxy c -> (forall (a :: k). c a => f a -> g a) -> SOP f xss -> SOP g xss

-- | Specialization of hcliftA2'.

-- | Deprecated: Use cliftA2_NS instead.
cliftA2'_NS :: forall {k} (c :: k -> Constraint) (xss :: [[k]]) proxy f g h. All2 c xss => proxy c -> (forall (xs :: [k]). All c xs => f xs -> g xs -> h xs) -> NP f xss -> NS g xss -> NS h xss

-- | Compare two sums with respect to the choice they are making.
--   
--   A value that chooses the first option is considered smaller than one
--   that chooses the second option.
--   
--   If the choices are different, then either the first (if the first is
--   smaller than the second) or the third (if the first is larger than the
--   second) argument are called. If both choices are equal, then the
--   second argument is called, which has access to the elements contained
--   in the sums.
compare_NS :: forall {k} r f g (xs :: [k]). r -> (forall (x :: k). () => f x -> g x -> r) -> r -> NS f xs -> NS g xs -> r

-- | Constrained version of compare_NS.
ccompare_NS :: forall {k} c proxy r f g (xs :: [k]). 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 two sums of products with respect to the choice in the sum
--   they are making.
--   
--   Only the sum structure is used for comparison. This is a small wrapper
--   around ccompare_NS for a common special case.
compare_SOP :: forall {k} r (f :: k -> Type) (g :: k -> Type) (xss :: [[k]]). r -> (forall (xs :: [k]). () => NP f xs -> NP g xs -> r) -> r -> SOP f xss -> SOP g xss -> r

-- | Constrained version of compare_SOP.
ccompare_SOP :: forall {k} (c :: k -> Constraint) proxy r (f :: k -> Type) (g :: k -> Type) (xss :: [[k]]). 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

-- | Specialization of hcollapse.
collapse_NS :: forall {k} a (xs :: [k]). NS (K a :: k -> Type) xs -> a

-- | Specialization of hcollapse.
collapse_SOP :: forall {k} (xss :: [[k]]) a. SListI xss => SOP (K a :: k -> Type) xss -> [a]

-- | Specialization of hctraverse_.
--   
--   Note: we don't need Applicative constraint.
ctraverse__NS :: forall {k} c proxy (xs :: [k]) f g. All c xs => proxy c -> (forall (a :: k). c a => f a -> g ()) -> NS f xs -> g ()

-- | Specialization of hctraverse_.
ctraverse__SOP :: forall {k} c proxy (xss :: [[k]]) f g. (All2 c xss, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g ()) -> SOP f xss -> g ()

-- | Specialization of htraverse_.
--   
--   Note: we don't need Applicative constraint.
traverse__NS :: forall {k} (xs :: [k]) f g. SListI xs => (forall (a :: k). () => f a -> g ()) -> NS f xs -> g ()

-- | Specialization of htraverse_.
traverse__SOP :: forall {k} (xss :: [[k]]) f g. (SListI2 xss, Applicative g) => (forall (a :: k). () => f a -> g ()) -> SOP f xss -> g ()

-- | Specialization of hcfoldMap.
--   
--   Note: We don't need Monoid instance.
cfoldMap_NS :: forall {k} c proxy f (xs :: [k]) m. All c xs => proxy c -> (forall (a :: k). c a => f a -> m) -> NS f xs -> m

-- | Specialization of hcfoldMap.
cfoldMap_SOP :: forall {k} c (xs :: [[k]]) m proxy f. (All2 c xs, Monoid m) => proxy c -> (forall (a :: k). c a => f a -> m) -> SOP f xs -> m

-- | Specialization of hsequence'.
sequence'_NS :: forall {k} f (g :: k -> Type) (xs :: [k]). Applicative f => NS (f :.: g) xs -> f (NS g xs)

-- | Specialization of hsequence'.
sequence'_SOP :: forall {k} (xss :: [[k]]) f (g :: k -> Type). (SListI xss, Applicative f) => SOP (f :.: g) xss -> f (SOP g xss)

-- | Specialization of hsequence.
sequence_NS :: forall (xs :: [Type]) f. (SListI xs, Applicative f) => NS f xs -> f (NS I xs)

-- | Specialization of hsequence.
sequence_SOP :: forall (xss :: [[Type]]) f. (All (SListI :: [Type] -> Constraint) xss, Applicative f) => SOP f xss -> f (SOP I xss)

-- | Specialization of hctraverse'.
--   
--   Note: as NS has exactly one element, the Functor
--   constraint is enough.
ctraverse'_NS :: forall {k} c proxy (xs :: [k]) f f' g. (All c xs, Functor g) => proxy c -> (forall (a :: k). c a => f a -> g (f' a)) -> NS f xs -> g (NS f' xs)

-- | Specialization of hctraverse'.
ctraverse'_SOP :: forall {k} c (xss :: [[k]]) g proxy f f'. (All2 c xss, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g (f' a)) -> SOP f xss -> g (SOP f' xss)

-- | Specialization of htraverse'.
--   
--   Note: as NS has exactly one element, the Functor
--   constraint is enough.
traverse'_NS :: forall {k} (xs :: [k]) f f' g. (SListI xs, Functor g) => (forall (a :: k). () => f a -> g (f' a)) -> NS f xs -> g (NS f' xs)

-- | Specialization of htraverse'.
traverse'_SOP :: forall {k} (xss :: [[k]]) g f f'. (SListI2 xss, Applicative g) => (forall (a :: k). () => f a -> g (f' a)) -> SOP f xss -> g (SOP f' xss)

-- | Specialization of hctraverse.
ctraverse_NS :: forall c (xs :: [Type]) g proxy f. (All c xs, Applicative g) => proxy c -> (forall a. c a => f a -> g a) -> NP f xs -> g (NP I xs)

-- | Specialization of hctraverse.
ctraverse_SOP :: forall c (xs :: [[Type]]) g proxy f. (All2 c xs, Applicative g) => proxy c -> (forall a. c a => f a -> g a) -> POP f xs -> g (POP I xs)

-- | Catamorphism for NS.
--   
--   Takes arguments determining what to do for Z and what to do for
--   S. The result type is still indexed over the type-level lit.
cata_NS :: forall {k} r f (xs :: [k]). (forall (y :: k) (ys :: [k]). () => f y -> r (y ': ys)) -> (forall (y :: k) (ys :: [k]). () => r ys -> r (y ': ys)) -> NS f xs -> r xs

-- | Constrained catamorphism for NS.
ccata_NS :: forall {k} c proxy r f (xs :: [k]). All c xs => proxy c -> (forall (y :: k) (ys :: [k]). c y => f y -> r (y ': ys)) -> (forall (y :: k) (ys :: [k]). c y => r ys -> r (y ': ys)) -> NS f xs -> r xs

-- | Anamorphism for NS.
ana_NS :: forall {k} s f (xs :: [k]). SListI xs => (forall r. () => s ('[] :: [k]) -> r) -> (forall (y :: k) (ys :: [k]). () => s (y ': ys) -> Either (f y) (s ys)) -> s xs -> NS f xs

-- | Constrained anamorphism for NS.
cana_NS :: forall {k} c proxy s f (xs :: [k]). All c xs => proxy c -> (forall r. () => s ('[] :: [k]) -> r) -> (forall (y :: k) (ys :: [k]). c y => s (y ': ys) -> Either (f y) (s ys)) -> s xs -> NS f xs

-- | Specialization of hexpand.
expand_NS :: forall {k} f (xs :: [k]). SListI xs => (forall (x :: k). () => f x) -> NS f xs -> NP f xs

-- | Specialization of hcexpand.
cexpand_NS :: forall {k} c proxy f (xs :: [k]). All c xs => proxy c -> (forall (x :: k). c x => f x) -> NS f xs -> NP f xs

-- | Specialization of hexpand.
expand_SOP :: forall {k} f (xss :: [[k]]). All (SListI :: [k] -> Constraint) xss => (forall (x :: k). () => f x) -> SOP f xss -> POP f xss

-- | Specialization of hcexpand.
cexpand_SOP :: forall {k} c proxy f (xss :: [[k]]). All2 c xss => proxy c -> (forall (x :: k). c x => f x) -> SOP f xss -> POP f xss

-- | Specialization of htrans.
trans_NS :: forall {k1} {k2} c (xs :: [k1]) (ys :: [k2]) proxy f g. AllZip c xs ys => proxy c -> (forall (x :: k1) (y :: k2). c x y => f x -> g y) -> NS f xs -> NS g ys

-- | Specialization of htrans.
trans_SOP :: forall {k1} {k2} c (xss :: [[k1]]) (yss :: [[k2]]) proxy f g. AllZip2 c xss yss => proxy c -> (forall (x :: k1) (y :: k2). c x y => f x -> g y) -> SOP f xss -> SOP g yss

-- | Specialization of hcoerce.
coerce_NS :: forall {k1} {k2} (f :: k1 -> Type) (g :: k2 -> Type) (xs :: [k1]) (ys :: [k2]). AllZip (LiftedCoercible f g) xs ys => NS f xs -> NS g ys

-- | Specialization of hcoerce.
coerce_SOP :: forall {k1} {k2} (f :: k1 -> Type) (g :: k2 -> Type) (xss :: [[k1]]) (yss :: [[k2]]). AllZip2 (LiftedCoercible f g) xss yss => SOP f xss -> SOP g yss

-- | Specialization of hfromI.
fromI_NS :: forall {k} (f :: k -> Type) (xs :: [Type]) (ys :: [k]). AllZip (LiftedCoercible I f) xs ys => NS I xs -> NS f ys

-- | Specialization of hfromI.
fromI_SOP :: forall {k} (f :: k -> Type) (xss :: [[Type]]) (yss :: [[k]]). AllZip2 (LiftedCoercible I f) xss yss => SOP I xss -> SOP f yss

-- | Specialization of htoI.
toI_NS :: forall {k} (f :: k -> Type) (xs :: [k]) (ys :: [Type]). AllZip (LiftedCoercible f I) xs ys => NS f xs -> NS I ys

-- | Specialization of htoI.
toI_SOP :: forall {k} (f :: k -> Type) (xss :: [[k]]) (yss :: [[Type]]). AllZip2 (LiftedCoercible f I) xss yss => SOP f xss -> SOP I yss
instance forall k (f :: k -> *) (xs :: [k]). Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Eq f) xs => GHC.Classes.Eq (Data.SOP.NS.NS f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). GHC.Classes.Eq (Data.SOP.NS.NS (Data.SOP.NP.NP f) xss) => GHC.Classes.Eq (Data.SOP.NS.SOP f xss)
instance Data.SOP.Classes.HApInjs Data.SOP.NS.NS
instance Data.SOP.Classes.HApInjs Data.SOP.NS.SOP
instance Data.SOP.Classes.HAp Data.SOP.NS.NS
instance Data.SOP.Classes.HAp Data.SOP.NS.SOP
instance Data.SOP.Classes.HCollapse Data.SOP.NS.NS
instance Data.SOP.Classes.HCollapse Data.SOP.NS.SOP
instance Data.SOP.Classes.HExpand Data.SOP.NS.NS
instance Data.SOP.Classes.HExpand Data.SOP.NS.SOP
instance Data.SOP.Classes.HIndex Data.SOP.NS.NS
instance Data.SOP.Classes.HIndex Data.SOP.NS.SOP
instance Data.SOP.Classes.HSequence Data.SOP.NS.NS
instance Data.SOP.Classes.HSequence Data.SOP.NS.SOP
instance Data.SOP.Classes.HTrans Data.SOP.NS.NS Data.SOP.NS.NS
instance Data.SOP.Classes.HTrans Data.SOP.NS.SOP Data.SOP.NS.SOP
instance Data.SOP.Classes.HTraverse_ Data.SOP.NS.NS
instance Data.SOP.Classes.HTraverse_ Data.SOP.NS.SOP
instance forall k (f :: k -> *) (xs :: [k]). Data.SOP.Constraint.All (Data.SOP.Constraint.Compose Control.DeepSeq.NFData f) xs => Control.DeepSeq.NFData (Data.SOP.NS.NS f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). Control.DeepSeq.NFData (Data.SOP.NS.NS (Data.SOP.NP.NP f) xss) => Control.DeepSeq.NFData (Data.SOP.NS.SOP f xss)
instance forall k (f :: k -> *) (xs :: [k]). (Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Eq f) xs, Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Classes.Ord f) xs) => GHC.Classes.Ord (Data.SOP.NS.NS f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). GHC.Classes.Ord (Data.SOP.NS.NS (Data.SOP.NP.NP f) xss) => GHC.Classes.Ord (Data.SOP.NS.SOP f xss)
instance forall k (f :: k -> *) (xs :: [k]). Data.SOP.Constraint.All (Data.SOP.Constraint.Compose GHC.Internal.Show.Show f) xs => GHC.Internal.Show.Show (Data.SOP.NS.NS f xs)
instance forall k (f :: k -> *) (xss :: [[k]]). GHC.Internal.Show.Show (Data.SOP.NS.NS (Data.SOP.NP.NP f) xss) => GHC.Internal.Show.Show (Data.SOP.NS.SOP f xss)

-- | Explicit dictionaries.
--   
--   When working with compound constraints such as constructed using
--   All or All2, GHC cannot always prove automatically what
--   one would expect to hold.
--   
--   This module provides a way of explicitly proving conversions between
--   such constraints to GHC. Such conversions still have to be manually
--   applied.
--   
--   This module remains somewhat experimental. It is therefore not
--   exported via the main module and has to be imported explicitly.
module Data.SOP.Dict

-- | An explicit dictionary carrying evidence of a class constraint.
--   
--   The constraint parameter is separated into a second argument so that
--   Dict c is of the correct kind to be used directly as a
--   parameter to e.g. NP.
data Dict (c :: k -> Constraint) (a :: k)
[Dict] :: forall {k} (c :: k -> Constraint) (a :: k). c a => Dict c a

-- | A proof that the trivial constraint holds over all type-level lists.
pureAll :: forall {k} (xs :: [k]). SListI xs => Dict (All (Top :: k -> Constraint)) xs

-- | A proof that the trivial constraint holds over all type-level lists of
--   lists.
pureAll2 :: forall {k} (xss :: [[k]]). All (SListI :: [k] -> Constraint) xss => Dict (All2 (Top :: k -> Constraint)) xss

-- | Lifts a dictionary conversion over a type-level list.
mapAll :: forall {k} (c :: k -> Constraint) (d :: k -> Constraint) (xs :: [k]). (forall (a :: k). () => Dict c a -> Dict d a) -> Dict (All c) xs -> Dict (All d) xs

-- | Lifts a dictionary conversion over a type-level list of lists.
mapAll2 :: forall {k} (c :: k -> Constraint) (d :: k -> Constraint) (xss :: [[k]]). (forall (a :: k). () => Dict c a -> Dict d a) -> Dict (All2 c) xss -> Dict (All2 d) xss

-- | If two constraints c and d hold over a type-level
--   list xs, then the combination of both constraints holds over
--   that list.
zipAll :: forall {k} (c :: k -> Constraint) (xs :: [k]) (d :: k -> Constraint). Dict (All c) xs -> Dict (All d) xs -> Dict (All (And c d)) xs

-- | If two constraints c and d hold over a type-level
--   list of lists xss, then the combination of both constraints
--   holds over that list of lists.
zipAll2 :: forall {k} (xss :: [[k]]) (c :: k -> Constraint) (d :: k -> Constraint). All (SListI :: [k] -> Constraint) xss => Dict (All2 c) xss -> Dict (All2 d) xss -> Dict (All2 (And c d)) xss

-- | If we have a constraint c that holds over a type-level list
--   xs, we can create a product containing proofs that each
--   individual list element satisfies c.
unAll_NP :: forall {k} (c :: k -> Constraint) (xs :: [k]). Dict (All c) xs -> NP (Dict c) xs

-- | If we have a constraint c that holds over a type-level list
--   of lists xss, we can create a product of products containing
--   proofs that all the inner elements satisfy c.
unAll_POP :: forall {k} (c :: k -> Constraint) (xss :: [[k]]). Dict (All2 c) xss -> POP (Dict c) xss

-- | If we have a product containing proofs that each element of
--   xs satisfies c, then All c holds for
--   xs.
all_NP :: forall {k} (c :: k -> Constraint) (xs :: [k]). NP (Dict c) xs -> Dict (All c) xs

-- | If we have a product of products containing proofs that each inner
--   element of xss satisfies c, then All2
--   c holds for xss.
all_POP :: forall {k} (xss :: [[k]]) (c :: k -> Constraint). SListI xss => POP (Dict c) xss -> Dict (All2 c) xss

-- | The constraint All2 c is convertible to All
--   (All c).

-- | Deprecated: 'All2 c' is now a synonym of 'All (All c)'
unAll2 :: forall {k} (c :: k -> Constraint) (xss :: [[k]]). Dict (All2 c) xss -> Dict (All (All c)) xss

-- | The constraint All (All c) is convertible to
--   All2 c.

-- | Deprecated: 'All2 c' is now a synonym of 'All (All c)'
all2 :: forall {k} (c :: k -> Constraint) (xss :: [[k]]). Dict (All (All c)) xss -> Dict (All2 c) xss

-- | If we have an explicit dictionary, we can unwrap it and pass a
--   function that makes use of it.
withDict :: forall {k} c (a :: k) r. Dict c a -> (c a => r) -> r

-- | A structure of dictionaries.
hdicts :: forall {k} {l} h (c :: k -> Constraint) (xs :: l). (AllN h c xs, HPure h) => h (Dict c) xs
instance forall k (c :: k -> GHC.Types.Constraint) (a :: k). GHC.Internal.Show.Show (Data.SOP.Dict.Dict c a)

-- | Main module of sop-core
module Data.SOP

-- | An n-ary product.
--   
--   The product is parameterized by a type constructor f and
--   indexed by a type-level list xs. The length of the list
--   determines the number of elements in the product, and if the
--   i-th element of the list is of type x, then the
--   i-th element of the product is of type f x.
--   
--   The constructor names are chosen to resemble the names of the list
--   constructors.
--   
--   Two common instantiations of f are the identity functor
--   I and the constant functor K. For I, the product
--   becomes a heterogeneous list, where the type-level list describes the
--   types of its components. For K a, the product becomes
--   a homogeneous list, where the contents of the type-level list are
--   ignored, but its length still specifies the number of elements.
--   
--   In the context of the SOP approach to generic programming, an n-ary
--   product describes the structure of the arguments of a single data
--   constructor.
--   
--   Examples:
--   
--   
--   I 'x'    :* I True  :* Nil  ::  NP I       '[ Char, Bool ]
--   K 0      :* K 1     :* Nil  ::  NP (K Int) '[ Char, Bool ]
--   Just 'x' :* Nothing :* Nil  ::  NP Maybe   '[ Char, Bool ]
--   
data NP (a :: k -> Type) (b :: [k])
[Nil] :: forall {k} (a :: k -> Type). NP a ('[] :: [k])
[:*] :: forall {k} (a :: k -> Type) (x :: k) (xs :: [k]). a x -> NP a xs -> NP a (x ': xs)
infixr 5 :*

-- | An n-ary sum.
--   
--   The sum is parameterized by a type constructor f and indexed
--   by a type-level list xs. The length of the list determines
--   the number of choices in the sum and if the i-th element of
--   the list is of type x, then the i-th choice of the
--   sum is of type f x.
--   
--   The constructor names are chosen to resemble Peano-style natural
--   numbers, i.e., Z is for "zero", and S is for
--   "successor". Chaining S and Z chooses the corresponding
--   component of the sum.
--   
--   Examples:
--   
--   
--   Z         :: f x -> NS f (x ': xs)
--   S . Z     :: f y -> NS f (x ': y ': xs)
--   S . S . Z :: f z -> NS f (x ': y ': z ': xs)
--   ...
--   
--   
--   Note that empty sums (indexed by an empty list) have no non-bottom
--   elements.
--   
--   Two common instantiations of f are the identity functor
--   I and the constant functor K. For I, the sum
--   becomes a direct generalization of the Either type to
--   arbitrarily many choices. For K a, the result is a
--   homogeneous choice type, where the contents of the type-level list are
--   ignored, but its length specifies the number of options.
--   
--   In the context of the SOP approach to generic programming, an n-ary
--   sum describes the top-level structure of a datatype, which is a choice
--   between all of its constructors.
--   
--   Examples:
--   
--   
--   Z (I 'x')      :: NS I       '[ Char, Bool ]
--   S (Z (I True)) :: NS I       '[ Char, Bool ]
--   S (Z (K 1))    :: NS (K Int) '[ Char, Bool ]
--   
data NS (a :: k -> Type) (b :: [k])
[Z] :: forall {k} (a :: k -> Type) (x :: k) (xs :: [k]). a x -> NS a (x ': xs)
[S] :: forall {k} (a :: k -> Type) (xs :: [k]) (x :: k). NS a xs -> NS a (x ': xs)

-- | A sum of products.
--   
--   This is a 'newtype' for an NS of an NP. The elements of
--   the (inner) products are applications of the parameter f. The
--   type SOP is indexed by the list of lists that determines the
--   sizes of both the (outer) sum and all the (inner) products, as well as
--   the types of all the elements of the inner products.
--   
--   A SOP I reflects the structure of a normal
--   Haskell datatype. The sum structure represents the choice between the
--   different constructors, the product structure represents the arguments
--   of each constructor.
newtype SOP (f :: k -> Type) (xss :: [[k]])
SOP :: NS (NP f) xss -> SOP (f :: k -> Type) (xss :: [[k]])

-- | Unwrap a sum of products.
unSOP :: forall {k} (f :: k -> Type) (xss :: [[k]]). SOP f xss -> NS (NP f) xss

-- | A product of products.
--   
--   This is a 'newtype' for an NP of an NP. The elements of
--   the inner products are applications of the parameter f. The
--   type POP is indexed by the list of lists that determines the
--   lengths of both the outer and all the inner products, as well as the
--   types of all the elements of the inner products.
--   
--   A POP is reminiscent of a two-dimensional table (but the inner
--   lists can all be of different length). In the context of the SOP
--   approach to generic programming, a POP is useful to represent
--   information that is available for all arguments of all constructors of
--   a datatype.
newtype POP (f :: k -> Type) (xss :: [[k]])
POP :: NP (NP f) xss -> POP (f :: k -> Type) (xss :: [[k]])

-- | Unwrap a product of products.
unPOP :: forall {k} (f :: k -> Type) (xss :: [[k]]). POP f xss -> NP (NP f) xss

-- | A generalization of pure or return to higher kinds.
class HPure (h :: k -> Type -> l -> Type)

-- | Corresponds to pure directly.
--   
--   Instances:
--   
--   
--   hpure, pure_NP  :: SListI  xs  => (forall a. f a) -> NP  f xs
--   hpure, pure_POP :: SListI2 xss => (forall a. f a) -> POP f xss
--   
hpure :: forall (xs :: l) f. (HPure h, SListIN h xs) => (forall (a :: k). () => f a) -> h f xs

-- | A variant of hpure that allows passing in a constrained
--   argument.
--   
--   Calling hcpure f s where s :: h f xs causes
--   f to be applied at all the types that are contained in
--   xs. Therefore, the constraint c has to be satisfied
--   for all elements of xs, which is what AllN h c
--   xs states.
--   
--   Instances:
--   
--   
--   hcpure, cpure_NP  :: (All  c xs ) => proxy c -> (forall a. c a => f a) -> NP  f xs
--   hcpure, cpure_POP :: (All2 c xss) => proxy c -> (forall a. c a => f a) -> POP f xss
--   
hcpure :: forall c (xs :: l) proxy f. (HPure h, AllN h c xs) => proxy c -> (forall (a :: k). c a => f a) -> h f xs

-- | Obtain the head of an n-ary product.
hd :: forall {k} f (x :: k) (xs :: [k]). NP f (x ': xs) -> f x

-- | Obtain the tail of an n-ary product.
tl :: forall {k} (f :: k -> Type) (x :: k) (xs :: [k]). NP f (x ': xs) -> NP f xs

-- | The type of projections from an n-ary product.
--   
--   A projection is a function from the n-ary product to a single element.
type Projection (f :: k -> Type) (xs :: [k]) = K NP f xs :: k -> Type -.-> f

-- | Compute all projections from an n-ary product.
--   
--   Each element of the resulting product contains one of the projections.
projections :: forall {k} (xs :: [k]) (f :: k -> Type). SListI xs => NP (Projection f xs) xs
shiftProjection :: forall {a1} (f :: a1 -> Type) (xs :: [a1]) (a2 :: a1) (x :: a1). Projection f xs a2 -> Projection f (x ': xs) a2

-- | Lifted functions.
newtype ( (f :: k -> Type) -.-> (g :: k -> Type) ) (a :: k)
Fn :: (f a -> g a) -> (-.->) (f :: k -> Type) (g :: k -> Type) (a :: k)
[apFn] :: (-.->) (f :: k -> Type) (g :: k -> Type) (a :: k) -> f a -> g a
infixr 1 -.->

-- | Construct a lifted function.
--   
--   Same as Fn. Only available for uniformity with the higher-arity
--   versions.
fn :: forall {k} f (a :: k) f'. (f a -> f' a) -> (f -.-> f') a

-- | Construct a binary lifted function.
fn_2 :: forall {k} f (a :: k) f' f''. (f a -> f' a -> f'' a) -> (f -.-> (f' -.-> f'')) a

-- | Construct a ternary lifted function.
fn_3 :: forall {k} f (a :: k) f' f'' f'''. (f a -> f' a -> f'' a -> f''' a) -> (f -.-> (f' -.-> (f'' -.-> f'''))) a

-- | Construct a quarternary lifted function.
fn_4 :: forall {k} f (a :: k) f' f'' f''' f''''. (f a -> f' a -> f'' a -> f''' a -> f'''' a) -> (f -.-> (f' -.-> (f'' -.-> (f''' -.-> f'''')))) a

-- | Maps a structure containing sums to the corresponding product
--   structure.
type family Prod (h :: k -> Type -> l -> Type) :: k -> Type -> l -> Type

-- | A generalization of <*>.
class (Prod Prod h ~ Prod h, HPure Prod h) => HAp (h :: k -> Type -> l -> Type)

-- | Corresponds to <*>.
--   
--   For products (NP) as well as products of products (POP),
--   the correspondence is rather direct. We combine a structure containing
--   (lifted) functions and a compatible structure containing corresponding
--   arguments into a compatible structure containing results.
--   
--   The same combinator can also be used to combine a product structure of
--   functions with a sum structure of arguments, which then results in
--   another sum structure of results. The sum structure determines which
--   part of the product structure will be used.
--   
--   Instances:
--   
--   
--   hap, ap_NP  :: NP  (f -.-> g) xs  -> NP  f xs  -> NP  g xs
--   hap, ap_NS  :: NP  (f -.-> g) xs  -> NS  f xs  -> NS  g xs
--   hap, ap_POP :: POP (f -.-> g) xss -> POP f xss -> POP g xss
--   hap, ap_SOP :: POP (f -.-> g) xss -> SOP f xss -> SOP g xss
--   
hap :: forall (f :: k -> Type) (g :: k -> Type) (xs :: l). HAp h => Prod h (f -.-> g) xs -> h f xs -> h g xs

-- | A generalized form of liftA, which in turn is a generalized
--   map.
--   
--   Takes a lifted function and applies it to every element of a structure
--   while preserving its shape.
--   
--   Specification:
--   
--   
--   hliftA f xs = hpure (fn f) ` <a>hap</a> ` xs
--   
--   
--   Instances:
--   
--   
--   hliftA, liftA_NP  :: SListI  xs  => (forall a. f a -> f' a) -> NP  f xs  -> NP  f' xs
--   hliftA, liftA_NS  :: SListI  xs  => (forall a. f a -> f' a) -> NS  f xs  -> NS  f' xs
--   hliftA, liftA_POP :: SListI2 xss => (forall a. f a -> f' a) -> POP f xss -> POP f' xss
--   hliftA, liftA_SOP :: SListI2 xss => (forall a. f a -> f' a) -> SOP f xss -> SOP f' xss
--   
hliftA :: forall {k} {l} h (xs :: l) f f'. (SListIN (Prod h) xs, HAp h) => (forall (a :: k). () => f a -> f' a) -> h f xs -> h f' xs

-- | A generalized form of liftA2, which in turn is a generalized
--   zipWith.
--   
--   Takes a lifted binary function and uses it to combine two structures
--   of equal shape into a single structure.
--   
--   It either takes two product structures to a product structure, or one
--   product and one sum structure to a sum structure.
--   
--   Specification:
--   
--   
--   hliftA2 f xs ys = hpure (fn_2 f) ` <a>hap</a> ` xs ` <a>hap</a> ` ys
--   
--   
--   Instances:
--   
--   
--   hliftA2, liftA2_NP  :: SListI  xs  => (forall a. f a -> f' a -> f'' a) -> NP  f xs  -> NP  f' xs  -> NP  f'' xs
--   hliftA2, liftA2_NS  :: SListI  xs  => (forall a. f a -> f' a -> f'' a) -> NP  f xs  -> NS  f' xs  -> NS  f'' xs
--   hliftA2, liftA2_POP :: SListI2 xss => (forall a. f a -> f' a -> f'' a) -> POP f xss -> POP f' xss -> POP f'' xss
--   hliftA2, liftA2_SOP :: SListI2 xss => (forall a. f a -> f' a -> f'' a) -> POP f xss -> SOP f' xss -> SOP f'' xss
--   
hliftA2 :: forall {k} {l} h (xs :: l) f f' f''. (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

-- | A generalized form of liftA3, which in turn is a generalized
--   zipWith3.
--   
--   Takes a lifted ternary function and uses it to combine three
--   structures of equal shape into a single structure.
--   
--   It either takes three product structures to a product structure, or
--   two product structures and one sum structure to a sum structure.
--   
--   Specification:
--   
--   
--   hliftA3 f xs ys zs = hpure (fn_3 f) ` <a>hap</a> ` xs ` <a>hap</a> ` ys ` <a>hap</a> ` zs
--   
--   
--   Instances:
--   
--   
--   hliftA3, liftA3_NP  :: SListI  xs  => (forall a. f a -> f' a -> f'' a -> f''' a) -> NP  f xs  -> NP  f' xs  -> NP  f'' xs  -> NP  f''' xs
--   hliftA3, liftA3_NS  :: SListI  xs  => (forall a. f a -> f' a -> f'' a -> f''' a) -> NP  f xs  -> NP  f' xs  -> NS  f'' xs  -> NS  f''' xs
--   hliftA3, liftA3_POP :: SListI2 xss => (forall a. f a -> f' a -> f'' a -> f''' a) -> POP f xss -> POP f' xss -> POP f'' xss -> POP f''' xs
--   hliftA3, liftA3_SOP :: SListI2 xss => (forall a. f a -> f' a -> f'' a -> f''' a) -> POP f xss -> POP f' xss -> SOP f'' xss -> SOP f''' xs
--   
hliftA3 :: forall {k} {l} h (xs :: l) f f' f'' f'''. (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

-- | Variant of hliftA that takes a constrained function.
--   
--   Specification:
--   
--   
--   hcliftA p f xs = hcpure p (fn f) ` <a>hap</a> ` xs
--   
hcliftA :: forall {k} {l} h c (xs :: l) proxy f f'. (AllN (Prod h) c xs, HAp h) => proxy c -> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs

-- | Variant of hliftA2 that takes a constrained function.
--   
--   Specification:
--   
--   
--   hcliftA2 p f xs ys = hcpure p (fn_2 f) ` <a>hap</a> ` xs ` <a>hap</a> ` ys
--   
hcliftA2 :: forall {k} {l} h c (xs :: l) proxy f f' f''. (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

-- | Variant of hliftA3 that takes a constrained function.
--   
--   Specification:
--   
--   
--   hcliftA3 p f xs ys zs = hcpure p (fn_3 f) ` <a>hap</a> ` xs ` <a>hap</a> ` ys ` <a>hap</a> ` zs
--   
hcliftA3 :: forall {k} {l} h c (xs :: l) proxy f f' f'' f'''. (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

-- | Another name for hliftA.
hmap :: forall {k} {l} h (xs :: l) f f'. (SListIN (Prod h) xs, HAp h) => (forall (a :: k). () => f a -> f' a) -> h f xs -> h f' xs

-- | Another name for hliftA2.
hzipWith :: forall {k} {l} h (xs :: l) f f' f''. (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

-- | Another name for hliftA3.
hzipWith3 :: forall {k} {l} h (xs :: l) f f' f'' f'''. (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

-- | Another name for hcliftA.
hcmap :: forall {k} {l} h c (xs :: l) proxy f f'. (AllN (Prod h) c xs, HAp h) => proxy c -> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs

-- | Another name for hcliftA2.
hczipWith :: forall {k} {l} h c (xs :: l) proxy f f' f''. (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

-- | Another name for hcliftA3.
hczipWith3 :: forall {k} {l} h c (xs :: l) proxy f f' f'' f'''. (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

-- | The type of injections into an n-ary sum.
--   
--   If you expand the type synonyms and newtypes involved, you get
--   
--   
--   Injection f xs a = (f -.-> K (NS f xs)) a ~= f a -> K (NS f xs) a ~= f a -> NS f xs
--   
--   
--   If we pick a to be an element of xs, this indeed
--   corresponds to an injection into the sum.
type Injection (f :: k -> Type) (xs :: [k]) = f -.-> K NS f xs :: k -> Type

-- | Compute all injections into an n-ary sum.
--   
--   Each element of the resulting product contains one of the injections.
injections :: forall {k} (xs :: [k]) (f :: k -> Type). SListI xs => NP (Injection f xs) xs

-- | Shift an injection.
--   
--   Given an injection, return an injection into a sum that is one
--   component larger.

-- | Deprecated: Use shiftInjection instead.
shift :: forall {a1} (f :: a1 -> Type) (xs :: [a1]) (a2 :: a1) (x :: a1). Injection f xs a2 -> Injection f (x ': xs) a2

-- | Shift an injection.
--   
--   Given an injection, return an injection into a sum that is one
--   component larger.
shiftInjection :: forall {a1} (f :: a1 -> Type) (xs :: [a1]) (a2 :: a1) (x :: a1). Injection f xs a2 -> Injection f (x ': xs) a2

-- | Maps a structure containing products to the corresponding sum
--   structure.
type family UnProd (h :: k -> Type -> l -> Type) :: k -> Type -> l -> Type

-- | A class for applying all injections corresponding to a sum-like
--   structure to a table containing suitable arguments.
class UnProd Prod h ~ h => HApInjs (h :: k -> Type -> l -> Type)

-- | For a given table (product-like structure), produce a list where each
--   element corresponds to the application of an injection function into
--   the corresponding sum-like structure.
--   
--   Instances:
--   
--   
--   hapInjs, apInjs_NP  :: SListI  xs  => NP  f xs -> [NS  f xs ]
--   hapInjs, apInjs_SOP :: SListI2 xss => POP f xs -> [SOP f xss]
--   
--   
--   Examples:
--   
--   
--   >>> hapInjs (I 'x' :* I True :* I 2 :* Nil) :: [NS I '[Char, Bool, Int]]
--   [Z (I 'x'),S (Z (I True)),S (S (Z (I 2)))]
--   
--   
--   
--   >>> hapInjs (POP ((I 'x' :* Nil) :* (I True :* I 2 :* Nil) :* Nil)) :: [SOP I '[ '[Char], '[Bool, Int]]]
--   [SOP (Z (I 'x' :* Nil)),SOP (S (Z (I True :* I 2 :* Nil)))]
--   
--   
--   Unfortunately the type-signatures are required in GHC-7.10 and older.
hapInjs :: forall (xs :: l) (f :: k -> Type). (HApInjs h, SListIN h xs) => Prod h f xs -> [h f xs]

-- | Apply injections to a product.
--   
--   Given a product containing all possible choices, produce a list of
--   sums by applying each injection to the appropriate element.
--   
--   Example:
--   
--   
--   >>> apInjs_NP (I 'x' :* I True :* I 2 :* Nil)
--   [Z (I 'x'),S (Z (I True)),S (S (Z (I 2)))]
--   
apInjs_NP :: forall {k} (xs :: [k]) (f :: k -> Type). SListI xs => NP f xs -> [NS f xs]

-- | Apply injections to a product of product.
--   
--   This operates on the outer product only. Given a product containing
--   all possible choices (that are products), produce a list of sums (of
--   products) by applying each injection to the appropriate element.
--   
--   Example:
--   
--   
--   >>> apInjs_POP (POP ((I 'x' :* Nil) :* (I True :* I 2 :* Nil) :* Nil))
--   [SOP (Z (I 'x' :* Nil)),SOP (S (Z (I True :* I 2 :* Nil)))]
--   
apInjs_POP :: forall {k} (xss :: [[k]]) (f :: k -> Type). SListI xss => POP f xss -> [SOP f xss]

-- | Extract the payload from a unary sum.
--   
--   For larger sums, this function would be partial, so it is only
--   provided with a rather restrictive type.
--   
--   Example:
--   
--   
--   >>> unZ (Z (I 'x'))
--   I 'x'
--   
unZ :: forall {k} f (x :: k). NS f '[x] -> f x

-- | A class for determining which choice in a sum-like structure a value
--   represents.
class HIndex (h :: k -> Type -> l -> Type)

-- | If h is a sum-like structure representing a choice between
--   n different options, and x is a value of type h
--   f xs, then hindex x returns a number between
--   0 and n - 1 representing the index of the choice
--   made by x.
--   
--   Instances:
--   
--   
--   hindex, index_NS  :: NS  f xs -> Int
--   hindex, index_SOP :: SOP f xs -> Int
--   
--   
--   Examples:
--   
--   
--   >>> hindex (S (S (Z (I False))))
--   2
--   
--   >>> hindex (Z (K ()))
--   0
--   
--   >>> hindex (SOP (S (Z (I True :* I 'x' :* Nil))))
--   1
--   
hindex :: forall (f :: k -> Type) (xs :: l). HIndex h => h f xs -> Int

-- | Lift a constrained function operating on a list-indexed structure to a
--   function on a list-of-list-indexed structure.
--   
--   This is a variant of hcliftA.
--   
--   Specification:
--   
--   
--   hcliftA' p f xs = hpure (fn_2 $ \ AllDictC -> f) ` <a>hap</a> ` allDict_NP p ` <a>hap</a> ` xs
--   
--   
--   Instances:
--   
--   
--   hcliftA' :: All2 c xss => proxy c -> (forall xs. All c xs => f xs -> f' xs) -> NP f xss -> NP f' xss
--   hcliftA' :: All2 c xss => proxy c -> (forall xs. All c xs => f xs -> f' xs) -> NS f xss -> NS f' xss
--   

-- | Deprecated: Use hcliftA or hcmap instead.
hcliftA' :: forall {k} (c :: k -> Constraint) (xss :: [[k]]) h proxy f f'. (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

-- | Like hcliftA', but for binary functions.

-- | Deprecated: Use hcliftA2 or hczipWith instead.
hcliftA2' :: forall {k} (c :: k -> Constraint) (xss :: [[k]]) h proxy f f' f''. (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

-- | Like hcliftA', but for ternary functions.

-- | Deprecated: Use hcliftA3 or hczipWith3 instead.
hcliftA3' :: forall {k} (c :: k -> Constraint) (xss :: [[k]]) h proxy f f' f'' f'''. (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 two sums with respect to the choice they are making.
--   
--   A value that chooses the first option is considered smaller than one
--   that chooses the second option.
--   
--   If the choices are different, then either the first (if the first is
--   smaller than the second) or the third (if the first is larger than the
--   second) argument are called. If both choices are equal, then the
--   second argument is called, which has access to the elements contained
--   in the sums.
compare_NS :: forall {k} r f g (xs :: [k]). r -> (forall (x :: k). () => f x -> g x -> r) -> r -> NS f xs -> NS g xs -> r

-- | Constrained version of compare_NS.
ccompare_NS :: forall {k} c proxy r f g (xs :: [k]). 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 two sums of products with respect to the choice in the sum
--   they are making.
--   
--   Only the sum structure is used for comparison. This is a small wrapper
--   around ccompare_NS for a common special case.
compare_SOP :: forall {k} r (f :: k -> Type) (g :: k -> Type) (xss :: [[k]]). r -> (forall (xs :: [k]). () => NP f xs -> NP g xs -> r) -> r -> SOP f xss -> SOP g xss -> r

-- | Constrained version of compare_SOP.
ccompare_SOP :: forall {k} (c :: k -> Constraint) proxy r (f :: k -> Type) (g :: k -> Type) (xss :: [[k]]). 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

-- | Maps products to lists, and sums to identities.
type family CollapseTo (h :: k -> Type -> l -> Type) x

-- | A class for collapsing a heterogeneous structure into a homogeneous
--   one.
class HCollapse (h :: k -> Type -> l -> Type)

-- | Collapse a heterogeneous structure with homogeneous elements into a
--   homogeneous structure.
--   
--   If a heterogeneous structure is instantiated to the constant functor
--   K, then it is in fact homogeneous. This function maps such a
--   value to a simpler Haskell datatype reflecting that. An NS
--   (K a) contains a single a, and an NP
--   (K a) contains a list of as.
--   
--   Instances:
--   
--   
--   hcollapse, collapse_NP  :: NP  (K a) xs  ->  [a]
--   hcollapse, collapse_NS  :: NS  (K a) xs  ->   a
--   hcollapse, collapse_POP :: POP (K a) xss -> [[a]]
--   hcollapse, collapse_SOP :: SOP (K a) xss ->  [a]
--   
hcollapse :: forall (xs :: l) a. (HCollapse h, SListIN h xs) => h (K a :: k -> Type) xs -> CollapseTo h a

-- | A generalization of traverse_ or foldMap.
class HTraverse_ (h :: k -> Type -> l -> Type)

-- | Corresponds to traverse_.
--   
--   Instances:
--   
--   
--   hctraverse_, ctraverse__NP  :: (All  c xs , Applicative g) => proxy c -> (forall a. c a => f a -> g ()) -> NP  f xs  -> g ()
--   hctraverse_, ctraverse__NS  :: (All2 c xs , Applicative g) => proxy c -> (forall a. c a => f a -> g ()) -> NS  f xs  -> g ()
--   hctraverse_, ctraverse__POP :: (All  c xss, Applicative g) => proxy c -> (forall a. c a => f a -> g ()) -> POP f xss -> g ()
--   hctraverse_, ctraverse__SOP :: (All2 c xss, Applicative g) => proxy c -> (forall a. c a => f a -> g ()) -> SOP f xss -> g ()
--   
hctraverse_ :: forall c (xs :: l) g proxy f. (HTraverse_ h, AllN h c xs, Applicative g) => proxy c -> (forall (a :: k). c a => f a -> g ()) -> h f xs -> g ()

-- | Unconstrained version of hctraverse_.
--   
--   Instances:
--   
--   
--   traverse_, traverse__NP  :: (SListI  xs , Applicative g) => (forall a. f a -> g ()) -> NP  f xs  -> g ()
--   traverse_, traverse__NS  :: (SListI  xs , Applicative g) => (forall a. f a -> g ()) -> NS  f xs  -> g ()
--   traverse_, traverse__POP :: (SListI2 xss, Applicative g) => (forall a. f a -> g ()) -> POP f xss -> g ()
--   traverse_, traverse__SOP :: (SListI2 xss, Applicative g) => (forall a. f a -> g ()) -> SOP f xss -> g ()
--   
htraverse_ :: forall (xs :: l) g f. (HTraverse_ h, SListIN h xs, Applicative g) => (forall (a :: k). () => f a -> g ()) -> h f xs -> g ()

-- | Special case of hctraverse_.
hcfoldMap :: forall {k} {l} h c (xs :: l) m proxy f. (HTraverse_ h, AllN h c xs, Monoid m) => proxy c -> (forall (a :: k). c a => f a -> m) -> h f xs -> m

-- | Flipped version of hctraverse_.
hcfor_ :: forall {k} {l} h c (xs :: l) g proxy f. (HTraverse_ h, AllN h c xs, Applicative g) => proxy c -> h f xs -> (forall (a :: k). c a => f a -> g ()) -> g ()

-- | A generalization of sequenceA.
class HAp h => HSequence (h :: k -> Type -> l -> Type)

-- | Corresponds to sequenceA.
--   
--   Lifts an applicative functor out of a structure.
--   
--   Instances:
--   
--   
--   hsequence', sequence'_NP  :: (SListI  xs , Applicative f) => NP  (f :.: g) xs  -> f (NP  g xs )
--   hsequence', sequence'_NS  :: (SListI  xs , Applicative f) => NS  (f :.: g) xs  -> f (NS  g xs )
--   hsequence', sequence'_POP :: (SListI2 xss, Applicative f) => POP (f :.: g) xss -> f (POP g xss)
--   hsequence', sequence'_SOP :: (SListI2 xss, Applicative f) => SOP (f :.: g) xss -> f (SOP g xss)
--   
hsequence' :: forall (xs :: l) f (g :: k -> Type). (HSequence h, SListIN h xs, Applicative f) => h (f :.: g) xs -> f (h g xs)

-- | Corresponds to traverse.
--   
--   Instances:
--   
--   
--   hctraverse', ctraverse'_NP  :: (All  c xs , Applicative g) => proxy c -> (forall a. c a => f a -> g (f' a)) -> NP  f xs  -> g (NP  f' xs )
--   hctraverse', ctraverse'_NS  :: (All2 c xs , Applicative g) => proxy c -> (forall a. c a => f a -> g (f' a)) -> NS  f xs  -> g (NS  f' xs )
--   hctraverse', ctraverse'_POP :: (All  c xss, Applicative g) => proxy c -> (forall a. c a => f a -> g (f' a)) -> POP f xss -> g (POP f' xss)
--   hctraverse', ctraverse'_SOP :: (All2 c xss, Applicative g) => proxy c -> (forall a. c a => f a -> g (f' a)) -> SOP f xss -> g (SOP f' xss)
--   
hctraverse' :: forall c (xs :: l) g proxy f f'. (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)

-- | Unconstrained variant of hctraverse'.
--   
--   Instances:
--   
--   
--   htraverse', traverse'_NP  :: (SListI  xs , Applicative g) => (forall a. c a => f a -> g (f' a)) -> NP  f xs  -> g (NP  f' xs )
--   htraverse', traverse'_NS  :: (SListI2 xs , Applicative g) => (forall a. c a => f a -> g (f' a)) -> NS  f xs  -> g (NS  f' xs )
--   htraverse', traverse'_POP :: (SListI  xss, Applicative g) => (forall a. c a => f a -> g (f' a)) -> POP f xss -> g (POP f' xss)
--   htraverse', traverse'_SOP :: (SListI2 xss, Applicative g) => (forall a. c a => f a -> g (f' a)) -> SOP f xss -> g (SOP f' xss)
--   
htraverse' :: forall (xs :: l) g f f'. (HSequence h, SListIN h xs, Applicative g) => (forall (a :: k). () => f a -> g (f' a)) -> h f xs -> g (h f' xs)

-- | Special case of hsequence' where g = I.
hsequence :: forall {l} h (xs :: l) f. (SListIN h xs, SListIN (Prod h) xs, HSequence h, Applicative f) => h f xs -> f (h I xs)

-- | Special case of hsequence' where g = K a.
hsequenceK :: forall {k} {l} h (xs :: l) f a. (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)

-- | Special case of hctraverse' where f' = I.
hctraverse :: forall {l} h c (xs :: l) g proxy f. (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)

-- | Flipped version of hctraverse.
hcfor :: forall {l} h c (xs :: l) g proxy f. (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)

-- | A class for expanding sum structures into corresponding product
--   structures, filling in the slots not targeted by the sum with default
--   values.
class HExpand (h :: k -> Type -> l -> Type)

-- | Expand a given sum structure into a corresponding product structure by
--   placing the value contained in the sum into the corresponding position
--   in the product, and using the given default value for all other
--   positions.
--   
--   Instances:
--   
--   
--   hexpand, expand_NS  :: SListI xs   => (forall x . f x) -> NS  f xs  -> NP  f xs
--   hexpand, expand_SOP :: SListI2 xss => (forall x . f x) -> SOP f xss -> POP f xss
--   
--   
--   Examples:
--   
--   
--   >>> hexpand Nothing (S (Z (Just 3))) :: NP Maybe '[Char, Int, Bool]
--   Nothing :* Just 3 :* Nothing :* Nil
--   
--   >>> hexpand [] (SOP (S (Z ([1,2] :* "xyz" :* Nil)))) :: POP [] '[ '[Bool], '[Int, Char] ]
--   POP (([] :* Nil) :* ([1,2] :* "xyz" :* Nil) :* Nil)
--   
hexpand :: forall (xs :: l) f. (HExpand h, SListIN (Prod h) xs) => (forall (x :: k). () => f x) -> h f xs -> Prod h f xs

-- | Variant of hexpand that allows passing a constrained default.
--   
--   Instances:
--   
--   
--   hcexpand, cexpand_NS  :: All  c xs  => proxy c -> (forall x . c x => f x) -> NS  f xs  -> NP  f xs
--   hcexpand, cexpand_SOP :: All2 c xss => proxy c -> (forall x . c x => f x) -> SOP f xss -> POP f xss
--   
--   
--   Examples:
--   
--   
--   >>> hcexpand (Proxy :: Proxy Bounded) (I minBound) (S (Z (I 20))) :: NP I '[Bool, Int, Ordering]
--   I False :* I 20 :* I LT :* Nil
--   
--   >>> hcexpand (Proxy :: Proxy Num) (I 0) (SOP (S (Z (I 1 :* I 2 :* Nil)))) :: POP I '[ '[Double], '[Int, Int] ]
--   POP ((I 0.0 :* Nil) :* (I 1 :* I 2 :* Nil) :* Nil)
--   
hcexpand :: forall c (xs :: l) proxy f. (HExpand h, AllN (Prod h) c xs) => proxy c -> (forall (x :: k). c x => f x) -> h f xs -> Prod h f xs

-- | A class for transforming structures into related structures with a
--   different index list, as long as the index lists have the same shape
--   and the elements and interpretation functions are suitably related.
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)

-- | Transform a structure into a related structure given a conversion
--   function for the elements.
htrans :: forall c (xs :: l1) (ys :: l2) proxy f g. (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

-- | Safely coerce a structure into a representationally equal structure.
--   
--   This is a special case of htrans, but can be implemented more
--   efficiently; for example in terms of unsafeCoerce.
--   
--   Examples:
--   
--   
--   >>> hcoerce (I (Just LT) :* I (Just 'x') :* I (Just True) :* Nil) :: NP Maybe '[Ordering, Char, Bool]
--   Just LT :* Just 'x' :* Just True :* Nil
--   
--   >>> hcoerce (SOP (Z (K True :* K False :* Nil))) :: SOP I '[ '[Bool, Bool], '[Bool] ]
--   SOP (Z (I True :* I False :* Nil))
--   
hcoerce :: forall (f :: k1 -> Type) (g :: k2 -> Type) (xs :: l1) (ys :: l2). (HTrans h1 h2, AllZipN (Prod h1) (LiftedCoercible f g) xs ys) => h1 f xs -> h2 g ys

-- | Specialization of hcoerce.
hfromI :: forall {l1} {k2} {l2} h1 (f :: k2 -> Type) (xs :: l1) (ys :: l2) h2. (AllZipN (Prod h1) (LiftedCoercible I f) xs ys, HTrans h1 h2) => h1 I xs -> h2 f ys

-- | Specialization of hcoerce.
htoI :: forall {k1} {l1} {l2} h1 (f :: k1 -> Type) (xs :: l1) (ys :: l2) h2. (AllZipN (Prod h1) (LiftedCoercible f I) xs ys, HTrans h1 h2) => h1 f xs -> h2 I ys

-- | Construct a homogeneous n-ary product from a normal Haskell list.
--   
--   Returns Nothing if the length of the list does not exactly
--   match the expected size of the product.
fromList :: forall {k} (xs :: [k]) a. SListI xs => [a] -> Maybe (NP (K a :: k -> Type) xs)

-- | The constant type functor.
--   
--   Like Constant, but kind-polymorphic in its second argument and
--   with a shorter name.
newtype K a (b :: k)
K :: a -> K a (b :: k)

-- | Extract the contents of a K value.
unK :: forall {k} a (b :: k). K a b -> a

-- | The identity type functor.
--   
--   Like Identity, but with a shorter name.
newtype I a
I :: a -> I a

-- | Extract the contents of an I value.
unI :: I a -> a

-- | Composition of functors.
--   
--   Like Compose, but kind-polymorphic and with a shorter name.
newtype ( (f :: l -> Type) :.: (g :: k -> l) ) (p :: k)
Comp :: f (g p) -> (:.:) (f :: l -> Type) (g :: k -> l) (p :: k)
infixr 7 :.:

-- | Extract the contents of a Comp value.
unComp :: forall {l} {k} f (g :: k -> l) (p :: k). (f :.: g) p -> f (g p)

-- | Lift the given function.
mapII :: (a -> b) -> I a -> I b

-- | Lift the given function.
mapIK :: forall {k} a b (c :: k). (a -> b) -> I a -> K b c

-- | Lift the given function.
mapKI :: forall {k} a b (c :: k). (a -> b) -> K a c -> I b

-- | Lift the given function.
mapKK :: forall {k1} {k2} a b (c :: k1) (d :: k2). (a -> b) -> K a c -> K b d

-- | Lift the given function.
mapIII :: (a -> b -> c) -> I a -> I b -> I c

-- | Lift the given function.
mapIIK :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> I b -> K c d

-- | Lift the given function.
mapIKI :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> K b d -> I c

-- | Lift the given function.
mapIKK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> I a -> K b d -> K c e

-- | Lift the given function.
mapKII :: forall {k} a b c (d :: k). (a -> b -> c) -> K a d -> I b -> I c

-- | Lift the given function.
mapKIK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> I b -> K c e

-- | Lift the given function.
mapKKI :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> K b e -> I c

-- | Lift the given function.
mapKKK :: forall {k1} {k2} {k3} a b c (d :: k1) (e :: k2) (f :: k3). (a -> b -> c) -> K a d -> K b e -> K c f

-- | Require a constraint for every element of a list.
--   
--   If you have a datatype that is indexed over a type-level list, then
--   you can use All to indicate that all elements of that
--   type-level list must satisfy a given constraint.
--   
--   Example: The constraint
--   
--   
--   All Eq '[ Int, Bool, Char ]
--   
--   
--   is equivalent to the constraint
--   
--   
--   (Eq Int, Eq Bool, Eq Char)
--   
--   
--   Example: A type signature such as
--   
--   
--   f :: All Eq xs => NP I xs -> ...
--   
--   
--   means that f can assume that all elements of the n-ary
--   product satisfy Eq.
--   
--   Note on superclasses: ghc cannot deduce superclasses from All
--   constraints. You might expect the following to compile
--   
--   
--   class (Eq a) => MyClass a
--   
--   foo :: (All Eq xs) => NP f xs -> z
--   foo = [..]
--   
--   bar :: (All MyClass xs) => NP f xs -> x
--   bar = foo
--   
--   
--   but it will fail with an error saying that it was unable to deduce the
--   class constraint AllF Eq xs (or similar) in the
--   definition of bar. In cases like this you can use Dict
--   from Data.SOP.Dict to prove conversions between constraints.
--   See this answer on SO for more details.
class (AllF c xs, SListI xs) => All (c :: k -> Constraint) (xs :: [k])

-- | Require a constraint for every element of a list of lists.
--   
--   If you have a datatype that is indexed over a type-level list of
--   lists, then you can use All2 to indicate that all elements of
--   the inner lists must satisfy a given constraint.
--   
--   Example: The constraint
--   
--   
--   All2 Eq '[ '[ Int ], '[ Bool, Char ] ]
--   
--   
--   is equivalent to the constraint
--   
--   
--   (Eq Int, Eq Bool, Eq Char)
--   
--   
--   Example: A type signature such as
--   
--   
--   f :: All2 Eq xss => SOP I xs -> ...
--   
--   
--   means that f can assume that all elements of the sum of
--   product satisfy Eq.
--   
--   Since 0.4.0.0, this is merely a synonym for 'All (All c)'.
type All2 (c :: k -> Constraint) = All All c

-- | Constrained paramorphism for a type-level list.
--   
--   The advantage of writing functions in terms of cpara_SList is
--   that they are then typically not recursive, and can be unfolded
--   statically if the type-level list is statically known.
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

-- | Constrained case distinction on a type-level list.
ccase_SList :: forall {a} c (xs :: [a]) proxy r. All c xs => proxy c -> r ('[] :: [a]) -> (forall (y :: a) (ys :: [a]). (c y, All c ys) => r (y ': ys)) -> r xs

-- | Require a constraint pointwise for every pair of elements from two
--   lists.
--   
--   Example: The constraint
--   
--   
--   AllZip (~) '[ Int, Bool, Char ] '[ a, b, c ]
--   
--   
--   is equivalent to the constraint
--   
--   
--   (Int ~ a, Bool ~ b, Char ~ c)
--   
class (SListI xs, SListI ys, SameShapeAs xs ys, SameShapeAs ys xs, AllZipF c xs ys) => AllZip (c :: a -> b -> Constraint) (xs :: [a]) (ys :: [b])

-- | Require a constraint pointwise for every pair of elements from two
--   lists of lists.
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]])

-- | A generalization of All and All2.
--   
--   The family AllN expands to All or All2 depending
--   on whether the argument is indexed by a list or a list of lists.
type family AllN (h :: k -> Type -> l -> Type) (c :: k -> Constraint) :: l -> Constraint

-- | A generalization of AllZip and AllZip2.
--   
--   The family AllZipN expands to AllZip or AllZip2
--   depending on whther the argument is indexed by a list or a list of
--   lists.
type family AllZipN (h :: k -> Type -> l -> Type) (c :: k1 -> k2 -> Constraint) :: l1 -> l2 -> Constraint

-- | Composition of constraints.
--   
--   Note that the result of the composition must be a constraint, and
--   therefore, in Compose f g, the kind of f is
--   k -> Constraint. The kind of g, however,
--   is l -> k and can thus be a normal type constructor.
--   
--   A typical use case is in connection with All on an NP or
--   an NS. For example, in order to denote that all elements on an
--   NP f xs satisfy Show, we can say All
--   (Compose Show f) xs.
class f g x => Compose (f :: k -> Constraint) (g :: k1 -> k) (x :: k1)
infixr 9 `Compose`

-- | Pairing of constraints.
class (f x, g x) => And (f :: k -> Constraint) (g :: k -> Constraint) (x :: k)
infixl 7 `And`

-- | A constraint that can always be satisfied.
class Top (x :: k)

-- | The constraint LiftedCoercible f g x y is equivalent
--   to Coercible (f x) (g y).
class Coercible f x g y => LiftedCoercible (f :: k -> k1) (g :: k2 -> k1) (x :: k) (y :: k2)

-- | Type family that forces a type-level list to be of the same shape as
--   the given type-level list.
--   
--   Since 0.5.0.0, this only tests the top-level structure of the list,
--   and is intended to be used in conjunction with a separate construct
--   (such as the AllZip, AllZipF combination to tie the
--   recursive knot). The reason is that making SameShapeAs directly
--   recursive leads to quadratic compile times.
--   
--   The main use of this constraint is to help type inference to learn
--   something about otherwise unknown type-level lists.
type family SameShapeAs (xs :: [a]) (ys :: [b])

-- | Explicit singleton list.
--   
--   A singleton list can be used to reveal the structure of a type-level
--   list argument that the function is quantified over. For every
--   type-level list xs, there is one non-bottom value of type
--   SList xs.
--   
--   Note that these singleton lists are polymorphic in the list elements;
--   we do not require a singleton representation for them.
data SList (a :: [k])
[SNil] :: forall {k}. SList ('[] :: [k])
[SCons] :: forall {k} (xs :: [k]) (x :: k). SListI xs => SList (x ': xs)

-- | Implicit singleton list.
--   
--   A singleton list can be used to reveal the structure of a type-level
--   list argument that the function is quantified over.
--   
--   Since 0.4.0.0, this is now defined in terms of All. A singleton
--   list provides a witness for a type-level list where the elements need
--   not satisfy any additional constraints.
type SListI = All Top :: k -> Constraint

-- | Require a singleton for every inner list in a list of lists.
type SListI2 = All SListI :: [k] -> Constraint

-- | Get hold of an explicit singleton (that one can then pattern match on)
--   for a type-level list
sList :: forall {k} (xs :: [k]). SListI xs => SList xs

-- | Paramorphism for a type-level list.
para_SList :: forall {a} (xs :: [a]) r. SListI xs => r ('[] :: [a]) -> (forall (y :: a) (ys :: [a]). SListI ys => r ys -> r (y ': ys)) -> r xs

-- | Case distinction on a type-level list.
case_SList :: forall {a} (xs :: [a]) r. SListI xs => r ('[] :: [a]) -> (forall (y :: a) (ys :: [a]). SListI ys => r (y ': ys)) -> r xs

-- | Occasionally it is useful to have an explicit, term-level,
--   representation of type-level lists (esp because of
--   https://ghc.haskell.org/trac/ghc/ticket/9108 )
data Shape (a :: [k])
[ShapeNil] :: forall {k}. Shape ('[] :: [k])
[ShapeCons] :: forall {k} (xs :: [k]) (x :: k). SListI xs => Shape xs -> Shape (x ': xs)

-- | The shape of a type-level list.
shape :: forall k (xs :: [k]). SListI xs => Shape xs

-- | The length of a type-level list.
lengthSList :: forall k (xs :: [k]) proxy. SListI xs => proxy xs -> Int

-- | Proxy 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, Proxy :: Proxy a is a safer
--   alternative to the undefined :: a idiom.
--   
--   
--   >>> Proxy :: Proxy (Void, Int -> Int)
--   Proxy
--   
--   
--   Proxy can even hold types of higher kinds,
--   
--   
--   >>> Proxy :: Proxy Either
--   Proxy
--   
--   
--   
--   >>> Proxy :: Proxy Functor
--   Proxy
--   
--   
--   
--   >>> Proxy :: Proxy complicatedStructure
--   Proxy
--   
data Proxy (t :: k)
Proxy :: Proxy (t :: k)
