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


-- | Generic programming in GHC style for arbitrary kinds and GADTs.
--   
--   This package provides functionality to extend the data type generic
--   programming functionality in GHC to classes of arbitrary kind, and
--   constructors featuring constraints and existentials, as usually gound
--   in GADTs.
@package kind-generics
@version 0.3.0.0


-- | Main module of <tt>kind-generics</tt>. Please refer to the
--   <tt>README</tt> file for documentation on how to use this package.
module Generics.Kind

-- | Sums: encode choice between constructors
data (:+:) (f :: k -> Type) (g :: k -> Type) (p :: k) :: forall k. () => k -> Type -> k -> Type -> k -> Type
L1 :: f p -> (:+:)
R1 :: g p -> (:+:)
infixr 5 :+:

-- | Products: encode multiple arguments to constructors
data (:*:) (f :: k -> Type) (g :: k -> Type) (p :: k) :: forall k. () => k -> Type -> k -> Type -> k -> Type
(:*:) :: f p -> g p -> (:*:)
infixr 6 :*:
infixr 6 :*:

-- | Void: used for datatypes without constructors
data V1 (p :: k) :: forall k. () => k -> Type

-- | Unit: used for constructors without arguments
data U1 (p :: k) :: forall k. () => k -> Type
U1 :: U1

-- | Meta-information (constructor names, etc.)
newtype M1 i (c :: Meta) (f :: k -> Type) (p :: k) :: forall k. () => Type -> Meta -> k -> Type -> k -> Type
M1 :: f p -> M1 i
[unM1] :: M1 i -> f p

-- | Fields: used to represent each of the (visible) arguments to a
--   constructor. Replaces the <a>K1</a> type from <a>GHC.Generics</a>. The
--   type of the field is represented by an <a>Atom</a> from
--   <a>Data.PolyKinded.Atom</a>.
--   
--   <pre>
--   instance GenericK [] (a :&amp;&amp;: LoT0) where
--     type RepK [] = Field Var0 :*: Field ([] :$: Var0)
--   </pre>
newtype Field (t :: Atom d (*)) (x :: LoT d)
[Field] :: {unField :: Interpret t x} -> Field t x

-- | Constraints: used to represent constraints in a constructor. Replaces
--   the '(:=&gt;:)' type from <a>GHC.Generics.Extra</a>.
--   
--   <pre>
--   data Showable a = Show a =&gt; a -&gt; X a
--   
--   instance GenericK Showable (a :&amp;&amp;: LoT0) where
--     type RepK Showable = (Show :$: a) :=&gt;: (Field V0)
--   </pre>
data (:=>:) (c :: Atom d Constraint) (f :: LoT d -> *) (x :: LoT d)
[SuchThat] :: Interpret c x => f x -> (c :=>: f) x

-- | Existentials: a representation of the form <tt>E f</tt> describes a
--   constructor whose inner type is represented by <tt>f</tt>, and where
--   the type variable at index 0, <tt>V0</tt>, is existentially
--   quantified.
--   
--   <pre>
--   data E where
--    E :: t -&gt; Exists
--   
--   instance GenericK E LoT0 where
--     type RepK E = Exists (*) (Field Var0)
--   </pre>
data Exists k (f :: LoT (k -> d) -> *) (x :: LoT d)
[Exists] :: forall (t :: k) d (f :: LoT (k -> d) -> *) (x :: LoT d). {unExists :: f (t :&&: x)} -> Exists k f x

-- | Representable types of any kind. The definition of an instance must
--   mention the type constructor along with a list of types of the
--   corresponding length. For example:
--   
--   <pre>
--   instance GenericK Int    LoT0
--   instance GenericK []     (a :&amp;&amp;: LoT0)
--   instance GenericK Either (a :&amp;&amp;: b :&amp;&amp;: LoT0)
--   </pre>
class GenericK (f :: k) (x :: LoT k) where {
    type family RepK f :: LoT k -> *;
}

-- | Convert the data type to its representation.
fromK :: GenericK f x => (f :@@: x) -> RepK f x

-- | Convert the data type to its representation.
fromK :: (GenericK f x, Generic (f :@@: x), Conv (Rep (f :@@: x)) (RepK f) x) => (f :@@: x) -> RepK f x

-- | Convert from a representation to its corresponding data type.
toK :: GenericK f x => RepK f x -> f :@@: x

-- | Convert from a representation to its corresponding data type.
toK :: (GenericK f x, Generic (f :@@: x), Conv (Rep (f :@@: x)) (RepK f) x) => RepK f x -> f :@@: x
type GenericF t f x = (GenericK f x, x ~ (SplitF t f), t ~ (f :@@: x))
fromF :: forall f t x. GenericF t f x => t -> RepK f x
toF :: forall f t x. GenericF t f x => RepK f x -> t
type GenericN n t f x = (GenericK f x,  'TyEnv f x ~ (SplitN n t), t ~ (f :@@: x))
fromN :: forall n t f x. GenericN n t f x => t -> RepK f x
toN :: forall n t f x. GenericN n t f x => RepK f x -> t
fromRepK :: forall f x xs. (GenericK f (x :&&: xs), SubstRep' (RepK f) x xs) => (f x :@@: xs) -> SubstRep (RepK f) x xs
toRepK :: forall f x xs. (GenericK f (x :&&: xs), SubstRep' (RepK f) x xs) => SubstRep (RepK f) x xs -> f x :@@: xs
type family SubstRep f x :: LoT k -> *

-- | Bridges a representation of a data type using the combinators in
--   <a>GHC.Generics</a> with a representation using this module. You are
--   never expected to manipulate this type class directly, it is part of
--   the deriving mechanism for <a>GenericK</a>.
class Conv (gg :: * -> *) (kg :: LoT d -> *) (tys :: LoT d)
toGhcGenerics :: Conv gg kg tys => kg tys -> gg a
toKindGenerics :: Conv gg kg tys => gg a -> kg tys
instance forall d (t :: Data.PolyKinded.Atom.Atom d *) (x :: Data.PolyKinded.LoT d). GHC.Show.Show (Data.PolyKinded.Atom.Interpret t x) => GHC.Show.Show (Generics.Kind.Field t x)
instance forall d (c :: Data.PolyKinded.Atom.Atom d GHC.Types.Constraint) (x :: Data.PolyKinded.LoT d) (f :: Data.PolyKinded.LoT d -> *). (Data.PolyKinded.Atom.Interpret c x => GHC.Show.Show (f x)) => GHC.Show.Show ((Generics.Kind.:=>:) c f x)
instance forall d k (f :: Data.PolyKinded.LoT (k -> d) -> *) (x :: Data.PolyKinded.LoT d). (forall (t :: k). GHC.Show.Show (f (t 'Data.PolyKinded.:&&: x))) => GHC.Show.Show (Generics.Kind.Exists k f x)
instance forall d (tys :: Data.PolyKinded.LoT d). Generics.Kind.Conv GHC.Generics.U1 GHC.Generics.U1 tys
instance forall d (f :: * -> *) (f' :: Data.PolyKinded.LoT d -> *) (tys :: Data.PolyKinded.LoT d) (g :: * -> *) (g' :: Data.PolyKinded.LoT d -> *). (Generics.Kind.Conv f f' tys, Generics.Kind.Conv g g' tys) => Generics.Kind.Conv (f GHC.Generics.:+: g) (f' GHC.Generics.:+: g') tys
instance forall d (f :: * -> *) (f' :: Data.PolyKinded.LoT d -> *) (tys :: Data.PolyKinded.LoT d) (g :: * -> *) (g' :: Data.PolyKinded.LoT d -> *). (Generics.Kind.Conv f f' tys, Generics.Kind.Conv g g' tys) => Generics.Kind.Conv (f GHC.Generics.:*: g) (f' GHC.Generics.:*: g') tys
instance forall d (f :: * -> *) (f' :: Data.PolyKinded.LoT d -> *) (tys :: Data.PolyKinded.LoT d) i (c :: GHC.Generics.Meta). Generics.Kind.Conv f f' tys => Generics.Kind.Conv (GHC.Generics.M1 i c f) f' tys
instance forall d (f :: * -> *) (f' :: Data.PolyKinded.LoT d -> *) (tys :: Data.PolyKinded.LoT d) i (c :: GHC.Generics.Meta). Generics.Kind.Conv f f' tys => Generics.Kind.Conv (GHC.Generics.M1 i c f) (GHC.Generics.M1 i c f') tys
instance forall d (k :: GHC.Types.Constraint) (t :: Data.PolyKinded.Atom.Atom d GHC.Types.Constraint) (tys :: Data.PolyKinded.LoT d) (f :: * -> *) (f' :: Data.PolyKinded.LoT d -> *). (k Data.Type.Equality.~ Data.PolyKinded.Atom.Interpret t tys, Generics.Kind.Conv f f' tys) => Generics.Kind.Conv (k GHC.Generics.Extra.:=>: f) (t Generics.Kind.:=>: f') tys
instance forall d k (t :: Data.PolyKinded.Atom.Atom d *) (tys :: Data.PolyKinded.LoT d) p. (k Data.Type.Equality.~ Data.PolyKinded.Atom.Interpret t tys) => Generics.Kind.Conv (GHC.Generics.K1 p k) (Generics.Kind.Field t) tys
instance forall t k (c :: Data.PolyKinded.Atom.Atom (t -> k) GHC.Types.Constraint) (x :: t) (xs :: Data.PolyKinded.LoT k) (f :: Data.PolyKinded.LoT (t -> k) -> *). (Data.PolyKinded.Atom.Interpret (Generics.Kind.SubstAtom c x) xs, Data.PolyKinded.Atom.Interpret c (x 'Data.PolyKinded.:&&: xs), Generics.Kind.SubstRep' f x xs) => Generics.Kind.SubstRep' (c Generics.Kind.:=>: f) x xs
instance forall t1 k (t2 :: Data.PolyKinded.Atom.Atom (t1 -> k) *) (x :: t1) (xs :: Data.PolyKinded.LoT k). (Data.PolyKinded.Atom.Interpret (Generics.Kind.SubstAtom t2 x) xs Data.Type.Equality.~ Data.PolyKinded.Atom.Interpret t2 (x 'Data.PolyKinded.:&&: xs)) => Generics.Kind.SubstRep' (Generics.Kind.Field t2) x xs
instance forall k t (x :: t) (xs :: Data.PolyKinded.LoT k). Generics.Kind.SubstRep' GHC.Generics.U1 x xs
instance forall t k (f :: Data.PolyKinded.LoT (t -> k) -> *) (x :: t) (xs :: Data.PolyKinded.LoT k) (g :: Data.PolyKinded.LoT (t -> k) -> *). (Generics.Kind.SubstRep' f x xs, Generics.Kind.SubstRep' g x xs) => Generics.Kind.SubstRep' (f GHC.Generics.:+: g) x xs
instance forall t k (f :: Data.PolyKinded.LoT (t -> k) -> *) (x :: t) (xs :: Data.PolyKinded.LoT k) (g :: Data.PolyKinded.LoT (t -> k) -> *). (Generics.Kind.SubstRep' f x xs, Generics.Kind.SubstRep' g x xs) => Generics.Kind.SubstRep' (f GHC.Generics.:*: g) x xs
instance forall t k (f :: Data.PolyKinded.LoT (t -> k) -> *) (x :: t) (xs :: Data.PolyKinded.LoT k) i (c :: GHC.Generics.Meta). Generics.Kind.SubstRep' f x xs => Generics.Kind.SubstRep' (GHC.Generics.M1 i c f) x xs

module Generics.Kind.Examples
data Tree a
Branch :: Tree a -> Tree a -> Tree a
Leaf :: a -> Tree a
data family HappyFamily t
data SimpleIndex :: * -> * -> *
[MkSimpleIndex] :: [a] -> SimpleIndex [a] b
data WeirdTree a
[WeirdBranch] :: WeirdTree a -> WeirdTree a -> WeirdTree a
[WeirdLeaf] :: Show a => t -> a -> WeirdTree a
data WeirdTreeR a
[WeirdBranchR] :: WeirdTreeR a -> WeirdTreeR a -> WeirdTreeR a
[WeirdLeafR] :: (Show a, Eq t, Typeable t) => t -> a -> WeirdTreeR a
data T (a :: k)
[MkT] :: forall (a :: *). Maybe a -> T a
data P k (a :: k)
[P] :: forall k (a :: k). P k a
data P' j (a :: k)
[P'] :: forall k (a :: k). P' k a
data Ranky
MkRanky :: (forall a. a -> a) -> Ranky
newtype Ranky2 b
MkRanky2 :: ((forall a. a -> a) -> b) -> Ranky2 b
data Shower a
[MkShower] :: (Show a => a -> String) -> Shower a
data Unboxed1
MkUnboxed1 :: (# Int, Int #) -> Unboxed1
instance GHC.Generics.Generic (Generics.Kind.Examples.Tree a)
instance Generics.Kind.GenericK Generics.Kind.Examples.Shower (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK Generics.Kind.Examples.Ranky2 (b 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK Generics.Kind.Examples.Ranky 'Data.PolyKinded.LoT0
instance forall k j (a :: k). Generics.Kind.GenericK (Generics.Kind.Examples.P' j) (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance forall k j (a :: k). Generics.Kind.GenericK Generics.Kind.Examples.P' (j 'Data.PolyKinded.:&&: (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0))
instance forall k (a :: k). Generics.Kind.GenericK (Generics.Kind.Examples.P k) (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance forall k (a :: k). Generics.Kind.GenericK Generics.Kind.Examples.T (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK Generics.Kind.Examples.WeirdTreeR (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK (Generics.Kind.Examples.WeirdTreeR a) 'Data.PolyKinded.LoT0
instance Generics.Kind.GenericK Generics.Kind.Examples.WeirdTree (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK Generics.Kind.Examples.SimpleIndex (a 'Data.PolyKinded.:&&: (b 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0))
instance Generics.Kind.GenericK (Generics.Kind.Examples.SimpleIndex a) (b 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK (Generics.Kind.Examples.SimpleIndex a b) 'Data.PolyKinded.LoT0
instance Generics.Kind.GenericK Generics.Kind.Examples.HappyFamily (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK (Generics.Kind.Examples.HappyFamily (GHC.Maybe.Maybe a)) 'Data.PolyKinded.LoT0
instance Generics.Kind.GenericK (Generics.Kind.Examples.HappyFamily [a]) 'Data.PolyKinded.LoT0
instance Generics.Kind.GenericK Generics.Kind.Examples.Tree (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK (Generics.Kind.Examples.Tree a) 'Data.PolyKinded.LoT0
instance Generics.Kind.GenericK GHC.Maybe.Maybe (a 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK (GHC.Maybe.Maybe a) 'Data.PolyKinded.LoT0
instance Generics.Kind.GenericK Data.Either.Either (a 'Data.PolyKinded.:&&: (b 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0))
instance Generics.Kind.GenericK (Data.Either.Either a) (b 'Data.PolyKinded.:&&: 'Data.PolyKinded.LoT0)
instance Generics.Kind.GenericK (Data.Either.Either a b) 'Data.PolyKinded.LoT0
