Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Main module of kind-generics
. Please refer to the README
file for documentation on how to use this package.
Synopsis
- data ((f :: k -> Type) :+: (g :: k -> Type)) (p :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type
- data ((f :: k -> Type) :*: (g :: k -> Type)) (p :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type = (f p) :*: (g p)
- data U1 (p :: k) :: forall k. k -> Type = U1
- newtype M1 i (c :: Meta) (f :: k -> Type) (p :: k) :: forall k. Type -> Meta -> (k -> Type) -> k -> Type = M1 {
- unM1 :: f p
- newtype F (t :: Atom d *) (x :: LoT d) = F {
- unF :: Ty t x
- data ((c :: Atom d Constraint) :=>: (f :: LoT d -> *)) (x :: LoT d) where
- data E (f :: LoT (k -> d) -> *) (x :: LoT d) where
- class GenericK (f :: k) (x :: LoT k) where
- 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
- type GenericS t f x = (Split t f x, GenericK f x)
- fromS :: forall t f x. GenericS t f x => t -> RepK f x
- toS :: forall t f x. GenericS t f x => RepK f x -> t
- class Conv (gg :: * -> *) (kg :: LoT d -> *) (tys :: LoT d) where
- toGhcGenerics :: kg tys -> gg a
- toKindGenerics :: gg a -> kg tys
Generic representation types
data ((f :: k -> Type) :+: (g :: k -> Type)) (p :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type infixr 5 #
Sums: encode choice between constructors
Instances
Generic1 (f :+: g :: k -> Type) | |
(GEq f tys, GEq g tys) => GEq (f :+: g :: LoT k -> Type) (tys :: LoT k) Source # | |
(GFunctor f v as bs, GFunctor g v as bs) => GFunctor (f :+: g :: LoT k -> Type) v (as :: LoT k) (bs :: LoT k) Source # | |
(Conv f f' tys, Conv g g' tys) => Conv (f :+: g) (f' :+: g' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: (f' :+: g') tys -> (f :+: g) a Source # toKindGenerics :: (f :+: g) a -> (f' :+: g') tys Source # | |
(Functor f, Functor g) => Functor (f :+: g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (f :+: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => (f :+: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldr1 :: (a -> a -> a) -> (f :+: g) a -> a # foldl1 :: (a -> a -> a) -> (f :+: g) a -> a # toList :: (f :+: g) a -> [a] # length :: (f :+: g) a -> Int # elem :: Eq a => a -> (f :+: g) a -> Bool # maximum :: Ord a => (f :+: g) a -> a # minimum :: Ord a => (f :+: g) a -> a # | |
(Traversable f, Traversable g) => Traversable (f :+: g) | Since: base-4.9.0.0 |
(Eq (f p), Eq (g p)) => Eq ((f :+: g) p) | Since: base-4.7.0.0 |
(Ord (f p), Ord (g p)) => Ord ((f :+: g) p) | Since: base-4.7.0.0 |
(Read (f p), Read (g p)) => Read ((f :+: g) p) | Since: base-4.7.0.0 |
(Show (f p), Show (g p)) => Show ((f :+: g) p) | Since: base-4.7.0.0 |
Generic ((f :+: g) p) | |
type Rep1 (f :+: g :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics type Rep1 (f :+: g :: k -> Type) = D1 (MetaData ":+:" "GHC.Generics" "base" False) (C1 (MetaCons "L1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 f)) :+: C1 (MetaCons "R1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 g))) | |
type Rep ((f :+: g) p) | Since: base-4.7.0.0 |
Defined in GHC.Generics type Rep ((f :+: g) p) = D1 (MetaData ":+:" "GHC.Generics" "base" False) (C1 (MetaCons "L1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f p))) :+: C1 (MetaCons "R1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g p)))) |
data ((f :: k -> Type) :*: (g :: k -> Type)) (p :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type infixr 6 #
Products: encode multiple arguments to constructors
(f p) :*: (g p) infixr 6 |
Instances
Generic1 (f :*: g :: k -> Type) | |
(GEq f tys, GEq g tys) => GEq (f :*: g :: LoT k -> Type) (tys :: LoT k) Source # | |
(GFunctor f v as bs, GFunctor g v as bs) => GFunctor (f :*: g :: LoT k -> Type) v (as :: LoT k) (bs :: LoT k) Source # | |
(Conv f f' tys, Conv g g' tys) => Conv (f :*: g) (f' :*: g' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: (f' :*: g') tys -> (f :*: g) a Source # toKindGenerics :: (f :*: g) a -> (f' :*: g') tys Source # | |
(Monad f, Monad g) => Monad (f :*: g) | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :*: g) | Since: base-4.9.0.0 |
(Applicative f, Applicative g) => Applicative (f :*: g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (f :*: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => (f :*: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldr1 :: (a -> a -> a) -> (f :*: g) a -> a # foldl1 :: (a -> a -> a) -> (f :*: g) a -> a # toList :: (f :*: g) a -> [a] # length :: (f :*: g) a -> Int # elem :: Eq a => a -> (f :*: g) a -> Bool # maximum :: Ord a => (f :*: g) a -> a # minimum :: Ord a => (f :*: g) a -> a # | |
(Traversable f, Traversable g) => Traversable (f :*: g) | Since: base-4.9.0.0 |
(Alternative f, Alternative g) => Alternative (f :*: g) | Since: base-4.9.0.0 |
(MonadPlus f, MonadPlus g) => MonadPlus (f :*: g) | Since: base-4.9.0.0 |
(Eq (f p), Eq (g p)) => Eq ((f :*: g) p) | Since: base-4.7.0.0 |
(Ord (f p), Ord (g p)) => Ord ((f :*: g) p) | Since: base-4.7.0.0 |
(Read (f p), Read (g p)) => Read ((f :*: g) p) | Since: base-4.7.0.0 |
(Show (f p), Show (g p)) => Show ((f :*: g) p) | Since: base-4.7.0.0 |
Generic ((f :*: g) p) | |
(Semigroup (f p), Semigroup (g p)) => Semigroup ((f :*: g) p) | Since: base-4.12.0.0 |
(Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) | Since: base-4.12.0.0 |
type Rep1 (f :*: g :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics type Rep1 (f :*: g :: k -> Type) = D1 (MetaData ":*:" "GHC.Generics" "base" False) (C1 (MetaCons ":*:" (InfixI RightAssociative 6) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 f) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 g))) | |
type Rep ((f :*: g) p) | Since: base-4.7.0.0 |
Defined in GHC.Generics type Rep ((f :*: g) p) = D1 (MetaData ":*:" "GHC.Generics" "base" False) (C1 (MetaCons ":*:" (InfixI RightAssociative 6) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f p)) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g p)))) |
data U1 (p :: k) :: forall k. k -> Type #
Unit: used for constructors without arguments
Instances
Generic1 (U1 :: k -> Type) | |
GEq (U1 :: LoT k -> Type) (tys :: LoT k) Source # | |
GFunctor (U1 :: LoT k -> Type) v (as :: LoT k) (bs :: LoT k) Source # | |
Conv (U1 :: Type -> Type) (U1 :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: U1 tys -> U1 a Source # toKindGenerics :: U1 a -> U1 tys Source # | |
Monad (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Functor (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Applicative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => U1 m -> m # foldMap :: Monoid m => (a -> m) -> U1 a -> m # foldr :: (a -> b -> b) -> b -> U1 a -> b # foldr' :: (a -> b -> b) -> b -> U1 a -> b # foldl :: (b -> a -> b) -> b -> U1 a -> b # foldl' :: (b -> a -> b) -> b -> U1 a -> b # foldr1 :: (a -> a -> a) -> U1 a -> a # foldl1 :: (a -> a -> a) -> U1 a -> a # elem :: Eq a => a -> U1 a -> Bool # maximum :: Ord a => U1 a -> a # | |
Traversable (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Alternative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
MonadPlus (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Eq (U1 p) | Since: base-4.9.0.0 |
Ord (U1 p) | Since: base-4.7.0.0 |
Read (U1 p) | Since: base-4.9.0.0 |
Show (U1 p) | Since: base-4.9.0.0 |
Generic (U1 p) | |
Semigroup (U1 p) | Since: base-4.12.0.0 |
Monoid (U1 p) | Since: base-4.12.0.0 |
type Rep1 (U1 :: k -> Type) | Since: base-4.9.0.0 |
type Rep (U1 p) | Since: base-4.7.0.0 |
newtype M1 i (c :: Meta) (f :: k -> Type) (p :: k) :: forall k. Type -> Meta -> (k -> Type) -> k -> Type #
Meta-information (constructor names, etc.)
Instances
Generic1 (M1 i c f :: k -> Type) | |
GEq f tys => GEq (M1 i c f :: LoT k -> Type) (tys :: LoT k) Source # | |
Conv f f' tys => Conv (M1 i c f) (f' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: f' tys -> M1 i c f a Source # toKindGenerics :: M1 i c f a -> f' tys Source # | |
GFunctor f v as bs => GFunctor (M1 i c f :: LoT k -> Type) v (as :: LoT k) (bs :: LoT k) Source # | |
Conv f f' tys => Conv (M1 i c f) (M1 i c f' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: M1 i c f' tys -> M1 i c f a Source # toKindGenerics :: M1 i c f a -> M1 i c f' tys Source # | |
Monad f => Monad (M1 i c f) | Since: base-4.9.0.0 |
Functor f => Functor (M1 i c f) | Since: base-4.9.0.0 |
Applicative f => Applicative (M1 i c f) | Since: base-4.9.0.0 |
Foldable f => Foldable (M1 i c f) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => M1 i c f m -> m # foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m # foldr :: (a -> b -> b) -> b -> M1 i c f a -> b # foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b # foldl :: (b -> a -> b) -> b -> M1 i c f a -> b # foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b # foldr1 :: (a -> a -> a) -> M1 i c f a -> a # foldl1 :: (a -> a -> a) -> M1 i c f a -> a # elem :: Eq a => a -> M1 i c f a -> Bool # maximum :: Ord a => M1 i c f a -> a # minimum :: Ord a => M1 i c f a -> a # | |
Traversable f => Traversable (M1 i c f) | Since: base-4.9.0.0 |
Alternative f => Alternative (M1 i c f) | Since: base-4.9.0.0 |
MonadPlus f => MonadPlus (M1 i c f) | Since: base-4.9.0.0 |
Eq (f p) => Eq (M1 i c f p) | Since: base-4.7.0.0 |
Ord (f p) => Ord (M1 i c f p) | Since: base-4.7.0.0 |
Read (f p) => Read (M1 i c f p) | Since: base-4.7.0.0 |
Show (f p) => Show (M1 i c f p) | Since: base-4.7.0.0 |
Generic (M1 i c f p) | |
Semigroup (f p) => Semigroup (M1 i c f p) | Since: base-4.12.0.0 |
Monoid (f p) => Monoid (M1 i c f p) | Since: base-4.12.0.0 |
type Rep1 (M1 i c f :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (M1 i c f p) | Since: base-4.7.0.0 |
Defined in GHC.Generics |
newtype F (t :: Atom d *) (x :: LoT d) Source #
Fields: used to represent each of the (visible) arguments to a constructor.
Replaces the K1
type from GHC.Generics. The type of the field is
represented by an Atom
from Data.PolyKinded.Atom.
instance GenericK [] (a :&&: LoT0) where type RepK [] = F V0 :*: F ([] :$: V0)
Instances
Eq (Ty t tys) => GEq (F t :: LoT k -> Type) (tys :: LoT k) Source # | |
GFunctorArg t v Co as bs => GFunctor (F t :: LoT k -> Type) v (as :: LoT k) (bs :: LoT k) Source # | |
k ~ Ty t tys => Conv (K1 p k :: Type -> Type) (F t :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: F t tys -> K1 p k a Source # toKindGenerics :: K1 p k a -> F t tys Source # | |
Show (Ty t x) => Show (F t x) Source # | |
data ((c :: Atom d Constraint) :=>: (f :: LoT d -> *)) (x :: LoT d) where Source #
Constraints: used to represent constraints in a constructor. Replaces the '(:=>:)' type from GHC.Generics.Extra.
data Showable a = Show a => a -> X a instance GenericK Showable (a :&&: LoT0) where type RepK Showable = (Show :$: a) :=>: (F V0)
Instances
Ty c tys -> GEq f tys => GEq (c :=>: f :: LoT k -> Type) (tys :: LoT k) Source # | |
(Ty c as -> GFunctor f v as bs, Ty c bs) => GFunctor (c :=>: f :: LoT k -> Type) v (as :: LoT k) (bs :: LoT k) Source # | |
(k ~ Ty t tys, Conv f f' tys) => Conv (k :=>: f) (t :=>: f' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: (t :=>: f') tys -> (k :=>: f) a Source # toKindGenerics :: (k :=>: f) a -> (t :=>: f') tys Source # |
data E (f :: LoT (k -> d) -> *) (x :: LoT d) where Source #
Existentials: a representation of the form E f
describes
a constructor whose inner type is represented by f
, and where
the type variable at index 0, V0
, is existentially quantified.
data Exists where E :: t -> Exists instance GenericK Exists LoT0 where type RepK Exists = E (F V0)
Generic type classes
class GenericK (f :: k) (x :: LoT k) where Source #
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:
instance GenericK Int LoT0 instance GenericK [] (a :&&: LoT0) instance GenericK Either (a :&&: b :&&: LoT0)
Nothing
fromK :: (f :@@: x) -> RepK f x Source #
Convert the data type to its representation.
fromK :: (Generic (f :@@: x), Conv (Rep (f :@@: x)) (RepK f) x) => (f :@@: x) -> RepK f x Source #
Convert the data type to its representation.
toK :: RepK f x -> f :@@: x Source #
Convert from a representation to its corresponding data type.
toK :: (Generic (f :@@: x), Conv (Rep (f :@@: x)) (RepK f) x) => RepK f x -> f :@@: x Source #
Convert from a representation to its corresponding data type.
type GenericS t f x = (Split t f x, GenericK f x) Source #
GenericS t f x
states that the ground type t
is split by
default as the constructor f
and a list of types @x$, and that
a GenericK
instance exists for that constructor.
This constraint provides an external interface similar to that
provided by Generic
in GHC.Generics.
Bridging with GHC.Generics
class Conv (gg :: * -> *) (kg :: LoT d -> *) (tys :: LoT d) where Source #
Bridges a representation of a data type using the combinators
in GHC.Generics with a representation using this module.
You are never expected to manipulate this type class directly,
it is part of the deriving mechanism for GenericK
.
toGhcGenerics :: kg tys -> gg a Source #
toKindGenerics :: gg a -> kg tys Source #
Instances
Conv (U1 :: Type -> Type) (U1 :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: U1 tys -> U1 a Source # toKindGenerics :: U1 a -> U1 tys Source # | |
k ~ Ty t tys => Conv (K1 p k :: Type -> Type) (F t :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: F t tys -> K1 p k a Source # toKindGenerics :: K1 p k a -> F t tys Source # | |
(k ~ Ty t tys, Conv f f' tys) => Conv (k :=>: f) (t :=>: f' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: (t :=>: f') tys -> (k :=>: f) a Source # toKindGenerics :: (k :=>: f) a -> (t :=>: f') tys Source # | |
(Conv f f' tys, Conv g g' tys) => Conv (f :*: g) (f' :*: g' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: (f' :*: g') tys -> (f :*: g) a Source # toKindGenerics :: (f :*: g) a -> (f' :*: g') tys Source # | |
(Conv f f' tys, Conv g g' tys) => Conv (f :+: g) (f' :+: g' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: (f' :+: g') tys -> (f :+: g) a Source # toKindGenerics :: (f :+: g) a -> (f' :+: g') tys Source # | |
Conv f f' tys => Conv (M1 i c f) (f' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: f' tys -> M1 i c f a Source # toKindGenerics :: M1 i c f a -> f' tys Source # | |
Conv f f' tys => Conv (M1 i c f) (M1 i c f' :: LoT d -> Type) (tys :: LoT d) Source # | |
Defined in Generics.Kind toGhcGenerics :: M1 i c f' tys -> M1 i c f a Source # toKindGenerics :: M1 i c f a -> M1 i c f' tys Source # |